01: /*
02: * $Id: BPELProcessFactoryImpl.java,v 1.10 2004/12/09 12:34:33 kowap Exp $
03: *
04: * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
05: * Berne University of Applied Sciences
06: * School of Engineering and Information Technology
07: * All rights reserved.
08: */
09: 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.10 $, $Date: 2004/12/09 12:34:33 $
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: // create the root BPELProcess object
41: //
42: BPELProcess processRoot = new BPELProcessImpl();
43:
44: // parse a BPEL document and create the BPELProcess
45: //
46: BPELProcess bpelProcess = (BPELProcess) DigesterLoader
47: .load(getRulesURL(), getClass().getClassLoader(),
48: bpelDocumentStream, processRoot);
49:
50: // if there is a reply element, the process is synchronous
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: }
|