This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 189151
Collapse All | Expand All

(-)a/j2ee.earproject/src/org/netbeans/modules/j2ee/earproject/resources/build-impl.xsl (-1 / +82 lines)
Lines 300-305 Link Here
300
                <taskdef resource="org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml" classpath="${{libs.CopyLibs.classpath}}"/>
300
                <taskdef resource="org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml" classpath="${{libs.CopyLibs.classpath}}"/>
301
            </target>
301
            </target>
302
302
303
            <target name="profile-init" depends="-profile-pre-init, init, -profile-post-init, -profile-init-check"/>
304
305
            <target name="-profile-pre-init">
306
                <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
307
                <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
308
            </target>
309
310
            <target name="-profile-post-init">
311
                <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
312
                <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
313
            </target>
314
            <target name="-profile-init-check">
315
                <xsl:attribute name="depends">-profile-pre-init, init, -profile-post-init</xsl:attribute>
316
                <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
317
                <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
318
            </target>
319
303
            <target name="init">
320
            <target name="init">
304
                <xsl:attribute name="depends">pre-init,init-private,init-userdir,init-user,init-project,do-init,post-init,init-check,-init-taskdefs</xsl:attribute>
321
                <xsl:attribute name="depends">pre-init,init-private,init-userdir,init-user,init-project,do-init,post-init,init-check,-init-taskdefs</xsl:attribute>
305
            </target>
322
            </target>
Lines 818-824 Link Here
818
        <ear2:debug-appclient subprojectname="${{app.client}}"/>
835
        <ear2:debug-appclient subprojectname="${{app.client}}"/>
819
    </target>
836
    </target>
820
    
837
    
821
            <xsl:comment>
838
        <xsl:comment>
839
    =================
840
    PROFILING SECTION
841
    =================
842
    </xsl:comment>
843
844
    <target name="profile">
845
        <xsl:attribute name="description">Profile a J2EE project in the IDE.</xsl:attribute>
846
        <condition>
847
            <xsl:attribute name="property">profiler.startserver.target</xsl:attribute>
848
            <xsl:attribute name="value">start-profiled-server-extraargs</xsl:attribute>
849
            <xsl:attribute name="else">start-profiled-server</xsl:attribute>
850
            <isset>
851
                <xsl:attribute name="property">profiler.info.jvmargs.extra</xsl:attribute>
852
            </isset>
853
        </condition>
854
        <antcall>
855
            <xsl:attribute name="target">${profiler.startserver.target}</xsl:attribute>
856
        </antcall>
857
        <antcall>
858
            <xsl:attribute name="target">run</xsl:attribute>
859
        </antcall>
860
        <antcall>
861
            <xsl:attribute name="target">start-loadgen</xsl:attribute>
862
        </antcall>
863
    </target>
864
865
    <target name="start-profiled-server">
866
        <nbstartprofiledserver>
867
            <xsl:attribute name="forceRestart">${profiler.j2ee.serverForceRestart}</xsl:attribute>
868
            <xsl:attribute name="startupTimeout">${profiler.j2ee.serverStartupTimeout}</xsl:attribute>
869
            <xsl:attribute name="javaPlatform">${profiler.info.javaPlatform}</xsl:attribute>
870
            <jvmarg>
871
                <xsl:attribute name="value">${profiler.info.jvmargs.agent}</xsl:attribute>
872
            </jvmarg>
873
            <jvmarg>
874
                <xsl:attribute name="value">${profiler.j2ee.agentID}</xsl:attribute>
875
            </jvmarg>
876
        </nbstartprofiledserver>
877
    </target>
878
879
    <target name="start-profiled-server-extraargs">
880
        <nbstartprofiledserver>
881
            <xsl:attribute name="forceRestart">${profiler.j2ee.serverForceRestart}</xsl:attribute>
882
            <xsl:attribute name="startupTimeout">${profiler.j2ee.serverStartupTimeout}</xsl:attribute>
883
            <xsl:attribute name="javaPlatform">${profiler.info.javaPlatform}</xsl:attribute>
884
            <jvmarg>
885
                <xsl:attribute name="value">${profiler.info.jvmargs.extra}</xsl:attribute>
886
            </jvmarg>
887
            <jvmarg>
888
                <xsl:attribute name="value">${profiler.info.jvmargs.agent}</xsl:attribute>
889
            </jvmarg>
890
            <jvmarg>
891
                <xsl:attribute name="value">${profiler.j2ee.agentID}</xsl:attribute>
892
            </jvmarg>
893
        </nbstartprofiledserver>
894
    </target>
895
896
    <target name="start-loadgen" if="profiler.loadgen.path">
897
            <loadgenstart>
898
                <xsl:attribute name="path">${profiler.loadgen.path}</xsl:attribute>
899
            </loadgenstart>
900
    </target>
901
902
    <xsl:comment>
822
    CLEANUP SECTION
903
    CLEANUP SECTION
823
    </xsl:comment>
904
    </xsl:comment>
824
905
(-)a/j2ee.ejbjarproject/src/org/netbeans/modules/j2ee/ejbjarproject/resources/build-impl.xsl (-2 / +118 lines)
Lines 832-837 Link Here
832
                <property name="ap.cmd.line.internal" value=""/>
832
                <property name="ap.cmd.line.internal" value=""/>
833
            </target>
833
            </target>
834
834
835
            <target name="profile-init" depends="-profile-pre-init, init, -profile-post-init, -profile-init-check"/>
836
837
            <target name="-profile-pre-init">
838
                <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
839
                <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
840
            </target>
841
842
            <target name="-profile-post-init">
843
                <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
844
                <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
845
            </target>
846
            <target name="-profile-init-check">
847
                <xsl:attribute name="depends">-profile-pre-init, init, -profile-post-init</xsl:attribute>
848
                <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
849
                <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
850
            </target>
851
835
852
836
            <target name="init">
853
            <target name="init">
837
                <xsl:attribute name="depends">-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</xsl:attribute>
854
                <xsl:attribute name="depends">-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</xsl:attribute>
Lines 1332-1338 Link Here
1332
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1349
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1333
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix</xsl:attribute>
1350
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix</xsl:attribute>
1334
            </target>
1351
            </target>
1335
            
1352
1353
            <xsl:comment>
1354
            =================
1355
            PROFILING SECTION
1356
            =================
1357
            </xsl:comment>
1358
1359
            <target name="profile">
1360
                <xsl:attribute name="description">Profile a J2EE project in the IDE.</xsl:attribute>
1361
                <condition>
1362
                    <xsl:attribute name="property">profiler.startserver.target</xsl:attribute>
1363
                    <xsl:attribute name="value">start-profiled-server-extraargs</xsl:attribute>
1364
                    <xsl:attribute name="else">start-profiled-server</xsl:attribute>
1365
                    <isset>
1366
                        <xsl:attribute name="property">profiler.info.jvmargs.extra</xsl:attribute>
1367
                    </isset>
1368
                </condition>
1369
                <antcall>
1370
                    <xsl:attribute name="target">${profiler.startserver.target}</xsl:attribute>
1371
                </antcall>
1372
                <antcall>
