(no commit message)
[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 /**
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. 
22  * 
23  * @author Erik Brakkee
24  */
25 public interface Scope {
26         
27         /**
28          * Gets the provided interfaces by this scope. 
29          * @return Provided interfaces. 
30          */
31         ProvidedInterface[] getProvidedInterfaces();
32         
33         /**
34          * Adds a key value pair to the scope. 
35          * @param aKey Key 
36          * @param aValue Value. 
37          */
38         void put(String aKey, Object aValue); 
39         
40         /**
41          * Retrieves a value for the key. 
42          * @param aKey Key.
43          * @return Value. 
44          */
45         Object get(String aKey);
46         
47         /**
48          * Adds the runtime of a started component. 
49          * @param aComponent Component. 
50          * @param aRuntime Runtime. 
51          */
52         void addRuntime(Component aComponent, Object aRuntime);
53         
54         /**
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.  
60          */
61         void publishInterface(ProvidedInterface aInterface, Object aImplementation); 
62         
63         /**
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.
68          */
69         <T> T retrieveInterfaceImplementation(ProvidedInterface aProvided, Class<T> aType );
70
71         /**
72          * Gets the runtime for a component.  
73          * @param aComponent Component for which we want to get the runtime.  
74          * @return Runtime.  
75          */
76         Object getRuntime(Component aComponent); 
77 }