Author: heiko.braun(a)jboss.com
Date: 2007-10-09 09:42:41 -0400 (Tue, 09 Oct 2007)
New Revision: 4708
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/CommonBindingProvider.java
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
Log:
Fix JBWS-1833: ConfigObserver was causing a memory leak
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/CommonBindingProvider.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/CommonBindingProvider.java 2007-10-09
13:11:26 UTC (rev 4707)
+++
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/core/CommonBindingProvider.java 2007-10-09
13:42:41 UTC (rev 4708)
@@ -55,6 +55,7 @@
{
this.epMetaData = epMetaData;
initBinding(epMetaData.getBindingId(), epMetaData.getType());
+ this.epMetaData.registerConfigObserver(this);
configure();
}
Modified:
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2007-10-09
13:11:26 UTC (rev 4707)
+++
legacy/branches/jbossws-1.2.1.GA_CP/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2007-10-09
13:42:41 UTC (rev 4708)
@@ -52,6 +52,8 @@
import java.lang.reflect.Method;
import java.util.*;
+import java.lang.ref.WeakReference;
+
/**
* A Service component describes a set of endpoints.
*
@@ -604,9 +606,6 @@
if (config == null)
initEndpointConfig();
- // register any configurable with the ConfigProvider
- configObservable.addObserver(configurable);
-
// SOAPBinding configuration
if (configurable instanceof CommonBindingProvider)
{
@@ -715,11 +714,51 @@
class ConfigObservable extends Observable
{
+
+ private List<WeakReference<Observer>> observer = new
ArrayList<WeakReference<Observer>>();
+
public void doNotify(Object object)
{
setChanged();
notifyObservers(object);
}
+
+ public synchronized void addObserver(Observer o)
+ {
+ observer.add( new WeakReference(o));
+ }
+
+ public synchronized void deleteObserver(Observer o)
+ {
+ for(WeakReference<Observer> w : observer)
+ {
+ Observer tmp = w.get();
+ if(tmp.equals(o))
+ {
+ observer.remove(o);
+ break;
+ }
+
+ }
+ }
+
+ public void notifyObservers()
+ {
+ notifyObservers(null);
+ }
+
+ public void notifyObservers(Object arg)
+ {
+ if(hasChanged())
+ {
+ for(WeakReference<Observer> w : observer)
+ {
+ Observer tmp = w.get();
+ tmp.update(this, arg);
+
+ }
+ }
+ }
}
public List<UnifiedPortComponentRefMetaData> getServiceRefContrib()