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: * The Original Software is NetBeans. The Initial Developer of the Original
026: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027: * Microsystems, Inc. All Rights Reserved.
028: *
029: * If you wish your version of this file to be governed by only the CDDL
030: * or only the GPL Version 2, indicate your decision by adding
031: * "[Contributor] elects to include this software in this distribution
032: * under the [CDDL or GPL Version 2] license." If you do not indicate a
033: * single choice of license, a recipient has the option to distribute
034: * your version of this file under either the CDDL, the GPL Version 2 or
035: * to extend the choice of license to its licensees as provided above.
036: * However, if you add GPL Version 2 code and therefore, elected the GPL
037: * Version 2 license, then the option applies only if the new code is
038: * made subject to such option by the copyright holder.
039: */
040:
041: package org.netbeans.lib.profiler.common.integration;
042:
043: import org.netbeans.lib.profiler.common.AttachSettings;
044: import java.io.File;
045: import java.util.ResourceBundle;
046: import java.util.Vector;
047: import javax.swing.JPanel;
048:
049: /**
050: * Interface to be implemented by each integration provider.
051: *
052: * @author Tomas Hurka
053: * @author Jiri Sedlacek
054: * @deprecated
055: * @since 2006/04/04
056: */
057: public interface IntegrationProvider2 {
058: //~ Inner Interfaces ---------------------------------------------------------------------------------------------------------
059:
060: public interface AutomaticIntegrationPanelListener {
061: //~ Methods --------------------------------------------------------------------------------------------------------------
062:
063: /**
064: * Notifies the listener that some options have changed
065: */
066: public void optionsChanged();
067: }
068:
069: //~ Inner Classes ------------------------------------------------------------------------------------------------------------
070:
071: public abstract class AutomaticIntegrationPanel extends JPanel {
072: //~ Instance fields ------------------------------------------------------------------------------------------------------
073:
074: private Vector listeners = new Vector();
075:
076: //~ Methods --------------------------------------------------------------------------------------------------------------
077:
078: /**
079: * Should return last stored JavaPlatform name (Used name of IDE JavaPlatform)
080: * @return last stored JavaPlatform name (Used name of IDE JavaPlatform)
081: */
082: public abstract String getJavaPlatform();
083:
084: /**
085: * Sets array of Objects used for manipulating with additional options required by the IntegrationProvider2
086: *
087: * @param supportedTarget Supported target
088: * @param targetOS Operating system of the target
089: * @param targetJVM Java platform running the target
090: * @param options additional options required by the IntIntegrationProvider2aram attachSettings Settings of target configuration
091: */
092: public abstract void setOptions(int supportedTarget,
093: String targetOS, String targetJVM,
094: Object[] selectedOptions, AttachSettings attachSettings);
095:
096: /**
097: * Gets array of Objects used for manipulating with additional options required by the IntegrationProvider2
098: *
099: * @return array of Objects representing additional options required by the IntegrationProvider2
100: */
101: public abstract Object[] getOptions();
102:
103: /**
104: * Checks if currently selected options are valid
105: * @return <CODE>true</CODE> if currently selected options are valid
106: */
107: public abstract boolean areOptionsValid();
108:
109: /**
110: * Called when the user changes Java platform for running the target
111: *
112: * @param supportedTarget Supported target
113: * @param targetOS Operating system of the target
114: * @param targetJVM Java platform running the target
115: * @param options additional options required by the IntIntegrationProvider2aram attachSettings Settings of target configuration
116: */
117: public abstract void javaPlatformChanged(int supportedTarget,
118: String targetOS, String targetJVM,
119: Object[] selectedOptions, AttachSettings attachSettings);
120:
121: /**
122: * Here the IntegrationProvider2 can load last stored state (settings) of AutomaticIntegrationPanel
123: *
124: * @param supportedTarget Supported target
125: * @param settingsDir Directory where the panel can store current options (can be null)
126: */
127: public abstract void loadCustomOptions(int supportedTarget,
128: File settingsDir);
129:
130: /**
131: * Here the IntegrationProvider2 can store current state (settings) of AutomaticIntegrationPanel
132: *
133: * @param supportedTarget Supported target
134: * @param settingsDir Directory where the panel can store current options (can be null)
135: * @param javaPlatform Name of Java platform which runs the server (Used name of IDE JavaPlatform)
136: */
137: public abstract void storeCustomOptions(int supportedTarget,
138: File settingsDir, String javaPlatform);
139:
140: public void addOptionsChangeListener(
141: AutomaticIntegrationPanelListener listener) {
142: if (!listeners.contains(listener)) {
143: listeners.add(listener);
144: }
145: }
146:
147: public void removeOptionsChangeListener(
148: AutomaticIntegrationPanelListener listener) {
149: if (listeners.contains(listener)) {
150: listeners.remove(listener);
151: }
152: }
153:
154: protected void fireOptionsChangedEvent() {
155: for (int i = 0; i < listeners.size(); i++) {
156: ((AutomaticIntegrationPanelListener) listeners.get(i))
157: .optionsChanged();
158: }
159: }
160: }
161:
162: //~ Static fields/initializers -----------------------------------------------------------------------------------------------
163:
164: // -----
165: // I18N String constants
166: static final ResourceBundle messages = ResourceBundle
167: .getBundle("org.netbeans.lib.profiler.common.integration.Bundle"); // NOI18N
168:
169: /**
170: * Integration with Java Application
171: */
172: public static final String TARGET_TYPE_APPLICATION = messages
173: .getString("IntegrationProvider_TargetTypeApplication"); // NOI18N
174:
175: /**
176: * Integration with Java Applet
177: */
178: public static final String TARGET_TYPE_APPLET = messages
179: .getString("IntegrationProvider_TargetTypeApplet"); // NOI18N
180:
181: /**
182: * Integration with J2EE Web/Application Server
183: */
184: public static final String TARGET_TYPE_J2EEAPPLICATION = messages
185: .getString("IntegrationProvider_TargetTypeJ2SeApplication"); // NOI18N
186:
187: /**
188: * Integration with Database
189: */
190: public static final String TARGET_TYPE_DATABASE = messages
191: .getString("IntegrationProvider_TargetTypeDatabase"); // NOI18N
192:
193: // -----
194:
195: //~ Methods ------------------------------------------------------------------------------------------------------------------
196:
197: /**
198: * Gets the HTML-formatted description of additional steps needed for finishing integration with supported target
199: *
200: * @param supportedTarget Supported target
201: * @param targetOS Operating system of the target
202: * @param targetJVM Java platform running the target
203: * @param targetJavaHomePath JAVA_HOME of target JVM
204: * @param selectedOptions other InteIntegrationProvider2cific parameters (typically configuration files to modify)
205: * @param attachSettings Settings of target configuration
206: * @return HTML-formatted description of additional steps needed for finishing integration with supported target
207: */
208: public String getAdditionalStepsInstructions(int supportedTarget,
209: String targetOS, String targetJVM,
210: String targetJavaHomePath, Object[] selectedOptions,
211: AttachSettings attachSettings);
212:
213: /**
214: * Gets panel for selecting parameters required for automatic integration.
215: * This method must be implemented by every IntegrationProvider2 which supports automatic integration.
216: *
217: * @return panel for selecting parameters required for automatic integration
218: */
219: public AutomaticIntegrationPanel getAutomaticIntegrationPanel();
220:
221: /**
222: * Returns number used for sorting Targets of the same Target Type
223: * @return number used for sorting Targets of the same Target Type
224: */
225: public int getIntegrationProviderNumber();
226:
227: /**
228: * Gets the HTML-formatted summary of integration steps that will be automatically performed
229: *
230: * @param supportedTarget Supported target
231: * @param targetOS Operating system of the target
232: * @param targetJVM Java platform running the target
233: * @param targetJavaHomePath JAVA_HOME of target JVM
234: * @param selectedOptions other InteIntegrationProvider2cific parameters (typically configuration files to modify)
235: * @param attachSettings Settings of target configuration
236: * @return HTML-formatted summary of integration steps that will be automatically performed
237: */
238: public String getIntegrationReviewText(int supportedTarget,
239: String targetOS, String targetJVM,
240: String targetJavaHomePath, Object[] selectedOptions,
241: AttachSettings attachSettings);
242:
243: /**
244: * Gets the textual description of last error
245: * @return textual description of last error
246: */
247: public String getLastErrorMessage();
248:
249: /**
250: * Gets the HTML-formatted description of manual steps needed for integration with supported target
251: * @param supportedTarget Supported target
252: * @param targetOS Operating system of the target
253: * @param targetJVM Java platform running the target
254: * @param attachSettings Settings of target configuration
255: * @return HTML-formatted description of manual steps needed for integration with supported target
256: */
257: public String getManualIntegrationStepsInstructions(
258: int supportedTarget, String targetOS, String targetJVM,
259: AttachSettings attachSettings);
260:
261: /**
262: * Checks if this provider is the only one for its target type (Java Application, Applet)
263: * @return <CODE>true</CODE> if this provider is the only one for its target type
264: */
265: public boolean isSingular();
266:
267: /**
268: * Returns supported target (defined by concrete IntegrationProvider2 implementation)
269: *
270: * @param supportedTargetIndex Index of supported target
271: * @return Supported target
272: */
273: public int getSupportedTarget(int supportedTargetIndex);
274:
275: /**
276: * Returns supported target
277: * @param supportedTargetName Name of supported target
278: * @return Supported target
279: */
280: public int getSupportedTarget(String supportedTargetName);
281:
282: /**
283: * Returns name of supported target
284: * @param supportedTarget Supported target
285: * @return Name of supported target
286: */
287: public String getSupportedTargetName(int supportedTarget);
288:
289: /**
290: * Returns number of targets supported by integration provider
291: * @return Number of supported targets
292: */
293: public int getSupportedTargetsCount();
294:
295: /**
296: * Returns type of targets supported by integration provider
297: * @return type of supported target
298: */
299: public String getSupportedTargetsType();
300:
301: /**
302: * Performs automatic integration
303: *
304: * @param supportedTarget Supported target
305: * @param targetOS Operating system of the target
306: * @param targetJVM Java platform running the target
307: * @param targetJavaHomePath JAVA_HOME of target JVM
308: * @param selectedOptions other InteIntegrationProvider2cific parameters (typically configuration files to modify)
309: * @param attachSettings Settings of target configuration
310: * @return <CODE>true</CODE> if automatic integration was successful
311: */
312: public boolean performIntegration(int supportedTarget,
313: String targetOS, String targetJVM,
314: String targetJavaHomePath, Object[] selectedOptions,
315: AttachSettings attachSettings);
316:
317: /**
318: * Automatically starts the target in separate thread
319: *
320: * @param supportedTarget Supported target
321: * @param targetOS Operating system of the target
322: * @param targetJVM Java platform running the target
323: * @param targetJavaHomePath JAVA_HOME of target JVM
324: * @param selectedOptions other InteIntegrationProvider2cific parameters (typically configuration files to modify)
325: * @param attachSettings Settings of target configuration
326: */
327: public void startTarget(int supportedTarget, String targetOS,
328: String targetJVM, String targetJavaHomePath,
329: Object[] selectedOptions, AttachSettings attachSettings);
330:
331: /**
332: * Checks if automatic integration with target configuration is supported by the integration provider
333: * @param supportedTarget Supported target
334: * @param targetOS Operating system of the target
335: * @param attachSettings Settings of target configuration
336: * @return <CODE>true</CODE> if this target configuration is supported
337: */
338: public boolean supportsAutomaticIntegration(int supportedTarget,
339: String targetOS, AttachSettings attachSettings);
340:
341: /**
342: * Checks if provided java platform is supported by the IntegrationProvider2
343: *
344: * @param supportedTarget Supported target
345: * @param targetJVM Java platform running the target
346: * @param attachSettings Settings of target configuration
347: * @return <CODE>true</CODE> if provided java platform is supported by the IntIntegrationProvider2
348: */
349: public boolean supportsJavaPlatform(int supportedTarget,
350: String targetJVM, AttachSettings attachSettings);
351:
352: /**
353: * Checks if automatic target startup is supported by the IntegrationProvider2
354: *
355: * @param supportedTarget Supported target
356: * @param targetOS Operating system of the target
357: * @param targetJVM Java platform running the target
358: * @param targetJavaHomePath JAVA_HOME of target JVM
359: * @param selectedOptions other InteIntegrationProvider2cific parameters (typically configuration files to modify)
360: * @param attachSettings Settings of target configuration
361: * @return <CODE>true</CODE> if automatic target startup is supported by the IntegrIntegrationProvider2
362: */
363: public boolean supportsTargetStartup(int supportedTarget,
364: String targetOS, String targetJVM,
365: String targetJavaHomePath, Object[] selectedOptions,
366: AttachSettings attachSettings);
367: }
|