/jbpm-flow/src/main/java/org/jbpm/workflow/core/node/StartNode.java

https://github.com/michelpohle/jbpm · Java · 86 lines · 50 code · 16 blank · 20 comment · 7 complexity · f47d1734f97d757f6aa59e982f7ffa6e MD5 · raw file

  1. /**
  2. * Copyright 2005 JBoss Inc
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.jbpm.workflow.core.node;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. import org.drools.definition.process.Connection;
  20. import org.jbpm.workflow.core.impl.ExtendedNodeImpl;
  21. /**
  22. * Default implementation of a start node.
  23. *
  24. * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
  25. */
  26. public class StartNode extends ExtendedNodeImpl {
  27. private static final String[] EVENT_TYPES =
  28. new String[] { EVENT_NODE_EXIT };
  29. private static final long serialVersionUID = 510l;
  30. private List<Trigger> triggers;
  31. public void addTrigger(Trigger trigger) {
  32. if (triggers == null) {
  33. triggers = new ArrayList<Trigger>();
  34. }
  35. triggers.add(trigger);
  36. }
  37. public void removeTrigger(Trigger trigger) {
  38. if (triggers != null) {
  39. triggers.remove(trigger);
  40. }
  41. }
  42. public List<Trigger> getTriggers() {
  43. return triggers;
  44. }
  45. public void setTriggers(List<Trigger> triggers) {
  46. this.triggers = triggers;
  47. }
  48. public String[] getActionTypes() {
  49. return EVENT_TYPES;
  50. }
  51. public void validateAddIncomingConnection(final String type, final Connection connection) {
  52. throw new UnsupportedOperationException(
  53. "A start node does not have an incoming connection!");
  54. }
  55. public void validateRemoveIncomingConnection(final String type, final Connection connection) {
  56. throw new UnsupportedOperationException(
  57. "A start node does not have an incoming connection!");
  58. }
  59. public void validateAddOutgoingConnection(final String type, final Connection connection) {
  60. super.validateAddOutgoingConnection(type, connection);
  61. if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
  62. throw new IllegalArgumentException(
  63. "This type of node only accepts default outgoing connection type!");
  64. }
  65. if (getTo() != null) {
  66. throw new IllegalArgumentException(
  67. "This type of node cannot have more than one outgoing connection!");
  68. }
  69. }
  70. }