From 1618160f4f2dbb67727df2d341c505f105aa1e2c Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 26 Oct 2010 11:07:13 +0000 Subject: Delete and redo release branch git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027464 13f79535-47bb-0310-9956-ffa450edef68 --- .../spring/elements/tie/SpringBeanElement.java | 129 +++++++++++++++++++++ .../elements/tie/SpringConstructorArgElement.java | 77 ++++++++++++ .../spring/elements/tie/SpringElementTie.java | 70 +++++++++++ .../spring/elements/tie/SpringPropertyElement.java | 68 +++++++++++ .../elements/tie/SpringSCAPropertyElement.java | 59 ++++++++++ .../elements/tie/SpringSCAReferenceElement.java | 91 +++++++++++++++ .../elements/tie/SpringSCAServiceElement.java | 91 +++++++++++++++ 7 files changed, 585 insertions(+) create mode 100644 sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java create mode 100644 sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java (limited to 'sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements') diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringBeanElement.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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 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 properties = new ArrayList(); + private List constructorargs = new ArrayList(); + + 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 getProperties() { + return properties; + } + + public void addProperty(SpringPropertyElement property) { + properties.add(property); + } + + public List 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/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringConstructorArgElement.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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 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 refs = new ArrayList(); + private List values = new ArrayList(); + + public SpringConstructorArgElement(String type) { + this.type = type; + } + + public String getType() { + return this.type; + } + + public List 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 getValues() { + return this.values; + } + + public void addValue(String value) { + this.values.add(value); + } +} diff --git a/sca-java-2.x/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringElementTie.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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 copy(Object source, Class 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/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringPropertyElement.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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 element in a Spring application-context + * - this has name and ref attributes + * + * @version $Rev$ $Date$ + */ +public class SpringPropertyElement { + + private String name; + private List refs = new ArrayList(); + private List values = new ArrayList(); + + public SpringPropertyElement(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public List getRefs() { + return this.refs; + } + + public void addRef(String ref) { + this.refs.add(ref); + } + + public List 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/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAPropertyElement.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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 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/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAReferenceElement.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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 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 intentNames = new ArrayList(); + private List policySetNames = new ArrayList(); + + + 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 getIntentNames() { + return intentNames; + } + + public List 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/branches/2.0-Beta1/modules/implementation-spring-tie/src/main/java/org/apache/tuscany/sca/implementation/spring/elements/tie/SpringSCAServiceElement.java b/sca-java-2.x/branches/2.0-Beta1/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/branches/2.0-Beta1/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 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 intentNames = new ArrayList(); + private List policySetNames = new ArrayList(); + + + 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 getIntentNames() { + return intentNames; + } + + public List 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 -- cgit v1.2.3