001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.scxml.env;
018
019 import java.io.Serializable;
020
021 import org.apache.commons.logging.Log;
022 import org.apache.commons.logging.LogFactory;
023 import org.apache.commons.scxml.SCXMLListener;
024 import org.apache.commons.scxml.model.Transition;
025 import org.apache.commons.scxml.model.TransitionTarget;
026
027
028 /**
029 * Simple SCXML Listener that logs execution.
030 */
031 public class SimpleSCXMLListener implements SCXMLListener, Serializable {
032
033 /** Serial version UID. */
034 private static final long serialVersionUID = 1L;
035 /** Log. */
036 private Log log = LogFactory.getLog(getClass());
037
038
039 /**
040 * @see SCXMLListener#onEntry(TransitionTarget)
041 */
042 public void onEntry(final TransitionTarget state) {
043 if (log.isInfoEnabled()) {
044 log.info(LogUtils.getTTPath(state));
045 }
046 }
047
048 /**
049 * @see SCXMLListener#onExit(TransitionTarget)
050 */
051 public void onExit(final TransitionTarget state) {
052 if (log.isInfoEnabled()) {
053 log.info(LogUtils.getTTPath(state));
054 }
055 }
056
057 /**
058 * @see SCXMLListener#onTransition(TransitionTarget,TransitionTarget,Transition)
059 */
060 public void onTransition(final TransitionTarget from,
061 final TransitionTarget to, final Transition transition) {
062 if (log.isInfoEnabled()) {
063 log.info(LogUtils.transToString(from, to, transition));
064 }
065 }
066
067 }
068