001 package net.sf.logdistiller.ant;
002
003 /*
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 import org.apache.tools.ant.Project;
018 import org.apache.tools.ant.types.Path;
019 import org.apache.tools.ant.types.Reference;
020
021 /**
022 * Definition of logevent class in Ant buildfile.
023 *
024 * <pre>
025 * <logevent factory="<i>[event factory class]</i>"/>
026 * </pre>
027 */
028 public class AntLogEvent
029 {
030 private final Project project;
031
032 private String logtype;
033
034 private Path classpath;
035
036 public AntLogEvent( Project project )
037 {
038 this.project = project;
039 }
040
041 public void setClasspath( Path classpath )
042 {
043 if ( this.classpath == null )
044 {
045 this.classpath = classpath;
046 }
047 else
048 {
049 this.classpath.append( classpath );
050 }
051 }
052
053 public Path createClasspath()
054 {
055 if ( classpath == null )
056 {
057 classpath = new Path( project );
058 }
059 return classpath.createPath();
060 }
061
062 public void setClasspathRef( Reference r )
063 {
064 createClasspath().setRefid( r );
065 }
066
067 public void setLoaderRef( Reference r )
068 {
069 }
070
071 /**
072 * @deprecated replaced by <code>logtype</code> attribute
073 */
074 public void setFactory( String factory )
075 {
076 setLogtype( factory );
077 project.log( "WARNING: attribute 'factory' is deprecated, please use attribute 'logtype' instead",
078 Project.MSG_WARN );
079 }
080
081 public void setLogtype( String logtype )
082 {
083 this.logtype = logtype;
084 }
085
086 public String getLogtype()
087 {
088 return logtype;
089 }
090 }