tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r525216 - in /incubator/tuscany/java/sca/modules: ./ core/ core/src/main/java/org/apache/tuscany/core/ core/src/main/java/org/apache/tuscany/core/bootstrap/ core/src/main/java/org/apache/tuscany/core/component/ core/src/main/java/org/apache...
Date Tue, 03 Apr 2007 17:40:41 GMT
Author: rfeng
Date: Tue Apr  3 10:40:40 2007
New Revision: 525216

URL: http://svn.apache.org/viewvc?view=rev&rev=525216
Log:
Add the minicore that can bootstrap Tuscany system without dependency on SCDL and Java component
type

Added:
    incubator/tuscany/java/sca/modules/
    incubator/tuscany/java/sca/modules/core/
      - copied from r521957, incubator/tuscany/sandbox/rfeng/minicore/
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/
      - copied from r524305, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java
      - copied, changed from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
      - copied, changed from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java
      - copied, changed from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistry.java
  (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImpl.java
  (with props)
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/CallableReferenceImpl.java
      - copied unchanged from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallableReferenceImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/CallbackReferenceImpl.java
      - copied unchanged from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/CallbackReferenceImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java
      - copied unchanged from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ComponentContextImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/ServiceReferenceImpl.java
      - copied unchanged from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/ServiceReferenceImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java
      - copied unchanged from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/component/WorkContextImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
      - copied unchanged from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java
      - copied unchanged from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeComponentTypeLoader.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java
      - copied unchanged from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/implementation/composite/CompositeLoader.java
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/loader/
      - copied from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/loader/
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
      - copied, changed from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImplTestCase.java
  (with props)
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java
      - copied unchanged from r521966, incubator/tuscany/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java
      - copied unchanged from r521966, incubator/tuscany/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/BasicHttpSessionScopeTestCase.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java
      - copied unchanged from r521966, incubator/tuscany/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerDestroyOnExpirationTestCase.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java
      - copied unchanged from r521966, incubator/tuscany/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxAgeTestCase.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java
      - copied unchanged from r521966, incubator/tuscany/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerMaxIdleTimeTestCase.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java
      - copied unchanged from r521966, incubator/tuscany/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainerPersistenceTestCase.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
      - copied unchanged from r521966, incubator/tuscany/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/component/scope/WorkContextTestCase.java
Removed:
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/model/
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorGenerator.java
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/builder/physical/
    incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/component/WorkContextImplTestCase.java
Modified:
    incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java

Copied: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java
(from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java?view=diff&rev=525216&p1=incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java&r1=524852&p2=incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java&r2=525216
==============================================================================
--- incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/Bootstrapper.java
Tue Apr  3 10:40:40 2007
@@ -71,5 +71,6 @@
     AutowireResolver getAutowireResolver();
     
     ComponentManager getComponentManager();
+    ExtensionRegistry getExtensionRegistry();
 
 }

Copied: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
(from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java?view=diff&rev=525216&p1=incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java&r1=524852&p2=incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java&r2=525216
==============================================================================
--- incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
Tue Apr  3 10:40:40 2007
@@ -24,6 +24,8 @@
 import org.apache.tuscany.core.binding.local.LocalBindingDefinition;
 import org.apache.tuscany.core.binding.local.LocalBindingLoader;
 import org.apache.tuscany.core.builder.BuilderRegistryImpl;
+import org.apache.tuscany.core.builder.ConnectorImpl;
+import org.apache.tuscany.core.component.ComponentManagerImpl;
 import org.apache.tuscany.core.component.scope.AbstractScopeContainer;
 import org.apache.tuscany.core.component.scope.CompositeScopeContainer;
 import org.apache.tuscany.core.component.scope.RequestScopeContainer;
@@ -41,8 +43,10 @@
 import org.apache.tuscany.core.loader.ReferenceLoader;
 import org.apache.tuscany.core.loader.ServiceLoader;
 import org.apache.tuscany.core.resolver.AutowireResolver;
+import org.apache.tuscany.core.resolver.DefaultAutowireResolver;
 import org.apache.tuscany.host.MonitorFactory;
 import org.apache.tuscany.spi.builder.Builder;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
 import org.apache.tuscany.spi.builder.Connector;
 import org.apache.tuscany.spi.component.ComponentManager;
 import org.apache.tuscany.spi.component.ScopeContainerMonitor;
@@ -68,6 +72,7 @@
     private final AutowireResolver resolver;
     private final Connector connector;
     private final ScopeRegistry scopeRegistry;
+    private final ExtensionRegistry extensionRegistry;
 
     /**
      * Create a default bootstrapper.
@@ -91,7 +96,18 @@
         this.resolver = resolver;
         this.connector = connector;
         this.scopeRegistry = createScopeRegistry();
+        this.extensionRegistry = new ExtensionRegistryImpl();
     }
+    
+    public DefaultBootstrapper(MonitorFactory monitorFactory) {
+        this.monitorFactory = monitorFactory;
+        this.xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory",
getClass().getClassLoader());
+        this.resolver = new DefaultAutowireResolver();
+        this.componentManager = new ComponentManagerImpl(null, this.resolver);
+        this.connector = new ConnectorImpl(componentManager);
+        this.scopeRegistry = createScopeRegistry();
+        this.extensionRegistry = new ExtensionRegistryImpl();
+    }    
 
     /**
      * Returns the MonitorFactory being used by this bootstrapper.
@@ -110,11 +126,15 @@
      */
     public Deployer createDeployer() {
         ScopeRegistry scopeRegistry = getScopeRegistry();
-        Builder builder = createBuilder(scopeRegistry);
-        Loader loader = createLoader(null, null);
+        BuilderRegistry builder = createBuilder(scopeRegistry);
+        LoaderRegistry loader = createLoader(null, null);
         DeployerImpl deployer = new DeployerImpl(xmlFactory, loader, builder, componentManager,
resolver, connector);
         deployer.setMonitor(getMonitorFactory().getMonitor(ScopeContainerMonitor.class));
         deployer.setScopeRegistry(getScopeRegistry());
+        extensionRegistry.addExtension(ScopeRegistry.class, scopeRegistry);
+        extensionRegistry.addExtension(BuilderRegistry.class, builder);
+        extensionRegistry.addExtension(LoaderRegistry.class, loader);
+        extensionRegistry.addExtension(Deployer.class, deployer);
         return deployer;
     }
 
@@ -195,7 +215,7 @@
      *            will be supported
      * @return a new Builder
      */
-    private Builder createBuilder(ScopeRegistry scopeRegistry) {
+    private BuilderRegistry createBuilder(ScopeRegistry scopeRegistry) {
         BuilderRegistryImpl builderRegistry = new BuilderRegistryImpl(scopeRegistry);
         CompositeBuilder compositeBuilder = new CompositeBuilder();
         compositeBuilder.setBuilderRegistry(builderRegistry);
@@ -219,6 +239,13 @@
      */
     public ScopeRegistry getScopeRegistry() {
         return scopeRegistry;
+    }
+
+    /**
+     * @return the extensionRegistry
+     */
+    public ExtensionRegistry getExtensionRegistry() {
+        return extensionRegistry;
     }
 
 }

Copied: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java
(from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java?view=diff&rev=525216&p1=incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java&r1=524852&p2=incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java&r2=525216
==============================================================================
--- incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionActivator.java
Tue Apr  3 10:40:40 2007
@@ -19,13 +19,17 @@
 
 package org.apache.tuscany.core.bootstrap;
 
-import org.apache.tuscany.spi.builder.BuilderRegistry;
-import org.apache.tuscany.spi.loader.LoaderRegistry;
 
 /**
  * @version $Rev$ $Date$
  */
 public interface ExtensionActivator {
-    void start(LoaderRegistry loaderRegistry, BuilderRegistry builderRegistry);
-    void stop();
+    /**
+     * @param registry
+     */
+    void start(ExtensionRegistry registry);
+    /**
+     * @param registry
+     */
+    void stop(ExtensionRegistry registry);
 }

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistry.java?view=auto&rev=525216
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistry.java
(added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistry.java
Tue Apr  3 10:40:40 2007
@@ -0,0 +1,56 @@
+/*
+ * 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.bootstrap;
+
+import java.util.List;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ExtensionRegistry {
+    /**
+     * @param <T>
+     * @param extensionPoint
+     * @param extension
+     */
+    <T> void addExtension(Class<T> extensionPoint, T extension);
+    /**
+     * @param <T>
+     * @param extensionPoint
+     * @return
+     */
+    <T> List<T> getExtensions(Class<T> extensionPoint);
+    /**
+     * @param <T>
+     * @param extensionPoint
+     * @return
+     */
+    <T> T getExtension(Class<T> extensionPoint);
+    /**
+     * @param <T>
+     * @param extensionPoint
+     * @param extension
+     */
+    <T> void removeExtension(Class<T> extensionPoint, T extension);
+    /**
+     * @param extensionPoint
+     */
+    void removeExtensionPoint(Class extensionPoint);
+}

Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistry.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImpl.java?view=auto&rev=525216
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImpl.java
(added)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImpl.java
Tue Apr  3 10:40:40 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.bootstrap;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A registry to hold all the extension points and extensions
+ * 
+ * @version $Rev$ $Date$
+ */
+public class ExtensionRegistryImpl implements ExtensionRegistry {
+    private Map<Class, List<Object>> extensions = new HashMap<Class, List<Object>>();
+
+    public <T> void addExtension(Class<T> extensionPoint, T extension) {
+        List<Object> list = extensions.get(extensionPoint);
+        if (list == null) {
+            list = new ArrayList<Object>();
+            extensions.put(extensionPoint, list);
+        }
+        if (!list.contains(extension)) {
+            list.add(extension);
+        }
+    }
+
+    public <T> T getExtension(Class<T> extensionPoint) {
+        List<Object> list = extensions.get(extensionPoint);
+        if (list == null || list.isEmpty()) {
+            return null;
+        } else {
+            return extensionPoint.cast(list.get(0));
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> List<T> getExtensions(Class<T> extensionPoint) {
+        return (List<T>)extensions.get(extensionPoint);
+    }
+
+    public <T> void removeExtension(Class<T> extensionPoint, T extension) {
+        List<T> list = getExtensions(extensionPoint);
+        if (list != null) {
+            list.remove(extension);
+        }
+    }
+
+    public void removeExtensionPoint(Class extensionPoint) {
+        extensions.remove(extensionPoint);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java?view=diff&rev=525216&r1=524305&r2=525216
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/component/scope/AbstractScopeContainer.java
Tue Apr  3 10:40:40 2007
@@ -59,127 +59,42 @@
         }
     };
 
-    private final Scope scope;
-    protected final ScopeContainerMonitor monitor;
-
     protected final Map<AtomicComponent<?>, URI> componentGroups =
         new ConcurrentHashMap<AtomicComponent<?>, URI>();
-
     protected final Map<KEY, URI> contextGroups = new ConcurrentHashMap<KEY, URI>();
 
+    // the queue of instanceWrappers to destroy, in the order that their instances were created
+    protected final Map<KEY, List<InstanceWrapper<?>>> destroyQueues =
+        new ConcurrentHashMap<KEY, List<InstanceWrapper<?>>>();
+
     // the queue of components to eagerly initialize in each group
     protected final Map<URI, List<AtomicComponent<?>>> initQueues =
         new HashMap<URI, List<AtomicComponent<?>>>();
 
-    // the queue of instanceWrappers to destroy, in the order that their instances were created
-    protected final Map<KEY, List<InstanceWrapper<?>>> destroyQueues =
-        new ConcurrentHashMap<KEY, List<InstanceWrapper<?>>>();
+    protected final ScopeContainerMonitor monitor;
+
+    private final Scope scope;
 
     public AbstractScopeContainer(Scope scope, ScopeContainerMonitor monitor) {
         this.scope = scope;
         this.monitor = monitor;
     }
 
-    public Scope getScope() {
-        return scope;
-    }
-
-    @Reference
-    public void setScopeRegistry(ScopeRegistry scopeRegistry) {
-        scopeRegistry.register(this);
-    }
-
-    @Init
-    public synchronized void start() {
-        int lifecycleState = getLifecycleState();
-        if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
-            throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state
[" + lifecycleState + "]");
-        }
-        setLifecycleState(RUNNING);
-    }
-
-    @Destroy
-    public synchronized void stop() {
-        int lifecycleState = getLifecycleState();
-        if (lifecycleState != RUNNING) {
-            throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]");
-        }
-        setLifecycleState(STOPPED);
-        componentGroups.clear();
-        contextGroups.clear();
-        synchronized (initQueues) {
-            initQueues.clear();
-        }
-        destroyQueues.clear();
-    }
-
     protected void checkInit() {
         if (getLifecycleState() != RUNNING) {
             throw new IllegalStateException("Scope container not running [" + getLifecycleState()
+ "]");
         }
     }
 
-    public void onEvent(Event event) {
-    }
-
-    public <T> void register(AtomicComponent<T> component, URI groupId) {
-        checkInit();
-        if (component.isEagerInit()) {
-            componentGroups.put(component, groupId);
-            synchronized (initQueues) {
-                List<AtomicComponent<?>> initQueue = initQueues.get(groupId);
-                if (initQueue == null) {
-                    initQueue = new ArrayList<AtomicComponent<?>>();
-                    initQueues.put(groupId, initQueue);
-                }
-                // FIXME it would be more efficient to binary search and then insert
-                initQueue.add(component);
-                Collections.sort(initQueue, COMPARATOR);
-            }
-        }
-    }
-
-    public <T> void unregister(AtomicComponent<T> component) {
-        if (component.isEagerInit()) {
-            URI groupId = componentGroups.remove(component);
-            synchronized (initQueues) {
-                List<AtomicComponent<?>> initQueue = initQueues.get(groupId);
-                initQueue.remove(component);
-                if (initQueue.isEmpty()) {
-                    initQueues.remove(groupId);
-                }
-            }
-        }
-    }
-
-    public void startContext(KEY contextId, URI groupId) throws GroupInitializationException
{
-        assert !contextGroups.containsKey(contextId);
-        contextGroups.put(contextId, groupId);
-        destroyQueues.put(contextId, new ArrayList<InstanceWrapper<?>>());
-
-        // get and clone initialization queue
-        List<AtomicComponent<?>> initQueue;
-        synchronized (initQueues) {
-            initQueue = initQueues.get(groupId);
-            if (initQueue != null) {
-                initQueue = new ArrayList<AtomicComponent<?>>(initQueue);
-            }
-        }
-        if (initQueue != null) {
-            initializeComponents(contextId, initQueue);
-        }
-    }
-
-    public void stopContext(KEY contextId) {
-        assert contextGroups.containsKey(contextId);
-        shutdownComponents(destroyQueues.get(contextId));
-        contextGroups.remove(contextId);
-        destroyQueues.remove(contextId);
-    }
-
-    public <T> InstanceWrapper<T> getWrapper(AtomicComponent<T> component,
KEY contextId)
-        throws TargetResolutionException {
-        return null;
+    /**
+     * Creates a new physical instance of a component, wrapped in an InstanceWrapper.
+     *
+     * @param component the component whose instance should be created
+     * @return a wrapped instance that has been injected but not yet started
+     * @throws TargetResolutionException if there was a problem creating the instance
+     */
+    protected <T> InstanceWrapper<T> createInstance(AtomicComponent<T>
component) throws TargetResolutionException {
+        return component.createInstanceWrapper();
     }
 
     public <T> InstanceWrapper<T> getAssociatedWrapper(AtomicComponent<T>
component, KEY contextId)
@@ -187,12 +102,13 @@
         return null;
     }
 
-    public <T> void returnWrapper(AtomicComponent<T> component, InstanceWrapper<T>
wrapper, KEY contextId)
-        throws TargetDestructionException {
+    public Scope getScope() {
+        return scope;
     }
 
-    public <T> void remove(AtomicComponent<T> component) throws PersistenceException
{
-        throw new UnsupportedOperationException("Scope does not support persistence");
+    public <T> InstanceWrapper<T> getWrapper(AtomicComponent<T> component,
KEY contextId)
+        throws TargetResolutionException {
+        return null;
     }
 
     /**
@@ -223,6 +139,39 @@
         }
     }
 
+    public void onEvent(Event event) {
+    }
+
+    public <T> void register(AtomicComponent<T> component, URI groupId) {
+        checkInit();
+        if (component.isEagerInit()) {
+            componentGroups.put(component, groupId);
+            synchronized (initQueues) {
+                List<AtomicComponent<?>> initQueue = initQueues.get(groupId);
+                if (initQueue == null) {
+                    initQueue = new ArrayList<AtomicComponent<?>>();
+                    initQueues.put(groupId, initQueue);
+                }
+                // FIXME it would be more efficient to binary search and then insert
+                initQueue.add(component);
+                Collections.sort(initQueue, COMPARATOR);
+            }
+        }
+    }
+
+    public <T> void remove(AtomicComponent<T> component) throws PersistenceException
{
+        throw new UnsupportedOperationException("Scope does not support persistence");
+    }
+
+    public <T> void returnWrapper(AtomicComponent<T> component, InstanceWrapper<T>
wrapper, KEY contextId)
+        throws TargetDestructionException {
+    }
+
+    @Reference
+    public void setScopeRegistry(ScopeRegistry scopeRegistry) {
+        scopeRegistry.register(this);
+    }
+
     /**
      * Shut down an ordered list of instances.
      * The list passed to this method is treated as a live, mutable list
@@ -248,18 +197,69 @@
         }
     }
 
+    @Init
+    public synchronized void start() {
+        int lifecycleState = getLifecycleState();
+        if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+            throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state
[" + lifecycleState + "]");
+        }
+        setLifecycleState(RUNNING);
+    }
+
+    public void startContext(KEY contextId, URI groupId) throws GroupInitializationException
{
+        assert !contextGroups.containsKey(contextId);
+        contextGroups.put(contextId, groupId);
+        destroyQueues.put(contextId, new ArrayList<InstanceWrapper<?>>());
+
+        // get and clone initialization queue
+        List<AtomicComponent<?>> initQueue;
+        synchronized (initQueues) {
+            initQueue = initQueues.get(groupId);
+            if (initQueue != null) {
+                initQueue = new ArrayList<AtomicComponent<?>>(initQueue);
+            }
+        }
+        if (initQueue != null) {
+            initializeComponents(contextId, initQueue);
+        }
+    }
+
+    @Destroy
+    public synchronized void stop() {
+        int lifecycleState = getLifecycleState();
+        if (lifecycleState != RUNNING) {
+            throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]");
+        }
+        setLifecycleState(STOPPED);
+        componentGroups.clear();
+        contextGroups.clear();
+        synchronized (initQueues) {
+            initQueues.clear();
+        }
+        destroyQueues.clear();
+    }
+
+    public void stopContext(KEY contextId) {
+        assert contextGroups.containsKey(contextId);
+        shutdownComponents(destroyQueues.get(contextId));
+        contextGroups.remove(contextId);
+        destroyQueues.remove(contextId);
+    }
+
     public String toString() {
         return "In state [" + super.toString() + ']';
     }
 
-    /**
-     * Creates a new physical instance of a component, wrapped in an InstanceWrapper.
-     *
-     * @param component the component whose instance should be created
-     * @return a wrapped instance that has been injected but not yet started
-     * @throws TargetResolutionException if there was a problem creating the instance
-     */
-    protected <T> InstanceWrapper<T> createInstance(AtomicComponent<T>
component) throws TargetResolutionException {
-        return component.createInstanceWrapper();
+    public <T> void unregister(AtomicComponent<T> component) {
+        if (component.isEagerInit()) {
+            URI groupId = componentGroups.remove(component);
+            synchronized (initQueues) {
+                List<AtomicComponent<?>> initQueue = initQueues.get(groupId);
+                initQueue.remove(component);
+                if (initQueue.isEmpty()) {
+                    initQueues.remove(groupId);
+                }
+            }
+        }
     }
 }

Copied: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
(from r524852, incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java?view=diff&rev=525216&p1=incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java&r1=524852&p2=incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java&r2=525216
==============================================================================
--- incubator/tuscany/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
(original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/AbstractRuntime.java
Tue Apr  3 10:40:40 2007
@@ -40,6 +40,7 @@
 import org.apache.tuscany.core.bootstrap.Bootstrapper;
 import org.apache.tuscany.core.bootstrap.DefaultBootstrapper;
 import org.apache.tuscany.core.bootstrap.ExtensionActivator;
+import org.apache.tuscany.core.bootstrap.ExtensionRegistry;
 import org.apache.tuscany.core.builder.ConnectorImpl;
 import org.apache.tuscany.core.component.ComponentManagerImpl;
 import org.apache.tuscany.core.component.SimpleWorkContext;
@@ -119,6 +120,7 @@
      * The ComponentManager that manages all components in this runtime.
      */
     protected ComponentManager componentManager;
+    protected ExtensionRegistry extensionRegistry;
 
     /**
      * Registry for ClassLoaders used by this runtime.
@@ -205,16 +207,17 @@
         // URI name = TUSCANY_SYSTEM_ROOT.resolve("main");
         Bootstrapper bootstrapper = createBootstrapper();
         Deployer deployer = bootstrapper.createDeployer();
+        this.extensionRegistry = bootstrapper.getExtensionRegistry();
+        
         registerSystemComponent(TUSCANY_DEPLOYER, Deployer.class, deployer);
         registerSystemComponent(WORK_CONTEXT_URI, WorkContext.class, new SimpleWorkContext());
 
         this.scopeRegistry = bootstrapper.getScopeRegistry();
-        
-        LoaderRegistry loaderRegistry = (LoaderRegistry)((DeployerImpl)deployer).getLoader();
-        BuilderRegistry builderRegistry = (BuilderRegistry)((DeployerImpl)deployer).getBuilder();
+
         activators = getInstances(getHostClassLoader(), ExtensionActivator.class);
+        ExtensionRegistry registry = bootstrapper.getExtensionRegistry();
         for (ExtensionActivator activator : activators) {
-            activator.start(loaderRegistry, builderRegistry);
+            activator.start(registry);
         }
 
         registerBaselineSystemComponents();
@@ -275,6 +278,7 @@
         try {
             JavaServiceContract<S> contract = new JavaServiceContract<S>(type);
             componentManager.registerJavaObject(uri, contract, component);
+            extensionRegistry.addExtension(type, component);
         } catch (RegistrationException e) {
             throw new InitializationException(e);
         }
@@ -333,16 +337,17 @@
         Enumeration<URL> urls = classLoader.getResources("META-INF/services/" + name);
         while (urls.hasMoreElements()) {
             URL url = urls.nextElement();
-            String service = getServiceName(url);
+            Set<String> service = getServiceNames(url);
             if (service != null) {
-                set.add(service);
+                set.addAll(service);
 
             }
         }
         return set;
     }
 
-    private static String getServiceName(URL url) throws IOException {
+    private static Set<String> getServiceNames(URL url) throws IOException {
+        Set<String> names = new HashSet<String>();
         InputStream is = IOHelper.getInputStream(url);
         BufferedReader reader = null;
         try {
@@ -351,8 +356,10 @@
                 String line = reader.readLine();
                 if (line == null) {
                     break;
-                } else if (!line.startsWith("#")) {
-                    return line.trim();
+                }
+                line = line.trim();
+                if (!line.startsWith("#") && !"".equals(line)) {
+                    names.add(line.trim());
                 }
             }
         } finally {
@@ -360,7 +367,7 @@
                 reader.close();
             }
         }
-        return null;
+        return names;
     }
 
     private static <T> Collection<T> getInstances(final ClassLoader classLoader,
Class<T> serviceClass) {

Added: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImplTestCase.java?view=auto&rev=525216
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImplTestCase.java
(added)
+++ incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImplTestCase.java
Tue Apr  3 10:40:40 2007
@@ -0,0 +1,40 @@
+package org.apache.tuscany.core.bootstrap;
+
+import junit.framework.TestCase;
+
+public class ExtensionRegistryImplTestCase extends TestCase {
+    private ExtensionRegistry registry;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        registry = new ExtensionRegistryImpl();
+    }
+
+    public void testRegistry() {
+        MyService service = new MyServiceImpl();
+        registry.addExtension(MyService.class, service);
+        assertSame(service, registry.getExtension(MyService.class));
+        assertEquals(1, registry.getExtensions(MyService.class).size());
+        MyService service2 = new MyServiceImpl();
+        registry.addExtension(MyService.class, service2);
+        assertSame(service, registry.getExtension(MyService.class));
+        assertEquals(2, registry.getExtensions(MyService.class).size());
+        registry.removeExtension(MyService.class, service);
+        assertSame(service2, registry.getExtension(MyService.class));
+        assertEquals(1, registry.getExtensions(MyService.class).size());
+        registry.removeExtensionPoint(MyService.class);
+        assertNull(registry.getExtension(MyService.class));
+    }
+
+    private static interface MyService {
+        void doSomething();
+    }
+
+    private static class MyServiceImpl implements MyService {
+
+        public void doSomething() {
+        }
+
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImplTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/bootstrap/ExtensionRegistryImplTestCase.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