01: /*
02: * $Id: BPELProcessFactory.java,v 1.6 2004/12/03 10:20:04 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:
13: import org.apache.commons.logging.Log;
14: import org.apache.commons.logging.LogFactory;
15:
16: import bexee.model.process.BPELProcess;
17: import bexee.model.process.impl.BPELProcessImpl;
18: import bexee.util.BexeeProperties;
19: import bexee.util.Constants;
20:
21: /**
22: * Abstract class for creating <code>BPELProcessFactory</code>
23: * implementations.
24: *
25: * @version $Revision: 1.6 $, $Date: 2004/12/03 10:20:04 $
26: * @author Patric Fornasier
27: * @author Pawel Kowalski
28: */
29: public abstract class BPELProcessFactory {
30:
31: private static Log log = LogFactory
32: .getLog(BPELProcessFactory.class);
33:
34: /**
35: * Creates a new <code>BPELProcessFactory</code>. The actual type is
36: * defined by the property <code>bexee.bpel.process.factory</code>.
37: * <p>
38: * If it is not set then {@link BPELProcessImpl}will be created.
39: *
40: * @return a <code>BPELProcessFactory</code> implementation
41: */
42: public static BPELProcessFactory getInstance() {
43:
44: BPELProcessFactory factory = null;
45:
46: String className = BexeeProperties
47: .getProperty(Constants.OPT_PROCESS_FACTORY);
48:
49: // if option is not set, create default factory
50: if (className == null) {
51: log.debug(Constants.OPT_DAO_FACTORY
52: + " not set, creating default factory: "
53: + BPELProcessImpl.class.getName());
54: factory = new BPELProcessFactoryImpl();
55: } else {
56: try {
57: // try to instantiate indicated class
58: Class clazz = Class.forName(className);
59: factory = (BPELProcessFactory) clazz.newInstance();
60: } catch (Exception e) {
61: log.warn("unable to create " + className
62: + ", creating default factory: "
63: + BPELProcessImpl.class.getName());
64: factory = new BPELProcessFactoryImpl();
65: }
66: }
67:
68: return factory;
69: }
70:
71: /**
72: * The concrete factories will have to implement this method.
73: *
74: * @return a <code>BPELProcess</code> implementation
75: */
76: public abstract BPELProcess createBPELProcess(
77: InputStream bpelDocumentStream)
78: throws BPELDocumentException;
79:
80: }
|