IBM WebSphere Application ServerTM
Release 8

com.ibm.wsspi.rawrapper
Class RAWrapperFactory

java.lang.Object
  extended by com.ibm.wsspi.rawrapper.RAWrapperFactory

public class RAWrapperFactory
extends java.lang.Object

Factory class used to create instances of RAWrapper objects which enable users to activate endpoints. Each call to getRAWrapper method will create a new RAWrapper instance.

Authentication aliases

  • To use an authentication alias to connect to a secure JMS provider, you can use a resource reference. The res-ref-name property of the resource reference must match the value of the applicationEndpointID property that is set in this JNDIActivationSpec instance. The authentication alias can then be used as part of the bindings for the resource reference.

    Example:
    Resource ref from the xml file:
    <resource-ref id="ResourceRef_ID">
    <description>com.ibm.ejs.models.base.resources.j2c.J2CActivationSpec</description>
    <res-ref-name>ExampleResAuthName</res-ref-name>
    <res-type>J2CActivationSpec</res-type>
    <res-auth>Container</res-auth> <-- This could also be set to application, but for the resource ref to use it, it must be set to container
    <res-sharing-scope>Unshareable</res-sharing-scope>
    </resource-ref>

    Bindings information from the bindings file.

    <resource-ref name="ExampleResAuthName" binding-name="notused"> <-- This must be set, but is not used
    <authentication-alias name="my_auth_alias" />
    </resource-ref>
  • Using a resource reference to specify the authentication alias is preferable to configuring it directly on the activation specification; specifying an authentication alias directly in an activation specification bypasses the security because this activation specification is accessible to anyone who can access JNDI.

    Java 2 Security
  • For Java 2 security, use the RAFactoryPermission class with a value of getRAWrapper for the ID. The security check is applied when the call to the getRAWrapper method is made on the RAWrapperFactory.


    Transactional Behaviour
    Implementations of Message Endpoint can optionally implement the following method: public void markInboundTransaction () This method tells the message endpoint that there is a transaction on the thread when message delivery occurs. This method is called reflectively during before-delivery processing, before the run time calls the isDeliveryTransacted method on the MessageEndpointFactory interface.
  • If isDeliveryTransacted returns true then we enlist in the global transaction.
  • If isDeliveryTransacted returns false then we start a local transaction.
  • If isDeliveryTransacted returns false and there is already a transaction on the thread then an IllegalStateException will be thrown.


    Example activation

    public void exampleActivate () throws ResourceException
    {
        try
        {
            ResourceAdapter ra = RAWrapperFactory.getRAWrapper();
            JNDIActivationSpec jndiActSpec = new JNDIActivationSpec ();
            jndiActSpec.setActSpecJndiName("jms/actSpec");
            jndiActSpec.setApplicationEndpointID("id");
            MessageEndpointFactory mef = new ExampleMEFImplentation (); // See ExampleMEFImplemention below
            ra.endpointActivation(mef, jndiActSpec);
        }
        catch (ResourceException ex)
        {
            ex.printStackTrace ();
        }
    }


    import java.lang.reflect.Method;
    import javax.resource.spi.UnavailableException;
    import javax.resource.spi.endpoint.MessageEndpoint;
    import javax.resource.spi.endpoint.MessageEndpointFactory;
    import javax.transaction.xa.XAResource;

    public class ExampleMEFImplentation implements MessageEndpointFactory
    {

        public MessageEndpoint createEndpoint(XAResource arg0)
              throws UnavailableException
        {
            return new ExampleMessageEndpoint (); // See ExampleMessageEndpoint below
        }

        public boolean isDeliveryTransacted(Method arg0)
              throws NoSuchMethodException
        {
            return false;
        }

    }

    The message endpoint class must implement both MessageEndpoint interface (for J2C activation) and MessageListener interface for the JMS provider to send messages to.

    import java.lang.reflect.Method;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    import javax.resource.ResourceException;
    import javax.resource.spi.endpoint.MessageEndpoint;

    public class ExampleMessageEndpoint implements MessageEndpoint, MessageListener {

        public void afterDelivery() throws ResourceException {
        }

        public void beforeDelivery(Method arg0) throws NoSuchMethodException,
              ResourceException {
        }
        public void release() {
        }

        public void onMessage(Message arg0) {
        }
    }


    Constructor Summary
    RAWrapperFactory()
               
     
    Method Summary
    static javax.resource.spi.ResourceAdapter getRAWrapper()
              This static method is called to obtain a new instance of a resource adapter object and is the entry point for users wishing to use the RAWrapper functionality.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    RAWrapperFactory

    public RAWrapperFactory()
    Method Detail

    getRAWrapper

    public static javax.resource.spi.ResourceAdapter getRAWrapper()
    This static method is called to obtain a new instance of a resource adapter object and is the entry point for users wishing to use the RAWrapper functionality. This resource adapter uses the activation spec class "JNDIActivationSpec" in this package. The properties on this JNDIActivationSpec are used to point to an activation specification that a messaging resource adapter can use. See JNDIActivationSpec for more info. If the implementation class for the resource adapter can not be found then an exception will be thrown.

    This method will perform a java 2 security check (using the RAFactoryPermission object with the permission name getRAWrapper).

    If the feature has not been enabled (by setting the server property com.ibm.wsspi.rawrapper.enabled to true) then a null will be returned.

    Returns:
    A new instance of a resource adapter used to wrap a messaging resource adapter. If the property com.ibm.wsspi.rawrapper.enabled on the server has not been set to true this will return null.
    Throws:
    java.security.AccessControlException - if the calling code fails the java 2 security check

    IBM WebSphere Application ServerTM
    Release 8