1
2
3
4
5
6
7
8
9 package bexee.model;
10
11 import java.io.InputStream;
12 import java.net.URL;
13
14 import org.apache.commons.digester.xmlrules.DigesterLoader;
15
16 import bexee.model.process.BPELProcess;
17 import bexee.model.process.impl.BPELProcessImpl;
18
19 /***
20 * This is a factory class used for the creation of object representations of
21 * BPEL processes. Such an representation is defined by a specified BPEL
22 * document.
23 *
24 * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:10 $
25 * @author Patric Fornasier
26 * @author Pawel Kowalski
27 */
28 public class BPELProcessFactoryImpl extends BPELProcessFactory {
29
30 private static final String BPEL_RULES = "bexee/model/bpel-rules.xml";
31
32 /***
33 * Create a <code>BPELProcess</code> for the BPEL document passed as an
34 * <code>InputStream</code>.
35 */
36 public BPELProcess createBPELProcess(InputStream bpelDocumentStream)
37 throws BPELDocumentException {
38
39 try {
40
41
42 BPELProcess processRoot = new BPELProcessImpl();
43
44
45
46 BPELProcess bpelProcess = (BPELProcess) DigesterLoader.load(
47 getRulesURL(), getClass().getClassLoader(),
48 bpelDocumentStream, processRoot);
49
50
51 IsSynchronousProcessVisitor synchVisitor = new IsSynchronousProcessVisitor();
52 bpelProcess.getProcess().accept(synchVisitor);
53 bpelProcess.setSynchronous(synchVisitor.isSynchronous());
54
55 return bpelProcess;
56
57 } catch (Exception ex) {
58 throw new BPELDocumentException(ex);
59 }
60 }
61
62 /***
63 * Get the <code>URL</code> of the Digester rules file. The parsing of
64 * BPEL xml documents and transformation into object representations is
65 * controlled by these rules.
66 *
67 * @return the URL with rules descriptions
68 */
69 public URL getRulesURL() {
70 return getClass().getClassLoader().getResource(BPEL_RULES);
71 }
72
73 }