2 * Copyright 2005-2010 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.system.core;
18 import java.util.List;
21 * A component represents a part of a system that requires a number of
22 * interfaces and provides a number of interfaces.
24 * The component interface provides the meta-data for a component. After calling
25 * {@link #start(Scope)}, an actual runtime representation of the component can
26 * be created which is independent of this component. As a special case, the
27 * runtime representation may be identical to the component instance but in
28 * general it is not. This allows a component to be used as a factory for
32 * @author Erik Brakkee
34 public interface Component<Type> {
36 * Gets the name of the subsystem.
38 * @return Subsystem name.
43 * Prepends the context with a super context.
46 void addContext(String aContext);
51 * @return Context or null if not set.
56 * Gets the fully qualified name of the component which includes the context
57 * of the component. This method can only be used after the component has
60 * @return Qualified name.
62 String getQualifiedName();
65 * Gets a description of the provided interfaces.
67 * @return Provided interfaces.
69 List<ProvidedInterface> getProvidedInterfaces();
72 * Gets a description of the required interfaces.
74 * @return Required interfaces.
76 List<RequiredInterface> getRequiredInterfaces();
79 * Initialises the subsystem by starting all the services that it described
83 * Scope with external interface implementations that are
84 * available. The component must publish its runtime and its
85 * provided interfaces in this scope.
87 * @return Gets an object representing the runtime of the component.
89 Type start(Scope aScope);
95 * THe runtime part of the component.
97 void stop(Type aRuntime);