Skip to content

Commit fd9b98e

Browse files
committed
Javadocs
1 parent 2ec62c0 commit fd9b98e

8 files changed

Lines changed: 206 additions & 0 deletions

File tree

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/Convert.java‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,69 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.ocpsoft.rewrite.bind.Converter;
26+
27+
/**
28+
* <p>
29+
* Tells Rewrite to use a converter to convert the value of a specific parameter binding.
30+
* </p>
31+
*
32+
* There are various ways to specify the kind of converter you want to use. You could for example reference a converter
33+
* class this way:
34+
*
35+
* <pre>
36+
* {@literal @}ParameterBinding
37+
* {@literal @}Convert(with = MyLocaleConverter.class)
38+
* private Locale locale;
39+
* </pre>
40+
*
41+
* <p>
42+
* You can always refer to {@link Converter} implementations this way. Integration modules like the JSF integration
43+
* module provide support for frameworks specific converters on top of that.
44+
* </p>
45+
*
46+
* <p>
47+
* You can also refer to a converter using an unique ID like this:
48+
* </p>
49+
*
50+
* <pre>
51+
* {@literal @}ParameterBinding
52+
* {@literal @}Convert(id = "com.example.MyConverterId")
53+
* private Locale locale;
54+
* </pre>
55+
*
56+
* <p>
57+
* Without any attributes set, Rewrite will try to find a converter by the type of the annotated field.
58+
* </p>
59+
*
60+
* <pre>
61+
* {@literal @}ParameterBinding
62+
* {@literal @}Convert
63+
* private Locale locale;
64+
* </pre>
65+
*
66+
* <p>
67+
* Please note that which of the three ways works in your case highly depends on the integration modules that you have
68+
* added to your application.
69+
* </p>
70+
*
71+
* @author Christian Kaltepoth
72+
*/
2573
@Inherited
2674
@Documented
2775
@Target(ElementType.FIELD)
2876
@Retention(RetentionPolicy.RUNTIME)
2977
public @interface Convert
3078
{
79+
80+
/**
81+
* Can be used to refer to a converter class that should be used for conversion.
82+
*/
3183
Class<?> with() default Object.class;
3284

85+
/**
86+
* Can be used to refer to a converter by some kind of unique ID.
87+
*/
3388
String id() default "";
89+
3490
}

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/ForwardTo.java‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,34 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.ocpsoft.rewrite.servlet.config.Forward;
26+
27+
/**
28+
* <p>
29+
* Adds a {@link Forward} operation to the current rule. This operation will perform a Servlet forward to the specified
30+
* path.
31+
* </p>
32+
*
33+
* <pre>
34+
* {@literal @}PathPattern("/login")
35+
* {@literal @}Forward("/login-page.html")
36+
* public class MyClass {
37+
*
38+
* }
39+
* </pre>
40+
*
41+
* @author Christian Kaltepoth
42+
*/
2543
@Inherited
2644
@Documented
2745
@Target(ElementType.TYPE)
2846
@Retention(RetentionPolicy.RUNTIME)
2947
public @interface ForwardTo
3048
{
49+
50+
/**
51+
* The path to forward the request to. The path is relative to the context path.
52+
*/
3153
String value();
54+
3255
}

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/Hostname.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,36 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.ocpsoft.rewrite.servlet.config.Domain;
26+
27+
/**
28+
* <p>
29+
* Adds a {@link Domain} condition to the current rule. This allows to restrict the rule to a specific hostname or to
30+
* bind a substring of the hostname to a bean property.
31+
* </p>
32+
*
33+
* <pre>
34+
* {@literal @}Hostname("{lang}.example.com")
35+
* {@literal @}Join(path = "/something", to = "/some-page.html")
36+
* public class MyClass {
37+
*
38+
* {@literal @}ParameterBinding
39+
* private String lang;
40+
*
41+
* }
42+
* </pre>
43+
*
44+
* @author Christian Kaltepoth
45+
*/
2546
@Inherited
2647
@Documented
2748
@Target(ElementType.TYPE)
2849
@Retention(RetentionPolicy.RUNTIME)
2950
public @interface Hostname
3051
{
52+
53+
/**
54+
* The pattern used for matching the hostname.
55+
*/
3156
String value();
3257
}

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/MappingId.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,23 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.ocpsoft.rewrite.config.RuleBuilder;
26+
27+
/**
28+
* Sets the ID of the current rule. Same as calling {@link RuleBuilder#withId(String)}.
29+
*
30+
* @author Christian Kaltepoth
31+
*/
2532
@Inherited
2633
@Documented
2734
@Target(ElementType.TYPE)
2835
@Retention(RetentionPolicy.RUNTIME)
2936
public @interface MappingId
3037
{
38+
39+
/**
40+
* The ID of the rule.
41+
*/
3142
String value();
43+
3244
}

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/ParameterBinding.java‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,45 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.ocpsoft.rewrite.bind.Binding;
26+
27+
/**
28+
* Registers a {@link Binding} for a parameter. This annotation can be used to bind a parameter to a bean property.
29+
*
30+
* <pre>
31+
* {@literal @}Join(path = "/user/{id}", to = "/user-details.html")
32+
* public class MyClass {
33+
*
34+
* {@literal @}ParameterBinding
35+
* private String id;
36+
*
37+
* }
38+
* </pre>
39+
*
40+
* Please note that you have to specify the parameter name manually if it differs from the field name.
41+
*
42+
* <pre>
43+
* {@literal @}Join(path = "/user/{id}", to = "/user-details.html")
44+
* public class MyClass {
45+
*
46+
* {@literal @}ParameterBinding("id")
47+
* private String userId;
48+
*
49+
* }
50+
* </pre>
51+
*
52+
* @author Christian Kaltepoth
53+
*/
2554
@Inherited
2655
@Documented
2756
@Target(ElementType.FIELD)
2857
@Retention(RetentionPolicy.RUNTIME)
2958
public @interface ParameterBinding
3059
{
60+
61+
/**
62+
* The name of the parameter. If the attribute is not set, the name of the annotated field is used.
63+
*/
3164
String value() default "";
65+
3266
}

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/Priority.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,23 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.ocpsoft.rewrite.config.RuleBuilder;
26+
27+
/**
28+
* Sets the priority of the current rule. Same as calling {@link RuleBuilder#withPriority(int)}.
29+
*
30+
* @author Christian Kaltepoth
31+
*/
2532
@Inherited
2633
@Documented
2734
@Target(ElementType.TYPE)
2835
@Retention(RetentionPolicy.RUNTIME)
2936
public @interface Priority
3037
{
38+
39+
/**
40+
* The priority of the rule.
41+
*/
3142
int value();
43+
3244
}

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/RequestAction.java‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import org.ocpsoft.rewrite.config.Invoke;
26+
27+
/**
28+
* Adds an {@link Invoke} to the current rule. This will invoke the annotated method if the rule matches.
29+
*
30+
* <pre>
31+
* {@literal @}Join(path = "/user/{id}", to = "/user-details.html")
32+
* public class MyClass {
33+
*
34+
* {@literal @}RequestAction
35+
* public void loadData() {
36+
* // do something
37+
* }
38+
*
39+
* }
40+
* </pre>
41+
*
42+
* @author Christian Kaltepoth
43+
*/
2544
@Inherited
2645
@Documented
2746
@Target(ElementType.METHOD)

‎config-annotations/src/main/java/org/ocpsoft/rewrite/annotation/RolesRequired.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,36 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25+
import javax.servlet.http.HttpServletRequest;
26+
27+
import org.ocpsoft.rewrite.servlet.config.JAASRoles;
28+
29+
/**
30+
* <p>
31+
* Adds a {@link JAASRoles} condition to the current rule. This allows to restrict the rule to users with the given
32+
* role. Rewrite uses {@link HttpServletRequest#isUserInRole(String)} for checking the roles.
33+
* </p>
34+
*
35+
* <pre>
36+
* {@literal @}Join(path = "/admin/users", to = "/admin/user-list.html")
37+
* {@literal @}RolesRequired("admin")
38+
* public class MyClass {
39+
*
40+
* }
41+
* </pre>
42+
*
43+
* @author Christian Kaltepoth
44+
*/
2545
@Inherited
2646
@Documented
2747
@Target(ElementType.TYPE)
2848
@Retention(RetentionPolicy.RUNTIME)
2949
public @interface RolesRequired
3050
{
51+
52+
/**
53+
* The roles required for the rule to match.
54+
*/
3155
String[] value();
56+
3257
}

0 commit comments

Comments
 (0)