[jboss-cvs] JBossAS SVN: r66247 - in trunk/ejb3/src/main/org/jboss/ejb3: stateful and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 18 12:52:05 EDT 2007
Author: ALRubinger
Date: 2007-10-18 12:52:05 -0400 (Thu, 18 Oct 2007)
New Revision: 66247
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
Log:
EJBTHREE-1075: Added check to ProxyFactories ensuring EJB 2.1 Session View is complete
Modified: trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2007-10-18 16:50:39 UTC (rev 66246)
+++ trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2007-10-18 16:52:05 UTC (rev 66247)
@@ -21,7 +21,11 @@
*/
package org.jboss.ejb3.session;
+import javax.ejb.EJBHome;
+import javax.ejb.EJBLocalHome;
+import javax.ejb.EJBLocalObject;
import javax.ejb.EJBMetaData;
+import javax.ejb.EJBObject;
import javax.ejb.Handle;
import javax.ejb.HomeHandle;
import javax.ejb.Remote;
@@ -34,6 +38,7 @@
import org.jboss.ejb3.proxy.EJBMetaDataImpl;
import org.jboss.ejb3.proxy.handle.HomeHandleImpl;
import org.jboss.logging.Logger;
+import org.jboss.proxy.ejb.EjbObjectCorbaServant;
/**
* Comment
@@ -105,4 +110,43 @@
return metadata;
}
+
+ /**
+ * Ensures that an EJB 2.1 view is complete; the following rules apply:
+ *
+ * 1) If EJBHome/EJBLocalHome is defined, at least one EJBObject/EJBLocalObject is defined.
+ * 2) If one EJBObject/EJBLocalObject is defined, an EJBHome/EJBLocalHome is defined.
+ *
+ * @param home
+ * @param localOrRemoteInterfaces
+ * @throws RuntimeException
+ */
+ protected void ensureEjb21ViewComplete(Object home,Class<?>[] localOrRemoteInterfaces) throws RuntimeException
+ {
+ // Ensure specified home is EJBHome or EJBLocalHome
+ assert(home instanceof EJBHome || home instanceof EJBLocalHome);
+
+ // Ensure all interfaces passed are either EJBObject or EJBLocalObject
+ for(Class<?> localOrRemoteInterface : localOrRemoteInterfaces)
+ {
+ assert (EJBObject.class.isAssignableFrom(localOrRemoteInterface) || EJBLocalObject.class
+ .isAssignableFrom(localOrRemoteInterface));
+ }
+
+ // If home is defined and there are no local/remote interfaces
+ if(home!=null && localOrRemoteInterfaces.length==0)
+ {
+ throw new RuntimeException(container.getBeanClassName() + " defines home"
+ + " but provides no local/remote interfaces extending " + EJBLocalObject.class.getName() + "/"
+ + EJBObject.class.getName() + "; EJB 2.1 view cannot be realized");
+ }
+
+ // If local/remote interfaces are defined, but no remote home
+ if(home==null&&localOrRemoteInterfaces.length!=0)
+ {
+ throw new RuntimeException(container.getBeanClassName() + " defines local/remote interfaces"
+ + " but provides no home; EJB 2.1 view cannot be realized");
+ }
+
+ }
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java 2007-10-18 16:50:39 UTC (rev 66246)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java 2007-10-18 16:52:05 UTC (rev 66247)
@@ -63,7 +63,10 @@
// Obtain all local interfaces
List<Class<?>> localInterfaces = new ArrayList<Class<?>>();
- localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalInterfaces(container)));
+ localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(container)));
+
+ // Ensure that if EJB 2.1 Components are defined, they're complete
+ this.ensureEjb21ViewComplete(localHome, ProxyFactoryHelper.getLocalInterfaces(container));
// Add JBossProxy
localInterfaces.add(JBossProxy.class);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java 2007-10-18 16:50:39 UTC (rev 66246)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java 2007-10-18 16:52:05 UTC (rev 66247)
@@ -85,8 +85,11 @@
// Obtain all remote interfaces
List<Class<?>> remoteInterfaces = new ArrayList<Class<?>>();
- remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteInterfaces(container)));
+ remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container)));
+ // Ensure that if EJB 2.1 Components are defined, they're complete
+ this.ensureEjb21ViewComplete(remoteHome, ProxyFactoryHelper.getRemoteInterfaces(container));
+
// Add JBossProxy
remoteInterfaces.add(JBossProxy.class);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java 2007-10-18 16:50:39 UTC (rev 66246)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java 2007-10-18 16:52:05 UTC (rev 66247)
@@ -65,9 +65,12 @@
// Obtain all local interfaces
List<Class<?>> localInterfaces = new ArrayList<Class<?>>();
- localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalInterfaces(container)));
+ localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalAndBusinessLocalInterfaces(container)));
+
+ // Ensure that if EJB 2.1 Components are defined, they're complete
+ this.ensureEjb21ViewComplete(localHome, ProxyFactoryHelper.getLocalInterfaces(container));
- // Ensure remote interfaces defined
+ // Ensure local interfaces defined
if (localInterfaces.size() > 0)
{
// Add JBossProxy
@@ -103,7 +106,7 @@
LocalHome localHome = (LocalHome) statelessContainer.resolveAnnotation(LocalHome.class);
if (localHome != null && !bindHomeAndBusinessTogether(statelessContainer))
{
- Class[] interfaces = {localHome.value()};
+ Class<?>[] interfaces = {localHome.value()};
Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(container.getBeanClass().getClassLoader(),
interfaces, new StatelessLocalProxy(container));
NonSerializableFactory.rebind(container.getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(container), homeProxy);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java 2007-10-18 16:50:39 UTC (rev 66246)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java 2007-10-18 16:52:05 UTC (rev 66247)
@@ -76,7 +76,10 @@
// Obtain all remote interfaces
List<Class<?>> remoteInterfaces = new ArrayList<Class<?>>();
- remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteInterfaces(container)));
+ remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container)));
+
+ // Ensure that if EJB 2.1 Components are defined, they're complete
+ this.ensureEjb21ViewComplete(remoteHome, ProxyFactoryHelper.getRemoteInterfaces(container));
// Ensure remote interfaces defined
if (remoteInterfaces.size() > 0)
More information about the jboss-cvs-commits
mailing list