Line 0
Link Here
|
|
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
8 |
* Development and Distribution License("CDDL") (collectively, the |
9 |
* "License"). You may not use this file except in compliance with the |
10 |
* License. You can obtain a copy of the License at |
11 |
* http://www.netbeans.org/cddl-gplv2.html |
12 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
13 |
* specific language governing permissions and limitations under the |
14 |
* License. When distributing the software, include this License Header |
15 |
* Notice in each file and include the License file at |
16 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this |
17 |
* particular file as subject to the "Classpath" exception as provided |
18 |
* by Sun in the GPL Version 2 section of the License file that |
19 |
* accompanied this code. If applicable, add the following below the |
20 |
* License Header, with the fields enclosed by brackets [] replaced by |
21 |
* your own identifying information: |
22 |
* "Portions Copyrighted [year] [name of copyright owner]" |
23 |
* |
24 |
* Contributor(s): |
25 |
* The Original Software is NetBeans. The Initial Developer of the Original |
26 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun |
27 |
* Microsystems, Inc. All Rights Reserved. |
28 |
* |
29 |
* If you wish your version of this file to be governed by only the CDDL |
30 |
* or only the GPL Version 2, indicate your decision by adding |
31 |
* "[Contributor] elects to include this software in this distribution |
32 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
33 |
* single choice of license, a recipient has the option to distribute |
34 |
* your version of this file under either the CDDL, the GPL Version 2 or |
35 |
* to extend the choice of license to its licensees as provided above. |
36 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
37 |
* Version 2 license, then the option applies only if the new code is |
38 |
* made subject to such option by the copyright holder. |
39 |
*/ |
40 |
|
41 |
package org.netbeans.modules.profiler.j2ee.generic; |
42 |
|
43 |
import org.netbeans.lib.profiler.common.AttachSettings; |
44 |
import org.netbeans.lib.profiler.common.integration.IntegrationUtils; |
45 |
import java.text.MessageFormat; |
46 |
import java.util.ResourceBundle; |
47 |
import org.netbeans.modules.profiler.attach.providers.AbstractIntegrationProvider; |
48 |
import org.netbeans.modules.profiler.attach.providers.IntegrationCategorizer; |
49 |
import org.netbeans.modules.profiler.attach.providers.TargetPlatformEnum; |
50 |
import org.netbeans.modules.profiler.attach.spi.IntegrationProvider; |
51 |
import org.netbeans.modules.profiler.attach.wizard.steps.NullWizardStep; |
52 |
import org.netbeans.modules.profiler.attach.wizard.steps.WizardStep; |
53 |
|
54 |
|
55 |
/** |
56 |
* |
57 |
* @author Tomas Hurka |
58 |
* @author Jaroslav Bachorik |
59 |
*/ |
60 |
@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.profiler.attach.spi.IntegrationProvider.class) |
61 |
public class GenericWebAppServerIntegrationProvider extends AbstractIntegrationProvider { |
62 |
//~ Static fields/initializers ----------------------------------------------------------------------------------------------- |
63 |
|
64 |
private static final ResourceBundle messages = ResourceBundle.getBundle("org.netbeans.modules.profiler.j2ee.Bundle"); // NOI18N |
65 |
private static final String GENERIC_WEBAPP_SERVER_STRING = messages.getString("GenericWebAppServerIntegrationProvider_GenericWebappServerString"); // NOI18N |
66 |
private static final String PATH_TO_JDK_DIRECTORY_STRING = messages.getString("GenericWebAppServerIntegrationProvider_PathToJdkDirectory"); // NOI18N |
67 |
private static final String MANUAL_REMOTE_STEP3_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_ManualRemoteStep3Message"); // NOI18N |
68 |
private static final String MANUAL_REMOTE_STEP4_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_ManualRemoteStep4Message"); // NOI18N |
69 |
private static final String MANUAL_REMOTE_STEP5_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_ManualRemoteStep5Message"); // NOI18N |
70 |
private static final String MANUAL_DIRECT_STEP1_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_ManualDirectStep1Message"); // NOI18N |
71 |
private static final String MANUAL_DIRECT_STEP2_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_ManualDirectStep2Message"); // NOI18N |
72 |
private static final String MANUAL_DIRECT_STEP3_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_ManualDirectStep3Message"); // NOI18N |
73 |
private static final String MANUAL_DYNAMIC_STEP1_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_ManualDynamicStep1Message"); // NOI18N |
74 |
private static final String MANUAL_DYNAMIC_STEP2_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_ManualDynamicStep2Message"); // NOI18N |
75 |
private static final String DYNAMIC_WARNING_MESSAGE = messages.getString("GenericWebAppServerIntegrationProvider_DynamicWarningMessage"); // NOI18N |
76 |
private static final WizardStep NULL_WIZARD_STEP = new NullWizardStep(); |
77 |
|
78 |
//~ Methods ------------------------------------------------------------------------------------------------------------------ |
79 |
|
80 |
public IntegrationProvider.IntegrationHints getAfterInstallationHints(AttachSettings attachSettings, boolean b) { |
81 |
return new IntegrationProvider.IntegrationHints(); |
82 |
} |
83 |
|
84 |
public WizardStep getAttachedWizard() { |
85 |
return NULL_WIZARD_STEP; |
86 |
} |
87 |
|
88 |
// <editor-fold defaultstate="collapsed" desc="WizardIntegrationProvider implementation"> |
89 |
public IntegrationProvider.IntegrationHints getIntegrationReview(AttachSettings attachSettings) { |
90 |
return null; |
91 |
} |
92 |
|
93 |
public IntegrationProvider.IntegrationHints getModificationHints(AttachSettings attachSettings) { |
94 |
String targetOS = attachSettings.getHostOS(); |
95 |
|
96 |
// Remote attach instructions |
97 |
if (attachSettings.isRemote()) { |
98 |
return getManualRemoteIntegrationStepsInstructions(targetOS, attachSettings); |
99 |
} |
100 |
// Local direct attach |
101 |
else if (attachSettings.isDirect()) { |
102 |
return getManualLocalDirectIntegrationStepsInstructions(targetOS, attachSettings); |
103 |
} |
104 |
// Local dynamic attach |
105 |
else { |
106 |
return getManualLocalDynamicIntegrationStepsInstructions(targetOS, attachSettings); |
107 |
} |
108 |
} |
109 |
|
110 |
public String getTitle() { |
111 |
return GENERIC_WEBAPP_SERVER_STRING; |
112 |
} |
113 |
|
114 |
public void categorize(IntegrationCategorizer integrationCategorizer) { |
115 |
integrationCategorizer.addAppserver(this, getAttachWizardPriority()); |
116 |
} |
117 |
|
118 |
public void modify(AttachSettings attachSettings) { |
119 |
} |
120 |
|
121 |
public void run(AttachSettings attachSettings) { |
122 |
} |
123 |
|
124 |
public boolean supportsAutomation() { |
125 |
return false; |
126 |
} |
127 |
|
128 |
public boolean supportsDirect() { |
129 |
return true; |
130 |
} |
131 |
|
132 |
public boolean supportsDynamic() { |
133 |
return true; |
134 |
} |
135 |
|
136 |
public boolean supportsDynamicPid() { |
137 |
return true; |
138 |
} |
139 |
|
140 |
public boolean supportsLocal() { |
141 |
return true; |
142 |
} |
143 |
|
144 |
public boolean supportsManual() { |
145 |
return true; |
146 |
} |
147 |
|
148 |
public boolean supportsRemote() { |
149 |
return true; |
150 |
} |
151 |
|
152 |
protected int getAttachWizardPriority() { |
153 |
return 1; |
154 |
} |
155 |
|
156 |
private IntegrationProvider.IntegrationHints getManualLocalDirectIntegrationStepsInstructions(String targetOS, |
157 |
AttachSettings attachSettings) { |
158 |
IntegrationProvider.IntegrationHints instructions = new IntegrationProvider.IntegrationHints(); |
159 |
|
160 |
// Step 1 |
161 |
String pathToJDKDirectory = "<" |
162 |
+ MessageFormat.format(PATH_TO_JDK_DIRECTORY_STRING, |
163 |
new Object[] { IntegrationUtils.getJavaPlatformName(getTargetJava()) }) |
164 |
+ ">"; // NOI18N |
165 |
instructions.addStep(MessageFormat.format(MANUAL_DIRECT_STEP1_MESSAGE, |
166 |
new Object[] { |
167 |
IntegrationUtils.getJavaPlatformName(getTargetJava()), |
168 |
IntegrationUtils.getExportEnvVariableValueString(targetOS, "JAVA_HOME", |
169 |
pathToJDKDirectory, true) |
170 |
})); // NOI18N |
171 |
|
172 |
// Step 2 |
173 |
instructions.addStep(MessageFormat.format(MANUAL_DIRECT_STEP2_MESSAGE, |
174 |
new Object[] { |
175 |
IntegrationUtils.getProfilerAgentCommandLineArgs(targetOS, getTargetJava(), |
176 |
attachSettings.isRemote(), |
177 |
attachSettings.getPort()) |
178 |
})); |
179 |
|
180 |
// Step 3 |
181 |
instructions.addStep(MANUAL_DIRECT_STEP3_MESSAGE); |
182 |
|
183 |
// Note about spaces in path when starting Profiler agent |
184 |
if (IntegrationUtils.isWindowsPlatform(targetOS)) { |
185 |
instructions.addWarning(SPACES_IN_PATH_WARNING_MSG); |
186 |
} |
187 |
|
188 |
// Note about decreasing CPU profiling overhead |
189 |
instructions.addHint(REDUCE_OVERHEAD_MSG); |
190 |
|
191 |
// Note about export vs. setenv on UNIXes |
192 |
if (!IntegrationUtils.isWindowsPlatform(targetOS)) { |
193 |
instructions.addHint(EXPORT_SETENV_MSG); |
194 |
} |
195 |
|
196 |
return instructions; |
197 |
} |
198 |
|
199 |
private IntegrationProvider.IntegrationHints getManualLocalDynamicIntegrationStepsInstructions(String targetOS, |
200 |
AttachSettings attachSettings) { |
201 |
IntegrationProvider.IntegrationHints instructions = new IntegrationProvider.IntegrationHints(); |
202 |
|
203 |
// Step 1 |
204 |
instructions.addStep(MessageFormat.format(MANUAL_DYNAMIC_STEP1_MESSAGE, |
205 |
new Object[] { IntegrationUtils.getJavaPlatformName(getTargetJava()) })); |
206 |
// Step 2 |
207 |
instructions.addStep(MANUAL_DYNAMIC_STEP2_MESSAGE); |
208 |
|
209 |
// Note about spaces in path when starting Profiler agent |
210 |
if (IntegrationUtils.isWindowsPlatform(targetOS)) { |
211 |
instructions.addWarning(SPACES_IN_PATH_WARNING_MSG); |
212 |
} |
213 |
|
214 |
// Note about decreasing CPU profiling overhead |
215 |
instructions.addHint(REDUCE_OVERHEAD_MSG); |
216 |
|
217 |
// Note about export vs. setenv on UNIXes |
218 |
if (!IntegrationUtils.isWindowsPlatform(targetOS)) { |
219 |
instructions.addHint(EXPORT_SETENV_MSG); |
220 |
} |
221 |
|
222 |
instructions.addWarning(MessageFormat.format(DYNAMIC_WARNING_MESSAGE, |
223 |
new Object[] { |
224 |
IntegrationUtils.getJavaPlatformName(getTargetJava()), |
225 |
IntegrationUtils.getProfilerAgentCommandLineArgs(targetOS, |
226 |
getTargetJava(), |
227 |
attachSettings.isRemote(), |
228 |
attachSettings.getPort()) |
229 |
})); |
230 |
|
231 |
return instructions; |
232 |
} |
233 |
|
234 |
// </editor-fold> |
235 |
private IntegrationProvider.IntegrationHints getManualRemoteIntegrationStepsInstructions(String targetOS, |
236 |
AttachSettings attachSettings) { |
237 |
IntegrationProvider.IntegrationHints instructions = new IntegrationProvider.IntegrationHints(); |
238 |
|
239 |
// Step 1 |
240 |
instructions.addStep(getManualRemoteStep1(targetOS)); |
241 |
|
242 |
// Step 2 |
243 |
instructions.addStep(getManualRemoteStep2(targetOS)); |
244 |
|
245 |
// Step 3 |
246 |
String pathToJDKDirectory = "<" |
247 |
+ MessageFormat.format(PATH_TO_JDK_DIRECTORY_STRING, |
248 |
new Object[] { IntegrationUtils.getJavaPlatformName(getTargetJava()) }) |
249 |
+ ">"; // NOI18N |
250 |
instructions.addStep(MessageFormat.format(MANUAL_REMOTE_STEP3_MESSAGE, |
251 |
new Object[] { |
252 |
IntegrationUtils.getJavaPlatformName(getTargetJava()), |
253 |
IntegrationUtils.getExportEnvVariableValueString(targetOS, "JAVA_HOME", |
254 |
pathToJDKDirectory, true) |
255 |
})); // NOI18N |
256 |
|
257 |
// Step 4 |
258 |
instructions.addStep(MessageFormat.format(MANUAL_REMOTE_STEP4_MESSAGE, |
259 |
new Object[] { |
260 |
IntegrationUtils.getProfilerAgentCommandLineArgs(targetOS, getTargetJava(), |
261 |
attachSettings.isRemote(), |
262 |
attachSettings.getPort()), |
263 |
REMOTE_ABSOLUTE_PATH_HINT |
264 |
})); |
265 |
|
266 |
// Step 5 |
267 |
instructions.addStep(MANUAL_REMOTE_STEP5_MESSAGE); |
268 |
|
269 |
// Note about spaces in path when starting Profiler agent |
270 |
if (IntegrationUtils.isWindowsPlatform(targetOS)) { |
271 |
instructions.addWarning(SPACES_IN_PATH_WARNING_MSG); |
272 |
} |
273 |
|
274 |
// Note about decreasing CPU profiling overhead |
275 |
instructions.addHint(REDUCE_OVERHEAD_MSG); |
276 |
|
277 |
// Note about export vs. setenv on UNIXes |
278 |
if (!IntegrationUtils.isWindowsPlatform(targetOS)) { |
279 |
instructions.addHint(EXPORT_SETENV_MSG); |
280 |
} |
281 |
|
282 |
return instructions; |
283 |
} |
284 |
} |