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.text.MessageFormat;
045: import java.util.ResourceBundle;
046:
047: /**
048: * Abstract implementation of IntegrationProvider2.
049: *
050: * @author Jiri Sedlacek
051: */
052: public abstract class AbstractIntegrationProvider implements
053: IntegrationProvider2 {
054: //~ Static fields/initializers -----------------------------------------------------------------------------------------------
055:
056: // -----
057: // I18N String constants
058: private static final ResourceBundle messages = ResourceBundle
059: .getBundle("org.netbeans.lib.profiler.common.integration.Bundle"); // NOI18N
060: private static final String WORKING_DIRECTORY_HINT = messages
061: .getString("AbstractIntegrationProvider_WorkingDirectoryHint"); // NOI18N
062: // -----
063: public static final int SUPPORTED_TARGET_NONE = -1;
064:
065: //~ Instance fields ----------------------------------------------------------------------------------------------------------
066:
067: protected String lastErrorMessage = ""; //NOI18N
068: protected int[] supportedTargets;
069:
070: //~ Constructors -------------------------------------------------------------------------------------------------------------
071:
072: protected AbstractIntegrationProvider() {
073: // other possible initialization comes here
074: }
075:
076: protected AbstractIntegrationProvider(int[] supportedTargets) {
077: this ();
078: this .supportedTargets = supportedTargets;
079: }
080:
081: //~ Methods ------------------------------------------------------------------------------------------------------------------
082:
083: public String getAdditionalStepsInstructions(int supportedTarget,
084: String targetOS, String targetJVM,
085: String targetJavaHomePath, Object[] selectedOptions,
086: AttachSettings attachSettings) {
087: return ""; //NOI18N
088: }
089:
090: public AutomaticIntegrationPanel getAutomaticIntegrationPanel() {
091: return null;
092: }
093:
094: public String getIntegrationReviewText(int supportedTarget,
095: String targetOS, String targetJVM,
096: String targetJavaHomePath, Object[] selectedOptions,
097: AttachSettings attachSettings) {
098: return ""; //NOI18N
099: }
100:
101: public String getLastErrorMessage() {
102: return lastErrorMessage;
103: }
104:
105: public String getManualIntegrationStepsInstructions(
106: int supportedTarget, String targetOS, String targetJVM,
107: AttachSettings attachSettings) {
108: return ""; //NOI18N
109: }
110:
111: public int getSupportedTarget(int supportedTargetIndex) {
112: if ((supportedTargetIndex < 0)
113: || (supportedTargetIndex >= getSupportedTargetsCount())) {
114: return SUPPORTED_TARGET_NONE;
115: }
116:
117: return supportedTargets[supportedTargetIndex];
118: }
119:
120: public int getSupportedTarget(String supportedTargetName) {
121: for (int i = 0; i < getSupportedTargetsCount(); i++) {
122: if (getSupportedTargetName(getSupportedTarget(i)).equals(
123: supportedTargetName)) {
124: return getSupportedTarget(i);
125: }
126: }
127:
128: return SUPPORTED_TARGET_NONE;
129: }
130:
131: // --- Shared implementation -------------------------------------------------
132: public int getSupportedTargetsCount() {
133: if (supportedTargets == null) {
134: return 0;
135: }
136:
137: return supportedTargets.length;
138: }
139:
140: // --- Abstract methods to be implemented by descendants of this class -------
141: public abstract String getSupportedTargetsType();
142:
143: public int getIntegrationProviderNumber() {
144: return Integer.MAX_VALUE;
145: }
146:
147: // --- Default implementation of IntegrationProvider2 methods -----------------
148: public boolean isSingular() {
149: return false;
150: }
151:
152: public String getSupportedTargetName(int supportedTarget) {
153: return ""; //NOI18N
154: }
155:
156: public boolean performIntegration(int supportedTarget,
157: String targetOS, String targetJVM,
158: String targetJavaHomePath, Object[] selectedOptions,
159: AttachSettings attachSettings) {
160: return false;
161: }
162:
163: public void startTarget(int supportedTarget, String targetOS,
164: String targetJVM, String targetJavaHomePath,
165: Object[] selectedOptions, AttachSettings attachSettings) {
166: }
167:
168: public boolean supportsAutomaticIntegration(int supportedTarget,
169: String targetOS, AttachSettings attachSettings) {
170: return false;
171: }
172:
173: public boolean supportsJavaPlatform(int supportedTarget,
174: String targetJVM, AttachSettings attachSettings) {
175: if (!attachSettings.isRemote() && !attachSettings.isDirect()) {
176: return targetJVM != IntegrationUtils.PLATFORM_JAVA_50;
177: }
178:
179: return true;
180: }
181:
182: public boolean supportsTargetStartup(int supportedTarget,
183: String targetOS, String targetJVM,
184: String targetJavaHomePath, Object[] selectedOptions,
185: AttachSettings attachSettings) {
186: return false;
187: }
188: }
|