1373
                    <xsl:attribute name="target">run</xsl:attribute>
1374
                </antcall>
1375
                <antcall>
1376
                    <xsl:attribute name="target">start-loadgen</xsl:attribute>
1377
                </antcall>
1378
            </target>
1379
1380
            <target name="start-profiled-server">
1381
                <nbstartprofiledserver>
1382
                    <xsl:attribute name="forceRestart">${profiler.j2ee.serverForceRestart}</xsl:attribute>
1383
                    <xsl:attribute name="startupTimeout">${profiler.j2ee.serverStartupTimeout}</xsl:attribute>
1384
                    <xsl:attribute name="javaPlatform">${profiler.info.javaPlatform}</xsl:attribute>
1385
                    <jvmarg>
1386
                        <xsl:attribute name="value">${profiler.info.jvmargs.agent}</xsl:attribute>
1387
                    </jvmarg>
1388
                    <jvmarg>
1389
                        <xsl:attribute name="value">${profiler.j2ee.agentID}</xsl:attribute>
1390
                    </jvmarg>
1391
                </nbstartprofiledserver>
1392
            </target>
1393
1394
            <target name="start-profiled-server-extraargs">
1395
                <nbstartprofiledserver>
1396
                    <xsl:attribute name="forceRestart">${profiler.j2ee.serverForceRestart}</xsl:attribute>
1397
                    <xsl:attribute name="startupTimeout">${profiler.j2ee.serverStartupTimeout}</xsl:attribute>
1398
                    <xsl:attribute name="javaPlatform">${profiler.info.javaPlatform}</xsl:attribute>
1399
                    <jvmarg>
1400
                        <xsl:attribute name="value">${profiler.info.jvmargs.extra}</xsl:attribute>
1401
                    </jvmarg>
1402
                    <jvmarg>
1403
                        <xsl:attribute name="value">${profiler.info.jvmargs.agent}</xsl:attribute>
1404
                    </jvmarg>
1405
                    <jvmarg>
1406
                        <xsl:attribute name="value">${profiler.j2ee.agentID}</xsl:attribute>
1407
                    </jvmarg>
1408
                </nbstartprofiledserver>
1409
            </target>
1410
1411
            <target name="start-loadgen" if="profiler.loadgen.path">
1412
                    <loadgenstart>
1413
                        <xsl:attribute name="path">${profiler.loadgen.path}</xsl:attribute>
1414
                    </loadgenstart>
1415
            </target>
1416
1336
            <xsl:comment>
1417
            <xsl:comment>
1337
                JAVADOC SECTION
1418
                JAVADOC SECTION
1338
            </xsl:comment>
1419
            </xsl:comment>
Lines 1604-1610 Link Here
1604
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1685
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1605
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix-test</xsl:attribute>
1686
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix-test</xsl:attribute>
1606
            </target>
1687
            </target>
1607
            
1688
1689
        <xsl:comment>
1690
        =========================
1691
        TESTS PROFILING  SECTION
1692
        =========================
1693
        </xsl:comment>
1694
1695
          <target name="profile-test-single">
1696
              <xsl:attribute name="if">netbeans.home</xsl:attribute>
1697
              <xsl:attribute name="depends">profile-init,compile-test-single</xsl:attribute>
1698
              <nbprofiledirect>
1699
                  <classpath>
1700
                      <path path="${{run.test.classpath}}"/>
1701
                      <path path="${{j2ee.platform.classpath}}"/>
1702
                  </classpath>
1703
              </nbprofiledirect>
1704
1705
              <junit showoutput="true" fork="true" dir="${{profiler.info.dir}}"  jvm="${{profiler.info.jvm}}" failureproperty="tests.failed" errorproperty="tests.failed">
1706
                  <env key="${{profiler.info.pathvar}}" path="${{profiler.info.agentpath}}:${{profiler.current.path}}"/>
1707
                  <jvmarg value="${{profiler.info.jvmargs.agent}}" />
1708
                  <jvmarg line="${{profiler.info.jvmargs}}"/>
1709
                  <test name="${{profile.class}}"/>
1710
                  <classpath>
1711
                      <path path="${{run.test.classpath}}"/>
1712
                      <path path="${{j2ee.platform.classpath}}"/>
1713
                  </classpath>
1714
                  <syspropertyset>
1715
                      <propertyref prefix="test-sys-prop."/>
1716
                      <mapper type="glob" from="test-sys-prop.*" to="*"/>
1717
                  </syspropertyset>
1718
                  <formatter type="brief" usefile="false"/>
1719
                  <formatter type="xml"/>
1720
              </junit>
1721
          </target>
1722
1723
1608
            <xsl:comment>
1724
            <xsl:comment>
1609
                CLEANUP SECTION
1725
                CLEANUP SECTION
1610
            </xsl:comment>
1726
            </xsl:comment>
(-)a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl (-2 / +150 lines)
Lines 692-698 Link Here
692
                    </sequential>
692
                    </sequential>
693
                </macrodef>
693
                </macrodef>
694
            </target>
694
            </target>
695
            
695
696
            <target name="profile-init" depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check"/>
697
698
            <target name="-profile-pre-init">
699
                <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
700
                <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
701
            </target>
702
703
            <target name="-profile-post-init">
704
                <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
705
                <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
706
            </target>
707
708
            <target name="-profile-init-macrodef-profile">
709
                <macrodef>
710
                  <xsl:attribute name="name">resolve</xsl:attribute>
711
                  <attribute>
712
                      <xsl:attribute name="name">name</xsl:attribute>
713
                  </attribute>
714
                  <attribute>
715
                      <xsl:attribute name="name">value</xsl:attribute>
716
                  </attribute>
717
                  <sequential>
718
                      <property name="@{{name}}" value="${{env.@{{value}}}}"/>
719
                  </sequential>
720
                </macrodef>
721
722
                <macrodef>
723
                    <xsl:attribute name="name">profile</xsl:attribute>
724
                    <attribute>
725
                        <xsl:attribute name="name">classname</xsl:attribute>
726
                        <xsl:attribute name="default">${main.class}</xsl:attribute>
727
                    </attribute>
728
                    <element>
729
                      <xsl:attribute name="name">customize</xsl:attribute>
730
                      <xsl:attribute name="optional">true</xsl:attribute>
731
                    </element>
732
                    <sequential>
733
                        <property environment="env"/>
734
                        <resolve name="profiler.current.path" value="${{profiler.info.pathvar}}"/>
735
                        <java fork="true" classname="@{{classname}}" dir="${{profiler.info.dir}}" jvm="${{profiler.info.jvm}}">
736
                            <jvmarg value="${{profiler.info.jvmargs.agent}}"/>
737
                            <jvmarg line="${{profiler.info.jvmargs}}"/>
738
                            <env key="${{profiler.info.pathvar}}" path="${{profiler.info.agentpath}}:${{profiler.current.path}}"/>
739
                            <arg line="${{application.args}}"/>
740
                            <classpath>
741
                                <path path="${{run.classpath}}"/>
742
                            </classpath>
743
                            <syspropertyset>
744
                                <propertyref prefix="run-sys-prop."/>
