summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie')
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java129
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java77
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java70
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java68
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java59
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java91
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java91
7 files changed, 585 insertions, 0 deletions
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java
new file mode 100644
index 0000000000..020e001a59
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java
@@ -0,0 +1,129 @@
+/*
+ * 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.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <bean> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringBeanElement {
+
+ private String id;
+ private String className = null;
+ private boolean innerBean = false;
+ private boolean abstractBean = false;
+ private boolean parentAttribute = false;
+ private boolean factoryBeanAttribute = false;
+ private boolean factoryMethodAttribute = false;
+
+ private List<SpringPropertyElement> properties = new ArrayList<SpringPropertyElement>();
+ private List<SpringConstructorArgElement> constructorargs = new ArrayList<SpringConstructorArgElement>();
+
+ public SpringBeanElement(String id, String className) {
+ this.id = id;
+ this.className = className;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<SpringPropertyElement> getProperties() {
+ return properties;
+ }
+
+ public void addProperty(SpringPropertyElement property) {
+ properties.add(property);
+ }
+
+ public List<SpringConstructorArgElement> getCustructorArgs() {
+ return constructorargs;
+ }
+
+ public void addCustructorArgs(SpringConstructorArgElement args) {
+ constructorargs.add(args);
+ }
+
+ public boolean isInnerBean() {
+ return innerBean;
+ }
+
+ public void setInnerBean(boolean innerBean) {
+ this.innerBean = innerBean;
+ }
+
+ public boolean isAbstractBean() {
+ return abstractBean;
+ }
+
+ public void setAbstractBean(boolean abstractBean) {
+ this.abstractBean = abstractBean;
+ }
+
+ public boolean hasParentAttribute() {
+ return parentAttribute;
+ }
+
+ public void setParentAttribute(boolean parentAttribute) {
+ this.parentAttribute = parentAttribute;
+ }
+
+ public boolean hasFactoryBeanAttribute() {
+ return factoryBeanAttribute;
+ }
+
+ public void setFactoryBeanAttribute(boolean factoryBeanAttribute) {
+ this.factoryBeanAttribute = factoryBeanAttribute;
+ }
+
+ public boolean hasFactoryMethodAttribute() {
+ return factoryMethodAttribute;
+ }
+
+ public void setFactoryMethodAttribute(boolean factoryMethodAttribute) {
+ this.factoryMethodAttribute = factoryMethodAttribute;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringBeanElement [id=").append(id).append(", className=").append(className)
+ .append(", innerBean=").append(innerBean).append(", abstractBean=").append(abstractBean)
+ .append(", parentAttribute=").append(parentAttribute).append(", factoryBeanAttribute=")
+ .append(factoryBeanAttribute).append(", factoryMethodAttribute=").append(factoryMethodAttribute)
+ .append(", properties=").append(properties).append(", constructorargs=").append(constructorargs)
+ .append("]");
+ return builder.toString();
+ }
+
+} // end class SpringBeanElement
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java
new file mode 100644
index 0000000000..53a972b7d8
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java
@@ -0,0 +1,77 @@
+/*
+ * 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.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <constructor-arg> element in a Spring application-context
+ * - this has ref attribute
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringConstructorArgElement {
+
+ private String type;
+ private int autoIndex = -1;
+ private int index = -1;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringConstructorArgElement(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public int getIndex() {
+ return this.index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public int getAutoIndex() {
+ return this.autoIndex;
+ }
+
+ public void setAutoIndex(int index) {
+ this.autoIndex = index;
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java
new file mode 100644
index 0000000000..c088e5d0f2
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java
@@ -0,0 +1,70 @@
+/*
+ * 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.implementation.spring.elements.tie;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * A hacking utility to copy beans field by field between two class loaders
+ */
+public class SpringElementTie {
+ public static <T> T copy(Object source, Class<T> cls, Type genericType) {
+ if (source == null) {
+ return null;
+ }
+ if (cls.isPrimitive()) {
+ return (T)source;
+ }
+ if (Collection.class.isAssignableFrom(cls)) {
+ ParameterizedType pType = (ParameterizedType)genericType;
+ Type itemType = pType.getActualTypeArguments()[0];
+ Collection col = (Collection)source;
+ List target = new ArrayList();
+ for (Object item : col) {
+ target.add(copy(item, (Class<?>)itemType, itemType));
+ }
+ return (T)target;
+ }
+ if (cls.isInstance(source)) {
+ return cls.cast(source);
+ }
+ try {
+ Class<?> sourceClass = source.getClass();
+ T target = cls.newInstance();
+ for (Field sourceField : sourceClass.getDeclaredFields()) {
+ sourceField.setAccessible(true);
+ Field targetField = cls.getDeclaredField(sourceField.getName());
+ targetField.setAccessible(true);
+ Object sourceFieldValue = sourceField.get(source);
+ Object targetFieldValue = copy(sourceFieldValue, targetField.getType(), targetField.getGenericType());
+ targetField.set(target, targetFieldValue);
+ }
+ return target;
+ } catch (Throwable e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java
new file mode 100644
index 0000000000..c0a1f2129b
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java
@@ -0,0 +1,68 @@
+/*
+ * 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.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a <property> element in a Spring application-context
+ * - this has name and ref attributes
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringPropertyElement {
+
+ private String name;
+ private List<String> refs = new ArrayList<String>();
+ private List<String> values = new ArrayList<String>();
+
+ public SpringPropertyElement(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<String> getRefs() {
+ return this.refs;
+ }
+
+ public void addRef(String ref) {
+ this.refs.add(ref);
+ }
+
+ public List<String> getValues() {
+ return this.values;
+ }
+
+ public void addValue(String value) {
+ this.values.add(value);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringPropertyElement [name=").append(name).append(", refs=").append(refs).append(", values=")
+ .append(values).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java
new file mode 100644
index 0000000000..3f9901abea
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java
@@ -0,0 +1,59 @@
+/*
+ * 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.implementation.spring.elements.tie;
+
+/**
+ * Represents an <sca:property> element in a Spring application-context
+ * - this has name and type attributes
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAPropertyElement {
+
+ private String name;
+ private String type;
+
+ public SpringSCAPropertyElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAPropertyElement [name=").append(name).append(", type=").append(type).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringPropertyElement
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java
new file mode 100644
index 0000000000..0bcbb73583
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java
@@ -0,0 +1,91 @@
+/*
+ * 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.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Represents a <sca:reference> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAReferenceElement {
+
+ private String name;
+ private String type;
+ private String defaultBean;
+
+ private List<QName> intentNames = new ArrayList<QName>();
+ private List<QName> policySetNames = new ArrayList<QName>();
+
+
+ public SpringSCAReferenceElement(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setDefaultBean(String defaultBean) {
+ this.defaultBean = defaultBean;
+ }
+
+ public String getDefaultBean() {
+ return defaultBean;
+ }
+
+ public List<QName> getIntentNames() {
+ return intentNames;
+ }
+
+ public List<QName> getPolicySetNames() {
+ return policySetNames;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAReferenceElement [name=").append(name).append(", type=").append(type)
+ .append(", defaultBean=").append(defaultBean).append(", intentNames=").append(intentNames)
+ .append(", policySetNames=").append(policySetNames).append("]");
+ return builder.toString();
+ }
+
+
+} // end class SpringSCAReferenceElement
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java
new file mode 100644
index 0000000000..2322d19e1f
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java
@@ -0,0 +1,91 @@
+/*
+ * 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.implementation.spring.elements.tie;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+
+/**
+ * Represents a <sca:service> element in a Spring application-context
+ * - this has id and className attributes
+ * - plus zero or more property elements as children
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringSCAServiceElement {
+
+ private String name;
+ private String type;
+ private String target;
+
+ private List<QName> intentNames = new ArrayList<QName>();
+ private List<QName> policySetNames = new ArrayList<QName>();
+
+
+ public SpringSCAServiceElement(String name, String target) {
+ this.name = name;
+ this.target = target;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setTarget(String target) {
+ this.target = target;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public List<QName> getIntentNames() {
+ return intentNames;
+ }
+
+ public List<QName> getPolicySetNames() {
+ return policySetNames;
+ }
+
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("SpringSCAServiceElement [name=").append(name).append(", type=").append(type)
+ .append(", target=").append(target).append(", intentNames=").append(intentNames)
+ .append(", policySetNames=").append(policySetNames).append("]");
+ return builder.toString();
+ }
+
+} // end class SpringSCAServiceElement