diff --git a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/resources/build-impl.xsl b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/resources/build-impl.xsl --- a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/resources/build-impl.xsl +++ b/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/resources/build-impl.xsl @@ -300,6 +300,23 @@ + + + + Empty placeholder for easier customization. + You can override this target in the ../build.xml file. + + + + Empty placeholder for easier customization. + You can override this target in the ../build.xml file. + + + -profile-pre-init, init, -profile-post-init + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + pre-init,init-private,init-userdir,init-user,init-project,do-init,post-init,init-check,-init-taskdefs @@ -818,7 +835,71 @@ - + + ================= + PROFILING SECTION + ================= + + + + Profile a J2EE project in the IDE. + + profiler.startserver.target + start-profiled-server-extraargs + start-profiled-server + + profiler.info.jvmargs.extra + + + + ${profiler.startserver.target} + + + run + + + start-loadgen + + + + + + ${profiler.j2ee.serverForceRestart} + ${profiler.j2ee.serverStartupTimeout} + ${profiler.info.javaPlatform} + + ${profiler.info.jvmargs.agent} + + + ${profiler.j2ee.agentID} + + + + + + + ${profiler.j2ee.serverForceRestart} + ${profiler.j2ee.serverStartupTimeout} + ${profiler.info.javaPlatform} + + ${profiler.info.jvmargs.extra} + + + ${profiler.info.jvmargs.agent} + + + ${profiler.j2ee.agentID} + + + + + + + ${profiler.loadgen.path} + + + + CLEANUP SECTION diff --git a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl --- a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl +++ b/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl @@ -832,6 +832,23 @@ + + + + Empty placeholder for easier customization. + You can override this target in the ../build.xml file. + + + + Empty placeholder for easier customization. + You can override this target in the ../build.xml file. + + + -profile-pre-init, init, -profile-post-init + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + -pre-init,-init-private,-init-userdir,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-java,-init-macrodef-nbjpda,-init-macrodef-debug,-init-taskdefs,-init-ap-cmdline @@ -1332,7 +1349,71 @@ netbeans.home init,-pre-debug-fix,-do-debug-fix - + + + ================= + PROFILING SECTION + ================= + + + + Profile a J2EE project in the IDE. + + profiler.startserver.target + start-profiled-server-extraargs + start-profiled-server + + profiler.info.jvmargs.extra + + + + ${profiler.startserver.target} + + + run + + + start-loadgen + + + + + + ${profiler.j2ee.serverForceRestart} + ${profiler.j2ee.serverStartupTimeout} + ${profiler.info.javaPlatform} + + ${profiler.info.jvmargs.agent} + + + ${profiler.j2ee.agentID} + + + + + + + ${profiler.j2ee.serverForceRestart} + ${profiler.j2ee.serverStartupTimeout} + ${profiler.info.javaPlatform} + + ${profiler.info.jvmargs.extra} + + + ${profiler.info.jvmargs.agent} + + + ${profiler.j2ee.agentID} + + + + + + + ${profiler.loadgen.path} + + + JAVADOC SECTION @@ -1604,7 +1685,42 @@ netbeans.home init,-pre-debug-fix,-do-debug-fix-test - + + + ========================= + TESTS PROFILING SECTION + ========================= + + + + netbeans.home + profile-init,compile-test-single + + + + + + + + + + + + + + + + + + + + + + + + + + CLEANUP SECTION diff --git a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl @@ -692,7 +692,70 @@ - + + + + + Empty placeholder for easier customization. + You can override this target in the ../build.xml file. + + + + Empty placeholder for easier customization. + You can override this target in the ../build.xml file. + + + + + resolve + + name + + + value + + + + + + + + profile + + classname + ${main.class} + + + customize + true + + + + + + + + + + + + + + + + + + + + + + + + -profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + nbjpdastart @@ -1334,7 +1397,92 @@ netbeans.home init,-pre-debug-fix,-do-debug-fix - + + + ================= + PROFILING SECTION + ================= + + + + netbeans.home + profile-init,compile + Profile a project in the IDE. + + + + + + + + + + netbeans.home + profile-init,compile-single + Profile a selected class in the IDE. + Must select one file in the IDE or set profile.class + + + + + + + + + + ========================= + APPLET PROFILING SECTION + ========================= + + + + netbeans.home + profile-init,compile-single + + + + + + + + + + + + + + + ========================= + TESTS PROFILING SECTION + ========================= + + + + netbeans.home + profile-init,compile-test-single + + + + + + + + + + + + + + + + + + + + + + + =============== JAVADOC SECTION diff --git a/profiler.j2ee/manifest.mf b/profiler.j2ee/manifest.mf --- a/profiler.j2ee/manifest.mf +++ b/profiler.j2ee/manifest.mf @@ -2,4 +2,4 @@ OpenIDE-Module: org.netbeans.modules.profiler.j2ee/1 OpenIDE-Module-Layer: org/netbeans/modules/profiler/j2ee/mf-layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/j2ee/Bundle.properties -OpenIDE-Module-Specification-Version: 1.11 +OpenIDE-Module-Specification-Version: 1.12 diff --git a/profiler.j2ee/src/org/netbeans/modules/profiler/j2ee/J2EEProjectTypeProfiler.java b/profiler.j2ee/src/org/netbeans/modules/profiler/j2ee/J2EEProjectTypeProfiler.java --- a/profiler.j2ee/src/org/netbeans/modules/profiler/j2ee/J2EEProjectTypeProfiler.java +++ b/profiler.j2ee/src/org/netbeans/modules/profiler/j2ee/J2EEProjectTypeProfiler.java @@ -48,11 +48,9 @@ import org.netbeans.api.java.platform.Specification; import org.netbeans.api.project.Project; import org.netbeans.api.project.ProjectManager; -import org.netbeans.lib.profiler.ProfilerLogger; import org.netbeans.lib.profiler.client.ClientUtils; import org.netbeans.lib.profiler.client.ClientUtils.SourceCodeSelection; import org.netbeans.lib.profiler.common.SessionSettings; -import org.netbeans.lib.profiler.common.filters.SimpleFilter; import org.netbeans.lib.profiler.common.integration.IntegrationUtils; import org.netbeans.lib.profiler.global.CommonConstants; import org.netbeans.lib.profiler.marker.MethodMarker; @@ -75,25 +73,19 @@ import org.openide.DialogDescriptor; import org.openide.ErrorManager; import org.openide.NotifyDescriptor; -import org.openide.filesystems.FileLock; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.modules.InstalledFileLocator; import org.openide.util.NbBundle; import org.openide.util.WeakListeners; -import org.openide.xml.XMLUtil; import org.w3c.dom.Document; import org.w3c.dom.Element; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.*; -import java.text.MessageFormat; -import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; import java.util.Map; import java.util.Properties; -import java.util.Set; import javax.swing.JComponent; import javax.swing.event.ChangeListener; import org.netbeans.api.project.ProjectUtils; @@ -350,7 +342,7 @@ final FileObject profiledClass) { switch (type) { case TARGET_PROFILE: - return "profile-j2ee"; // NOI18N + return "profile"; // NOI18N case TARGET_PROFILE_TEST: return null; // not currently supported // "profile-test"; // NOI18N case TARGET_PROFILE_TEST_SINGLE: @@ -500,149 +492,6 @@ } } - public boolean checkProjectIsModifiedForProfiler(final Project project) { - if (ProjectUtilities.isProfilerIntegrated(project)) { - return true; // already modified by this version, nothing more to do - } - - String projectName = ProjectUtils.getInformation(project).getDisplayName(); - String caption = MessageFormat.format(MODIFY_BUILDSCRIPT_CAPTION, new Object[] { projectName }); - String message = MessageFormat.format(MODIFY_BUILDSCRIPT_MSG, new Object[] { projectName, "build-before-profiler.xml" }); // NOI18N - if (ProfilerDialogs.notify(new NotifyDescriptor(message, caption, NotifyDescriptor.OK_CANCEL_OPTION, - NotifyDescriptor.INFORMATION_MESSAGE, new Object[] { NotifyDescriptor.OK_OPTION, - NotifyDescriptor.CANCEL_OPTION }, NotifyDescriptor.OK_OPTION)) != NotifyDescriptor.OK_OPTION) { - return false; // cancelled by the user - } - - // not yet modified for profiler => create profiler-build-impl & modify build.xml and project.xml - final Element profilerFragment = XMLUtil.createDocument("ignore", null, null, null) - .createElementNS(ProjectUtilities.PROFILER_NAME_SPACE, "data"); // NOI18N - profilerFragment.setAttribute(PROFILE_VERSION_ATTRIBUTE, VERSION_NUMBER); // NOI18N - - ProjectUtils.getAuxiliaryConfiguration(project).putConfigurationFragment(profilerFragment, false); - - try { - ProjectManager.getDefault().saveProject(project); - } catch (IOException e1) { - err.notify(e1); - ProfilerLogger.log(e1); - - return false; - } - - // we are going to regenerate the build script in one of 3 cases: - // 1. it has not been generated yet - // 2. the profiler version has been changed (see above) - // 3. the stylesheet changed (usually should be caught by 2.) - final GeneratedFilesHelper gfh = new GeneratedFilesHelper(project.getProjectDirectory()); - int flags = gfh.getBuildScriptState("nbproject/profiler-build-impl.xml", - J2EEProjectTypeProfiler.class.getResource("profiler-build-impl.xsl")); // NOI18N - - if (((flags & GeneratedFilesHelper.FLAG_MISSING) != 0) || ((flags & GeneratedFilesHelper.FLAG_OLD_STYLESHEET) != 0)) { - try { - if ((flags & GeneratedFilesHelper.FLAG_MODIFIED) != 0) { - if (ProfilerDialogs.notify(new NotifyDescriptor.Confirmation(MessageFormat.format(REGENERATE_BUILDSCRIPT_MSG, - new Object[] { - "profiler-build-impl.xml" - }), // NOI18N - NotifyDescriptor.OK_CANCEL_OPTION)) != NotifyDescriptor.OK_OPTION) { - return false; - } - } - - gfh.generateBuildScriptFromStylesheet("nbproject/profiler-build-impl.xml", - J2EEProjectTypeProfiler.class.getResource("profiler-build-impl.xsl")); // NOI18N - } catch (IOException e1) { - err.notify(ErrorManager.WARNING, e1); - - return false; - } - } - - final String buildScript = ProjectUtilities.getProjectBuildScript(project); - - if (buildScript == null) { - ProfilerDialogs.notify(new NotifyDescriptor.Message(MessageFormat.format(CANNOT_FIND_BUILDSCRIPT_MSG, - new Object[] { "build.xml" }), // NOI18N - NotifyDescriptor.ERROR_MESSAGE)); - - return false; - } - - if (!ProjectUtilities.backupBuildScript(project)) { - if (ProfilerDialogs.notify(new NotifyDescriptor.Confirmation(CANNOT_BACKUP_BUILDSCRIPT_MSG, - NotifyDescriptor.OK_CANCEL_OPTION, - NotifyDescriptor.WARNING_MESSAGE)) != NotifyDescriptor.OK_OPTION) { - return false; // cancelled by the user - } - } - - final StringBuffer newDataBuffer = new StringBuffer(buildScript.length() + 200); - final int importIndex = buildScript.indexOf(STANDARD_IMPORT_STRING); - - if (importIndex == -1) { - // notify the user that the build script cannot be modified, and he should perform the change himself - ProfilerDialogs.notify(new NotifyDescriptor.Message(MessageFormat.format(MODIFY_BUILDSCRIPT_MANUALLY_MSG, - new Object[] { - "build.xml", - "" - }), // NOI18N - NotifyDescriptor.WARNING_MESSAGE)); - - return false; - } - - String indent = ""; // NOI18N - int idx = importIndex - 1; - - while (idx >= 0) { - if (buildScript.charAt(idx) == ' ') { - indent = " " + indent; // NOI18N - } else if (buildScript.charAt(idx) == '\t') { - indent = "\t" + indent; // NOI18N - } else { - break; - } - - idx--; - } - - newDataBuffer.append(buildScript.substring(0, importIndex + STANDARD_IMPORT_STRING.length() + 1)); - newDataBuffer.append("\n"); // NOI18N - newDataBuffer.append(indent); - newDataBuffer.append(PROFILER_IMPORT_STRING); - newDataBuffer.append(buildScript.substring(importIndex + STANDARD_IMPORT_STRING.length() + 1)); - - final FileObject buildFile = getProjectBuildScript(project); - FileLock lock = null; - OutputStreamWriter writer = null; - - try { - lock = buildFile.lock(); - writer = new OutputStreamWriter(buildFile.getOutputStream(lock), "UTF-8"); // NOI18N // According to Issue 65557, build.xml uses UTF-8, not default encoding! - writer.write(newDataBuffer.toString()); - } catch (FileNotFoundException e1) { - err.notify(e1); - ProfilerLogger.log(e1); - } catch (IOException e1) { - err.notify(e1); - ProfilerLogger.log(e1); - } finally { - if (lock != null) { - lock.releaseLock(); - } - - if (writer != null) { - try { - writer.close(); - } catch (IOException ex) { - } - } - } - - return true; - } - public void configurePropertiesForProfiling(final Properties props, final Project project, final FileObject profiledClassFile) { initAntPlatform(project, props); // set forceRestart diff --git a/profiler.j2se/manifest.mf b/profiler.j2se/manifest.mf --- a/profiler.j2se/manifest.mf +++ b/profiler.j2se/manifest.mf @@ -2,4 +2,4 @@ OpenIDE-Module: org.netbeans.modules.profiler.j2se/1 OpenIDE-Module-Layer: org/netbeans/modules/profiler/j2se/mf-layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/j2se/Bundle.properties -OpenIDE-Module-Specification-Version: 1.12 +OpenIDE-Module-Specification-Version: 1.13 diff --git a/profiler.j2se/src/org/netbeans/modules/profiler/j2se/J2SEProjectTypeProfiler.java b/profiler.j2se/src/org/netbeans/modules/profiler/j2se/J2SEProjectTypeProfiler.java --- a/profiler.j2se/src/org/netbeans/modules/profiler/j2se/J2SEProjectTypeProfiler.java +++ b/profiler.j2se/src/org/netbeans/modules/profiler/j2se/J2SEProjectTypeProfiler.java @@ -253,151 +253,6 @@ } } - public boolean checkProjectIsModifiedForProfiler(final Project project) { - if (ProjectUtilities.isProfilerIntegrated(project)) { - return true; // already modified by this version, nothing more to do - } - - String projectName = ProjectUtils.getInformation(project).getDisplayName(); - String caption = MessageFormat.format(MODIFY_BUILDSCRIPT_CAPTION, new Object[] { projectName }); - String message = MessageFormat.format(MODIFY_BUILDSCRIPT_MSG, new Object[] { projectName, "build-before-profiler.xml" }); // NOI18N - - if (ProfilerDialogs.notify(new NotifyDescriptor(message, caption, NotifyDescriptor.OK_CANCEL_OPTION, - NotifyDescriptor.INFORMATION_MESSAGE, - new Object[] { - NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION - }, NotifyDescriptor.OK_OPTION)) != NotifyDescriptor.OK_OPTION) { - return false; // cancelled by the user - } - - // we are going to regenerate the build script in one of 3 cases: - // 1. it has not been generated yet - // 2. the profiler version has been changed (see above) - // 3. the stylesheet changed (usually should be caught by 2.) - final GeneratedFilesHelper gfh = new GeneratedFilesHelper(project.getProjectDirectory()); - int flags = gfh.getBuildScriptState("nbproject/profiler-build-impl.xml", - J2SEProjectTypeProfiler.class.getResource("profiler-build-impl.xsl")); // NOI18N - - if (((flags & GeneratedFilesHelper.FLAG_MISSING) != 0) || ((flags & GeneratedFilesHelper.FLAG_OLD_STYLESHEET) != 0)) { - try { - if ((flags & GeneratedFilesHelper.FLAG_MODIFIED) != 0) { - if (ProfilerDialogs.notify(new NotifyDescriptor.Confirmation(MessageFormat.format(REGENERATE_BUILDSCRIPT_MSG, - new Object[] { - "profiler-build-impl.xml" - }), // NOI18N - NotifyDescriptor.OK_CANCEL_OPTION)) != NotifyDescriptor.OK_OPTION) { - return false; - } - } - - gfh.generateBuildScriptFromStylesheet("nbproject/profiler-build-impl.xml", - J2SEProjectTypeProfiler.class.getResource("profiler-build-impl.xsl")); // NOI18N - } catch (IOException e1) { - err.notify(ErrorManager.WARNING, e1); - - return false; - } - } - - // store info about profiler with project's auxiliary configuration - final Element profilerFragment = XMLUtil.createDocument("ignore", null, null, null) - .createElementNS(ProjectUtilities.PROFILER_NAME_SPACE, "data"); // NOI18N - profilerFragment.setAttribute(PROFILE_VERSION_ATTRIBUTE, VERSION_NUMBER); - ProjectUtils.getAuxiliaryConfiguration(project).putConfigurationFragment(profilerFragment, false); - - try { - ProjectManager.getDefault().saveProject(project); - } catch (IOException e1) { - err.notify(e1); - ProfilerLogger.log(e1); - - return false; - } - - final String buildScript = ProjectUtilities.getProjectBuildScript(project); - - if (buildScript == null) { - ProfilerDialogs.notify(new NotifyDescriptor.Message(MessageFormat.format(CANNOT_FIND_BUILDSCRIPT_MSG, - new Object[] { "build.xml" }), // NOI18N - NotifyDescriptor.ERROR_MESSAGE)); - - return false; - } - - if (!ProjectUtilities.backupBuildScript(project)) { - if (ProfilerDialogs.notify(new NotifyDescriptor.Confirmation(CANNOT_BACKUP_BUILDSCRIPT_MSG, - NotifyDescriptor.OK_CANCEL_OPTION, - NotifyDescriptor.WARNING_MESSAGE)) != NotifyDescriptor.OK_OPTION) { - return false; // cancelled by the user - } - } - - final StringBuffer newDataBuffer = new StringBuffer(buildScript.length() + 200); - final int importIndex = buildScript.indexOf(STANDARD_IMPORT_STRING); - - if (importIndex == -1) { - // notify the user that the build script cannot be modified, and he should perform the change himself - ProfilerDialogs.notify(new NotifyDescriptor.Message(MessageFormat.format(MODIFY_BUILDSCRIPT_MANUALLY_MSG, - new Object[] { - "build.xml", - "" - }), // NOI18N - NotifyDescriptor.WARNING_MESSAGE)); - - return false; - } - - String indent = ""; // NOI18N - int idx = importIndex - 1; - - while (idx >= 0) { - if (buildScript.charAt(idx) == ' ') { - indent = " " + indent; // NOI18N - } else if (buildScript.charAt(idx) == '\t') { - indent = "\t" + indent; // NOI18N - } else { - break; - } - - idx--; - } - - newDataBuffer.append(buildScript.substring(0, importIndex + STANDARD_IMPORT_STRING.length() + 1)); - newDataBuffer.append("\n"); // NOI18N - newDataBuffer.append(indent); - newDataBuffer.append(PROFILER_IMPORT_STRING); - newDataBuffer.append(buildScript.substring(importIndex + STANDARD_IMPORT_STRING.length() + 1)); - - FileObject buildFile = getProjectBuildScript(project); - FileLock lock = null; - OutputStreamWriter writer = null; - - try { - lock = buildFile.lock(); - writer = new OutputStreamWriter(buildFile.getOutputStream(lock), "UTF-8"); // NOI18N // According to Issue 65557, build.xml uses UTF-8, not default encoding! - writer.write(newDataBuffer.toString()); - } catch (FileNotFoundException e1) { - ProfilerLogger.log(e1); - err.notify(e1); - } catch (IOException e1) { - ProfilerLogger.log(e1); - err.notify(e1); - } finally { - if (lock != null) { - lock.releaseLock(); - } - - if (writer != null) { - try { - writer.close(); - } catch (IOException ex) { - } - } - } - - return true; - } - public void configurePropertiesForProfiling(final Properties props, final Project project, final FileObject profiledClassFile) { if (profiledClassFile == null) { if (mainClassSetManually != null) { diff --git a/profiler.nbmodule/manifest.mf b/profiler.nbmodule/manifest.mf --- a/profiler.nbmodule/manifest.mf +++ b/profiler.nbmodule/manifest.mf @@ -2,4 +2,4 @@ OpenIDE-Module: org.netbeans.modules.profiler.nbmodule/1 OpenIDE-Module-Layer: org/netbeans/modules/profiler/nbmodule/mf-layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/nbmodule/Bundle.properties -OpenIDE-Module-Specification-Version: 1.12 +OpenIDE-Module-Specification-Version: 1.13 diff --git a/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java b/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java --- a/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java +++ b/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java @@ -200,11 +200,7 @@ public boolean checkProjectCanBeProfiled(final Project project, final FileObject profiledClassFile) { return true; // no check performed in nbmodule project } - - public boolean checkProjectIsModifiedForProfiler(final Project project) { - return true; - } - + private static String getTestType(FileObject testFile) { String testPath = testFile.getPath(); if (testPath.contains(TEST_TYPE_QA_FUNCTIONAL)) return TEST_TYPE_QA_FUNCTIONAL; diff --git a/profiler/manifest.mf b/profiler/manifest.mf --- a/profiler/manifest.mf +++ b/profiler/manifest.mf @@ -3,6 +3,6 @@ OpenIDE-Module-Layer: org/netbeans/modules/profiler/mf-layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/Bundle.properties OpenIDE-Module-Install: org/netbeans/modules/profiler/ProfilerModule.class -OpenIDE-Module-Specification-Version: 1.18 +OpenIDE-Module-Specification-Version: 1.19 OpenIDE-Module-Provides: org.netbeans.modules.profiler, org.netbeans.lib.profiler.common.Profiler diff --git a/profiler/src/org/netbeans/modules/profiler/AbstractProjectTypeProfiler.java b/profiler/src/org/netbeans/modules/profiler/AbstractProjectTypeProfiler.java --- a/profiler/src/org/netbeans/modules/profiler/AbstractProjectTypeProfiler.java +++ b/profiler/src/org/netbeans/modules/profiler/AbstractProjectTypeProfiler.java @@ -136,7 +136,9 @@ public abstract boolean checkProjectCanBeProfiled(Project project, FileObject profiledClassFile); - public abstract boolean checkProjectIsModifiedForProfiler(Project project); + public boolean checkProjectIsModifiedForProfiler(Project project) { + return true; + } public List getPredefinedInstrumentationFilters(Project project) { return ProjectUtilities.getProjectDefaultInstrFilters(project); diff --git a/profiler/src/org/netbeans/modules/profiler/utils/ProjectUtilities.java b/profiler/src/org/netbeans/modules/profiler/utils/ProjectUtilities.java --- a/profiler/src/org/netbeans/modules/profiler/utils/ProjectUtilities.java +++ b/profiler/src/org/netbeans/modules/profiler/utils/ProjectUtilities.java @@ -100,6 +100,8 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; @@ -107,6 +109,8 @@ import javax.swing.event.ChangeListener; import org.netbeans.modules.profiler.NetBeansProfiler; import org.netbeans.modules.profiler.projectsupport.utilities.SourceUtils; +import org.netbeans.spi.project.ProjectServiceProvider; +import org.netbeans.spi.project.ui.ProjectOpenedHook; import org.openide.loaders.DataObject; import org.openide.util.lookup.Lookups; import org.openide.util.lookup.ProxyLookup; @@ -120,6 +124,34 @@ */ @Deprecated public final class ProjectUtilities { + @ProjectServiceProvider(service=ProjectOpenedHook.class, + projectType={ + "org-netbeans-modules-java-j2seproject", + "org-netbeans-modules-j2ee-earproject", + "org-netbeans-modules-j2ee-ejbjarproject", + "org-netbeans-modules-web-project"}) + final public static class IntegrationUpdater extends ProjectOpenedHook { + private Project prj; + + public IntegrationUpdater(Project prj) { + this.prj = prj; + } + + @Override + protected void projectClosed() { + // ignore + } + + @Override + protected void projectOpened() { + Element e = ProjectUtils.getAuxiliaryConfiguration(prj) + .getConfigurationFragment("data", ProjectUtilities.PROFILER_NAME_SPACE, false); // NOI18N + + if (e != null) { + unintegrateProfiler(prj); + } + } + } //~ Static fields/initializers ----------------------------------------------------------------------------------------------- private static final Logger LOGGER = Logger.getLogger(ProjectUtilities.class.getName()); @@ -310,20 +342,11 @@ return buildDir; } + final private static Pattern PROFILER_INIT = Pattern.compile("<\\s*target\\s+.*?name\\s*=\\s*\"profile-init\"", Pattern.DOTALL | Pattern.MULTILINE); public static boolean isProfilerIntegrated(Project project) { - Element e = ProjectUtils.getAuxiliaryConfiguration(project) - .getConfigurationFragment("data", ProjectUtilities.PROFILER_NAME_SPACE, false); // NOI18N - - return e != null; - - // TODO: Should check for obsolete versions (currently commented below) - - // if (e != null) { - // String storedVersion = e.getAttribute("version"); // NOI18N - // if (storedVersion.equals("0.9.1")) return true; // NOI18N - // } - // - // return false; + String buildXml = ProjectUtilities.getProjectBuildScript(project, "nbproject/build-impl.xml"); // NOI18N + Matcher m = PROFILER_INIT.matcher(buildXml); + return m.find(); } public static float getProfilingOverhead(ProfilingSettings settings) { @@ -357,7 +380,11 @@ } public static String getProjectBuildScript(final Project project) { - final FileObject buildFile = findBuildFile(project); + return getProjectBuildScript(project, "build.xml"); + } + + public static String getProjectBuildScript(final Project project, final String buildXml) { + final FileObject buildFile = findBuildFile(project, buildXml); if (buildFile == null) { return null; } @@ -403,14 +430,18 @@ Properties props = org.netbeans.modules.profiler.projectsupport.utilities.ProjectUtilities.getProjectProperties(project); String buildFileName = props != null ? props.getProperty("buildfile") : null; // NOI18N if (buildFileName != null) { - buildFile = project.getProjectDirectory().getFileObject(buildFileName); + buildFile = findBuildFile(project, buildFileName); } if (buildFile == null) { - buildFile = project.getProjectDirectory().getFileObject("build.xml"); //NOI18N + buildFile = findBuildFile(project, "build.xml"); //NOI18N } return buildFile; } + public static FileObject findBuildFile(final Project project, final String buildFileName) { + return project.getProjectDirectory().getFileObject(buildFileName); + } + public static java.util.List getProjectDefaultInstrFilters(Project project) { java.util.List v = new ArrayList(); diff --git a/web.project/src/org/netbeans/modules/web/project/resources/build-impl.xsl b/web.project/src/org/netbeans/modules/web/project/resources/build-impl.xsl --- a/web.project/src/org/netbeans/modules/web/project/resources/build-impl.xsl +++ b/web.project/src/org/netbeans/modules/web/project/resources/build-impl.xsl @@ -917,6 +917,23 @@ + + + + Empty placeholder for easier customization. + You can override this target in the ../build.xml file. + + + + Empty placeholder for easier customization. + You can override this target in the ../build.xml file. + + + -profile-pre-init, init, -profile-post-init + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + -pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-java,-init-macrodef-nbjpda,-init-macrodef-nbjsdebug,-init-macrodef-debug,-init-taskdefs,-init-ap-cmdline @@ -1651,7 +1668,71 @@ netbeans.home init,-pre-debug-fix,-do-debug-fix - + + + ================= + PROFILING SECTION + ================= + + + + Profile a J2EE project in the IDE. + + profiler.startserver.target + start-profiled-server-extraargs + start-profiled-server + + profiler.info.jvmargs.extra + + + + ${profiler.startserver.target} + + + run + + + start-loadgen + + + + + + ${profiler.j2ee.serverForceRestart} + ${profiler.j2ee.serverStartupTimeout} + ${profiler.info.javaPlatform} + + ${profiler.info.jvmargs.agent} + + + ${profiler.j2ee.agentID} + + + + + + + ${profiler.j2ee.serverForceRestart} + ${profiler.j2ee.serverStartupTimeout} + ${profiler.info.javaPlatform} + + ${profiler.info.jvmargs.extra} + + + ${profiler.info.jvmargs.agent} + + + ${profiler.j2ee.agentID} + + + + + + + ${profiler.loadgen.path} + + + JAVADOC SECTION @@ -1934,7 +2015,40 @@ init,-pre-debug-fix,-do-debug-fix-test - + + ========================= + TESTS PROFILING SECTION + ========================= + + + + netbeans.home + profile-init,compile-test-single + + + + + + + + + + + + + + + + + + + + + + + + + CLEANUP SECTION