User: mnf999 Date: 01/12/18 20:36:19 Modified: src/main/org/jboss/ejb Container.java Log: new invocation layer for the containers Revision Changes Path 1.64 +405 -311 jboss/src/main/org/jboss/ejb/Container.java Index: Container.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/Container.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- Container.java 2001/12/03 03:43:41 1.63 +++ Container.java 2001/12/19 04:36:19 1.64 @@ -1,16 +1,18 @@ /* - * 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.ejb; import java.lang.reflect.Method; +import java.rmi.MarshalledObject; // tmp import java.net.URL; import java.net.MalformedURLException; import java.util.Iterator; +import java.util.Map; import java.util.HashMap; import java.util.Set; @@ -41,6 +43,8 @@ import org.jboss.deployment.DeploymentException; +import org.jboss.invocation.Invocation; +import org.jboss.invocation.MarshalledInvocation; import org.jboss.ejb.BeanLockManager; import org.jboss.logging.Logger; import org.jboss.metadata.BeanMetaData; @@ -56,110 +60,131 @@ import org.jboss.ejb.plugins.local.BaseLocalContainerInvoker; /** - * This is the base class for all EJB-containers in JBoss. A Container - * functions as the central hub of all metadata and plugins. Through this - * the container plugins can get hold of the other plugins and any metadata - * they need. - * - * <p>The ContainerFactory creates instances of subclasses of this class - * and calls the appropriate initialization methods. - * - * <p>A Container does not perform any significant work, but instead delegates - * to the plugins to provide for all kinds of algorithmic functionality. - * - * @see ContainerFactory - * - * @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a> - * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> - * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>. - * @author <a href="[EMAIL PROTECTED]">Bill Burke</a> - * @version $Revision: 1.63 $ - * - * <p><b>Revisions:</b> - * - * <p><b>2001/07/26 bill burke:</b> - * <ul> - * <li> Added BeanLockManager. - * </ul> - * <p><b>2001/08/13 scott.stark:</b> - * <ul> - * <li> Added DynamicMBean support for method invocations and access to EJB interfaces. - * </ul> - */ +* This is the base class for all EJB-containers in JBoss. A Container +* functions as the central hub of all metadata and plugins. Through this +* the container plugins can get hold of the other plugins and any metadata +* they need. +* +* <p>The ContainerFactory creates instances of subclasses of this class +* and calls the appropriate initialization methods. +* +* <p>A Container does not perform any significant work, but instead delegates +* to the plugins to provide for all kinds of algorithmic functionality. +* +* @see ContainerFactory +* +* @author <a href="mailto:[EMAIL PROTECTED]">Rickard �berg</a> +* @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> +* @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>. +* @author <a href="[EMAIL PROTECTED]">Bill Burke</a> +* @version $Revision: 1.64 $ +* +* <p><b>Revisions:</b> +* +* <p><b>2001/07/26 bill burke:</b> +* <ul> +* <li> Added BeanLockManager. +* </ul> +* <p><b>2001/08/13 scott.stark:</b> +* <ul> +* <li> Added DynamicMBean support for method invocations and access to EJB interfaces. +* </ul> +* <p><b>2001/12/18 marc fleury:</b> +* <ul> +* <li> Moved to new Invocation layer and detached invokers. +* <li> Use the method mappings for MarshalledInvocation. +* </ul> +*/ public abstract class Container implements DynamicMBean { // Constants ----------------------------------------------------- - + // Attributes ---------------------------------------------------- - + /** Instance logger. */ protected Logger log = Logger.getLogger(this.getClass()); - + /** This is the application that this container is a part of */ protected Application application; - + /** - * This is the local classloader of this container. Used for loading - * resources that must come from the local jar file for the container. - * NOT for loading classes! - */ + * This is the local classloader of this container. Used for loading + * resources that must come from the local jar file for the container. + * NOT for loading classes! + */ protected ClassLoader localClassLoader; - + /** - * This is the classloader of this container. All classes and resources that - * the bean uses will be loaded from here. By doing this we make the bean - * re-deployable - */ + * This is the classloader of this container. All classes and resources that + * the bean uses will be loaded from here. By doing this we make the bean + * re-deployable + */ protected ClassLoader classLoader; - + /** - * This is the new metadata. it includes information from both ejb-jar and - * jboss.xml the metadata for the application can be accessed trough - * metaData.getApplicationMetaData() - */ + * This is the new metadata. it includes information from both ejb-jar and + * jboss.xml the metadata for the application can be accessed trough + * metaData.getApplicationMetaData() + */ protected BeanMetaData metaData; - + /** This is the EnterpriseBean class */ protected Class beanClass; - + + /** This is the Home interface class */ + protected Class homeInterface; + + /** This is the Remote interface class */ + protected Class remoteInterface; + + /** ??? */ + protected Class localHomeInterface; + + /** ??? */ + protected Class localInterface; + /** This is the TransactionManager */ protected TransactionManager tm; - + /** This is the SecurityManager */ protected AuthenticationManager sm; - + /** This is the realm mapping */ protected RealmMapping rm; - + /** The custom security proxy used by the SecurityInterceptor */ protected Object securityProxy; - + /** This is the bean lock manager that is to be used */ protected BeanLockManager lockManager; - + /** ??? */ protected LocalContainerInvoker localContainerInvoker = - new BaseLocalContainerInvoker(); - + new BaseLocalContainerInvoker(); + /** This is a cache for method permissions */ private HashMap methodPermissionsCache = new HashMap(); - - /** ??? */ - protected Class localHomeInterface; - /** ??? */ - protected Class localInterface; + /** Maps for MarshalledInvocation mapping */ + protected Map marshalledInvocationMapping = new HashMap(); + /** ObjectName of the JSR-77 EJB representation **/ protected String mEJBObjectName; + /** The name of the Remote invoker dedicated to this container, the type is set through deployment**/ + // marcf FIXME: FOR NOW ONLY JRMP (Debugging) but in the future make configurable from xml + // FIXME + protected String invokerType = "JBOSS-SYSTEM:service=invoker,type=jrmp"; + + // We need the visibility on the MBeanServer for prototyping, it will be removed in the future FIXME marcf //protected MBeanServer mbeanServer; public MBeanServer mbeanServer; - + // Public -------------------------------------------------------- - + public Class getLocalClass() { return localInterface; @@ -171,57 +196,62 @@ } /** - * Sets a transaction manager for this container. - * - * @see javax.transaction.TransactionManager - * - * @param tm - */ + * Sets a transaction manager for this container. + * + * @see javax.transaction.TransactionManager + * + * @param tm + */ public void setTransactionManager(TransactionManager tm) { this.tm = tm; } - + /** - * Returns this container's transaction manager. - * - * @return A concrete instance of javax.transaction.TransactionManager - */ + * Returns this container's transaction manager. + * + * @return A concrete instance of javax.transaction.TransactionManager + */ public TransactionManager getTransactionManager() { return tm; } - + public void setSecurityManager(AuthenticationManager sm) { this.sm = sm; } - + + public String getInvokerType() + { + return invokerType; + } + public AuthenticationManager getSecurityManager() { return sm; } - + public BeanLockManager getLockManager() { return lockManager; } - - public void setLockManager(BeanLockManager lockManager) - { - this.lockManager = lockManager; - } - + + public void setLockManager(BeanLockManager lockManager) + { + this.lockManager = lockManager; + } + public void setRealmMapping(RealmMapping rm) { this.rm = rm; } - + public RealmMapping getRealmMapping() { return rm; } - + public void setSecurityProxy(Object proxy) { this.securityProxy = proxy; @@ -235,195 +265,195 @@ { this.mbeanServer = mbeanServer; } - + /** - * Sets the application deployment unit for this container. All the bean - * containers within the same application unit share the same instance. - * - * @param app application for this container - */ + * Sets the application deployment unit for this container. All the bean + * containers within the same application unit share the same instance. + * + * @param app application for this container + */ public void setApplication(Application app) { if (app == null) throw new IllegalArgumentException("Null application"); - + application = app; } - + /** - * Returns the application for this container. - * - * @return - */ + * Returns the application for this container. + * + * @return + */ public Application getApplication() { return application; } - + /** - * Sets the local class loader for this container. - * Used for loading resources from the local jar file for this container. - * NOT for loading classes! - * - * @param cl - */ + * Sets the local class loader for this container. + * Used for loading resources from the local jar file for this container. + * NOT for loading classes! + * + * @param cl + */ public void setLocalClassLoader(ClassLoader cl) { this.localClassLoader = cl; } - + /** - * Returns the local classloader for this container. - * - * @return - */ + * Returns the local classloader for this container. + * + * @return + */ public ClassLoader getLocalClassLoader() { return localClassLoader; } - + /** - * Sets the class loader for this container. All the classes and resources - * used by the bean in this container will use this classloader. - * - * @param cl - */ + * Sets the class loader for this container. All the classes and resources + * used by the bean in this container will use this classloader. + * + * @param cl + */ public void setClassLoader(ClassLoader cl) { this.classLoader = cl; } - + /** - * Returns the classloader for this container. - * - * @return - */ + * Returns the classloader for this container. + * + * @return + */ public ClassLoader getClassLoader() { return classLoader; } - + /** - * Sets the meta data for this container. The meta data consists of the - * properties found in the XML descriptors. - * - * @param metaData - */ + * Sets the meta data for this container. The meta data consists of the + * properties found in the XML descriptors. + * + * @param metaData + */ public void setBeanMetaData(BeanMetaData metaData) { this.metaData = metaData; } - + /** - * Returns the metadata of this container. - * - * @return metaData; - */ + * Returns the metadata of this container. + * + * @return metaData; + */ public BeanMetaData getBeanMetaData() { return metaData; } - + /** - * Returns the permissions for a method. (a set of roles) - * - * @return assemblyDescriptor; - */ + * Returns the permissions for a method. (a set of roles) + * + * @return assemblyDescriptor; + */ public Set getMethodPermissions( Method m, boolean home ) { Set permissions; - + if (methodPermissionsCache.containsKey(m)) { permissions = (Set) methodPermissionsCache.get( m ); } else { permissions = getBeanMetaData(). - getMethodPermissions(m.getName(), m.getParameterTypes(), !home); + getMethodPermissions(m.getName(), m.getParameterTypes(), !home); methodPermissionsCache.put(m, permissions); } return permissions; } - + /** - * Returns the bean class instance of this container. - * - * @return instance of the Enterprise bean class. - */ + * Returns the bean class instance of this container. + * + * @return instance of the Enterprise bean class. + */ public Class getBeanClass() { return beanClass; } - + /** - * Returns a new instance of the bean class or a subclass of the bean class. - * This factory style method is speciffically used by a container to supply - * an implementation of the abstract accessors in EJB2.0, but could be - * usefull in other situations. This method should ALWAYS be used instead - * of getBeanClass().newInstance(); - * - * @return the new instance - * - * @see java.lang.Class#newInstance - */ + * Returns a new instance of the bean class or a subclass of the bean class. + * This factory style method is speciffically used by a container to supply + * an implementation of the abstract accessors in EJB2.0, but could be + * usefull in other situations. This method should ALWAYS be used instead + * of getBeanClass().newInstance(); + * + * @return the new instance + * + * @see java.lang.Class#newInstance + */ public Object createBeanClassInstance() throws Exception { return getBeanClass().newInstance(); } - + /** - * The ContainerFactory calls this method. The ContainerFactory has set - * all the plugins and interceptors that this bean requires and now proceeds - * to initialize the chain. The method looks for the standard classes in - * the URL, sets up the naming environment of the bean. The concrete - * container classes should override this method to introduce - * implementation specific initialization behaviour. - * - * @throws Exception if loading the bean class failed - * (ClassNotFoundException) or setting up "java:" - * naming environment failed (DeploymentException) - */ - public void init() throws Exception + * The ContainerFactory calls this method. The ContainerFactory has set + * all the plugins and interceptors that this bean requires and now proceeds + * to initialize the chain. The method looks for the standard classes in + * the URL, sets up the naming environment of the bean. The concrete + * container classes should override this method to introduce + * implementation specific initialization behaviour. + * + * @throws Exception if loading the bean class failed + * (ClassNotFoundException) or setting up "java:" + * naming environment failed (DeploymentException) + */ + public void create() throws Exception { // Acquire classes from CL beanClass = classLoader.loadClass(metaData.getEjbClass()); - + if (metaData.getLocalHome() != null) localHomeInterface = classLoader.loadClass(metaData.getLocalHome()); if (metaData.getLocal() != null) localInterface = classLoader.loadClass(metaData.getLocal()); localContainerInvoker.setContainer( this ); - localContainerInvoker.init(); + localContainerInvoker.create(); if (localHomeInterface != null) application.addLocalHome(this, localContainerInvoker.getEJBLocalHome() ); // Setup "java:comp/env" namespace setupEnvironment(); } - + /** - * A default implementation of starting the container service. - * The container registers it's dynamic MBean interface in the JMX base. - * FIXME marcf: give some more thought as to where to start and stop MBean registration. - * stop could be a flag in the JMX server that essentially doesn't proxy invocations but the - * MBean would still be registered in the MBeanServer under the right name until undeploy - - * The concrete container classes should override this method to introduce - * implementation specific start behaviour. - * - * @throws Exception An exception that occured during start - */ + * A default implementation of starting the container service. + * The container registers it's dynamic MBean interface in the JMX base. + * FIXME marcf: give some more thought as to where to start and stop MBean registration. + * stop could be a flag in the JMX server that essentially doesn't proxy invocations but the + * MBean would still be registered in the MBeanServer under the right name until undeploy + + * The concrete container classes should override this method to introduce + * implementation specific start behaviour. + * + * @throws Exception An exception that occured during start + */ public void start() - throws Exception + throws Exception { localContainerInvoker.start(); String jndiName = this.getBeanMetaData().getJndiName(); ObjectName jmxName = new ObjectName("J2EE:service=EJB,jndiName="+jndiName); mbeanServer.registerMBean(this, jmxName); } - + /** - * A default implementation of stopping the container service (no-op). The - * concrete container classes should override this method to introduce - * implementation specific stop behaviour. - */ + * A default implementation of stopping the container service (no-op). The + * concrete container classes should override this method to introduce + * implementation specific stop behaviour. + */ public void stop() { localContainerInvoker.stop(); @@ -437,92 +467,92 @@ { } } - + /** - * A default implementation of destroying the container service (no-op). - * The concrete container classes should override this method to introduce - * implementation specific destroy behaviour. - */ + * A default implementation of destroying the container service (no-op). + * The concrete container classes should override this method to introduce + * implementation specific destroy behaviour. + */ public void destroy() { localContainerInvoker.destroy(); application.removeLocalHome( this ); } - + /** - * This method is called by the ContainerInvoker when a method call comes - * in on the Home object. The Container forwards this call to the - * interceptor chain for further processing. - * - * @param mi the object holding all info about this invocation - * @return the result of the home invocation - * - * @throws Exception - */ - public abstract Object invokeHome(MethodInvocation mi) - throws Exception; - + * This method is called by the ContainerInvoker when a method call comes + * in on the Home object. The Container forwards this call to the + * interceptor chain for further processing. + * + * @param mi the object holding all info about this invocation + * @return the result of the home invocation + * + * @throws Exception + */ + public abstract Object invokeHome(Invocation mi) + throws Exception; + /** - * This method is called by the ContainerInvoker when a method call comes - * in on an EJBObject. The Container forwards this call to the interceptor - * chain for further processing. - * - * @param id the id of the object being invoked. May be null - * if stateless - * @param method the method being invoked - * @param args the parameters - * @return the result of the invocation - * - * @throws Exception - */ - public abstract Object invoke(MethodInvocation mi) - throws Exception; - - + * This method is called by the ContainerInvoker when a method call comes + * in on an EJBObject. The Container forwards this call to the interceptor + * chain for further processing. + * + * @param id the id of the object being invoked. May be null + * if stateless + * @param method the method being invoked + * @param args the parameters + * @return the result of the invocation + * + * @throws Exception + */ + public abstract Object invoke(Invocation mi) + throws Exception; + + // DynamicMBean interface implementation ---------------------------------------------- - + public Object getAttribute(String attribute) - throws AttributeNotFoundException, - MBeanException, - ReflectionException + throws AttributeNotFoundException, + MBeanException, + ReflectionException { return null; } public void setAttribute(Attribute attribute) - throws AttributeNotFoundException, - InvalidAttributeValueException, - MBeanException, - ReflectionException + throws AttributeNotFoundException, + InvalidAttributeValueException, + MBeanException, + ReflectionException { } - + public AttributeList getAttributes(String[] attributes) { return null; } - + public AttributeList setAttributes(AttributeList attributes) { return null; } - + /** - * Handle a operation invocation. - */ + * Handle a operation invocation. + */ public Object invoke(String actionName, Object[] params, String[] signature) - throws MBeanException, ReflectionException + throws MBeanException, ReflectionException { - - if( params != null && params.length == 1 && (params[0] instanceof MethodInvocation) == false ) - throw new MBeanException(new IllegalArgumentException("Expected zero or single MethodInvocation argument")); - + + if( params != null && params.length == 1 && (params[0] instanceof Invocation) == false ) + throw new MBeanException(new IllegalArgumentException("Expected zero or single Invocation argument")); + Object value = null; - MethodInvocation mi = null; + Invocation mi = null; if( params != null && params.length == 1 ) - mi = (MethodInvocation) params[0]; - + mi = (Invocation) params[0]; + ClassLoader callerClassLoader = Thread.currentThread().getContextClassLoader(); try { @@ -530,14 +560,78 @@ // Check against home, remote, localHome, local, getHome, getRemote, getLocalHome, getLocal if( actionName.equals("remote") ) { + + if (mi instanceof MarshalledInvocation) + + { + ((MarshalledInvocation) mi).setMethodMap(marshalledInvocationMapping); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + log.info("METHOD REMOTE INVOKE "+mi.getContainer()+"||"+mi.getMethod().getName()+"||"); + + } + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + else if (!mi.getMethod().getDeclaringClass().isAssignableFrom(remoteInterface)) + { + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + log.info("METHOD REMOTE INVOKE "+mi.getContainer()+"||"+mi.getMethod().getName()+"||"); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + log.info("WARNING: YOU ARE RUNNING NON-OPTIMIZED"); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + //Serialize deserialize + mi = (Invocation) new MarshalledObject(new MarshalledInvocation(mi.payload)).get(); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + ((MarshalledInvocation) mi).setMethodMap(marshalledInvocationMapping); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + return new MarshalledObject(invoke(mi)); + } + value = invoke(mi); } + else if( actionName.equals("local") ) { throw new MBeanException(new UnsupportedOperationException("local is not supported yet")); } else if( actionName.equals("home") ) { + + if (mi instanceof MarshalledInvocation) + { + + ((MarshalledInvocation) mi).setMethodMap(marshalledInvocationMapping); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + log.info("METHOD HOME INVOKE "+mi.getContainer()+"||"+mi.getMethod().getName()+"||"+mi.getArguments().toString()); + + } + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + else if (!mi.getMethod().getDeclaringClass().isAssignableFrom(remoteInterface)) + { + + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + log.info("METHOD HOME INVOKE "+mi.getContainer()+"||"+mi.getMethod().getName()+"||"+mi.getArguments().toString()); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + log.info("WARNING: YOU ARE RUNNING NON-OPTIMIZED"); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + //Serialize deserialize + mi = (MarshalledInvocation) new MarshalledObject(new MarshalledInvocation(mi.payload)).get(); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + ((MarshalledInvocation) mi).setMethodMap(marshalledInvocationMapping); + + // FIXME FIXME FIXME FIXME REMOVE WHEN CL ARE INTEGRATED + return new MarshalledObject(invokeHome(mi)); + + } + value = invokeHome(mi); } else if( actionName.equals("localHome") ) @@ -584,26 +678,26 @@ { Thread.currentThread().setContextClassLoader(callerClassLoader); } - + return value; } - + /** - * Build the container MBean information on attributes, contstructors, - * operations, and notifications. Currently there are no attributes, no - * constructors, no notifications, and the following ops: - * <ul> - * <li>'home' -> invokeHome(MethodInvocation);</li> - * <li>'remote' -> invoke(MethodInvocation);</li> - * <li>'localHome' -> not implemented;</li> - * <li>'local' -> not implemented;</li> - * <li>'getHome' -> return EBJHome interface;</li> - * <li>'getRemote' -> return EJBObject interface</li> - * </ul> - */ + * Build the container MBean information on attributes, contstructors, + * operations, and notifications. Currently there are no attributes, no + * constructors, no notifications, and the following ops: + * <ul> + * <li>'home' -> invokeHome(Invocation);</li> + * <li>'remote' -> invoke(Invocation);</li> + * <li>'localHome' -> not implemented;</li> + * <li>'local' -> not implemented;</li> + * <li>'getHome' -> return EBJHome interface;</li> + * <li>'getRemote' -> return EJBObject interface</li> + * </ul> + */ public MBeanInfo getMBeanInfo() { - MBeanParameterInfo miInfo = new MBeanParameterInfo("method", MethodInvocation.class.getName(), "MethodInvocation data"); + MBeanParameterInfo miInfo = new MBeanParameterInfo("method", Invocation.class.getName(), "Invocation data"); MBeanConstructorInfo[] ctorInfo = null; MBeanOperationInfo[] opInfo = { new MBeanOperationInfo("home", "Invoke an EJBHome interface method", @@ -623,24 +717,24 @@ return new MBeanInfo(getClass().getName(), "EJB Container MBean", null, ctorInfo, opInfo, notifyInfo); } - + // End DynamicMBean interface - + // Protected ----------------------------------------------------- - + abstract Interceptor createContainerInterceptor(); public abstract void addInterceptor(Interceptor in); - + // Private ------------------------------------------------------- - + /** - * This method sets up the naming environment of the bean. - * We create the java:comp/env namespace with properties, EJB-References, - * and DataSource ressources. - */ + * This method sets up the naming environment of the bean. + * We create the java:comp/env namespace with properties, EJB-References, + * and DataSource ressources. + */ private void setupEnvironment() - throws DeploymentException + throws DeploymentException { try { @@ -650,7 +744,7 @@ // Since the BCL is already associated with this thread we can start using the java: namespace directly Context ctx = (Context) new InitialContext().lookup("java:comp"); Context envCtx = ctx.createSubcontext("env"); - + // Bind environment properties { Iterator enum = beanMetaData.getEnvironmentEntries(); @@ -669,16 +763,16 @@ } } } - + // Bind EJB references { Iterator enum = beanMetaData.getEjbReferences(); while(enum.hasNext()) { - + EjbRefMetaData ref = (EjbRefMetaData)enum.next(); log.debug("Binding an EJBReference "+ref.getName()); - + if (ref.getLink() != null) { // Internal link @@ -687,7 +781,7 @@ if (refContainer == null) throw new DeploymentException ("Bean "+ref.getLink()+" not found within this application."); bind(envCtx, ref.getName(), new LinkRef(refContainer.getBeanMetaData().getJndiName())); - + // bind(envCtx, ref.getName(), new Reference(ref.getHome(), new StringRefAddr("Container",ref.getLink()), getClass().getName()+".EjbReferenceFactory", null)); // bind(envCtx, ref.getName(), new LinkRef(ref.getLink())); } @@ -703,7 +797,7 @@ } } } - + // Bind Local EJB references { Iterator enum = beanMetaData.getEjbLocalReferences(); @@ -711,10 +805,10 @@ String uniqueKey = Long.toString( (new java.util.Date()).getTime() ); while(enum.hasNext()) { - + EjbLocalRefMetaData ref = (EjbLocalRefMetaData)enum.next(); log.debug("Binding an EJBLocalReference "+ref.getName()); - + if (ref.getLink() != null) { // Internal link @@ -724,12 +818,12 @@ // get local home // bind it into the local namespace LocalHomeObjectFactory.rebind( uniqueKey + ref.getName(), - getApplication(), getApplication().getContainer(ref.getLink()) ); + getApplication(), getApplication().getContainer(ref.getLink()) ); StringRefAddr refAddr = new StringRefAddr("nns", uniqueKey+ref.getName() ); Reference jndiRef = new Reference(ref.getLocalHome(), - refAddr, LocalHomeObjectFactory.class.getName(), null ); + refAddr, LocalHomeObjectFactory.class.getName(), null ); bind(envCtx, ref.getName(), jndiRef ); - + } else { @@ -737,30 +831,30 @@ } } } - + // Bind resource references { Iterator enum = beanMetaData.getResourceReferences(); - + // let's play guess the cast game ;) New metadata should fix this. ApplicationMetaData application = beanMetaData.getApplicationMetaData(); - + while(enum.hasNext()) { ResourceRefMetaData ref = (ResourceRefMetaData)enum.next(); - + String resourceName = ref.getResourceName(); String finalName = application.getResourceByName(resourceName); /* If there was no resource-manager specified then an immeadiate - jndi-name or res-url name should have been given */ + jndi-name or res-url name should have been given */ if (finalName == null) finalName = ref.getJndiName(); - + if (finalName == null) { // the application assembler did not provide a resource manager // if the type is javax.sql.Datasoure use the default one - + if (ref.getType().equals("javax.sql.DataSource")) { // Go through JNDI and look for DataSource - use the first one @@ -775,7 +869,7 @@ log.debug("failed to lookup DefaultDS; ignoring", e); } } - + // Default failed? Warn user and move on // POTENTIALLY DANGEROUS: should this be a critical error? if (finalName == null) @@ -784,7 +878,7 @@ continue; } } - + if (ref.getType().equals("java.net.URL")) { // URL bindings @@ -805,7 +899,7 @@ } } } - + // Bind resource env references { Iterator enum = beanMetaData.getResourceEnvReferences(); @@ -819,10 +913,10 @@ bind(envCtx, encName, new LinkRef(jndiName)); } } - + /* Create a java:comp/env/security/security-domain link to the container - or application security-domain if one exists so that access to the - security manager can be made without knowing the global jndi name. + or application security-domain if one exists so that access to the + security manager can be made without knowing the global jndi name. */ String securityDomain = metaData.getContainerConfiguration().getSecurityDomain(); if( securityDomain == null ) @@ -833,7 +927,7 @@ bind(envCtx, "security/security-domain", new LinkRef(securityDomain)); bind(envCtx, "security/subject", new LinkRef(securityDomain+"/subject")); } - + log.debug("End java:comp/env for EJB: "+beanMetaData.getEjbName()); } catch (NamingException e) { @@ -842,20 +936,20 @@ throw new DeploymentException("Could not set up environment", e); } } - - + + /** - * Bind a value to a name in a JNDI-context, and create any missing - * subcontexts. - * - * @param ctx - * @param name - * @param val - * - * @throws NamingException - */ + * Bind a value to a name in a JNDI-context, and create any missing + * subcontexts. + * + * @param ctx + * @param name + * @param val + * + * @throws NamingException + */ private void bind(Context ctx, String name, Object val) - throws NamingException + throws NamingException { // Bind val to name in ctx, and make sure that all // intermediate contexts exist @@ -872,7 +966,7 @@ } n = n.getSuffix(1); } - + ctx.bind(n.get(0), val); } }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
