From 3ca8a1eec06e82a603c03e1d2aaca4669d7d78ed Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 2 May 2009 06:18:19 +0000 Subject: Get the spring reference and property annotations going git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@770894 13f79535-47bb-0310-9956-ffa450edef68 --- .../spring/invocation/ComponentTie.java | 35 ++++++++++++++++ .../spring/invocation/PropertyValueTie.java | 47 ++++++++++++++++++++++ .../spring/invocation/SpringImplementationTie.java | 5 +-- 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java create mode 100644 java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java (limited to 'java/sca/modules/implementation-spring/src/main') diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java new file mode 100644 index 0000000000..58dd94f657 --- /dev/null +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.implementation.spring.invocation; + +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +public class ComponentTie { + + private RuntimeComponent component; + + public ComponentTie(RuntimeComponent component) { + this.component = component; + } + + public Object getService(Class type, String name) { + return component.getComponentContext().getService(type, name); + } +} diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java new file mode 100644 index 0000000000..09a53267d7 --- /dev/null +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java @@ -0,0 +1,47 @@ +/* + * 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.invocation; + +import java.util.List; + +import org.apache.tuscany.sca.assembly.ComponentProperty; +import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +public class PropertyValueTie { + + private RuntimeComponent component; + private JavaPropertyValueObjectFactory propertyFactory; + + public PropertyValueTie(RuntimeComponent component, JavaPropertyValueObjectFactory propertyFactory) { + this.component = component; + this.propertyFactory = propertyFactory; + } + + public Object getPropertyObj(Class type, String name) { + List props = component.getProperties(); + for (ComponentProperty prop : props) { + if (prop.getName().equals(name)) { + return propertyFactory.createValueFactory(prop, prop.getValue(), type).getInstance(); + } + } + return null; // property name not found + } +} diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java index cf98440903..ac913fdee2 100644 --- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java +++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java @@ -134,11 +134,10 @@ public class SpringImplementationTie { } // end method getBean( String, Class ) public Object getComponentTie() { - return new ComponentTie(); + return new ComponentTie(component); } - public Object getPropertyValueTie() { - return new PropertyValueTie(); + return new PropertyValueTie(component, propertyFactory); } } -- cgit v1.2.3