Author: rfeng
Date: Wed Oct 31 12:07:50 2007
New Revision: 590789

URL: http://svn.apache.org/viewvc?rev=590789&view=rev
Log:
Apply the patch from Mark for TUSCANY-1883. Thank you, Mark.

Added:
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java
   (with props)
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
Removed:
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingActivator.java
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingsActivator.java
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBTargetInvoker.java
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.extension.helper.BindingActivator
Modified:
    incubator/tuscany/java/sca/modules/binding-ejb/pom.xml
    
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java

Modified: incubator/tuscany/java/sca/modules/binding-ejb/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/pom.xml?rev=590789&r1=590788&r2=590789&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ejb/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/binding-ejb/pom.xml Wed Oct 31 12:07:50 
2007
@@ -31,18 +31,34 @@
     <name>Apache Tuscany SCA EJB Binding Extension</name>
 
     <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-extension-helper</artifactId>
+            <artifactId>tuscany-assembly-xml</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-interface-java</artifactId>
             <version>1.1-incubating-SNAPSHOT</version>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-ejb_3.0_spec</artifactId>
-            <version>1.0</version>
-            <scope>compile</scope>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-spi</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-policy</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
         </dependency>
 
         <dependency>
@@ -51,6 +67,12 @@
             <version>2.1_3</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-ejb_3.0_spec</artifactId>
+            <version>1.0</version>
+            <scope>compile</scope>
+        </dependency>
 
         <dependency>
             <groupId>junit</groupId>
@@ -60,15 +82,15 @@
         </dependency>
 
         <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymock</artifactId>
-            <version>2.2</version>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.1-incubating-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
 
         <dependency>
             <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <artifactId>tuscany-host-embedded</artifactId>
             <version>1.1-incubating-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>

Modified: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java?rev=590789&r1=590788&r2=590789&view=diff
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java
 (original)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java
 Wed Oct 31 12:07:50 2007
@@ -18,85 +18,75 @@
  */
 package org.apache.tuscany.sca.binding.ejb;
 
+import javax.xml.namespace.QName;
 
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.xml.Constants;
 
 /**
  * An implementation of EJBBinding.
  */
