View Javadoc
1   package net.sf.logdistiller.ant;
2   
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  
17  import org.apache.tools.ant.Project;
18  import org.apache.tools.ant.types.Path;
19  import org.apache.tools.ant.types.Reference;
20  
21  /**
22   * Definition of logevent class in Ant buildfile.
23   *
24   * <pre>
25   * &lt;logevent factory=&quot;&lt;i&gt;[event factory class]&lt;/i&gt;&quot;/&gt;
26   * </pre>
27   */
28  public class AntLogEvent
29  {
30      private final Project project;
31  
32      private String logtype;
33  
34      private Path classpath;
35  
36      public AntLogEvent( Project project )
37      {
38          this.project = project;
39      }
40  
41      public void setClasspath( Path classpath )
42      {
43          if ( this.classpath == null )
44          {
45              this.classpath = classpath;
46          }
47          else
48          {
49              this.classpath.append( classpath );
50          }
51      }
52  
53      public Path createClasspath()
54      {
55          if ( classpath == null )
56          {
57              classpath = new Path( project );
58          }
59          return classpath.createPath();
60      }
61  
62      public void setClasspathRef( Reference r )
63      {
64          createClasspath().setRefid( r );
65      }
66  
67      public void setLoaderRef( Reference r )
68      {
69      }
70  
71      /**
72       * @deprecated replaced by <code>logtype</code> attribute
73       */
74      public void setFactory( String factory )
75      {
76          setLogtype( factory );
77          project.log( "WARNING: attribute 'factory' is deprecated, please use attribute 'logtype' instead",
78                       Project.MSG_WARN );
79      }
80  
81      public void setLogtype( String logtype )
82      {
83          this.logtype = logtype;
84      }
85  
86      public String getLogtype()
87      {
88          return logtype;
89      }
90  }