745
                                <mapper type="glob" from="run-sys-prop.*" to="*"/>
746
                            </syspropertyset>
747
                            <customize/>
748
                        </java>
749
                    </sequential>
750
                  </macrodef>
751
            </target>
752
753
            <target name="-profile-init-check">
754
                <xsl:attribute name="depends">-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile</xsl:attribute>
755
                <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
756
                <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
757
            </target>
758
696
            <target name="-init-macrodef-nbjpda" depends="-init-debug-args">
759
            <target name="-init-macrodef-nbjpda" depends="-init-debug-args">
697
                <macrodef>
760
                <macrodef>
698
                    <xsl:attribute name="name">nbjpdastart</xsl:attribute>
761
                    <xsl:attribute name="name">nbjpdastart</xsl:attribute>
Lines 1334-1340 Link Here
1334
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1397
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1335
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix</xsl:attribute>
1398
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix</xsl:attribute>
1336
            </target>
1399
            </target>
1337
            
1400
1401
            <xsl:comment>
1402
                =================
1403
                PROFILING SECTION
1404
                =================
1405
            </xsl:comment>
1406
1407
            <target name="profile">
1408
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1409
                <xsl:attribute name="depends">profile-init,compile</xsl:attribute>
1410
                <xsl:attribute name="description">Profile a project in the IDE.</xsl:attribute>
1411
                <nbprofiledirect>
1412
                    <classpath>
1413
                        <path path="${{run.classpath}}"/>
1414
                    </classpath>
1415
                </nbprofiledirect>
1416
                <profile/>
1417
            </target>
1418
1419
            <target name="profile-single">
1420
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1421
                <xsl:attribute name="depends">profile-init,compile-single</xsl:attribute>
1422
                <xsl:attribute name="description">Profile a selected class in the IDE.</xsl:attribute>
1423
                <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
1424
                <nbprofiledirect>
1425
                    <classpath>
1426
                        <path path="${{run.classpath}}"/>
1427
                    </classpath>
1428
                </nbprofiledirect>
1429
              <profile classname="${{profile.class}}"/>
1430
            </target>
1431
1432
            <xsl:comment>
1433
                =========================
1434
                APPLET PROFILING  SECTION
1435
                =========================
1436
            </xsl:comment>
1437
1438
            <target name="profile-applet">
1439
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1440
                <xsl:attribute name="depends">profile-init,compile-single</xsl:attribute>
1441
                <nbprofiledirect>
1442
                    <classpath>
1443
                        <path path="${{run.classpath}}"/>
1444
                    </classpath>
1445
                </nbprofiledirect>
1446
1447
                <profile classname="sun.applet.AppletViewer">
1448
                    <customize>
1449
                        <arg value="${{applet.url}}"/>
1450
                    </customize>
1451
                </profile>
1452
            </target>
1453
1454
            <xsl:comment>
1455
                =========================
1456
                TESTS PROFILING  SECTION
1457
                =========================
1458
            </xsl:comment>
1459
1460
            <target name="profile-test-single">
1461
              <xsl:attribute name="if">netbeans.home</xsl:attribute>
1462
              <xsl:attribute name="depends">profile-init,compile-test-single</xsl:attribute>
1463
              <nbprofiledirect>
1464
                  <classpath>
1465
                      <path path="${{run.test.classpath}}"/>
1466
                  </classpath>
1467
              </nbprofiledirect>
1468
1469
              <junit showoutput="true" fork="true" dir="${{profiler.info.dir}}"  jvm="${{profiler.info.jvm}}" failureproperty="tests.failed" errorproperty="tests.failed">
1470
                  <env key="${{profiler.info.pathvar}}" path="${{profiler.info.agentpath}}:${{profiler.current.path}}"/>
1471
                  <jvmarg value="${{profiler.info.jvmargs.agent}}" />
1472
                  <jvmarg line="${{profiler.info.jvmargs}}"/>
1473
                  <test name="${{profile.class}}"/>
1474
                  <classpath>
1475
                      <path path="${{run.test.classpath}}"/>
1476
                  </classpath>
1477
                  <syspropertyset>
1478
                      <propertyref prefix="test-sys-prop."/>
1479
                      <mapper type="glob" from="test-sys-prop.*" to="*"/>
1480
                  </syspropertyset>
1481
                  <formatter type="brief" usefile="false"/>
1482
                  <formatter type="xml"/>
1483
              </junit>
1484
            </target>
1485
1338
            <xsl:comment>
1486
            <xsl:comment>
1339
                ===============
1487
                ===============
1340
                JAVADOC SECTION
1488
                JAVADOC SECTION
(-)a/profiler.j2ee/manifest.mf (-1 / +1 lines)
Lines 2-5 Link Here
2
OpenIDE-Module: org.netbeans.modules.profiler.j2ee/1
2
OpenIDE-Module: org.netbeans.modules.profiler.j2ee/1
3
OpenIDE-Module-Layer: org/netbeans/modules/profiler/j2ee/mf-layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/profiler/j2ee/mf-layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/j2ee/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/j2ee/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.11
5
OpenIDE-Module-Specification-Version: 1.12
(-)a/profiler.j2ee/src/org/netbeans/modules/profiler/j2ee/J2EEProjectTypeProfiler.java (-152 / +1 lines)
Lines 48-58 Link Here
48
import org.netbeans.api.java.platform.Specification;
48
import org.netbeans.api.java.platform.Specification;
49
import org.netbeans.api.project.Project;
49
import org.netbeans.api.project.Project;
50
import org.netbeans.api.project.ProjectManager;
50
import org.netbeans.api.project.ProjectManager;
51
import org.netbeans.lib.profiler.ProfilerLogger;
52
import org.netbeans.lib.profiler.client.ClientUtils;
51
import org.netbeans.lib.profiler.client.ClientUtils;
53
import org.netbeans.lib.profiler.client.ClientUtils.SourceCodeSelection;
52
import org.netbeans.lib.profiler.client.ClientUtils.SourceCodeSelection;
54
import org.netbeans.lib.profiler.common.SessionSettings;
53
import org.netbeans.lib.profiler.common.SessionSettings;
55
import org.netbeans.lib.profiler.common.filters.SimpleFilter;
56
import org.netbeans.lib.profiler.common.integration.IntegrationUtils;
54
import org.netbeans.lib.profiler.common.integration.IntegrationUtils;
57
import org.netbeans.lib.profiler.global.CommonConstants;
55
import org.netbeans.lib.profiler.global.CommonConstants;
58
import org.netbeans.lib.profiler.marker.MethodMarker;
56
import org.netbeans.lib.profiler.marker.MethodMarker;
Lines 75-99 Link Here
75
import org.openide.DialogDescriptor;
73
import org.openide.DialogDescriptor;
76
import org.openide.ErrorManager;
74
import org.openide.ErrorManager;
77
import org.openide.NotifyDescriptor;
75
import org.openide.NotifyDescriptor;
78
import org.openide.filesystems.FileLock;
79
import org.openide.filesystems.FileObject;
76
import org.openide.filesystems.FileObject;
80
import org.openide.filesystems.FileUtil;
77
import org.openide.filesystems.FileUtil;
81
import org.openide.modules.InstalledFileLocator;
78
import org.openide.modules.InstalledFileLocator;
82
import org.openide.util.NbBundle;
79
import org.openide.util.NbBundle;
83
import org.openide.util.WeakListeners;
80
import org.openide.util.WeakListeners;
84
import org.openide.xml.XMLUtil;
85
import org.w3c.dom.Document;
81
import org.w3c.dom.Document;
86
import org.w3c.dom.Element;
82
import org.w3c.dom.Element;
87
import java.beans.PropertyChangeEvent;
83
import java.beans.PropertyChangeEvent;
88
import java.beans.PropertyChangeListener;
84
import java.beans.PropertyChangeListener;
89
import java.io.*;
85
import java.io.*;
90
import java.text.MessageFormat;
91
import java.util.Arrays;
92
import java.util.Collection;
86
import java.util.Collection;
93
import java.util.HashSet;
94
import java.util.Map;
87
import java.util.Map;
95
import java.util.Properties;
88
import java.util.Properties;
96
import java.util.Set;
97
import javax.swing.JComponent;
89
import javax.swing.JComponent;
98
import javax.swing.event.ChangeListener;
90
import javax.swing.event.ChangeListener;
99
import org.netbeans.api.project.ProjectUtils;
91
import org.netbeans.api.project.ProjectUtils;
Lines 350-356 Link Here
350
                                        final FileObject profiledClass) {
342
                                        final FileObject profiledClass) {
351
        switch (type) {
343
        switch (type) {
352
            case TARGET_PROFILE:
344
            case TARGET_PROFILE:
353
                return "profile-j2ee"; // NOI18N
345
                return "profile"; // NOI18N
354
            case TARGET_PROFILE_TEST:
346
            case TARGET_PROFILE_TEST:
355
                return null; // not currently supported // "profile-test"; // NOI18N
347
                return null; // not currently supported // "profile-test"; // NOI18N
356
            case TARGET_PROFILE_TEST_SINGLE:
348
            case TARGET_PROFILE_TEST_SINGLE:
Lines 500-648 Link Here
500
        }
492
        }
501
    }
