パッケージ jakarta.ws.rs

アノテーション型 NameBinding


  • @TargetSE(ANNOTATION_TYPESE)
    @RetentionSE(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 {
          ...
      }
     
    最後に、名前バインディングアノテーションが、名前バインド JAX-RS プロバイダーをバインドする必要のあるリソースメソッドに適用されます。
      @Path("/")
      public class MyResourceClass {
          @GET
          @Produces("text/plain")
          @Path("{name}")
          @Logged
          public String hello(@PathParam("name") String name) {
              return "Hello " + name;
          }
      }
     
    名前バインディングアノテーションは、カスタム JAX-RS Application サブクラスに添付することもできます。このような場合、アノテーションによってバインドされた名前にバインドされた JAX-RS プロバイダーは、JAX-RS アプリケーションのすべての resource and sub-resource methods に適用されます。
      @Logged
      @ApplicationPath("myApp")
      public class MyApplication extends jakarta.ws.rs.core.Application {
          ...
      }
     
    導入:
    2.0
    作成者:
    Santiago Pericas-Geertsen, Marek Potociar