View Javadoc

1   /*
2    Copyright (C) 2007 Grid Systems, S.A.
3   
4    This library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8   
9    This library is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   Lesser General Public License for more details.
13  
14   You should have received a copy of the GNU Lesser General Public
15   License along with this library; if not, write to the Free Software
16   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
17  */
18  package nextgrid.api.env;
19  
20  import java.io.Serializable;
21  import java.net.URI;
22  import java.util.Collection;
23  import java.util.List;
24  import java.util.Map;
25  
26  import nextgrid.api.pem.POMListener;
27  
28  /**
29   * Provides environment context and services to the processes involved in
30   * a workflow enaction.
31   * <p>
32   * It also provides control and monitoring operations for the enaction user.
33   *
34   * @author Rodrigo Ruiz
35   */
36  public interface ProcessEnvironment extends Serializable {
37  
38    // ==========================================================================
39    // Discoverers management
40    // ==========================================================================
41  
42    /**
43     * Gets the discoverer instances registered in this environment.
44     *
45     * @return A list of discoverers
46     */
47    List<ProcessDiscoverer> getDiscoverers();
48  
49    /**
50     * Gets a discoverer for the specified process id.
51     * <p>
52     * The selection of the appropriate instance is up to the implementation.
53     *
54     * @param id A process id
55     * @return A discoverer
56     * @throws DiscoveryException If an error occurs selecting a discoverer
57     */
58    ProcessDiscoverer getDiscovererFor(URI id) throws DiscoveryException;
59  
60    /**
61     * Sets the discoverer associated to a given URI.
62     *
63     * @param id          A process id
64     * @param discoverer  A discoverer instance
65     */
66    void setDiscovererFor(URI id, ProcessDiscoverer discoverer);
67  
68    /**
69     * Sets the discoverer instance associated to all processes without
70     * an explicit one.
71     *
72     * @param discoverer A discoverer instance
73     */
74    void setDefaultDiscoverer(ProcessDiscoverer discoverer);
75  
76    // ==========================================================================
77    // Prioritisers management
78    // ==========================================================================
79  
80    /**
81     * Gets the prioritiser instances.
82     *
83     * @return A list of prioritisers
84     */
85    List<Prioritiser> getPrioritisers();
86  
87    /**
88     * Gets a prioritiser for the specified process id.
89     * <p>
90     * The selection of the appropriate instance is up to the implementation.
91     *
92     * @param id A process id
93     * @return A prioritiser
94     */
95    Prioritiser getPrioritiserFor(URI id);
96  
97    /**
98     * Sets the prioritiser associated to a given URI.
99     *
100    * @param id           A process id
101    * @param prioritiser  A prioritiser instance
102    */
103   void setPrioritiser(URI id, Prioritiser prioritiser);
104 
105   /**
106    * Sets the prioritiser instance associated to all processes without
107    * an explicit one.
108    *
109    * @param prioritiser A prioritiser instance
110    */
111   void setDefaultPrioritiser(Prioritiser prioritiser);
112 
113   // ==========================================================================
114   // Selectors management
115   // ==========================================================================
116 
117   /**
118    * Gets the selector instances registered in this environment.
119    *
120    * @return A list of selectors
121    */
122   List<ProcessSelector> getSelectors();
123 
124   /**
125    * Gets a selector for the specified process id.
126    * <p>
127    * The selection of the appropriate instance is up to the implementation.
128    *
129    * @param id A process id
130    * @return A selector
131    */
132   ProcessSelector getSelectorFor(URI id);
133 
134   /**
135    * Sets the selector associated to a given URI.
136    *
137    * @param id        A process id
138    * @param selector  A selector instance
139    */
140   void setSelectorFor(URI id, ProcessSelector selector);
141 
142   /**
143    * Sets the selector instance associated to all processes without
144    * an explicit one.
145    *
146    * @param selector A selector instance
147    */
148   void setDefaultSelector(ProcessSelector selector);
149 
150   // ==========================================================================
151   // Security management
152   // added by Nikolaos Matskanis, IT Innovation
153   // ==========================================================================
154 
155   /**
156    * Gets the security module.
157    * <p>
158    * The security token service client module implementation.
159    *
160    * @return Security module instance
161    */
162   STSModule getSTSModule();
163 
164   /**
165    * Sets the security module implementation.
166    *
167    * @param stsmod  A STS module instance
168    */
169   void setSTSModule(STSModule stsmod);
170 
171   // ==========================================================================
172   // Listeners management
173   // ==========================================================================
174 
175   /**
176    * Adds one or more listeners to a given process.
177    *
178    * @param id        The id of the Process to attach these listeners to
179    * @param listeners The listeners to attach
180    */
181   void addListenersFor(URI id, POMListener... listeners);
182 
183   /**
184    * Gets a collection of listeners to be attached to the given Process id.
185    *
186    * @param id The id of the Process
187    * @return A collection of listeners
188    */
189   Collection<POMListener> getListenersFor(URI id);
190 
191   /**
192    * Removes one or more listeners from the attachment map.
193    *
194    * @param id        The id of the Process to detach these listeners from
195    * @param listeners The listeners to detach
196    */
197   void removeListenersFrom(URI id, POMListener... listeners);
198 
199   /**
200    * Clears all listeners registered in this environment instance.
201    */
202   void clearListeners();
203 
204   /**
205    * Clears all listeners registered for a given Process in this environment
206    * instance.
207    *
208    * @param id The id of the Process
209    */
210   void clearListenersFor(URI id);
211 
212   /**
213    * Registers an arbitrary object in any collection it fits in. The interfaces
214    * <tt>obj</tt> implements will determine in which collections it is set.
215    * <p>
216    * If the object does not implement any relevant interface, nothing should
217    * be done. In particular, exceptions should never be thrown.
218    *
219    * @param id  The Process URI to associate the component to
220    * @param obj Component
221    */
222   void setComponentFor(URI id, Object obj);
223 
224 
225   // ==========================================================================
226   // Attribute management
227   // ==========================================================================
228 
229   /**
230    * Gets an environment attribute value.
231    *
232    * @param name Attribute name
233    * @return Attribute value
234    */
235   Serializable getAttribute(String name);
236 
237   /**
238    * Sets an environment attribute value.
239    *
240    * @param name  Attribute name
241    * @param value Attribute value
242    */
243   void setAttribute(String name, Serializable value);
244 
245   /**
246    * Gets a map containing all attributes.
247    *
248    * @return A map with all attributes in this environment
249    */
250   Map<String, Serializable> getAttributes();
251 }