01: /*
02: * JBoss, Home of Professional Open Source
03: * Copyright 2005, JBoss Inc., and individual contributors as indicated
04: * by the @authors tag. See the copyright.txt in the distribution for a
05: * full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package org.jbpm.graph.node;
23:
24: import java.util.Map;
25:
26: import org.dom4j.Element;
27: import org.jbpm.graph.def.Event;
28: import org.jbpm.graph.def.Node;
29: import org.jbpm.graph.def.Transition;
30: import org.jbpm.graph.exe.ExecutionContext;
31: import org.jbpm.jpdl.xml.JpdlXmlReader;
32:
33: public class StartState extends Node {
34:
35: private static final long serialVersionUID = 1L;
36:
37: public StartState() {
38: }
39:
40: public StartState(String name) {
41: super (name);
42: }
43:
44: // event types //////////////////////////////////////////////////////////////
45:
46: public static final String[] supportedEventTypes = new String[] {
47: Event.EVENTTYPE_NODE_LEAVE, Event.EVENTTYPE_AFTER_SIGNAL };
48:
49: public String[] getSupportedEventTypes() {
50: return supportedEventTypes;
51: }
52:
53: // xml //////////////////////////////////////////////////////////////////////
54:
55: public void read(Element startStateElement, JpdlXmlReader jpdlReader) {
56: // if the start-state has a task specified,
57: Element startTaskElement = startStateElement.element("task");
58: if (startTaskElement != null) {
59: // delegate the parsing of the start-state task to the jpdlReader
60: jpdlReader.readStartStateTask(startTaskElement, this );
61: }
62: }
63:
64: public void write(Element nodeElement) {
65: }
66:
67: public void leave(ExecutionContext executionContext,
68: Transition transition) {
69: // leave this node as usual
70: super .leave(executionContext, transition);
71: }
72:
73: public void execute(ExecutionContext executionContext) {
74: }
75:
76: public Transition addArrivingTransition(Transition t) {
77: throw new UnsupportedOperationException(
78: "illegal operation : its not possible to add a transition that is arriving in a start state");
79: }
80:
81: public void setArrivingTransitions(Map arrivingTransitions) {
82: if ((arrivingTransitions != null)
83: && (arrivingTransitions.size() > 0)) {
84: throw new UnsupportedOperationException(
85: "illegal operation : its not possible to set a non-empty map in the arriving transitions of a start state");
86: }
87: }
88: }
|