View Javadoc

1   package org.apache.fulcrum.osworkflow;
2   
3   
4   
5   /*
6    * Licensed to the Apache Software Foundation (ASF) under one
7    * or more contributor license agreements.  See the NOTICE file
8    * distributed with this work for additional information
9    * regarding copyright ownership.  The ASF licenses this file
10   * to you under the Apache License, Version 2.0 (the
11   * "License"); you may not use this file except in compliance
12   * with the License.  You may obtain a copy of the License at
13   *
14   *   http://www.apache.org/licenses/LICENSE-2.0
15   *
16   * Unless required by applicable law or agreed to in writing,
17   * software distributed under the License is distributed on an
18   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19   * KIND, either express or implied.  See the License for the
20   * specific language governing permissions and limitations
21   * under the License.
22   */
23  
24  import com.opensymphony.workflow.Workflow;
25  import com.opensymphony.workflow.WorkflowException;
26  
27  
28  /***
29   * This is a Facade class for WorkflowService.
30   *
31   * This class provides static methods that call related methods of the
32   * implementation of the WorkflowService used by the System.
33   *
34   * @version $Id: WorkflowServiceFacade.java 535465 2007-05-05 06:58:06Z tv $
35   */
36  public class WorkflowServiceFacade
37  {
38  
39      /*** Static instance of the WorkflowService.  */
40      private static WorkflowService workflowService;
41  
42      /***
43       * Utility method for accessing the service
44       * implementation
45       *
46       * @return a WorkflowService implementation instance
47       */
48      private static WorkflowService getService()
49      {
50      	if(workflowService==null){
51      		throw new RuntimeException("Workflow Service has not been set yet.");
52      	}
53          return workflowService;
54      }
55      static void setWorkflowService(WorkflowService service)
56      {
57          workflowService = service;
58      }
59  
60      /*** Retrives a workflow based on the caller */
61      public static Workflow retrieveWorkflow(String caller)
62      {
63          return getService().retrieveWorkflow(caller);
64      }
65  
66      /*** For a specific caller and status, return all the workflows. */
67      public static long[] retrieveWorkflows(String caller, String status)
68              throws WorkflowException
69      {
70          return getService().retrieveWorkflows(caller, status);
71      }
72  }