tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmar...@apache.org
Subject svn commit: r440553 - in /incubator/tuscany/java/sca/kernel: core/src/main/java/org/apache/tuscany/core/builder/ core/src/main/java/org/apache/tuscany/core/component/scope/ core/src/main/java/org/apache/tuscany/core/implementation/processor/ core/src/m...
Date Wed, 06 Sep 2006 01:16:55 GMT
Author: jmarino
Date: Tue Sep  5 18:16:55 2006
New Revision: 440553

URL: http://svn.apache.org/viewvc?view=rev&rev=440553
Log:
make scope containers completely pluggable by interning string representations

Added:
    incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
  (with props)
Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java

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=440553&r1=440552&r2=440553
==============================================================================
--- 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
Tue Sep  5 18:16:55 2006
@@ -131,7 +131,7 @@
     public <T> void connect(InboundWire<T> sourceWire,
                             OutboundWire<T> targetWire,
                             boolean optimizable) throws BuilderConfigException {
-        if (postProcessorRegistry != null){
+        if (postProcessorRegistry != null) {
             // run wire post-processors
             postProcessorRegistry.process(sourceWire, targetWire);
         }
@@ -158,7 +158,7 @@
                             OutboundWire<T> sourceWire,
                             InboundWire<T> targetWire,
                             boolean optimizable) {
-        if (postProcessorRegistry != null){
+        if (postProcessorRegistry != null) {
             // run wire post-processors
             postProcessorRegistry.process(sourceWire, targetWire);
         }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java?view=diff&rev=440553&r1=440552&r2=440553
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ScopeRegistryImpl.java
Tue Sep  5 18:16:55 2006
@@ -63,20 +63,8 @@
             ObjectFactory<? extends ScopeContainer> factory = factoryCache.get(scope);
             if (factory == null) {
                 ScopeNotFoundException e = new ScopeNotFoundException("Scope object factory
not registered for scope");
-                switch (scope) {
-                    case SESSION:
-                        e.setIdentifier("SESSION");
-                        break;
-                    case REQUEST:
-                        e.setIdentifier("REQUEST");
-                        break;
-                    case STATELESS:
-                        e.setIdentifier("STATELESS");
-                        break;
-                    default:
-                        e.setIdentifier("UNKNOWN");
-                        break;
-                }
+                e.setIdentifier(scope.getScope());
+                
                 throw e;
             }
             container = factory.getInstance();

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java?view=diff&rev=440553&r1=440552&r2=440553
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java
Tue Sep  5 18:16:55 2006
@@ -18,17 +18,18 @@
  */
 package org.apache.tuscany.core.implementation.processor;
 
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
 import org.apache.tuscany.spi.implementation.java.ProcessingException;
-import org.apache.tuscany.core.implementation.system.component.SystemCompositeComponent;
-import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.model.Scope;
 
+import org.apache.tuscany.core.implementation.system.component.SystemCompositeComponent;
+
 /**
  * Processes the {@link Scope} annotation and updates the component type with the corresponding
implmentation scope
  *
@@ -51,7 +52,6 @@
             return;
         }
         //FIXME deal with eager init
-        //FIXME needs to be extensible
         String name = annotation.value();
         Scope scope;
         if ("MODULE".equals(name)) {
@@ -63,7 +63,7 @@
         } else if ("COMPOSITE".equals(name)) {
             scope = Scope.COMPOSITE;
         } else {
-            scope = Scope.STATELESS;
+            scope = new Scope(name);
         }
         type.setImplementationScope(scope);
     }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java?view=diff&rev=440553&r1=440552&r2=440553
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemBindingBuilder.java
Tue Sep  5 18:16:55 2006
@@ -23,8 +23,6 @@
 import org.apache.tuscany.spi.builder.BuilderConfigException;
 import org.apache.tuscany.spi.component.Component;
 import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.component.Reference;
-import org.apache.tuscany.spi.component.Service;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.model.BoundReferenceDefinition;
 import org.apache.tuscany.spi.model.BoundServiceDefinition;
@@ -43,13 +41,14 @@
 import org.apache.tuscany.core.implementation.system.wire.SystemOutboundWireImpl;
 
 /**
- * Creates {@link SystemService}s and {@link SystemReference}s by evaluating an assembly
definition
+ * Creates {@link SystemService}s and {@link org.apache.tuscany.core.implementation.system.component.SystemReference}s
+ * by evaluating an assembly definition
  *
  * @version $$Rev$$ $$Date$$
  */
 public class SystemBindingBuilder implements BindingBuilder<SystemBinding> {
 
-    public Service<?> build(CompositeComponent parent,
+    public SystemService build(CompositeComponent parent,
                                BoundServiceDefinition<SystemBinding> boundServiceDefinition,
                                DeploymentContext deploymentContext) {
         Class interfaze = boundServiceDefinition.getServiceContract().getInterfaceClass();
@@ -68,7 +67,7 @@
         return service;
     }
 
-    public Reference<?> build(CompositeComponent parent,
+    public SystemReference build(CompositeComponent parent,
                                  BoundReferenceDefinition<SystemBinding> boundReferenceDefinition,
                                  DeploymentContext deploymentContext) {
         assert parent.getParent() instanceof AutowireComponent
@@ -79,7 +78,7 @@
         SystemInboundWire<?> inboundWire = new SystemInboundWireImpl(boundReferenceDefinition.getName(),
interfaze);
         String refName = boundReferenceDefinition.getName();
         OutboundWire outboundWire = new SystemOutboundAutowire(refName, interfaze,
-                autowireComponent, boundReferenceDefinition.isRequired());
+            autowireComponent, boundReferenceDefinition.isRequired());
         reference.setInboundWire(inboundWire);
         reference.setOutboundWire(outboundWire);
         return reference;

Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java?view=diff&rev=440553&r1=440552&r2=440553
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
(original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Operation.java
Tue Sep  5 18:16:55 2006
@@ -30,6 +30,7 @@
  * @version $Rev$ $Date$
  */
 public class Operation<T> {
+    protected Map<String, Object> metaData;
     private final String name;
     private final DataType<T> returnType;
     private final List<DataType<T>> parameterTypes;
@@ -38,7 +39,6 @@
     private ServiceContract<?> contract;
     private boolean callback;
     private String dataBinding;
-    protected Map<String, Object> metaData;
 
     /**
      * Construct an operation specifying all characteristics.
@@ -185,6 +185,7 @@
 
     /**
      * Adds metadata associated with the operation.
+     *
      * @param key the metadata key
      * @param val the metadata value
      */

Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java?view=diff&rev=440553&r1=440552&r2=440553
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java
(original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java
Tue Sep  5 18:16:55 2006
@@ -21,12 +21,37 @@
 /**
  * The default implementation scopes supported by assemblies.
  */
-public enum Scope {
-    STATELESS,
-    REQUEST,
-    SESSION,
-    MODULE,
-    COMPOSITE,
-    UNDEFINED
+public class Scope {
+    public static final Scope STATELESS = new Scope("STATELESS");
+    public static final Scope REQUEST = new Scope("REQUEST");
+    public static final Scope SESSION = new Scope("SESSION");
+    public static final Scope MODULE = new Scope("MODULE");
+    public static final Scope COMPOSITE = new Scope("COMPOSITE");
+    public static final Scope UNDEFINED = new Scope("UNDEFINED");
+
+    private String scope;
+
+    public Scope(String scope) {
+        this.scope = scope.toUpperCase().intern();
+    }
+
+    public String getScope() {
+        return scope;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        final Scope scope1 = (Scope) o;
+        return !(scope != null ? scope != scope1.scope.intern() : scope1.scope != null);
+    }
+
+    public int hashCode() {
+        return scope != null ? scope.hashCode() : 0;
+    }
 
 }

Added: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java?view=auto&rev=440553
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
(added)
+++ incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
Tue Sep  5 18:16:55 2006
@@ -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.spi.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ScopeTestCase extends TestCase {
+
+    public void testEquals() throws Exception {
+        Scope module = new Scope("module");
+        assertTrue(module.equals(Scope.MODULE));
+    }
+
+    public void testEqualsNew() throws Exception {
+        Scope foo = new Scope("foo");
+        Scope foo2 = new Scope("FOO");
+        assertTrue(foo.equals(foo2));
+    }
+
+    public void testNotEquals() throws Exception {
+        Scope foo = new Scope("BAR");
+        Scope foo2 = new Scope("FOO");
+        assertFalse(foo.equals(foo2));
+    }
+
+    public void testNotEqualsDifferent() throws Exception {
+        Scope foo = new Scope("FOO");
+        assertFalse(foo.equals(new Bar("FOO")));
+    }
+
+    public class Bar {
+        private String scope;
+
+        public Bar(String scope) {
+            this.scope = scope;
+        }
+    }
+
+
+}

Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
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