You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2006/02/14 22:11:27 UTC
svn commit: r377833 [2/4] - in /incubator/tuscany/java:
samples/helloworld/helloworld/ samples/helloworld/helloworldmc/ sca/
sca/container.java/src/main/java/org/apache/tuscany/container/java/injection/
sca/container.js/ sca/container.js/src/ sca/conta...
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/DocumentRootImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/DocumentRootImpl.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/DocumentRootImpl.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/DocumentRootImpl.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,302 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.sdo.impl;
+
+import commonj.sdo.Sequence;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.tuscany.container.js.assembly.sdo.DocumentRoot;
+import org.apache.tuscany.container.js.assembly.sdo.JavaScriptAssemblyPackage;
+import org.apache.tuscany.container.js.assembly.sdo.JavaScriptImplementation;
+
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EMap;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl;
+
+import org.eclipse.emf.ecore.sdo.impl.EDataObjectImpl;
+
+import org.eclipse.emf.ecore.sdo.util.BasicESequence;
+import org.eclipse.emf.ecore.sdo.util.ESequence;
+
+import org.eclipse.emf.ecore.util.BasicFeatureMap;
+import org.eclipse.emf.ecore.util.EcoreEMap;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Document Root</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.apache.tuscany.container.js.assembly.sdo.impl.DocumentRootImpl#getMixed <em>Mixed</em>}</li>
+ * <li>{@link org.apache.tuscany.container.js.assembly.sdo.impl.DocumentRootImpl#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}</li>
+ * <li>{@link org.apache.tuscany.container.js.assembly.sdo.impl.DocumentRootImpl#getXSISchemaLocation <em>XSI Schema Location</em>}</li>
+ * <li>{@link org.apache.tuscany.container.js.assembly.sdo.impl.DocumentRootImpl#getImplementationJs <em>Implementation Js</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class DocumentRootImpl extends EDataObjectImpl implements DocumentRoot {
+ /**
+ * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMixed()
+ * @generated
+ * @ordered
+ */
+ protected ESequence mixed = null;
+
+ /**
+ * The cached value of the '{@link #getXMLNSPrefixMap() <em>XMLNS Prefix Map</em>}' map.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getXMLNSPrefixMap()
+ * @generated
+ * @ordered
+ */
+ protected EMap xMLNSPrefixMap = null;
+
+ /**
+ * The cached value of the '{@link #getXSISchemaLocation() <em>XSI Schema Location</em>}' map.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getXSISchemaLocation()
+ * @generated
+ * @ordered
+ */
+ protected EMap xSISchemaLocation = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected DocumentRootImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EClass eStaticClass() {
+ return JavaScriptAssemblyPackage.eINSTANCE.getDocumentRoot();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Sequence getMixed() {
+ if (mixed == null) {
+ mixed = new BasicESequence(new BasicFeatureMap(this, JavaScriptAssemblyPackage.DOCUMENT_ROOT__MIXED));
+ }
+ return mixed;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Map getXMLNSPrefixMap() {
+ if (xMLNSPrefixMap == null) {
+ xMLNSPrefixMap = new EcoreEMap(EcorePackage.eINSTANCE.getEStringToStringMapEntry(), EStringToStringMapEntryImpl.class, this, JavaScriptAssemblyPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
+ }
+ return xMLNSPrefixMap.map();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Map getXSISchemaLocation() {
+ if (xSISchemaLocation == null) {
+ xSISchemaLocation = new EcoreEMap(EcorePackage.eINSTANCE.getEStringToStringMapEntry(), EStringToStringMapEntryImpl.class, this, JavaScriptAssemblyPackage.DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
+ }
+ return xSISchemaLocation.map();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public JavaScriptImplementation getImplementationJs() {
+ return (JavaScriptImplementation)((ESequence)getMixed()).featureMap().get(JavaScriptAssemblyPackage.eINSTANCE.getDocumentRoot_ImplementationJs(), true);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain basicSetImplementationJs(JavaScriptImplementation newImplementationJs, NotificationChain msgs) {
+ return ((FeatureMap.Internal)((ESequence)getMixed()).featureMap()).basicAdd(JavaScriptAssemblyPackage.eINSTANCE.getDocumentRoot_ImplementationJs(), newImplementationJs, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setImplementationJs(JavaScriptImplementation newImplementationJs) {
+ ((FeatureMap.Internal)((ESequence)getMixed()).featureMap()).set(JavaScriptAssemblyPackage.eINSTANCE.getDocumentRoot_ImplementationJs(), newImplementationJs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
+ if (featureID >= 0) {
+ switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__MIXED:
+ return ((InternalEList)((ESequence)getMixed()).featureMap()).basicRemove(otherEnd, msgs);
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
+ return ((InternalEList)((EMap.InternalMapView)getXMLNSPrefixMap()).eMap()).basicRemove(otherEnd, msgs);
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
+ return ((InternalEList)((EMap.InternalMapView)getXSISchemaLocation()).eMap()).basicRemove(otherEnd, msgs);
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__IMPLEMENTATION_JS:
+ return basicSetImplementationJs(null, msgs);
+ default:
+ return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
+ }
+ }
+ return eBasicSetContainer(null, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object eGet(EStructuralFeature eFeature, boolean resolve) {
+ switch (eDerivedStructuralFeatureID(eFeature)) {
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__MIXED:
+ return ((ESequence)getMixed()).featureMap();
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
+ return ((EMap.InternalMapView)getXMLNSPrefixMap()).eMap();
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
+ return ((EMap.InternalMapView)getXSISchemaLocation()).eMap();
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__IMPLEMENTATION_JS:
+ return getImplementationJs();
+ }
+ return eDynamicGet(eFeature, resolve);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eSet(EStructuralFeature eFeature, Object newValue) {
+ switch (eDerivedStructuralFeatureID(eFeature)) {
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__MIXED:
+ ((ESequence)getMixed()).featureMap().clear();
+ ((ESequence)getMixed()).featureMap().addAll((Collection)newValue);
+ return;
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
+ getXMLNSPrefixMap().clear();
+ ((EMap.InternalMapView)getXMLNSPrefixMap()).eMap().addAll((Collection)newValue);
+ return;
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
+ getXSISchemaLocation().clear();
+ ((EMap.InternalMapView)getXSISchemaLocation()).eMap().addAll((Collection)newValue);
+ return;
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__IMPLEMENTATION_JS:
+ setImplementationJs((JavaScriptImplementation)newValue);
+ return;
+ }
+ eDynamicSet(eFeature, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eUnset(EStructuralFeature eFeature) {
+ switch (eDerivedStructuralFeatureID(eFeature)) {
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__MIXED:
+ ((ESequence)getMixed()).featureMap().clear();
+ return;
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
+ getXMLNSPrefixMap().clear();
+ return;
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
+ getXSISchemaLocation().clear();
+ return;
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__IMPLEMENTATION_JS:
+ setImplementationJs((JavaScriptImplementation)null);
+ return;
+ }
+ eDynamicUnset(eFeature);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean eIsSet(EStructuralFeature eFeature) {
+ switch (eDerivedStructuralFeatureID(eFeature)) {
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__MIXED:
+ return mixed != null && !mixed.featureMap().isEmpty();
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP:
+ return xMLNSPrefixMap != null && !xMLNSPrefixMap.isEmpty();
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__XSI_SCHEMA_LOCATION:
+ return xSISchemaLocation != null && !xSISchemaLocation.isEmpty();
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT__IMPLEMENTATION_JS:
+ return getImplementationJs() != null;
+ }
+ return eDynamicIsSet(eFeature);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (mixed: ");
+ result.append(mixed);
+ result.append(')');
+ return result.toString();
+ }
+
+} //DocumentRootImpl
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/DocumentRootImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/DocumentRootImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyFactoryImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyFactoryImpl.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyFactoryImpl.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyFactoryImpl.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,109 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.sdo.impl;
+
+import org.apache.tuscany.container.js.assembly.sdo.*;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class JavaScriptAssemblyFactoryImpl extends EFactoryImpl implements JavaScriptAssemblyFactory {
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public JavaScriptAssemblyFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case JavaScriptAssemblyPackage.DOCUMENT_ROOT: return (EObject)createDocumentRoot();
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION: return (EObject)createJavaScriptImplementation();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DocumentRoot createDocumentRoot() {
+ DocumentRootImpl documentRoot = new DocumentRootImpl();
+ return documentRoot;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public JavaScriptImplementation createJavaScriptImplementationGen() {
+ JavaScriptImplementationImpl javaScriptImplementation = new JavaScriptImplementationImpl();
+ return javaScriptImplementation;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public JavaScriptAssemblyPackage getJavaScriptAssemblyPackage() {
+ return (JavaScriptAssemblyPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ public static JavaScriptAssemblyPackage getPackage() {
+ return JavaScriptAssemblyPackage.eINSTANCE;
+ }
+
+ /**
+ * Custom code
+ */
+
+ private final org.apache.tuscany.container.js.assembly.JavaScriptAssemblyFactory logicalModelFactory = new org.apache.tuscany.container.js.assembly.impl.JavaScriptAssemblyFactoryImpl();
+
+ /**
+ * @see org.apache.tuscany.container.java.assembly.sdo.sdo.JavaAssemblyFactory#createJavaImplementation()
+ */
+ public JavaScriptImplementation createJavaScriptImplementation() {
+ return (JavaScriptImplementation) logicalModelFactory.createJavaScriptImplementation();
+ }
+
+} //JavaScriptAssemblyFactoryImpl
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyFactoryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyFactoryImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyPackageImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyPackageImpl.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyPackageImpl.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyPackageImpl.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,393 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.sdo.impl;
+
+import org.apache.tuscany.container.js.assembly.sdo.DocumentRoot;
+import org.apache.tuscany.container.js.assembly.sdo.JavaScriptAssemblyFactory;
+import org.apache.tuscany.container.js.assembly.sdo.JavaScriptAssemblyPackage;
+import org.apache.tuscany.container.js.assembly.sdo.JavaScriptImplementation;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+
+import org.eclipse.emf.ecore.xml.type.impl.XMLTypePackageImpl;
+
+import org.apache.tuscany.model.assembly.sdo.AssemblyPackage;
+import org.apache.tuscany.model.assembly.sdo.impl.AssemblyPackageImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class JavaScriptAssemblyPackageImpl extends EPackageImpl implements JavaScriptAssemblyPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass documentRootEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass javaScriptImplementationEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see org.apache.tuscany.container.js.assembly.sdo.JavaScriptAssemblyPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private JavaScriptAssemblyPackageImpl() {
+ super(eNS_URI, JavaScriptAssemblyFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this
+ * model, and for any others upon which it depends. Simple
+ * dependencies are satisfied by calling this method on all
+ * dependent packages before doing anything else. This method drives
+ * initialization for interdependent packages directly, in parallel
+ * with this package, itself.
+ * <p>Of this package and its interdependencies, all packages which
+ * have not yet been registered by their URI values are first created
+ * and registered. The packages are then initialized in two steps:
+ * meta-model objects for all of the packages are created before any
+ * are initialized, since one package's meta-model objects may refer to
+ * those of another.
+ * <p>Invocation of this method will not affect any packages that have
+ * already been initialized.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static JavaScriptAssemblyPackage init() {
+ if (isInited) return (JavaScriptAssemblyPackage)EPackage.Registry.INSTANCE.getEPackage(JavaScriptAssemblyPackage.eNS_URI);
+
+ // Obtain or create and register package
+ JavaScriptAssemblyPackageImpl theJavaScriptAssemblyPackage = (JavaScriptAssemblyPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof JavaScriptAssemblyPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new JavaScriptAssemblyPackageImpl());
+
+ isInited = true;
+
+ // Initialize simple dependencies
+ XMLTypePackageImpl.init();
+
+ // Create package meta-data objects
+ theJavaScriptAssemblyPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theJavaScriptAssemblyPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theJavaScriptAssemblyPackage.freeze();
+
+ return theJavaScriptAssemblyPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getDocumentRoot() {
+ return documentRootEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getDocumentRoot_Mixed() {
+ return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getDocumentRoot_XMLNSPrefixMap() {
+ return (EReference)documentRootEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getDocumentRoot_XSISchemaLocation() {
+ return (EReference)documentRootEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getDocumentRoot_ImplementationJs() {
+ return (EReference)documentRootEClass.getEStructuralFeatures().get(3);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getJavaScriptImplementation() {
+ return javaScriptImplementationEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getJavaScriptImplementation_Any() {
+ return (EAttribute)javaScriptImplementationEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getJavaScriptImplementation_ScriptFile() {
+ return (EAttribute)javaScriptImplementationEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getJavaScriptImplementation_AnyAttribute() {
+ return (EAttribute)javaScriptImplementationEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public JavaScriptAssemblyFactory getJavaScriptAssemblyFactory() {
+ return (JavaScriptAssemblyFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create classes and their features
+ documentRootEClass = createEClass(DOCUMENT_ROOT);
+ createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
+ createEReference(documentRootEClass, DOCUMENT_ROOT__IMPLEMENTATION_JS);
+
+ javaScriptImplementationEClass = createEClass(JAVA_SCRIPT_IMPLEMENTATION);
+ createEAttribute(javaScriptImplementationEClass, JAVA_SCRIPT_IMPLEMENTATION__ANY);
+ createEAttribute(javaScriptImplementationEClass, JAVA_SCRIPT_IMPLEMENTATION__SCRIPT_FILE);
+ createEAttribute(javaScriptImplementationEClass, JAVA_SCRIPT_IMPLEMENTATION__ANY_ATTRIBUTE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContentsGen() {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ AssemblyPackageImpl the_0Package = (AssemblyPackageImpl)EPackage.Registry.INSTANCE.getEPackage(AssemblyPackage.eNS_URI);
+ XMLTypePackageImpl theXMLTypePackage = (XMLTypePackageImpl)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI);
+
+ // Add supertypes to classes
+ if (the_0Package!=null)
+ javaScriptImplementationEClass.getESuperTypes().add(the_0Package.getImplementation());
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(documentRootEClass, DocumentRoot.class, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getDocumentRoot_ImplementationJs(), this.getJavaScriptImplementation(), null, "implementationJs", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
+
+ initEClass(javaScriptImplementationEClass, JavaScriptImplementation.class, "JavaScriptImplementation", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getJavaScriptImplementation_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, JavaScriptImplementation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getJavaScriptImplementation_ScriptFile(), theXMLTypePackage.getNCName(), "scriptFile", null, 1, 1, JavaScriptImplementation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getJavaScriptImplementation_AnyAttribute(), ecorePackage.getEFeatureMapEntry(), "anyAttribute", null, 0, -1, JavaScriptImplementation.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ // Create resource
+ createResource(eNS_URI);
+
+ // Create annotations
+ // http:///org/eclipse/emf/ecore/util/ExtendedMetaData
+ createExtendedMetaDataAnnotations();
+ }
+
+ /**
+ * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected void createExtendedMetaDataAnnotations() {
+ String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";
+ addAnnotation
+ (documentRootEClass,
+ source,
+ new String[] {
+ "name", "",
+ "kind", "mixed"
+ });
+ addAnnotation
+ (getDocumentRoot_Mixed(),
+ source,
+ new String[] {
+ "kind", "elementWildcard",
+ "name", ":mixed"
+ });
+ addAnnotation
+ (getDocumentRoot_XMLNSPrefixMap(),
+ source,
+ new String[] {
+ "kind", "attribute",
+ "name", "xmlns:prefix"
+ });
+ addAnnotation
+ (getDocumentRoot_XSISchemaLocation(),
+ source,
+ new String[] {
+ "kind", "attribute",
+ "name", "xsi:schemaLocation"
+ });
+ addAnnotation
+ (getDocumentRoot_ImplementationJs(),
+ source,
+ new String[] {
+ "kind", "element",
+ "name", "implementation.js",
+ "namespace", "##targetNamespace",
+ "affiliation", "http://www.osoa.org/xmlns/sca/0.9#implementation"
+ });
+ addAnnotation
+ (javaScriptImplementationEClass,
+ source,
+ new String[] {
+ "name", "JavaScriptImplementation",
+ "kind", "elementOnly"
+ });
+ addAnnotation
+ (getJavaScriptImplementation_Any(),
+ source,
+ new String[] {
+ "kind", "elementWildcard",
+ "wildcards", "##other",
+ "name", ":0",
+ "processing", "lax"
+ });
+ addAnnotation
+ (getJavaScriptImplementation_ScriptFile(),
+ source,
+ new String[] {
+ "kind", "attribute",
+ "name", "scriptFile"
+ });
+ addAnnotation
+ (getJavaScriptImplementation_AnyAttribute(),
+ source,
+ new String[] {
+ "kind", "attributeWildcard",
+ "wildcards", "##any",
+ "name", ":2",
+ "processing", "lax"
+ });
+ }
+
+ /**
+ * Custom code
+ */
+
+ /**
+ * Initialize the package
+ */
+ public void initializePackageContents() {
+ initializePackageContentsGen();
+ AssemblyPackage.eINSTANCE.merge(this);
+ }
+
+} //JavaScriptAssemblyPackageImpl
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyPackageImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptAssemblyPackageImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptImplementationImpl.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptImplementationImpl.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptImplementationImpl.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptImplementationImpl.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,276 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.sdo.impl;
+
+import commonj.sdo.Sequence;
+
+import java.util.Collection;
+
+import org.apache.tuscany.container.js.assembly.sdo.JavaScriptAssemblyPackage;
+import org.apache.tuscany.container.js.assembly.sdo.JavaScriptImplementation;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+
+import org.eclipse.emf.ecore.sdo.util.BasicESequence;
+import org.eclipse.emf.ecore.sdo.util.ESequence;
+
+import org.eclipse.emf.ecore.util.BasicFeatureMap;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+import org.apache.tuscany.model.assembly.sdo.impl.ImplementationImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Java Script Implementation</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.apache.tuscany.container.js.assembly.sdo.impl.JavaScriptImplementationImpl#getAny <em>Any</em>}</li>
+ * <li>{@link org.apache.tuscany.container.js.assembly.sdo.impl.JavaScriptImplementationImpl#getScriptFile <em>Script File</em>}</li>
+ * <li>{@link org.apache.tuscany.container.js.assembly.sdo.impl.JavaScriptImplementationImpl#getAnyAttribute <em>Any Attribute</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class JavaScriptImplementationImpl extends ImplementationImpl implements JavaScriptImplementation {
+ /**
+ * The cached value of the '{@link #getAny() <em>Any</em>}' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getAny()
+ * @generated
+ * @ordered
+ */
+ protected ESequence any = null;
+
+ /**
+ * The default value of the '{@link #getScriptFile() <em>Script File</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getScriptFile()
+ * @generated
+ * @ordered
+ */
+ protected static final String SCRIPT_FILE_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getScriptFile() <em>Script File</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getScriptFile()
+ * @generated
+ * @ordered
+ */
+ protected String scriptFile = SCRIPT_FILE_EDEFAULT;
+
+ /**
+ * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getAnyAttribute()
+ * @generated
+ * @ordered
+ */
+ protected ESequence anyAttribute = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected JavaScriptImplementationImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EClass eStaticClass() {
+ return JavaScriptAssemblyPackage.eINSTANCE.getJavaScriptImplementation();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Sequence getAny() {
+ if (any == null) {
+ any = new BasicESequence(new BasicFeatureMap(this, JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY));
+ }
+ return any;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getScriptFile() {
+ return scriptFile;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setScriptFile(String newScriptFile) {
+ String oldScriptFile = scriptFile;
+ scriptFile = newScriptFile;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__SCRIPT_FILE, oldScriptFile, scriptFile));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Sequence getAnyAttribute() {
+ if (anyAttribute == null) {
+ anyAttribute = new BasicESequence(new BasicFeatureMap(this, JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY_ATTRIBUTE));
+ }
+ return anyAttribute;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
+ if (featureID >= 0) {
+ switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY:
+ return ((InternalEList)((ESequence)getAny()).featureMap()).basicRemove(otherEnd, msgs);
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY_ATTRIBUTE:
+ return ((InternalEList)((ESequence)getAnyAttribute()).featureMap()).basicRemove(otherEnd, msgs);
+ default:
+ return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
+ }
+ }
+ return eBasicSetContainer(null, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object eGet(EStructuralFeature eFeature, boolean resolve) {
+ switch (eDerivedStructuralFeatureID(eFeature)) {
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY:
+ return ((ESequence)getAny()).featureMap();
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__SCRIPT_FILE:
+ return getScriptFile();
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY_ATTRIBUTE:
+ return ((ESequence)getAnyAttribute()).featureMap();
+ }
+ return eDynamicGet(eFeature, resolve);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eSet(EStructuralFeature eFeature, Object newValue) {
+ switch (eDerivedStructuralFeatureID(eFeature)) {
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY:
+ ((ESequence)getAny()).featureMap().clear();
+ ((ESequence)getAny()).featureMap().addAll((Collection)newValue);
+ return;
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__SCRIPT_FILE:
+ setScriptFile((String)newValue);
+ return;
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY_ATTRIBUTE:
+ ((ESequence)getAnyAttribute()).featureMap().clear();
+ ((ESequence)getAnyAttribute()).featureMap().addAll((Collection)newValue);
+ return;
+ }
+ eDynamicSet(eFeature, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eUnset(EStructuralFeature eFeature) {
+ switch (eDerivedStructuralFeatureID(eFeature)) {
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY:
+ ((ESequence)getAny()).featureMap().clear();
+ return;
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__SCRIPT_FILE:
+ setScriptFile(SCRIPT_FILE_EDEFAULT);
+ return;
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY_ATTRIBUTE:
+ ((ESequence)getAnyAttribute()).featureMap().clear();
+ return;
+ }
+ eDynamicUnset(eFeature);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean eIsSet(EStructuralFeature eFeature) {
+ switch (eDerivedStructuralFeatureID(eFeature)) {
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY:
+ return any != null && !any.featureMap().isEmpty();
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__SCRIPT_FILE:
+ return SCRIPT_FILE_EDEFAULT == null ? scriptFile != null : !SCRIPT_FILE_EDEFAULT.equals(scriptFile);
+ case JavaScriptAssemblyPackage.JAVA_SCRIPT_IMPLEMENTATION__ANY_ATTRIBUTE:
+ return anyAttribute != null && !anyAttribute.featureMap().isEmpty();
+ }
+ return eDynamicIsSet(eFeature);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (any: ");
+ result.append(any);
+ result.append(", scriptFile: ");
+ result.append(scriptFile);
+ result.append(", anyAttribute: ");
+ result.append(anyAttribute);
+ result.append(')');
+ return result.toString();
+ }
+
+} //JavaScriptImplementationImpl
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptImplementationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/assembly/sdo/impl/JavaScriptImplementationImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.builder;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.js.config.JavaScriptComponentRuntimeConfiguration;
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+public class JavaScriptComponentContextBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
+ public JavaScriptComponentContextBuilder() {
+ }
+
+ public void build(AssemblyModelObject modelObject, AggregateContext context) throws BuilderException {
+ if (modelObject instanceof SimpleComponent) {
+ SimpleComponent component = (SimpleComponent) modelObject;
+ ComponentImplementation impl = component.getComponentImplementation();
+ if (impl instanceof JavaScriptImplementation) {
+ JavaScriptComponentRuntimeConfiguration config = new JavaScriptComponentRuntimeConfiguration(component, (JavaScriptImplementation) impl);
+ component.getComponentImplementation().setRuntimeConfiguration(config);
+ }
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/builder/JavaScriptComponentContextBuilder.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.config;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.js.context.JavaScriptComponentContext;
+import org.apache.tuscany.core.builder.ContextCreationException;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+public class JavaScriptComponentRuntimeConfiguration implements RuntimeConfiguration<SimpleComponentContext> {
+
+ private int scope;
+ private SimpleComponent component;
+ private JavaScriptImplementation implementation;
+
+ public JavaScriptComponentRuntimeConfiguration(SimpleComponent component, JavaScriptImplementation implementation) {
+ this.component = component;
+ this.implementation = implementation;
+ this.scope = implementation.getServices().get(0).getInterfaceContract().getScope().getValue();
+ }
+
+ public SimpleComponentContext createInstanceContext() throws ContextCreationException {
+ return new JavaScriptComponentContext(component, implementation);
+ }
+
+ public int getScope() {
+ return scope;
+ }
+
+ public String getName() {
+ return component.getName();
+ }
+
+ private Map<String, ProxyFactory> targetProxyFactories = new HashMap<String, ProxyFactory>();
+
+ public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
+ targetProxyFactories.put(serviceName, factory);
+ }
+
+ public ProxyFactory getTargetProxyFactory(String serviceName) {
+ return targetProxyFactories.get(serviceName);
+ }
+
+ public Map<String, ProxyFactory> getTargetProxyFactories() {
+ return targetProxyFactories;
+ }
+
+ private Map<String, ProxyFactory> sourceProxyFactories = new HashMap<String, ProxyFactory>();
+
+ public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
+ sourceProxyFactories.put(referenceName, factory);
+ }
+
+ public ProxyFactory getSourceProxyFactory(String referenceName) {
+ return sourceProxyFactories.get(referenceName);
+ }
+
+ public Map<String, ProxyFactory> getSourceProxyFactories() {
+ return sourceProxyFactories;
+ }
+
+ public void prepare(){
+
+ }
+
+}
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/config/JavaScriptComponentRuntimeConfiguration.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,144 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.context;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.js.injection.ReferenceProxyTargetFactory;
+import org.apache.tuscany.container.js.rhino.RhinoInvoker;
+import org.apache.tuscany.core.context.AbstractContext;
+import org.apache.tuscany.core.context.CoreRuntimeException;
+import org.apache.tuscany.core.context.LifecycleEventListener;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.SimpleComponentContext;
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.model.assembly.ConfiguredProperty;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+
+public class JavaScriptComponentContext extends AbstractContext implements
+ SimpleComponentContext {
+
+ private SimpleComponent component;
+ private JavaScriptImplementation implementation;
+
+ public JavaScriptComponentContext(SimpleComponent component,
+ JavaScriptImplementation implementation) {
+ super(component.getName());
+ this.component = component;
+ this.implementation = implementation;
+ }
+
+ public Object getInstance(QualifiedName qName) throws TargetException {
+ return getInstance(qName, true);
+ }
+
+ public synchronized Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
+ //TODO: should this cache the instance?
+ ConfiguredService service = component.getConfiguredServices().get(0);
+ String iface = service.getPort().getInterfaceContract().getInterface();
+ Class[] ifaces;
+ try {
+ ifaces = new Class[] { implementation.getResourceLoader().loadClass(iface) };
+ } catch (ClassNotFoundException e) {
+ throw new TargetException(qName.getPartName() + ": ClassNotFoundException creating interface: " + iface);
+ }
+ Object proxy = createProxy(ifaces);
+
+ notifyListeners(notify);
+
+ return proxy;
+ }
+
+ private Object createProxy(Class[] ifaces) {
+
+ final RhinoInvoker rhinoInvoker = implementation.getRhinoInvoker().copy();
+ rhinoInvoker.updateScriptScope(createPropertyValues());
+
+ InvocationHandler ih = new InvocationHandler() {
+ public Object invoke(Object proxy, Method method, Object[] args) {
+ return rhinoInvoker.invoke(method.getName(), args, method.getReturnType(), createInvocationContext());
+ }
+ };
+
+ Object proxy = Proxy.newProxyInstance(ifaces[0].getClassLoader(), ifaces, ih);
+
+ return proxy;
+ }
+
+ private void notifyListeners(boolean notify) {
+ if (notify) {
+ for (Iterator iter = contextListener.iterator(); iter.hasNext();) {
+ LifecycleEventListener listener = (LifecycleEventListener) iter.next();
+ listener.onInstanceCreate(this);
+ }
+ }
+ }
+
+ /**
+ * Creates a map containing any properties and their values
+ */
+ private Map createPropertyValues() {
+ Map<String,Object> context = new HashMap<String,Object>();
+ List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
+ if (configuredProperties != null) {
+ for (ConfiguredProperty property : configuredProperties) {
+ context.put(property.getProperty().getName(), property.getValue());
+ }
+ }
+ return context;
+ }
+
+ /**
+ * Creates a map containing any ServiceReferences
+ */
+ private Map createInvocationContext() {
+ Map<String,Object> context = new HashMap<String,Object>();
+ List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
+ if (configuredReferences != null) {
+ for (ConfiguredReference reference : configuredReferences) {
+ ReferenceProxyTargetFactory rptf = new ReferenceProxyTargetFactory(reference);
+ String refName = reference.getReference().getName();
+ context.put(refName, rptf.getInstance());
+ }
+ }
+ return context;
+ }
+
+ public boolean isEagerInit() {
+ return false;
+ }
+
+ public boolean isDestroyable() {
+ return false;
+ }
+
+ public void start() throws CoreRuntimeException {
+ }
+
+ public void stop() throws CoreRuntimeException {
+ }
+
+}
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/context/JavaScriptComponentContext.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/AbstractJavaScriptComponentInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/AbstractJavaScriptComponentInvoker.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/AbstractJavaScriptComponentInvoker.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/AbstractJavaScriptComponentInvoker.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,73 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.handler;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.context.TargetException;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationRuntimeException;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * Base class for dispatching to a Java based component implementation. Subclasses implement a strategy for resolving
+ * implementation instances.
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 18:54:38 +0000 (Fri, 13 Jan 2006) $
+ */
+public abstract class AbstractJavaScriptComponentInvoker implements TargetInvoker, Interceptor {
+
+ protected Method operation;
+
+ public AbstractJavaScriptComponentInvoker(Method operation) {
+ assert (operation != null) : "Operation method cannot be null";
+ this.operation = operation;
+ }
+
+ public Object invokeTarget(Object payload) throws InvocationTargetException {
+ try {
+ if (payload != null && !payload.getClass().isArray()) {
+ return operation.invoke(getInstance(), payload);
+ } else {
+ return operation.invoke(getInstance(), (Object[]) payload);
+ }
+ } catch (IllegalAccessException e) {
+ throw new InvocationRuntimeException(e);
+ }
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = invokeTarget(msg.getPayload());
+ msg.setPayload(resp);
+ } catch (InvocationTargetException e) {
+ msg.setPayload(e.getCause());
+ } catch (Throwable e) {
+ msg.setPayload(e);
+ }
+ return msg;
+ }
+
+ protected abstract Object getInstance() throws TargetException;
+
+ public void setNext(Interceptor next) {
+ throw new IllegalStateException("This interceptor must be the last interceptor in an interceptor chain");
+ }
+
+}
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/AbstractJavaScriptComponentInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/AbstractJavaScriptComponentInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.handler;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.core.addressing.EndpointReference;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.ProxyConfiguration;
+import org.apache.tuscany.core.invocation.TargetInvoker;
+import org.apache.tuscany.core.message.Message;
+import org.apache.tuscany.core.message.handler.MessageHandler;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.ConfiguredPort;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Interface;
+import org.apache.tuscany.model.assembly.Part;
+import org.apache.tuscany.model.assembly.ScopeEnum;
+import org.apache.tuscany.model.types.InterfaceType;
+import org.apache.tuscany.model.types.OperationType;
+import org.apache.tuscany.model.types.java.JavaOperationType;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+
+public class JavaScriptComponentConfigurationHandler extends AdapterImpl implements MessageHandler {
+
+ public JavaScriptComponentConfigurationHandler() {
+ }
+
+ public boolean processMessage(Message message) {
+
+ // Get the endpoint reference of the target service and the service model element
+ EndpointReference endpointReference = message.getEndpointReference();
+ ConfiguredPort portEndpoint = endpointReference.getConfiguredPort();
+
+ // Return immediately if the target is not a service
+ if (!(portEndpoint instanceof ConfiguredService))
+ return true;
+
+ ConfiguredService serviceEndpoint = (ConfiguredService) portEndpoint;
+ Part part = serviceEndpoint.getPart();
+ if (!(part instanceof Component))
+ return true;
+ Component component = (Component) part;
+
+ // Return immediately if the target is not a JavaScript component
+ ComponentImplementation implementation = component.getComponentImplementation();
+ if (!(implementation instanceof JavaScriptImplementation))
+ return true;
+
+ setInvocationConfigurations(message, serviceEndpoint);
+
+ return false;
+ }
+
+ private void setInvocationConfigurations(Message message, ConfiguredService serviceEndpoint) {
+ ProxyConfiguration proxyConfiguration=(ProxyConfiguration)message.getBody();
+ Map<OperationType, InvocationConfiguration>invocationConfigurations=proxyConfiguration.getInvocationConfigurations();
+ Map<Integer,ScopeContext> scopeContainers = proxyConfiguration.getScopeContainers();
+
+ Interface targetInterface = serviceEndpoint.getService().getInterfaceContract();
+ InterfaceType targetInterfaceType = targetInterface.getInterfaceType();
+ ScopeEnum scope = targetInterface.getScope();
+ String serviceAddress = serviceEndpoint.getPart().getName();
+
+ for (InvocationConfiguration invocationConfiguration : invocationConfigurations.values()) {
+ OperationType targetOperationType=targetInterfaceType.getOperationType(invocationConfiguration.getOperationType().getName());
+ Method method = ((JavaOperationType) targetOperationType).getJavaMethod();
+ TargetInvoker invoker = new ScopedJavaScriptComponentInvoker(serviceAddress, method, scopeContainers.get(scope.getValue()));
+ invocationConfiguration.setTargetInvoker(invoker);
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/JavaScriptComponentConfigurationHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/ScopedJavaScriptComponentInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/ScopedJavaScriptComponentInvoker.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/ScopedJavaScriptComponentInvoker.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/ScopedJavaScriptComponentInvoker.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,49 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.handler;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.ScopeContext;
+import org.apache.tuscany.core.context.TargetException;
+
+/**
+ * Uses a scope container to resolve an implementation instance based on the current thread context
+ */
+public class ScopedJavaScriptComponentInvoker extends AbstractJavaScriptComponentInvoker {
+
+ private ScopeContext container;
+ private QualifiedName name;
+
+ public ScopedJavaScriptComponentInvoker(String serviceName, Method operation, ScopeContext container) {
+ super(operation);
+ assert (serviceName != null) : "No service name specified";
+ assert (container != null) : "No scope container specified";
+ name = new QualifiedName(serviceName);
+ this.container = container;
+ }
+
+ protected Object getInstance() throws TargetException {
+ return container.getInstance(name);
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/ScopedJavaScriptComponentInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/handler/ScopedJavaScriptComponentInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/injection/ReferenceProxyTargetFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/injection/ReferenceProxyTargetFactory.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/injection/ReferenceProxyTargetFactory.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/injection/ReferenceProxyTargetFactory.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,62 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.injection;
+
+import org.apache.tuscany.core.injection.FactoryInitException;
+import org.apache.tuscany.core.injection.ObjectCreationException;
+import org.apache.tuscany.core.injection.ObjectFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyCreationException;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+
+/**
+ * Returns a service component reference target for injection onto a component implementation instance. The target may be a proxy or an actual
+ * component implementation instance.
+ */
+public class ReferenceProxyTargetFactory<T> implements ObjectFactory<T> {
+
+ // the proxy factory for the reference
+ private ProxyFactory<T> factory;
+
+ // ----------------------------------
+ // Constructors
+ // ----------------------------------
+
+ public ReferenceProxyTargetFactory(ConfiguredReference reference) throws FactoryInitException {
+ // FIXME how to handle a reference that is a list - may take different proxy factories for each entry
+ assert (reference != null) : "Reference was null";
+
+ // FIXME should not need the cast to ProxyFactory
+ factory = (ProxyFactory) reference.getProxyFactory();
+ if (factory == null) {
+ throw new FactoryInitException("No proxy factory found");
+ }
+ }
+
+ // ----------------------------------
+ // Methods
+ // ----------------------------------
+
+ public T getInstance() throws ObjectCreationException {
+ try {
+ return factory.createProxy();
+ } catch (ProxyCreationException e) {
+ throw new ObjectCreationException(e);
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/injection/ReferenceProxyTargetFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/injection/ReferenceProxyTargetFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoInvoker.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoInvoker.java?rev=377833&view=auto
==============================================================================
--- incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoInvoker.java (added)
+++ incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoInvoker.java Tue Feb 14 13:11:19 2006
@@ -0,0 +1,316 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.rhino;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.Script;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.Wrapper;
+
+/**
+ * RhinoInvoker simplifies invoking JavaScript functions with Rhino.
+ */
+public class RhinoInvoker {
+
+ private String scriptName;
+
+ private String script;
+
+ private Scriptable scriptScope;
+
+ private Scriptable sharedScope;
+
+ /*
+ * Enable dynamic scopes so a script can be used concurrently with a global shared scope and individual execution scopes. See
+ * http://www.mozilla.org/rhino/scopes.html TODO: need to review how ths fits in with Tuscany scopes
+ */
+ private static class MyFactory extends ContextFactory {
+ protected boolean hasFeature(Context cx, int featureIndex) {
+ if (featureIndex == Context.FEATURE_DYNAMIC_SCOPE) {
+ return true;
+ }
+ return super.hasFeature(cx, featureIndex);
+ }
+ }
+
+ static {
+ ContextFactory.initGlobal(new MyFactory());
+ }
+
+ /**
+ * Create a new RhinoInvoker.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ */
+ public RhinoInvoker(String scriptName, String script) {
+ this(scriptName, script, (Map) null);
+ }
+
+ /**
+ * Create a new RhinoInvoker.
+ *
+ * @param scriptName
+ * the name of the script. Can be anything, only used in messages to identify the script
+ * @param script
+ * the complete script
+ * @param context
+ * name-value pairs that are added in to the scope where the script is compiled. May be null. The value objects are made available to
+ * the script by using a variable with the name.
+ */
+ public RhinoInvoker(String scriptName, String script, Map context) {
+ this.scriptName = scriptName;
+ this.script = script;
+ initScriptScope(scriptName, script, context);
+ initSharedScope();
+ }
+
+ /**
+ * Construct a RhinoInvoker from another RhinoInvoker object. This uses the original script scope so the script doesn't need to be recompiled.
+ */
+ protected RhinoInvoker(String scriptName, String script, Scriptable scriptScope) {
+ this.scriptName = scriptName;
+ this.script = script;
+ this.scriptScope = scriptScope;
+ initSharedScope();
+ }
+
+ /**
+ * Invoke a script function
+ *
+ * @param functionName
+ * the name of the function to invoke.
+ * @param arg
+ * arguments to the function, may be a single object or an array of objects.
+ * @return the function return value.
+ */
+ public Object invoke(String functionName, Object args) {
+ return invoke(functionName, args, null, null);
+ }
+
+ /**
+ * Invoke a script function
+ *
+ * @param functionName
+ * the name of the function to invoke.
+ * @param arg
+ * arguments to the function, may be a single object or an array of objects.
+ * @param contexts
+ * a Map of name-value pairs which are added to the invocation Scope to enable the script to access the values by using the variable in
+ * name.
+ * @return the function return value.
+ */
+ public Object invoke(String functionName, Object args, Map contexts) {
+ return invoke(functionName, args, null, contexts);
+ }
+
+ /**
+ * Invoke a script function
+ *
+ * @param functionName
+ * the name of the function to invoke.
+ * @param arg
+ * arguments to the function, may be a single object or an array of objects.
+ * @param responseClass
+ * the desired class of the response object.
+ * @param contexts
+ * a Map of name-value pairs which are added to the invocation Scope to enable the script to access the values by using the variable in
+ * name.
+ * @return the function return value.
+ */
+ public Object invoke(String functionName, Object arg, Class responseClass, Map contexts) {
+
+ Context cx = Context.enter();
+ try {
+
+ Function function = getFunction(scriptScope, functionName);
+ Scriptable invocationScope = getInvocationScope(cx, contexts);
+
+ Object[] args = processArgs(arg, invocationScope);
+
+ Object jsResponse = function.call(cx, invocationScope, invocationScope, args);
+
+ Object response = processResponse(jsResponse, responseClass);
+
+ return response;
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Turn args to JS objects and convert any OMElement to E4X XML
+ */
+ protected Object[] processArgs(Object arg, Scriptable scope) {
+ // TODO: implement pluggable way to transform objects (eg SDO or AXIOM) to E4X XML objects
+ // if (arg instanceof OMElement) {
+ // try {
+ // arg = E4XAXIOMUtils.toScriptableObject((OMElement) arg, scope);
+ // } catch (XmlException e) {
+ // throw new RuntimeException(e);
+ // }
+ // } else if (arg instanceof MessageContext) {
+ // arg = new E4XMessageContext((MessageContext) arg, scope);
+ // }
+ Object[] args;
+ if (arg == null) {
+ args = new Object[] { null };
+ } else if (arg.getClass().isArray()) {
+ args = (Object[]) arg;
+ for (int i = 0; i < args.length; i++) {
+ args[i] = Context.toObject(args[i], scope);
+ }
+ } else {
+ args = new Object[] { Context.toObject(arg, scope) };
+ }
+ return args;
+ }
+
+ /**
+ * Unwrap and convert response
+ */
+ protected Object processResponse(Object response, Class responseClass) {
+ // TODO: implement pluggable way to transform E4X XML into specific objects (eg SDO or AXIOM)
+ // } else if (response instanceof XMLObject) {
+ // response = E4XAXIOMUtils.toOMElement((XMLObject) response);
+ if (Context.getUndefinedValue().equals(response)) {
+ response = null;
+ } else if (response instanceof Wrapper) {
+ response = ((Wrapper) response).unwrap();
+ } else {
+ if (responseClass != null) {
+ response = Context.toType(response, responseClass);
+ } else {
+ response = Context.toType(response, String.class);
+ }
+ }
+ return response;
+ }
+
+ /**
+ * Create a Rhino scope and compile the script into it
+ */
+ protected void initScriptScope(String scriptName, String script, Map context) {
+ Context cx = Context.enter();
+ try {
+
+ this.scriptScope = cx.initStandardObjects(null, true);
+ Script compiledScript = cx.compileString(script, scriptName, 1, null);
+ compiledScript.exec(cx, scriptScope);
+ addContexts(scriptScope, context);
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Initializes the shared scope
+ */
+ protected void initSharedScope() {
+ Context cx = Context.enter();
+ try {
+
+ this.sharedScope = cx.newObject(scriptScope);
+ sharedScope.setPrototype(scriptScope);
+ sharedScope.setParentScope(null);
+
+ } finally {
+ Context.exit();
+ }
+ }
+
+ /**
+ * Get a Rhino scope for the function invocation. If the invocation has no context objects then this will use the shared scope otherwise a new
+ * scope is created to hold the context objects. Any new variables the executing script might define will go in the sharedScope. This new scope is
+ * just to hold the invocation specific context objects.
+ */
+ protected Scriptable getInvocationScope(Context cx, Map contexts) {
+
+ Scriptable scope;
+ if (contexts == null || contexts.size() == 0) {
+ scope = sharedScope;
+ } else {
+ scope = cx.newObject(sharedScope);
+ scope.setPrototype(sharedScope);
+ scope.setParentScope(null);
+ addContexts(scope, contexts);
+ }
+
+ return scope;
+ }
+
+ /**
+ * Add the context to the scope. This will make the objects available to a script by using the name it was added with.
+ */
+ protected void addContexts(Scriptable scope, Map contexts) {
+ if (contexts != null) {
+ for (Iterator i = contexts.keySet().iterator(); i.hasNext();) {
+ String name = (String) i.next();
+ Object value = contexts.get(name);
+ if (value != null) {
+ scope.put(name, scope, Context.toObject(value, scope));
+ }
+ }
+ }
+ }
+
+ /**
+ * Get the Rhino Function object for the named script function
+ */
+ protected Function getFunction(Scriptable scope, String functionName) {
+
+ Object handleObj = scope.get(functionName, scope);
+
+ if (!(handleObj instanceof Function)) {
+ throw new RuntimeException("script function '" + functionName + "' is undefined or not a function in script " + scriptName);
+ }
+
+ return (Function) handleObj;
+ }
+
+ /**
+ * Make a copy of this RhinoScript object. This shares the script scope to avoid the overhead of recompiling the script, and to allow any
+ * initialization done by the script to be shared.
+ */
+ public RhinoInvoker copy() {
+ return new RhinoInvoker(scriptName, script, scriptScope);
+ }
+
+ /**
+ * Update the scope where the script is complied with new context values
+ *
+ * @param properties
+ */
+ public void updateScriptScope(Map context) {
+ Context.enter();
+ try {
+ addContexts(scriptScope, context);
+ } finally {
+ Context.exit();
+ }
+ }
+
+}
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/container.js/src/main/java/org/apache/tuscany/container/js/rhino/RhinoInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date