View Javadoc

1   /*
2    wsmo4j extension - a Choreography API and Reference Implementation
3   
4    Copyright (c) 2005, University of Innsbruck, Austria
5   
6    This library is free software; you can redistribute it and/or modify it under
7    the terms of the GNU Lesser General Public License as published by the Free
8    Software Foundation; either version 2.1 of the License, or (at your option)
9    any later version.
10   This library is distributed in the hope that it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13   details.
14   You should have received a copy of the GNU Lesser General Public License along
15   with this library; if not, write to the Free Software Foundation, Inc.,
16   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17   */
18  
19  package org.wsmo.factory;
20  
21  import java.util.*;
22  
23  import org.omwg.logicalexpression.*;
24  import org.omwg.ontology.*;
25  import org.wsmo.common.*;
26  import org.wsmo.common.exception.InvalidModelException;
27  import org.wsmo.service.choreography.*;
28  import org.wsmo.service.choreography.rule.*;
29  import org.wsmo.service.rule.*;
30  import org.wsmo.service.signature.*;
31  
32  /**
33   * Factory for creating <code>Choreographies</code>. Nested inner interfaces
34   * are used in combination with public fields to create a pseudo-namespace
35   * mechanism, which groups the objects that are created by this factory in a
36   * type safe way using the reference type of the inner interfaces. It is also
37   * safe for the fields to be public since they're final. Inner interfaces create
38   * a new reference type like a any other top-level interface, which let
39   * code-completion IDEs work with the exposed fields. It also allows the client
40   * programmer to either keep a reference to the main factory around or
41   * references to the individual subfactories, which is usefull if subsystems
42   * exist in the client programmers code that need/should create only a certain
43   * type of objects.
44   * 
45   * Note that it is ok for the inner interface names to be in plural, unlike most
46   * singularily named top-level interfaces including
47   * <code>ChoreographyFactory</code>.
48   * 
49   * <pre>
50   *         Created on Jul 26, 2005
51   *         Committed by $Author: vassil_momtchev $
52   *         $Source$
53   * </pre>
54   * 
55   * @author James Scicluna
56   * @author Thomas Haselwanter
57   * @author Holger Lausen
58   * 
59   * @version $Revision: 1844 $ $Date: 2006-10-24 17:11:48 +0300 (Tue, 24 Oct 2006) $
60   */
61  public abstract class ChoreographyFactory {
62  
63      public interface Containers {
64          public Choreography createChoreography(Identifier id);
65  
66          public Choreography createChoreography(Identifier id, StateSignature signature, ChoreographyRules rules);
67  
68          public StateSignature createStateSignature(Identifier id);
69  
70          public StateSignature createStateSignature(Identifier id, Set<In> inMode, Set<Out> outMode,
71                  Set<Shared> sharedMode, Set<Static> staticMode, Set<Controlled> controlledMode);
72  
73          public ChoreographyRules createRules(Identifier id);
74  
75          public ChoreographyRules createRules(Identifier id, Set<ChoreographyRule> rules);
76      }
77  
78      public interface TransitionRules {
79  
80          public Condition createConditionFromLogicalExpression(LogicalExpression e) throws InvalidModelException;
81  
82          public ChoreographyIfThen createIfThen(Condition expression, ChoreographyRule rule);
83  
84          public ChoreographyIfThen createIfThen(Condition expression, Set<ChoreographyRule> rules);
85  
86          public ChoreographyForAll createForAll(Variable variable, Condition condition, ChoreographyRule rule);
87  
88          public ChoreographyForAll createForAll(Set<Variable> variables, Condition condition, ChoreographyRule rule);
89  
90          public ChoreographyForAll createForAll(Variable variable, Condition condition, Set<ChoreographyRule> rules);
91  
92          public ChoreographyForAll createForAll(Set<Variable> variables, Condition condition, Set<ChoreographyRule> rules);
93  
94          public ChoreographyChoose createChoose(Variable variable, Condition condition, ChoreographyRule rule);
95  
96          public ChoreographyChoose createChoose(Set<Variable> variables, Condition condition, ChoreographyRule rule);
97  
98          public ChoreographyChoose createChoose(Variable variable, Condition condition, Set<ChoreographyRule> rules);
99  
100         public ChoreographyChoose createChoose(Set<Variable> variables, Condition condition, Set<ChoreographyRule> rules);
101     }
102 
103     public interface UpdateRules {
104 
105         public Add createAdd(CompoundFact fact);
106 
107         public Delete createDelete(CompoundFact fact);
108 
109         public Update createUpdate(CompoundFact newFact);
110 
111         public Update createUpdate(CompoundFact newFact, CompoundFact oldFact)
112                 throws InvalidModelException;
113     }
114 
115     public interface Facts {
116         public MoleculeFact createMoleculeFact();
117 
118         public MoleculeFact createMoleculeFact(Set<MembershipMolecule> memberMolecules,
119                 Set<AttributeValueMolecule> attrValues);
120         
121         public MoleculeFact createMoleculeFact(MembershipMolecule memberMolecule,
122                 Set<AttributeValueMolecule> attrValues);
123 
124         public MoleculeFact createMoleculeFact(Set<MembershipMolecule> memberMolecules,
125                 AttributeValueMolecule attrValue);
126 
127         public MoleculeFact createMoleculeFact(MembershipMolecule memberMolecule, AttributeValueMolecule attrValue);
128         
129         public RelationFact createRelationFact();
130         
131         public RelationFact createRelationFact(Atom atom);
132     }
133 
134     public interface Modes {
135         public In createIn(Concept concept);
136 
137         public In createIn(Concept concept, Set<Grounding> grounding);
138 
139         public In createIn(Relation relation);
140 
141         public In createIn(Relation relation, Set<Grounding> grounding);
142 
143         public Out createOut(Concept concept);
144 
145         public Out createOut(Concept concept, Set<Grounding> grounding);
146 
147         public Out createOut(Relation relation);
148 
149         public Out createOut(Relation relation, Set<Grounding> grounding);
150 
151         public Shared createShared(Concept concept);
152 
153         public Shared createShared(Concept concept, Set<Grounding> grounding);
154 
155         public Shared createShared(Relation relation);
156 
157         public Shared createShared(Relation relation, Set<Grounding> grounding);
158 
159         public Controlled createControlled(Concept concept);
160 
161         public Controlled createControlled(Relation relation);
162 
163         public Static createStatic(Concept concept);
164 
165         public Static createStatic(Relation relation);
166 
167         public WSDLGrounding createWSDLGrounding(IRI iri);
168     }
169 
170     public final Containers containers = createContainers();
171 
172     public final TransitionRules transitionRules = createTransitionRules();
173 
174     public final UpdateRules updateRules = createUpdateRules();
175 
176     public final Facts facts = createFacts();
177 
178     public final Modes modes = createModes();
179 
180     protected abstract Containers createContainers();
181 
182     protected abstract TransitionRules createTransitionRules();
183 
184     protected abstract UpdateRules createUpdateRules();
185 
186     protected abstract Facts createFacts();
187 
188     protected abstract Modes createModes();
189 }
190 
191 /*
192  * $Log$
193  * Revision 1.27  2006/10/24 14:11:46  vassil_momtchev
194  * choreography/orchestration rules refactored. different types where appropriate now supported
195  *
196  * Revision 1.26  2006/05/30 16:49:25  jamsci001
197  * - removed redundant comment
198  *
199  * Revision 1.25  2006/04/17 09:44:06  vassil_momtchev
200  * method public Choreography createChoreography(Identifier id) added; public Condition createConditionFromLogicalExpression(LogicalExpression e) changed to public Condition createConditionFromLogicalExpression(LogicalExpression e) throws InvalidModelException;
201  *
202  * Revision 1.24  2006/04/17 07:37:43  vassil_momtchev
203  * method signature createRelationFact(Identifier, List)  -> createRelationFact(Atom); method createRelationFact() added
204  *
205  * Revision 1.23  2006/02/10 09:58:45  jamsci001
206  * - Added convenience methods for MoleculeFact
207  *
208  * Revision 1.22  2006/02/03 13:27:41  jamsci001
209  * - support for relation updates
210  * - consequently modified creator methods for facts and update rules
211  * Revision 1.21 2006/01/31 10:36:54
212  * vassil_momtchev MembershipUpdate and AttributeValueUpdate types removed. use
213  * two CompoundFacts instead; log footer added
214  * 
215  */
216