KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > def > BpelDefinition


1 package org.jbpm.bpel.def;
2
3 import org.jbpm.context.def.ContextDefinition;
4 import org.jbpm.graph.def.GraphElement;
5 import org.jbpm.graph.def.ProcessDefinition;
6 import org.jbpm.graph.exe.ProcessInstance;
7 import org.jbpm.graph.exe.Token;
8
9 import org.jbpm.bpel.service.def.Receiver;
10
11 /**
12  * Represents a BPEL process.
13  * @see "WS-BPEL 2.0 §6.2"
14  * @author Juan Cantú
15  * @version $Revision: 1.14 $ $Date: 2005/06/04 00:08:20 $
16  */

17 public class BpelDefinition extends ProcessDefinition {
18   
19   private String JavaDoc targetNamespace;
20   private String JavaDoc queryLanguage;
21   private String JavaDoc expressionLanguage;
22   private boolean abstractProcess;
23   private boolean enableInstanceCompensation;
24   
25   private String JavaDoc location;
26   
27   private static final long serialVersionUID = 1L;
28
29   public BpelDefinition() {
30     this(null);
31   }
32   
33   public BpelDefinition(String JavaDoc name) {
34     super(name);
35     addNode(new RootScope());
36     addDefinition(new ContextDefinition());
37     addDefinition(new ImportsDefinition());
38   }
39
40   // property getters and setters ///////////////////////////////////////////////////////////////
41

42   public String JavaDoc getTargetNamespace() {
43     return targetNamespace;
44   }
45   
46   public void setTargetNamespace(String JavaDoc targetNamespace) {
47     this.targetNamespace = targetNamespace;
48   }
49
50   public String JavaDoc getQueryLanguage() {
51     return queryLanguage;
52   }
53
54   public void setQueryLanguage(String JavaDoc queryLanguage) {
55     this.queryLanguage = queryLanguage;
56   }
57
58   public String JavaDoc getExpressionLanguage() {
59     return expressionLanguage;
60   }
61
62   public void setExpressionLanguage(String JavaDoc expressionLanguage) {
63     this.expressionLanguage = expressionLanguage;
64   }
65
66   public boolean isAbstractProcess() {
67     return abstractProcess;
68   }
69
70   public void setAbstractProcess(boolean abstractProcess) {
71     this.abstractProcess = abstractProcess;
72   }
73
74   public boolean getEnableInstanceCompensation() {
75     return enableInstanceCompensation;
76   }
77   
78   public void setEnableInstanceCompensation(boolean enableInstanceCompensation) {
79     this.enableInstanceCompensation = enableInstanceCompensation;
80   }
81   
82   public String JavaDoc getLocation() {
83     return location;
84   }
85   
86   public void setLocation(String JavaDoc location) {
87     this.location = location;
88   }
89   
90   public ImportsDefinition getImports() {
91     return (ImportsDefinition) getDefinition(ImportsDefinition.class);
92   }
93   
94   public Activity getRoot() {
95     return getScope().getRoot();
96   }
97   
98   public void setRoot(Activity root) {
99     getScope().setRoot(root);
100   }
101   
102   public Scope getScope() {
103     return (Scope) getNodes().get(0);
104   }
105   
106   public void triggerProcessInstance(ProcessInstance instance, Receiver trigger) {
107     Token rootToken = instance.getRootToken();
108     Scope scope = getScope();
109     scope.enableEvents(rootToken);
110     new ProcessInstanceTrigger(scope.createScopeContext(rootToken), trigger).visit(this);
111   }
112
113   // jbpm override /////////////////////////////////////////////////////////////////////////////
114

115   public ProcessInstance createProcessInstance() {
116     ProcessInstance instance = super.createProcessInstance();
117     getScope().initScopeData(instance.getRootToken());
118     return instance;
119   }
120   
121   public static class RootScope extends Scope {
122
123     private static final long serialVersionUID = 1L;
124
125     public RootScope() {
126       setImplicit(true);
127     }
128     
129     public boolean isChildInitial(Activity activity) {
130       return activity.equals(root);
131     }
132     
133     /**
134      * is the {@link CompositeActivity} or the {@link BpelDefinition} in which this
135      * activity is contained.
136      */

137     public GraphElement getParent() {
138       return processDefinition;
139     }
140     
141     public ProcessDefinition getProcessDefinition() {
142       return processDefinition;
143     }
144     
145     public boolean suppressJoinFailure() {
146       return getSuppressJoinFailure().booleanValue();
147     }
148   }
149 }
150
Popular Tags