KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > loader > AbstractWorkflowFactory


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow.loader;
6
7 import com.opensymphony.workflow.FactoryException;
8
9 import java.util.Properties JavaDoc;
10
11
12 /**
13  * Abstract base class for all workflow factories.
14  * A workflow factory is a factory class that is able
15  * to provide workflow descriptors given a workflow name,
16  * as well as save descriptors.
17  *
18  * @author Hani Suleiman
19  * Date: May 10, 2002
20  * Time: 11:17:06 AM
21  */

22 public abstract class AbstractWorkflowFactory {
23     //~ Instance fields ////////////////////////////////////////////////////////
24

25     protected Properties JavaDoc properties = new Properties JavaDoc();
26
27     //~ Methods ////////////////////////////////////////////////////////////////
28

29     /**
30      * Get the configuration properties of this factory
31      */

32     public Properties JavaDoc getProperties() {
33         return properties;
34     }
35
36     public final void init(Properties JavaDoc p) {
37         this.properties = p;
38     }
39
40     /**
41      * Get a workflow descriptor given a workflow name.
42      * @param name The name of the workflow to get.
43      * @return The descriptor for the specified workflow.
44      * @throws FactoryException if the specified workflow name does not exist or cannot be located.
45      */

46     public abstract WorkflowDescriptor getWorkflow(String JavaDoc name) throws FactoryException;
47
48     /**
49      * Get all workflow names in the current factory
50      * @return An array of all workflow names
51      * @throws FactoryException if the factory cannot determine the names of the workflows it has.
52      */

53     public abstract String JavaDoc[] getWorkflowNames() throws FactoryException;
54
55     public abstract boolean removeWorkflow(String JavaDoc name) throws FactoryException;
56
57     /**
58      * Save the workflow.
59      * @param name The name of the workflow to same.
60      * @param descriptor The descriptor for the workflow.
61      * @param replace true if an existing workflow with this name should be replaced.
62      * @return true if the workflow was saved.
63      * @throws FactoryException if there was an error saving the workflow
64      * @throws com.opensymphony.workflow.InvalidWorkflowDescriptorException if the descriptor specified is invalid
65      */

66     public abstract boolean saveWorkflow(String JavaDoc name, WorkflowDescriptor descriptor, boolean replace) throws FactoryException;
67
68     /**
69      * Invoked after the properties of the factory have been set.
70      * Subclasses should override this method and add any specific
71      * setup code required. For example, connecting to an external resource
72      * or database.
73      * @throws FactoryException if there was an error during initialization.
74      */

75     public void initDone() throws FactoryException {
76     }
77 }
78
Popular Tags