tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmar...@apache.org
Subject svn commit: r440222 - in /incubator/tuscany/java/sca: commands/launcher/src/main/resources/META-INF/tuscany/ kernel/core/src/main/java/org/apache/tuscany/core/builder/ kernel/core/src/test/java/org/apache/tuscany/core/builder/ runtime/webapp-host/src/m...
Date Tue, 05 Sep 2006 02:43:55 GMT
Author: jmarino
Date: Mon Sep  4 19:43:55 2006
New Revision: 440222

URL: http://svn.apache.org/viewvc?view=rev&rev=440222
Log:
add wire post processor step prior to connect

Added:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java
  (with props)
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
  (with props)
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java
  (with props)
Modified:
    incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
    incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl
    incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl

Modified: incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl?view=diff&rev=440222&r1=440221&r2=440222
==============================================================================
--- incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
(original)
+++ incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
Mon Sep  4 19:43:55 2006
@@ -66,6 +66,10 @@
         <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
     </component>
 
+    <component name="wirePostProcessorRegistry">
+        <system:implementation.system class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
+    </component>
+    
     <!-- Default scopes -->
     <component name="scope.module">
         <system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
@@ -106,7 +110,8 @@
 
     <!-- WorkScheduler service -->
     <component name="workManager">
-        <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
+        <system:implementation.system
+            class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
         <property name="poolSize">10</property>
     </component>
 
@@ -115,7 +120,7 @@
     </component>
 
     <component name="policyBuilderRegistry">
-         <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+        <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
     </component>
 
     <component name="propertyFactory">

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?view=diff&rev=440222&r1=440221&r2=440222
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
Mon Sep  4 19:43:55 2006
@@ -22,9 +22,13 @@
 import java.util.List;
 import java.util.Map;
 
+import org.osoa.sca.annotations.Constructor;
+
 import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.builder.BuilderConfigException;
 import org.apache.tuscany.spi.builder.Connector;
+import org.apache.tuscany.spi.builder.WirePostProcessorRegistry;
 import org.apache.tuscany.spi.component.AtomicComponent;
 import org.apache.tuscany.spi.component.Component;
 import org.apache.tuscany.spi.component.ComponentRuntimeException;
