01: /*
02: * $Id: ProcessImplFactory.java,v 1.5 2004/12/09 12:34:16 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.xmltobpel;
10:
11: import java.util.Hashtable;
12: import java.util.Map;
13:
14: import org.xml.sax.Attributes;
15:
16: import bexee.model.process.Process;
17:
18: /**
19: * This class is used by the <a
20: * href="http://jakarta.apache.org/commons/digester/">Digester </a> for the
21: * transformation of a process from a BPEL document into a
22: * <code>ProcessImpl</code> object. The creation of a process object is
23: * delegated to the <code>BPELElementFactory</code>.
24: *
25: * @author Pawel Kowalski
26: * @version $Revision: 1.5 $, $Date: 2004/12/09 12:34:16 $
27: */
28: public class ProcessImplFactory extends AbstractObjectCreationFactory {
29:
30: //**************************************************/
31: // create object
32: //**************************************************/
33:
34: /**
35: * Create a <code>ProcessImpl</code> activity instance using delegation to
36: * a <code>BPELElementFactory</code>.
37: *
38: * @param attributes
39: * an <code>Attributes</code> value
40: * @return an <code>ProcessImpl</code> value
41: * @exception Exception
42: * if an error occurs
43: */
44: public Object createObject(Attributes attributes) throws Exception {
45:
46: String name = attributes.getValue(NAME);
47: String targetNamespace = attributes.getValue(TARGET_NAMESPACE);
48: String queryLanguage = attributes.getValue(QUERY_LANGUAGE);
49: String expressionLanguage = attributes
50: .getValue(EXPRESSION_LANGUAGE);
51: String suppressJoinFailure = attributes
52: .getValue(SUPPRESS_JOIN_FAILURE);
53: String enableInstanceCompensation = attributes
54: .getValue(ENABLE_INSTANCE_COMPESATION);
55: String abstractProcess = attributes.getValue(ABSTRACT_PROCESS);
56: String xmlns = attributes.getValue(XMLNS);
57:
58: Map nameSpaces = new Hashtable();
59: String currentQName;
60: for (int i = 0; i < attributes.getLength(); i++) {
61: currentQName = attributes.getQName(i);
62: int separatorIndex = currentQName.indexOf(":");
63: if (separatorIndex != 1) {
64: nameSpaces.put(currentQName
65: .substring(separatorIndex + 1), attributes
66: .getValue(i));
67: }
68: }
69:
70: Process process = getElementFactory().createProcess(name,
71: targetNamespace, queryLanguage, expressionLanguage,
72: suppressJoinFailure, enableInstanceCompensation,
73: abstractProcess, xmlns, nameSpaces);
74:
75: return process;
76: }
77: }
|