[jboss-cvs] JBossAS SVN: r98079 - in projects/metadata/ejb/trunk/src: main/java/org/jboss/metadata/ejb/jboss/jndi and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 21 08:52:38 EST 2009
Author: jaikiran
Date: 2009-12-21 08:52:37 -0500 (Mon, 21 Dec 2009)
New Revision: 98079
Added:
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/JNDIPolicyBasedSessionBean31JNDINameResolver.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/JNDIPolicyBasedSessionBeanJNDINameResolver.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/EnterpriseBeanJNDINameResolver.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/SessionBean31JNDINameResolver.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/SessionBeanJNDINameResolver.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/DefaultBindingsBean.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/Echo.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoEJB2xLocal.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoEJB2xRemote.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoHome.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoLocal.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoLocalHome.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoRemote.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/ExplicitBindingStatelessBean.java
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/unit/
projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/unit/SessionBeanJNDINameResolverTestCase.java
Modified:
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/plugins/JavaEE6JndiBindingPolicy.java
projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/KnownInterfaces.java
Log:
JBMETA-241 Introduced JNDI name resolvers
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/JNDIPolicyBasedSessionBean31JNDINameResolver.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/JNDIPolicyBasedSessionBean31JNDINameResolver.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/JNDIPolicyBasedSessionBean31JNDINameResolver.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.jboss.jndi.resolver.impl;
+
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+import org.jboss.metadata.ejb.jboss.jndi.resolver.spi.SessionBean31JNDINameResolver;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces.KnownInterfaceType;
+
+/**
+ * JNDIPolicyBasedSessionBean31JNDINameResolver
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class JNDIPolicyBasedSessionBean31JNDINameResolver<T extends JBossSessionBean31MetaData>
+ extends
+ JNDIPolicyBasedSessionBeanJNDINameResolver<T> implements SessionBean31JNDINameResolver<T>
+{
+
+ /**
+ * @param jndibindingPolicy
+ */
+ public JNDIPolicyBasedSessionBean31JNDINameResolver(DefaultJndiBindingPolicy jndibindingPolicy)
+ {
+ super(jndibindingPolicy);
+ }
+
+ /**
+ * @see org.jboss.metadata.ejb.jboss.jndi.resolver.spi.SessionBean31JNDINameResolver#resolveNoInterfaceJNDIName(org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData)
+ */
+ @Override
+ public String resolveNoInterfaceJNDIName(T metadata)
+ {
+ // Get the no-interface view jndi name from the jndi binding policy
+ EjbDeploymentSummary ejbDeploymentSummary = this.getEjbDeploymentSummary(metadata);
+ return this.jndiBindingPolicy.getJndiName(ejbDeploymentSummary, KnownInterfaces.NO_INTERFACE, KnownInterfaceType.NO_INTERFACE);
+ }
+
+}
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/JNDIPolicyBasedSessionBeanJNDINameResolver.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/JNDIPolicyBasedSessionBeanJNDINameResolver.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/impl/JNDIPolicyBasedSessionBeanJNDINameResolver.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,270 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.jboss.jndi.resolver.impl;
+
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
+import org.jboss.metadata.ejb.jboss.jndi.resolver.spi.SessionBeanJNDINameResolver;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DeploymentSummary;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces.KnownInterfaceType;
+import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
+
+/**
+ * JNDIPolicyBasedSessionBeanJNDINameResolver
+ *
+ * A {@link SessionBeanJNDINameResolver} which uses a {@link DefaultJndiBindingPolicy}
+ * for resolving the jndi names.
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class JNDIPolicyBasedSessionBeanJNDINameResolver<T extends JBossSessionBeanMetaData>
+ implements
+ SessionBeanJNDINameResolver<T>
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(JNDIPolicyBasedSessionBeanJNDINameResolver.class);
+
+ /**
+ * The jndi binding policy which will be used for resolving the jndi names
+ */
+ protected DefaultJndiBindingPolicy jndiBindingPolicy;
+
+ /**
+ * Constructs a {@link JNDIPolicyBasedSessionBeanJNDINameResolver}
+ *
+ * @param jndibindingPolicy The jndi binding policy which will be used for resolving jndi names
+ * out of session bean metadata
+ */
+ public JNDIPolicyBasedSessionBeanJNDINameResolver(DefaultJndiBindingPolicy jndibindingPolicy)
+ {
+ this.jndiBindingPolicy = jndibindingPolicy;
+ }
+
+ /**
+ * @see org.jboss.metadata.ejb.jboss.jndi.resolver.spi.SessionBeanJNDINameResolver#resolveLocalHomeJNDIName(org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData)
+ */
+ @Override
+ public String resolveLocalHomeJNDIName(T metadata)
+ {
+ // Check first for explicitly-defined Local Home JNDI Name
+ String localHomeJndiName = metadata.getLocalHomeJndiName();
+ if (localHomeJndiName != null)
+ return localHomeJndiName;
+
+ // Get the local home jndi name from the jndi binding policy
+ EjbDeploymentSummary ejbDeploymentSummary = this.getEjbDeploymentSummary(metadata);
+ return this.jndiBindingPolicy.getJndiName(ejbDeploymentSummary, KnownInterfaces.LOCAL_HOME,
+ KnownInterfaceType.LOCAL_HOME);
+ }
+
+ /**
+ * @see org.jboss.metadata.ejb.jboss.jndi.resolver.spi.SessionBeanJNDINameResolver#resolveRemoteBusinessDefaultJNDIName(org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData)
+ */
+ @Override
+ public String resolveRemoteBusinessDefaultJNDIName(T metadata)
+ {
+ // Obtain remote bindings
+ List<RemoteBindingMetaData> bindings = metadata.getRemoteBindings();
+
+ // If defined, use the first remote binding as a JNDI default
+ if (bindings != null && bindings.size() > 0)
+ {
+ String remoteBindingJndiName = bindings.get(0).getJndiName();
+ if (remoteBindingJndiName != null && remoteBindingJndiName.length() > 0)
+ {
+ return remoteBindingJndiName;
+ }
+ }
+
+ // Try the mapped-name
+ String mappedName = metadata.getMappedName();
+ if (mappedName != null && mappedName.length() > 0)
+ return mappedName;
+
+ // Try explicit jndi-name
+ String jndiName = metadata.getJndiName();
+ if (jndiName != null && jndiName.length() > 0)
+ return jndiName;
+
+ // Not explicitly defined, so delegate out to the policy
+ EjbDeploymentSummary ejbDeploymentSummary = this.getEjbDeploymentSummary(metadata);
+ return this.jndiBindingPolicy.getJndiName(ejbDeploymentSummary, KnownInterfaces.REMOTE,
+ KnownInterfaceType.BUSINESS_REMOTE);
+ }
+
+ /**
+ * @see org.jboss.metadata.ejb.jboss.jndi.resolver.spi.SessionBeanJNDINameResolver#resolveRemoteHomeJNDIName(org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData)
+ */
+ @Override
+ public String resolveRemoteHomeJNDIName(T metadata)
+ {
+ // Check first for explicitly-defined Remote Home JNDI Name
+ String remoteHomeJndiName = metadata.getHomeJndiName();
+ if (remoteHomeJndiName != null)
+ return remoteHomeJndiName;
+
+ // Get the remote home jndi name from the jndi binding policy
+ EjbDeploymentSummary ejbDeploymentSummary = this.getEjbDeploymentSummary(metadata);
+ return this.jndiBindingPolicy.getJndiName(ejbDeploymentSummary, KnownInterfaces.HOME,
+ KnownInterfaceType.REMOTE_HOME);
+
+ }
+
+ /**
+ * @see org.jboss.metadata.ejb.jboss.jndi.resolver.spi.SessionBeanJNDINameResolver#resolveLocalBusinessDefaultJNDIName(org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData)
+ */
+ @Override
+ public String resolveLocalBusinessDefaultJNDIName(T metadata)
+ {
+ // Check first for explicitly-defined local JNDI Name
+ String localJndiName = metadata.getLocalJndiName();
+ if (localJndiName != null && localJndiName.length() > 0)
+ return localJndiName;
+
+ // Get the local jndi name from the jndi binding policy
+ EjbDeploymentSummary ejbDeploymentSummary = this.getEjbDeploymentSummary(metadata);
+ return this.jndiBindingPolicy.getJndiName(ejbDeploymentSummary, KnownInterfaces.LOCAL,
+ KnownInterfaceType.BUSINESS_LOCAL);
+ }
+
+ /**
+ * @see org.jboss.metadata.ejb.jboss.jndi.resolver.spi.EnterpriseBeanJNDINameResolver#resolveJNDIName(org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData, java.lang.String)
+ */
+ @Override
+ public String resolveJNDIName(T metadata, String interfaceName)
+ {
+ String resolvedJndiName = null;
+
+ // Classify the interface
+ KnownInterfaceType ifaceType = classifyInterface(metadata, interfaceName);
+
+ // Take appropriate handling depending upon the interface
+ if (ifaceType.equals(KnownInterfaceType.REMOTE_HOME))
+ {
+ resolvedJndiName = this.resolveRemoteHomeJNDIName(metadata);
+ }
+ if (ifaceType.equals(KnownInterfaceType.LOCAL_HOME))
+ {
+ resolvedJndiName = this.resolveLocalHomeJNDIName(metadata);
+ }
+ if (ifaceType.equals(KnownInterfaceType.BUSINESS_REMOTE) || ifaceType.equals(KnownInterfaceType.BUSINESS_LOCAL))
+ {
+ // Revert to defaults; have the policy generate the actual name
+ resolvedJndiName = this.jndiBindingPolicy.getJndiName(this.getEjbDeploymentSummary(metadata), interfaceName,
+ ifaceType);
+ }
+
+ logger.debug("Resolved JNDI Name for Interface " + interfaceName + " of type " + ifaceType + " is "
+ + resolvedJndiName);
+
+ // Return
+ return resolvedJndiName;
+ }
+
+ /**
+ * Classifies the fully qualified <code>interfaceName</code> into a {@link KnownInterfaceType}
+ * based on the bean <code>metadata</code>.
+ *
+ * @param metadata The bean metadata
+ * @param interfaceName Fully qualified interface name
+ * @return Returns a {@link KnownInterfaceType}
+ * @throws NullPointerException If <code>metadata</code> is null
+ */
+ protected KnownInterfaceType classifyInterface(T metadata, String interfaceName)
+ {
+
+ // TODO: Why do we need this? The KnownInterfaces.classifyInterface expects the param
+ // passed to be strings like "home", "remote" etc...
+// KnownInterfaceType ifaceType = KnownInterfaces.classifyInterface(iface);
+// if (ifaceType != KnownInterfaceType.UNKNOWN)
+// return ifaceType;
+
+ KnownInterfaceType ifaceType = KnownInterfaceType.UNKNOWN;
+
+ // Compare interface against the metadata local-home/home & business locals/remotes
+ // Figure out the interface type from the metadata
+ if (metadata.getLocalHome() != null && metadata.getLocalHome().equals(interfaceName))
+ return KnownInterfaceType.LOCAL_HOME;
+ else if (metadata.getHome() != null && metadata.getHome().equals(interfaceName))
+ return KnownInterfaceType.REMOTE_HOME;
+ else
+ {
+ // Check business locals
+ BusinessLocalsMetaData locals = metadata.getBusinessLocals();
+ if (locals != null)
+ {
+ for (String local : locals)
+ {
+ if (local.equals(interfaceName))
+ {
+ return KnownInterfaceType.BUSINESS_LOCAL;
+ }
+ }
+ }
+ if (ifaceType == KnownInterfaceType.UNKNOWN)
+ {
+ // Check business remotes
+ BusinessRemotesMetaData remotes = metadata.getBusinessRemotes();
+ if (remotes != null)
+ {
+ for (String remote : remotes)
+ {
+ if (remote.equals(interfaceName))
+ {
+ return KnownInterfaceType.BUSINESS_REMOTE;
+ }
+ }
+ }
+ }
+ }
+
+ // Assume business remote
+ return KnownInterfaceType.BUSINESS_REMOTE;
+ }
+
+ /**
+ * Returns the {@link EjbDeploymentSummary} from the metadata
+ *
+ * @param metadata Bean metadata
+ * @return
+ */
+ protected EjbDeploymentSummary getEjbDeploymentSummary(T metadata)
+ {
+ DeploymentSummary dsummary = metadata.getJBossMetaData().getDeploymentSummary();
+ if (dsummary == null)
+ dsummary = new DeploymentSummary();
+ return new EjbDeploymentSummary(metadata, dsummary);
+ }
+
+
+}
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/EnterpriseBeanJNDINameResolver.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/EnterpriseBeanJNDINameResolver.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/EnterpriseBeanJNDINameResolver.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.jboss.jndi.resolver.spi;
+
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+
+/**
+ * EnterpriseBeanJNDIResolver
+ *
+ * A JNDI name resolver capable of resolving JNDI names for an enterprise bean,
+ * from the enterprise bean's metadata
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface EnterpriseBeanJNDINameResolver<T extends JBossEnterpriseBeanMetaData>
+{
+
+ /**
+ * Returns the JNDI name for the <code>interfaceName</code>, of the session bean
+ * represented by the <code>metadata</code>.
+ *
+ * Returns null if the JNDI name for the <code>interfaceName</code> cannot be resolved
+ *
+ * @param iface The fully qualified interface name
+ * @return
+ */
+ String resolveJNDIName(T metadata, String interfaceName);
+}
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/SessionBean31JNDINameResolver.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/SessionBean31JNDINameResolver.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/SessionBean31JNDINameResolver.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.jboss.jndi.resolver.spi;
+
+import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
+
+/**
+ * SessionBean31JNDINameResolver
+ *
+ * A JNDI name resolver capable of resolving JNDI names for a EJB3.1 session bean,
+ * from the session bean's metadata
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface SessionBean31JNDINameResolver<T extends JBossSessionBean31MetaData>
+ extends
+ SessionBeanJNDINameResolver<T>
+{
+
+ /**
+ * Returns the JNDI name for the default EJB3.1 no-interface view, of the session bean
+ * represented by the <code>metadata</code>.
+ *
+ * Returns null if the JNDI name for EJB3.1 no-interface view cannot be resolved
+ * @return
+ */
+ public String resolveNoInterfaceJNDIName(T metadata);
+}
Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/SessionBeanJNDINameResolver.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/SessionBeanJNDINameResolver.java (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndi/resolver/spi/SessionBeanJNDINameResolver.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.jboss.jndi.resolver.spi;
+
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * SessionBeanJNDINameResolver
+ *
+ * A JNDI name resolver capable of resolving JNDI names for a session bean,
+ * from the session bean's metadata
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface SessionBeanJNDINameResolver<T extends JBossSessionBeanMetaData>
+ extends
+ EnterpriseBeanJNDINameResolver<T>
+{
+
+ /**
+ * Returns the JNDI name for the EJB2.x Remote Home interface, of the session bean
+ * represented by the <code>metadata</code>.
+ *
+ * Returns null if the JNDI name EJB2.x Remote Home interface cannot be resolved
+ * @return
+ */
+ public String resolveRemoteHomeJNDIName(T metadata);
+
+ /**
+ * Returns the JNDI name for the EJB2.x Local Home interface, of the session bean
+ * represented by the <code>metadata</code>.
+ *
+ * Returns null if the JNDI name for EJB2.x Local Home interface cannot be resolved
+ * @return
+ */
+ public String resolveLocalHomeJNDIName(T metadata);
+
+ /**
+ * Returns the JNDI name for the default EJB3.x Remote Business interfaces, of the session bean
+ * represented by the <code>metadata</code>.
+ *
+ * Returns null if the JNDI name for EJB3.x Remote Business interfaces cannot be resolved
+ * @return
+ */
+ public String resolveRemoteBusinessDefaultJNDIName(T metadata);
+
+ /**
+ * Returns the JNDI name for the default EJB3.x Local Business interfaces, of the session bean
+ * represented by the <code>metadata</code>.
+ *
+ * Returns null if the JNDI name for EJB3.x Local Business interfaces cannot be resolved
+ * @return
+ */
+ public String resolveLocalBusinessDefaultJNDIName(T metadata);
+}
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/plugins/JavaEE6JndiBindingPolicy.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/plugins/JavaEE6JndiBindingPolicy.java 2009-12-21 13:19:39 UTC (rev 98078)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/plugins/JavaEE6JndiBindingPolicy.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -169,6 +169,11 @@
// base-name / (local|remote)Home
jndiName = baseJndiName + "!" + ifaceType.toSuffix();
break;
+
+ case NO_INTERFACE:
+ // base-name ! no-interface
+ jndiName = baseJndiName + "!" + ifaceType.toSuffix();
+ break;
}
}
else
Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/KnownInterfaces.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/KnownInterfaces.java 2009-12-21 13:19:39 UTC (rev 98078)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/ejb/jboss/jndipolicy/spi/KnownInterfaces.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -38,7 +38,8 @@
BUSINESS_REMOTE(KnownInterfaces.REMOTE),
LOCAL_HOME(KnownInterfaces.LOCAL_HOME),
REMOTE_HOME(KnownInterfaces.HOME),
- UNKNOWN(KnownInterfaces.UNKNOWN);
+ UNKNOWN(KnownInterfaces.UNKNOWN),
+ NO_INTERFACE(KnownInterfaces.NO_INTERFACE);
/**
* Get the preferred jndi binding suffix
@@ -59,6 +60,7 @@
public static final String LOCAL_HOME = "localHome";
public static final String REMOTE = "remote";
public static final String HOME = "home";
+ public static final String NO_INTERFACE = "no-interface";
public static final String UNKNOWN = "unknown";
/**
@@ -72,6 +74,7 @@
|| KnownInterfaces.LOCAL.equalsIgnoreCase(iface)
|| KnownInterfaces.LOCAL_HOME.equalsIgnoreCase(iface)
|| KnownInterfaces.REMOTE.equalsIgnoreCase(iface)
+ || KnownInterfaces.NO_INTERFACE.equalsIgnoreCase(iface)
;
return isKnownInterface;
}
@@ -92,6 +95,8 @@
ifaceType = KnownInterfaceType.LOCAL_HOME;
else if(KnownInterfaces.REMOTE.equalsIgnoreCase(iface))
ifaceType = KnownInterfaceType.BUSINESS_REMOTE;
+ else if(KnownInterfaces.NO_INTERFACE.equalsIgnoreCase(iface))
+ ifaceType = KnownInterfaceType.NO_INTERFACE;
return ifaceType;
}
}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/DefaultBindingsBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/DefaultBindingsBean.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/DefaultBindingsBean.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateful;
+
+/**
+ * DefaultBindingsBean
+ *
+ * (Yeah, it doesn't make sense for a "Echo" bean to be Stateful. But it's used only in
+ * testcases after all!)
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateful
+ at Remote (EchoRemote.class)
+ at Local (EchoLocal.class)
+ at LocalHome(EchoLocalHome.class)
+ at RemoteHome(EchoHome.class)
+public class DefaultBindingsBean implements Echo
+{
+
+ /**
+ * @see org.jboss.metadata.ejb.test.jndiresolver.Echo#echo(java.lang.String)
+ */
+ @Override
+ public String echo(String msg)
+ {
+ return msg;
+ }
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/Echo.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/Echo.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/Echo.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,34 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+/**
+ * Echo
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface Echo
+{
+
+ String echo(String msg);
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoEJB2xLocal.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoEJB2xLocal.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoEJB2xLocal.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * EchoEJB2xLocal
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface EchoEJB2xLocal extends Echo, EJBLocalObject
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoEJB2xRemote.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoEJB2xRemote.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoEJB2xRemote.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBObject;
+
+/**
+ * EchoEJB2xRemote
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface EchoEJB2xRemote extends EJBObject
+{
+ String echo(String msg) throws RemoteException;
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoHome.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoHome.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoHome.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * EchoHome
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface EchoHome extends EJBHome
+{
+ EchoEJB2xRemote create () throws CreateException;
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoLocal.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoLocal.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoLocal.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+/**
+ * EchoLocal
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface EchoLocal extends Echo
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoLocalHome.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoLocalHome.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoLocalHome.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,36 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+import javax.ejb.EJBLocalHome;
+
+/**
+ * EchoLocalHome
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface EchoLocalHome extends EJBLocalHome
+{
+
+ EchoEJB2xLocal create();
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoRemote.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoRemote.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/EchoRemote.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+/**
+ * EchoRemote
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface EchoRemote extends Echo
+{
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/ExplicitBindingStatelessBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/ExplicitBindingStatelessBean.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/ExplicitBindingStatelessBean.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,70 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver;
+
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.LocalBinding;
+import org.jboss.ejb3.annotation.LocalHomeBinding;
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.RemoteHomeBinding;
+
+/**
+ * ExplicitBindingStatelessBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote (EchoRemote.class)
+ at RemoteBinding (jndiBinding=ExplicitBindingStatelessBean.REMOTE_JNDI_NAME)
+ at LocalBinding (jndiBinding=ExplicitBindingStatelessBean.LOCAL_JNDI_NAME)
+ at Local (EchoLocal.class)
+ at LocalHome(EchoLocalHome.class)
+ at RemoteHome(EchoHome.class)
+ at RemoteHomeBinding(jndiBinding=ExplicitBindingStatelessBean.REMOTE_HOME_JNDI_NAME)
+ at LocalHomeBinding(jndiBinding=ExplicitBindingStatelessBean.LOCAL_HOME_JNDI_NAME)
+public class ExplicitBindingStatelessBean implements Echo
+{
+
+ public static final String REMOTE_JNDI_NAME = "Explicit_Remote_Jndi_Name";
+
+ public static final String REMOTE_HOME_JNDI_NAME = "Explicit_Remote_Home_Jndi_Name";
+
+ public static final String LOCAL_JNDI_NAME = "Explicit_Local_Jndi_Name";
+
+ public static final String LOCAL_HOME_JNDI_NAME = "Explicit_Local_Home_Jndi_Name";
+
+ /**
+ * @see org.jboss.metadata.ejb.test.jndiresolver.Echo#echo(java.lang.String)
+ */
+ @Override
+ public String echo(String msg)
+ {
+ return msg;
+ }
+
+}
Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/unit/SessionBeanJNDINameResolverTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/unit/SessionBeanJNDINameResolverTestCase.java (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jndiresolver/unit/SessionBeanJNDINameResolverTestCase.java 2009-12-21 13:52:37 UTC (rev 98079)
@@ -0,0 +1,220 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.ejb.test.jndiresolver.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndi.resolver.impl.JNDIPolicyBasedSessionBeanJNDINameResolver;
+import org.jboss.metadata.ejb.jboss.jndi.resolver.spi.SessionBeanJNDINameResolver;
+import org.jboss.metadata.ejb.jboss.jndipolicy.plugins.BasicJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.DefaultJndiBindingPolicy;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.KnownInterfaces.KnownInterfaceType;
+import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
+import org.jboss.metadata.ejb.test.jndiresolver.DefaultBindingsBean;
+import org.jboss.metadata.ejb.test.jndiresolver.ExplicitBindingStatelessBean;
+import org.jboss.metadata.process.processor.JBossMetaDataProcessor;
+import org.jboss.metadata.process.processor.ejb.jboss.SetExplicitLocalJndiNameProcessor;
+import org.jboss.test.metadata.common.PackageScanner;
+import org.jboss.test.metadata.common.ScanPackage;
+import org.junit.Test;
+
+/**
+ * SessionBeanJNDINameResolver
+ *
+ * Test case for testing the jndi name resolvers for session beans
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class SessionBeanJNDINameResolverTestCase
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(SessionBeanJNDINameResolverTestCase.class);
+
+ /**
+ * Tests that the jndi names of a bean explicitly marked with jndi bindings
+ * (like @RemoteBinding, @LocalHomeBinding etc...), will be correctly resolved by the
+ * jndi name resolver.
+ *
+ * @throws Exception
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.jndiresolver")
+ public void testJNDINameResolutionForExplicitlyBindings() throws Exception
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull(metaData);
+
+ // process the metadata through the SetExplicitLocalJndiNameProcessor processor
+ // which is expected to set the local jndi name on the beans
+ JBossMetaDataProcessor<JBossMetaData> processor = SetExplicitLocalJndiNameProcessor.INSTANCE;
+ metaData = processor.process(metaData);
+
+ String beanName = ExplicitBindingStatelessBean.class.getSimpleName();
+ JBossEnterpriseBeanMetaData bean = metaData.getEnterpriseBean(beanName);
+ assertNotNull("Could not get metadata for bean " + beanName);
+ assertTrue(beanName + " is not a session bean", bean.isSession());
+ JBossSessionBeanMetaData sessionBean = (JBossSessionBeanMetaData) bean;
+ // Create a jndi name resolver based on the jndi binding policy
+ DefaultJndiBindingPolicy jndiBindingPolicy = new BasicJndiBindingPolicy();
+ SessionBeanJNDINameResolver<JBossSessionBeanMetaData> jndiNameResolver = new JNDIPolicyBasedSessionBeanJNDINameResolver<JBossSessionBeanMetaData>(
+ jndiBindingPolicy);
+
+ // ensure that the remote default business interface jndi name is correctly resolved
+ String remoteDefaultBusinessJNDIName = jndiNameResolver.resolveRemoteBusinessDefaultJNDIName(sessionBean);
+ assertEquals("Incorrect default remote business jndi name returned by jndi name resolver",
+ ExplicitBindingStatelessBean.REMOTE_JNDI_NAME, remoteDefaultBusinessJNDIName);
+ // ensure that the local default business interface jndi name is correctly resolved
+ String localDefaultBusinessJNDIName = jndiNameResolver.resolveLocalBusinessDefaultJNDIName(sessionBean);
+ assertEquals("Incorrect default local business jndi name returned by jndi name resolver",
+ ExplicitBindingStatelessBean.LOCAL_JNDI_NAME, localDefaultBusinessJNDIName);
+
+ // ensure that the remote home interface jndi name is correctly resolved
+ String remoteHomeJndiName = jndiNameResolver.resolveRemoteHomeJNDIName(sessionBean);
+ assertEquals("Incorrect remote home jndi name returned by jndi name resolver",
+ ExplicitBindingStatelessBean.REMOTE_HOME_JNDI_NAME, remoteHomeJndiName);
+
+ // ensure that the local home jndi name is correctly resolved
+ String localHomeJndiName = jndiNameResolver.resolveLocalHomeJNDIName(sessionBean);
+ assertEquals("Incorrect local home jndi name returned by jndi name resolver",
+ ExplicitBindingStatelessBean.LOCAL_HOME_JNDI_NAME, localHomeJndiName);
+
+ // test remote business interface specific binding (per remote business interface)
+ BusinessRemotesMetaData businessRemotes = sessionBean.getBusinessRemotes();
+ assertNotNull("Business remotes metadata was null", businessRemotes);
+ for (String businessRemote : businessRemotes)
+ {
+ String remoteBusinessInterfaceJNDIName = jndiNameResolver.resolveJNDIName(sessionBean, businessRemote);
+ logger.debug("Resolved remote business interface specific binding for interface " + businessRemote + " is "
+ + remoteBusinessInterfaceJNDIName);
+ assertEquals("Incorrect remote business interface jndi name returned by jndi name resolver", beanName + "/"
+ + KnownInterfaceType.BUSINESS_REMOTE.toSuffix() + "-" + businessRemote, remoteBusinessInterfaceJNDIName);
+
+ }
+
+ // test local business interface specific binding (per local business interface)
+ BusinessLocalsMetaData businessLocals = sessionBean.getBusinessLocals();
+ assertNotNull("Business locals metadata was null", businessLocals);
+ for (String businessLocal : businessLocals)
+ {
+ String localBusinessInterfaceJNDIName = jndiNameResolver.resolveJNDIName(sessionBean, businessLocal);
+ logger.debug("Resolved local business interface specific binding for interface " + businessLocal + " is "
+ + localBusinessInterfaceJNDIName);
+ assertEquals("Incorrect local business interface jndi name returned by jndi name resolver", beanName + "/"
+ + KnownInterfaceType.BUSINESS_LOCAL.toSuffix() + "-" + businessLocal, localBusinessInterfaceJNDIName);
+
+ }
+
+ }
+
+ /**
+ * Tests that the jndi names of a bean which does *not* explicitly set the jndi bindings,
+ * is resolved correctly by the jndi name resolvers
+ *
+ * @throws Exception
+ */
+ @Test
+ @ScanPackage("org.jboss.metadata.ejb.test.jndiresolver")
+ public void testDefaultJNDIBindings() throws Exception
+ {
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ JBoss50Creator creator = new JBoss50Creator(finder);
+ Collection<Class<?>> classes = PackageScanner.loadClasses();
+ JBossMetaData metaData = creator.create(classes);
+ assertNotNull(metaData);
+
+ String beanName = DefaultBindingsBean.class.getSimpleName();
+ JBossEnterpriseBeanMetaData bean = metaData.getEnterpriseBean(beanName);
+ assertNotNull("Could not get metadata for bean " + beanName);
+ assertTrue(beanName + " is not a session bean", bean.isSession());
+ JBossSessionBeanMetaData sessionBean = (JBossSessionBeanMetaData) bean;
+ // Create a jndi name resolver based on the jndi binding policy
+ DefaultJndiBindingPolicy jndiBindingPolicy = new BasicJndiBindingPolicy();
+ SessionBeanJNDINameResolver<JBossSessionBeanMetaData> jndiNameResolver = new JNDIPolicyBasedSessionBeanJNDINameResolver<JBossSessionBeanMetaData>(
+ jndiBindingPolicy);
+
+ // ensure that the remote default business interface jndi name is correctly resolved
+ String remoteDefaultBusinessJNDIName = jndiNameResolver.resolveRemoteBusinessDefaultJNDIName(sessionBean);
+ assertEquals("Incorrect default remote business jndi name returned by jndi name resolver", beanName + "/"
+ + KnownInterfaceType.BUSINESS_REMOTE.toSuffix(), remoteDefaultBusinessJNDIName);
+ // ensure that the local default business interface jndi name is correctly resolved
+ String localDefaultBusinessJNDIName = jndiNameResolver.resolveLocalBusinessDefaultJNDIName(sessionBean);
+ assertEquals("Incorrect default local business jndi name returned by jndi name resolver", beanName + "/"
+ + KnownInterfaceType.BUSINESS_LOCAL.toSuffix(), localDefaultBusinessJNDIName);
+
+ // ensure that the remote home interface jndi name is correctly resolved
+ String remoteHomeJndiName = jndiNameResolver.resolveRemoteHomeJNDIName(sessionBean);
+ assertEquals("Incorrect remote home jndi name returned by jndi name resolver", beanName + "/"
+ + KnownInterfaceType.REMOTE_HOME.toSuffix(), remoteHomeJndiName);
+
+ // ensure that the local home jndi name is correctly resolved
+ String localHomeJndiName = jndiNameResolver.resolveLocalHomeJNDIName(sessionBean);
+ assertEquals("Incorrect local home jndi name returned by jndi name resolver", beanName + "/"
+ + KnownInterfaceType.LOCAL_HOME.toSuffix(), localHomeJndiName);
+
+ // test remote business interface specific binding (per remote business interface)
+ BusinessRemotesMetaData businessRemotes = sessionBean.getBusinessRemotes();
+ assertNotNull("Business remotes metadata was null", businessRemotes);
+ for (String businessRemote : businessRemotes)
+ {
+ String remoteBusinessInterfaceJNDIName = jndiNameResolver.resolveJNDIName(sessionBean, businessRemote);
+ logger.debug("Resolved remote business interface specific binding for interface " + businessRemote + " is "
+ + remoteBusinessInterfaceJNDIName);
+ assertEquals("Incorrect remote business interface jndi name returned by jndi name resolver", beanName + "/"
+ + KnownInterfaceType.BUSINESS_REMOTE.toSuffix() + "-" + businessRemote, remoteBusinessInterfaceJNDIName);
+
+ }
+
+ // test local business interface specific binding (per local business interface)
+ BusinessLocalsMetaData businessLocals = sessionBean.getBusinessLocals();
+ assertNotNull("Business locals metadata was null", businessLocals);
+ for (String businessLocal : businessLocals)
+ {
+ String localBusinessInterfaceJNDIName = jndiNameResolver.resolveJNDIName(sessionBean, businessLocal);
+ logger.debug("Resolved local business interface specific binding for interface " + businessLocal + " is "
+ + localBusinessInterfaceJNDIName);
+ assertEquals("Incorrect local business interface jndi name returned by jndi name resolver", beanName + "/"
+ + KnownInterfaceType.BUSINESS_LOCAL.toSuffix() + "-" + businessLocal, localBusinessInterfaceJNDIName);
+
+ }
+
+ }
+}
More information about the jboss-cvs-commits
mailing list