493
    }
502
494
503
    public boolean checkProjectIsModifiedForProfiler(final Project project) {
504
        if (ProjectUtilities.isProfilerIntegrated(project)) {
505
            return true; // already modified by this version, nothing more to do
506
        }
507
508
        String projectName = ProjectUtils.getInformation(project).getDisplayName();
509
        String caption = MessageFormat.format(MODIFY_BUILDSCRIPT_CAPTION, new Object[] { projectName });
510
        String message = MessageFormat.format(MODIFY_BUILDSCRIPT_MSG, new Object[] { projectName, "build-before-profiler.xml" }); // NOI18N
511
        if (ProfilerDialogs.notify(new NotifyDescriptor(message, caption, NotifyDescriptor.OK_CANCEL_OPTION,
512
                                                        NotifyDescriptor.INFORMATION_MESSAGE, new Object[] { NotifyDescriptor.OK_OPTION,
513
                                                        NotifyDescriptor.CANCEL_OPTION }, NotifyDescriptor.OK_OPTION)) != NotifyDescriptor.OK_OPTION) {
514
            return false; // cancelled by the user
515
        }
516
517
        // not yet modified for profiler => create profiler-build-impl & modify build.xml and project.xml
518
        final Element profilerFragment = XMLUtil.createDocument("ignore", null, null, null)
519
                                                .createElementNS(ProjectUtilities.PROFILER_NAME_SPACE, "data"); // NOI18N
520
        profilerFragment.setAttribute(PROFILE_VERSION_ATTRIBUTE, VERSION_NUMBER); // NOI18N
521
522
        ProjectUtils.getAuxiliaryConfiguration(project).putConfigurationFragment(profilerFragment, false);
523
524
        try {
525
            ProjectManager.getDefault().saveProject(project);
526
        } catch (IOException e1) {
527
            err.notify(e1);
528
            ProfilerLogger.log(e1);
529
530
            return false;
531
        }
532
533
        // we are going to regenerate the build script in one of 3 cases:
534
        // 1. it has not been generated yet
535
        // 2. the profiler version has been changed (see above)
536
        // 3. the stylesheet changed (usually should be caught by 2.)
537
        final GeneratedFilesHelper gfh = new GeneratedFilesHelper(project.getProjectDirectory());
538
        int flags = gfh.getBuildScriptState("nbproject/profiler-build-impl.xml",
539
                                            J2EEProjectTypeProfiler.class.getResource("profiler-build-impl.xsl")); // NOI18N
540
541
        if (((flags & GeneratedFilesHelper.FLAG_MISSING) != 0) || ((flags & GeneratedFilesHelper.FLAG_OLD_STYLESHEET) != 0)) {
542
            try {
543
                if ((flags & GeneratedFilesHelper.FLAG_MODIFIED) != 0) {
544
                    if (ProfilerDialogs.notify(new NotifyDescriptor.Confirmation(MessageFormat.format(REGENERATE_BUILDSCRIPT_MSG,
545
                                                                                                          new Object[] {
546
                                                                                                              "profiler-build-impl.xml"
547
                                                                                                          }), // NOI18N
548
                                                                                     NotifyDescriptor.OK_CANCEL_OPTION)) != NotifyDescriptor.OK_OPTION) {
549
                        return false;
550
                    }
551
                }
552
553
                gfh.generateBuildScriptFromStylesheet("nbproject/profiler-build-impl.xml",
554
                                                      J2EEProjectTypeProfiler.class.getResource("profiler-build-impl.xsl")); // NOI18N
555
            } catch (IOException e1) {
556
                err.notify(ErrorManager.WARNING, e1);
557
558
                return false;
559
            }
560
        }
561
562
        final String buildScript = ProjectUtilities.getProjectBuildScript(project);
563
564
        if (buildScript == null) {
565
            ProfilerDialogs.notify(new NotifyDescriptor.Message(MessageFormat.format(CANNOT_FIND_BUILDSCRIPT_MSG,
566
                                                                                     new Object[] { "build.xml" }), // NOI18N
567
                                                                NotifyDescriptor.ERROR_MESSAGE));
568
569
            return false;
570
        }
571
572
        if (!ProjectUtilities.backupBuildScript(project)) {
573
            if (ProfilerDialogs.notify(new NotifyDescriptor.Confirmation(CANNOT_BACKUP_BUILDSCRIPT_MSG,
574
                                                                             NotifyDescriptor.OK_CANCEL_OPTION,
575
                                                                             NotifyDescriptor.WARNING_MESSAGE)) != NotifyDescriptor.OK_OPTION) {
576
                return false; // cancelled by the user
577
            }
578
        }
579
580
        final StringBuffer newDataBuffer = new StringBuffer(buildScript.length() + 200);
581
        final int importIndex = buildScript.indexOf(STANDARD_IMPORT_STRING);
582
583
        if (importIndex == -1) {
584
            // notify the user that the build script cannot be modified, and he should perform the change himself
585
            ProfilerDialogs.notify(new NotifyDescriptor.Message(MessageFormat.format(MODIFY_BUILDSCRIPT_MANUALLY_MSG,
586
                                                                                     new Object[] {
587
                                                                                         "build.xml",
588
                                                                                         "<import file=\"nbproject/profiler-build-impl.xml\"/>"
589
                                                                                     }), // NOI18N
590
                                                                NotifyDescriptor.WARNING_MESSAGE));
591
592
            return false;
593
        }
594
595
        String indent = ""; // NOI18N
596
        int idx = importIndex - 1;
597
598
        while (idx >= 0) {
599
            if (buildScript.charAt(idx) == ' ') {
600
                indent = " " + indent; // NOI18N
601
            } else if (buildScript.charAt(idx) == '\t') {
602
                indent = "\t" + indent; // NOI18N
603
            } else {
604
                break;
605
            }
606
607
            idx--;
608
        }
609
610
        newDataBuffer.append(buildScript.substring(0, importIndex + STANDARD_IMPORT_STRING.length() + 1));
611
        newDataBuffer.append("\n"); // NOI18N
612
        newDataBuffer.append(indent);
613
        newDataBuffer.append(PROFILER_IMPORT_STRING);
614
        newDataBuffer.append(buildScript.substring(importIndex + STANDARD_IMPORT_STRING.length() + 1));
615
616
        final FileObject buildFile = getProjectBuildScript(project);
617
        FileLock lock = null;
618
        OutputStreamWriter writer = null;
619
620
        try {
621
            lock = buildFile.lock();
622
            writer = new OutputStreamWriter(buildFile.getOutputStream(lock), "UTF-8"); // NOI18N // According to Issue 65557, build.xml uses UTF-8, not default encoding!
623
            writer.write(newDataBuffer.toString());
624
        } catch (FileNotFoundException e1) {
625
            err.notify(e1);
626
            ProfilerLogger.log(e1);
627
        } catch (IOException e1) {
628
            err.notify(e1);
629
            ProfilerLogger.log(e1);
630
        } finally {
631
            if (lock != null) {
632
                lock.releaseLock();
633
            }
634
635
            if (writer != null) {
636
                try {
637
                    writer.close();
638
                } catch (IOException ex) {
639
                }
640
            }
641
        }
642
643
        return true;
644
    }
