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 */ 017package org.apache.commons.scxml2.env; 018 019import java.io.Serializable; 020 021import org.apache.commons.logging.Log; 022import org.apache.commons.logging.LogFactory; 023import org.apache.commons.scxml2.SCXMLListener; 024import org.apache.commons.scxml2.model.EnterableState; 025import org.apache.commons.scxml2.model.Transition; 026import org.apache.commons.scxml2.model.TransitionTarget; 027 028 029/** 030 * Simple SCXML Listener that logs execution. 031 */ 032public class SimpleSCXMLListener implements SCXMLListener, Serializable { 033 034 /** Serial version UID. */ 035 private static final long serialVersionUID = 1L; 036 /** Log. */ 037 private Log log = LogFactory.getLog(getClass()); 038 039 040 /** 041 * @see SCXMLListener#onEntry(EnterableState) 042 */ 043 public void onEntry(final EnterableState state) { 044 if (log.isInfoEnabled()) { 045 log.info("enter " + LogUtils.getTTPath(state)); 046 } 047 } 048 049 /** 050 * @see SCXMLListener#onExit(EnterableState) 051 */ 052 public void onExit(final EnterableState state) { 053 if (log.isInfoEnabled()) { 054 log.info("exit " + LogUtils.getTTPath(state)); 055 } 056 } 057 058 /** 059* @see SCXMLListener#onTransition(TransitionTarget,TransitionTarget,Transition,String) 060 */ 061 public void onTransition(final TransitionTarget from, 062 final TransitionTarget to, final Transition transition, String event) { 063 if (log.isInfoEnabled()) { 064 log.info("transition " + LogUtils.transToString(from, to, transition, event)); 065 } 066 } 067 068} 069