fe83e85709c8083526dbc81873836815a85ec066
[utils] / system / general / src / main / java / org / wamblee / system / core / Scope.java
1 /*
2  * Copyright 2008 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 the 
22  * started components and is (usually) the result of 
23  * starting a container. 
24  * 
25  * @author Erik Brakkee
26  */
27 public interface Scope {
28         
29         /**
30          * Gets the provided interfaces by this scope. 
31          * @return Provided interfaces. 
32          */
33         List<ProvidedInterface> getProvidedInterfaces();
34         
35         /**
36          * Adds a key value pair to the scope. 
37          * @param aKey Key 
38          * @param aValue Value. 
39          */
40         void put(String aKey, Object aValue); 
41         
42         /**
43          * Retrieves a value for the key. 
44          * @param aKey Key.
45          * @return Value. 
46          */
47         Object get(String aKey);
48         
49         /**
50          * Adds the runtime of a started component. 
51          * @param aComponent Component. 
52          * @param aRuntime Runtime. 
53          */
54         void addRuntime(Component aComponent, Object aRuntime);
55         
56         /**
57          * Publishes an implementation of a provided interface. 
58          * @param aInterface Interface that is provided.
59          * @param aImplementation Implementation of the interface.  
60          */
61         void publishInterface(ProvidedInterface aInterface, Object aImplementation); 
62         
63         /**
64          * Retrieves an implementation of a provided interface. 
65          * @param aProvided P
66          * rovided interface. If it is null then null is returned.  
67          * @param aType Type of implementation that is expected.
68          * @return Retrieved interface.
69          */
70         <T> T getInterfaceImplementation(ProvidedInterface aProvided, Class<T> aType );
71
72         /**
73          * Gets the runtime for a component.  
74          * @param aComponent Component for which we want to get the runtime.  
75          * @return Runtime.  
76          */
77         Object getRuntime(Component aComponent);
78         
79         /**
80          * Gets the runtime for a component based on the name of the component
81          * (excluding its context). 
82          * @param aName Component name. 
83          * @return Component name. 
84          */
85         Object getRuntime(String aName);
86 }