This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement StagemonitorRuntimeAgentAttacherDriver to attach the agent …
…ealier in the lifecycle of JBoss/wildfly
- Loading branch information
Felix Barnsteiner
committed
May 14, 2015
1 parent
c53e011
commit ea37dc0
Showing
3 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...rc/main/java/org/stagemonitor/core/instrument/StagemonitorRuntimeAgentAttacherDriver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.stagemonitor.core.instrument; | ||
|
||
import java.sql.Connection; | ||
import java.sql.Driver; | ||
import java.sql.DriverPropertyInfo; | ||
import java.sql.SQLException; | ||
import java.sql.SQLFeatureNotSupportedException; | ||
import java.util.Properties; | ||
import java.util.logging.Logger; | ||
|
||
import org.slf4j.LoggerFactory; | ||
import org.stagemonitor.core.CorePlugin; | ||
import org.stagemonitor.core.Stagemonitor; | ||
|
||
/** | ||
* This is not a real Driver, it is just used to attach the stagemonitor agent as early in the lifecycle as possible. | ||
* Because the earlier the agent is attached, the less classes have to be retransformed, which is a expensive operation. | ||
* | ||
* Some application server as wildfly load all Driver implementations with a ServiceLoader at startup and even | ||
* before @WebListener classes are loaded. | ||
*/ | ||
public class StagemonitorRuntimeAgentAttacherDriver implements Driver { | ||
|
||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(StagemonitorRuntimeAgentAttacherDriver.class); | ||
|
||
static { | ||
try { | ||
final CorePlugin configuration = Stagemonitor.getConfiguration(CorePlugin.class); | ||
if (configuration.isStagemonitorActive() && configuration.isAttachAgentAtRuntime()) { | ||
MainStagemonitorClassFileTransformer.performRuntimeAttachment(); | ||
} | ||
} catch (Exception e) { | ||
logger.warn(e.getMessage(), e); | ||
} | ||
} | ||
|
||
@Override | ||
public Connection connect(String url, Properties info) throws SQLException { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean acceptsURL(String url) throws SQLException { | ||
return false; | ||
} | ||
|
||
@Override | ||
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { | ||
return new DriverPropertyInfo[0]; | ||
} | ||
|
||
@Override | ||
public int getMajorVersion() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public int getMinorVersion() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public boolean jdbcCompliant() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public Logger getParentLogger() throws SQLFeatureNotSupportedException { | ||
throw new SQLFeatureNotSupportedException(); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
stagemonitor-core/src/main/resources/META-INF/services/java.sql.Driver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.stagemonitor.core.instrument.StagemonitorRuntimeAgentAttacherDriver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters