KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > module > run > LoggerTrampoline


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.apache.tools.ant.module.run;
21
22 import java.io.File JavaDoc;
23 import java.net.URL JavaDoc;
24 import java.util.Set JavaDoc;
25 import org.apache.tools.ant.module.spi.AntEvent;
26 import org.apache.tools.ant.module.spi.AntLogger;
27 import org.apache.tools.ant.module.spi.AntSession;
28 import org.apache.tools.ant.module.spi.TaskStructure;
29 import org.openide.windows.OutputListener;
30
31 /**
32  * Trick to let {@link AntSession}, {@link AntEvent}, and {@link TaskStructure}
33  * be final classes when naturally they should be interfaces because their
34  * implementation is elsewhere.
35  * @see "#45491"
36  * @author Jesse Glick
37  */

38 public final class LoggerTrampoline {
39     
40     private LoggerTrampoline() {}
41     
42     public interface Creator {
43         AntSession makeAntSession(AntSessionImpl impl);
44         AntEvent makeAntEvent(AntEventImpl impl);
45         TaskStructure makeTaskStructure(TaskStructureImpl impl);
46     }
47     
48     public static Creator ANT_SESSION_CREATOR, ANT_EVENT_CREATOR, TASK_STRUCTURE_CREATOR;
49     static {
50         try {
51             Class JavaDoc c = AntSession.class;
52             Class.forName(c.getName(), true, c.getClassLoader());
53             c = AntEvent.class;
54             Class.forName(c.getName(), true, c.getClassLoader());
55             c = TaskStructure.class;
56             Class.forName(c.getName(), true, c.getClassLoader());
57         } catch (ClassNotFoundException JavaDoc e) {
58             assert false : e;
59         }
60         assert ANT_SESSION_CREATOR != null && ANT_EVENT_CREATOR != null && TASK_STRUCTURE_CREATOR != null;
61     }
62     
63     public interface AntSessionImpl {
64         File JavaDoc getOriginatingScript();
65         String JavaDoc[] getOriginatingTargets();
66         Object JavaDoc getCustomData(AntLogger logger);
67         void putCustomData(AntLogger logger, Object JavaDoc data);
68         void println(String JavaDoc message, boolean err, OutputListener listener);
69         void deliverMessageLogged(AntEvent originalEvent, String JavaDoc message, int level);
70         void consumeException(Throwable JavaDoc t) throws IllegalStateException JavaDoc;
71         boolean isExceptionConsumed(Throwable JavaDoc t);
72         int getVerbosity();
73         String JavaDoc getDisplayName();
74         OutputListener createStandardHyperlink(URL JavaDoc file, String JavaDoc message, int line1, int column1, int line2, int column2);
75     }
76     
77     public interface AntEventImpl {
78         AntSession getSession();
79         void consume() throws IllegalStateException JavaDoc;
80         boolean isConsumed();
81         File JavaDoc getScriptLocation();
82         int getLine();
83         String JavaDoc getTargetName();
84         String JavaDoc getTaskName();
85         TaskStructure getTaskStructure();
86         String JavaDoc getMessage();
87         int getLogLevel();
88         Throwable JavaDoc getException();
89         String JavaDoc getProperty(String JavaDoc name);
90         Set JavaDoc<String JavaDoc> getPropertyNames();
91         String JavaDoc evaluate(String JavaDoc text);
92     }
93     
94     public interface TaskStructureImpl {
95         String JavaDoc getName();
96         String JavaDoc getAttribute(String JavaDoc name);
97         Set JavaDoc<String JavaDoc> getAttributeNames();
98         String JavaDoc getText();
99         TaskStructure[] getChildren();
100     }
101     
102 }
103
Popular Tags