summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management')
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentListener.java29
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentManager.java43
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentInfo.java32
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentListener.java31
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentManager.java43
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentManagerService.java36
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentInfoImpl.java45
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentManagerImpl.java105
-rw-r--r--sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentManagerServiceImpl.java66
9 files changed, 430 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentListener.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentListener.java
new file mode 100644
index 0000000000..452f1a1ab1
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentListener.java
@@ -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.embedded.management;
+
+import java.util.EventListener;
+
+public interface ComponentListener extends EventListener {
+
+ void componentStarted(String componentName);
+ void componentStopped(String componentName);
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentManager.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentManager.java
new file mode 100644
index 0000000000..57b6a6d746
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/ComponentManager.java
@@ -0,0 +1,43 @@
+/*
+ * 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.management;
+
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+
+public interface ComponentManager {
+
+ Set<String> getComponentNames();
+
+ Component getComponent(String componentName);
+
+ boolean isComponentStarted(String componentName);
+
+ void startComponent(String componentName) throws ActivationException;
+
+ void stopComponent(String componentName) throws ActivationException;
+
+ void addComponentListener(ComponentListener listener);
+
+ void removeComponentListener(ComponentListener listener);
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentInfo.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentInfo.java
new file mode 100644
index 0000000000..1b835d1ba6
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentInfo.java
@@ -0,0 +1,32 @@
+/*
+ * 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.management.variation;
+
+public interface ComponentInfo {
+
+ public String getName();
+
+ public void setName(String name);
+
+ public boolean isStarted();
+
+ public void setStarted(boolean started);
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentListener.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentListener.java
new file mode 100644
index 0000000000..f117304a81
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentListener.java
@@ -0,0 +1,31 @@
+/*
+ * 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.management.variation;
+
+import java.util.EventListener;
+
+import org.apache.tuscany.sca.assembly.Component;
+
+public interface ComponentListener extends EventListener {
+
+ void componentStarted(Component component);
+ void componentStopped(Component component);
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentManager.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentManager.java
new file mode 100644
index 0000000000..399d30836f
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentManager.java
@@ -0,0 +1,43 @@
+/*
+ * 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.management.variation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+
+public interface ComponentManager {
+
+ List<Component> getComponents();
+
+ Component getComponent(String componentName);
+
+ boolean isComponentStarted(Component component);
+
+ void startComponent(Component component) throws ActivationException;
+
+ void stopComponent(Component component) throws ActivationException;
+
+ void addComponentListener(ComponentListener listener);
+
+ void removeComponentListener(ComponentListener listener);
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentManagerService.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentManagerService.java
new file mode 100644
index 0000000000..547e4c13d2
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/ComponentManagerService.java
@@ -0,0 +1,36 @@
+/*
+ * 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.management.variation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+
+public interface ComponentManagerService {
+
+ List<ComponentInfo> getComponentInfos();
+
+ ComponentInfo getComponentInfo(String componentName);
+
+ void startComponent(String componentName) throws ActivationException;
+
+ void stopComponent(String componentName) throws ActivationException;
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentInfoImpl.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentInfoImpl.java
new file mode 100644
index 0000000000..76b8c866fc
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentInfoImpl.java
@@ -0,0 +1,45 @@
+/*
+ * 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.management.variation.impl;
+
+import org.apache.tuscany.sca.host.embedded.management.variation.ComponentInfo;
+
+public class ComponentInfoImpl implements ComponentInfo {
+
+ private String name;
+ private boolean started;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isStarted() {
+ return started;
+ }
+
+ public void setStarted(boolean started) {
+ this.started = started;
+ }
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentManagerImpl.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentManagerImpl.java
new file mode 100644
index 0000000000..384122e1d3
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentManagerImpl.java
@@ -0,0 +1,105 @@
+/*
+ * 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.management.variation.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+import org.apache.tuscany.sca.core.assembly.RuntimeComponentImpl;
+import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
+import org.apache.tuscany.sca.host.embedded.management.variation.ComponentListener;
+import org.apache.tuscany.sca.host.embedded.management.variation.ComponentManager;
+
+public class ComponentManagerImpl implements ComponentManager {
+
+ protected List<ComponentListener> listeners = new CopyOnWriteArrayList<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 Component getComponent(String componentName) {
+ for (Composite composite: domain.getDomainComposite().getIncludes()) {
+ for (Component component: composite.getComponents()) {
+ if (component.getName().equals(componentName)) {
+ return component;
+ }
+ }
+ }
+ return null;
+ }
+
+ public List<Component> getComponents() {
+ List<Component> components = new ArrayList<Component>();
+ for (Composite composite: domain.getDomainComposite().getIncludes()) {
+ components.addAll(composite.getComponents());
+ }
+ return components;
+ }
+
+ public void startComponent(Component component) throws ActivationException {
+ domain.getCompositeActivator().start(component);
+ notifyComponentStarted(component);
+ }
+
+ public void stopComponent(Component component) throws ActivationException {
+ domain.getCompositeActivator().stop(component);
+ notifyComponentStopped(component);
+ }
+
+ public void notifyComponentStarted(Component component) {
+ for (ComponentListener listener : listeners) {
+ try {
+ listener.componentStarted(component);
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO: log
+ }
+ }
+ }
+
+ public void notifyComponentStopped(Component component) {
+ for (ComponentListener listener : listeners) {
+ try {
+ listener.componentStopped(component);
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO: log
+ }
+ }
+ }
+
+ public boolean isComponentStarted(Component component) {
+ RuntimeComponentImpl runtimeComponent = (RuntimeComponentImpl)component;
+ return runtimeComponent.isStarted();
+ }
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentManagerServiceImpl.java b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentManagerServiceImpl.java
new file mode 100644
index 0000000000..cb05c28841
--- /dev/null
+++ b/sca-java-1.x/tags/0.99-incubating/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/management/variation/impl/ComponentManagerServiceImpl.java
@@ -0,0 +1,66 @@
+/*
+ * 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.management.variation.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.core.assembly.ActivationException;
+import org.apache.tuscany.sca.host.embedded.management.variation.ComponentInfo;
+import org.apache.tuscany.sca.host.embedded.management.variation.ComponentManager;
+import org.apache.tuscany.sca.host.embedded.management.variation.ComponentManagerService;
+
+public class ComponentManagerServiceImpl implements ComponentManagerService {
+
+ private ComponentManager componentManager;
+
+ public ComponentManagerServiceImpl(ComponentManager componentManager) {
+ this.componentManager = componentManager;
+ }
+
+ public List<ComponentInfo> getComponentInfos() {
+ List<ComponentInfo> componentInfos = new ArrayList<ComponentInfo>();
+ for (Component component: componentManager.getComponents()) {
+ ComponentInfo componentInfo = new ComponentInfoImpl();
+ componentInfo.setName(component.getName());
+ componentInfo.setStarted(componentManager.isComponentStarted(component));
+ componentInfos.add(componentInfo);
+ }
+ return componentInfos;
+ }
+
+ public ComponentInfo getComponentInfo(String componentName) {
+ Component component = componentManager.getComponent(componentName);
+ ComponentInfo componentInfo = new ComponentInfoImpl();
+ componentInfo.setName(component.getName());
+ componentInfo.setStarted(componentManager.isComponentStarted(component));
+ return componentInfo;
+ }
+
+ public void startComponent(String componentName) throws ActivationException {
+ componentManager.startComponent(componentManager.getComponent(componentName));
+ }
+
+ public void stopComponent(String componentName) throws ActivationException {
+ componentManager.stopComponent(componentManager.getComponent(componentName));
+ }
+
+}