2 * Copyright 2008 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;
19 * A scope represents a set of running services and the runtime information for the
20 * started components and is (usually) the result of
21 * starting a container.
23 * @author Erik Brakkee
25 public interface Scope {
28 * Gets the provided interfaces by this scope.
29 * @return Provided interfaces.
31 ProvidedInterface[] getProvidedInterfaces();
34 * Adds a key value pair to the scope.
36 * @param aValue Value.
38 void put(String aKey, Object aValue);
41 * Retrieves a value for the key.
45 Object get(String aKey);
48 * Adds the runtime of a started component.
49 * @param aComponent Component.
50 * @param aRuntime Runtime.
52 void addRuntime(Component aComponent, Object aRuntime);
55 * Publishes an implementation of a provided interface.
56 * @param aComponent Component that provides the interface.
57 * @param aInterface Interface that is provided.
58 * @param aImplementation Implementation of the interface.
59 * @return Returns a unique id of the published interface.
61 void publishInterface(ProvidedInterface aInterface, Object aImplementation);
64 * Retrieves an implementation of a provided interface.
65 * @param aProvided Provided interface. If it is null then null is returned.
66 * @param aType Type of implementation that is expected.
67 * @return Retrieved interface.
69 <T> T retrieveInterfaceImplementation(ProvidedInterface aProvided, Class<T> aType );
72 * Gets the runtime for a component.
73 * @param aComponent Component for which we want to get the runtime.
76 Object getRuntime(Component aComponent);