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.netbeans.modules.j2ee.deployment.plugins.spi;
043
044 import java.awt.Image;
045 import java.beans.PropertyChangeListener;
046 import java.beans.PropertyChangeSupport;
047 import java.io.File;
048 import java.util.Set;
049 import org.netbeans.api.java.platform.JavaPlatform;
050 import org.netbeans.spi.project.libraries.LibraryImplementation;
051
052 /**
053 * Base SPI interface for J2eePlatform. The J2eePlatform describes the target
054 * environment J2EE applications are build against and subsequently deployed to.
055 * Each server instance defines its own J2EE platform.
056 *
057 * @author Stepan Herold
058 * @since 1.5
059 */
060 public abstract class J2eePlatformImpl {
061
062 /** Display name property */
063 public static final String PROP_DISPLAY_NAME = "displayName"; //NOI18N
064 /** Libraries property */
065 public static final String PROP_LIBRARIES = "libraries"; //NOI18N
066 /** Platform roots property */
067 public static final String PROP_PLATFORM_ROOTS = "platformRoots"; //NOI18N
068
069 private PropertyChangeSupport supp;
070
071 /**
072 * Return platform's libraries.
073 *
074 * @return platform's libraries.
075 */
076 public abstract LibraryImplementation[] getLibraries();
077
078 /**
079 * Return platform's display name.
080 *
081 * @return platform's display name.
082 */
083 public abstract String getDisplayName();
084
085 /**
086 * Return an icon describing the platform. This will be mostly the icon
087 * used for server instance nodes
088 *
089 * @return an icon describing the platform
090 * @since 1.6
091 */
092 public abstract Image getIcon();
093
094 /**
095 * Return platform's root directories. This will be mostly server's installation
096 * directory.
097 *
098 * @return platform's root directories.
099 */
100 public abstract File[] getPlatformRoots();
101
102 /**
103 * Return classpath for the specified tool. Use the tool constants declared
104 * in the {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform}.
105 *
106 * @param toolName tool name, for example {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform#TOOL_APP_CLIENT_RUNTIME}.
107 * @return classpath for the specified tool.
108 */
109 public abstract File[] getToolClasspathEntries(String toolName);
110
111 /**
112 * Specifies whether a tool of the given name is supported by this platform.
113 * Use the tool constants declared in the {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform}.
114 *
115 * @param toolName tool name, for example {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform#TOOL_APP_CLIENT_RUNTIME}
116 * .
117 * @return <code>true</code> if platform supports tool of the given name,
118 * <code>false</code> otherwise.
119 */
120 public abstract boolean isToolSupported(String toolName);
121
122 /**
123 * Return a list of supported J2EE specification versions. Use J2EE specification
124 * versions defined in the {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule}
125 * class.
126 *
127 * @return list of supported J2EE specification versions.
128 */
129 public abstract Set/*<String>*/getSupportedSpecVersions();
130
131 /**
132 * Return a list of supported J2EE specification versions for
133 * a given module type.
134 *
135 * Implement this method if the server supports different versions
136 * of spec for different types of modules.
137 * If this method is not implemented by the plugin the IDE
138 * will use the non parametrized version of
139 * getSupportedSpecVersions.
140 *
141 * @param moduleType one of the constants defined in
142 * {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule}
143 * @return list of supported J2EE specification versions.
144 */
145 public Set<String> getSupportedSpecVersions(Object moduleType) {
146 return getSupportedSpecVersions();
147 }
148
149 /**
150 * Return a list of supported J2EE module types. Use module types defined in the
151 * {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule}
152 * class.
153 *
154 * @return list of supported J2EE module types.
155 */
156 public abstract Set/*<Object>*/getSupportedModuleTypes();
157
158 /**
159 * Return a set of J2SE platform versions this J2EE platform can run with.
160 * Versions should be specified as strings i.g. ("1.3", "1.4", etc.)
161 *
162 * @since 1.9
163 */
164 public abstract Set/*<String>*/getSupportedJavaPlatformVersions();
165
166 /**
167 * Return server J2SE platform or null if the platform is unknown, not
168 * registered in the IDE.
169 *
170 * @return server J2SE platform or null if the platform is unknown, not
171 * registered in the IDE.
172 *
173 * @since 1.9
174 */
175 public abstract JavaPlatform getJavaPlatform();
176
177 /**
178 * Register a listener which will be notified when some of the platform's properties
179 * change.
180 *
181 * @param l listener which should be added.
182 */
183 public final void addPropertyChangeListener(PropertyChangeListener l) {
184 synchronized (this ) {
185 if (supp == null)
186 supp = new PropertyChangeSupport(this );
187 }
188 supp.addPropertyChangeListener(l);
189 }
190
191 /**
192 * Remove a listener registered previously.
193 *
194 * @param l listener which should be removed.
195 */
196 public final void removePropertyChangeListener(
197 PropertyChangeListener l) {
198 if (supp != null)
199 supp.removePropertyChangeListener(l);
200 }
201
202 /**
203 * Fire PropertyChange to all registered PropertyChangeListeners.
204 *
205 * @param propName property name.
206 * @param oldValue old value.
207 * @param newValue new value.
208 */
209 public final void firePropertyChange(String propName,
210 Object oldValue, Object newValue) {
211 if (supp != null)
212 supp.firePropertyChange(propName, oldValue, newValue);
213 }
214
215 /**
216 * Returns the property value for the specified tool.
217 * <p>
218 * The property value uses Ant property format and therefore may contain
219 * references to another properties defined either by the client of this API
220 * or by the tool itself.
221 * <p>
222 * The properties the client may be requited to define are as follows
223 * {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform#CLIENT_PROP_DIST_ARCHIVE}
224 *
225 * @param toolName tool name, for example {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform#TOOL_APP_CLIENT_RUNTIME}.
226 * @param propertyName tool property name, for example {@link org.netbeans.modules.j2ee.deployment.devmodules.api.J2eePlatform#TOOL_PROP_MAIN_CLASS}.
227 *
228 * @return property value or null, if the property is not defined for the
229 * specified tool.
230 *
231 * @since 1.16
232 */
233 public String getToolProperty(String toolName, String propertyName) {
234 return null;
235 }
236 }
|