com.ibm.wsspi.rawrapper

Class JNDIActivationSpec

  1. java.lang.Object
  2. extended bycom.ibm.wsspi.rawrapper.JNDIActivationSpec
All implemented interfaces:
javax.resource.spi.ActivationSpec, javax.resource.spi.ResourceAdapterAssociation

  1. public class JNDIActivationSpec
  2. extends java.lang.Object
  3. implements javax.resource.spi.ActivationSpec
This class is used to specify the configuration used when activating an endpoint that will asynchronously consume messages from a destination.
  • actSpecJndiName - Required. Set this to the location in JNDI of the activation specification for the messaging provider, for example "jms/myActSpec".
  • applicationEndpointID - Required. This name must be unique within the scope of the application.
  • destinationJndiName - Optional. Use this property if you want to override the destination that is specified in the activation specification that the actSpecJndiName property points to.
    To set these properties, call the various setter methods.

    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> <-- thiscouldalsobesettoapplication,butfortheresourcereftouseit,itmustbesettocontainer
    <res-sharing-scope>Unshareable</res-sharing-scope>
    </resource-ref>

    Bindings information from the bindings file.

    <resource-ref name="ExampleResAuthName" binding-name="notused"> <-- thismustbeset,butisnotused
    <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

    Constructor and Description
    JNDIActivationSpec()
    Zero arg constructor ONLY for use as a java bean containing three fields

    Method Summary

    Modifier and Type Method and Description
    1. java.lang.String
    getActSpecJndiName()
    Gets the JNDI name of the activation spec to use.
    1. java.lang.String
    getApplicationEndpointID()
    gets the application endpoint name.
    1. java.lang.String
    getDestinationJndiName()
    Get the overridden jndi name of the destination
    1. javax.resource.spi.ResourceAdapter
    getResourceAdapter()
    This method is part of the activation spec inteface and is not expected to be called by the user
    1. void
    setActSpecJndiName(java.lang.String actSpecJndiName)
    Sets the JNDI name of the activation spec to use
    1. void
    setApplicationEndpointID(java.lang.String applicationEndpointID)
    This method sets the required application endpoint ID property.
    1. void
    setDestinationJndiName(java.lang.String destJndiName)
    Optional: Sets the JNDI name of the destination to use.
    1. void
    setResourceAdapter(javax.resource.spi.ResourceAdapter ra)
    This method is part of the activation spec inteface and is not expected to be called by the user
    1. java.lang.String
    toString()
    This to string method will print out the property values along with the objects memory address
    1. void
    validate()
    This method is called by the WAS framework to validate the activation spec, this will check this object activation spec and NOT the activation spec specified by the actSpecJndiName property.
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Constructor Detail

    JNDIActivationSpec

    1. public JNDIActivationSpec()
    Zero arg constructor ONLY for use as a java bean containing three fields

    Method Detail

    getActSpecJndiName

    1. public java.lang.String getActSpecJndiName( )
    Gets the JNDI name of the activation spec to use.
    Returns:
    the _jmsActSpecJndiName

    setActSpecJndiName

    1. public void setActSpecJndiName( java.lang.String actSpecJndiName)
    Sets the JNDI name of the activation spec to use
    Parameters:
    actSpecJndiName - the _jmsActSpecJndiName to set

    getDestinationJndiName

    1. public java.lang.String getDestinationJndiName( )
    Get the overridden jndi name of the destination
    Returns:
    the _jmsDestJndiName

    setDestinationJndiName

    1. public void setDestinationJndiName( java.lang.String destJndiName)
    Optional: Sets the JNDI name of the destination to use. This will override the destination JNDI name specified in the activation spec that ActSpecJndiName refers to
    Parameters:
    destJndiName - the _jmsDestJndiName to set

    getApplicationEndpointID

    1. public java.lang.String getApplicationEndpointID( )
    gets the application endpoint name. This field must be set by the creator of the JNDIActivationSpec object
    Returns:
    the application endpoint ID

    setApplicationEndpointID

    1. public void setApplicationEndpointID( java.lang.String applicationEndpointID)
    This method sets the required application endpoint ID property. This property is used to uniquely identify an endpoint within the scope of an application.
    Parameters:
    applicationEndpointID -

    validate

    1. public void validate()
    2. throws javax.resource.spi.InvalidPropertyException
    This method is called by the WAS framework to validate the activation spec, this will check this object activation spec and NOT the activation spec specified by the actSpecJndiName property. Validate that we have at least a JMS activation spec JNDI name specified and an application endpoint ID specified.
    Specified by:
    validate in interface javax.resource.spi.ActivationSpec
    Throws:
    javax.resource.spi.InvalidPropertyException

    toString

    1. public java.lang.String toString( )
    This to string method will print out the property values along with the objects memory address
    Overrides:
    toString in class java.lang.Object

    getResourceAdapter

    1. public javax.resource.spi.ResourceAdapter getResourceAdapter( )
    This method is part of the activation spec inteface and is not expected to be called by the user
    Specified by:
    getResourceAdapter in interface javax.resource.spi.ResourceAdapterAssociation

    setResourceAdapter

    1. public void setResourceAdapter( javax.resource.spi.ResourceAdapter ra)
    2. throws javax.resource.ResourceException
    This method is part of the activation spec inteface and is not expected to be called by the user
    Specified by:
    setResourceAdapter in interface javax.resource.spi.ResourceAdapterAssociation
    Throws:
    javax.resource.ResourceException