User: sparre
Date: 01/06/30 13:15:29
Modified: src/main/org/jboss/ejb MethodInvocation.java
Log:
Moved the TPC import from the MethodInvocation to the
ContainerInvoker.
Also did a little cleanup in these files.
Revision Changes Path
1.12 +139 -153 jboss/src/main/org/jboss/ejb/MethodInvocation.java
Index: MethodInvocation.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/MethodInvocation.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- MethodInvocation.java 2001/06/18 20:01:21 1.11
+++ MethodInvocation.java 2001/06/30 20:15:29 1.12
@@ -6,22 +6,11 @@
*/
package org.jboss.ejb;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
import java.lang.reflect.Method;
-import java.util.Map;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
import java.security.Principal;
import javax.transaction.Transaction;
-import org.jboss.tm.TransactionPropagationContextImporter;
-
import org.jboss.logging.Logger;
/**
@@ -32,7 +21,8 @@
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>.
- * @version $Revision: 1.11 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Ole Husgaard</a>
+ * @version $Revision: 1.12 $
*/
public class MethodInvocation
{
@@ -40,21 +30,8 @@
// Attributes ----------------------------------------------------
- Object id;
- Object[] args;
-
- Principal identity;
- Object credential;
-
- Method m;
- EnterpriseContext ctx;
-
-
// Static --------------------------------------------------------
- private static TransactionPropagationContextImporter tpcImporter;
-
-
// Constructors --------------------------------------------------
/**
@@ -67,8 +44,8 @@
* home interface of the bean.
* @param args
* The arguments for this invocation.
- * @param tpc
- * The transaction propagation context of this invocation.
+ * @param tx
+ * The transaction of this invocation.
* @param identity
* The security identity to use in this invocation.
* @param credential
@@ -80,154 +57,133 @@
this.id = id;
this.m = m;
this.args = args;
- this.tpc = null;
this.tx = tx;
this.identity = identity;
this.credential = credential;
}
+
+ // Public --------------------------------------------------------
+
/**
- * Create a new instance.
- *
- * @param id
- * The id of target EJB of this method invocation.
- * @param m
- * The method to invoke. This method is declared in the remote or
- * home interface of the bean.
- * @param args
- * The arguments for this invocation.
- * @param identity
- * The security identity to use in this invocation.
- * @param credential
- * The security credentials to use in this invocation.
- * @param tpc
- * The transaction propagation context of this invocation.
+ * Return the invocation target ID.
+ * This is the internal ID of the invoked enterprise bean.
*/
- public MethodInvocation(Object id, Method m, Object[] args,
- Principal identity, Object credential, Object tpc)
+ public Object getId()
{
- this.id = id;
- this.m = m;
- this.args = args;
- this.tpc = tpc;
- this.tx = null;
- this.identity = identity;
- this.credential = credential;
+ return id;
}
- // Public --------------------------------------------------------
-
- public Object getId() { return id; }
-
+ /**
+ * Return the invocation method.
+ */
public Method getMethod()
{
return m;
}
+ /**
+ * Return the invocation argument list.
+ */
public Object[] getArguments()
{
return args;
}
- /**
- * This method sets the transaction associated with the method.
- * Note that this doesn't mean that the transaction is associated
- * with the thread. In fact this is the only place it exists until
- * the TxInterceptor logic. Notably it might be the case that the
- * tx associated here is different than the one on the target instance.
- */
- public void setTransaction(Transaction tx)
- {
+ /**
+ * This method sets the transaction associated with the method.
+ * Note that this doesn't mean that the transaction is associated
+ * with the thread. In fact this is the only place it exists until
+ * the TxInterceptor logic. Notably it might be the case that the
+ * tx associated here is different than the one on the target instance.
+ */
+ public void setTransaction(Transaction tx)
+ {
//DEBUG Logger.debug("Setting a transaction on Method invocation"+hashCode()+"
"+m.getName()+" with "+tx);
- this.tx = tx;
-
- }
+ this.tx = tx;
+ }
- /**
- * Return the transaction associated with the method.
- *
- * If no transaction is associated with this method but we have
- * a transaction propagation context, import the TPC into the
- * transaction manager, and associate the resulting transaction
- * with this method before returning it.
- */
- public Transaction getTransaction()
- {
- if (tx == null) {
- // See if we have a transaction propagation context
- if (tpc != null) {
- // import the propagation context
- if (tpcImporter == null) {
- try {
- tpcImporter = (TransactionPropagationContextImporter)new
InitialContext().lookup("java:/TransactionPropagationContextImporter");
- } catch (NamingException ex) {
- // No importer: Log exception, and return null.
- Logger.exception(ex);
- return null;
- }
- }
- tx = tpcImporter.importTransactionPropagationContext(tpc);
-//DEBUG Logger.debug("Imported transaction " + tx +
-//DEBUG " on Method invocation " + hashCode() +
-//DEBUG " " + m.getName());
- }
- }
- return tx;
- }
-
- public void setPrincipal(Principal identity)
- {
- this.identity = identity;
- }
-
- public Principal getPrincipal()
- {
- return identity;
- }
-
- public void setCredential(Object credential)
- {
- this.credential = credential;
- }
-
- public Object getCredential()
- {
- return credential;
- }
-
- /**
- * Set the enterprise context of this invocation.
- *
- * Once a context is associated to a Method Invocation,
- * the MI can pass it all the relevant information.
- * We set Transaction and Principal.
- */
- public void setEnterpriseContext(EnterpriseContext ctx)
- {
- this.ctx = ctx;
-
- //Set the transaction
- // MF FIXME: wrong decision. Setting the context is just an assocation of
the
- // the Method invocation to the instance. Decisions on the transaction
association
- // should be done elsewhere (new interceptor)
- //ctx.setTransaction(tx);
-
- // Set the principal
- // MF FIXME: a warning really. The association of the context variables
(tx, principal)
- // to the enterprise Context should not be done here but by the final
interceptor in the
- // container, it will signify that the instance is indeed ready for calling
- if (ctx != null) {
- ctx.setPrincipal(identity);
- }
- }
-
- public EnterpriseContext getEnterpriseContext()
- {
- return ctx;
- }
+ /**
+ * Return the transaction associated with the method.
+ *
+ * If no transaction is associated with this method but we have
+ * a transaction propagation context, import the TPC into the
+ * transaction manager, and associate the resulting transaction
+ * with this method before returning it.
+ */
+ public Transaction getTransaction()
+ {
+ return tx;
+ }
+ /**
+ * Change the security identity of this invocation.
+ */
+ public void setPrincipal(Principal identity)
+ {
+ this.identity = identity;
+ }
+
+ /**
+ * Return the security identity of this invocation.
+ */
+ public Principal getPrincipal()
+ {
+ return identity;
+ }
+
+ /**
+ * Change the security credentials of this invocation.
+ */
+ public void setCredential(Object credential)
+ {
+ this.credential = credential;
+ }
+
+ /**
+ * Return the security credentials of this invocation.
+ */
+ public Object getCredential()
+ {
+ return credential;
+ }
+
+ /**
+ * Set the enterprise context of this invocation.
+ *
+ * Once a context is associated to a Method Invocation,
+ * the MI can pass it all the relevant information.
+ * We set Transaction and Principal.
+ */
+ public void setEnterpriseContext(EnterpriseContext ctx)
+ {
+ this.ctx = ctx;
+
+ //Set the transaction
+ // MF FIXME: wrong decision. Setting the context is just an assocation of the
+ // the Method invocation to the instance. Decisions on the transaction
association
+ // should be done elsewhere (new interceptor)
+ //ctx.setTransaction(tx);
+
+ // Set the principal
+ // MF FIXME: a warning really. The association of the context variables (tx,
principal)
+ // to the enterprise Context should not be done here but by the final
interceptor in the
+ // container, it will signify that the instance is indeed ready for calling
+ if (ctx != null) {
+ ctx.setPrincipal(identity);
+ }
+ }
+
+ /**
+ * Return the enterprise context of this invocation.
+ */
+ public EnterpriseContext getEnterpriseContext()
+ {
+ return ctx;
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -235,14 +191,44 @@
// Private -------------------------------------------------------
/**
- * The transaction propagation context of this invocation.
+ * The internal ID of the enterprise bean who is the target
+ * of this invocation.
*/
- private Object tpc;
-
+ private Object id;
+
+ /**
+ * The method to invoke.
+ *
+ * This method is declared in the remote or home interface
+ * of the target enterprise bean.
+ */
+ private Method m;
+
+ /**
+ * The argument list of this invocation.
+ */
+ private Object[] args;
+
/**
* The transaction of this invocation.
*/
private Transaction tx;
+
+ /**
+ * The security identity of this invocation.
+ */
+ private Principal identity;
+
+ /**
+ * The security credentials of this invocation.
+ */
+ private Object credential;
+
+ /**
+ * The container bean context of the target bean.
+ */
+ private EnterpriseContext ctx;
+
// Inner classes -------------------------------------------------
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development