[jboss-cvs] JBossAS SVN: r74580 - in projects/ejb3/trunk/proxy/src: test/java/org/jboss/ejb3/test/proxy/common/container and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Jun 15 14:16:14 EDT 2008
Author: ALRubinger
Date: 2008-06-15 14:16:12 -0400 (Sun, 15 Jun 2008)
New Revision: 74580
Modified:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatefulSessionRegistrar.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatelessSessionRegistrar.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java
projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase-beans.xml
projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionTestCase-beans.xml
projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionTestCase-beans.xml
Log:
[EJBTHREE-1389] JNDI Registrars no longer use preconfigured Context, but that of the calling Container
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java 2008-06-15 18:03:41 UTC (rev 74579)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java 2008-06-15 18:16:12 UTC (rev 74580)
@@ -85,11 +85,6 @@
// --------------------------------------------------------------------------------||
/**
- * Context under which we'll bind to JNDI
- */
- private Context context;
-
- /**
* Fully-qualified class name of the JNDI Object Factory to Reference
*/
private String sessionProxyObjectFactoryType;
@@ -102,17 +97,11 @@
* Creates a JNDI Registrar from the specified configuration properties, none of
* which may be null.
*
- * @param context The JNDI Context into which Objects will be bound
* @param sessionProxyObjectFactoryType String representation of the JNDI Object
* Factory Class Name (fully-qualified) to use for this Session EJB
*/
- public JndiSessionRegistrarBase(final Context context, final String sessionProxyObjectFactoryType)
+ public JndiSessionRegistrarBase(final String sessionProxyObjectFactoryType)
{
- // Set the Context
- assert context != null : this + " may not be configured with null " + Context.class.getName();
- this.setContext(context);
- log.debug("Using " + Context.class.getName() + ": " + context);
-
/*
* Perform some assertions and logging
*/
@@ -146,11 +135,13 @@
* responsible for creation and registration of any all ProxyFactory
* implementations required by the EJB
*
+ * @param context The JNDI Context to use for binding
* @param smd
* @param cl The CL of the Container
* @param containerName The name under which the target container is registered
*/
- public void bindEjb(final JBossSessionBeanMetaData smd, final ClassLoader cl, final String containerName)
+ public void bindEjb(final Context context, final JBossSessionBeanMetaData smd, final ClassLoader cl,
+ final String containerName)
{
// Log
String ejbName = smd.getEjbName();
@@ -245,7 +236,7 @@
assert homeAddress != null && !homeAddress.equals("") : "JNDI Address for Remote Home must be defined";
log.debug("Remote Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \"" + homeAddress
+ "\"");
- this.bind(homeRef, homeAddress, remoteProxyFactoryKey, containerName);
+ this.bind(context, homeRef, homeAddress, remoteProxyFactoryKey, containerName);
}
// Add a Reference Address for the Remoting URL
@@ -275,7 +266,7 @@
String defaultRemoteAddress = smd.determineJndiName();
log.debug("Default Remote Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ defaultRemoteAddress + "\"");
- this.bind(defaultRemoteRef, defaultRemoteAddress, remoteProxyFactoryKey, containerName);
+ this.bind(context, defaultRemoteRef, defaultRemoteAddress, remoteProxyFactoryKey, containerName);
// Bind ObjectFactory specific to each Remote Business Interface
if (businessRemotes != null)
@@ -292,7 +283,7 @@
String address = smd.determineResolvedJndiName(businessRemote);
log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
+ " to be bound into JNDI at \"" + address + "\"");
- this.bind(ref, address, remoteProxyFactoryKey, containerName);
+ this.bind(context, ref, address, remoteProxyFactoryKey, containerName);
}
}
}
@@ -339,7 +330,7 @@
String localHomeAddress = smd.getLocalHomeJndiName();
log.debug("Local Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \"" + localHomeAddress
+ "\"");
- this.bind(localHomeRef, localHomeAddress, localProxyFactoryKey, containerName);
+ this.bind(context, localHomeRef, localHomeAddress, localProxyFactoryKey, containerName);
}
/*
@@ -366,7 +357,7 @@
String defaultLocalAddress = smd.determineLocalJndiName();
log.debug("Default Local Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ defaultLocalAddress + "\"");
- this.bind(defaultLocalRef, defaultLocalAddress, localProxyFactoryKey, containerName);
+ this.bind(context, defaultLocalRef, defaultLocalAddress, localProxyFactoryKey, containerName);
// Bind ObjectFactory specific to each Local Business Interface
if (businessLocals != null)
@@ -381,7 +372,7 @@
String address = smd.determineResolvedJndiName(businessLocal);
log.debug("Local Business View for " + businessLocal + " of EJB " + smd.getEjbName()
+ " to be bound into JNDI at \"" + address + "\"");
- this.bind(ref, address, localProxyFactoryKey, containerName);
+ this.bind(context, ref, address, localProxyFactoryKey, containerName);
}
}
@@ -394,9 +385,10 @@
* responsible for destruction and deregistration of any all ProxyFactory
* implementations required by the EJB
*
+ * @param context The JNDI Context to use for unbinding
* @param smd
*/
- public void unbindEjb(final JBossSessionBeanMetaData smd)
+ public void unbindEjb(final Context context, final JBossSessionBeanMetaData smd)
{
// Log
String ejbName = smd.getEjbName();
@@ -445,7 +437,7 @@
String homeAddress = smd.getHomeJndiName();
log.debug("Remote Home View for EJB " + smd.getEjbName() + " to be unbound from JNDI at \"" + homeAddress
+ "\"");
- this.unbind(homeAddress);
+ this.unbind(context, homeAddress);
}
/*
@@ -456,7 +448,7 @@
String defaultRemoteAddress = smd.determineJndiName();
log.debug("Default Remote Business View for EJB " + smd.getEjbName() + " to be unbound from JNDI at \""
+ defaultRemoteAddress + "\"");
- this.unbind(defaultRemoteAddress);
+ this.unbind(context, defaultRemoteAddress);
// Unbind ObjectFactory specific to each Remote Business Interface
if (businessRemotes != null)
@@ -466,7 +458,7 @@
String address = smd.determineResolvedJndiName(businessRemote);
log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
+ " to be unbound from JNDI at \"" + address + "\"");
- this.unbind(address);
+ this.unbind(context, address);
}
}
}
@@ -486,7 +478,7 @@
String localHomeAddress = smd.getLocalHomeJndiName();
log.debug("Local Home View for EJB " + smd.getEjbName() + " to be unbound from JNDI at \""
+ localHomeAddress + "\"");
- this.unbind(localHomeAddress);
+ this.unbind(context, localHomeAddress);
}
/*
@@ -497,7 +489,7 @@
String defaultLocalAddress = smd.determineLocalJndiName();
log.debug("Default Local Business View for EJB " + smd.getEjbName() + " to be unbound from JNDI at \""
+ defaultLocalAddress + "\"");
- this.unbind(defaultLocalAddress);
+ this.unbind(context,defaultLocalAddress);
// Unbind ObjectFactory specific to each Local Business Interface
if (businessLocals != null)
@@ -507,7 +499,7 @@
String address = smd.determineResolvedJndiName(businessLocal);
log.debug("Local Business View for " + businessLocal + " of EJB " + smd.getEjbName()
+ " to be unbound from JNDI at \"" + address + "\"");
- this.unbind(address);
+ this.unbind(context, address);
}
}
}
@@ -551,13 +543,15 @@
* the requisite key for the ProxyFactory within the Registry and the requisite
* target EJB Container Name as ReferenceAddresses
*
+ * @param context The JNDI Context to use
* @param ref
* @param address
* @param proxyFactoryRegistryKey The key under which the proxy factory
* for this reference is stored in the proxy factory registry
* @param containerName The target container to be used in invocations from Proxies obtained from this address
*/
- protected void bind(Reference ref, String address, String proxyFactoryRegistryKey, String containerName)
+ protected void bind(Context context, Reference ref, String address, String proxyFactoryRegistryKey,
+ String containerName)
{
// Add the Proxy Factory Registry key for this Reference
assert proxyFactoryRegistryKey != null && !proxyFactoryRegistryKey.trim().equals("") : "Proxy Factory Registry key is required but not supplied";
@@ -578,7 +572,7 @@
// Bind
try
{
- Util.rebind(this.getContext(), address, ref);
+ Util.rebind(context, address, ref);
log.debug("Bound " + ref.getClass().getName() + " into JNDI at \"" + address + "\"");
}
catch (NamingException e)
@@ -590,14 +584,15 @@
/**
* Unbinds the specified address from JNDI
*
+ * @param context The JNDI Context to use
* @param address
*/
- protected void unbind(String address)
+ protected void unbind(Context context, String address)
{
// Unbind
try
{
- Util.unbind(this.getContext(), address);
+ Util.unbind(context, address);
}
catch (NameNotFoundException nnfe)
{
@@ -777,16 +772,6 @@
// Accessors / Mutators -----------------------------------------------------------||
// --------------------------------------------------------------------------------||
- public Context getContext()
- {
- return context;
- }
-
- public void setContext(Context context)
- {
- this.context = context;
- }
-
public String getSessionProxyObjectFactoryType()
{
return sessionProxyObjectFactoryType;
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatefulSessionRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatefulSessionRegistrar.java 2008-06-15 18:03:41 UTC (rev 74579)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatefulSessionRegistrar.java 2008-06-15 18:16:12 UTC (rev 74580)
@@ -21,8 +21,6 @@
*/
package org.jboss.ejb3.proxy.jndiregistrar;
-import javax.naming.Context;
-
import org.jboss.aop.Dispatcher;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionLocalProxyFactory;
@@ -57,12 +55,11 @@
* Creates a JNDI Registrar from the specified configuration properties, none of
* which may be null.
*
- * @param context The JNDI Context into which Objects will be bound
* @param statelessSessionProxyObjectFactoryType String representation of the JNDI Object Factory to use for SLSBs
*/
- public JndiStatefulSessionRegistrar(Context context, String statelessSessionProxyObjectFactoryType)
+ public JndiStatefulSessionRegistrar(String statelessSessionProxyObjectFactoryType)
{
- super(context, statelessSessionProxyObjectFactoryType);
+ super(statelessSessionProxyObjectFactoryType);
}
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatelessSessionRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatelessSessionRegistrar.java 2008-06-15 18:03:41 UTC (rev 74579)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiStatelessSessionRegistrar.java 2008-06-15 18:16:12 UTC (rev 74580)
@@ -21,8 +21,6 @@
*/
package org.jboss.ejb3.proxy.jndiregistrar;
-import javax.naming.Context;
-
import org.jboss.aop.Dispatcher;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionLocalProxyFactory;
@@ -56,12 +54,11 @@
* Creates a JNDI Registrar from the specified configuration properties, none of
* which may be null.
*
- * @param context The JNDI Context into which Objects will be bound
* @param statelessSessionProxyObjectFactoryType String representation of the JNDI Object Factory to use for SLSBs
*/
- public JndiStatelessSessionRegistrar(Context context, String statelessSessionProxyObjectFactoryType)
+ public JndiStatelessSessionRegistrar(String statelessSessionProxyObjectFactoryType)
{
- super(context, statelessSessionProxyObjectFactoryType);
+ super(statelessSessionProxyObjectFactoryType);
}
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java 2008-06-15 18:03:41 UTC (rev 74579)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java 2008-06-15 18:16:12 UTC (rev 74580)
@@ -25,6 +25,10 @@
import java.util.ArrayList;
import java.util.List;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import org.jboss.aop.Dispatcher;
import org.jboss.beans.metadata.api.annotations.Start;
import org.jboss.beans.metadata.api.annotations.Stop;
@@ -81,6 +85,11 @@
*/
private JndiSessionRegistrarBase jndiRegistrar;
+ /**
+ * The JNDI Context to use for binding
+ */
+ private Context jndiContext;
+
// --------------------------------------------------------------------------------||
// Constructor --------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -183,7 +192,7 @@
if (registrar != null)
{
this.setJndiRegistrar(registrar);
- registrar.bindEjb(this.getMetaData(), this.getClassLoader(), this.getName());
+ registrar.bindEjb(this.getJndiContext(), this.getMetaData(), this.getClassLoader(), this.getName());
}
else
{
@@ -207,7 +216,7 @@
// If the registrar has been used for this container, unbind all JNDI references
if (registrar != null)
{
- registrar.unbindEjb(this.getMetaData());
+ registrar.unbindEjb(this.getJndiContext(), this.getMetaData());
}
}
@@ -218,30 +227,34 @@
*/
protected JndiSessionRegistrarBase getJndiRegistrar()
{
- // Initialize
- String jndiRegistrarBindName = this.getJndiRegistrarBindName();
+ // If the JNDI Registrar has not yet been set
+ if (this.jndiRegistrar == null)
+ {
+ // Initialize
+ String jndiRegistrarBindName = this.getJndiRegistrarBindName();
- // Obtain Registrar
- Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
+ // Obtain Registrar
+ Ejb3Registrar registrar = Ejb3RegistrarLocator.locateRegistrar();
- // Lookup
- Object obj = null;
- try
- {
- obj = registrar.lookup(jndiRegistrarBindName);
- }
- // If not installed, warn and return null
- catch (NotBoundException e)
- {
- log.warn("No " + JndiSessionRegistrarBase.class.getName()
- + " was found installed in the ObjectStore (Registry) at " + jndiRegistrarBindName);
- return null;
+ // Lookup
+ Object obj = null;
+ try
+ {
+ obj = registrar.lookup(jndiRegistrarBindName);
+ }
+ // If not installed, warn and return null
+ catch (NotBoundException e)
+ {
+ log.warn("No " + JndiSessionRegistrarBase.class.getName()
+ + " was found installed in the ObjectStore (Registry) at " + jndiRegistrarBindName);
+ return null;
+ }
+
+ // Cast and set
+ this.setJndiRegistrar((JndiSessionRegistrarBase) obj);
}
- // Cast
- JndiSessionRegistrarBase jndiRegistrar = (JndiSessionRegistrarBase) obj;
-
// Return
return jndiRegistrar;
}
@@ -321,4 +334,25 @@
{
this.jndiRegistrar = jndiRegistrar;
}
+
+ protected Context getJndiContext()
+ {
+ if (this.jndiContext == null)
+ {
+ try
+ {
+ this.setJndiContext(new InitialContext());
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Could not create new default JNDI Context for Container: " + this.getName(), e);
+ }
+ }
+ return jndiContext;
+ }
+
+ private void setJndiContext(Context jndiContext)
+ {
+ this.jndiContext = jndiContext;
+ }
}
Modified: projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase-beans.xml 2008-06-15 18:03:41 UTC (rev 74579)
+++ projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase-beans.xml 2008-06-15 18:16:12 UTC (rev 74580)
@@ -40,9 +40,6 @@
class="org.jboss.ejb3.proxy.jndiregistrar.JndiStatelessSessionRegistrar">
<constructor>
<parameter>
- <inject bean="org.jboss.ejb3.JndiContext" />
- </parameter>
- <parameter>
org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory
</parameter>
</constructor>
@@ -54,19 +51,12 @@
class="org.jboss.ejb3.proxy.jndiregistrar.JndiStatefulSessionRegistrar">
<constructor>
<parameter>
- <inject bean="org.jboss.ejb3.JndiContext" />
- </parameter>
- <parameter>
org.jboss.ejb3.proxy.objectfactory.session.stateful.StatefulSessionProxyObjectFactory
</parameter>
</constructor>
<depends>NameServer</depends>
</bean>
- <!-- JNDI Registrar Configuration -->
- <bean name="org.jboss.ejb3.JndiContext"
- class="javax.naming.InitialContext" />
-
<!--
Remoting
Modified: projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionTestCase-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionTestCase-beans.xml 2008-06-15 18:03:41 UTC (rev 74579)
+++ projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionTestCase-beans.xml 2008-06-15 18:16:12 UTC (rev 74580)
@@ -31,19 +31,12 @@
class="org.jboss.ejb3.proxy.jndiregistrar.JndiStatefulSessionRegistrar">
<constructor>
<parameter>
- <inject bean="org.jboss.ejb3.JndiContext" />
- </parameter>
- <parameter>
org.jboss.ejb3.proxy.objectfactory.session.stateful.StatefulSessionProxyObjectFactory
</parameter>
</constructor>
<depends>NameServer</depends>
</bean>
- <!-- JNDI Registrar Configuration -->
- <bean name="org.jboss.ejb3.JndiContext"
- class="javax.naming.InitialContext" />
-
<!--
Remoting
Modified: projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionTestCase-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionTestCase-beans.xml 2008-06-15 18:03:41 UTC (rev 74579)
+++ projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionTestCase-beans.xml 2008-06-15 18:16:12 UTC (rev 74580)
@@ -31,19 +31,12 @@
class="org.jboss.ejb3.proxy.jndiregistrar.JndiStatelessSessionRegistrar">
<constructor>
<parameter>
- <inject bean="org.jboss.ejb3.JndiContext" />
- </parameter>
- <parameter>
org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory
</parameter>
</constructor>
<depends>NameServer</depends>
</bean>
- <!-- JNDI Registrar Configuration -->
- <bean name="org.jboss.ejb3.JndiContext"
- class="javax.naming.InitialContext" />
-
<!--
Remoting
More information about the jboss-cvs-commits
mailing list