1 /*
2 * Copyright (c) 2007, Fraunhofer-Gesellschaft
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * (1) Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the disclaimer at the end.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * (2) Neither the name of Fraunhofer nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * DISCLAIMER
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
35 package org.ogf.graap.wsag.api;
36
37 import java.util.Map;
38 import java.util.Observer;
39
40 import org.apache.xmlbeans.XmlObject;
41 import org.ogf.schemas.graap.wsAgreement.AgreementContextType;
42 import org.ogf.schemas.graap.wsAgreement.AgreementPropertiesType;
43 import org.ogf.schemas.graap.wsAgreement.AgreementStateType;
44 import org.ogf.schemas.graap.wsAgreement.GuaranteeTermStateType;
45 import org.ogf.schemas.graap.wsAgreement.ServiceTermStateType;
46 import org.ogf.schemas.graap.wsAgreement.TermTreeType;
47 import org.ogf.schemas.graap.wsAgreement.TerminateInputType;
48
49 /**
50 * Agreement interface used by the server module. It provides the required methods to access the properties of
51 * the agreement and to terminate the agreement instance. Moreover, it provides access to the domains-specific
52 * agreement implementation via the {@link #getAgreementInstance()} method.
53 *
54 * @see AgreementFactory
55 * @author Oliver Waeldrich
56 */
57 public interface Agreement
58 {
59
60 // definitions from the ArgreementPortType
61
62 /**
63 * Returns the agreement name.
64 *
65 * @return the agreement name
66 */
67 String getName();
68
69 /**
70 * Returns the agreement id.
71 *
72 * @return the agreement id
73 */
74 String getAgreementId();
75
76 // /**
77 // * Returns a domain-specific agreement implementation. The {@link AbstractAgreementType} implements the
78 // * domain-specific termination method and stored the agreement properties. The
79 // * {@link AbstractAgreementType#getXMLObject()} returns the actual properties of an agreement
80 // * implementation. These properties must be valid at all time, i.e. if an agreement implementation
81 // * overrides the {@link #getState()} method the implementation must make sure that the agreement
82 // * properties are updated with the returned state.
83 // *
84 // * @return the agreement implementation
85 // */
86 // AbstractAgreementType getAgreementInstance();
87
88 /**
89 * @return the agreement context
90 */
91 AgreementContextType getContext();
92
93 /**
94 * @return the agreement terms
95 */
96 TermTreeType getTerms();
97
98 /**
99 * Terminates an agreement.
100 *
101 * @param reason
102 * termination reason
103 */
104 void terminate( TerminateInputType reason );
105
106 // definitions from the ArgreementStatePortType
107
108 /**
109 * @return the agreement state
110 */
111 AgreementStateType getState();
112
113 /**
114 * @return the agreement guarantee term states
115 */
116 GuaranteeTermStateType[] getGuaranteeTermStates();
117
118 /**
119 * @return the agreement service term states
120 */
121 ServiceTermStateType[] getServiceTermStates();
122
123 /**
124 * Validates the resource properties document of this instance.
125 *
126 * @return true if the resource properties document is valid, otherwise false.
127 */
128 boolean validate();
129
130 /**
131 * This method allows an agreement instance to get notified after reload. An invocation of the
132 * {@link #notifyReload(Map)} method sets the execution context (see {@link #getExecutionContext()}) of
133 * the agreement and invokes the {@link #notifyReinitialized(Map)} method of this agreement instance.
134 *
135 * @param executionCtx
136 * the current execution context
137 */
138 void notifyReload( Map<String, XmlObject> executionCtx );
139
140 /**
141 * Sets the ID of the agreement.
142 *
143 * @param agreementId
144 * the agreement id to set
145 */
146 void setAgreementId( String agreementId );
147
148 /**
149 * Sets the context of the agreement.
150 *
151 * @param context
152 * the agreement context to set
153 */
154 void setContext( AgreementContextType context );
155
156 /**
157 * Sets the name of the agreement.
158 *
159 * @param name
160 * the agreement name to set
161 */
162 void setName( String name );
163
164 /**
165 * Sets the terms of the agreement.
166 *
167 * @param terms
168 * the agreement terms to set
169 */
170 void setTerms( TermTreeType terms );
171
172 /**
173 * Sets the state of the agreement.
174 *
175 * @param agreementState
176 * the agreement state to set
177 */
178 void setState( AgreementStateType agreementState );
179
180 /**
181 * Sets the guarantee term states of the agreement.
182 *
183 * @param guaranteeTermStateList
184 * the guarantee term states to set
185 */
186 void setGuaranteeTermStates( GuaranteeTermStateType[] guaranteeTermStateList );
187
188 /**
189 * Sets the service term states of the agreement.
190 *
191 * @param serviceTermStateList
192 * the service term states to set
193 */
194 void setServiceTermStates( ServiceTermStateType[] serviceTermStateList );
195
196 /**
197 * Returns the agreement properties as {@link XmlObject}.
198 *
199 * @return an XML representation of the agreement properties document
200 */
201 AgreementPropertiesType getXMLObject();
202
203 /**
204 * Sets the properties for this agreement explicitly.
205 *
206 * @param properties
207 * the agreement properties to set
208 */
209 void setXmlObject( AgreementPropertiesType properties );
210
211 /**
212 * Returns the persisted execution context for this agreement.
213 *
214 * @return the agreement persisted execution context
215 */
216 Map<String, XmlObject> getExecutionContext();
217
218 /**
219 * Returns the transient execution context for this agreement.
220 *
221 * @return the agreement transient execution context
222 */
223 Map<String, Object> getTransientExecutionContext();
224
225 /**
226 * Returns the class of the agreement implementation.
227 *
228 * @return the implementation class
229 */
230 Class<?> getImplementationClass();
231
232 /**
233 * Adds a new observer to an agreement that gets notified of agreement state changes.
234 *
235 * @param o
236 * the observer
237 *
238 * @see java.util.Observable#addObserver(java.util.Observer)
239 */
240 void addObserver( Observer o );
241
242 /**
243 *
244 * @see java.util.Observable#notifyObservers()
245 */
246 void notifyObservers();
247
248 /**
249 * Notifies all registered observer of an agreement's state change.
250 *
251 * @param arg
252 * notification message
253 *
254 * @see java.util.Observable#notifyObservers(java.lang.Object)
255 */
256 void notifyObservers( Object arg );
257
258 /**
259 * Returns true if the content of the agreement has changed, otherwise false.
260 *
261 * @return true if the agreement has changed, i.e. runtime state was updated
262 *
263 * @see java.util.Observable#hasChanged()
264 */
265 boolean hasChanged();
266
267 }