645
646
    public void configurePropertiesForProfiling(final Properties props, final Project project, final FileObject profiledClassFile) {
495
    public void configurePropertiesForProfiling(final Properties props, final Project project, final FileObject profiledClassFile) {
647
        initAntPlatform(project, props);
496
        initAntPlatform(project, props);
648
        // set forceRestart
497
        // set forceRestart
(-)a/profiler.j2se/manifest.mf (-1 / +1 lines)
Lines 2-5 Link Here
2
OpenIDE-Module: org.netbeans.modules.profiler.j2se/1
2
OpenIDE-Module: org.netbeans.modules.profiler.j2se/1
3
OpenIDE-Module-Layer: org/netbeans/modules/profiler/j2se/mf-layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/profiler/j2se/mf-layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/j2se/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/j2se/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.12
5
OpenIDE-Module-Specification-Version: 1.13
(-)a/profiler.j2se/src/org/netbeans/modules/profiler/j2se/J2SEProjectTypeProfiler.java (-145 lines)
Lines 253-403 Link Here
253
        }
253
        }
254
    }
254
    }
255
255
256
    public boolean checkProjectIsModifiedForProfiler(final Project project) {
257
        if (ProjectUtilities.isProfilerIntegrated(project)) {
258
            return true; // already modified by this version, nothing more to do
259
        }
260
261
        String projectName = ProjectUtils.getInformation(project).getDisplayName();
262
        String caption = MessageFormat.format(MODIFY_BUILDSCRIPT_CAPTION, new Object[] { projectName });
263
        String message = MessageFormat.format(MODIFY_BUILDSCRIPT_MSG, new Object[] { projectName, "build-before-profiler.xml" }); // NOI18N
264
265
        if (ProfilerDialogs.notify(new NotifyDescriptor(message, caption, NotifyDescriptor.OK_CANCEL_OPTION,
266
                                                            NotifyDescriptor.INFORMATION_MESSAGE,
267
                                                            new Object[] {
268
                                                                NotifyDescriptor.OK_OPTION, NotifyDescriptor.CANCEL_OPTION
269
                                                            }, NotifyDescriptor.OK_OPTION)) != NotifyDescriptor.OK_OPTION) {
270
            return false; // cancelled by the user
271
        }
272
273
        // we are going to regenerate the build script in one of 3 cases:
274
        // 1. it has not been generated yet
275
        // 2. the profiler version has been changed (see above)
276
        // 3. the stylesheet changed (usually should be caught by 2.)
277
        final GeneratedFilesHelper gfh = new GeneratedFilesHelper(project.getProjectDirectory());
278
        int flags = gfh.getBuildScriptState("nbproject/profiler-build-impl.xml",
279
                                            J2SEProjectTypeProfiler.class.getResource("profiler-build-impl.xsl")); // NOI18N
280
281
        if (((flags & GeneratedFilesHelper.FLAG_MISSING) != 0) || ((flags & GeneratedFilesHelper.FLAG_OLD_STYLESHEET) != 0)) {
282
            try {
283
                if ((flags & GeneratedFilesHelper.FLAG_MODIFIED) != 0) {
284
                    if (ProfilerDialogs.notify(new NotifyDescriptor.Confirmation(MessageFormat.format(REGENERATE_BUILDSCRIPT_MSG,
285
                                                                                                          new Object[] {
286
                                                                                                              "profiler-build-impl.xml"
287
                                                                                                          }), // NOI18N
288
                                                                                     NotifyDescriptor.OK_CANCEL_OPTION)) != NotifyDescriptor.OK_OPTION) {
289
                        return false;
290
                    }
291
                }
292
293
                gfh.generateBuildScriptFromStylesheet("nbproject/profiler-build-impl.xml",
294
                                                      J2SEProjectTypeProfiler.class.getResource("profiler-build-impl.xsl")); // NOI18N
295
            } catch (IOException e1) {
296
                err.notify(ErrorManager.WARNING, e1);
297
298
                return false;
299
            }
300
        }
301
302
        // store info about profiler with project's auxiliary configuration
303
        final Element profilerFragment = XMLUtil.createDocument("ignore", null, null, null)
304
                                                .createElementNS(ProjectUtilities.PROFILER_NAME_SPACE, "data"); // NOI18N
305
        profilerFragment.setAttribute(PROFILE_VERSION_ATTRIBUTE, VERSION_NUMBER);
306
        ProjectUtils.getAuxiliaryConfiguration(project).putConfigurationFragment(profilerFragment, false);
307
308
        try {
309
            ProjectManager.getDefault().saveProject(project);
310
        } catch (IOException e1) {
311
            err.notify(e1);
312
            ProfilerLogger.log(e1);
313
314
            return false;
315
        }
316
317
        final String buildScript = ProjectUtilities.getProjectBuildScript(project);
318
319
        if (buildScript == null) {
320
            ProfilerDialogs.notify(new NotifyDescriptor.Message(MessageFormat.format(CANNOT_FIND_BUILDSCRIPT_MSG,
321
                                                                                     new Object[] { "build.xml" }), // NOI18N
322
                                                                NotifyDescriptor.ERROR_MESSAGE));
323
324
            return false;
325
        }
326
327
        if (!ProjectUtilities.backupBuildScript(project)) {
328
            if (ProfilerDialogs.notify(new NotifyDescriptor.Confirmation(CANNOT_BACKUP_BUILDSCRIPT_MSG,
329
                                                                             NotifyDescriptor.OK_CANCEL_OPTION,
330
                                                                             NotifyDescriptor.WARNING_MESSAGE)) != NotifyDescriptor.OK_OPTION) {
331
                return false; // cancelled by the user
332
            }
333
        }
334
335
        final StringBuffer newDataBuffer = new StringBuffer(buildScript.length() + 200);
336
        final int importIndex = buildScript.indexOf(STANDARD_IMPORT_STRING);
337
338
        if (importIndex == -1) {
339
            // notify the user that the build script cannot be modified, and he should perform the change himself
340
            ProfilerDialogs.notify(new NotifyDescriptor.Message(MessageFormat.format(MODIFY_BUILDSCRIPT_MANUALLY_MSG,
341
                                                                                     new Object[] {
342
                                                                                         "build.xml",
343
                                                                                         "<import file=\"nbproject/profiler-build-impl.xml\"/>"
344
                                                                                     }), // NOI18N
345
                                                                NotifyDescriptor.WARNING_MESSAGE));
346
347
            return false;
348
        }
349
350
        String indent = ""; // NOI18N
351
        int idx = importIndex - 1;
352
353
        while (idx >= 0) {
354
            if (buildScript.charAt(idx) == ' ') {
355
                indent = " " + indent; // NOI18N
356
            } else if (buildScript.charAt(idx) == '\t') {
357
                indent = "\t" + indent; // NOI18N
358
            } else {
359
                break;
360
            }
361
362
            idx--;
363
        }
364
365
        newDataBuffer.append(buildScript.substring(0, importIndex + STANDARD_IMPORT_STRING.length() + 1));
366
        newDataBuffer.append("\n"); // NOI18N
367
        newDataBuffer.append(indent);
368
        newDataBuffer.append(PROFILER_IMPORT_STRING);
369
        newDataBuffer.append(buildScript.substring(importIndex + STANDARD_IMPORT_STRING.length() + 1));
370
371
        FileObject buildFile = getProjectBuildScript(project);
372
        FileLock lock = null;
373
        OutputStreamWriter writer = null;
374
375
        try {
376
            lock = buildFile.lock();
377
            writer = new OutputStreamWriter(buildFile.getOutputStream(lock), "UTF-8"); // NOI18N // According to Issue 65557, build.xml uses UTF-8, not default encoding!
378
            writer.write(newDataBuffer.toString());
379
        } catch (FileNotFoundException e1) {
380
            ProfilerLogger.log(e1);
381
            err.notify(e1);
382
        } catch (IOException e1) {
383
            ProfilerLogger.log(e1);
384
            err.notify(e1);
385
        } finally {
386
            if (lock != null) {
387
                lock.releaseLock();
388
            }
389
390
            if (writer != null) {
391
                try {
392
                    writer.close();
393
                } catch (IOException ex) {
394
                }
395
            }
396
        }
397
398
        return true;
399
    }
