Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To do this, a class that implements org.fabric3.spi.binding.handler.BindingHandler must be provided as a Fabric3 extension componentscomponent:

Code Block
java
java
public interface BindingHandler<T> {

    /**
     * The fully qualified binding name corresponding to the SCA architected binding name scheme binding.xxxx.
     *
     * @return the fully qualified binding name
     */
    QName getType();

    /**
     * Handles an outbound (reference-side) message.
     *
     * @param context the binding-specific transport context
     * @param message the current message
     */
    void handleOutbound(Message message, T context);

    /**
     * Handles an inbound (service-side) message.
     *
     * @param context the binding-specific transport context
     * @param message the current message
     */
    void handleInbound(T context, Message message);

}

BindingHandler implementations that require access Web Service SOAP messages must use javax.xml.soap.SOAPMessage as the parameterized type. Below is an example handler:

Code Block
java
java
@EagerInit@Scope("COMPOSITE")
public class SOAPHandlerTestHandler implements BindingHandler<SOAPMessage> {
    private static final QName BINDING = new QName(Constants.SCA_NS, "binding.ws");

    privatepublic BindingHandlerRegistry registry;

    public SOAPHandler(@Reference BindingHandlerRegistry registryQName getType() {
        this.registry = registryreturn BINDING;
    }

 

 @Init     public void inithandleOutbound()Message {message,         registry.register(this);
    }

    @Destroy
    public void destroy(SOAPMessage context) {
       // registry.unregister(this);...
    }

    public QNamevoid getTypehandleInbound()SOAPMessage {
        return BINDING;
    }

    public void handleOutbound(context, Message message, SOAPMessage context) {
     }  //.. 
  public void handleInbound(SOAPMessage soapMessage, Message message) {

    }
}

Note the component handler is eager-initialized and registers with the BindingHandlerRegistry. Fabric3 extension components are configured using the implementation.system type as shown belowcomposite-scoped. Although this is not necessary, most handlers are threadsafe and making them composite-scoped will avoid the overhead associated with stateless-scoped implementations. The handler configuration is shown below. Note the component may be contained in the same contribution as the services or references it applies to or in a different contribution if used for more than one application:

Code Block
xml
xml
<composite<component xmlnsname="http://docs.oasis-open.org/ns/opencsa/sca/200912"HandlerService">
           xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
   <implementation.java class="org.fabric3.tests.binding.metro.handler.HandlerServiceImpl"/>
   <service name="HandlerService">
       xmlns:f3="urn:fabric3.org"<binding.ws uri="/handlerService">
         <f3:handler  targetNamespacetarget="urn:fabric3.org"TestHandler"/>
      </binding.ws>
    name="TestWsHandlerExtensionComposite">

 </service>
</component>


<component name="SOAPHandlerTestHandler">
        <f3:implementation.system<implementation.java class="org.fabric3.tests.binding.metro.handler.SOAPHandlerTestHandler"/>
 
  </component>

</composite>

...


The manifest (sca-contribution.xml) similar to of the contribution containing the handler must contain the following imports:

Code Block
xml
xml
<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" ...>
    <import.java package="org.fabric3.spi.*" version="1.9.6"/>
    <import.java package="javax.xml.ws.*"/>
</contribution>

Finally, the handler may be used on a binding as follows:

Code Block
xml
xml
<component name="HandlerService">
    xmlns:f3<implementation.java class="urn:org.fabric3.org"tests.binding.metro.handler.HandlerServiceImpl"/>
   <service name="HandlerService">
         f3:extension<binding.ws uri="true/handlerService">
         <import.java package="org.fabric3.spi.*<f3:handler target="TestHandler"/>
    <deployable composite="f3:TestWsHandlerExtensionComposite"/>  </binding.ws>
   </contribution>

...

service>
</component>