1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.workflow;
16  
17  import com.liferay.portal.kernel.util.ListUtil;
18  import com.liferay.portal.kernel.workflow.WorkflowHandler;
19  import com.liferay.portal.kernel.workflow.WorkflowHandlerRegistry;
20  
21  import java.util.List;
22  import java.util.Map;
23  import java.util.concurrent.ConcurrentHashMap;
24  
25  /**
26   * <a href="WorkflowHandlerRegistryImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Bruno Farache
29   * @author Marcellus Tavares
30   */
31  public class WorkflowHandlerRegistryImpl implements WorkflowHandlerRegistry {
32  
33      public WorkflowHandler getWorkflowHandler(String className) {
34          return _workflowHandlerMap.get(className);
35      }
36  
37      public List<WorkflowHandler> getWorkflowHandlers() {
38          return ListUtil.fromCollection(_workflowHandlerMap.values());
39      }
40  
41      public void register(WorkflowHandler workflowHandler) {
42          _workflowHandlerMap.put(
43              workflowHandler.getClassName(), workflowHandler);
44      }
45  
46      public void unregister(WorkflowHandler workflowHandler) {
47          _workflowHandlerMap.remove(workflowHandler);
48      }
49  
50      private Map<String, WorkflowHandler> _workflowHandlerMap =
51          new ConcurrentHashMap<String, WorkflowHandler>();
52  
53  }