Author: jmarino
Date: Thu Apr 20 15:01:38 2006
New Revision: 395708
URL: http://svn.apache.org/viewcvs?rev=395708&view=rev
Log:
initial commit of wire factory system service
Added:
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/DefaultWireFactoryService.java
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/WireFactoryService.java
Modified:
incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilder.java
Modified:
incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilder.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilder.java?rev=395708&r1=395707&r2=395708&view=diff
==============================================================================
---
incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilder.java
(original)
+++
incubator/tuscany/java/sca/containers/container.java/src/main/java/org/apache/tuscany/container/java/builder/JavaContextFactoryBuilder.java
Thu Apr 20 15:01:38 2006
@@ -161,9 +161,9 @@
List<Injector> injectors = new ArrayList<Injector>();
- EventInvoker initInvoker = null;
+ EventInvoker<Object> initInvoker = null;
boolean eagerInit = false;
- EventInvoker destroyInvoker = null;
+ EventInvoker<Object> destroyInvoker = null;
ContextObjectFactory contextObjectFactory = new
ContextObjectFactory(contextFactory);
for (Field field : fields) {
ComponentName compName =
field.getAnnotation(ComponentName.class);
@@ -180,14 +180,14 @@
for (Method method : methods) {
Init init = method.getAnnotation(Init.class);
if (init != null && initInvoker == null) {
- initInvoker = new MethodEventInvoker(method);
+ initInvoker = new MethodEventInvoker<Object>(method);
eagerInit = init.eager();
continue;
}
// @spec - should we allow the same method to have @init
and @destroy?
Destroy destroy = method.getAnnotation(Destroy.class);
if (destroy != null && destroyInvoker == null) {
- destroyInvoker = new MethodEventInvoker(method);
+ destroyInvoker = new
MethodEventInvoker<Object>(method);
continue;
}
ComponentName compName =
method.getAnnotation(ComponentName.class);
Added:
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/DefaultWireFactoryService.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/DefaultWireFactoryService.java?rev=395708&view=auto
==============================================================================
---
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/DefaultWireFactoryService.java
(added)
+++
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/DefaultWireFactoryService.java
Thu Apr 20 15:01:38 2006
@@ -0,0 +1,87 @@
+/**
+ *
+ * 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.core.wire.service;
+
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.wire.MethodHashMap;
+import org.apache.tuscany.core.wire.ProxyFactoryFactory;
+import org.apache.tuscany.core.wire.SourceInvocationConfiguration;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetInvocationConfiguration;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+import org.apache.tuscany.core.wire.WireSourceConfiguration;
+import org.apache.tuscany.core.wire.WireTargetConfiguration;
+import org.osoa.sca.annotations.Scope;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The default implementation of the <code>WireFactoryService</code> in the
runtime
+ *
+ * @version $$Rev$$ $$Date$$
+ */
[EMAIL PROTECTED]("MODULE")
+public class DefaultWireFactoryService implements WireFactoryService {
+
+ private MessageFactory messageFactory;
+
+ @Autowire
+ public void setMessageFactory(MessageFactory messageFactory) {
+ this.messageFactory = messageFactory;
+ }
+
+ private ProxyFactoryFactory proxyFactory;
+
+ @Autowire
+ public void setProxyFactory(ProxyFactoryFactory proxyFactory) {
+ this.proxyFactory = proxyFactory;
+ }
+
+ public SourceWireFactory createSourceFactory(String referenceName,
QualifiedName targetName, Class interfaze) {
+ SourceWireFactory wireFactory = proxyFactory.createSourceWireFactory();
+ Map<Method, SourceInvocationConfiguration> iConfigMap = new
HashMap<Method, SourceInvocationConfiguration>();
+ Set<Method> javaMethods =
JavaIntrospectionHelper.getAllUniqueMethods(interfaze);
+ for (Method method : javaMethods) {
+ SourceInvocationConfiguration iConfig = new
SourceInvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ WireSourceConfiguration pConfiguration = new
WireSourceConfiguration(referenceName, targetName, iConfigMap,
interfaze.getClassLoader(),
+ messageFactory);
+ wireFactory.setBusinessInterface(interfaze);
+ wireFactory.setConfiguration(pConfiguration);
+ return wireFactory;
+ }
+
+ public TargetWireFactory createTargetFactory(QualifiedName targetName,
Class interfaze) {
+ Map<Method, TargetInvocationConfiguration> iConfigMap = new
MethodHashMap<TargetInvocationConfiguration>();
+ TargetWireFactory wireFactory = proxyFactory.createTargetWireFactory();
+ Set<Method> javaMethods =
JavaIntrospectionHelper.getAllUniqueMethods(interfaze);
+ for (Method method : javaMethods) {
+ TargetInvocationConfiguration iConfig = new
TargetInvocationConfiguration(method);
+ iConfigMap.put(method, iConfig);
+ }
+ WireTargetConfiguration wireConfiguration = new
WireTargetConfiguration(targetName, iConfigMap, interfaze.getClassLoader(),
messageFactory);
+ wireFactory.setBusinessInterface(interfaze);
+ wireFactory.setConfiguration(wireConfiguration);
+ return wireFactory;
+ }
+
+
+}
Added:
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/WireFactoryService.java
URL:
http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/WireFactoryService.java?rev=395708&view=auto
==============================================================================
---
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/WireFactoryService.java
(added)
+++
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/service/WireFactoryService.java
Thu Apr 20 15:01:38 2006
@@ -0,0 +1,47 @@
+/**
+ *
+ * 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.core.wire.service;
+
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.wire.SourceWireFactory;
+import org.apache.tuscany.core.wire.TargetWireFactory;
+
+/**
+ * Implementations are responsible for providing a system service that creates
[EMAIL PROTECTED] org.apache.tuscany.core.wire.SourceWireFactory}s
+ * and [EMAIL PROTECTED] org.apache.tuscany.core.wire.TargetWireFactory}s
+ *
+ * @version $$Rev$$ $$Date$$
+ */
+public interface WireFactoryService {
+
+ /**
+ * Creates a source-side wire factory for the given reference
+ *
+ * @param referenceName the name of the reference the wire is associated
with
+ * @param targetName the qualified name of the target service
+ * @param interfaze the business interface used in constructing wire
proxies
+ * @return the source-side wire factory
+ */
+ public SourceWireFactory createSourceFactory(String referenceName,
QualifiedName targetName, Class interfaze);
+
+ /**
+ * Creates a target-side wire factory for a service implementing a given
interface
+ *
+ * @param targetName the qualified name of the wire target
+ * @param interfaze the interface used to represent the service offered
by the wire target
+ * @return the target-side wire factory
+ */
+ public TargetWireFactory createTargetFactory(QualifiedName targetName,
Class interfaze);
+
+}