User: starksm Date: 02/04/12 12:30:42 Modified: src/main/org/jboss/ejb Container.java ContainerPlugin.java EjbModule.java EntityContainer.java Log: Start cleaning up the web of container references in destroy so that the container may be garbage collected. Revision Changes Path 1.85 +30 -6 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.84 retrieving revision 1.85 diff -u -r1.84 -r1.85 --- Container.java 10 Apr 2002 05:32:58 -0000 1.84 +++ Container.java 12 Apr 2002 19:30:41 -0000 1.85 @@ -82,7 +82,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>. * @author <a href="[EMAIL PROTECTED]">Bill Burke</a> * @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a> -* @version $Revision: 1.84 $ +* @version $Revision: 1.85 $ ** <p><b>Revisions:</b> * * <p><b>2001/07/26 bill burke:</b> @@ -131,7 +131,9 @@ * re-deployable */ protected ClassLoader classLoader; - + /** The class loader for remote dynamic classloading */ + protected ClassLoader webClassLoader; + /** * This is the new metadata. it includes information from both ejb-jar and * jboss.xml the metadata for the application can be accessed trough @@ -399,7 +401,20 @@ { return classLoader; } - + + /** Get the class loader for dynamic class loading via http. + */ + public ClassLoader getWebClassLoader() + { + return webClassLoader; + } + /** Set the class loader for dynamic class loading via http. + */ + public void setWebClassLoader(ClassLoader webClassLoader) + { + this.webClassLoader = webClassLoader; + } + /** * Sets the meta data for this container. The meta data consists of the * properties found in the XML descriptors. @@ -430,9 +445,12 @@ { Set permissions; - if (methodPermissionsCache.containsKey(m)) { + if (methodPermissionsCache.containsKey(m)) + { permissions = (Set) methodPermissionsCache.get( m ); - } else { + } + else + { permissions = getBeanMetaData(). getMethodPermissions(m.getName(), m.getParameterTypes(), !home); methodPermissionsCache.put(m, permissions); @@ -569,8 +587,14 @@ { localContainerInvoker.destroy(); ejbModule.removeLocalHome( this ); + this.classLoader = null; + this.webClassLoader = null; + this.localClassLoader = null; + this.ejbModule = null; + this.lockManager = null; + this.methodPermissionsCache.clear(); } - + /** * This method is called by the ContainerInvoker when a method call comes * in on the Home object. The Container forwards this call to the 1.9 +3 -2 jboss/src/main/org/jboss/ejb/ContainerPlugin.java Index: ContainerPlugin.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/ContainerPlugin.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ContainerPlugin.java 30 Aug 2001 03:10:02 -0000 1.8 +++ ContainerPlugin.java 12 Apr 2002 19:30:41 -0000 1.9 @@ -15,7 +15,7 @@ * * @see Service * @author <a href="mailto:[EMAIL PROTECTED]">Rickard Öberg</a> - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ public interface ContainerPlugin extends Service @@ -23,7 +23,8 @@ /** * This callback is set by the container so that the plugin may access it * - * @param con The container using this plugin. + * @param con The container using this plugin. This may be null if the + plugin is being disassociated from a container. */ void setContainer(Container con); } 1.16 +34 -15 jboss/src/main/org/jboss/ejb/EjbModule.java Index: EjbModule.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/EjbModule.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- EjbModule.java 6 Apr 2002 21:20:43 -0000 1.15 +++ EjbModule.java 12 Apr 2002 19:30:41 -0000 1.16 @@ -78,7 +78,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a> * @author <a href="mailto:[EMAIL PROTECTED]">Francisco Reverbel</a> * @author <a href="mailto:[EMAIL PROTECTED]">Adrian.Brock</a> - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ * * @jmx:mbean extends="org.jboss.system.ServiceMBean" */ @@ -419,29 +419,47 @@ public void destroyService() { + WebServiceMBean webServer = + (WebServiceMBean)MBeanProxy.create(WebServiceMBean.class, + WebServiceMBean.OBJECT_NAME); for (Iterator i = containers.values().iterator(); i.hasNext();) { Container con = (Container)i.next(); + ObjectName jmxName = con.getJmxName(); // Remove JSR-77 EJB-Wrapper - if( con.mEJBObjectName != null ) { + if( con.mEJBObjectName != null ) + { EJB.destroy( con.mbeanServer, con.mEJBObjectName ); } try { - serviceController.destroy(con.getJmxName()); + serviceController.destroy(jmxName); } catch (Throwable e) { - log.error("unexpected exception destroying Container: " + con.getJmxName(), e); + log.error("unexpected exception destroying Container: " + jmxName, e); } // end of try-catch try { - serviceController.remove(con.getJmxName()); + serviceController.remove(jmxName); } catch (Throwable e) { - log.error("unexpected exception destroying Container: " + con.getJmxName(), e); + log.error("unexpected exception destroying Container: " + jmxName, e); } // end of try-catch + // Unregister the web classloader + ClassLoader wcl = con.getWebClassLoader(); + if( wcl != null ) + { + try + { + webServer.removeClassLoader(wcl); + } + catch(Throwable e) + { + log.warn("Failed to unregister webClassLoader", e); + } + } } log.info( "Remove JSR-77 EJB Module: " + getModuleName() ); if (getModuleName() != null) @@ -454,8 +472,11 @@ { ejbModulesByDeploymentInfo.remove(deploymentInfo); } + + this.containers.clear(); + this.localHomes.clear(); } - + // ****************** // Container Creation // ****************** @@ -626,7 +647,7 @@ // Create the container's WebClassLoader // and register it with the web service. String webClassLoaderName = conf.getWebClassLoader(); - WebClassLoader wcl; + WebClassLoader wcl = null; try { Class clazz = cl.loadClass(webClassLoaderName); @@ -646,10 +667,13 @@ WebServiceMBean.OBJECT_NAME); URL[] codebase = { webServer.addClassLoader(wcl) }; wcl.setWebURLs(codebase); + container.setWebClassLoader(wcl); StringBuffer sb = new StringBuffer(); - for (int i = 0; i < codebase.length; i++) { + for (int i = 0; i < codebase.length; i++) + { sb.append(codebase[i].toString()); - if (i < codebase.length - 1) { + if (i < codebase.length - 1) + { sb.append(" "); } } @@ -666,11 +690,6 @@ // Set security domain manager String securityDomain = bean.getApplicationMetaData().getSecurityDomain(); String confSecurityDomain = conf.getSecurityDomain(); - /* These are deprecated. - String securityManagerJNDIName = conf.getAuthenticationModule(); - String roleMappingManagerJNDIName = conf.getRoleMappingManager(); - */ - if( securityDomain != null || confSecurityDomain != null ) { // Either the application has a security domain or the container has security setup try 1.75 +8 -4 jboss/src/main/org/jboss/ejb/EntityContainer.java Index: EntityContainer.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/EntityContainer.java,v retrieving revision 1.74 retrieving revision 1.75 diff -u -r1.74 -r1.75 --- EntityContainer.java 9 Apr 2002 03:48:59 -0000 1.74 +++ EntityContainer.java 12 Apr 2002 19:30:41 -0000 1.75 @@ -61,7 +61,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Daniel OConnor</a> * @author <a href="[EMAIL PROTECTED]">Bill Burke</a> * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a> -* @version $Revision: 1.74 $ +* @version $Revision: 1.75 $ * * <p><b>Revisions:</b> * @@ -435,29 +435,33 @@ try { - // Call default destroy - super.destroy(); - // Destroy container invoker if (containerInvoker != null) containerInvoker.destroy(); // Destroy instance cache instanceCache.destroy(); + instanceCache.setContainer(null); // Destroy persistence persistenceManager.destroy(); + persistenceManager.setContainer(null); // Destroy the pool instancePool.destroy(); + instancePool.setContainer(null); // Destroy all the interceptors in the chain Interceptor in = interceptor; while (in != null) { in.destroy(); + in.setContainer(null); in = in.getNext(); } + + // Call default destroy + super.destroy(); } finally {
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development