[jboss-cvs] JBossAS SVN: r72147 - in projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3: stateful and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Apr 13 20:52:58 EDT 2008
Author: ALRubinger
Date: 2008-04-13 20:52:58 -0400 (Sun, 13 Apr 2008)
New Revision: 72147
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulRemoteProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessRemoteProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
Log:
[EJBTHREE-1271] Ensure home interface is added to list of interfaces for business proxy if the two share a common JNDI binding
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -31,7 +31,6 @@
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import javax.ejb.EJBException;
@@ -171,6 +170,13 @@
}
}
+ /**
+ * Whether or not to bind the home and business interfaces together
+ *
+ * @return
+ */
+ protected abstract boolean bindHomeAndBusinessTogether();
+
protected Object constructProxyBusiness(InvocationHandler handler)
{
// Return
@@ -286,9 +292,9 @@
* Returns an array of interfaces to be used for the proxy;
* will return null if none are defined.
*
- * @param business
+ * @param accessType
+ * @param specType
* @return
- * @throws IllegalStateException If specified to use EJB21 View and no Remote/Local interfaces defined
*/
private Class<?>[] getInterfacesForProxy(ProxyAccessType accessType, SpecificationInterfaceType specType)
{
@@ -307,7 +313,13 @@
// If business
if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
{
- intfs.addAll(Arrays.asList(ProxyFactoryHelper.getLocalBusinessInterfaces(container)));
+ intfs.addAll(Arrays.asList(ProxyFactoryHelper.getLocalBusinessInterfaces(container)));
+
+ // If binding home with local business
+ if(this.bindHomeAndBusinessTogether())
+ {
+ intfs.add(this.getHomeType());
+ }
}
// If EJBLocalObject
else
@@ -331,7 +343,14 @@
// If business
if (specType.equals(SpecificationInterfaceType.EJB30_BUSINESS))
{
- intfs.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteBusinessInterfaces(container)));
+ intfs.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteBusinessInterfaces(container)));
+
+ // If binding home with remote business
+ if(this.bindHomeAndBusinessTogether())
+ {
+ intfs.add(this.getHomeType());
+ }
+
}
// If EJBObject
else
@@ -393,6 +412,13 @@
return homeHandle;
}
+ /**
+ * Returns the interface type for Home
+ *
+ * @return
+ */
+ protected abstract Class<?> getHomeType();
+
protected final String getJndiName()
{
return this.jndiName;
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulRemoteProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/BaseStatefulRemoteProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -1,3 +1,24 @@
+/*
+ * 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.stateful;
import javax.ejb.EJBObject;
@@ -15,6 +36,15 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
+/**
+ * BaseStatefulRemoteProxyFactory
+ *
+ * Common base for factories generating remoting-enabled
+ * proxies (ie. remote and clustering)
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
public abstract class BaseStatefulRemoteProxyFactory extends BaseStatefulProxyFactory implements RemoteProxyFactory
{
// Class Members
@@ -84,8 +114,10 @@
// Functional Methods
- protected boolean bindHomeAndBusinessTogether(SessionContainer container)
+ @Override
+ protected boolean bindHomeAndBusinessTogether()
{
+ SessionSpecContainer container = this.getContainer();
String homeJndiName = ProxyFactoryHelper.getHomeJndiName(container);
String remoteBusinessJndiName = ProxyFactoryHelper.getRemoteBusinessJndiName(container);
return homeJndiName.equals(remoteBusinessJndiName);
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -49,6 +49,7 @@
import org.jboss.ha.framework.server.HATarget;
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
+import org.jboss.util.NotImplementedException;
import org.jboss.util.naming.Util;
@@ -84,6 +85,17 @@
}
/**
+ * Returns the interface type for Home
+ *
+ * @return
+ */
+ @Override
+ protected Class<?> getHomeType()
+ {
+ throw new NotImplementedException("Cluster Proxy Factories do not have Home interfaces");
+ }
+
+ /**
* Defines the access type for this Proxies created by this Factory
*
* @return
@@ -93,6 +105,17 @@
return ProxyAccessType.REMOTE;
}
+ /**
+ * Whether or not to bind the home and business interfaces together
+ *
+ * @return
+ */
+ @Override
+ protected boolean bindHomeAndBusinessTogether()
+ {
+ throw new NotImplementedException("Not Applicable for Cluster Proxy Factories");
+ }
+
protected void validateEjb21Views()
{
// Obtain Container
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -64,6 +64,17 @@
{
super(container, binding.jndiBinding());
}
+
+ /**
+ * Returns the interface type for Home
+ *
+ * @return
+ */
+ @Override
+ protected Class<?> getHomeType()
+ {
+ return ProxyFactoryHelper.getLocalHomeInterface(this.getContainer());
+ }
/**
* Defines the access type for this Proxies created by this Factory
@@ -89,9 +100,15 @@
}
- protected boolean bindHomeAndBusinessTogether(SessionContainer container)
+ /**
+ * Whether or not to bind the home and business interfaces together
+ *
+ * @return
+ */
+ @Override
+ protected boolean bindHomeAndBusinessTogether()
{
- return ProxyFactoryHelper.getLocalHomeJndiName(container).equals(jndiName);
+ return ProxyFactoryHelper.getLocalHomeJndiName(this.getContainer()).equals(this.jndiName);
}
public void start() throws Exception
@@ -113,13 +130,13 @@
SessionContainer statefulContainer = (SessionContainer) getContainer();
LocalHome localHome = this.getContainer().getAnnotation(LocalHome.class);
- if (localHome != null && !bindHomeAndBusinessTogether(statefulContainer))
+ if (localHome != null && !bindHomeAndBusinessTogether())
{
Class<?>[] interfaces =
{localHome.value()};
- Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(),
- interfaces, new StatefulLocalHomeProxy(getContainer()));
- Util.rebind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()),
+ Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(statefulContainer.getBeanClass().getClassLoader(),
+ interfaces, new StatefulLocalHomeProxy(statefulContainer));
+ Util.rebind(statefulContainer.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(statefulContainer),
homeProxy);
}
}
@@ -128,11 +145,11 @@
{
super.stop();
Util.unbind(getContainer().getInitialContext(), jndiName + PROXY_FACTORY_NAME);
- SessionContainer statefulContainer = (SessionContainer) getContainer();
+ SessionContainer statefulContainer = this.getContainer();
LocalHome localHome = this.getContainer().getAnnotation(LocalHome.class);
- if (localHome != null && !bindHomeAndBusinessTogether(statefulContainer))
+ if (localHome != null && !bindHomeAndBusinessTogether())
{
- Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()));
+ Util.unbind(statefulContainer.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(statefulContainer));
}
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -85,12 +85,12 @@
assert !Dispatcher.singleton.isRegistered(targetId) : targetId + " is already registered";
Dispatcher.singleton.registerTarget(targetId, this);
- SessionContainer statefulContainer = this.getContainer();
+ SessionSpecContainer statefulContainer = this.getContainer();
RemoteHome remoteHome = statefulContainer.getAnnotation(RemoteHome.class);
- if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer))
+ if (remoteHome != null && !bindHomeAndBusinessTogether())
{
Object homeProxy = createHomeProxy(remoteHome.value());
- String homeJndiName = ProxyFactoryHelper.getHomeJndiName(this.getContainer());
+ String homeJndiName = ProxyFactoryHelper.getHomeJndiName(statefulContainer);
log.debug("Binding home proxy at " + homeJndiName);
Util.rebind(this.getContainer().getInitialContext(), homeJndiName, homeProxy);
}
@@ -104,7 +104,7 @@
SessionContainer statefulContainer = this.getContainer();
RemoteHome remoteHome = statefulContainer.getAnnotation(RemoteHome.class);
- if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer))
+ if (remoteHome != null && !bindHomeAndBusinessTogether())
{
Util.unbind(this.getContainer().getInitialContext(), ProxyFactoryHelper.getHomeJndiName(getContainer()));
}
@@ -144,7 +144,18 @@
proxy.setEjbMetaData(getEjbMetaData());
}
+ /**
+ * Returns the interface type for Home
+ *
+ * @return
+ */
@Override
+ protected Class<?> getHomeType()
+ {
+ return ProxyFactoryHelper.getRemoteHomeInterface(this.getContainer());
+ }
+
+ @Override
String getStackNameInterceptors()
{
return StatefulRemoteProxyFactory.STACK_NAME_STATEFUL_SESSION_CLIENT_INTERCEPTORS;
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessRemoteProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/BaseStatelessRemoteProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -69,7 +69,7 @@
// Functional Methods
- protected boolean bindHomeAndBusinessTogether(SessionContainer container)
+ protected boolean bindHomeAndEjb21ViewTogether(SessionContainer container)
{
String homeJndiName = ProxyFactoryHelper.getHomeJndiName(container);
String remoteBusinessJndiName = ProxyFactoryHelper.getRemoteBusinessJndiName(container);
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessClusterProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -22,16 +22,11 @@
package org.jboss.ejb3.stateless;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
-import javax.ejb.RemoteHome;
-
import org.jboss.aop.AspectManager;
import org.jboss.aop.advice.AdviceStack;
import org.jboss.aspects.remoting.FamilyWrapper;
-import org.jboss.ejb3.JBossProxy;
import org.jboss.ejb3.ProxyFactoryHelper;
import org.jboss.ejb3.SpecificationInterfaceType;
import org.jboss.ejb3.annotation.Clustered;
@@ -40,7 +35,6 @@
import org.jboss.ejb3.remoting.LoadBalancePolicyNotRegisteredException;
import org.jboss.ejb3.remoting.RemoteProxyFactory;
import org.jboss.ejb3.remoting.RemoteProxyFactoryRegistry;
-import org.jboss.ejb3.session.SessionContainer;
import org.jboss.ejb3.session.SessionSpecContainer;
import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
import org.jboss.ha.client.loadbalance.RandomRobin;
@@ -50,6 +44,7 @@
import org.jboss.ha.framework.server.HATarget;
import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
+import org.jboss.util.NotImplementedException;
/**
@@ -153,6 +148,16 @@
return proxy;
}
+ /**
+ * Whether or not to bind the home and business interfaces together
+ *
+ * @return
+ */
+ @Override
+ protected boolean bindHomeAndBusinessTogether(){
+ throw new NotImplementedException("Not Applicable for Cluster Proxy Factories");
+ }
+
public synchronized void replicantsChanged (String key,
List newReplicants,
int newReplicantsViewId,
@@ -173,6 +178,18 @@
log.error(e);
}
}
+
+ /**
+ * Returns the interface type for Home
+ *
+ * @param container
+ * @return
+ */
+ @Override
+ protected Class<?> getHomeType()
+ {
+ throw new NotImplementedException("Cluster Proxy Factories do not have Home interfaces");
+ }
@Override
String getStackNameInterceptors()
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -49,7 +49,19 @@
super(container, binding.jndiBinding());
}
+ /**
+ * Returns the interface type for Home
+ *
+ * @param container
+ * @return
+ */
@Override
+ protected Class<?> getHomeType()
+ {
+ return ProxyFactoryHelper.getLocalHomeInterface(this.getContainer());
+ }
+
+ @Override
protected ProxyAccessType getProxyAccessType()
{
return ProxyAccessType.LOCAL;
@@ -67,18 +79,24 @@
.getLocalInterfaces(container));
}
- protected boolean bindHomeAndBusinessTogether(EJBContainer container)
+ /**
+ * Whether or not to bind the home and business interfaces together
+ *
+ * @return
+ */
+ @Override
+ protected boolean bindHomeAndBusinessTogether()
{
- return ProxyFactoryHelper.getLocalHomeJndiName(container).equals(jndiName);
+ return ProxyFactoryHelper.getLocalHomeJndiName(this.getContainer()).equals(jndiName);
}
@Override
public void start() throws Exception
{
super.start();
- EJBContainer statelessContainer = (EJBContainer) getContainer();
+ SessionSpecContainer statelessContainer = getContainer();
LocalHome localHome = statelessContainer.getAnnotation(LocalHome.class);
- if (localHome != null && !bindHomeAndBusinessTogether(statelessContainer))
+ if (localHome != null && !bindHomeAndBusinessTogether())
{
Class<?>[] interfaces = {localHome.value()};
Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(),
@@ -93,7 +111,7 @@
super.stop();
SessionSpecContainer statelessContainer = this.getContainer();
LocalHome localHome = statelessContainer.getAnnotation(LocalHome.class);
- if (localHome != null && !bindHomeAndBusinessTogether(statelessContainer))
+ if (localHome != null && !bindHomeAndBusinessTogether())
{
Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()));
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java 2008-04-14 00:51:56 UTC (rev 72146)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java 2008-04-14 00:52:58 UTC (rev 72147)
@@ -52,8 +52,15 @@
super(container, binding);
}
- protected boolean bindHomeAndBusinessTogether(SessionSpecContainer container)
+ /**
+ * Whether or not to bind the home and business interfaces together
+ *
+ * @return
+ */
+ @Override
+ protected boolean bindHomeAndBusinessTogether()
{
+ SessionSpecContainer container = this.getContainer();
return ProxyFactoryHelper.getHomeJndiName(container).equals(ProxyFactoryHelper.getRemoteBusinessJndiName(container));
}
@@ -66,7 +73,7 @@
{
super.start();
RemoteHome remoteHome = this.getContainer().getAnnotation(RemoteHome.class);
- if (remoteHome != null && !bindHomeAndBusinessTogether(this.getContainer()))
+ if (remoteHome != null && !bindHomeAndEjb21ViewTogether(this.getContainer()))
{
Object homeProxy = createHomeProxy(remoteHome.value());
String jndiName = ProxyFactoryHelper.getHomeJndiName(getContainer());
@@ -90,7 +97,7 @@
super.stop();
SessionSpecContainer statelessContainer = this.getContainer();
RemoteHome remoteHome = this.getContainer().getAnnotation(RemoteHome.class);
- if (remoteHome != null && !bindHomeAndBusinessTogether(statelessContainer))
+ if (remoteHome != null && !bindHomeAndEjb21ViewTogether(statelessContainer))
{
Util.unbind(getContainer().getInitialContext(), ProxyFactoryHelper.getHomeJndiName(getContainer()));
}
@@ -119,6 +126,17 @@
throw new RuntimeException(e);
}
}
+
+ /**
+ * Returns the interface type for Home
+ *
+ * @return
+ */
+ @Override
+ protected Class<?> getHomeType()
+ {
+ return ProxyFactoryHelper.getRemoteHomeInterface(this.getContainer());
+ }
@Override
String getStackNameInterceptors()
More information about the jboss-cvs-commits
mailing list