|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| WerkflowEvent.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* WerkflowEvent.java
|
|
| 3 |
* Copyright 2002-2004 Bill2, Inc.
|
|
| 4 |
*
|
|
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 6 |
* you may not use this file except in compliance with the License.
|
|
| 7 |
* You may obtain a copy of the License at
|
|
| 8 |
*
|
|
| 9 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 10 |
*
|
|
| 11 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 14 |
* See the License for the specific language governing permissions and
|
|
| 15 |
* limitations under the License.
|
|
| 16 |
*/
|
|
| 17 |
package org.dentaku.foundation.event;
|
|
| 18 |
|
|
| 19 |
import org.codehaus.werkflow.Wfms;
|
|
| 20 |
import org.codehaus.werkflow.SimpleAttributes;
|
|
| 21 |
import org.codehaus.werkflow.definition.ProcessDefinition;
|
|
| 22 |
import org.codehaus.werkflow.personality.Personality;
|
|
| 23 |
import org.codehaus.werkflow.personality.basic.BasicPersonality;
|
|
| 24 |
import org.codehaus.werkflow.engine.WorkflowEngine;
|
|
| 25 |
import org.codehaus.werkflow.service.SimpleWfmsServices;
|
|
| 26 |
import org.codehaus.werkflow.service.persistence.fleeting.FleetingPersistenceManager;
|
|
| 27 |
import org.codehaus.werkflow.service.messaging.simple.SimpleMessagingManager;
|
|
| 28 |
import org.dentaku.foundation.output.OutputContext;
|
|
| 29 |
|
|
| 30 |
import java.net.URL;
|
|
| 31 |
import java.util.HashMap;
|
|
| 32 |
|
|
| 33 |
public abstract class WerkflowEvent extends AbstractEvent { |
|
| 34 |
public abstract URL getWorkflowURL();
|
|
| 35 |
|
|
| 36 |
private static Wfms wfms; |
|
| 37 |
private static HashMap workflows = new HashMap(); |
|
| 38 |
|
|
| 39 | 0 |
protected WerkflowEvent(OutputContext response) {
|
| 40 | 0 |
super(response);
|
| 41 |
} |
|
| 42 |
|
|
| 43 | 0 |
public boolean execute() throws Exception { |
| 44 | 0 |
deploy(getWorkflowURL()); |
| 45 | 0 |
SimpleAttributes attrs = new SimpleAttributes();
|
| 46 | 0 |
attrs.setAttribute("event", this); |
| 47 | 0 |
getWfms().getRuntime().callProcess("", "EventDispatch", attrs); |
| 48 | 0 |
return true; |
| 49 |
} |
|
| 50 |
|
|
| 51 | 0 |
public static Wfms getWfms() { |
| 52 | 0 |
if (wfms == null) { |
| 53 | 0 |
SimpleWfmsServices services = new SimpleWfmsServices();
|
| 54 | 0 |
services.setMessagingManager(new SimpleMessagingManager());
|
| 55 | 0 |
services.setPersistenceManager(new FleetingPersistenceManager());
|
| 56 | 0 |
wfms = new WorkflowEngine(services);
|
| 57 |
} |
|
| 58 | 0 |
return wfms;
|
| 59 |
} |
|
| 60 |
|
|
| 61 | 0 |
public static void deploy(URL url) throws Exception { |
| 62 | 0 |
if (workflows.get(url) == null) { |
| 63 | 0 |
Personality personality = BasicPersonality.getInstance(); |
| 64 | 0 |
ProcessDefinition[] processDefs = personality.load(url); |
| 65 | 0 |
for (int i = 0; i < processDefs.length; ++i) { |
| 66 | 0 |
getWfms().getAdmin().deployProcess(processDefs[i]); |
| 67 |
} |
|
| 68 | 0 |
workflows.put(url, null);
|
| 69 |
} |
|
| 70 |
} |
|
| 71 |
} |
|
| 72 |
|
|
||||||||||