User: user57 Date: 02/01/02 20:00:59 Modified: src/main/org/jboss/proxy/ejb GenericProxy.java HomeProxy.java ProxyFactory.java Log: o migrated all components to a new JMX domain name model. jboss.system is now where to core/spine components live. moved all components that were in JBOSS-SYSTEM that did not move into a jboss.* domain into jboss (where the server is now registered). The point was to limit the members of jboss.system to core bits only. o Created org.jboss.system.Server, which does the work of initialization that org.jboss.Main used to do. Main now only parses the command line, sets up basic legecy properties and creates a Server instance. o Moved functionality of Shutdown (component not cl tool) into Server ( which is bound as jboss.system:service=Server) o Moved more Runtime access from Info into Server. Exposed memory info as attributes. o Logging a WARN everywhere that uses System.getProperty("jboss.system.home") as that should go away soon/eventually. o Initialized the invokerMap in the harmi impl to avoid NPE o Made getopt.jar a member of the lib/* dir instead of adding it to the run.jar and shutdown.jars each time. o Minor cosmetic changes along the way. Revision Changes Path 1.2 +87 -110 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.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- GenericProxy.java 2001/12/19 07:20:36 1.1 +++ GenericProxy.java 2002/01/03 04:00:59 1.2 @@ -1,9 +1,10 @@ /* -* 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.io.IOException; @@ -30,43 +31,39 @@ import org.jboss.tm.TransactionPropagationContextFactory; import org.jboss.security.SecurityAssociation; - /** -* Generic Proxy -* -* These proxies are independent of the transportation protocol. Their role is to take -* care of some of the local calls on the client (done in extension like EJB) and to -* delegate the calls to a "delegate invoker". -* -* -* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> -* @version $Revision: 1.1 $ -* -* <p><b>2001/11/19: marcf</b> -* <ol> -* <li>Initial checkin -* </ol> -*/ + * Generic Proxy + * + * These proxies are independent of the transportation protocol. Their role is to take + * care of some of the local calls on the client (done in extension like EJB) and to + * delegate the calls to a "delegate invoker". + * + * + * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> + * @version $Revision: 1.2 $ + * + * <p><b>2001/11/19: marcf</b> + * <ol> + * <li>Initial checkin + * </ol> + */ public abstract class GenericProxy -implements Externalizable, InvocationHandler + implements Externalizable, InvocationHandler { - // Constants ----------------------------------------------------- - - /** Serial Version Identifier. */ - // private static final long serialVersionUID = 1870461898442160570L; - - // Attributes ---------------------------------------------------- - - // Invoker to the delegate + /** Invoker to the delegate */ protected Invoker invoker; - // A proxy is associated with a given container, we identify the container by any object - // in RH 3.0 this is for example a simple MBean identifying the container in the future - // we should give just an abstract key into a metadata container repository in the server + /** + * A proxy is associated with a given container, we identify the container by + * any object in RH 3.0 this is for example a simple MBean identifying the + * container in the future we should give just an abstract key into a metadata + * container repository in the server. + */ protected transient String objectName; + protected String jndiName; - // An empty method parameter list. + /** An empty method parameter list. */ protected static final Object[] EMPTY_ARGS = {}; // Static method references @@ -75,7 +72,7 @@ // Static method references to EJB protected static final Method GET_PRIMARY_KEY, GET_HANDLE, GET_EJB_HOME, IS_IDENTICAL; - //Initialize the static variables + /** Initialize the static variables. */ static { try { @@ -102,59 +99,51 @@ } /** - * Our transaction manager. - * - * When set to a non-null value, this is used for getting the - * transaction to use for optimized local method invocations. - * If <code>null</code>, transactions are not propagated on - * optimized local method invocations. - */ + * Our transaction manager. + * + * When set to a non-null value, this is used for getting the + * transaction to use for optimized local method invocations. + * If <code>null</code>, transactions are not propagated on + * optimized local method invocations. + */ protected static TransactionManager tm = null; - - // Get and set methods - // Transaction manager + /** Transaction manager. */ public static void setTransactionManager(TransactionManager txm) { tm = txm; } - // Constructors -------------------------------------------------- - /** - * A public, no-args constructor for externalization to work. - */ + * A public, no-args constructor for externalization to work. + */ public GenericProxy() { // For externalization to work } /** - * Create a new GenericProxy. - * - * @param container - * @param invoker - */ - protected GenericProxy(String jndiName, Invoker invoker) + * Create a new GenericProxy. + * + * @param container + * @param invoker + */ + protected GenericProxy(final String jndiName, final Invoker invoker) { this.jndiName = jndiName; - - this.objectName = "J2EE:service=EJB,jndiName="+jndiName; - + this.objectName = "jboss.j2ee:service=EJB,jndiName="+jndiName; this.invoker = invoker; } - // Package protected --------------------------------------------- - /** - * Test the identitiy of an <tt>EJBObject</tt>. - * - * @param a <tt>EJBObject</tt>. - * @param b Object to test identity with. - * @return True if objects are identical. - * - * @throws RemoteException Failed to get primary key. - * @throws ClassCastException Not an EJBObject instance. - */ + * Test the identitiy of an <tt>EJBObject</tt>. + * + * @param a <tt>EJBObject</tt>. + * @param b Object to test identity with. + * @return True if objects are identical. + * + * @throws RemoteException Failed to get primary key. + * @throws ClassCastException Not an EJBObject instance. + */ protected Boolean isIdentical(final Object a, final Object b) - throws RemoteException + throws RemoteException { if (a == null) return new Boolean(a==b); final EJBObject ejb = (EJBObject)a; @@ -167,69 +156,57 @@ protected Object getCredential() { return SecurityAssociation.getCredential(); } /** - * Return the transaction associated with the current thread. - * Returns <code>null</code> if the transaction manager was never - * set, or if no transaction is associated with the current thread. - */ - protected Transaction getTransaction() - throws SystemException + * Return the transaction associated with the current thread. + * Returns <code>null</code> if the transaction manager was never + * set, or if no transaction is associated with the current thread. + */ + protected Transaction getTransaction() throws SystemException { return (tm == null) ? null : tm.getTransaction(); } - // Protected ----------------------------------------------------- - protected EJBHome getEJBHome() throws NamingException { - return (EJBHome) new InitialContext().lookup(jndiName); } + /** - * Invoke a method. - * - * The actual optimization happens in the delegate, the responsibility here it set the - * variables on the Invocation - * - */ - protected Object invoke(Invocation invocation) - throws Exception + * Invoke a method. + * + * The actual optimization happens in the delegate, the responsibility here it + * set the variables on the Invocation + * + */ + protected Object invoke(Invocation invocation) throws Exception { - // just delegate return invoker.invoke(invocation); } - /** - * Externalize this instance. - * - * If this instance lives in a different VM than its container - * invoker, the remote interface of the container invoker is - * not externalized. - */ - public void writeExternal(final ObjectOutput out) - throws IOException + * Externalize this instance. + * + * If this instance lives in a different VM than its container + * invoker, the remote interface of the container invoker is + * not externalized. + */ + public void writeExternal(final ObjectOutput out) throws IOException { out.writeUTF(jndiName); out.writeObject(invoker); } /** - * Un-externalize this instance. - * - * If this instance is deserialized in the same VM as its container - * invoker, the remote interface of the container invoker is - * restored by looking up the name in the invokers map. - */ + * Un-externalize this instance. + * + * If this instance is deserialized in the same VM as its container + * invoker, the remote interface of the container invoker is + * restored by looking up the name in the invokers map. + */ public void readExternal(final ObjectInput in) - throws IOException, ClassNotFoundException + throws IOException, ClassNotFoundException { jndiName = in.readUTF(); - objectName = "J2EE:service=EJB,jndiName="+jndiName; + objectName = "jboss.j2ee:service=EJB,jndiName="+jndiName; invoker = (Invoker) in.readObject(); } - - // Private ------------------------------------------------------- - - // Inner classes ------------------------------------------------- } - 1.3 +2 -7 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- HomeProxy.java 2001/12/31 09:20:05 1.2 +++ HomeProxy.java 2002/01/03 04:00:59 1.3 @@ -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.2 $ +* @version $Revision: 1.3 $ * * <p><b>2001/11/21: marcf</b> * <ol> @@ -46,7 +46,7 @@ * </ol> */ public class HomeProxy -extends GenericProxy + extends GenericProxy { // Constants ----------------------------------------------------- @@ -187,21 +187,16 @@ return invoke(invocation); } - // If not taken care of, go on and call the container else { - // Create an Invocation - return invoke(createInvocation(m, args)); } } - public Invocation createInvocation(Method m, Object[] arguments) throws Exception { - Invocation invocation = new Invocation(new HashMap()); invocation.setContainer(objectName); 1.3 +27 -35 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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ProxyFactory.java 2001/12/30 17:12:02 1.2 +++ ProxyFactory.java 2002/01/03 04:00:59 1.3 @@ -1,12 +1,11 @@ /* -* 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; import java.lang.reflect.Proxy; import java.util.ArrayList; @@ -38,10 +37,7 @@ import org.jboss.logging.Logger; - /** - * <description> - * * 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 @@ -52,21 +48,18 @@ * In particular we declare that we "implement" the container invoker interface when we are * just implementing the Proxy generation calls. Separation of concern. * - * @see <related> * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * * <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 ; @@ -84,7 +77,6 @@ // A pointer to the container this proxy factory is dedicated to Container container; - // Container plugin implementation ----------------------------------------- public void setContainer(Container con) @@ -92,8 +84,7 @@ this.container = con; } - public void create() - throws Exception + public void create() throws Exception { Context ctx = new InitialContext(); @@ -165,28 +156,34 @@ log.debug("Proxy Factory for "+jndiName+" initialized"); } - - public void start() - throws Exception + public void start() throws Exception { - try{ - + try { + ObjectName oname; + // Get the local invoker - homeInvoker = (Invoker) Registry.lookup(new ObjectName(container.getBeanMetaData().getHomeInvoker())); - beanInvoker = (Invoker) Registry.lookup(new ObjectName(container.getBeanMetaData().getBeanInvoker())); + oname = new ObjectName(container.getBeanMetaData().getHomeInvoker()); + homeInvoker = (Invoker)Registry.lookup(oname); + if (homeInvoker == null) + 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); + // FIXME FIXME In the near future move to // invoker = (Invoker) Registry.lookup(new ObjectName(container.getInvokerType())); // 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(jndiName, homeInvoker, ejbMetaData)); // Create stateless session object // Same instance is used for all objects @@ -204,8 +201,6 @@ ); } - - // Bind the home in the JNDI naming space rebind( // The context @@ -242,10 +237,8 @@ { } - // Container invoker implementation ------------------------------------- - public EJBMetaData getEJBMetaData() { return ejbMetaData; @@ -300,7 +293,8 @@ new Class[] { ((ContainerInvokerContainer)container).getRemoteClass(), ReadAheadBuffer.class }, new ListEntityProxy(jndiName, beanInvoker, idEnum.next(), list, listId, i))); } - } else { + } + else { while(idEnum.hasNext()) { list.add(Proxy.newProxyInstance(((ContainerInvokerContainer)container).getRemoteClass().getClassLoader(), @@ -312,7 +306,7 @@ } 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 @@ -329,8 +323,6 @@ } n = n.getSuffix(1); } - ctx.rebind(n.get(0), val); } - }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development