User: salborini
Date: 00/08/11 17:40:48
Modified: src/main/org/jboss/ejb/plugins AbstractInstancePool.java
CMPFilePersistenceManager.java
EntityInstancePool.java LogInterceptor.java
NoPassivationEntityInstanceCache.java
NoPassivationStatefulSessionInstanceCache.java
SingletonStatelessSessionInstancePool.java
StatefulSessionFilePersistenceManager.java
StatelessSessionInstancePool.java
TxInterceptor.java
Log:
Modifications to use the new metadata package
Revision Changes Path
1.2 +19 -3 jboss/src/main/org/jboss/ejb/plugins/AbstractInstancePool.java
Index: AbstractInstancePool.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/AbstractInstancePool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractInstancePool.java 2000/04/23 14:29:28 1.1
+++ AbstractInstancePool.java 2000/08/12 00:40:46 1.2
@@ -18,15 +18,21 @@
import org.jboss.ejb.InstancePool;
import org.jboss.ejb.EnterpriseContext;
+import org.w3c.dom.Element;
+import org.jboss.ejb.DeploymentException;
+import org.jboss.metadata.MetaData;
+import org.jboss.metadata.XmlLoadable;
+
+
/**
* <description>
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public abstract class AbstractInstancePool
- implements InstancePool
+ implements InstancePool, XmlLoadable
{
// Constants -----------------------------------------------------
@@ -142,7 +148,17 @@
}
// Z implementation ----------------------------------------------
-
+
+ // XmlLoadable implementation
+ public void importXml(Element element) throws DeploymentException {
+ String maximumSize =
MetaData.getElementContent(MetaData.getUniqueChild(element, "MaximumSize"));
+ try {
+ maxSize = Integer.parseInt(maximumSize);
+ } catch (NumberFormatException e) {
+ throw new DeploymentException("Invalid MaximumSize value for
instance pool configuration");
+ }
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
1.3 +2 -2
jboss/src/main/org/jboss/ejb/plugins/CMPFilePersistenceManager.java
Index: CMPFilePersistenceManager.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/CMPFilePersistenceManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMPFilePersistenceManager.java 2000/07/14 19:09:22 1.2
+++ CMPFilePersistenceManager.java 2000/08/12 00:40:46 1.3
@@ -42,7 +42,7 @@
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class CMPFilePersistenceManager
implements EntityPersistenceStore
@@ -84,7 +84,7 @@
ejbRemove = EntityBean.class.getMethod("ejbRemove", new Class[0]);
*/
- String ejbName = con.getMetaData().getEjbName();
+ String ejbName = con.getBeanMetaData().getEjbName();
dir = new
File(getClass().getResource("/db/"+ejbName+"/db.properties").getFile()).getParentFile();
idField = con.getBeanClass().getField("id");
}
1.4 +1 -5 jboss/src/main/org/jboss/ejb/plugins/EntityInstancePool.java
Index: EntityInstancePool.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/EntityInstancePool.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- EntityInstancePool.java 2000/08/10 16:32:25 1.3
+++ EntityInstancePool.java 2000/08/12 00:40:46 1.4
@@ -8,8 +8,6 @@
import java.rmi.RemoteException;
-import org.jboss.ejb.deployment.EntityInstancePoolConfiguration;
-
import org.jboss.ejb.Container;
import org.jboss.ejb.EnterpriseContext;
import org.jboss.ejb.EntityEnterpriseContext;
@@ -19,7 +17,7 @@
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class EntityInstancePool
extends AbstractInstancePool
@@ -56,8 +54,6 @@
public void start()
throws Exception
{
- EntityInstancePoolConfiguration conf =
(EntityInstancePoolConfiguration)getContainer().getMetaData().getContainerConfiguration().getInstancePoolConfiguration();
- maxSize = conf.getMaximumSize();
}
// Package protected ---------------------------------------------
1.6 +3 -3 jboss/src/main/org/jboss/ejb/plugins/LogInterceptor.java
Index: LogInterceptor.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/LogInterceptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- LogInterceptor.java 2000/06/16 13:10:23 1.5
+++ LogInterceptor.java 2000/08/12 00:40:46 1.6
@@ -31,7 +31,7 @@
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class LogInterceptor
extends AbstractInterceptor
@@ -66,10 +66,10 @@
{
super.start();
- String name = getContainer().getMetaData().getEjbName();
+ String name = getContainer().getBeanMetaData().getEjbName();
// Should we log all calls?
- callLogging =
getContainer().getMetaData().getContainerConfiguration().getCallLogging();
+ callLogging =
getContainer().getBeanMetaData().getContainerConfiguration().getCallLogging();
log = new Log(name);
}
1.6 +3 -3
jboss/src/main/org/jboss/ejb/plugins/NoPassivationEntityInstanceCache.java
Index: NoPassivationEntityInstanceCache.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/NoPassivationEntityInstanceCache.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NoPassivationEntityInstanceCache.java 2000/07/27 23:02:59 1.5
+++ NoPassivationEntityInstanceCache.java 2000/08/12 00:40:46 1.6
@@ -24,14 +24,14 @@
import org.jboss.ejb.EnterpriseContext;
import org.jboss.ejb.EntityEnterpriseContext;
-import org.jboss.ejb.deployment.jBossEntity;
+import org.jboss.metadata.EntityMetaData;
/**
* <description>
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
public class NoPassivationEntityInstanceCache
implements InstanceCache
@@ -64,7 +64,7 @@
public void init()
throws Exception
{
- isReentrant = ((jBossEntity)con.getMetaData()).getReentrant().equals("True");
+ isReentrant = ((EntityMetaData)con.getBeanMetaData()).isReentrant();
}
public void start()
1.6 +1 -3
jboss/src/main/org/jboss/ejb/plugins/NoPassivationStatefulSessionInstanceCache.java
Index: NoPassivationStatefulSessionInstanceCache.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/NoPassivationStatefulSessionInstanceCache.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NoPassivationStatefulSessionInstanceCache.java 2000/06/16 13:10:23 1.5
+++ NoPassivationStatefulSessionInstanceCache.java 2000/08/12 00:40:46 1.6
@@ -24,15 +24,13 @@
import org.jboss.ejb.EnterpriseContext;
import org.jboss.ejb.StatefulSessionEnterpriseContext;
-import org.jboss.ejb.deployment.jBossSession;
-
/**
* <description>
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.5 $
+* @version $Revision: 1.6 $
*/
public class NoPassivationStatefulSessionInstanceCache
implements InstanceCache
1.3 +12 -6
jboss/src/main/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java
Index: SingletonStatelessSessionInstancePool.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/SingletonStatelessSessionInstancePool.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SingletonStatelessSessionInstancePool.java 2000/05/31 14:37:25 1.2
+++ SingletonStatelessSessionInstancePool.java 2000/08/12 00:40:46 1.3
@@ -15,8 +15,11 @@
import org.jboss.ejb.InstancePool;
import org.jboss.ejb.EnterpriseContext;
import org.jboss.ejb.StatelessSessionEnterpriseContext;
+import org.jboss.ejb.DeploymentException;
-import org.jboss.ejb.deployment.SingletonStatelessSessionInstancePoolConfiguration;
+import org.jboss.metadata.XmlLoadable;
+import org.jboss.metadata.MetaData;
+import org.w3c.dom.Element;
/**
* Singleton pool for session beans. This lets you have
@@ -24,10 +27,10 @@
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class SingletonStatelessSessionInstancePool
- implements InstancePool
+ implements InstancePool, XmlLoadable
{
// Constants -----------------------------------------------------
@@ -58,8 +61,6 @@
public void init()
throws Exception
{
- SingletonStatelessSessionInstancePoolConfiguration conf =
(SingletonStatelessSessionInstancePoolConfiguration)con.getMetaData().getContainerConfiguration().getInstancePoolConfiguration();
- isSynchronized = conf.getSynchronized();
}
public void start()
@@ -143,7 +144,12 @@
}
// Z implementation ----------------------------------------------
-
+
+ // XmlLoadable implementation
+ public void importXml(Element element) throws DeploymentException {
+ isSynchronized =
Boolean.valueOf(MetaData.getElementContent(MetaData.getUniqueChild(element,
"Synchronized"))).booleanValue();
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
1.4 +2 -2
jboss/src/main/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java
Index: StatefulSessionFilePersistenceManager.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/StatefulSessionFilePersistenceManager.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StatefulSessionFilePersistenceManager.java 2000/05/31 19:09:15 1.3
+++ StatefulSessionFilePersistenceManager.java 2000/08/12 00:40:46 1.4
@@ -58,7 +58,7 @@
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class StatefulSessionFilePersistenceManager
implements StatefulSessionPersistenceManager
@@ -96,7 +96,7 @@
ejbRemove = SessionBean.class.getMethod("ejbRemove", new Class[0]);
// Initialize the dataStore
- String ejbName = con.getMetaData().getEjbName();
+ String ejbName = con.getBeanMetaData().getEjbName();
File database = new File("database");
1.2 +1 -5
jboss/src/main/org/jboss/ejb/plugins/StatelessSessionInstancePool.java
Index: StatelessSessionInstancePool.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/StatelessSessionInstancePool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StatelessSessionInstancePool.java 2000/04/22 14:30:12 1.1
+++ StatelessSessionInstancePool.java 2000/08/12 00:40:46 1.2
@@ -8,8 +8,6 @@
import java.rmi.RemoteException;
-import org.jboss.ejb.deployment.StatelessSessionInstancePoolConfiguration;
-
import org.jboss.ejb.Container;
import org.jboss.ejb.EnterpriseContext;
import org.jboss.ejb.StatelessSessionEnterpriseContext;
@@ -19,7 +17,7 @@
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class StatelessSessionInstancePool
extends AbstractInstancePool
@@ -38,8 +36,6 @@
public void init()
throws Exception
{
- StatelessSessionInstancePoolConfiguration conf =
(StatelessSessionInstancePoolConfiguration)getContainer().getMetaData().getContainerConfiguration().getInstancePoolConfiguration();
- maxSize = conf.getMaximumSize();
}
// Package protected ---------------------------------------------
1.10 +47 -85 jboss/src/main/org/jboss/ejb/plugins/TxInterceptor.java
Index: TxInterceptor.java
===================================================================
RCS file:
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/TxInterceptor.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TxInterceptor.java 2000/08/10 16:30:44 1.9
+++ TxInterceptor.java 2000/08/12 00:40:47 1.10
@@ -27,16 +27,18 @@
import org.jboss.ejb.MethodInvocation;
import org.jboss.tm.TxManager;
import org.jboss.logging.Logger;
-import org.jboss.metadata.*;
-import org.jboss.metadata.ejbjar.EJBMethod;
+import org.jboss.metadata.MetaData;
+import org.jboss.metadata.BeanMetaData;
+import org.jboss.metadata.MethodMetaData;
+
/**
* <description>
*
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.9 $
+* @version $Revision: 1.10 $
*/
public class TxInterceptor
extends AbstractInterceptor
@@ -47,8 +49,6 @@
private HashMap methodTx = new HashMap();
protected Container container;
- private RunInvoke invoker = new RunInvoke();
- private RunInvokeHome invokeHomer = new RunInvokeHome();
// Static --------------------------------------------------------
@@ -80,10 +80,7 @@
public Object invokeHome(MethodInvocation mi)
throws Exception
{
- // TODO
- // return getNext().invokeHome(mi);
- invokeHomer.mi = mi;
- return runWithTransactions(invokeHomer, mi);
+ return runWithTransactions(false, mi);
}
/**
@@ -96,29 +93,28 @@
* @exception Exception
*/
public Object invoke(MethodInvocation mi) throws Exception {
- invoker.mi = mi;
- return runWithTransactions(invoker, mi);
+ return runWithTransactions(true, mi);
}
private void printMethod(Method m, byte type) {
String name;
switch(type) {
- case EJBMethod.TX_MANDATORY:
+ case MetaData.TX_MANDATORY:
name = "TX_MANDATORY";
break;
- case EJBMethod.TX_NEVER:
+ case MetaData.TX_NEVER:
name = "TX_NEVER";
break;
- case EJBMethod.TX_NOT_SUPPORTED:
+ case MetaData.TX_NOT_SUPPORTED:
name = "TX_NOT_SUPPORTED";
break;
- case EJBMethod.TX_REQUIRED:
+ case MetaData.TX_REQUIRED:
name = "TX_REQUIRED";
break;
- case EJBMethod.TX_REQUIRES_NEW:
+ case MetaData.TX_REQUIRES_NEW:
name = "TX_REQUIRES_NEW";
break;
- case EJBMethod.TX_SUPPORTS:
+ case MetaData.TX_SUPPORTS:
name = "TX_SUPPORTS";
break;
default:
@@ -127,8 +123,16 @@
Logger.debug(name+" for "+m.getName());
}
+ private Object invokeNext(boolean remoteInvocation, MethodInvocation mi)
throws Exception {
+ if (remoteInvocation) {
+ return getNext().invoke(mi);
+ } else {
+ return getNext().invokeHome(mi);
+ }
+ }
+
- private Object runWithTransactions(Doable runner, MethodInvocation mi) throws
Exception {
+ private Object runWithTransactions(boolean remoteInvocation, MethodInvocation
mi) throws Exception {
// Old transaction is the transaction that comes with the MI
Transaction oldTransaction = mi.getTransaction();
@@ -137,13 +141,13 @@
//DEBUG System.out.println("Current transaction in MI is
"+mi.getTransaction());
- byte transType = getTransactionMethod(mi.getMethod(), runner);
+ byte transType = getTransactionMethod(mi.getMethod(),
remoteInvocation);
// DEBUG printMethod(mi.getMethod(), transType);
switch (transType) {
- case EJBMethod.TX_NOT_SUPPORTED: {
+ case MetaData.TX_NOT_SUPPORTED: {
// Thread arriving must be clean (jboss doesn't set
the thread previously)
@@ -151,13 +155,13 @@
tm.disassociateThread();
// Do not set a transaction on the thread even if in
MI, just run
- return runner.run();
+ return invokeNext(remoteInvocation,mi );
// We don't have to do anything since we don't deal
with transactions
}
- case EJBMethod.TX_REQUIRED: {
+ case MetaData.TX_REQUIRED: {
if (oldTransaction == null) { // No tx running
@@ -182,7 +186,7 @@
// Continue invocation
try {
- return runner.run();
+ return invokeNext(remoteInvocation,mi );
}
catch (RemoteException e) {
@@ -242,7 +246,7 @@
}
}
- case EJBMethod.TX_SUPPORTS: {
+ case MetaData.TX_SUPPORTS: {
if (oldTransaction != null) { // We have a tx
propagated
@@ -255,7 +259,7 @@
// Continue invocation
try {
- return runner.run();
+ return invokeNext(remoteInvocation,mi );
}
catch (RuntimeException e) {
@@ -270,7 +274,7 @@
}
- case EJBMethod.TX_REQUIRES_NEW: {
+ case MetaData.TX_REQUIRES_NEW: {
// Always begin a transaction
tm.begin();
@@ -284,7 +288,7 @@
// Continue invocation
try {
- return runner.run();
+ return invokeNext(remoteInvocation,mi );
}
catch (RemoteException e) {
@@ -329,7 +333,7 @@
}
}
- case EJBMethod.TX_MANDATORY: {
+ case MetaData.TX_MANDATORY: {
if (oldTransaction == null) { // no transaction = bad!
@@ -341,19 +345,19 @@
tm.associateThread(oldTransaction);
// That's it
- return runner.run();
+ return invokeNext(remoteInvocation,mi );
}
}
- case EJBMethod.TX_NEVER: {
-
+ case MetaData.TX_NEVER: {
+
if (oldTransaction != null) { // Transaction = bad!
throw new RemoteException("Transaction not
allowed");
}
else {
- return runner.run();
+ return invokeNext(remoteInvocation,mi );
}
}
}
@@ -364,63 +368,21 @@
// Protected ----------------------------------------------------
// This should be cached, since this method is called very often
- protected byte getTransactionMethod(Method m, Doable d) {
+ protected byte getTransactionMethod(Method m, boolean remoteInvocation) {
Byte b = (Byte)methodTx.get(m);
if(b != null) return b.byteValue();
- try {
- BeanMetaData bmd = container.getBeanMetaData();
- System.out.println("Found metadata for bean
'"+bmd.getName()+"'"+" method is "+m);
- try {
- MethodMetaData mmd;
- if(d == invoker)
- mmd = bmd.getMethod(m.getName(),
m.getParameterTypes());
- else
- mmd = bmd.getHomeMethod(m.getName(),
m.getParameterTypes());
- //System.out.println("Found metadata for method
'"+mmd.getName()+"'");
- byte result =
((Byte)mmd.getProperty("transactionAttribute")).byteValue();
- methodTx.put(m, new Byte(result));
- return result;
- } catch(IllegalArgumentException e2) {
- try {
- MethodMetaData mmd;
- if(d == invoker)
- mmd = bmd.getMethod("*", new Class[0]);
- else
- mmd = bmd.getHomeMethod("*", new
Class[0]);
- //System.out.println("Found metadata for '*'");
- byte result =
((Byte)mmd.getProperty("transactionAttribute")).byteValue();
- methodTx.put(m, new Byte(result));
- return result;
- } catch(IllegalArgumentException e3) {
- //System.out.println("Couldn't find method
metadata for "+m+" in "+bmd.getName());
- }
- }
- } catch(IllegalArgumentException e) {
- System.out.println("Couldn't find bean
'"+container.getMetaData().getEjbName()+"'");
- }
- methodTx.put(m, new Byte(EJBMethod.TX_SUPPORTS));
- return EJBMethod.TX_SUPPORTS;
- }
- // Inner classes -------------------------------------------------
- interface Doable {
- public Object run() throws Exception;
+ BeanMetaData bmd = container.getBeanMetaData();
+ System.out.println("Found metadata for bean '"+bmd.getEjbName()+"'"+"
method is "+m);
+ byte result = bmd.getMethodTransactionType(m.getName(),
m.getParameterTypes(), remoteInvocation);
+
+ // provide default if method is not found in descriptor
+ if (result == MetaData.TX_UNKNOWN) result = MetaData.TX_SUPPORTS;
+
+ methodTx.put(m, new Byte(result));
+ return result;
}
- class RunInvoke implements Doable {
- MethodInvocation mi;
- public Object run() throws Exception {
-//DEBUG System.out.println("Calling the next invoker in
runInvoke");
- return getNext().invoke(mi);
- }
- }
+ // Inner classes -------------------------------------------------
- class RunInvokeHome implements Doable {
- MethodInvocation mi;
- public Object run() throws Exception {
-
-//DEBUG System.out.println("Calling the next invoker in
runInvokeHome");
- return getNext().invokeHome(mi);
- }
- }
}