001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.apache.tools.ant.module.run;
043:
044: import java.io.File;
045: import java.net.URL;
046: import java.util.Set;
047: import org.apache.tools.ant.module.spi.AntEvent;
048: import org.apache.tools.ant.module.spi.AntLogger;
049: import org.apache.tools.ant.module.spi.AntSession;
050: import org.apache.tools.ant.module.spi.TaskStructure;
051: import org.openide.windows.OutputListener;
052:
053: /**
054: * Trick to let {@link AntSession}, {@link AntEvent}, and {@link TaskStructure}
055: * be final classes when naturally they should be interfaces because their
056: * implementation is elsewhere.
057: * @see "#45491"
058: * @author Jesse Glick
059: */
060: public final class LoggerTrampoline {
061:
062: private LoggerTrampoline() {
063: }
064:
065: public interface Creator {
066: AntSession makeAntSession(AntSessionImpl impl);
067:
068: AntEvent makeAntEvent(AntEventImpl impl);
069:
070: TaskStructure makeTaskStructure(TaskStructureImpl impl);
071: }
072:
073: public static Creator ANT_SESSION_CREATOR, ANT_EVENT_CREATOR,
074: TASK_STRUCTURE_CREATOR;
075: static {
076: try {
077: Class c = AntSession.class;
078: Class.forName(c.getName(), true, c.getClassLoader());
079: c = AntEvent.class;
080: Class.forName(c.getName(), true, c.getClassLoader());
081: c = TaskStructure.class;
082: Class.forName(c.getName(), true, c.getClassLoader());
083: } catch (ClassNotFoundException e) {
084: assert false : e;
085: }
086: assert ANT_SESSION_CREATOR != null && ANT_EVENT_CREATOR != null
087: && TASK_STRUCTURE_CREATOR != null;
088: }
089:
090: public interface AntSessionImpl {
091: File getOriginatingScript();
092:
093: String[] getOriginatingTargets();
094:
095: Object getCustomData(AntLogger logger);
096:
097: void putCustomData(AntLogger logger, Object data);
098:
099: void println(String message, boolean err,
100: OutputListener listener);
101:
102: void deliverMessageLogged(AntEvent originalEvent,
103: String message, int level);
104:
105: void consumeException(Throwable t) throws IllegalStateException;
106:
107: boolean isExceptionConsumed(Throwable t);
108:
109: int getVerbosity();
110:
111: String getDisplayName();
112:
113: OutputListener createStandardHyperlink(URL file,
114: String message, int line1, int column1, int line2,
115: int column2);
116: }
117:
118: public interface AntEventImpl {
119: AntSession getSession();
120:
121: void consume() throws IllegalStateException;
122:
123: boolean isConsumed();
124:
125: File getScriptLocation();
126:
127: int getLine();
128:
129: String getTargetName();
130:
131: String getTaskName();
132:
133: TaskStructure getTaskStructure();
134:
135: String getMessage();
136:
137: int getLogLevel();
138:
139: Throwable getException();
140:
141: String getProperty(String name);
142:
143: Set<String> getPropertyNames();
144:
145: String evaluate(String text);
146: }
147:
148: public interface TaskStructureImpl {
149: String getName();
150:
151: String getAttribute(String name);
152:
153: Set<String> getAttributeNames();
154:
155: String getText();
156:
157: TaskStructure[] getChildren();
158: }
159:
160: }
|