You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

What's My Bean's JNDI Name?

The easiest way to answer that is with this chunk of code.

        public String getName(DeploymentInfo deploymentInfo, Class interfce, Interface type) {
            String deploymentId = deploymentInfo.getDeploymentID() + "";
            if (deploymentId.charAt(0) == '/') {
                deploymentId = deploymentId.substring(1);
            }

            switch (type) {
                case REMOTE_HOME:
                    return deploymentId;
                case LOCAL_HOME:
                    return deploymentId + "Local";
                case BUSINESS_LOCAL:
                    return deploymentId + "BusinessLocal";
                case BUSINESS_REMOTE:
                    return deploymentId + "BusinessRemote";
            }
            return deploymentId;
        }

This is the code that creates the JNDI names that clients use to lookup the bean. If you have no openejb-jar.xml the value for deploymentId is your ejb-name as mentioned in your ejb-jar.xml. If you have no ejb-jar.xml then per EJB3 rules the value of your ejb-name will default to the *un*qualified name of the ejb class (i.e. org.acme.WidgetBean would get the ejb-name WidgetBean).

In Development

The above naming strategy is rather limited. We are working on a way for users to configure specifically what JNDI name to use for each interface as well as a way to "set the pattern" we will use for creating default names when they aren't explicitly set.

  • No labels