[jboss-cvs] JBossAS SVN: r76964 - projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 12 02:31:18 EDT 2008
Author: ALRubinger
Date: 2008-08-12 02:31:18 -0400 (Tue, 12 Aug 2008)
New Revision: 76964
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
Log:
[EJBTHREE-1060] Add support to throw IllegalAccessException where appropriate from SessionContext.getInvokedBusinessInterface
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 2008-08-12 06:30:38 UTC (rev 76963)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2008-08-12 06:31:18 UTC (rev 76964)
@@ -11,6 +11,7 @@
import javax.ejb.EJBLocalObject;
import javax.ejb.EJBObject;
import javax.ejb.Handle;
+import javax.ejb.SessionContext;
import org.jboss.aop.Advisor;
import org.jboss.aop.Dispatcher;
@@ -42,6 +43,8 @@
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
+import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
/**
* SessionSpecContainer
@@ -253,10 +256,76 @@
//TODO Should be getting from current invocation
SerializableMethod invokedMethod = SessionSpecContainer.invokedMethod.get();
assert invokedMethod!=null : "Invoked Method has not been set";
- String interfaceName = invokedMethod.getActualClassName();
- assert interfaceName !=null && interfaceName.trim().length()>0 : "Target Business Interface is not available on invoked method";
+
+ // Obtain the name of the invoking interface
+ String interfaceName = null;
+ if (invokedMethod != null)
+ {
+ interfaceName = invokedMethod.getActualClassName();
+ }
+
+ // Test for no invoked business interface
+ if(interfaceName==null)
+ {
+ throw new IllegalStateException(
+ "Call to "
+ + SessionContext.class.getName()
+ + ".getInvokedBusinessInterface() was made from outside an EJB3 Business Interface (possibly an EJB2.x Remote/Local?)");
+ }
+
+ /*
+ * Determine if the specified class is not a valid business
+ * interface
+ */
+
+ // Initialize a check flag
+ boolean isValidBusinessInterface = false;
+
+ // Get Metadata
+ JBossSessionBeanMetaData smd = this.getMetaData();
+
+ // Check in business remotes
+ BusinessRemotesMetaData businessRemotes = smd.getBusinessRemotes();
+ if (businessRemotes != null)
+ {
+ for (String businessRemote : businessRemotes)
+ {
+ if (businessRemote.equals(interfaceName))
+ {
+ isValidBusinessInterface = true;
+ break;
+ }
+ }
+ }
+
+ // Check in business locals
+ BusinessLocalsMetaData businessLocals = smd.getBusinessLocals();
+ if (businessLocals != null)
+ {
+ for (String businessLocal : businessLocals)
+ {
+ if (businessLocal.equals(interfaceName))
+ {
+ isValidBusinessInterface = true;
+ break;
+ }
+ }
+ }
+
+ // If not found as a business interface, we haven't invoked through EJB3 View
+ if(!isValidBusinessInterface)
+ {
+ throw new IllegalStateException("Cannot invoke " + SessionContext.class.getName()
+ + ".getInvokedBusinessInterface() from outside of an EJB3 Business View - "
+ + "EJB 3.0 Core Specification 4.5.2; Used: " + interfaceName);
+ }
+
+ /*
+ * Get Invoked Interface
+ */
+
+ // Attempt to load the invoked interface
Class<?> invokedInterface = null;
-
try
{
invokedInterface = Class.forName(interfaceName, false, this.getClassloader());
@@ -394,7 +463,6 @@
@Deprecated
protected boolean isHomeMethod(Method method)
{
- log.warn("Deprecated usage of isHomeMethod(Method method), use instead isHomeMethod(SerializableMethod method)");
if (javax.ejb.EJBHome.class.isAssignableFrom(method.getDeclaringClass()))
return true;
if (javax.ejb.EJBLocalHome.class.isAssignableFrom(method.getDeclaringClass()))
More information about the jboss-cvs-commits
mailing list