geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vamsic...@apache.org
Subject svn commit: r742385 - in /geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany: SCACallbackReference.java TuscanyModuleBuilderExtension.java
Date Mon, 09 Feb 2009 10:54:16 GMT
Author: vamsic007
Date: Mon Feb  9 10:54:15 2009
New Revision: 742385

URL: http://svn.apache.org/viewvc?rev=742385&view=rev
Log:
Support for callback injection in EJBs

Added:
    geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/SCACallbackReference.java
  (with props)
Modified:
    geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java

Added: geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/SCACallbackReference.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/SCACallbackReference.java?rev=742385&view=auto
==============================================================================
--- geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/SCACallbackReference.java
(added)
+++ geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/SCACallbackReference.java
Mon Feb  9 10:54:15 2009
@@ -0,0 +1,60 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.tuscany;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.xbean.naming.reference.SimpleReference;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCACallbackReference extends SimpleReference {
+    private String componentName;
+    
+    public SCACallbackReference(String componentName) {
+        this.componentName = componentName;
+    }
+
+    @Override
+    public Object getContent() throws NamingException {
+        InitialContext ctx = new InitialContext();
+        SCADomain domain = (SCADomain) ctx.lookup("ger:/SCADomain");
+        ComponentContext componentContext = null;
+        for(Component component : ((org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain)domain).getDomainComposite().getComponents())
{
+            if(component.getName().equals(componentName)) {
+                componentContext = ((RuntimeComponent)component).getComponentContext();
+            }
+        }
+        
+        Object callback = null;
+        try {
+            callback = componentContext.getRequestContext().getCallback();
+        } catch(Exception e) {
+            // Happens when there is no callback or the invocation is through non-SCA means
+        }
+        return callback;
+    }
+}

Propchange: geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/SCACallbackReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/SCACallbackReference.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/SCACallbackReference.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java?rev=742385&r1=742384&r2=742385&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java
(original)
+++ geronimo/plugins/tuscany/trunk/geronimo-tuscany/src/main/java/org/apache/geronimo/tuscany/TuscanyModuleBuilderExtension.java
Mon Feb  9 10:54:15 2009
@@ -79,6 +79,7 @@
 import org.apache.tuscany.sca.implementation.ejb.EJBImplementation;
 import org.apache.tuscany.sca.implementation.web.WebImplementation;
 import org.apache.xmlbeans.XmlObject;
+import org.osoa.sca.annotations.Callback;
 import org.osoa.sca.annotations.ComponentName;
 import org.osoa.sca.annotations.Context;
 import org.osoa.sca.annotations.Property;
@@ -567,6 +568,9 @@
                 } else if(field.isAnnotationPresent(Context.class)) {
                     addEJBInjectionPoint(beanInfo, targetName, type);
                     contextMap.put(beanClassName+ "/" +targetName, new SCAContextReference(componentName));
+                } else if(field.isAnnotationPresent(Callback.class)) {
+                    addEJBInjectionPoint(beanInfo, targetName, type);
+                    contextMap.put(beanClassName+ "/" +targetName, new SCACallbackReference(componentName));
                 }
             }
 
@@ -592,6 +596,9 @@
                 } else if(method.isAnnotationPresent(Context.class)) {
                     addEJBInjectionPoint(beanInfo, targetName, type);
                     contextMap.put(beanClassName+ "/" +targetName, new SCAContextReference(componentName));
+                } else if(method.isAnnotationPresent(Callback.class)) {
+                    addEJBInjectionPoint(beanInfo, targetName, type);
+                    contextMap.put(beanClassName+ "/" +targetName, new SCACallbackReference(componentName));
                 }
             }       
         }



Mime
View raw message