-public class EJBBinding {
-
-    /**
-     * corba location For exmaple,
-     * "corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/MyEJBHome"
-     */
-    private String uri;
-
-    /**
-     * homeInterface. remote or local
-     */
-    private String homeInterface;
-
-    /**
-     * The ejb-link-name attribute allows a SCA client to bind to an EJB that 
is
-     * packaged in the same JEE EAR file as the SCA client. This is 
functionally
-     * equivalent to using the <ejb-link/> subelement of the <ejb-ref/> element
-     * in s EJB deployment descriptor. Used only for Service binding
-     */
-    private String ejbLinkName;
+public interface EJBBinding extends Binding, Base {
+    // Contants used when describing the EJB binding
+    // model and for setting up defaults
+    String BINDING_EJB = "binding.ejb";
+    QName BINDING_JMS_QNAME = new QName(Constants.SCA10_NS, BINDING_EJB);
+
+    // Constants for the XML describing the EJB Binding
+    String HOME_INTERFACE = "homeInterface";
+    String EJB_LINK_NAME = "ejb-link-name";
+    String SESSION_TYPE = "session-type";
+    String EJB_VERSION = "ejb-version";
+    String NAME = "name";
+    String POLICY_SETS = "policySets";
+    String REQUIRES = "requires";
+    String URI = "uri";
+
+    // Enums for the EJB Binding
+    enum EJBVersion {
+        EJB2, EJB3
+    };
+
+    enum SessionType {
+        STATEFUL, STATELESS
+    };
 
     /**
      * Gets the homeInterface.
      * 
      * @return home interface of the service binding
      */
-    public String getHomeInterface() {
-        return homeInterface;
-    }
+    String getHomeInterface();
 
     /**
      * Set homeInterface
      * 
      * @param homeInterface
      */
-    public void setHomeInterface(String homeInterface) {
-        this.homeInterface = homeInterface;
-    }
+    void setHomeInterface(String homeInterface);
 
     /**
      * get ejb-link-name
      * 
      * @return ejb-link-name
      */
-    public String getEjbLinkName() {
-        return ejbLinkName;
-    }
+    String getEjbLinkName();
 
     /**
      * Set ejb-link-name
      * 
      * @param ejb-link-name
      */
-    public void setEjbLinkName(String ejbLinkName) {
-        this.ejbLinkName = ejbLinkName;
-    }
+    void setEjbLinkName(String ejbLinkName);
 
-    // TODO: uri needs to be part of runtime extension helper
-    
-    /**
-     * Sets binding URI.
-     * 
-     * @param value the binding uri
-     */
-    public void setUri(String value) {
-        this.uri = value;
-    }
+    SessionType getSessionType();
+    void setSessionType(SessionType sessionType);
 
-    /**
-     * gets binding URI.
-     * 
-     * @return value the binding uri
-     */
-    public String getUri() {
-        return uri;
-    }
+    EJBVersion getEjbVersion();
+    void setEjbVersion(EJBVersion ejbVersion);
+
+    // FIXME: Should use Intent instead of String
+    String getRequires();
+    void setRequires(String requires);
 }

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.tuscany.sca.binding.ejb;
+
+/**
+ * Exception for the EJB Binding
+ */
+public class EJBBindingException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public EJBBindingException() {
+        super();
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public EJBBindingException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public EJBBindingException(String message) {
+        super(message);
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public EJBBindingException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.tuscany.sca.binding.ejb;
+
+/**
+ * Factory for the EJB binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface EJBBindingFactory {
+
+    /**
+     * Creates a new EJB binding.
+     * @return the new EJB binding
+     */
+    EJBBinding createEJBBinding();
+
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,30 @@
+/*
+ * 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.tuscany.sca.binding.ejb.impl;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.binding.ejb.EJBBindingFactory;
+
+public class EJBBindingFactoryImpl implements EJBBindingFactory {
+
+    public EJBBinding createEJBBinding() {
+        return new EJBBindingImpl();
+    }
+
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,172 @@
+/*
+ * 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.tuscany.sca.binding.ejb.impl;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+
+/**
+ * An implementation of EJBBinding.
+ */
+public class EJBBindingImpl implements EJBBinding {
+
+    /**
+     * corba location For exmaple,
+     * "corbaname:iiop:localhost:2809/NameServiceServerRoot#ejb/MyEJBHome"
+     */
+    private String uri;
+
+    /**
+     * homeInterface. remote or local
+     */
+    private String homeInterface;
+
+    /**
+     * The ejb-link-name attribute allows a SCA client to bind to an EJB that 
is
+     * packaged in the same JEE EAR file as the SCA client. This is 
functionally
+     * equivalent to using the <ejb-link/> subelement of the <ejb-ref/> element
+     * in s EJB deployment descriptor. Used only for Service binding
+     */
+    private String ejbLinkName;
+
+    /**
+     * The name of this binding
+     */
+    private String name;
+
+    /**
+     * Whether the binding is unresolved
+     */
+    private boolean unresolved;
+
+    /**
+     * The type of session for this EJB Binding 
+     */
+    private SessionType sessionType;
+
+    /**
+     * The EJB version for this EJB Binding 
+     */
+    private EJBVersion ejbVersion;
+
+    private String requires;
+
+    /**
+     * Constructor
+     */
+    public EJBBindingImpl() {
+        super();
+    }
+
+    /**
+     * Gets the homeInterface.
+     * 
+     * @return home interface of the service binding
+     */
+    public String getHomeInterface() {
+        return homeInterface;
+    }
+
+    /**
+     * Set homeInterface
+     * 
+     * @param homeInterface
+     */
+    public void setHomeInterface(String homeInterface) {
+        this.homeInterface = homeInterface;
+    }
+
+    /**
+     * get ejb-link-name
+     * 
+     * @return ejb-link-name
+     */
+    public String getEjbLinkName() {
+        return ejbLinkName;
+    }
+
+    /**
+     * Set ejb-link-name
+     * 
+     * @param ejb-link-name
+     */
+    public void setEjbLinkName(String ejbLinkName) {
+        this.ejbLinkName = ejbLinkName;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public String getURI() {
+        return uri;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    public boolean isUnresolved() {
+        return this.unresolved;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+        this.unresolved = unresolved;
+    }
+
+    public void setSessionType(SessionType ejb_version_enum) {
+        this.sessionType = ejb_version_enum;
+    }
+
+    public void setEjbVersion(EJBVersion ejb_version_enum) {
+        this.ejbVersion = ejb_version_enum;
+    }
+
+    public void setRequires(String requires) {
+        this.requires = requires;
+
+    }
+
+    public SessionType getSessionType() {
+        return sessionType;
+    }
+
+    public EJBVersion getEjbVersion() {
+        return ejbVersion;
+    }
+
+    public String getRequires() {
+        return requires;
+    }
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,149 @@
+/*
+ * 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.tuscany.sca.binding.ejb.impl;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.xml.Constants;
+import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import 
org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+/**
+ * A processor to read the XML that describes the EJB binding...
+ * 
+ * <binding.ejb
+ *  homeInterface="NCName"?
+ *  ejb-link-name="NCName"?
+ *  session-type="stateful or stateless"?
+ *  ejb-version="EJB2 or EJB3"?
+ *  name="NCName"?
+ *  policySets=" sca:listOfQNames"?
+ *  requires="sca:listOfQNames"?
+ *  uri="anyURI"?
+ * >
+ *
+ *  <!-- additional elements here -->
+ *  
+ * </binding.ejb>
+ */
+public class EJBBindingProcessor implements 
StAXArtifactProcessor<EJBBindingImpl> {
+    private PolicyFactory policyFactory;
+    private PolicyAttachPointProcessor policyProcessor;
+
+    public EJBBindingProcessor(ModelFactoryExtensionPoint modelFactories) {
+        this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+        this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public QName getArtifactType() {
+        return EJBBinding.BINDING_JMS_QNAME;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public EJBBindingImpl read(XMLStreamReader reader) throws 
ContributionReadException, XMLStreamException {
+        EJBBindingImpl ejbBinding = new EJBBindingImpl();
+
+        // Read the policies 
+        policyProcessor.readPolicies(ejbBinding, reader);
+
+        // Read the name
+        String name = reader.getAttributeValue(null, EJBBinding.NAME);
+        if (name != null) {
+            ejbBinding.setName(name);
+        }
+
+        // Read binding URI
+        String uri = reader.getAttributeValue(null, EJBBinding.URI);
+        if (uri != null) {
+            ejbBinding.setURI(uri);
+        }
+
+        String homeInterface = reader.getAttributeValue(null, 
EJBBinding.HOME_INTERFACE);
+        if (homeInterface != null) {
+            ejbBinding.setHomeInterface(homeInterface);
+        }
+
+        String ejbLinkName = reader.getAttributeValue(null, 
EJBBinding.EJB_LINK_NAME);
+        if (ejbLinkName != null) {
+            ejbBinding.setEjbLinkName(ejbLinkName);
+        }
+
+        String sessionType = reader.getAttributeValue(null, 
EJBBinding.SESSION_TYPE);
+        if (sessionType != null) {
+            if (sessionType.equals("stateless")) {
+                ejbBinding.setSessionType(EJBBinding.SessionType.STATELESS);
+            } else if (sessionType.equals("stateful")) {
+                ejbBinding.setSessionType(EJBBinding.SessionType.STATEFUL);
+            } else {
+                throw new ContributionReadException("Unknown EJB Session Type 
of " + sessionType + " for " + name);
+            }
+        }
+
+        String ejbVersion = reader.getAttributeValue(null, 
EJBBinding.EJB_VERSION);
+        if (ejbVersion != null) {
+            if (ejbVersion.equals("EJB2")) {
+                ejbBinding.setEjbVersion(EJBBinding.EJBVersion.EJB2);
+            } else if (ejbVersion.equals("EJB3")) {
+                ejbBinding.setEjbVersion(EJBBinding.EJBVersion.EJB3);
+            } else {
+                throw new ContributionReadException("Unknown EJB Version of " 
+ sessionType + " for " + name);
+            }
+        }
+
+        // TODO: Read requires
+        String requires = reader.getAttributeValue(null, EJBBinding.REQUIRES);
+        if (requires != null) {
+            ejbBinding.setRequires(requires);
+        }
+
+        return ejbBinding;
+    }
+
+    public void write(EJBBindingImpl ejbBinding, XMLStreamWriter writer) 
throws ContributionWriteException,
+        XMLStreamException {
+        // Write a <binding.ejb>
+        writer.writeStartElement(Constants.SCA10_NS, EJBBinding.BINDING_EJB);
+
+        // FIXME Implement
+
+        writer.writeEndElement();
+    }
+
+    public Class<EJBBindingImpl> getModelType() {
+        return EJBBindingImpl.class;
+    }
+
+    public void resolve(EJBBindingImpl ejbBinding, ModelResolver 
modelResolver) throws ContributionResolveException {
+    }
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.tuscany.sca.binding.ejb.provider;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.binding.ejb.util.EJBHandler;
+import org.apache.tuscany.sca.binding.ejb.util.NamingEndpoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * EJBTargetInvoker
+ */
+public class EJBBindingInvoker implements Invoker {
+
+    private Operation operation;
+    private String location;
+    private Class serviceInterface;
+
+    public EJBBindingInvoker(EJBBinding ejbBinding, Class serviceInterface, 
Operation operation) {
+        this.serviceInterface = serviceInterface;
+        this.location = ejbBinding.getURI();
+        this.operation = operation;
+    }
+
+    public Message invoke(Message msg) {
+        try {
+            Object resp = doInvoke(msg.getBody());
+            msg.setBody(resp);
+        } catch (Throwable e) {
+            e.printStackTrace();
+            msg.setFaultBody(e);
+        }
+        return msg;
+    }
+
+    /**
+     * Invoke a EJB operation
+     * 
+     * @param payload
+     * @return
+     */
+    public Object doInvoke(final Object payload) {
+
+        // construct NamingendPoint
+        NamingEndpoint endpoint = getNamingEndpoint();
+
+        // lookup home and ejb stub
+        EJBHandler ejbHandler = new EJBHandler(endpoint, serviceInterface);
+
+        String methodName = operation.getName();
+
+        // invoke business method on ejb
+        Object response = ejbHandler.invoke(methodName, (Object[])payload);
+
+        return response;
+    }
+
+    protected NamingEndpoint getNamingEndpoint() {
+        return new NamingEndpoint(location);
+    }
+
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.tuscany.sca.binding.ejb.provider;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.binding.ejb.EJBBindingException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * A factory from creating the EJB binding provider.
+ */
+public class EJBBindingProviderFactory implements 
BindingProviderFactory<EJBBinding> {
+
+    public EJBBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+    }
+
+    public ReferenceBindingProvider 
createReferenceBindingProvider(RuntimeComponent component,
+                                                                   
RuntimeComponentReference reference,
+                                                                   EJBBinding 
binding) {
+        return new EJBBindingReferenceBindingProvider(component, reference, 
binding);
+    }
+
+    public ServiceBindingProvider 
createServiceBindingProvider(RuntimeComponent component,
+                                                               
RuntimeComponentService service,
+                                                               EJBBinding 
binding) {
+        throw new EJBBindingException("Service Binding not supported for EJB 
Binding");
+    }
+
+    public Class<EJBBinding> getModelType() {
+        return EJBBinding.class;
+    }
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,81 @@
+/*
+ * 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.tuscany.sca.binding.ejb.provider;
+
+import org.apache.tuscany.sca.binding.ejb.EJBBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+public class EJBBindingReferenceBindingProvider implements 
ReferenceBindingProvider {
+    private EJBBinding ejbBinding;
+    private RuntimeComponentReference reference;
+
+    /**
+     * Constructor
+     * 
+     * @param component
+     * @param reference
+     * @param binding
+     */
+    public EJBBindingReferenceBindingProvider(RuntimeComponent component,
+                                              RuntimeComponentReference 
reference,
+                                              EJBBinding binding) {
+        this.reference = reference;
+        this.ejbBinding = binding;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public Invoker createInvoker(Operation operation) {
+        return new EJBBindingInvoker(ejbBinding, 
((JavaInterface)reference.getInterfaceContract().getInterface())
+            .getJavaClass(), operation);
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public InterfaceContract getBindingInterfaceContract() {
+        return reference.getInterfaceContract();
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public void start() {
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public void stop() {
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public boolean supportsOneWayInvocation() {
+        return true;
+    }
+}

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,19 @@
+# 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. 
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.ejb.impl.EJBBindingProcessor;qname=http://www.osoa.org/xmlns/sca/1.0#binding.ejb,model=org.apache.tuscany.sca.binding.ejb.EJBBinding

Added: 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory?rev=590789&view=auto
==============================================================================
--- 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
 (added)
+++ 
incubator/tuscany/java/sca/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
 Wed Oct 31 12:07:50 2007
@@ -0,0 +1,19 @@
+# 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. 
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.ejb.provider.EJBBindingProviderFactory;model=org.apache.tuscany.sca.binding.ejb.EJBBinding



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to