1   /*
2    * Copyright 2006 The Apache Software Foundation.
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.apache.commons.scxml.model;
17  
18  import java.util.Collection;
19  
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.scxml.ErrorReporter;
22  import org.apache.commons.scxml.EventDispatcher;
23  import org.apache.commons.scxml.SCInstance;
24  import org.apache.commons.scxml.SCXMLExpressionException;
25  import org.apache.commons.scxml.model.Action;
26  
27  /***
28   * Our custom "hello world" action.
29   */
30  public class Hello extends Action {
31  
32      /*** This is who we say hello to. */
33      private String name;
34      /*** We count callbacks to execute() as part of the test suite. */
35      public static int callbacks = 0;
36  
37      /*** Public constructor is needed for the I in SCXML IO. */
38      public Hello() {
39          super();
40      }
41  
42      /***
43       * Get the name.
44       *
45       * @return Returns the name.
46       */
47      public String getName() {
48          return name;
49      }
50  
51      /***
52       * Set the name.
53       *
54       * @param name The name to set.
55       */
56      public void setName(String name) {
57          this.name = name;
58      }
59  
60      /***
61       * @inheritDoc
62       */
63      public void execute(final EventDispatcher evtDispatcher,
64              final ErrorReporter errRep, final SCInstance scInstance,
65              final Log appLog, final Collection derivedEvents)
66      throws ModelException, SCXMLExpressionException {
67          if (appLog.isInfoEnabled()) {
68              appLog.info("Hello " + name);
69          }
70          callbacks++;
71      }
72  }
73