(no commit message)
[utils] / system / general / src / main / java / org / wamblee / system / core / Scope.java
1 /*
2  * Copyright 2005-2010 the original author or authors.
3  * 
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
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
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.
15  */
16 package org.wamblee.system.core;
17
18 import java.util.List;
19
20 /**
21  * A scope represents a set of running services and the runtime information for
22  * the started components and is (usually) the result of starting a container.
23  * 
24  * @author Erik Brakkee
25  */
26 public interface Scope {
27     /**
28      * Gets the provided interfaces by this scope.
29      * 
30      * @return Provided interfaces.
31      */
32     List<ProvidedInterface> getProvidedInterfaces();
33
34     /**
35      * Adds a key value pair to the scope.
36      * 
37      * @param aKey
38      *            Key
39      * @param aValue
40      *            Value.
41      */
42     void put(String aKey, Object aValue);
43
44     /**
45      * Retrieves a value for the key.
46      * 
47      * @param aKey
48      *            Key.
49      * 
50      * @return Value.
51      */
52     Object get(String aKey);
53
54     /**
55      * Adds the runtime of a started component.
56      * 
57      * @param aComponent
58      *            Component.
59      * @param aRuntime
60      *            Runtime.
61      */
62     void addRuntime(Component aComponent, Object aRuntime);
63
64     /**
65      * Publishes an implementation of a provided interface.
66      * 
67      * @param aInterface
68      *            Interface that is provided.
69      * @param aImplementation
70      *            Implementation of the interface.
71      */
72     void publishInterface(ProvidedInterface aInterface, Object aImplementation);
73
74     <T> T getInterfaceImplementation(ProvidedInterface aProvided, Class<T> aType);
75
76     /**
77      * Gets the runtime for a component.
78      * 
79      * @param aComponent
80      *            Component for which we want to get the runtime.
81      * 
82      * @return Runtime.
83      */
84     Object getRuntime(Component aComponent);
85
86     /**
87      * Gets the runtime for a component based on the name of the component
88      * (excluding its context).
89      * 
90      * @param aName
91      *            Component name.
92      * 
93      * @return Component name.
94      */
95     Object getRuntime(String aName);
96 }