View Javadoc

1   /*
2    * $Id: ProcessImplFactory.java,v 1.1 2004/12/15 14:18:09 patforna Exp $
3    *
4    * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
5    * Berne University of Applied Sciences
6    * School of Engineering and Information Technology
7    * All rights reserved.
8    */
9   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.1 $, $Date: 2004/12/15 14:18:09 $
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.getValue(EXPRESSION_LANGUAGE);
50          String suppressJoinFailure = attributes.getValue(SUPPRESS_JOIN_FAILURE);
51          String enableInstanceCompensation = attributes
52                  .getValue(ENABLE_INSTANCE_COMPESATION);
53          String abstractProcess = attributes.getValue(ABSTRACT_PROCESS);
54          String xmlns = attributes.getValue(XMLNS);
55  
56          Map nameSpaces = new Hashtable();
57          String currentQName;
58          for (int i = 0; i < attributes.getLength(); i++) {
59              currentQName = attributes.getQName(i);
60              int separatorIndex = currentQName.indexOf(":");
61              if (separatorIndex != 1) {
62                  nameSpaces.put(currentQName.substring(separatorIndex + 1),
63                          attributes.getValue(i));
64              }
65          }
66  
67          Process process = getElementFactory().createProcess(name,
68                  targetNamespace, queryLanguage, expressionLanguage,
69                  suppressJoinFailure, enableInstanceCompensation,
70                  abstractProcess, xmlns, nameSpaces);
71  
72          return process;
73      }
74  }