|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface represents the chain of the transport interceptors either for the service endpoint or for the client.
Interceptors are at the lowest level of message processing. They accept a transport messages as their input, can modify it and return a transport message as an output. This level has no notion about XML or higher level protocols, so it is able to, for example, convert non-XML protocols into XML protocols and vice versa. For instance, you can use interceptors for dumping messages into the console, computing message statistics (such as average message length), performing authentication, transforming the incoming message via XSLT etc.
In WSO2 SOA Enablement Server, all interceptors must implement the
TransportInterceptor
interface.
The interceptor implementation can use CallContext
(which can be obtained via Current.getCallContext()
)
for passing data to the service instance or from the client and vice versa.
The following code snippet shows how to insert a transport interceptor at the client-side:
ServiceClient serviceClient = ServiceClient.create("http://localhost:6060/MyService", MyService.class); serviceClient.getInterceptors().insert(new MyInterceptor(), Interceptors.DIRECTION_INOUT);
And the following code snippet shows how to insert a transport interceptor at the server-side:
ServiceEndpoint endpoint = Registry.publish("/MyService", new MyService()); endpoint.getInterceptors().insert(new MyInterceptor(), Interceptors.DIRECTION_INOUT);
Field Summary | |
static int |
DIRECTION_IN
Constant value representing interceptor is used for incoming message. |
static int |
DIRECTION_INOUT
Constant value representing interceptor is used both for incoming and outgoing message. |
static int |
DIRECTION_OUT
Constant value representing interceptor is used for outgoing message. |
static int |
POSITION_FIRST
Constant value representing the first position in the chain. |
static int |
POSITION_LAST
Constant value representing the last position in the chain. |
Method Summary | |
Interceptor |
get(int position)
Returns an interceptor at the specified position within the chain of transport interceptors. |
int |
getDirection(int position)
Returns a communication direction of the interceptor residing at the specified position within the chain of the transport interceptors. |
void |
insert(Interceptor instance,
int direction)
Inserts an interceptor to the end of the chain of the transport interceptors. |
void |
insert(int position,
Interceptor instance,
int direction)
Inserts an interceptor to the specified position in the chain of the transport interceptors. |
void |
remove(int position)
Removes a interceptor at the specified position in the chain of the transport interceptors. |
boolean |
remove(Interceptor instance)
Removes all occurrences of the given interceptor's instance from the chain of the transport interceptors. |
void |
setDirection(int position,
int direction)
Sets a communication direction of the interceptor residing at the specified position within the chain of the transport interceptors. |
int |
size()
Returns the size (number of interceptors) of the chain of the transport interceptors. |
Field Detail |
public static final int DIRECTION_IN
public static final int DIRECTION_OUT
public static final int DIRECTION_INOUT
DIRECTION_INOUT = DIRECTION_IN | DIRECTION_OUT
.
public static final int POSITION_FIRST
public static final int POSITION_LAST
Method Detail |
public Interceptor get(int position) throws java.lang.IndexOutOfBoundsException
position
- interceptor's index within the chain
java.lang.IndexOutOfBoundsException
- if position is if out of range (position < 0 || position => size())public int getDirection(int position) throws java.lang.IndexOutOfBoundsException
Returns a communication direction of the interceptor residing at the specified position within the chain of the transport interceptors.
The direction is one of DIRECTION_IN
, DIRECTION_OUT
, DIRECTION_INOUT
.
These directions depend on which end of the service they are viewed from: a interceptor that is "in"
according to ServiceEndpoint is "out" according to ServiceClient, and vice-versa.
position
- specifies the interceptor's position within the chain
java.lang.IndexOutOfBoundsException
- if position is if out of range (position < 0 || position => size())public void setDirection(int position, int direction) throws java.lang.IndexOutOfBoundsException
DIRECTION_IN
, DIRECTION_OUT
, DIRECTION_INOUT
.
position
- specifies the interceptor's position within the chaindirection
- interceptor's direction (see DIRECTION_IN
, DIRECTION_OUT
, DIRECTION_INOUT
)
java.lang.IllegalArgumentException
- when such direction does not exist
java.lang.IndexOutOfBoundsException
- if position is if out of range (position < 0 || position => size())public void insert(int position, Interceptor instance, int direction) throws java.lang.IndexOutOfBoundsException
position
- interceptor's index within the chain,
constants POSITION_FIRST
, POSITION_LAST
can be usedinstance
- interceptor to be inserteddirection
- interceptor's direction
(see DIRECTION_IN
, DIRECTION_OUT
, DIRECTION_INOUT
)
java.lang.IllegalArgumentException
- when such direction does not exist
java.lang.IndexOutOfBoundsException
- if position is if out of range (position < 0 || position > size())public void insert(Interceptor instance, int direction)
instance
- interceptor to be inserteddirection
- interceptor's direction
(see DIRECTION_IN
, DIRECTION_OUT
, DIRECTION_INOUT
)
java.lang.IllegalArgumentException
- when such direction does not existpublic void remove(int position) throws java.lang.IndexOutOfBoundsException
position
- position in the interceptor chain
java.lang.IndexOutOfBoundsException
- if position is if out of range (position < 0 || position => size())public int size()
public boolean remove(Interceptor instance)
instance
- instance of the interceptor to be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |