servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r513764 - /incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java
Date Fri, 02 Mar 2007 13:55:00 GMT
Author: gnodet
Date: Fri Mar  2 05:54:59 2007
New Revision: 513764

URL: http://svn.apache.org/viewvc?view=rev&rev=513764
Log:
SM-858: The JBIContainer can now be injected on the POJO

Modified:
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java

Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java?view=diff&rev=513764&r1=513763&r2=513764
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java
(original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181Endpoint.java
Fri Mar  2 05:54:59 2007
@@ -19,6 +19,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.HashMap;
@@ -44,6 +45,7 @@
 import org.apache.servicemix.common.ExchangeProcessor;
 import org.apache.servicemix.common.ManagementSupport;
 import org.apache.servicemix.common.tools.wsdl.WSDLFlattener;
+import org.apache.servicemix.jbi.container.JBIContainer;
 import org.apache.servicemix.jsr181.xfire.JbiFaultSerializer;
 import org.apache.servicemix.jsr181.xfire.ServiceFactoryHelper;
 import org.codehaus.xfire.XFire;
@@ -181,7 +183,7 @@
         logger = this.serviceUnit.getComponent().getLogger();
         ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
         activated = ctx.activateEndpoint(service, endpoint);
-        injectContext(new EndpointComponentContext(this));
+        injectPojo(new EndpointComponentContext(this), getContainer());
         processor.start();
     }
 
@@ -194,15 +196,34 @@
         processor.stop();
         ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
         ctx.deactivateEndpoint(ep);
-        injectContext(null);
+        injectPojo(null, null);
     }
 
-    protected void injectContext(ComponentContext context) {
+    protected void injectPojo(ComponentContext context, JBIContainer container) {
         try {
             Method mth = pojo.getClass().getMethod("setContext", new Class[] { ComponentContext.class
});
             mth.invoke(pojo, new Object[] { context });
         } catch (Exception e) {
             logger.debug("Unable to inject ComponentContext: " + e.getMessage());
+        }
+        try {
+            Method mth = pojo.getClass().getMethod("setContainer", new Class[] { JBIContainer.class
});
+            mth.invoke(pojo, new Object[] { container });
+        } catch (Exception e) {
+            logger.debug("Unable to inject JBIContainer: " + e.getMessage());
+        }
+    }
+    
+    protected JBIContainer getContainer() {
+        try {
+            ComponentContext ctx = getServiceUnit().getComponent().getComponentContext();
+            Field field = ctx.getClass().getDeclaredField("container");
+            field.setAccessible(true);
+            JBIContainer container = (JBIContainer) field.get(ctx);
+            return container;
+        } catch (Exception e) {
+            logger.debug("Unable to retrieve JBIContainer: " + e.getMessage());
+            return null;
         }
     }
 



Mime
View raw message