File tree Expand file tree Collapse file tree 5 files changed +92
-2
lines changed
nucleus/flashlight/framework/src/main/java/org/glassfish/flashlight Expand file tree Collapse file tree 5 files changed +92
-2
lines changed Original file line number Diff line number Diff line change 127127 </executions >
128128 </plugin >
129129
130+ <plugin >
131+ <groupId >org.codehaus.gmaven</groupId >
132+ <artifactId >groovy-maven-plugin</artifactId >
133+ <executions >
134+ <execution >
135+ <id >merge-manifest-values-to-properties</id >
136+ <phase >prepare-package</phase >
137+ </execution >
138+ </executions >
139+ </plugin >
140+
130141 <plugin >
131142 <artifactId >maven-assembly-plugin</artifactId >
132143 <executions >
168179 <Main-Class >org.glassfish.runnablejar.UberMain</Main-Class >
169180 <Add-Opens >java.base/java.lang java.base/java.io java.base/java.util java.base/sun.nio.fs java.base/sun.net.www.protocol.jrt java.naming/javax.naming.spi java.rmi/sun.rmi.transport jdk.management/com.sun.management.internal java.base/jdk.internal.vm.annotation</Add-Opens >
170181 <Add-Exports >java.naming/com.sun.jndi.ldap java.base/jdk.internal.vm.annotation</Add-Exports >
182+ <probe-provider-class-names >${probe.provider.class.names} </probe-provider-class-names >
171183 </manifestEntries >
172184 </archive >
173185 </configuration >
Original file line number Diff line number Diff line change 1616 SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1717
1818-->
19-
2019<project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" >
2120 <modelVersion >4.0.0</modelVersion >
2221
5251 </dependencies >
5352 </dependencyManagement >
5453
54+ <build >
55+ <pluginManagement >
56+ <plugins >
57+ <plugin >
58+ <groupId >org.codehaus.gmaven</groupId >
59+ <artifactId >groovy-maven-plugin</artifactId >
60+ <executions >
61+ <execution >
62+ <!-- Merges all values in the 'probe-provider-class-names'
63+
64+ attribute into a system property 'probe.provider.class.names',
65+
66+ which be used when building the final manifest
67+ -->
68+ <id >merge-manifest-values-to-properties</id >
69+ <goals >
70+ <goal >execute</goal >
71+ </goals >
72+ <configuration >
73+ <source >
74+ import java.util.jar.JarFile
75+ import java.util.jar.Manifest
76+
77+ def probeProviders = [] as Set
78+
79+ project. artifacts. each { artifact ->
80+ if (artifact. type == ' jar' ) {
81+ try {
82+ def jar = new JarFile (artifact. file)
83+ def manifest = jar. manifest
84+ if (manifest) {
85+ def probeValue = manifest. mainAttributes. getValue(' probe-provider-class-names' )
86+ if (probeValue) {
87+ probeProviders. add(probeValue)
88+ }
89+ }
90+ jar. close()
91+ } catch (Exception e) {
92+ // Ignore invalid JARs
93+ }
94+ }
95+ }
96+
97+ if (probeProviders) {
98+ project. properties[' probe.provider.class.names' ] = probeProviders. join(' ,' )
99+ println " Found ${ probeProviders.size()} probe providers in project dependencies"
100+ } else {
101+ println " No probe providers found in project dependencies"
102+ }
103+ </source >
104+ </configuration >
105+ </execution >
106+ </executions >
107+ </plugin >
108+ </plugins >
109+ </pluginManagement >
110+ </build >
111+
55112</project >
Original file line number Diff line number Diff line change 113113 </executions >
114114 </plugin >
115115
116+ <plugin >
117+ <groupId >org.codehaus.gmaven</groupId >
118+ <artifactId >groovy-maven-plugin</artifactId >
119+ <executions >
120+ <execution >
121+ <id >merge-manifest-values-to-properties</id >
122+ <phase >prepare-package</phase >
123+ </execution >
124+ </executions >
125+ </plugin >
126+
116127 <plugin >
117128 <artifactId >maven-assembly-plugin</artifactId >
118129 <executions >
192203 <Main-Class >org.glassfish.runnablejar.UberMain</Main-Class >
193204 <Add-Opens >java.base/java.lang java.base/java.io java.base/java.util java.base/sun.nio.fs java.base/sun.net.www.protocol.jrt java.naming/javax.naming.spi java.rmi/sun.rmi.transport jdk.management/com.sun.management.internal java.base/jdk.internal.vm.annotation</Add-Opens >
194205 <Add-Exports >java.naming/com.sun.jndi.ldap java.base/jdk.internal.vm.annotation</Add-Exports >
206+ <probe-provider-class-names >${probe.provider.class.names} </probe-provider-class-names >
195207 </manifestEntries >
196208 </archive >
197209 </configuration >
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ public void execute(AdminCommandContext context) {
126126 if (!AgentAttacher .attachAgent (pidInt , options )) {
127127 ActionReport .MessagePart part = report .getTopMessagePart ().addChild ();
128128 part .setMessage (localStrings .getLocalString ("attach.agent.exception" ,
129- "Can't attach the agent to the JVM." ));
129+ "Can't attach the agent to the JVM. Restart with the flash-light agent attached by the -javaagent command line parameter " ));
130130 report .setActionExitCode (ActionReport .ExitCode .FAILURE );
131131 return ;
132132 }
Original file line number Diff line number Diff line change @@ -48,13 +48,22 @@ static boolean attachAgent() {
4848 return attachAgent (-1 , "" );
4949 }
5050
51+ private static final String AGENT_CLASSNAME = "org.glassfish.flashlight.agent.ProbeAgentMain" ;
5152 static boolean attachAgent (long pid , String options ) {
5253 try {
5354 if (isAttached ) {
5455 return true ;
5556 }
5657
5758 if (pid < 0 ) {
59+
60+ try {
61+ ClassLoader .getSystemClassLoader ().loadClass (AGENT_CLASSNAME );
62+ isAttached = true ;
63+ return true ;
64+ } catch (Throwable t ) {
65+ }
66+
5867 pid = ProcessHandle .current ().pid ();
5968 }
6069
You can’t perform that action at this time.
0 commit comments