You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2007/07/16 14:47:35 UTC

svn commit: r556606 - in /incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host: embedded/impl/ management/

Author: antelder
Date: Mon Jul 16 05:47:34 2007
New Revision: 556606

URL: http://svn.apache.org/viewvc?view=rev&rev=556606
Log:
Initial cut at start/stop/query componets for TUSCANY-1379

Added:
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentListener.java   (with props)
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentManager.java   (with props)
Modified:
    incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java

Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java?view=auto&rev=556606
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java Mon Jul 16 05:47:34 2007
@@ -0,0 +1,92 @@
+/*
+ * 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.host.embedded.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.core.runtime.ActivationException;
+import org.apache.tuscany.sca.host.management.ComponentListener;
+import org.apache.tuscany.sca.host.management.ComponentManager;
+
+public class ComponentManagerImpl implements ComponentManager {
+
+    protected List<ComponentListener> listeners = new ArrayList<ComponentListener>();
+    protected EmbeddedSCADomain domain;
+
+    public ComponentManagerImpl(EmbeddedSCADomain domain) {
+        this.domain = domain;
+    }
+
+    public void addComponentListener(ComponentListener listener) {
+        this.listeners.add(listener);
+    }
+
+    public void removeComponentListener(ComponentListener listener) {
+        this.listeners.remove(listener);
+    }
+
+    public Set<String> getComponentNames() {
+        return domain.getDomainCompositeHelper().getComponentNames();
+    }
+
+    public Component getComponent(String componentName) {
+        return domain.getDomainCompositeHelper().getComponent(componentName);
+    }
+
+    public void startComponent(String componentName) throws ActivationException {
+        Component component = domain.getDomainCompositeHelper().getComponent(componentName);
+        if (component == null) {
+            throw new IllegalArgumentException("no component: " + componentName);
+        }
+        domain.getDomainCompositeHelper().startComponent(component);
+    }
+
+    public void stopComponent(String componentName) throws ActivationException {
+        Component component = domain.getDomainCompositeHelper().getComponent(componentName);
+        if (component == null) {
+            throw new IllegalArgumentException("no component: " + componentName);
+        }
+        domain.getDomainCompositeHelper().stopComponent(component);
+    }
+
+    public void notifyComponentStarted(String componentName) {
+        for (ComponentListener listener : listeners) {
+            try {
+                listener.componentStarted(componentName);
+            } catch (Exception e) {
+                e.printStackTrace(); // TODO: log
+            }
+        }
+    }
+
+    public void notifyComponentStopped(String componentName) {
+        for (ComponentListener listener : listeners) {
+            try {
+                listener.componentStopped(componentName);
+            } catch (Exception e) {
+                e.printStackTrace(); // TODO: log
+            }
+        }
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/ComponentManagerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java?view=diff&rev=556606&r1=556605&r2=556606
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java Mon Jul 16 05:47:34 2007
@@ -54,6 +54,7 @@
     private ReallySmallRuntime runtime;
     private Map<String, Component> components = new HashMap<String, Component>();
     private DomainCompositeHelper domainCompositeHelper;
+    private ComponentManagerImpl componentManager = new ComponentManagerImpl(this);
     
     public class DomainCompositeHelper {
         
@@ -129,6 +130,7 @@
         public void startComponent(Component component) throws ActivationException {
             CompositeActivator compositeActivator = runtime.getCompositeActivator();
             compositeActivator.start(component);
+            componentManager.notifyComponentStarted(component.getName());
         }
         
         /**
@@ -139,6 +141,7 @@
         public void stopComponent(Component component) throws ActivationException {
             CompositeActivator compositeActivator = runtime.getCompositeActivator();
             compositeActivator.stop(component);
+            componentManager.notifyComponentStopped(component.getName());
         }        
         
         /**
@@ -199,6 +202,9 @@
     }
     
     public DomainCompositeHelper getDomainCompositeHelper() {
+        if (domainCompositeHelper == null) {
+            throw new IllegalStateException("domain not started");
+        }
         return domainCompositeHelper;
     }
     

Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentListener.java?view=auto&rev=556606
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentListener.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentListener.java Mon Jul 16 05:47:34 2007
@@ -0,0 +1,29 @@
+/*
+ * 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.host.management;
+
+import java.util.EventListener;
+
+public interface ComponentListener extends EventListener {
+    
+    void componentStarted(String componentName);
+    void componentStopped(String componentName);
+
+}

Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentListener.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentManager.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentManager.java?view=auto&rev=556606
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentManager.java (added)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentManager.java Mon Jul 16 05:47:34 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.host.management;
+
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.core.runtime.ActivationException;
+
+public interface ComponentManager {
+
+    Set<String> getComponentNames();
+
+    Component getComponent(String componentName);
+
+    void startComponent(String componentName) throws ActivationException;
+
+    void stopComponent(String componentName) throws ActivationException;
+
+    void addComponentListener(ComponentListener listener);
+
+    void removeComponentListener(ComponentListener listener);
+    
+}

Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/management/ComponentManager.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