FileDocCategorySizeDatePackage
EjbMessageBeanDescriptor.javaAPI DocGlassfish v2 API24344Fri May 04 22:31:22 BST 2007com.sun.enterprise.deployment

EjbMessageBeanDescriptor

public final class EjbMessageBeanDescriptor extends EjbDescriptor implements com.sun.enterprise.deployment.types.MessageDestinationReferencer
Objects of this kind represent the deployment information describing a single message driven Ejb.

Fields Summary
private static final boolean
debug
public static final String
TYPE
The Session type String.
private static com.sun.enterprise.util.LocalStringManagerImpl
localStrings
private String
messageListenerType
private transient Collection
beanClassTxMethods
private String
destinationType
private static final String
DURABLE_SUBSCRIPTION_PROPERTY
private static final String
DURABLE
private static final String
NON_DURABLE
private static final String
ACK_MODE_PROPERTY
private static final String
AUTO_ACK
private static final String
DUPS_OK_ACK
private static final String
MESSAGE_SELECTOR_PROPERTY
private String
durableSubscriptionName
private String
connectionFactoryName
private String
resourceAdapterMid
private MessageDestinationReferencerImpl
msgDestReferencer
private ActivationConfigDescriptor
activationConfig
private ActivationConfigDescriptor
runtimeActivationConfig
Constructors Summary
public EjbMessageBeanDescriptor()
Default constructor.

    
            
      
        msgDestReferencer = new MessageDestinationReferencerImpl(this);
        this.activationConfig = new ActivationConfigDescriptor();
        this.runtimeActivationConfig = new ActivationConfigDescriptor();
    
public EjbMessageBeanDescriptor(EjbMessageBeanDescriptor other)
The copy constructor.

        super(other);
        this.messageListenerType = other.messageListenerType;
        this.beanClassTxMethods = null;
        this.durableSubscriptionName = other.durableSubscriptionName;
        this.msgDestReferencer = new MessageDestinationReferencerImpl(this);
        this.activationConfig = 
            new ActivationConfigDescriptor(other.activationConfig);
        this.runtimeActivationConfig = 
            new ActivationConfigDescriptor(other.runtimeActivationConfig);
        this.destinationType = other.destinationType;
    
Methods Summary
public ActivationConfigDescriptorgetActivationConfigDescriptor()

        return activationConfig;
    
public java.util.SetgetActivationConfigProperties()

return
Set of EnvironmentProperty elements.

        return activationConfig.getActivationConfig();
    
public java.lang.StringgetActivationConfigValue(java.lang.String name)

        for(Iterator iter = activationConfig.getActivationConfig().iterator(); 
            iter.hasNext();) {
            EnvironmentProperty next = (EnvironmentProperty) iter.next();
            if( next.getName().equals(name) ) {
                return (String) next.getValue();
            }
        }
        return null;
    
public java.lang.StringgetConnectionFactoryName()

        return connectionFactoryName;
    
public java.lang.StringgetDestinationType()

        return destinationType;
    
public java.lang.StringgetDurableSubscriptionName()

        return durableSubscriptionName;
    
public intgetJmsAcknowledgeMode()

        String ackModeStr = getActivationConfigValue(ACK_MODE_PROPERTY);
        return ( (ackModeStr != null) && ackModeStr.equals(DUPS_OK_ACK) ) ? 
            Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE;
    
public java.lang.StringgetJmsAcknowledgeModeAsString()

        return getActivationConfigValue(ACK_MODE_PROPERTY);
    
public java.lang.StringgetJmsMessageSelector()

	return getActivationConfigValue(MESSAGE_SELECTOR_PROPERTY);
    
public com.sun.enterprise.deployment.EjbMessageBeanDescriptorgetMessageBeanOwner()
Get the descriptor for the message-driven bean owner.

        return this;
    
public MessageDestinationDescriptorgetMessageDestination()

return
the message destination to which I refer. Can be NULL.

        return msgDestReferencer.getMessageDestination();
    
public java.lang.StringgetMessageDestinationLinkName()

return
the name of the message destination to which I refer

        return msgDestReferencer.getMessageDestinationLinkName();
    
public MessageDestinationReferenceDescriptorgetMessageDestinationRefOwner()

        return null;
    
public java.lang.reflect.Method[]getMessageListenerInterfaceMethods(java.lang.ClassLoader classLoader)
This returns the message listener onMessage method from the *message listener interface* itself, as opposed to the method from the ejb class that implements it.

                             
        Method[] methods; 
        try {
            Class messageListenerClass = 
                classLoader.loadClass(messageListenerType);
            methods = messageListenerClass.getDeclaredMethods();
            if( methods.length == 0 ) {
                throw new NoSuchMethodException
                    ("MessageListener interface " + messageListenerType + 
                     " must declare at least one method");
            }
        } catch(Exception e) {
            NoSuchMethodException nsme = new NoSuchMethodException();
            nsme.initCause(e);
            throw nsme;
        }
        return methods;
    
public java.lang.StringgetMessageListenerType()

        return messageListenerType;
    
public java.util.VectorgetMethods(java.lang.ClassLoader classLoader)

        // @@@
        return new Vector();
    
public java.util.VectorgetPossibleTransactionAttributes()

        Vector txAttributes = new Vector();
        txAttributes.add(new ContainerTransaction
            (ContainerTransaction.REQUIRED, ""));
        txAttributes.add(new ContainerTransaction
            (ContainerTransaction.NOT_SUPPORTED, ""));
        if( isTimedObject() ) {
            txAttributes.add(new ContainerTransaction
                (ContainerTransaction.REQUIRES_NEW, ""));
        }
        return txAttributes;
    
public java.lang.StringgetResourceAdapterMid()

        return resourceAdapterMid;
    
public ActivationConfigDescriptorgetRuntimeActivationConfigDescriptor()

        return runtimeActivationConfig;
    
public java.util.SetgetRuntimeActivationConfigProperties()

return
Set of EnvironmentProperty elements.

        return runtimeActivationConfig.getActivationConfig();
    
public java.lang.StringgetRuntimeActivationConfigValue(java.lang.String name)

        for(Iterator iter = 
                runtimeActivationConfig.getActivationConfig().iterator(); 
            iter.hasNext();) {
            EnvironmentProperty next = (EnvironmentProperty) iter.next();
            if( next.getName().equals(name) ) {
                return (String) next.getValue();
            }
        }
        return null;
    
public java.util.SetgetSecurityBusinessMethodDescriptors()

	throw new IllegalArgumentException(localStrings.getLocalString(
		   "enterprise.deployment.exceptioncannotgetsecbusmethodsinmsgbean",
                   "Cannot get business method for security for message-driven bean."));
    
protected java.util.CollectiongetTransactionMethods(java.lang.ClassLoader classLoader)

return
a collection of MethodDescriptor for methods which may have a assigned security attribute.

        Vector txMethods = new Vector();

        if( beanClassTxMethods == null ) {
            try {
                beanClassTxMethods = new HashSet();
                Class ejbClass = classLoader.loadClass(this.getEjbClassName());
                Method interfaceMessageListenerMethods[] =
                    getMessageListenerInterfaceMethods(classLoader);
                for(int i = 0; i < interfaceMessageListenerMethods.length; 
                    i++) {
                    Method next = interfaceMessageListenerMethods[i];
                    // Convert method objects from MessageListener interface
                    // to method objects from ejb class
                    Method nextBeanMethod = ejbClass.getMethod
                        (next.getName(), next.getParameterTypes());
                    beanClassTxMethods.add(new MethodDescriptor(nextBeanMethod, MethodDescriptor.EJB_BEAN));
                }
                if( isTimedObject() ) {
                    beanClassTxMethods.add(getEjbTimeoutMethod()); 
                }
            }
            catch(Exception e) {
                NoSuchMethodError nsme = new NoSuchMethodError(localStrings.getLocalString("enterprise.deployment.noonmessagemethod", "", new Object[] { 
                    getEjbClassName(), getMessageListenerType() }));
                nsme.initCause(e);
                throw nsme;
            }
        }
        txMethods.addAll(beanClassTxMethods);

        return txMethods;
    
public java.util.SetgetTxBusinessMethodDescriptors()

         
        ClassLoader classLoader = getEjbBundleDescriptor().getClassLoader();
        Set methods = new HashSet();

        try {
            addAllInterfaceMethodsIn
                (methods, classLoader.loadClass(messageListenerType), 
                 MethodDescriptor.EJB_BEAN);

            if (isTimedObject()) {
                methods.add(getEjbTimeoutMethod());
            }

        } catch (Throwable t) { 
            _logger.log(Level.SEVERE,"enterprise.deployment.backend.methodClassLoadFailure",new Object [] {"(EjbDescriptor.getBusinessMethodDescriptors())"});
                                                           
	    throw new RuntimeException(t);
	}   
         
        return methods;
    
public java.lang.StringgetType()
Returns the type of this bean - always "Message-driven".

        return TYPE;
    
public booleanhasConnectionFactory()

        return (connectionFactoryName != null);
    
public booleanhasDestinationType()

        return (destinationType != null);
    
public booleanhasDurableSubscription()

        String value = getActivationConfigValue(DURABLE_SUBSCRIPTION_PROPERTY);
        return ( (value != null) && value.equals(DURABLE) );
    
public booleanhasJmsMessageSelector()

        return ( getActivationConfigValue(MESSAGE_SELECTOR_PROPERTY) != null );
    
public booleanhasMessageDestinationLinkName()

        return (msgDestReferencer.getMessageDestinationLinkName() != null);
    
public booleanhasQueueDest()

        return ( (destinationType != null) && 
                 (destinationType.equals("javax.jms.Queue")) );
    
public booleanhasResourceAdapterMid()

        return (resourceAdapterMid != null);
    
public booleanhasTopicDest()

        return ( (destinationType != null) && 
                 (destinationType.equals("javax.jms.Topic")) );
    
public booleanisLinkedToMessageDestination()

        return msgDestReferencer.isLinkedToMessageDestination();
    
public booleanownedByMessageBean()
True if the owner is a message-driven bean.

        return true;
    
public booleanownedByMessageDestinationRef()

        return false;
    
public voidprint(java.lang.StringBuffer toStringBuffer)
Returns a formatted String of the attributes of this object.

	super.print(toStringBuffer);
	toStringBuffer.append("Message-driven descriptor : ").append( 
            activationConfig.getActivationConfig()).append(
            runtimeActivationConfig.getActivationConfig());
    
public voidputActivationConfigProperty(EnvironmentProperty prop)

    	// remove first an existing property with the same name
    	removeActivationConfigPropertyByName(prop.getName());
        activationConfig.getActivationConfig().add(prop);
    
public voidputRuntimeActivationConfigProperty(EnvironmentProperty prop)

        runtimeActivationConfig.getActivationConfig().add(prop);
    
public voidremoveActivationConfigProperty(EnvironmentProperty prop)

        for(Iterator iter = activationConfig.getActivationConfig().iterator(); 
            iter.hasNext();) {
            EnvironmentProperty next = (EnvironmentProperty) iter.next();
            if( next.getName().equals(prop.getName()) && 
                next.getValue().equals(prop.getValue()) ) {
                iter.remove();
                break;
            }
        }
    
public voidremoveActivationConfigPropertyByName(java.lang.String name)

        for(Iterator iter = activationConfig.getActivationConfig().iterator(); 
            iter.hasNext();) {
            EnvironmentProperty next = (EnvironmentProperty) iter.next();
            if( next.getName().equals(name) ) {
                iter.remove();
                break;
            }
        }
    
public voidremoveRuntimeActivationConfigProperty(EnvironmentProperty prop)

        
        for(Iterator iter = 
                runtimeActivationConfig.getActivationConfig().iterator();
            iter.hasNext();) {
            EnvironmentProperty next = (EnvironmentProperty) iter.next();
            if( next.getName().equals(prop.getName()) && 
                next.getValue().equals(prop.getValue()) ) {
                iter.remove();
                break;
            }
        }

    
public voidremoveRuntimeActivationConfigPropertyByName(java.lang.String name)

        for(Iterator iter = 
                runtimeActivationConfig.getActivationConfig().iterator(); 
            iter.hasNext();) {
            EnvironmentProperty next = (EnvironmentProperty) iter.next();
            if( next.getName().equals(name) ) {
                iter.remove();
                break;
            }
        }
    
public MessageDestinationDescriptorresolveLinkName()

        return msgDestReferencer.resolveLinkName();
    
public voidsetActivationConfigDescriptor(ActivationConfigDescriptor desc)

        activationConfig = desc;
    
public voidsetConnectionFactoryName(java.lang.String connectionFactory)
Connection factory is optional. If set to null, hasConnectionFactory will return false.

        connectionFactoryName = connectionFactory;
    
public voidsetContainerTransactionFor(MethodDescriptor methodDescriptor, ContainerTransaction containerTransaction)

        Vector allowedTxAttributes = getPossibleTransactionAttributes();
        if( allowedTxAttributes.contains(containerTransaction) ) {
            super.setContainerTransactionFor
                (methodDescriptor, containerTransaction);
         }
         else {
             throw new IllegalArgumentException(localStrings.getLocalString(
                 "enterprise.deployment.msgbeantxattrnotvalid",
		   "Invalid transaction attribute for message-driven bean"));
         }
    
public voidsetDestinationType(java.lang.String destType)

        destinationType = destType;
    
public voidsetDurableSubscriptionName(java.lang.String durableSubscriptionName)

        this.durableSubscriptionName = durableSubscriptionName;
        super.changed();
    
public voidsetHasDurableSubscription(boolean durable)

        if( durable ) {
            EnvironmentProperty durableProp = 
                new EnvironmentProperty(DURABLE_SUBSCRIPTION_PROPERTY, 
                                        DURABLE, "");
            putActivationConfigProperty(durableProp);
        } else {
            removeActivationConfigPropertyByName(DURABLE_SUBSCRIPTION_PROPERTY);
        }
        super.changed();
    
public voidsetHasQueueDest()

        destinationType = "javax.jms.Queue";
        setHasDurableSubscription(false);
        super.changed();
    
public voidsetHasTopicDest()

        destinationType = "javax.jms.Topic";
        super.changed();
    
public voidsetJmsAcknowledgeMode(int acknowledgeMode)

        String ackModeValue = (acknowledgeMode == Session.AUTO_ACKNOWLEDGE) ?
            AUTO_ACK : DUPS_OK_ACK;
        EnvironmentProperty ackModeProp =
            new EnvironmentProperty(ACK_MODE_PROPERTY, ackModeValue, "");
        putActivationConfigProperty(ackModeProp);

        super.changed();
    
public voidsetJmsAcknowledgeMode(java.lang.String acknowledgeMode)

        if (AUTO_ACK.equals(acknowledgeMode)) {
            setJmsAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
        } else {
            if (DUPS_OK_ACK.equals(acknowledgeMode)) {
                setJmsAcknowledgeMode(Session.DUPS_OK_ACKNOWLEDGE);
            } else {
                throw new IllegalArgumentException
                    ("Invalid jms acknowledge mode : " + acknowledgeMode);
            }
        }
    
public voidsetJmsMessageSelector(java.lang.String selector)

        
        if( (selector == null) || (selector.trim().equals("")) ) {
            removeActivationConfigPropertyByName(MESSAGE_SELECTOR_PROPERTY);
        } else {
            EnvironmentProperty msgSelectorProp =
                new EnvironmentProperty(MESSAGE_SELECTOR_PROPERTY,selector,"");
            putActivationConfigProperty(msgSelectorProp);
        }

        super.changed();
    
public voidsetMessageDestination(MessageDestinationDescriptor newMsgDest)

param
messageDestiation the message destination to which I refer.

        msgDestReferencer.setMessageDestination(newMsgDest);
    
public voidsetMessageDestinationLinkName(java.lang.String linkName)
Sets the name of the message destination to which I refer.

        msgDestReferencer.setMessageDestinationLinkName(linkName);
    
public MessageDestinationDescriptorsetMessageDestinationLinkName(java.lang.String linkName, boolean resolveLink)

        return msgDestReferencer.setMessageDestinationLinkName
            (linkName, resolveLink);
    
public voidsetMessageListenerType(java.lang.String messagingType)

        messageListenerType = messagingType;

        // Clear message listener methods so transaction methods will be 
        // recomputed using new message listener type;
        beanClassTxMethods = null;
    
public voidsetResourceAdapterMid(java.lang.String resourceAdapterMid)
resource-adapter-mid is optional. It is set when a resource adapter is responsible for delivering messages to the message-driven bean. If not set, hasResourceAdapterMid will return false.

        this.resourceAdapterMid = resourceAdapterMid;
    
public voidsetRuntimeActivationConfigDescriptor(ActivationConfigDescriptor desc)

        runtimeActivationConfig = desc;
        
    
public voidsetSubscriptionDurability(java.lang.String subscription)

        if (subscription.equals(DURABLE)) {
            setHasDurableSubscription(true);
        }
        else if (subscription.equals(NON_DURABLE)) {
            setHasDurableSubscription(false);
        } else {
            throw new IllegalArgumentException
                ("Invalid subscription durability string : " + subscription);
        }
    
public voidsetTransactionType(java.lang.String transactionType)
Sets the transaction type for this bean. Must be either BEAN_TRANSACTION_TYPE or CONTAINER_TRANSACTION_TYPE.

	boolean isValidType = (BEAN_TRANSACTION_TYPE.equals(transactionType) ||
				CONTAINER_TRANSACTION_TYPE.equals(transactionType));
				
	if (!isValidType && this.isBoundsChecking()) {
	    throw new IllegalArgumentException(localStrings.getLocalString(
									   "enterprise.deployment.exceptionmsgbeantxtypenotlegaltype",
									   "{0} is not a legal transaction type for a message-driven bean", new Object[] {transactionType}));
	} else {
	    super.transactionType = transactionType;
	    super.setMethodContainerTransactions(new Hashtable());
	    super.changed();
	}
    
public voidsetType(java.lang.String type)
Sets my type

	throw new IllegalArgumentException(localStrings.getLocalString(
		   "enterprise.deployment.exceptioncannotsettypeofmsgdrivenbean",
		   "Cannot set the type of a message-drive bean"));