Skip to content

Commit fbbfaa4

Browse files
committed
Added @hostname annotation
1 parent c47b698 commit fbbfaa4

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.ocpsoft.prettyfaces.annotation;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.ElementType;
5+
import java.lang.annotation.Inherited;
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.RetentionPolicy;
8+
import java.lang.annotation.Target;
9+
10+
@Inherited
11+
@Documented
12+
@Target(ElementType.TYPE)
13+
@Retention(RetentionPolicy.RUNTIME)
14+
public @interface Hostname
15+
{
16+
String value();
17+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.ocpsoft.prettyfaces.annotation.handlers;
2+
3+
import java.lang.reflect.AnnotatedElement;
4+
5+
import org.ocpsoft.prettyfaces.annotation.Hostname;
6+
import org.ocpsoft.rewrite.annotation.api.ClassContext;
7+
import org.ocpsoft.rewrite.annotation.spi.AnnotationHandler;
8+
import org.ocpsoft.rewrite.config.ConditionBuilder;
9+
import org.ocpsoft.rewrite.servlet.config.Domain;
10+
11+
public class HostnameHandler implements AnnotationHandler<Hostname>
12+
{
13+
14+
@Override
15+
public Class<Hostname> handles()
16+
{
17+
return Hostname.class;
18+
}
19+
20+
@Override
21+
public void process(ClassContext context, AnnotatedElement element, Hostname annotation)
22+
{
23+
Domain domain = Domain.matches(annotation.value());
24+
ConditionBuilder condition = context.getRuleBuilder().getConditionBuilder().and(domain);
25+
context.getRuleBuilder().when(condition);
26+
}
27+
}

‎annotations/src/main/resources/META-INF/services/org.ocpsoft.rewrite.annotation.spi.AnnotationHandler‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ org.ocpsoft.prettyfaces.annotation.handlers.URLActionHandler
88
org.ocpsoft.prettyfaces.annotation.handlers.JSFConverterHandler
99
org.ocpsoft.prettyfaces.annotation.handlers.RolesRequiredHandler
1010
org.ocpsoft.prettyfaces.annotation.handlers.QueryParameterBindingHandler
11-
org.ocpsoft.prettyfaces.annotation.handlers.JoinHandler
11+
org.ocpsoft.prettyfaces.annotation.handlers.JoinHandler
12+
org.ocpsoft.prettyfaces.annotation.handlers.HostnameHandler

0 commit comments

Comments
 (0)