Package rename org.wamblee.system to org.wamblee.system.core
[utils] / system / general / src / main / java / org / wamblee / system / core / Component.java
diff --git a/system/general/src/main/java/org/wamblee/system/core/Component.java b/system/general/src/main/java/org/wamblee/system/core/Component.java
new file mode 100644 (file)
index 0000000..b9b5dad
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2007 the original author or authors.
+ * 
+ * Licensed 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.wamblee.system.core;
+
+/**
+ * A component represents a part of a system that requires a 
+ * number of interfaces and provides a number of interfaces. 
+ *
+ * @author Erik Brakkee
+ */
+public interface Component {
+       
+       enum Status { 
+               NOT_STARTED, RUNNING, STOPPED
+       }
+       
+       /**
+        * Gets the status of the component. 
+        * @return Status. 
+        */
+       Status getStatus();
+       
+       /**
+        * Gets the name of the subsystem.
+        * @return Subsystem name. 
+        */
+       String getName();
+       
+       /**
+        * Prepends the context with a super context. 
+        */
+       void addContext(String aContext);
+       
+       /**
+        * Gets the fully qualified name of the component which includes
+        * the context of the component.  
+        * This method can only be used after the component has started.
+        * @return Qualified name. 
+        */
+       String getQualifiedName(); 
+
+       /**
+        * Gets a description of the provided interfaces. 
+        * @return Provided interfaces. 
+        */
+       ProvidedInterface[] getProvidedServices();
+       
+       /**
+        * Gets a description of the required interfaces. 
+        * @return Required interfaces. 
+        */
+       RequiredInterface[] getRequiredServices();
+
+       
+       /**
+        * Initialises the subsytem by starting all the services that
+        * it described as provided. 
+        */
+       void start();
+       
+       /**
+        * Stops a subsystem. 
+        */
+       void stop(); 
+       
+       /**
+        * Gets the list of running services in the subsystem. 
+        * 
+        * This method may only be called after the
+        * {@link #initialize(String, Service[])} has been called. 
+        * @return
+        */
+       ProvidedInterface[] getRunningServices();
+}