Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Swordfish Documentation: Architecture: Interceptor Framework"

(Description)
Line 3: Line 3:
  
 
== Description ==
 
== Description ==
 +
=== Example scenario  ===
 +
==== Sampe Interceptors ====
 +
In the example scenario below there are 4 different interceptors implementing the <code>process(...)</code> method defined in the base interface.
 +
The names of the interceptor classes indicate the purpose of the interceptor. Basically they are supposed to be plugged in on consumer (Cons) and provider side to process requests (Res) and responses (Cons).
 +
<br/>
 
[[Image:Interceptor Framework Option2.png]]  
 
[[Image:Interceptor Framework Option2.png]]  
  
=== Example of interceptor registration===
+
==== Interceptor registration ====
<pre>&lt;bean id="exampleConsReqInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleConsReqInterceptor"/&gt;
+
<pre>
 +
&lt;!-- Instances of the interceptors --&gt;
 +
&lt;bean id="exampleConsReqInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleConsReqInterceptor"/&gt;
 
&lt;bean id="exampleConsResInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleConsResInterceptor"/&gt;
 
&lt;bean id="exampleConsResInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleConsResInterceptor"/&gt;
 
&lt;bean id="exampleProvReqInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleProvReqInterceptor"/&gt;
 
&lt;bean id="exampleProvReqInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleProvReqInterceptor"/&gt;
 
&lt;bean id="exampleProvResInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleProvResInterceptor"/&gt;
 
&lt;bean id="exampleProvResInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleProvResInterceptor"/&gt;
  
 +
&lt;!-- Expose the exampleConsReqInterceptor as an OSGi service to be used on outgoing requests on consumer side --&gt;
 
&lt;osgi:service ref="exampleConsReqInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“&gt;
 
&lt;osgi:service ref="exampleConsReqInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“&gt;
 
&lt;osgi:service-properties&gt;
 
&lt;osgi:service-properties&gt;
Line 17: Line 25:
 
&lt;/osgi:service-properties&gt;
 
&lt;/osgi:service-properties&gt;
 
&lt;/osgi:service&gt;
 
&lt;/osgi:service&gt;
 +
 +
&lt;!-- Expose the exampleConsResInterceptor as an OSGi service to be used on incoming responses on consumer side --&gt;
 
&lt;osgi:service ref="exampleConsResInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“&gt;
 
&lt;osgi:service ref="exampleConsResInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“&gt;
 
&lt;osgi:service-properties&gt;
 
&lt;osgi:service-properties&gt;
Line 23: Line 33:
 
&lt;/osgi:service-properties&gt;
 
&lt;/osgi:service-properties&gt;
 
&lt;/osgi:service&gt;
 
&lt;/osgi:service&gt;
 +
 +
&lt;!-- Expose the exampleProviderReqInterceptor as an OSGi service to be used on incoming requests on provider side --&gt;
 
&lt;osgi:service ref="exampleProviderReqInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“&gt;
 
&lt;osgi:service ref="exampleProviderReqInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“&gt;
 
&lt;osgi:service-properties&gt;
 
&lt;osgi:service-properties&gt;
Line 29: Line 41:
 
&lt;/osgi:service-properties&gt;
 
&lt;/osgi:service-properties&gt;
 
&lt;/osgi:service&gt;
 
&lt;/osgi:service&gt;
 +
 +
&lt;!-- Expose the exampleProvResInterceptor as an OSGi service to be used on outgoing responses on provider side --&gt;
 
&lt;osgi:service ref="exampleProvResInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“&gt;
 
&lt;osgi:service ref="exampleProvResInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“&gt;
 
&lt;osgi:service-properties&gt;
 
&lt;osgi:service-properties&gt;
Line 47: Line 61:
 
</pre>  
 
</pre>  
  
==== Consequences ====
+
== Consequences ==
 
* New dimensions can easily be added by defining additional properties
 
* New dimensions can easily be added by defining additional properties
 
* Unified interface makes chain execution straightforward (no conditional processing)
 
* Unified interface makes chain execution straightforward (no conditional processing)
  
 
== See also ==
 
== See also ==

Revision as of 03:45, 20 November 2009

Overview

The interceptor framework needs to support implementations that allow the distinguishing direction (inbound / outbound) and scope (request, response).

Description

Example scenario

Sampe Interceptors

In the example scenario below there are 4 different interceptors implementing the process(...) method defined in the base interface. The names of the interceptor classes indicate the purpose of the interceptor. Basically they are supposed to be plugged in on consumer (Cons) and provider side to process requests (Res) and responses (Cons).
Interceptor Framework Option2.png

Interceptor registration

<!-- Instances of the interceptors -->
<bean id="exampleConsReqInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleConsReqInterceptor"/>
<bean id="exampleConsResInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleConsResInterceptor"/>
<bean id="exampleProvReqInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleProvReqInterceptor"/>
<bean id="exampleProvResInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleProvResInterceptor"/>

<!-- Expose the exampleConsReqInterceptor as an OSGi service to be used on outgoing requests on consumer side -->
<osgi:service ref="exampleConsReqInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“>
	<osgi:service-properties>
		<entry key=“role“ value=“consumer“/>
		<entry key=“scope“ value=“request“/>
	</osgi:service-properties>
</osgi:service>

<!-- Expose the exampleConsResInterceptor as an OSGi service to be used on incoming responses on consumer side -->
<osgi:service ref="exampleConsResInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“>
	<osgi:service-properties>
		<entry key=“role“ value=“consumer“/>
		<entry key=“scope“ value=“response“/>
	</osgi:service-properties>
</osgi:service>

<!-- Expose the exampleProviderReqInterceptor as an OSGi service to be used on incoming requests on provider side -->
<osgi:service ref="exampleProviderReqInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“>
	<osgi:service-properties>
		<entry key=“role“ value=“provider“/>
		<entry key=“scope“ value=“request“/>
	</osgi:service-properties>
</osgi:service>

<!-- Expose the exampleProvResInterceptor as an OSGi service to be used on outgoing responses on provider side -->
<osgi:service ref="exampleProvResInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“>
	<osgi:service-properties>
		<entry key=“role“ value=“provider“/>
		<entry key=“scope“ value=“response“/>
	</osgi:service-properties>
</osgi:service>

If the interceptor should exhibit the same behaviour in all four processing positions, only one implementation class would be needed that is registered as shown below:

<bean id="exampleInterceptor" class="org.eclipse.swordfish.plugins.samples.ExampleInterceptor"/>

<osgi:service ref="exampleInterceptor" interface=“org.eclipse.swordfish.core.Interceptor“>
	<osgi:service-properties>
		<entry key=“role“ value=“consumer,provider“/>
		<entry key=“scope“ value=“request,response“/>
	</osgi:service-properties>
</osgi:service>

Consequences

  • New dimensions can easily be added by defining additional properties
  • Unified interface makes chain execution straightforward (no conditional processing)

See also

Back to the top