[jboss-cvs] JBossAS SVN: r77247 - in projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy: objectfactory and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 20 10:43:20 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-08-20 10:43:20 -0400 (Wed, 20 Aug 2008)
New Revision: 77247
Added:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiReferenceBinding.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiReferenceBindingSet.java
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/objectfactory/ProxyObjectFactory.java
Log:
[EJBTHREE-1469] Refactor proxy module classes to allow extension by proxy-clustered
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiReferenceBinding.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiReferenceBinding.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiReferenceBinding.java 2008-08-20 14:43:20 UTC (rev 77247)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.proxy.jndiregistrar;
+
+import javax.naming.Reference;
+
+/**
+ * Simple data object that encapsulates a <code>Reference</code> and the
+ * associated name under which it should be bound in JNDI.
+ *
+ * @author Brian Stansberry
+ */
+public class JndiReferenceBinding
+{
+ private final String jndiName;
+ private final Reference reference;
+
+ public JndiReferenceBinding(String jndiName, Reference reference)
+ {
+ assert jndiName != null : "jndiName is null";
+ assert reference != null : "reference is null";
+
+ this.jndiName = jndiName;
+ this.reference = reference;
+ }
+
+ public String getJndiName()
+ {
+ return jndiName;
+ }
+
+ public Reference getReference()
+ {
+ return reference;
+ }
+}
\ No newline at end of file
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiReferenceBindingSet.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiReferenceBindingSet.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiReferenceBindingSet.java 2008-08-20 14:43:20 UTC (rev 77247)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.proxy.jndiregistrar;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * Encapsulates the {@link JndiReferenceBinding}s associated with a particular
+ * container.
+ *
+ * @author Brian Stansberry
+ */
+public class JndiReferenceBindingSet
+{
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /** The naming context to use if there is a need to rebind */
+ private Context context;
+ /** Naming properties associated with context; used if context is not viable */
+ private final Hashtable<?, ?> namingEnvironment;
+
+ /** All bindings for remote homes */
+ private Set<JndiReferenceBinding> homeRemoteBindings = new HashSet<JndiReferenceBinding>();
+ /** All bindings for default remotes */
+ private Set<JndiReferenceBinding> defaultRemoteBindings = new HashSet<JndiReferenceBinding>();
+ /** All bindings for business remotes, grouped by business interface */
+ private Map<String, Set<JndiReferenceBinding>> businessRemoteBindings = new HashMap<String, Set<JndiReferenceBinding>>();
+ /** All bindings for local homes */
+ private Set<JndiReferenceBinding> homeLocalBindings = new HashSet<JndiReferenceBinding>();
+ /** All bindings for default locals */
+ private Set<JndiReferenceBinding> defaultLocalBindings = new HashSet<JndiReferenceBinding>();
+ /** All bindings for business locals, grouped by business interface */
+ private Map<String, Set<JndiReferenceBinding>> businessLocalBindings = new HashMap<String, Set<JndiReferenceBinding>>();
+
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public JndiReferenceBindingSet(Context context)
+ {
+ assert context != null : "context is null";
+ this.context = context;
+ try
+ {
+ this.namingEnvironment = context.getEnvironment();
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Cannot retrieve naming environment from " + context);
+ }
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public Context getContext()
+ {
+ // FIXME pass the env properties through JndiSessionRegistrarBase.bindEjb
+ // instead of passing the context. Then we cache those and recreate
+ // the context via InitialContextFactory
+ try
+ {
+ // A test of the viability of our cached context
+ context.getEnvironment();
+ }
+ catch (NamingException ne)
+ {
+ try
+ {
+ context = new InitialContext(namingEnvironment);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Cannot create InitialContext from " + namingEnvironment);
+ }
+ }
+ return context;
+ }
+
+ public Set<JndiReferenceBinding> getHomeRemoteBindings()
+ {
+ return new HashSet<JndiReferenceBinding>(homeRemoteBindings);
+ }
+
+ public void addHomeRemoteBinding(JndiReferenceBinding binding)
+ {
+ assert binding != null : "binding is null";
+ this.homeRemoteBindings.add(binding);
+ }
+
+ public Set<JndiReferenceBinding> getDefaultRemoteBindings()
+ {
+ return new HashSet<JndiReferenceBinding>(defaultRemoteBindings);
+ }
+
+ public void addDefaultRemoteBinding(JndiReferenceBinding binding)
+ {
+ assert binding != null : "binding is null";
+ this.defaultRemoteBindings.add(binding);
+ }
+
+ public Map<String, Set<JndiReferenceBinding>> getBusinessRemoteBindings()
+ {
+ return new HashMap<String, Set<JndiReferenceBinding>>(businessRemoteBindings);
+ }
+
+ public void addBusinessRemoteBinding(String businessInterfaceName, JndiReferenceBinding binding)
+ {
+ assert businessInterfaceName != null : "businessInterfaceName is null";
+ assert binding != null : "binding is null";
+
+ Set<JndiReferenceBinding> bindings = businessRemoteBindings.get(businessInterfaceName);
+ if (bindings == null)
+ {
+ bindings = new HashSet<JndiReferenceBinding>();
+ businessRemoteBindings.put(businessInterfaceName, bindings);
+ }
+ bindings.add(binding);
+ }
+
+ public Set<JndiReferenceBinding> getHomeLocalBindings()
+ {
+ return new HashSet<JndiReferenceBinding>(homeLocalBindings);
+ }
+
+ public void addHomeLocalBinding(JndiReferenceBinding binding)
+ {
+ assert binding != null : "binding is null";
+ this.homeLocalBindings.add(binding);
+ }
+
+ public Set<JndiReferenceBinding> getDefaultLocalBindings()
+ {
+ return new HashSet<JndiReferenceBinding>(defaultLocalBindings);
+ }
+
+ public void addDefaultLocalBinding(JndiReferenceBinding binding)
+ {
+ assert binding != null : "binding is null";
+ this.defaultLocalBindings.add(binding);
+ }
+
+ public Map<String, Set<JndiReferenceBinding>> getBusinessLocalBindings()
+ {
+ return new HashMap<String, Set<JndiReferenceBinding>>(businessLocalBindings);
+ }
+
+ public void addBusinessLocalBinding(String businessInterfaceName, JndiReferenceBinding binding)
+ {
+ assert businessInterfaceName != null : "businessInterfaceName is null";
+ assert binding != null : "binding is null";
+
+ Set<JndiReferenceBinding> bindings = businessLocalBindings.get(businessInterfaceName);
+ if (bindings == null)
+ {
+ bindings = new HashSet<JndiReferenceBinding>();
+ businessLocalBindings.put(businessInterfaceName, bindings);
+ }
+ bindings.add(binding);
+ }
+
+}
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-08-20 14:37:58 UTC (rev 77246)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java 2008-08-20 14:43:20 UTC (rev 77247)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import javax.naming.Context;
import javax.naming.NameNotFoundException;
@@ -151,7 +152,7 @@
* implementations required by the EJB
*
* @param context The JNDI Context to use for binding
- * @param smd
+ * @param smd the Container's metadata
* @param cl The CL of the Container
* @param containerName The name under which the target container is registered
* @param containerGuid The globally-unique name of the container
@@ -160,6 +161,29 @@
public void bindEjb(final Context context, final JBossSessionBeanMetaData smd, final ClassLoader cl,
final String containerName, final String containerGuid, final Advisor advisor)
{
+ JndiReferenceBindingSet bindingSet = createJndiReferenceBindingSet(context, smd, cl, containerName, containerGuid, advisor);
+
+ bind(context, bindingSet, false, true);
+ }
+
+ /**
+ * Creates all of the <code>Reference</code> objects that should be bound
+ * in JNDI for the EJB, and determines the correct JNDI name for each.
+ * Additionally responsible for creation and registration of any all
+ * ProxyFactory implementations required by the EJB.
+ *
+ * @param smd the Container's metadata
+ * @param cl The CL of the Container
+ * @param containerName The name under which the target container is registered
+ * @param containerGuid The globally-unique name of the container
+ * @param advisor The advisor to use for generated proxies
+ *
+ * @return data object encapsulating the references and their JNDI names
+ */
+ protected JndiReferenceBindingSet createJndiReferenceBindingSet(final Context context,
+ final JBossSessionBeanMetaData smd, final ClassLoader cl, final String containerName,
+ final String containerGuid, final Advisor advisor)
+ {
// Log
String ejbName = smd.getEjbName();
log.debug("Found Session Bean: " + ejbName);
@@ -183,6 +207,8 @@
/*
* Create and Register Proxy Factories
*/
+
+ JndiReferenceBindingSet bindingSet = new JndiReferenceBindingSet(context);
// If there's a remote view
/*
@@ -241,15 +267,17 @@
RefAddr refAddrHomeInterface = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_REMOTE, homeType);
RefAddr refAddrRemoting = this.createRemotingRefAddr(smd);
- Reference homeRef = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + homeType, this
- .getSessionProxyObjectFactoryType(), null);
+ Reference homeRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + homeType,
+ remoteProxyFactoryKey, containerName);
homeRef.add(refAddrHomeInterface);
homeRef.add(refAddrRemoting);
+
String homeAddress = smd.getHomeJndiName();
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(context, homeRef, homeAddress, remoteProxyFactoryKey, containerName);
+
+ bindingSet.addHomeRemoteBinding(new JndiReferenceBinding(homeAddress, homeRef));
}
// Add a Reference Address for the Remoting URL
@@ -263,8 +291,8 @@
String defaultRemoteClassName = this.getHumanReadableListOfInterfacesInRefAddrs(refAddrsForDefaultRemote);
// Create a Reference
- Reference defaultRemoteRef = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
- + defaultRemoteClassName, this.getSessionProxyObjectFactoryType(), null);
+ Reference defaultRemoteRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ + defaultRemoteClassName, remoteProxyFactoryKey, containerName);
// Add all Reference Addresses for Default Remote Reference
for (RefAddr refAddr : refAddrsForDefaultRemote)
@@ -279,7 +307,8 @@
String defaultRemoteAddress = smd.getJndiName();
log.debug("Default Remote Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ defaultRemoteAddress + "\"");
- this.bind(context, defaultRemoteRef, defaultRemoteAddress, remoteProxyFactoryKey, containerName);
+
+ bindingSet.addDefaultRemoteBinding(new JndiReferenceBinding(defaultRemoteAddress, defaultRemoteRef));
// Bind ObjectFactory specific to each Remote Business Interface
if (businessRemotes != null)
@@ -289,14 +318,15 @@
RefAddr refAddrBusinessInterface = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
RefAddr refAddrRemoting = this.createRemotingRefAddr(smd);
- Reference ref = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + businessRemote,
- this.getSessionProxyObjectFactoryType(), null);
+ Reference ref = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + businessRemote,
+ remoteProxyFactoryKey, containerName);
ref.add(refAddrBusinessInterface);
ref.add(refAddrRemoting);
String address = JbossSessionBeanJndiNameResolver.resolveJndiName(smd, businessRemote);
log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
+ " to be bound into JNDI at \"" + address + "\"");
- this.bind(context, ref, address, remoteProxyFactoryKey, containerName);
+
+ bindingSet.addBusinessRemoteBinding(businessRemote, new JndiReferenceBinding(address, ref));
}
}
}
@@ -338,13 +368,14 @@
String localHomeType = smd.getLocalHome();
RefAddr refAddr = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_LOCAL, localHomeType);
- Reference localHomeRef = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
- + localHomeType, this.getSessionProxyObjectFactoryType(), null);
+ Reference localHomeRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ + localHomeType, localProxyFactoryKey, containerName);
localHomeRef.add(refAddr);
String localHomeAddress = smd.getLocalHomeJndiName();
log.debug("Local Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \"" + localHomeAddress
+ "\"");
- this.bind(context, localHomeRef, localHomeAddress, localProxyFactoryKey, containerName);
+
+ bindingSet.addHomeLocalBinding(new JndiReferenceBinding(localHomeAddress, localHomeRef));
}
/*
@@ -355,8 +386,8 @@
String defaultLocalClassName = this.getHumanReadableListOfInterfacesInRefAddrs(refAddrsForDefaultLocal);
// Create a Reference
- Reference defaultLocalRef = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
- + defaultLocalClassName, this.getSessionProxyObjectFactoryType(), null);
+ Reference defaultLocalRef = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX
+ + defaultLocalClassName, localProxyFactoryKey, containerName);
// Add all Reference Addresses for Default Local Reference
for (RefAddr refAddr : refAddrsForDefaultLocal)
@@ -371,7 +402,8 @@
String defaultLocalAddress = smd.getLocalJndiName();
log.debug("Default Local Business View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ defaultLocalAddress + "\"");
- this.bind(context, defaultLocalRef, defaultLocalAddress, localProxyFactoryKey, containerName);
+
+ bindingSet.addDefaultLocalBinding(new JndiReferenceBinding(defaultLocalAddress, defaultLocalRef));
// Bind ObjectFactory specific to each Local Business Interface
if (businessLocals != null)
@@ -380,17 +412,18 @@
{
RefAddr refAddr = new StringRefAddr(
ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_LOCAL, businessLocal);
- Reference ref = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + businessLocal,
- this.getSessionProxyObjectFactoryType(), null);
+ Reference ref = createStandardReference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + businessLocal,
+ localProxyFactoryKey, containerName);
ref.add(refAddr);
String address = JbossSessionBeanJndiNameResolver.resolveJndiName(smd, businessLocal);
log.debug("Local Business View for " + businessLocal + " of EJB " + smd.getEjbName()
+ " to be bound into JNDI at \"" + address + "\"");
- this.bind(context, ref, address, localProxyFactoryKey, containerName);
-
+
+ bindingSet.addBusinessLocalBinding(businessLocal, new JndiReferenceBinding(address, ref));
}
}
}
+ return bindingSet;
}
/**
@@ -558,20 +591,19 @@
// --------------------------------------------------------------------------------||
/**
- * Binds the specified Reference into JNDI at the specified address, adding
- * 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
+ * Creates a new <code>Reference</code> whose <code>classname</code> is
+ * the given <code>referenceName</code> and whose <code>classFactory</code>
+ * is {@link #getSessionProxyObjectFactoryType()}, adding
+ * the requisite Registry key for the ProxyFactory and the requisite
+ * target EJB Container Name as ReferenceAddresses.
*/
- protected void bind(Context context, Reference ref, String address, String proxyFactoryRegistryKey,
- String containerName)
+ protected Reference createStandardReference(String referenceName,
+ String proxyFactoryRegistryKey,
+ String containerName)
{
+ Reference ref = new Reference(referenceName,
+ this.getSessionProxyObjectFactoryType(), null);
+
// Add the Proxy Factory Registry key for this Reference
assert proxyFactoryRegistryKey != null && !proxyFactoryRegistryKey.trim().equals("") : "Proxy Factory Registry key is required but not supplied";
String proxyFactoryRefType = ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY;
@@ -587,8 +619,73 @@
ref.add(containerRefAddr);
log.debug("Adding " + RefAddr.class.getSimpleName() + " to " + Reference.class.getSimpleName() + ": Type \""
+ ejbContainerRefType + "\", Content \"" + containerName + "\"");
+
+ return ref;
+ }
+
+ protected void bind(final Context context, final JndiReferenceBindingSet bindings,
+ final boolean useRebind, final boolean bindLocals)
+ {
+ for (JndiReferenceBinding binding : bindings.getDefaultRemoteBindings())
+ {
+ bind(context, binding, useRebind);
+ }
+
+ for (JndiReferenceBinding binding : bindings.getHomeRemoteBindings())
+ {
+ bind(context, binding, useRebind);
+ }
+
+ for (Set<JndiReferenceBinding> businessBindings : bindings.getBusinessRemoteBindings().values())
+ {
+ for (JndiReferenceBinding binding : businessBindings)
+ {
+ bind(context, binding, useRebind);
+ }
+ }
+
+ if (bindLocals)
+ {
+ for (JndiReferenceBinding binding : bindings.getDefaultLocalBindings())
+ {
+ bind(context, binding, useRebind);
+ }
+
+ for (JndiReferenceBinding binding : bindings.getHomeLocalBindings())
+ {
+ bind(context, binding, useRebind);
+ }
+
+ for (Set<JndiReferenceBinding> businessBindings : bindings.getBusinessLocalBindings().values())
+ {
+ for (JndiReferenceBinding binding : businessBindings)
+ {
+ bind(context, binding, useRebind);
+ }
+ }
+ }
+ }
+
+ protected void bind(Context context, JndiReferenceBinding binding, boolean useRebind)
+ {
+ if (binding != null)
+ {
+ if (useRebind)
+ rebind(context, binding.getJndiName(), binding.getReference());
+ else
+ bind(context, binding.getJndiName(), binding.getReference());
+ }
+ }
- // Bind
+ /**
+ * Binds the specified Reference into JNDI at the specified address
+ *
+ * @param context The JNDI Context to use
+ * @param address the address
+ * @param ref the reference to bind
+ */
+ protected void bind(Context context, String address, Reference ref)
+ {
try
{
Util.bind(context, address, ref);
@@ -601,6 +698,26 @@
}
/**
+ * Re-binds the specified Reference into JNDI at the specified address
+ *
+ * @param context The JNDI Context to use
+ * @param address the address
+ * @param object the object to bind
+ */
+ protected void rebind(Context context, String address, Reference ref)
+ {
+ try
+ {
+ Util.rebind(context, address, ref);
+ log.debug("Bound " + ref.getClass().getName() + " into JNDI at \"" + address + "\"");
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Could not bind " + ref + " into JNDI at \"" + address + "\"", e);
+ }
+ }
+
+ /**
* Unbinds the specified address from JNDI
*
* @param context The JNDI Context to use
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java 2008-08-20 14:37:58 UTC (rev 77246)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java 2008-08-20 14:43:20 UTC (rev 77247)
@@ -23,6 +23,7 @@
import java.io.Serializable;
import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
@@ -138,23 +139,7 @@
// Registrar is not local, so use Remoting to Obtain Proxy Factory
catch (NotBoundException nbe)
{
- // Obtain the URL for invoking upon the Registry
- String url = this.getSingleRequiredReferenceAddressValue(name, refAddrs,
- ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_INVOKER_LOCATOR_URL);
-
- // Create an InvokerLocator
- assert url != null && !url.trim().equals("") : InvokerLocator.class.getSimpleName()
- + " URL is required, but is not specified; improperly bound reference in JNDI";
- InvokerLocator locator = new InvokerLocator(url);
-
- // Create a POJI Proxy to the Registrar
- Interceptor[] interceptors =
- {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
- PojiProxy handler = new PojiProxy(proxyFactoryRegistryKey, locator, interceptors);
- Class<?>[] interfaces = new Class<?>[]
- {this.getProxyFactoryClass()};
- proxyFactory = (ProxyFactory) Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, handler);
-
+ proxyFactory = createProxyFactoryProxy(name, refAddrs, proxyFactoryRegistryKey);
}
// Get the proxy returned from the ProxyFactory
@@ -166,6 +151,36 @@
}
/**
+ * Creates a remoting proxy to the proxy factory.
+ *
+ * @param name
+ * @param refAddrs
+ * @param proxyFactoryRegistryKey
+ * @return
+ * @throws Exception
+ */
+ protected ProxyFactory createProxyFactoryProxy(Name name, Map<String, List<String>> refAddrs,
+ String proxyFactoryRegistryKey) throws Exception
+ {
+ // Obtain the URL for invoking upon the Registry
+ String url = this.getSingleRequiredReferenceAddressValue(name, refAddrs,
+ ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_INVOKER_LOCATOR_URL);
+
+ // Create an InvokerLocator
+ assert url != null && !url.trim().equals("") : InvokerLocator.class.getSimpleName()
+ + " URL is required, but is not specified; improperly bound reference in JNDI";
+ InvokerLocator locator = new InvokerLocator(url);
+
+ // Create a POJI Proxy to the Registrar
+ Interceptor[] interceptors =
+ {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
+ PojiProxy handler = new PojiProxy(proxyFactoryRegistryKey, locator, interceptors);
+ Class<?>[] interfaces = new Class<?>[]{this.getProxyFactoryClass()};
+
+ return (ProxyFactory) Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, handler);
+ }
+
+ /**
* Obtains the single value of the specified type as obtained from the specified reference
* addresses bound at the specified Name. Asserts that the value exists and is the only one
* for the specified type.
More information about the jboss-cvs-commits
mailing list