tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r561991 - in /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm: BaseEjbProxyHandler.java EjbHomeProxyHandler.java EjbObjectProxyHandler.java
Date Wed, 01 Aug 2007 23:46:57 GMT
Author: dblevins
Date: Wed Aug  1 16:46:56 2007
New Revision: 561991

URL: http://svn.apache.org/viewvc?view=rev&rev=561991
Log:
Turned two remaining class refs info weak references

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbHomeProxyHandler.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java?view=diff&rev=561991&r1=561990&r2=561991
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/BaseEjbProxyHandler.java
Wed Aug  1 16:46:56 2007
@@ -91,9 +91,9 @@
     protected boolean doIntraVmCopy;
     protected boolean doCrossClassLoaderCopy;
     protected final InterfaceType interfaceType;
-    protected final List<Class> interfaces;
+    private final WeakReference<List<Class>> interfaces;
     private static final boolean REMOTE_COPY_ENABLED = parseRemoteCopySetting();
-    protected final Class mainInterface;
+    private final WeakReference<Class> mainInterface;
 
     public BaseEjbProxyHandler(DeploymentInfo deploymentInfo, Object pk, InterfaceType interfaceType,
List<Class> interfaces) {
         this.container = (RpcContainer) deploymentInfo.getContainer();
@@ -107,7 +107,7 @@
             interfaces = new ArrayList<Class>(deploymentInfo.getInterfaces(objectInterfaceType));
         }
 
-        this.interfaces = Collections.unmodifiableList(interfaces);
+        this.interfaces = new WeakReference(Collections.unmodifiableList(interfaces));
 
         this.doIntraVmCopy = !interfaceType.isLocal();
 
@@ -116,10 +116,10 @@
         }
 
         if (interfaceType.isHome()){
-            mainInterface = deploymentInfo.getInterface(interfaceType);
+            mainInterface = new WeakReference(deploymentInfo.getInterface(interfaceType));
         } else {
             // Then arbitrarily pick the first interface
-            mainInterface = interfaces.get(0);
+            mainInterface = new WeakReference(interfaces.get(0));
         }
     }
 
@@ -135,20 +135,20 @@
         // Home's only have one interface ever.  We don't
         // need to verify that the method invoked is in
         // it's interface.
-        if (interfaceType.isHome()) return mainInterface;
+        if (interfaceType.isHome()) return getMainInterface();
 
         Class declaringClass = method.getDeclaringClass();
 
         // If our "main" interface is or extends the method's declaring class
         // then we're good.  We know the main interface has the method being
         // invoked and it's safe to return it as the invoked interface.
-        if (declaringClass.isAssignableFrom(mainInterface)){
-            return mainInterface;
+        if (declaringClass.isAssignableFrom(getMainInterface())){
+            return getMainInterface();
         }
 
         // If the method being invoked isn't in the "main" interface
         // we need to find a suitable interface or throw an exception.
-        for (Class secondaryInterface : interfaces) {
+        for (Class secondaryInterface : getInterfaces()) {
             if (declaringClass.isAssignableFrom(secondaryInterface)){
                 return secondaryInterface;
             }
@@ -159,6 +159,14 @@
         throw new IllegalStateException("Received method invocation and cannot determine
corresponding business interface: method=" + method);
     }
 
+    public List<Class> getInterfaces() {
+        return interfaces.get();
+    }
+
+    public Class getMainInterface() {
+        return mainInterface.get();
+    }
+    
     private static boolean parseRemoteCopySetting() {
         Properties properties = SystemInstance.get().getProperties();
         String value = properties.getProperty("openejb.localcopy");

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbHomeProxyHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbHomeProxyHandler.java?view=diff&rev=561991&r1=561990&r2=561991
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbHomeProxyHandler.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbHomeProxyHandler.java
Wed Aug  1 16:46:56 2007
@@ -120,17 +120,17 @@
 
             InterfaceType objectInterfaceType = this.interfaceType.getCounterpart();
 
-            EjbObjectProxyHandler handler = newEjbObjectHandler(getDeploymentInfo(), primaryKey,
objectInterfaceType, this.interfaces);
+            EjbObjectProxyHandler handler = newEjbObjectHandler(getDeploymentInfo(), primaryKey,
objectInterfaceType, this.getInterfaces());
 
-            List<Class> proxyInterfaces = new ArrayList<Class>(handler.interfaces.size()
+ 1);
+            List<Class> proxyInterfaces = new ArrayList<Class>(handler.getInterfaces().size()
+ 1);
 
-            proxyInterfaces.addAll(handler.interfaces);
+            proxyInterfaces.addAll(handler.getInterfaces());
             proxyInterfaces.add(IntraVmProxy.class);
 
             return ProxyManager.newProxyInstance(proxyInterfaces.toArray(new Class[]{}),
handler);
 
         } catch (IllegalAccessException iae) {
-            throw new RuntimeException("Could not create IVM proxy for " + interfaces.get(0),
iae);
+            throw new RuntimeException("Could not create IVM proxy for " + getInterfaces().get(0),
iae);
         }
     }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java?view=diff&rev=561991&r1=561990&r2=561991
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/EjbObjectProxyHandler.java
Wed Aug  1 16:46:56 2007
@@ -164,7 +164,7 @@
     }
 
     public org.apache.openejb.ProxyInfo getProxyInfo() {
-        return new org.apache.openejb.ProxyInfo(getDeploymentInfo(), primaryKey, interfaces,
interfaceType);
+        return new org.apache.openejb.ProxyInfo(getDeploymentInfo(), primaryKey, getInterfaces(),
interfaceType);
     }
 
     protected Object _writeReplace(Object proxy) throws ObjectStreamException {



Mime
View raw message