400
401
    public void configurePropertiesForProfiling(final Properties props, final Project project, final FileObject profiledClassFile) {
256
    public void configurePropertiesForProfiling(final Properties props, final Project project, final FileObject profiledClassFile) {
402
        if (profiledClassFile == null) {
257
        if (profiledClassFile == null) {
403
            if (mainClassSetManually != null) {
258
            if (mainClassSetManually != null) {
(-)a/profiler.nbmodule/manifest.mf (-1 / +1 lines)
Lines 2-5 Link Here
2
OpenIDE-Module: org.netbeans.modules.profiler.nbmodule/1
2
OpenIDE-Module: org.netbeans.modules.profiler.nbmodule/1
3
OpenIDE-Module-Layer: org/netbeans/modules/profiler/nbmodule/mf-layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/profiler/nbmodule/mf-layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/nbmodule/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/nbmodule/Bundle.properties
5
OpenIDE-Module-Specification-Version: 1.12
5
OpenIDE-Module-Specification-Version: 1.13
(-)a/profiler.nbmodule/src/org/netbeans/modules/profiler/nbmodule/NbModuleProjectTypeProfiler.java (-5 / +1 lines)
Lines 200-210 Link Here
200
    public boolean checkProjectCanBeProfiled(final Project project, final FileObject profiledClassFile) {
200
    public boolean checkProjectCanBeProfiled(final Project project, final FileObject profiledClassFile) {
201
        return true; // no check performed in nbmodule project
201
        return true; // no check performed in nbmodule project
202
    }
202
    }
203
203
    
204
    public boolean checkProjectIsModifiedForProfiler(final Project project) {
205
        return true;
206
    }
207
208
    private static String getTestType(FileObject testFile) {
204
    private static String getTestType(FileObject testFile) {
209
        String testPath = testFile.getPath();
205
        String testPath = testFile.getPath();
210
        if (testPath.contains(TEST_TYPE_QA_FUNCTIONAL)) return TEST_TYPE_QA_FUNCTIONAL;
206
        if (testPath.contains(TEST_TYPE_QA_FUNCTIONAL)) return TEST_TYPE_QA_FUNCTIONAL;
(-)a/profiler/manifest.mf (-1 / +1 lines)
Lines 3-8 Link Here
3
OpenIDE-Module-Layer: org/netbeans/modules/profiler/mf-layer.xml
3
OpenIDE-Module-Layer: org/netbeans/modules/profiler/mf-layer.xml
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/profiler/Bundle.properties
5
OpenIDE-Module-Install: org/netbeans/modules/profiler/ProfilerModule.class
5
OpenIDE-Module-Install: org/netbeans/modules/profiler/ProfilerModule.class
6
OpenIDE-Module-Specification-Version: 1.18
6
OpenIDE-Module-Specification-Version: 1.19
7
OpenIDE-Module-Provides: org.netbeans.modules.profiler, org.netbeans.lib.profiler.common.Profiler
7
OpenIDE-Module-Provides: org.netbeans.modules.profiler, org.netbeans.lib.profiler.common.Profiler
8
8
(-)a/profiler/src/org/netbeans/modules/profiler/AbstractProjectTypeProfiler.java (-1 / +3 lines)
Lines 136-142 Link Here
136
136
137
    public abstract boolean checkProjectCanBeProfiled(Project project, FileObject profiledClassFile);
137
    public abstract boolean checkProjectCanBeProfiled(Project project, FileObject profiledClassFile);
138
138
139
    public abstract boolean checkProjectIsModifiedForProfiler(Project project);
139
    public boolean checkProjectIsModifiedForProfiler(Project project) {
140
        return true;
141
    }
140
142
141
    public List<SimpleFilter> getPredefinedInstrumentationFilters(Project project) {
143
    public List<SimpleFilter> getPredefinedInstrumentationFilters(Project project) {
142
        return ProjectUtilities.getProjectDefaultInstrFilters(project);
144
        return ProjectUtilities.getProjectDefaultInstrFilters(project);
(-)a/profiler/src/org/netbeans/modules/profiler/utils/ProjectUtilities.java (-16 / +47 lines)
Lines 100-105 Link Here
100
import java.util.Set;
100
import java.util.Set;
101
import java.util.logging.Level;
101
import java.util.logging.Level;
102
import java.util.logging.Logger;
102
import java.util.logging.Logger;
103
import java.util.regex.Matcher;
104
import java.util.regex.Pattern;
103
import javax.swing.Icon;
105
import javax.swing.Icon;
104
import javax.swing.ImageIcon;
106
import javax.swing.ImageIcon;
105
import javax.swing.JButton;
107
import javax.swing.JButton;
Lines 107-112 Link Here
107
import javax.swing.event.ChangeListener;
109
import javax.swing.event.ChangeListener;
108
import org.netbeans.modules.profiler.NetBeansProfiler;
110
import org.netbeans.modules.profiler.NetBeansProfiler;
109
import org.netbeans.modules.profiler.projectsupport.utilities.SourceUtils;
111
import org.netbeans.modules.profiler.projectsupport.utilities.SourceUtils;
112
import org.netbeans.spi.project.ProjectServiceProvider;
113
import org.netbeans.spi.project.ui.ProjectOpenedHook;
110
import org.openide.loaders.DataObject;
114
import org.openide.loaders.DataObject;
111
import org.openide.util.lookup.Lookups;
115
import org.openide.util.lookup.Lookups;
112
import org.openide.util.lookup.ProxyLookup;
116
import org.openide.util.lookup.ProxyLookup;
Lines 120-125 Link Here
120
 */
124
 */
121
@Deprecated
125
@Deprecated
122
public final class ProjectUtilities {
126
public final class ProjectUtilities {
127
    @ProjectServiceProvider(service=ProjectOpenedHook.class, 
128
                            projectType={
129
                                "org-netbeans-modules-java-j2seproject",
130
                                "org-netbeans-modules-j2ee-earproject",
131
                                "org-netbeans-modules-j2ee-ejbjarproject",
132
                                "org-netbeans-modules-web-project"})
133
    final public static class IntegrationUpdater extends ProjectOpenedHook {
134
        private Project prj;
135
136
        public IntegrationUpdater(Project prj) {
137
            this.prj = prj;
138
        }
139
140
        @Override
141
        protected void projectClosed() {
142
            // ignore
143
        }
144
145
        @Override
146
        protected void projectOpened() {
147
            Element e = ProjectUtils.getAuxiliaryConfiguration(prj)
148
                           .getConfigurationFragment("data", ProjectUtilities.PROFILER_NAME_SPACE, false); // NOI18N
149
150
            if (e != null) {
151
                unintegrateProfiler(prj);
152
            }
153
        }
154
    }
123
    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
155
    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
124
156
125
    private static final Logger LOGGER = Logger.getLogger(ProjectUtilities.class.getName());
157
    private static final Logger LOGGER = Logger.getLogger(ProjectUtilities.class.getName());
Lines 310-329 Link Here
310
        return buildDir;
342
        return buildDir;
311
    }
343
    }
312
344
345
    final private static Pattern PROFILER_INIT = Pattern.compile("<\\s*target\\s+.*?name\\s*=\\s*\"profile-init\"", Pattern.DOTALL | Pattern.MULTILINE);
313
    public static boolean isProfilerIntegrated(Project project) {
346
    public static boolean isProfilerIntegrated(Project project) {
314
        Element e = ProjectUtils.getAuxiliaryConfiguration(project)
347
        String buildXml = ProjectUtilities.getProjectBuildScript(project, "nbproject/build-impl.xml"); // NOI18N
315
                           .getConfigurationFragment("data", ProjectUtilities.PROFILER_NAME_SPACE, false); // NOI18N
348
        Matcher m = PROFILER_INIT.matcher(buildXml);
316
349
        return m.find();
317
        return e != null;
318
319
        // TODO: Should check for obsolete versions (currently commented below)
320
321
        //    if (e != null) {
322
        //      String storedVersion = e.getAttribute("version"); // NOI18N
323
        //      if (storedVersion.equals("0.9.1")) return true; // NOI18N
324
        //    }
325
        //
326
        //    return false;
327
    }
350
    }
328
351
329
    public static float getProfilingOverhead(ProfilingSettings settings) {
352
    public static float getProfilingOverhead(ProfilingSettings settings) {
Lines 357-363 Link Here
357
    }
380
    }
358
381
359
    public static String getProjectBuildScript(final Project project) {
382
    public static String getProjectBuildScript(final Project project) {
360
        final FileObject buildFile = findBuildFile(project);
383
        return getProjectBuildScript(project, "build.xml");
384
    }
385
386
    public static String getProjectBuildScript(final Project project, final String buildXml) {
387
        final FileObject buildFile = findBuildFile(project, buildXml);
361
        if (buildFile == null) {
388
        if (buildFile == null) {
362
            return null;
389
            return null;
363
        }
390
        }
Lines 403-416 Link Here
403
        Properties props = org.netbeans.modules.profiler.projectsupport.utilities.ProjectUtilities.getProjectProperties(project);
430
        Properties props = org.netbeans.modules.profiler.projectsupport.utilities.ProjectUtilities.getProjectProperties(project);
404
        String buildFileName = props != null ? props.getProperty("buildfile") : null; // NOI18N
431
        String buildFileName = props != null ? props.getProperty("buildfile") : null; // NOI18N
405
        if (buildFileName != null) {
432
        if (buildFileName != null) {
406
            buildFile = project.getProjectDirectory().getFileObject(buildFileName);
433
            buildFile = findBuildFile(project, buildFileName);
407
        }
434
        }
408
        if (buildFile == null) {
435
        if (buildFile == null) {
409
            buildFile = project.getProjectDirectory().getFileObject("build.xml"); //NOI18N
436
            buildFile = findBuildFile(project, "build.xml"); //NOI18N
410
        }
437
        }
411
        return buildFile;
438
        return buildFile;
412
    }
439
    }
413
440
441
    public static FileObject findBuildFile(final Project project, final String buildFileName) {
442
        return project.getProjectDirectory().getFileObject(buildFileName);
443
    }
444
414
    public static java.util.List<SimpleFilter> getProjectDefaultInstrFilters(Project project) {
445
    public static java.util.List<SimpleFilter> getProjectDefaultInstrFilters(Project project) {
415
        java.util.List<SimpleFilter> v = new ArrayList<SimpleFilter>();
446
        java.util.List<SimpleFilter> v = new ArrayList<SimpleFilter>();
416
447
(-)a/web.project/src/org/netbeans/modules/web/project/resources/build-impl.xsl (-2 / +116 lines)
Lines 917-922 Link Here
917
                <property name="ap.cmd.line.internal" value=""/>
917
                <property name="ap.cmd.line.internal" value=""/>
918
            </target>
918
            </target>
919
919
920
            <target name="profile-init" depends="-profile-pre-init, init, -profile-post-init, -profile-init-check"/>
921
922
            <target name="-profile-pre-init">
923
                <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
924
                <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
925
            </target>
926
927
            <target name="-profile-post-init">
928
                <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
929
                <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
930
            </target>
931
            <target name="-profile-init-check">
932
                <xsl:attribute name="depends">-profile-pre-init, init, -profile-post-init</xsl:attribute>
933
                <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
934
                <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
935
            </target>
936
920
            <target name="init">
937
            <target name="init">
921
                <xsl:attribute name="depends">-pre-init,-init-private<xsl:if test="/p:project/p:configuration/libs:libraries/libs:definitions">,-init-libraries</xsl:if>,-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</xsl:attribute>
938
                <xsl:attribute name="depends">-pre-init,-init-private<xsl:if test="/p:project/p:configuration/libs:libraries/libs:definitions">,-init-libraries</xsl:if>,-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</xsl:attribute>
922
            </target>
939
            </target>
Lines 1651-1657 Link Here
1651
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1668
                <xsl:attribute name="if">netbeans.home</xsl:attribute>
1652
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix</xsl:attribute>
1669
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix</xsl:attribute>
1653
            </target>
1670
            </target>
1654
            
1671
1672
            <xsl:comment>
1673
            =================
1674
            PROFILING SECTION
1675
            =================
1676
            </xsl:comment>
1677
1678
            <target name="profile">
1679
                <xsl:attribute name="description">Profile a J2EE project in the IDE.</xsl:attribute>
1680
                <condition>
1681
                    <xsl:attribute name="property">profiler.startserver.target</xsl:attribute>
1682
                    <xsl:attribute name="value">start-profiled-server-extraargs</xsl:attribute>
1683
                    <xsl:attribute name="else">start-profiled-server</xsl:attribute>
1684
                    <isset>
1685
                        <xsl:attribute name="property">profiler.info.jvmargs.extra</xsl:attribute>
1686
                    </isset>
1687
                </condition>
1688
                <antcall>
1689
                    <xsl:attribute name="target">${profiler.startserver.target}</xsl:attribute>
1690
                </antcall>
1691
                <antcall>
1692
                    <xsl:attribute name="target">run</xsl:attribute>
1693
                </antcall>
1694
                <antcall>
1695
                    <xsl:attribute name="target">start-loadgen</xsl:attribute>
1696
                </antcall>
1697
            </target>
1698
1699
            <target name="start-profiled-server">
1700
                <nbstartprofiledserver>
1701
                    <xsl:attribute name="forceRestart">${profiler.j2ee.serverForceRestart}</xsl:attribute>
1702
                    <xsl:attribute name="startupTimeout">${profiler.j2ee.serverStartupTimeout}</xsl:attribute>
1703
                    <xsl:attribute name="javaPlatform">${profiler.info.javaPlatform}</xsl:attribute>
1704
                    <jvmarg>
1705
                        <xsl:attribute name="value">${profiler.info.jvmargs.agent}</xsl:attribute>
1706
                    </jvmarg>
1707
                    <jvmarg>
1708
                        <xsl:attribute name="value">${profiler.j2ee.agentID}</xsl:attribute>
1709
                    </jvmarg>
1710
                </nbstartprofiledserver>
1711
            </target>
1712
1713
            <target name="start-profiled-server-extraargs">
1714
                <nbstartprofiledserver>
1715
                    <xsl:attribute name="forceRestart">${profiler.j2ee.serverForceRestart}</xsl:attribute>
1716
                    <xsl:attribute name="startupTimeout">${profiler.j2ee.serverStartupTimeout}</xsl:attribute>
1717
                    <xsl:attribute name="javaPlatform">${profiler.info.javaPlatform}</xsl:attribute>
1718
                    <jvmarg>
1719
                        <xsl:attribute name="value">${profiler.info.jvmargs.extra}</xsl:attribute>
1720
                    </jvmarg>
1721
                    <jvmarg>
1722
                        <xsl:attribute name="value">${profiler.info.jvmargs.agent}</xsl:attribute>
1723
                    </jvmarg>
1724
                    <jvmarg>
1725
                        <xsl:attribute name="value">${profiler.j2ee.agentID}</xsl:attribute>
1726
                    </jvmarg>
1727
                </nbstartprofiledserver>
1728
            </target>
1729
1730
            <target name="start-loadgen" if="profiler.loadgen.path">
1731
                    <loadgenstart>
1732
                        <xsl:attribute name="path">${profiler.loadgen.path}</xsl:attribute>
1733
                    </loadgenstart>
1734
            </target>
1735
1655
            <xsl:comment>
1736
            <xsl:comment>
1656
                JAVADOC SECTION
1737
                JAVADOC SECTION
1657
            </xsl:comment>
1738
            </xsl:comment>
Lines 1934-1940 Link Here
1934
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix-test</xsl:attribute>
2015
                <xsl:attribute name="depends">init,-pre-debug-fix,-do-debug-fix-test</xsl:attribute>
1935
            </target>
2016
            </target>
1936
            
2017
            
1937
            
2018
        <xsl:comment>
2019
        =========================
2020
        TESTS PROFILING  SECTION
2021
        =========================
2022
        </xsl:comment>
2023
2024
          <target name="profile-test-single">
2025
              <xsl:attribute name="if">netbeans.home</xsl:attribute>
2026
              <xsl:attribute name="depends">profile-init,compile-test-single</xsl:attribute>
2027
              <nbprofiledirect>
2028
                  <classpath>
2029
                      <path path="${{run.test.classpath}}"/>
2030
                      <path path="${{j2ee.platform.classpath}}"/>
2031
                  </classpath>
2032
              </nbprofiledirect>
2033
2034
              <junit showoutput="true" fork="true" dir="${{profiler.info.dir}}"  jvm="${{profiler.info.jvm}}" failureproperty="tests.failed" errorproperty="tests.failed">
2035
                  <env key="${{profiler.info.pathvar}}" path="${{profiler.info.agentpath}}:${{profiler.current.path}}"/>
2036
                  <jvmarg value="${{profiler.info.jvmargs.agent}}" />
2037
                  <jvmarg line="${{profiler.info.jvmargs}}"/>
2038
                  <test name="${{profile.class}}"/>
2039
                  <classpath>
2040
                      <path path="${{run.test.classpath}}"/>
2041
                      <path path="${{j2ee.platform.classpath}}"/>
2042
                  </classpath>
2043
                  <syspropertyset>
2044
                      <propertyref prefix="test-sys-prop."/>
2045
                      <mapper type="glob" from="test-sys-prop.*" to="*"/>
2046
                  </syspropertyset>
2047
                  <formatter type="brief" usefile="false"/>
2048
                  <formatter type="xml"/>
2049
              </junit>
2050
          </target>
2051
1938
            <xsl:comment>
2052
            <xsl:comment>
1939
                
2053
                
1940
                CLEANUP SECTION
2054
                CLEANUP SECTION

Return to bug 189151