01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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.apache.commons.scxml.model;
18:
19: import java.util.Collection;
20:
21: import org.apache.commons.logging.Log;
22: import org.apache.commons.scxml.ErrorReporter;
23: import org.apache.commons.scxml.EventDispatcher;
24: import org.apache.commons.scxml.SCInstance;
25: import org.apache.commons.scxml.SCXMLExpressionException;
26: import org.apache.commons.scxml.model.Action;
27:
28: /**
29: * Our custom "hello world" action.
30: */
31: public class Hello extends Action {
32:
33: /** Serial version UID. */
34: private static final long serialVersionUID = 1L;
35: /** This is who we say hello to. */
36: private String name;
37: /** We count callbacks to execute() as part of the test suite. */
38: public static int callbacks = 0;
39:
40: /** Public constructor is needed for the I in SCXML IO. */
41: public Hello() {
42: super ();
43: }
44:
45: /**
46: * Get the name.
47: *
48: * @return Returns the name.
49: */
50: public String getName() {
51: return name;
52: }
53:
54: /**
55: * Set the name.
56: *
57: * @param name The name to set.
58: */
59: public void setName(String name) {
60: this .name = name;
61: }
62:
63: /**
64: * @inheritDoc
65: */
66: public void execute(final EventDispatcher evtDispatcher,
67: final ErrorReporter errRep, final SCInstance scInstance,
68: final Log appLog, final Collection derivedEvents)
69: throws ModelException, SCXMLExpressionException {
70: if (appLog.isInfoEnabled()) {
71: appLog.info("Hello " + name);
72: }
73: callbacks++;
74: }
75: }
|