IBM WebSphere Application ServerTM
Release 8

com.ibm.wsspi.rawrapper
Class JNDIActivationSpec

java.lang.Object
  extended by com.ibm.wsspi.rawrapper.JNDIActivationSpec
All Implemented Interfaces:
javax.resource.spi.ActivationSpec, javax.resource.spi.ResourceAdapterAssociation

public class JNDIActivationSpec
extends java.lang.Object
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> <-- 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
    JNDIActivationSpec()
              Zero arg constructor ONLY for use as a java bean containing three fields
     
    Method Summary
     java.lang.String getActSpecJndiName()
              Gets the JNDI name of the activation spec to use.
     java.lang.String getApplicationEndpointID()
              gets the application endpoint name.
     java.lang.String getDestinationJndiName()
              Get the overridden jndi name of the destination
     javax.resource.spi.ResourceAdapter getResourceAdapter()
              This method is part of the activation spec inteface and is not expected to be called by the user
     void setActSpecJndiName(java.lang.String actSpecJndiName)
              Sets the JNDI name of the activation spec to use
     void setApplicationEndpointID(java.lang.String applicationEndpointID)
              This method sets the required application endpoint ID property.
     void setDestinationJndiName(java.lang.String destJndiName)
              Optional: Sets the JNDI name of the destination to use.
     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
     java.lang.String toString()
              This to string method will print out the property values along with the objects memory address
     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

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

    Method Detail

    getActSpecJndiName

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

    Returns:
    the _jmsActSpecJndiName

    setActSpecJndiName

    public void setActSpecJndiName(java.lang.String actSpecJndiName)
    Sets the JNDI name of the activation spec to use

    Parameters:
    actSpecJndiName - the _jmsActSpecJndiName to set

    getDestinationJndiName

    public java.lang.String getDestinationJndiName()
    Get the overridden jndi name of the destination

    Returns:
    the _jmsDestJndiName

    setDestinationJndiName

    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

    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

    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

    public void validate()
                  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

    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

    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

    public void setResourceAdapter(javax.resource.spi.ResourceAdapter ra)
                            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

    IBM WebSphere Application ServerTM
    Release 8