hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jcar...@apache.org
Subject svn commit: r400333 - in /jakarta/hivemind/branches/branch-1-1: ./ library/src/descriptor/META-INF/ library/src/java/org/apache/hivemind/lib/impl/ library/src/test/org/apache/hivemind/lib/impl/
Date Sat, 06 May 2006 16:45:44 GMT
Author: jcarman
Date: Sat May  6 09:45:42 2006
New Revision: 400333

URL: http://svn.apache.org/viewcvs?rev=400333&view=rev
Log:
Using JDK proxied service in ServicePropertyFactory doesn't work
PR: HIVEMIND-169

Modified:
    jakarta/hivemind/branches/branch-1-1/library/src/descriptor/META-INF/hivemodule.xml
    jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java
    jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactoryParameter.java
    jakarta/hivemind/branches/branch-1-1/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
    jakarta/hivemind/branches/branch-1-1/status.xml

Modified: jakarta/hivemind/branches/branch-1-1/library/src/descriptor/META-INF/hivemodule.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/branch-1-1/library/src/descriptor/META-INF/hivemodule.xml?rev=400333&r1=400332&r2=400333&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-1-1/library/src/descriptor/META-INF/hivemodule.xml (original)
+++ jakarta/hivemind/branches/branch-1-1/library/src/descriptor/META-INF/hivemodule.xml Sat
May  6 09:45:42 2006
@@ -301,7 +301,7 @@
     <parameters-schema>
     <element name="construct">
       
-      <attribute name="service-id" required="true" translator="service">
+      <attribute name="service-id" required="true" translator="service-point">
       
       The service which contains the property.
       
@@ -313,7 +313,7 @@
       </attribute>
       
       <conversion class="impl.ServicePropertyFactoryParameter">
-      <map attribute="service-id" property="service"/>
+      <map attribute="service-id" property="servicePoint"/>
       <map attribute="property" property="propertyName"/>
       </conversion>
       

Modified: jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java?rev=400333&r1=400332&r2=400333&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java
(original)
+++ jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactory.java
Sat May  6 09:45:42 2006
@@ -19,6 +19,7 @@
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.ServiceImplementationFactory;
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
+import org.apache.hivemind.internal.ServicePoint;
 import org.apache.hivemind.service.BodyBuilder;
 import org.apache.hivemind.service.ClassFab;
 import org.apache.hivemind.service.ClassFabUtils;
@@ -46,7 +47,9 @@
         ServicePropertyFactoryParameter p = (ServicePropertyFactoryParameter) factoryParameters
                 .getParameters().get(0);
 
-        Object targetService = p.getService();
+        ServicePoint targetServicePoint = p.getServicePoint();
+        final Class targetServiceInterface = targetServicePoint.getServiceInterface();
+		final Object targetService = targetServicePoint.getService( targetServiceInterface );
         String propertyName = p.getPropertyName();
 
         PropertyAdaptor pa = PropertyUtils.getPropertyAdaptor(targetService, propertyName);
@@ -72,7 +75,7 @@
 
         ClassFab cf = _classFactory.newClass(name, Object.class);
 
-        addInfrastructure(cf, targetService, serviceInterface, propertyName, readMethodName);
+        addInfrastructure(cf, targetService, serviceInterface, targetServiceInterface, propertyName,
readMethodName);
 
         addMethods(
                 cf,
@@ -94,13 +97,13 @@
         }
     }
 
-    private void addInfrastructure(ClassFab cf, Object targetService, Class serviceInterface,
+    private void addInfrastructure(ClassFab cf, Object targetService, Class serviceInterface,
Class targetServiceInterface,
             String propertyName, String readPropertyMethodName)
     {
         cf.addInterface(serviceInterface);
 
-        Class targetServiceClass = ClassFabUtils.getInstanceClass(cf, targetService, serviceInterface);
-
+        Class targetServiceClass = ClassFabUtils.getInstanceClass(cf, targetService, targetServiceInterface);
+        
         cf.addField("_targetService", targetServiceClass);
 
         cf.addConstructor(new Class[]

Modified: jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactoryParameter.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactoryParameter.java?rev=400333&r1=400332&r2=400333&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactoryParameter.java
(original)
+++ jakarta/hivemind/branches/branch-1-1/library/src/java/org/apache/hivemind/lib/impl/ServicePropertyFactoryParameter.java
Sat May  6 09:45:42 2006
@@ -15,6 +15,7 @@
 package org.apache.hivemind.lib.impl;
 
 import org.apache.hivemind.impl.BaseLocatable;
+import org.apache.hivemind.internal.ServicePoint;
 
 /**
  * Parameter object used with {@link ServicePropertyFactory}.
@@ -23,7 +24,7 @@
  */
 public class ServicePropertyFactoryParameter extends BaseLocatable
 {
-    private Object _service;
+    private ServicePoint _servicePoint;
     private String _propertyName;
 
     public String getPropertyName()
@@ -31,9 +32,9 @@
         return _propertyName;
     }
 
-    public Object getService()
+    public ServicePoint getServicePoint()
     {
-        return _service;
+        return _servicePoint;
     }
 
     public void setPropertyName(String string)
@@ -41,9 +42,9 @@
         _propertyName = string;
     }
 
-    public void setService(Object object)
+    public void setServicePoint(ServicePoint servicePoint)
     {
-        _service = object;
+        _servicePoint = servicePoint;
     }
 
 }

Modified: jakarta/hivemind/branches/branch-1-1/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/branch-1-1/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java?rev=400333&r1=400332&r2=400333&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-1-1/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
(original)
+++ jakarta/hivemind/branches/branch-1-1/library/src/test/org/apache/hivemind/lib/impl/TestServicePropertyFactory.java
Sat May  6 09:45:42 2006
@@ -14,6 +14,9 @@
 
 package org.apache.hivemind.lib.impl;
 
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
 import java.util.Collections;
 import java.util.List;
 
@@ -21,6 +24,7 @@
 import org.apache.hivemind.HiveMind;
 import org.apache.hivemind.Registry;
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
+import org.apache.hivemind.internal.ServicePoint;
 import org.apache.hivemind.service.impl.ClassFactoryImpl;
 import org.apache.hivemind.test.HiveMindTestCase;
 import org.easymock.MockControl;
@@ -41,11 +45,18 @@
         return result;
     }
 
-    private List newParameters(Object service, String propertyName)
+    private List newParameters(WonkSource service, String propertyName)
     {
         ServicePropertyFactoryParameter p = new ServicePropertyFactoryParameter();
 
-        p.setService(service);
+        final MockControl spControl = newControl( ServicePoint.class );
+        final ServicePoint sp = ( ServicePoint )spControl.getMock();
+        
+        sp.getServiceInterface();
+        spControl.setReturnValue( WonkSource.class );
+        sp.getService( WonkSource.class );
+        spControl.setReturnValue( service );
+        p.setServicePoint(sp);
         p.setPropertyName(propertyName);
         p.setLocation(newLocation());
 
@@ -92,6 +103,52 @@
         verifyControls();
     }
 
+    public void testWithJdkProxies()
+    {
+    	ServicePropertyFactory f = newFactory();
+
+        MockControl wonkControl = newControl(Wonk.class);
+        final Wonk wonk = (Wonk) wonkControl.getMock();
+
+        MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
+        ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc
+                .getMock();
+        final WonkHolder delegate = new WonkHolder( wonk );
+        final WonkSource jdkProxy = ( WonkSource )Proxy.newProxyInstance( WonkSource.class.getClassLoader(),
new Class[] { WonkSource.class }, new InvocationHandler()
+        		{
+					public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+						return method.invoke( delegate, args );
+					}
+        	  
+        		} );
+        List parameters = newParameters(jdkProxy, "wonk");
+
+        wonk.wonkVoid();
+        wonk.wonkString("zebra");
+        wonkControl.setReturnValue("stripes");
+
+        fp.getParameters();
+        fpc.setReturnValue(parameters);
+
+        fp.getServiceInterface();
+        fpc.setReturnValue(Wonk.class);
+
+        fp.getServiceId();
+        fpc.setReturnValue("foo.bar");
+
+        replayControls();
+
+        Wonk proxy = (Wonk) f.createCoreServiceImplementation(fp);
+
+        proxy.wonkVoid();
+        assertEquals("stripes", proxy.wonkString("zebra"));
+
+        assertEquals(
+                "<ServicePropertyProxy foo.bar(org.apache.hivemind.lib.impl.Wonk) for
property 'wonk' of <WonkHolder>>",
+                proxy.toString());
+
+        verifyControls();
+    }
     public void testPropertyNull()
     {
         MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);

Modified: jakarta/hivemind/branches/branch-1-1/status.xml
URL: http://svn.apache.org/viewcvs/jakarta/hivemind/branches/branch-1-1/status.xml?rev=400333&r1=400332&r2=400333&view=diff
==============================================================================
--- jakarta/hivemind/branches/branch-1-1/status.xml (original)
+++ jakarta/hivemind/branches/branch-1-1/status.xml Sat May  6 09:45:42 2006
@@ -30,6 +30,7 @@
   <changes>
     <release version="1.1.2" date="unreleased">
       <action type="fix" dev="JC" fixes-bug="HIVEMIND-176">HiveMind LoggingInterceptor
incompatible with proxies generated by outside means (CGLIB or Javassist)</action>
+      <action type="fix" dev="JC" fixes-bug="HIVEMIND-169">Using JDK proxied service
in ServicePropertyFactory doesn't work</action>
     </release> 
     <release version="1.1.1" date="Jan 28 2006">
       <action type="fix" dev="HLS" fixes-bug="HIVEMIND-162">Performance bottleneck
with threaded services</action>



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message