Author: mageshbk(a)jboss.com
Date: 2007-10-24 01:37:43 -0400 (Wed, 24 Oct 2007)
New Revision: 4869
Modified:
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-core/src/java/org/jboss/ws/core/CommonBindingProvider.java
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws626/ServerHandler.java
Log:
[JBWS-1860] Ported JBWS-1833 - ConfigObserver was causing a memory leak
Modified:
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-core/src/java/org/jboss/ws/core/CommonBindingProvider.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-core/src/java/org/jboss/ws/core/CommonBindingProvider.java 2007-10-23
18:19:13 UTC (rev 4868)
+++
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-core/src/java/org/jboss/ws/core/CommonBindingProvider.java 2007-10-24
05:37:43 UTC (rev 4869)
@@ -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_JBWS-1860/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2007-10-23
18:19:13 UTC (rev 4868)
+++
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-core/src/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2007-10-24
05:37:43 UTC (rev 4869)
@@ -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()
Modified:
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws626/ServerHandler.java
===================================================================
---
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws626/ServerHandler.java 2007-10-23
18:19:13 UTC (rev 4868)
+++
legacy/branches/jbossws-1.2.1.GA_JBWS-1860/jbossws-tests/src/java/org/jboss/test/ws/jaxrpc/jbws626/ServerHandler.java 2007-10-24
05:37:43 UTC (rev 4869)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.ws.jaxrpc.jbws626;
+import org.jboss.ws.core.CommonMessageContext;
+
import java.util.Iterator;
import javax.xml.namespace.QName;
@@ -83,6 +85,10 @@
wasName = soapElement.getElementName();
assertElementName(expName, wasName);
}
+
+ // for testing the CommonBindingProvider memory leak. Not related to this
test...
+ ((CommonMessageContext)msgContext).setModified(true);
+
}
catch (SOAPException ex)
{