Author: pete.muir(a)jboss.org
Date: 2009-12-02 17:07:31 -0500 (Wed, 02 Dec 2009)
New Revision: 5199
Added:
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ProxyCleaner.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/Container.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/CallableMethodHandler.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/LoggerFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/MessageConveyorFactory.java
Log:
Some more explicit cleanup
Modified: core/trunk/impl/src/main/java/org/jboss/weld/Container.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/Container.java 2009-12-02 22:04:00 UTC
(rev 5198)
+++ core/trunk/impl/src/main/java/org/jboss/weld/Container.java 2009-12-02 22:07:31 UTC
(rev 5199)
@@ -25,6 +25,8 @@
import org.jboss.weld.bootstrap.api.Singleton;
import org.jboss.weld.bootstrap.api.SingletonProvider;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.logging.LoggerFactory;
+import org.jboss.weld.logging.MessageConveyorFactory;
/**
* A Weld application container
@@ -102,7 +104,6 @@
{
return instance.isSet() && instance() != null &&
instance().getStatus().isAvailable();
}
-
/**
* Initialize the container for the current application deployment
@@ -155,6 +156,9 @@
deploymentServices.cleanup();
deploymentManager.cleanup();
+ LoggerFactory.cleanup();
+ MessageConveyorFactory.cleanup();
+ instance.clear();
}
/**
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/CallableMethodHandler.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/CallableMethodHandler.java 2009-12-02
22:04:00 UTC (rev 5198)
+++
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/CallableMethodHandler.java 2009-12-02
22:07:31 UTC (rev 5199)
@@ -8,25 +8,57 @@
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.concurrent.Callable;
import javassist.util.proxy.MethodHandler;
+import org.jboss.weld.Container;
import org.jboss.weld.NullInstanceException;
+import org.jboss.weld.bootstrap.api.Service;
import org.slf4j.cal10n.LocLogger;
public class CallableMethodHandler implements MethodHandler, Serializable
{
+ public static class CallableMethodHandlerCleaner implements Service
+ {
+
+ private final Collection<CallableMethodHandler> callableMethodHandlers;
+
+ public CallableMethodHandlerCleaner()
+ {
+ this.callableMethodHandlers = new HashSet<CallableMethodHandler>();
+ }
+
+ private void add(CallableMethodHandler callableMethodHandler)
+ {
+ this.callableMethodHandlers.add(callableMethodHandler);
+ }
+
+ public void cleanup()
+ {
+ for (CallableMethodHandler callableMethodHandler : callableMethodHandlers)
+ {
+ callableMethodHandler.cleanup();
+ }
+ callableMethodHandlers.clear();
+ }
+
+ }
+
private static final long serialVersionUID = -1348302663981663427L;
private static final LocLogger log = loggerFactory().getLogger(BEAN);
- private final Callable<?> callable;
+ // Can't make this final, need to deallocate on shutdown
+ private Callable<?> callable;
public CallableMethodHandler(Callable<?> callable)
{
super();
this.callable = callable;
+
Container.instance().deploymentServices().get(CallableMethodHandlerCleaner.class).add(this);
}
public Object invoke(Object self, Method proxiedMethod, Method proceed, Object[] args)
throws Throwable
@@ -60,5 +92,10 @@
}
}
}
+
+ private void cleanup()
+ {
+ this.callable = null;
+ }
}
Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ProxyCleaner.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ProxyCleaner.java
(rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ProxyCleaner.java 2009-12-02
22:07:31 UTC (rev 5199)
@@ -0,0 +1 @@
+
Property changes on:
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ProxyCleaner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2009-12-02
22:04:00 UTC (rev 5198)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2009-12-02
22:07:31 UTC (rev 5199)
@@ -46,6 +46,7 @@
import org.jboss.weld.Validator;
import org.jboss.weld.Container.Status;
import org.jboss.weld.bean.builtin.BeanManagerBean;
+import org.jboss.weld.bean.builtin.CallableMethodHandler.CallableMethodHandlerCleaner;
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environment;
import org.jboss.weld.bootstrap.api.Lifecycle;
@@ -320,6 +321,7 @@
services.add(MetaAnnotationStore.class, new
MetaAnnotationStore(services.get(ClassTransformer.class)));
services.add(ContextualStore.class, new ContextualStoreImpl());
services.add(ServiceLoaderFactory.class, new DefaultServiceLoaderFactory());
+ services.add(CallableMethodHandlerCleaner.class, new
CallableMethodHandlerCleaner());
return services;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/LoggerFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/LoggerFactory.java 2009-12-02
22:04:00 UTC (rev 5198)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/LoggerFactory.java 2009-12-02
22:07:31 UTC (rev 5199)
@@ -10,8 +10,13 @@
public class LoggerFactory
{
- private static LoggerFactory INSTANCE = new LoggerFactory("WELD");
+ private static LoggerFactory INSTANCE;
+ public static void cleanup()
+ {
+ INSTANCE = null;
+ }
+
private final LocLoggerFactory locLoggerFactory;
private final IMessageConveyor messageConveyor;
@@ -33,6 +38,10 @@
public static LoggerFactory loggerFactory()
{
+ if (INSTANCE == null)
+ {
+ INSTANCE = new LoggerFactory("WELD");
+ }
return INSTANCE;
}
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/logging/MessageConveyorFactory.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/logging/MessageConveyorFactory.java 2009-12-02
22:04:00 UTC (rev 5198)
+++
core/trunk/impl/src/main/java/org/jboss/weld/logging/MessageConveyorFactory.java 2009-12-02
22:07:31 UTC (rev 5199)
@@ -9,7 +9,7 @@
public abstract class MessageConveyorFactory
{
- private static MessageConveyorFactory INSTANCE = load();
+ private static MessageConveyorFactory INSTANCE;
private static MessageConveyorFactory load()
{
@@ -29,9 +29,18 @@
public static MessageConveyorFactory messageConveyerFactory()
{
+ if (INSTANCE == null)
+ {
+ INSTANCE = load();
+ }
return INSTANCE;
}
+ public static void cleanup()
+ {
+ INSTANCE = null;
+ }
+
public static IMessageConveyor defaultMessageConveyer(String subsystem)
{
return messageConveyerFactory().getDefaultMessageConveyer(subsystem);
Show replies by date