@@ -56,6 +60,16 @@
  */
 public class ConnectorImpl implements Connector {
 
+    private WirePostProcessorRegistry postProcessorRegistry;
+
+    public ConnectorImpl() {
+    }
+
+    @Constructor
+    public ConnectorImpl(@Autowire WirePostProcessorRegistry postProcessorRegistry) {
+        this.postProcessorRegistry = postProcessorRegistry;
+    }
+
     public <T> void connect(SCAObject<T> source) {
         CompositeComponent parent = source.getParent();
         if (source instanceof AtomicComponent) {
@@ -117,6 +131,10 @@
     public <T> void connect(InboundWire<T> sourceWire,
                             OutboundWire<T> targetWire,
                             boolean optimizable) throws BuilderConfigException {
+        if (postProcessorRegistry != null){
+            // run wire post-processors
+            postProcessorRegistry.process(sourceWire, targetWire);
+        }
         Map<Operation<?>, OutboundInvocationChain> targetChains = targetWire.getInvocationChains();
         // perform optimization, if possible
         if (optimizable && sourceWire.getInvocationChains().isEmpty() &&
targetChains.isEmpty()) {
@@ -140,6 +158,10 @@
                             OutboundWire<T> sourceWire,
                             InboundWire<T> targetWire,
                             boolean optimizable) {
+        if (postProcessorRegistry != null){
+            // run wire post-processors
+            postProcessorRegistry.process(sourceWire, targetWire);
+        }
         Map<Operation, InboundInvocationChain> targetChains = targetWire.getInvocationChains();
         // perform optimization, if possible
         // REVIEW: (kentaminator@gmail.com) shouldn't this check whether the interceptors
in the

Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java?view=auto&rev=440222
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java
(added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java
Mon Sep  4 19:43:55 2006
@@ -0,0 +1,57 @@
+/*
+ * 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.core.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.spi.builder.WirePostProcessor;
+import org.apache.tuscany.spi.builder.WirePostProcessorRegistry;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+/**
+ * The default implementation of a <code>WirePostProcessor</code>
+ *
+ * @version $Rev$ $Date$
+ */
+public class WirePostProcessorRegistryImpl implements WirePostProcessorRegistry {
+
+    private final List<WirePostProcessor> processors = new ArrayList<WirePostProcessor>();
+
+    public <T> void process(OutboundWire<T> source, InboundWire<T> target)
{
+        for (WirePostProcessor processor : processors) {
+            processor.process(source, target);
+        }
+    }
+
+    public <T> void process(InboundWire<T> source, OutboundWire<T> target)
{
+        for (WirePostProcessor processor : processors) {
+            processor.process(source, target);
+        }
+    }
+
+    public void register(WirePostProcessor processor) {
+        processors.add(processor);
+    }
+
+    public void unregister(WirePostProcessor processor) {
+        processors.remove(processor);
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java?view=auto&rev=440222
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
(added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
Mon Sep  4 19:43:55 2006
@@ -0,0 +1,74 @@
+/*
+ * 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.core.builder;
+
+import static org.easymock.EasyMock.expect;
+
+import java.util.Collections;
+
+import org.apache.tuscany.spi.builder.WirePostProcessorRegistry;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConnectorPostProcessTestCase extends TestCase {
+
+    @SuppressWarnings("unchecked")
+    public void testInboundToOutboundPostProcessCalled() throws Exception {
+        OutboundWire owire = createNiceMock(OutboundWire.class);
+        replay(owire);
+        InboundWire iwire = createNiceMock(InboundWire.class);
+        expect(iwire.getInvocationChains()).andReturn(Collections.emptyMap());
+        replay(iwire);
+        WirePostProcessorRegistry registry = createMock(WirePostProcessorRegistry.class);
+        registry.process(EasyMock.eq(iwire), EasyMock.eq(owire));
+        replay(registry);
+        ConnectorImpl connector = new ConnectorImpl(registry);
+        connector.connect(iwire, owire, false);
+        verify(registry);
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testOutboundToInboundPostProcessCalled() throws Exception {
+        OutboundWire owire = createNiceMock(OutboundWire.class);
+        expect(owire.getSourceCallbackInvocationChains()).andReturn(Collections.emptyMap());
+        expect(owire.getInvocationChains()).andReturn(Collections.emptyMap());
+        replay(owire);
+        InboundWire iwire = createNiceMock(InboundWire.class);
+        replay(iwire);
+        WirePostProcessorRegistry registry = createMock(WirePostProcessorRegistry.class);
+        registry.process(EasyMock.eq(owire), EasyMock.eq(iwire));
+        replay(registry);
+        ConnectorImpl connector = new ConnectorImpl(registry);
+        connector.connect(null, null, owire, iwire, false);
+        verify(registry);
+    }
+
+
+
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorPostProcessTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java?view=auto&rev=440222
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java
(added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java
Mon Sep  4 19:43:55 2006
@@ -0,0 +1,47 @@
+package org.apache.tuscany.core.builder;
+
+import org.apache.tuscany.spi.builder.WirePostProcessor;
+import org.apache.tuscany.spi.builder.WirePostProcessorRegistry;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.OutboundWire;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WirePostProcessorRegistryImplTestCase extends TestCase {
+
+    @SuppressWarnings("unchecked")
+    public void testRegisterUnregister() throws Exception {
+        WirePostProcessorRegistry registry = new WirePostProcessorRegistryImpl();
+        OutboundWire owire = EasyMock.createMock(OutboundWire.class);
+        InboundWire iwire = EasyMock.createMock(InboundWire.class);
+        WirePostProcessor processor = createMock(WirePostProcessor.class);
+        processor.process(EasyMock.eq(owire), EasyMock.eq(iwire));
+        EasyMock.replay(processor);
+        registry.register(processor);
+        registry.process(owire, iwire);
+        registry.unregister(processor);
+        registry.process(owire, iwire);
+        verify(processor);
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testProcessInboundToOutbound() throws Exception {
+        WirePostProcessorRegistry registry = new WirePostProcessorRegistryImpl();
+        OutboundWire owire = EasyMock.createMock(OutboundWire.class);
+        InboundWire iwire = EasyMock.createMock(InboundWire.class);
+        WirePostProcessor processor = createMock(WirePostProcessor.class);
+        processor.process(EasyMock.eq(iwire), EasyMock.eq(owire));
+        EasyMock.replay(processor);
+        registry.register(processor);
+        registry.process(iwire, owire);
+        verify(processor);
+    }
+
+
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/WirePostProcessorRegistryImplTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl?view=diff&rev=440222&r1=440221&r2=440222
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl
(original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/sca/webapp.system.scdl
Mon Sep  4 19:43:55 2006
@@ -66,6 +66,10 @@
         <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
     </component>
 
+    <component name="wirePostProcessorRegistry">
+        <system:implementation.system class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
+    </component>
+
     <!-- Default scopes -->
     <component name="scope.module">
         <system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>

Modified: incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl?view=diff&rev=440222&r1=440221&r2=440222
==============================================================================
--- incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl (original)
+++ incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl Mon Sep
 4 19:43:55 2006
@@ -66,6 +66,10 @@
         <system:implementation.system class="org.apache.tuscany.core.builder.ConnectorImpl"/>
     </component>
 
+    <component name="wirePostProcessorRegistry">
+        <system:implementation.system class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
+    </component>
+    
     <!-- Default scopes -->
     <component name="scope.module">
         <system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
@@ -109,7 +113,8 @@
 
     <!-- WorkScheduler service -->
     <component name="workManager">
-        <system:implementation.system class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
+        <system:implementation.system
+            class="org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager"/>
         <property name="poolSize">10</property>
     </component>
 
@@ -118,11 +123,11 @@
     </component>
 
     <component name="policyBuilderRegistry">
-         <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
+        <system:implementation.system class="org.apache.tuscany.core.policy.PolicyBuilderRegistryImpl"/>
     </component>
 
     <component name="propertyFactory">
         <system:implementation.system class="org.apache.tuscany.core.loader.StringParserPropertyFactory"/>
     </component>
-    
+
 </composite>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message