All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.juneau.http.annotation.Request Maven / Gradle / Ivy

// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
// * with the License.  You may obtain a copy of the License at                                                              *
// *                                                                                                                         *
// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
// *                                                                                                                         *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
// * specific language governing permissions and limitations under the License.                                              *
// ***************************************************************************************************************************
package org.apache.juneau.http.annotation;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;

import java.lang.annotation.*;

import org.apache.juneau.annotation.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.oapi.*;

/**
 * Request bean annotation.
 *
 * 

* Identifies an interface to use to interact with HTTP parts of an HTTP request through a bean. * *

* Can be used in the following locations: *

    *
  • Arguments and argument-types of server-side @RestOp-annotated methods. *
  • Arguments and argument-types of client-side @RemoteResource-annotated interfaces. *
* *
Arguments and argument-types of server-side @RestOp-annotated methods
*

* Annotation that can be applied to a parameter of a @RestOp-annotated method to identify it as an interface for retrieving HTTP parts through a bean interface. * *

Example:
*

* @RestGet("/mypath/{p1}/{p2}/*") * public void myMethod(@Request MyRequest requestBean) {...} * * public interface MyRequest { * * @Path // Path variable name inferred from getter. * String getP1(); * * @Path("p2") * String getX(); * * @Path("/*") * String getRemainder(); * * @Query * String getQ1(); * * // Schema-based query parameter: Pipe-delimited lists of comma-delimited lists of integers. * @Query( * collectionFormat="pipes" * items=@Items( * items=@SubItems( * collectionFormat="csv" * type="integer" * ) * ) * ) * int[][] getQ3(); * * @Header("*") * Map<String,Object> getHeaders(); *

*

* // Same as above but annotation defined on interface. * @RestGet(path="/mypath/{p1}/{p2}/*") * public void myMethod(MyRequest requestBean) {...} * * @Request * public interface MyRequest {...} * *

* The return types of the getters must be the supported parameter types for the HTTP-part annotation used. *
Schema-based serialization and parsing is allowed just as if used as individual parameter types. * *

See Also:
    *
* *
Arguments and argument-types of client-side @RemoteResource-annotated interfaces
*

* Annotation applied to Java method arguments of interface proxies to denote a bean with remote resource annotations. * *

Example:
*

* @RemoteResource(path="/myproxy") * public interface MyProxy { * * @RemoteGet("/mymethod/{p1}/{p2}") * String myProxyMethod(@Request MyRequest requestBean); * } * * public class MyRequest { * * @Path // Path variable name inferred from getter. * public String getP1() {...} * * @Path("p2") * public String getX() {...} * * @Path("/*") * public String getRemainder() {...} * * @Query * public String getQ1() {...} * * // Schema-based query parameter: Pipe-delimited lists of comma-delimited lists of integers. * @Query( * schema=@Query( * collectionFormat="pipes" * items=@Items( * items=@SubItems( * collectionFormat="csv" * type="integer" * ) * ) * ) * ) * public int[][] getQ3() {...} * * @Header("*") * public Map<String,Object> getHeaders() {...} * } *

* *
See Also:
*

*

See Also:
    *
*/ @Documented @Target({PARAMETER,TYPE,METHOD}) @Retention(RUNTIME) @Inherited @Repeatable(RequestAnnotation.Array.class) @ContextApply(RequestAnnotation.Applier.class) public @interface Request { /** * Dynamically apply this annotation to the specified classes. * *
See Also:
* * @return The annotation value. */ String[] on() default {}; /** * Dynamically apply this annotation to the specified classes. * *

* Identical to {@link #on()} except allows you to specify class objects instead of a strings. * *

See Also:
* * @return The annotation value. */ Class[] onClass() default {}; /** * Specifies the {@link HttpPartParser} class used for parsing strings to values. * *

* Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}. * * @return The annotation value. */ Class parser() default HttpPartParser.Void.class; /** * Specifies the {@link HttpPartSerializer} class used for serializing values to strings. * *

* Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}. * * @return The annotation value. */ Class serializer() default HttpPartSerializer.Void.class; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy