MessageDestinationReferencerImpl.javaAPI DocGlassfish v2 API10545Fri May 04 22:31:22 BST 2007com.sun.enterprise.deployment


public class MessageDestinationReferencerImpl extends Object implements com.sun.enterprise.deployment.types.MessageDestinationReferencer, Serializable
Shared implementation for deployment descriptor entities that can refer to a message destination. Each MessageDestinationReferencer has an owner. The owner can either be a MessageDestinationReference or a MessageDrivenBean.
Kenneth Saks

Fields Summary
private String
private MessageDestinationDescriptor
private MessageDestinationReferenceDescriptor
private EjbMessageBeanDescriptor
Constructors Summary
public MessageDestinationReferencerImpl(MessageDestinationReferencerImpl other)

	messageDestinationLinkName = other.messageDestinationLinkName; // immutable String
	messageDestination = other.messageDestination; // copy as-is
	ownerMsgDestRef = other.ownerMsgDestRef; // copy as-is
	ownerMsgBean = other.ownerMsgBean; // copy as-is
public MessageDestinationReferencerImpl(Descriptor desc)

        if( desc instanceof MessageDestinationReferenceDescriptor ) {
            ownerMsgDestRef = (MessageDestinationReferenceDescriptor) desc;
        } else if( desc instanceof EjbMessageBeanDescriptor ) {
            ownerMsgBean = (EjbMessageBeanDescriptor) desc;
        } else {
            throw new IllegalArgumentException("Invalid desc = " + desc);
Methods Summary
private BundleDescriptorgetBundleDescriptor()

        return ownedByMessageDestinationRef() ?
            ownerMsgDestRef.getReferringBundleDescriptor() :
public EjbMessageBeanDescriptorgetMessageBeanOwner()
Get the descriptor for the message-driven bean owner.

        return ownerMsgBean;
public MessageDestinationDescriptorgetMessageDestination()

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

	return messageDestination;
public java.lang.StringgetMessageDestinationLinkName()

the link name of the message destination to which I refer NOTE that this "link name" is potentially different from the actual name of the target message destination, since the message destination could be defined in a different module.

        return messageDestinationLinkName;
public MessageDestinationReferenceDescriptorgetMessageDestinationRefOwner()
Get the descriptor for the message destination reference owner.

        return ownerMsgDestRef;
public booleanisLinkedToMessageDestination()
True if this reference has been resolved to a valid MessageDestination object.

	return (messageDestination != null);
public booleanownedByMessageBean()
True if the owner is a message-driven bean.

        return (ownerMsgBean != null);
public booleanownedByMessageDestinationRef()
True if the owner is a message destination reference.

        return (ownerMsgDestRef != null);
public MessageDestinationDescriptorresolveLinkName()
Try to resolve the current link name value to a MessageDestination object.

MessageDestination to which link was resolved, or null if link name resolution failed.

        MessageDestinationDescriptor msgDest = null;

        String linkName = messageDestinationLinkName;

        if( (linkName != null) && (linkName.length() > 0) ) {
            int hashIndex = linkName.indexOf('#");

            BundleDescriptor bundleDescriptor = getBundleDescriptor();
            Application app = bundleDescriptor.getApplication();
            BundleDescriptor targetBundle = bundleDescriptor;
            String msgDestName = linkName;
            if( app != null ) {

                // explicit reference to another module
                if( hashIndex != -1 )  {
                    String relativeModuleUri = linkName.substring(0, hashIndex);
                    msgDestName = linkName.substring(hashIndex + 1);
                    targetBundle = app.getRelativeBundle(bundleDescriptor,
                } else {
                    // Default is to find message destination within this
                    // module.  If it's not there, try searching the other
                    // modules.  NOTE that it's up to the deployer to ensure
                    // that any message destinations that are referred to
                    // from outside the defining module without an explicit
                    // reference have names that are unique within all the
                    // message destinations in the .ear.  There is no 
                    // required search ordering.  
                    if( !bundleDescriptor.hasMessageDestinationByName
                          (msgDestName) ) {
                        Set modules = app.getBundleDescriptors();
                        for(Iterator iter = modules.iterator(); iter.hasNext();)
                            BundleDescriptor next=(BundleDescriptor);
                            if( next.hasMessageDestinationByName(msgDestName) ) {
                                targetBundle = next;
            try {
                if( targetBundle != null ) {
                    msgDest = targetBundle.getMessageDestinationByName
            } catch(IllegalArgumentException iae) {}
        if( msgDest != null ) {

        return msgDest;
public voidsetMessageDestination(MessageDestinationDescriptor newMsgDest)

messageDestiation the message destination to which I refer.

        if( messageDestination != null ) {
        if( newMsgDest != null ) {

            // Keep message destination link name in synch with message 
            // destination object.
            BundleDescriptor bundleDescriptor = getBundleDescriptor();
            BundleDescriptor targetBundleDescriptor = 
            String linkName = newMsgDest.getName();
            if( bundleDescriptor != targetBundleDescriptor ) {
                Application app = bundleDescriptor.getApplication();
                String relativeUri = app.getRelativeUri(bundleDescriptor,
                linkName = relativeUri + "#" + linkName;
            messageDestinationLinkName = linkName;
        messageDestination = newMsgDest;
public voidsetMessageDestinationLinkName(java.lang.String linkName)
Sets the name of the message destination to which I refer. NOTE : Does *NOT* attempt to resolve link name. Use alternate version of setMessageDestinationLinkName or resolveLink if link resolution is required.

        setMessageDestinationLinkName(linkName, false);
public MessageDestinationDescriptorsetMessageDestinationLinkName(java.lang.String linkName, boolean resolve)
Sets the name of the message destination to which I refer.

resolve if true, *try* to resolve link to the target message destination.
MessageDestination to which link was resolved, or null if link name resolution failed.

        messageDestinationLinkName = linkName;
        MessageDestinationDescriptor msgDest = null;        

        if( resolve ) {
            msgDest = resolveLinkName();
        return msgDest;