[jboss-cvs] JBossAS SVN: r103877 - in projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3: mdb and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 13 00:13:50 EDT 2010
Author: ALRubinger
Date: 2010-04-13 00:13:47 -0400 (Tue, 13 Apr 2010)
New Revision: 103877
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryHelper.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
Log:
[EJBTHREE-2076] Check for valid business interface invoked, if not set BI to null in the Invocation object to be picked up by ejb3-context
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2010-04-13 04:05:18 UTC (rev 103876)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2010-04-13 04:13:47 UTC (rev 103877)
@@ -194,7 +194,7 @@
private String partitionName;
- private List<Class<?>> businessInterfaces;
+ private List<Class<?>> businessAndComponentInterfaces;
private ThreadLocalStack<BeanContext<?>> currentBean = new ThreadLocalStack<BeanContext<?>>();
@@ -503,10 +503,10 @@
*
* @return an array of business interfaces or empty if no interface is provided
*/
- public List<Class<?>> getBusinessInterfaces()
+ public List<Class<?>> getBusinessAndComponentInterfaces()
{
- if(businessInterfaces == null) throw new IllegalStateException("businessInterfaces not yet initialized");
- return businessInterfaces;
+ if(businessAndComponentInterfaces == null) throw new IllegalStateException("businessAndComponentInterfaces not yet initialized");
+ return businessAndComponentInterfaces;
}
public String getDeploymentQualifiedName()
@@ -554,7 +554,7 @@
*/
public boolean isBusinessMethod(Method businessMethod)
{
- for(Class<?> businessInterface : getBusinessInterfaces())
+ for(Class<?> businessInterface : getBusinessAndComponentInterfaces())
{
for(Method method : businessInterface.getMethods())
{
@@ -684,7 +684,7 @@
// EJBTHREE-1025
this.checkForDuplicateLocalAndRemoteInterfaces();
- for(Class<?> businessInterface : getBusinessInterfaces())
+ for(Class<?> businessInterface : getBusinessAndComponentInterfaces())
((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(businessInterface);
Class localHomeInterface = ProxyFactoryHelper.getLocalHomeInterface(this);
@@ -1652,7 +1652,7 @@
*/
public void instantiated()
{
- this.businessInterfaces = resolveBusinessInterfaces();
+ this.businessAndComponentInterfaces = resolveBusinessInterfaces();
// Before we start to process annotations, make sure we also have the ones from interceptors-aop.
// FIXME: because of the flaked life cycle of an EJBContainer (we add annotations after it's been
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java 2010-04-13 04:05:18 UTC (rev 103876)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java 2010-04-13 04:13:47 UTC (rev 103877)
@@ -265,7 +265,7 @@
Destination dest = (Destination) getInitialContext().lookup(getDestination());
MessageProperties props = (MessageProperties) resolveAnnotation(MessageProperties.class);
if (props == null) props = new MessagePropertiesImpl();
- for (Class<?> producer : getBusinessInterfaces())
+ for (Class<?> producer : getBusinessAndComponentInterfaces())
{
log.debug("Producer: " + producer.getName());
ProducerFactory producerFactory = null;
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryHelper.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryHelper.java 2010-04-13 04:05:18 UTC (rev 103876)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryHelper.java 2010-04-13 04:13:47 UTC (rev 103877)
@@ -259,7 +259,7 @@
*
* @param beanClass the EJB implementation class
* @return a list of potential business interfaces
- * @see org.jboss.ejb3.EJBContainer#getBusinessInterfaces()
+ * @see org.jboss.ejb3.EJBContainer#getBusinessAndComponentInterfaces()
*/
public static Set<Class<?>> getBusinessInterfaces(Class<?> beanClass)
{
@@ -277,7 +277,7 @@
* @param beanClass the EJB implementation class
* @param includeSupers Whether or not to include superclasses of the specified beanClass in this check
* @return a list of potential business interfaces
- * @see org.jboss.ejb3.EJBContainer#getBusinessInterfaces()
+ * @see org.jboss.ejb3.EJBContainer#getBusinessAndComponentInterfaces()
*/
public static Set<Class<?>> getBusinessInterfaces(Class<?> beanClass, boolean includeSupers)
{
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2010-04-13 04:05:18 UTC (rev 103876)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2010-04-13 04:13:47 UTC (rev 103877)
@@ -4,7 +4,10 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.Hashtable;
+import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.EJBLocalObject;
@@ -52,6 +55,11 @@
// ------------------------------------------------------------------------------||
private static final Logger log = Logger.getLogger(SessionSpecContainer.class);
+
+ /**
+ * Business interfaces for this EJB
+ */
+ private Set<Class<?>> businessInterfaces;
// ------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------||
@@ -146,6 +154,11 @@
try
{
Class<?> invokedBusinessInterface = Class.forName(method.getActualClassName(), false, getClassloader());
+ if (!this.getBusinessInterfaces().contains(invokedBusinessInterface))
+ {
+ // Required because SerializableMethod will automatically set the actual class name to the declaring class name
+ invokedBusinessInterface = null;
+ }
// Increment invocation statistics
invokeStats.callIn();
@@ -479,6 +492,19 @@
// Use legacy
return this.isHandleMethod(invokingMethod);
}
+
+ /**
+ * Returns the busines interfaces for this EJB
+ * @return
+ */
+ protected Set<Class<?>> getBusinessInterfaces()
+ {
+ if(businessInterfaces==null)
+ {
+ throw new IllegalStateException("Business interfaces not yet initialized");
+ }
+ return businessInterfaces;
+ }
// ------------------------------------------------------------------------------||
// Lifecycle Methods ------------------------------------------------------------||
@@ -491,6 +517,32 @@
protected void lockedStart() throws Exception
{
log.info("Starting " + this);
+
+ // Cache the business interfaces
+ final Set<Class<?>> set = new HashSet<Class<?>>();
+ final Set<String> businessInterfaceNames = new HashSet<String>();
+ if (this.getMetaData().getBusinessLocals() != null)
+ {
+ businessInterfaceNames.addAll(this.getMetaData().getBusinessLocals());
+ }
+ if (this.getMetaData().getBusinessRemotes() != null)
+ {
+ businessInterfaceNames.addAll(this.getMetaData().getBusinessRemotes());
+ }
+ for (final String businessInterfaceName : businessInterfaceNames)
+ {
+ final Class<?> businessInterface;
+ try
+ {
+ businessInterface = Class.forName(businessInterfaceName, false, this.getClassloader());
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ throw new RuntimeException("Could not find marked business interface in this EJB's ClassLoader", cnfe);
+ }
+ set.add(businessInterface);
+ }
+ businessInterfaces = Collections.unmodifiableSet(set);
super.lockedStart();
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2010-04-13 04:05:18 UTC (rev 103876)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java 2010-04-13 04:13:47 UTC (rev 103877)
@@ -474,6 +474,11 @@
SerializableMethod invokedMethod = (SerializableMethod) objInvokedMethod;
Class<?> invokedBusinessInterface = Class.forName(invokedMethod.getActualClassName(), false, this.getClassloader());
+ if (!this.getBusinessInterfaces().contains(invokedBusinessInterface))
+ {
+ // Required because SerializableMethod will automatically set the actual class name to the declaring class name
+ invokedBusinessInterface = null;
+ }
try
{
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2010-04-13 04:05:18 UTC (rev 103876)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2010-04-13 04:13:47 UTC (rev 103877)
@@ -413,7 +413,13 @@
assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type " + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
SerializableMethod invokedMethod = (SerializableMethod)objInvokedMethod;
- Class<?> invokedBusinessInterface = Class.forName(invokedMethod.getActualClassName(), false, this.getClassloader());
+ Class<?> invokedBusinessInterface = Class.forName(invokedMethod.getActualClassName(), false, this
+ .getClassloader());
+ if (!this.getBusinessInterfaces().contains(invokedBusinessInterface))
+ {
+ // Required because SerializableMethod will automatically set the actual class name to the declaring class name
+ invokedBusinessInterface = null;
+ }
Map responseContext = null;
Object rtn = null;
More information about the jboss-cvs-commits
mailing list