@TargetSE(valueSE=ANNOTATION_TYPESE) @RetentionSE(valueSE=RUNTIMESE) @DocumentedSE public @interface NameBinding
アノテーションによる名前バインディングは、サーバー API の一部としてのみサポートされています。名前バインディングでは、 名前バインディングアノテーションは最初に @NameBinding メタアノテーションを使用して定義されます。
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(value = RetentionPolicy.RUNTIME)
@NameBinding
public @interface Logged { }
次に、定義された名前バインディングアノテーションを使用して、フィルターまたはインターセプタークラスを装飾します(複数のフィルターまたはインターセプターを同じ名前バインディングアノテーションで装飾できます)。
@Logged
public class LoggingFilter
implements ContainerRequestFilter, ContainerResponseFilter {
...
}
最後に、名前バインディングアノテーションは、名前バインドプロバイダーがバインドされる必要があるリソースメソッドに適用されます。
@Path("/")
public class MyResourceClass {
@GET
@Produces("text/plain")
@Path("{name}")
@Logged
public String hello(@PathParam("name") String name) {
return "Hello " + name;
}
}
名前バインディングアノテーションは、カスタム Application サブクラスに添付することもできます。このような場合、アノテーションによってバインドされた名前にバインドされたプロバイダーは、アプリケーション内のすべての resource and sub-resource methods に適用されます。
@Logged
@ApplicationPath("myApp")
public class MyApplication extends javax.ws.rs.core.Application {
...
}
Copyright © 2019 Eclipse Foundation.
Use is subject to license terms.