User: mnf999
Date: 02/02/06 10:27:51
Modified: src/main/org/jboss/proxy/ejb EntityProxy.java
GenericProxy.java HomeProxy.java
ListEntityProxy.java ProxyFactory.java
StatefulSessionProxy.java
StatelessSessionProxy.java
Log:
Fix for caching the Object Name, SPEEEED!
Revision Changes Path
1.3 +4 -4 jboss/src/main/org/jboss/proxy/ejb/EntityProxy.java
Index: EntityProxy.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/proxy/ejb/EntityProxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- EntityProxy.java 2001/12/31 09:20:05 1.2
+++ EntityProxy.java 2002/02/06 18:27:51 1.3
@@ -29,7 +29,7 @@
/**
* An EJB entity bean proxy class.
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.2 $
+* @version $Revision: 1.3 $
*
* <p><b>2001/11/19: marcf</b>
* <ol>
@@ -67,9 +67,9 @@
*
* @throws NullPointerException Id may not be null.
*/
- public EntityProxy(String jndiName, Object id, Invoker invoker)
+ public EntityProxy(int objectName, String jndiName, Object id, Invoker invoker)
{
- super(jndiName, invoker);
+ super(objectName, jndiName, invoker);
if (id == null)
throw new NullPointerException("Id may not be null");
@@ -139,7 +139,7 @@
{
Invocation invocation = new Invocation(new HashMap());
- invocation.setContainer(objectName);
+ invocation.setContainer(new Integer(objectName));
invocation.setType("remote");
invocation.setId(id);
invocation.setMethod(m);
1.3 +6 -5 jboss/src/main/org/jboss/proxy/ejb/GenericProxy.java
Index: GenericProxy.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/proxy/ejb/GenericProxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- GenericProxy.java 2002/01/03 04:00:59 1.2
+++ GenericProxy.java 2002/02/06 18:27:51 1.3
@@ -40,7 +40,7 @@
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*
* <p><b>2001/11/19: marcf</b>
* <ol>
@@ -59,7 +59,7 @@
* container in the future we should give just an abstract key into a metadata
* container repository in the server.
*/
- protected transient String objectName;
+ protected int objectName;
protected String jndiName;
@@ -125,10 +125,10 @@
* @param container
* @param invoker
*/
- protected GenericProxy(final String jndiName, final Invoker invoker)
+ protected GenericProxy(int objectName, final String jndiName, final Invoker
invoker)
{
this.jndiName = jndiName;
- this.objectName = "jboss.j2ee:service=EJB,jndiName="+jndiName;
+ this.objectName = objectName;
this.invoker = invoker;
}
@@ -192,6 +192,7 @@
public void writeExternal(final ObjectOutput out) throws IOException
{
out.writeUTF(jndiName);
+ out.writeInt(objectName);
out.writeObject(invoker);
}
@@ -206,7 +207,7 @@
throws IOException, ClassNotFoundException
{
jndiName = in.readUTF();
- objectName = "jboss.j2ee:service=EJB,jndiName="+jndiName;
+ objectName = in.readInt();
invoker = (Invoker) in.readObject();
}
}
1.5 +5 -5 jboss/src/main/org/jboss/proxy/ejb/HomeProxy.java
Index: HomeProxy.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/proxy/ejb/HomeProxy.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HomeProxy.java 2002/01/04 05:39:22 1.4
+++ HomeProxy.java 2002/02/06 18:27:51 1.5
@@ -38,7 +38,7 @@
* The client-side proxy for an EJB Home object.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.4 $
+* @version $Revision: 1.5 $
*
* <p><b>2001/11/21: marcf</b>
* <ol>
@@ -109,9 +109,9 @@
* Construct a <tt>HomeProxy</tt>.
*
*/
- public HomeProxy(String jndiName, Invoker invoker, EJBMetaData ejbMetaData)
+ public HomeProxy(int objectName, String jndiName, Invoker invoker, EJBMetaData
ejbMetaData)
{
- super(jndiName, invoker);
+ super(objectName, jndiName, invoker);
this.ejbMetaData = ejbMetaData;
}
@@ -179,7 +179,7 @@
Invocation invocation = new Invocation(new HashMap());
- invocation.setContainer(objectName);
+ invocation.setContainer(new Integer(objectName));
invocation.setId(id);
invocation.setType("remote");
invocation.setMethod(REMOVE_OBJECT);
@@ -200,7 +200,7 @@
{
Invocation invocation = new Invocation(new HashMap());
- invocation.setContainer(objectName);
+ invocation.setContainer(new Integer(objectName));
invocation.setType("home");
invocation.setMethod(m);
invocation.setArguments(arguments);
1.2 +93 -92 jboss/src/main/org/jboss/proxy/ejb/ListEntityProxy.java
Index: ListEntityProxy.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/proxy/ejb/ListEntityProxy.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ListEntityProxy.java 2001/12/19 07:21:18 1.1
+++ ListEntityProxy.java 2002/02/06 18:27:51 1.2
@@ -1,9 +1,9 @@
/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
package org.jboss.proxy.ejb;
import java.util.List;
@@ -26,41 +26,41 @@
import org.jboss.ejb.ListCacheKey;
/**
- * An EJB CMP entity bean proxy class holds info about the List that the entity
belongs to,
- * is used for reading ahead.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Oleg Nitz</a>
- * @version $Revision: 1.1 $
- */
+* An EJB CMP entity bean proxy class holds info about the List that the entity
belongs to,
+* is used for reading ahead.
+*
+* @author <a href="mailto:[EMAIL PROTECTED]">Oleg Nitz</a>
+* @version $Revision: 1.2 $
+*/
public class ListEntityProxy
extends EntityProxy
implements InvocationHandler
{
// Constants -----------------------------------------------------
-
+
/** Serial Version Identifier. */
-// private static final long serialVersionUID = -1523442773137704949L;
-
+ // private static final long serialVersionUID = -1523442773137704949L;
+
protected static final Method GET_READ_AHEAD_VALUES;
-
+
// Attributes ----------------------------------------------------
-
+
/**
- * A List that this entity belongs to (used for reading ahead).
- */
+ * A List that this entity belongs to (used for reading ahead).
+ */
private List list;
-
+
/**
- * A hash map of read ahead values, maps Methods to values.
- */
+ * A hash map of read ahead values, maps Methods to values.
+ */
private transient HashMap readAheadValues;
-
+
// Static --------------------------------------------------------
-
+
static {
try {
final Class[] empty = {};
-
+
GET_READ_AHEAD_VALUES =
ReadAheadBuffer.class.getMethod("getReadAheadValues", empty);
}
catch (Exception e) {
@@ -68,64 +68,65 @@
throw new ExceptionInInitializerError(e);
}
}
-
+
// Constructors --------------------------------------------------
-
+
/**
- * No-argument constructor for externalization.
- */
+ * No-argument constructor for externalization.
+ */
public ListEntityProxy() {}
-
+
/**
- * Construct a <tt>ListEntityProxy</tt>.
- *
- * @param name The JNDI name of the container that we proxy for.
- * @param container The remote interface of the invoker for which
- * this is a proxy for.
- * @param id The primary key of the entity.
- * @param optimize True if the proxy will attempt to optimize
- * VM-local calls.
- * @param list A List that this entity belongs to (used for reading
ahead).
- * @param listId The list id.
- * @param index The index of this entity in the list.
- *
- * @throws NullPointerException Id may not be null.
- */
- public ListEntityProxy(String name,
- Invoker invoker,
- Object id,
- List list,
- long listId,
- int index)
+ * Construct a <tt>ListEntityProxy</tt>.
+ *
+ * @param name The JNDI name of the container that we proxy for.
+ * @param container The remote interface of the invoker for which
+ * this is a proxy for.
+ * @param id The primary key of the entity.
+ * @param optimize True if the proxy will attempt to optimize
+ * VM-local calls.
+ * @param list A List that this entity belongs to (used for reading
ahead).
+ * @param listId The list id.
+ * @param index The index of this entity in the list.
+ *
+ * @throws NullPointerException Id may not be null.
+ */
+ public ListEntityProxy(int objectName,
+ String name,
+ Invoker invoker,
+ Object id,
+ List list,
+ long listId,
+ int index)
{
- super(name, new ListCacheKey(id, listId, index), invoker);
-
+ super(objectName, name, new ListCacheKey(id, listId, index), invoker);
+
this.list = list;
}
-
+
// Public --------------------------------------------------------
-
+
public Map getReadAheadValues() {
if (readAheadValues == null) {
readAheadValues = new HashMap();
}
return readAheadValues;
}
-
-
+
+
/**
- * InvocationHandler implementation.
- *
- * @param proxy The proxy object.
- * @param m The method being invoked.
- * @param args The arguments for the method.
- *
- * @throws Throwable Any exception or error thrown while processing.
- */
+ * InvocationHandler implementation.
+ *
+ * @param proxy The proxy object.
+ * @param m The method being invoked.
+ * @param args The arguments for the method.
+ *
+ * @throws Throwable Any exception or error thrown while processing.
+ */
public final Object invoke(final Object proxy,
- final Method m,
- Object[] args)
- throws Throwable
+ final Method m,
+ Object[] args)
+ throws Throwable
{
Object result;
ReadAheadResult raResult;
@@ -133,11 +134,11 @@
int from;
int to;
ReadAheadBuffer buf;
-
+
if (m.equals(GET_READ_AHEAD_VALUES)) {
return getReadAheadValues();
}
-
+
// have we read ahead the result?
if (readAheadValues != null) {
result = readAheadValues.get(m);
@@ -145,9 +146,9 @@
return readAheadValues.remove(m);
}
}
-
+
result = super.invoke(proxy, m, args);
-
+
if (result instanceof ReadAheadResult) {
raResult = (ReadAheadResult) result;
aheadResult = raResult.getAheadResult();
@@ -162,43 +163,43 @@
return result;
}
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
/**
- * Externalization support.
- *
- * @param out
- *
- * @throws IOException
- */
+ * Externalization support.
+ *
+ * @param out
+ *
+ * @throws IOException
+ */
public void writeExternal(final ObjectOutput out)
- throws IOException
+ throws IOException
{
super.writeExternal(out);
out.writeObject(list);
}
-
+
/**
- * Externalization support.
- *
- * @param in
- *
- * @throws IOException
- * @throws ClassNotFoundException
- */
+ * Externalization support.
+ *
+ * @param in
+ *
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
public void readExternal(final ObjectInput in)
- throws IOException, ClassNotFoundException
+ throws IOException, ClassNotFoundException
{
super.readExternal(in);
list = (List)in.readObject();
}
-
-
+
+
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
}
1.6 +54 -40 jboss/src/main/org/jboss/proxy/ejb/ProxyFactory.java
Index: ProxyFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/proxy/ejb/ProxyFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ProxyFactory.java 2002/01/14 02:01:07 1.5
+++ ProxyFactory.java 2002/02/06 18:27:51 1.6
@@ -1,9 +1,9 @@
/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
package org.jboss.proxy.ejb;
import java.lang.reflect.InvocationHandler;
@@ -38,27 +38,27 @@
import org.jboss.logging.Logger;
/**
- * As we remove the one one association between container STACK and invoker we keep
this around
- * IN the future the creation of proxies is a task done on a container basis but
the container
- * as a logical representation, in other words, the container "Entity with
RMI/IIOP" is not a
- * container stack but an association at the invocation level that points to all
metadata for
- * a given container.
- *
- * In other words this is here for legacy reason and to not disrupt the container
at once
- * In particular we declare that we "implement" the container invoker interface
when we are
- * just implementing the Proxy generation calls. Separation of concern.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
- * @version $Revision: 1.5 $
- *
- * <p><b>Revisions:</b><br>
- * <p><b>2001/12/30: billb</b>
- * <ol>
- * <li>made home and bean invokers pluggable
- * </ol>
- */
+* As we remove the one one association between container STACK and invoker we keep
this around
+* IN the future the creation of proxies is a task done on a container basis but the
container
+* as a logical representation, in other words, the container "Entity with RMI/IIOP"
is not a
+* container stack but an association at the invocation level that points to all
metadata for
+* a given container.
+*
+* In other words this is here for legacy reason and to not disrupt the container at
once
+* In particular we declare that we "implement" the container invoker interface when
we are
+* just implementing the Proxy generation calls. Separation of concern.
+*
+* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
+* @version $Revision: 1.6 $
+*
+* <p><b>Revisions:</b><br>
+* <p><b>2001/12/30: billb</b>
+* <ol>
+* <li>made home and bean invokers pluggable
+* </ol>
+*/
public class ProxyFactory
- implements ContainerInvoker
+implements ContainerInvoker
{
// Metadata for the proxies
public EJBMetaData ejbMetaData ;
@@ -66,10 +66,13 @@
protected static Logger log = Logger.getLogger(ProxyFactory.class);
protected EJBHome home;
protected EJBObject statelessObject;
-
+
// The name of the bean being deployed
protected String jndiName;
+ // The objectName hash for the container
+ protected int objectName;
+
// The name of the delegate invoker
protected Invoker homeInvoker;
protected Invoker beanInvoker;
@@ -90,6 +93,14 @@
jndiName = container.getBeanMetaData().getJndiName();
+ // The objectName hashCode
+ ObjectName jmx = new ObjectName("jboss.j2ee:service=EJB,jndiName="+jndiName);
+
+ // We keep the hashCode around for fast creation of proxies
+ objectName = jmx.hashCode();
+
+ Registry.bind(new Integer(objectName), jmx);
+
// Create metadata
/**
@@ -155,7 +166,7 @@
if (log.isDebugEnabled())
log.debug("Proxy Factory for "+jndiName+" initialized");
}
-
+
protected void initInvokers() throws Exception
{
ObjectName oname;
@@ -164,26 +175,28 @@
oname = new ObjectName(container.getBeanMetaData().getHomeInvoker());
homeInvoker = (Invoker)Registry.lookup(oname);
if (homeInvoker == null)
- throw new RuntimeException("homeInvoker is null: " + oname);
+ throw new RuntimeException("homeInvoker is null: " + oname);
oname = new ObjectName(container.getBeanMetaData().getBeanInvoker());
beanInvoker = (Invoker)Registry.lookup(oname);
if (beanInvoker == null)
- throw new RuntimeException("beanInvoker is null: " + oname);
+ throw new RuntimeException("beanInvoker is null: " + oname);
}
-
+
public void start() throws Exception
{
try {
- initInvokers();
+
+ initInvokers();
+
// Create the EJBHome
this.home =
- (EJBHome)Proxy.newProxyInstance(
+ (EJBHome)Proxy.newProxyInstance(
// Class loader pointing to the right classes from deployment
((ContainerInvokerContainer)container).getHomeClass().getClassLoader(),
// The classes we want to implement home and handle
new Class[] { ((ContainerInvokerContainer)container).getHomeClass(),
Class.forName("javax.ejb.Handle")},
// The home proxy as invocation handler
- new HomeProxy(jndiName, homeInvoker, ejbMetaData));
+ new HomeProxy(objectName, jndiName, homeInvoker, ejbMetaData));
// Create stateless session object
// Same instance is used for all objects
@@ -197,7 +210,7 @@
// Interfaces
new Class[] {
((ContainerInvokerContainer)container).getRemoteClass() } ,
// SLSB proxy as invocation handler
- new StatelessSessionProxy(jndiName, beanInvoker)
+ new StatelessSessionProxy(objectName, jndiName, beanInvoker)
);
}
@@ -211,9 +224,10 @@
getEJBHome());
+
if (log.isDebugEnabled())
log.debug("Bound "+container.getBeanMetaData().getEjbName() + " to " +
container.getBeanMetaData().getJndiName());
-
+
} catch (Exception e)
{
throw new ServerException("Could not bind home", e);
@@ -265,7 +279,7 @@
// Interfaces
new Class[] { ((ContainerInvokerContainer)container).getRemoteClass() },
// Proxy as invocation handler
- new StatefulSessionProxy(jndiName, id, beanInvoker));
+ new StatefulSessionProxy(objectName, jndiName, id, beanInvoker));
}
public Object getEntityEJBObject(Object id)
@@ -277,7 +291,7 @@
// Interfaces
new Class[] { ((ContainerInvokerContainer)container).getRemoteClass() },
// Proxy as invocation handler
- new EntityProxy(jndiName, id,beanInvoker));
+ new EntityProxy(objectName, jndiName, id,beanInvoker));
}
public Collection getEntityCollection(Collection ids)
@@ -292,7 +306,7 @@
{
list.add(Proxy.newProxyInstance(((ContainerInvokerContainer)container).getRemoteClass().getClassLoader(),
new Class[] {
((ContainerInvokerContainer)container).getRemoteClass(), ReadAheadBuffer.class },
- new ListEntityProxy(jndiName, beanInvoker, idEnum.next(), list,
listId, i)));
+ new ListEntityProxy(objectName, jndiName, beanInvoker,
idEnum.next(), list, listId, i)));
}
}
else {
@@ -300,14 +314,14 @@
{
list.add(Proxy.newProxyInstance(((ContainerInvokerContainer)container).getRemoteClass().getClassLoader(),
new Class[] {
((ContainerInvokerContainer)container).getRemoteClass() },
- new EntityProxy(jndiName, idEnum.next(), beanInvoker)));
+ new EntityProxy(objectName, jndiName, idEnum.next(),
beanInvoker)));
}
}
return list;
}
protected void rebind(Context ctx, String name, Object val)
- throws NamingException
+ throws NamingException
{
// Bind val to name in ctx, and make sure that all intermediate contexts exist
1.4 +7 -5 jboss/src/main/org/jboss/proxy/ejb/StatefulSessionProxy.java
Index: StatefulSessionProxy.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/proxy/ejb/StatefulSessionProxy.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StatefulSessionProxy.java 2002/01/09 23:23:51 1.3
+++ StatefulSessionProxy.java 2002/02/06 18:27:51 1.4
@@ -30,7 +30,7 @@
* An EJB stateful session bean proxy class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.3 $
+* @version $Revision: 1.4 $
*
* <p><b>2001/11/23: marcf</b>
* <ol>
@@ -69,11 +69,13 @@
* @param optimize True if the proxy will attempt to optimize
* VM-local calls.
*/
- public StatefulSessionProxy(String name,
+ public StatefulSessionProxy(
+ int objectName,
+ String name,
Object cacheID,
Invoker invoker)
{
- super(name,invoker);
+ super(objectName,name,invoker);
id = cacheID;
}
@@ -110,7 +112,7 @@
// Implement local EJB calls
else if (m.equals(GET_HANDLE)) {
- return new StatefulHandleImpl(jndiName,invoker, id);
+ return new StatefulHandleImpl(objectName,jndiName,invoker, id);
}
else if (m.equals(GET_EJB_HOME)) {
@@ -136,7 +138,7 @@
throws Exception
{
Invocation invocation = new Invocation(new HashMap());
- invocation.setContainer(objectName);
+ invocation.setContainer(new Integer(objectName));
invocation.setType("remote");
invocation.setId(id);
invocation.setMethod(m);
1.3 +10 -9 jboss/src/main/org/jboss/proxy/ejb/StatelessSessionProxy.java
Index: StatelessSessionProxy.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/proxy/ejb/StatelessSessionProxy.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StatelessSessionProxy.java 2001/12/31 09:20:05 1.2
+++ StatelessSessionProxy.java 2002/02/06 18:27:51 1.3
@@ -18,7 +18,7 @@
* An EJB stateless session bean proxy class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a>
-* @version $Revision: 1.2 $
+* @version $Revision: 1.3 $
*
* <p><b>2001/11/23: marcf</b>
* <ol>
@@ -31,7 +31,7 @@
// Constants -----------------------------------------------------
/** Serial Version Identifier. */
-// private static final long serialVersionUID = 2327647224051998978L;
+ // private static final long serialVersionUID = 2327647224051998978L;
// Attributes ----------------------------------------------------
@@ -48,10 +48,11 @@
* Construct a <tt>StatelessSessionProxy</tt>.
*
*/
- public StatelessSessionProxy(String jndiName,
+ public StatelessSessionProxy(int objectName,
+ String jndiName,
Invoker invoker)
{
- super(jndiName,invoker);
+ super(objectName, jndiName,invoker);
}
// Public --------------------------------------------------------
@@ -104,19 +105,19 @@
// if the names are equal we are equal
return isIdentical(args[0], jndiName);
}
-
+
// If not taken care of, go on and call the container
else {
return invoke(createInvocation(m, args));
}
}
-
+
public Invocation createInvocation(Method m, Object[] args)
- throws Exception
+ throws Exception
{
Invocation invocation = new Invocation(new HashMap());
-
- invocation.setContainer(objectName);
+
+ invocation.setContainer(new Integer(objectName));
invocation.setType("remote");
invocation.setMethod(m);
invocation.setArguments(args);
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development