User: slaboure
Date: 01/09/20 15:19:00
Modified: src/main/org/jboss/ejb/plugins Tag: Branch_2_4
AbstractInstancePool.java EntityInstancePool.java
MessageDrivenInstancePool.java
StatelessSessionInstancePool.java
Log:
Instance pooling activated for SLSB and MDB
Revision Changes Path
No revision
No revision
1.9.6.2 +54 -28 jboss/src/main/org/jboss/ejb/plugins/AbstractInstancePool.java
Index: AbstractInstancePool.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/AbstractInstancePool.java,v
retrieving revision 1.9.6.1
retrieving revision 1.9.6.2
diff -u -r1.9.6.1 -r1.9.6.2
--- AbstractInstancePool.java 2001/09/04 01:51:07 1.9.6.1
+++ AbstractInstancePool.java 2001/09/20 22:19:00 1.9.6.2
@@ -34,9 +34,10 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
-*
-* @version $Revision: 1.9.6.1 $
+* @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>
*
+* @version $Revision: 1.9.6.2 $
+*
* <p><b>Revisions:</b>
* <p><b>20010704 marcf:</b>
* <ul>
@@ -46,24 +47,31 @@
* <ul>
* <li>- Added statistics gathering
* </ul>
+* <p><b>20010920 Sacha Labourey:</b>
+* <ul>
+* <li>- Pooling made optional and only activated in concrete subclasses for SLSB
and MDB
+* </ul>
*/
public abstract class AbstractInstancePool
implements InstancePool, XmlLoadable
{
// Constants -----------------------------------------------------
-
+
// Attributes ----------------------------------------------------
private Container container;
-
+
Stack pool = new Stack();
int maxSize = 30;
-
+
+ // determine if we reuse EnterpriseContext objects i.e. if we actually do pooling
+ protected boolean reclaim = false;
+
// Static --------------------------------------------------------
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
-
+
/**
* Set the callback to the container. This is for initialization.
* The IM may extract the configuration from the container.
@@ -74,7 +82,7 @@
{
this.container = c;
}
-
+
/**
* <review>
* @return Callback to the container which can be null if not set proviously
@@ -84,25 +92,35 @@
{
return container;
}
-
+
public void init()
throws Exception
{
}
-
+
public void start()
throws Exception
{
}
-
+
public void stop()
{
}
-
+
public void destroy()
{
}
-
+
+ public boolean getReclaim()
+ {
+ return reclaim;
+ }
+
+ public void setReclaim(boolean reclaim)
+ {
+ this.reclaim = reclaim;
+ }
+
/**
* Get an instance without identity.
* Can be used by finders,create-methods, and activation
@@ -114,7 +132,7 @@
throws Exception
{
//DEBUG Logger.debug("Get instance "+this);
-
+
if (!pool.empty())
{
return (EnterpriseContext)pool.pop();
@@ -132,7 +150,7 @@
}
}
}
-
+
/**
* Return an instance after invocation.
*
@@ -147,21 +165,29 @@
// Pool it
//DEBUG Logger.debug("Free
instance:"+ctx.getId()+"#"+ctx.getTransaction());
ctx.clear();
-
+
if (pool.size() < maxSize)
{
-
- // We do not reuse but create a brand new instance simplifies the design
+
+ // If (!reclaim), we do not reuse but create a brand new instance
simplifies the design
try {
- pool.push(create(container.createBeanClassInstance()));
- } catch (Exception ignored) {}
+ if (this.reclaim)
+ {
+ pool.push(ctx);
+ }
+ else
+ {
+ discard (ctx);
+ pool.push(create(container.createBeanClassInstance()));
+ }
+ } catch (Exception ignored) {}
//pool.push(ctx);
} else
{
discard(ctx);
}
}
-
+
public void discard(EnterpriseContext ctx)
{
// Throw away
@@ -173,9 +199,9 @@
// DEBUG Logger.exception(e);
}
}
-
+
// Z implementation ----------------------------------------------
-
+
// XmlLoadable implementation
public void importXml(Element element) throws DeploymentException {
String maximumSize =
MetaData.getElementContent(MetaData.getUniqueChild(element, "MaximumSize"));
@@ -185,15 +211,15 @@
throw new DeploymentException("Invalid MaximumSize value for instance pool
configuration");
}
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
protected abstract EnterpriseContext create(Object instance)
throws Exception;
-
+
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
}
1.9.6.2 +21 -27 jboss/src/main/org/jboss/ejb/plugins/EntityInstancePool.java
Index: EntityInstancePool.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/EntityInstancePool.java,v
retrieving revision 1.9.6.1
retrieving revision 1.9.6.2
diff -u -r1.9.6.1 -r1.9.6.2
--- EntityInstancePool.java 2001/09/04 01:51:07 1.9.6.1
+++ EntityInstancePool.java 2001/09/20 22:19:00 1.9.6.2
@@ -15,31 +15,37 @@
import org.jboss.ejb.EntityEnterpriseContext;
/**
- * <description>
- *
+ * <description>
+ *
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.9.6.1 $
- *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>
+ * @version $Revision: 1.9.6.2 $
+ *
* <p><b>Revisions:</b>
* <p><b>20010718 andreas schaefer:</b>
* <ul>
* <li>- Added statistics gathering
* </ul>
+* <p><b>20010920 Sacha Labourey:</b>
+* <ul>
+* <li>- Moved "reclaim" flag (set by Bill Burke) to the AbstractInstancePool level.
+* It can now be used for SLSB and MDB (pooling activated)
+* </ul>
*/
public class EntityInstancePool
extends AbstractInstancePool
{
// Constants -----------------------------------------------------
-
+
// Attributes ----------------------------------------------------
-
+
// Static --------------------------------------------------------
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
/**
* Return an instance to the free pool. Reset state
@@ -49,44 +55,32 @@
* b) Removed
* c) Passivated
*
- * @param ctx
+ * @param ctx
*/
- private boolean reclaim = false;
-
- public boolean getReclaim()
- {
- return reclaim;
- }
-
- public void setReclaim(boolean reclaim)
- {
- this.reclaim = reclaim;
- }
-
public synchronized void free(EnterpriseContext ctx)
{
// If transaction still present don't do anything (let the instance be GC)
if (ctx.getTransaction() != null) return ;
-
- // To simplify design we don't reuse the ctx.
+
+ // To simplify design we don't reuse the ctx.
if (reclaim) super.free(ctx);
}
-
+
// Z implementation ----------------------------------------------
public void start()
throws Exception
{
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
protected EnterpriseContext create(Object instance)
throws Exception
{
return new EntityEnterpriseContext(instance, getContainer());
}
-
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
1.3.6.1 +20 -10
jboss/src/main/org/jboss/ejb/plugins/MessageDrivenInstancePool.java
Index: MessageDrivenInstancePool.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/MessageDrivenInstancePool.java,v
retrieving revision 1.3
retrieving revision 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- MessageDrivenInstancePool.java 2001/02/28 09:25:40 1.3
+++ MessageDrivenInstancePool.java 2001/09/20 22:19:00 1.3.6.1
@@ -13,41 +13,51 @@
import org.jboss.ejb.MessageDrivenEnterpriseContext;
/**
- * <description>
+ * <description>
* Stolen from StatelessSessionInstancePool
* @see <related>
* @author Rickard �berg ([EMAIL PROTECTED])
* @author Peter Antman ([EMAIL PROTECTED])
- * @version $Revision: 1.3 $
+ * @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>
+ * @version $Revision: 1.3.6.1 $
+ *
+ * <p><b>Revisions:</b>
+ * <p><b>20010920 Sacha Labourey:</b>
+ * <ul>
+ * <li>- Activate pooling for MDB
+ * </ul>
*/
public class MessageDrivenInstancePool
extends AbstractInstancePool
{
// Constants -----------------------------------------------------
-
+
// Attributes ----------------------------------------------------
-
+
// Static --------------------------------------------------------
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
-
+
// Z implementation ----------------------------------------------
public void init()
throws Exception
{
+ super.init();
+ // for MDB, we *do* pool
+ this.reclaim = true;
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
protected EnterpriseContext create(Object instance)
throws Exception
{
return new MessageDrivenEnterpriseContext(instance, getContainer());
}
-
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
1.4.6.2 +20 -12
jboss/src/main/org/jboss/ejb/plugins/StatelessSessionInstancePool.java
Index: StatelessSessionInstancePool.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/StatelessSessionInstancePool.java,v
retrieving revision 1.4.6.1
retrieving revision 1.4.6.2
diff -u -r1.4.6.1 -r1.4.6.2
--- StatelessSessionInstancePool.java 2001/09/04 01:51:07 1.4.6.1
+++ StatelessSessionInstancePool.java 2001/09/20 22:19:00 1.4.6.2
@@ -13,47 +13,55 @@
import org.jboss.ejb.StatelessSessionEnterpriseContext;
/**
- * <description>
- *
+ * <description>
+ *
* @see <related>
* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.4.6.1 $
- *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Sacha Labourey</a>
+ * @version $Revision: 1.4.6.2 $
+ *
* <p><b>Revisions:</b>
* <p><b>20010718 andreas schaefer:</b>
* <ul>
* <li>- Added Statistics Gathering
* </ul>
+ * <p><b>20010920 Sacha Labourey:</b>
+ * <ul>
+ * <li>- Activate pooling for SLSB
+ * </ul>
*/
public class StatelessSessionInstancePool
extends AbstractInstancePool
{
// Constants -----------------------------------------------------
-
+
// Attributes ----------------------------------------------------
-
+
// Static --------------------------------------------------------
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
-
+
// Z implementation ----------------------------------------------
public void init()
throws Exception
{
+ super.init();
+ // for SLSB, we *do* pool
+ this.reclaim = true;
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
protected EnterpriseContext create(Object instance)
throws Exception
{
return new StatelessSessionEnterpriseContext(instance, getContainer());
}
-
+
// Private -------------------------------------------------------
// Inner classes -------------------------------------------------
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development