本文整理汇总了Java中org.avaje.agentloader.AgentLoader类的典型用法代码示例。如果您正苦于以下问题:Java AgentLoader类的具体用法?Java AgentLoader怎么用?Java AgentLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AgentLoader类属于org.avaje.agentloader包,在下文中一共展示了AgentLoader类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import org.avaje.agentloader.AgentLoader; //导入依赖的package包/类
@Override
public void run(final Set<String> packages) {
try {
String params = "debug=0;packages=" + packages.stream()
.map(pkg -> pkg + ".**")
.collect(Collectors.joining(","));
URL resource = getClass().getResource(transformerClass);
String location = resource.getPath();
int idx = location.indexOf(".jar!");
if (idx > 0) {
location = location.substring(0, idx + ".jar".length());
}
File jarLocation = location.startsWith("file:")
? new File(URI.create(location))
: new File(location);
AgentLoader.loadAgent(jarLocation.getAbsolutePath(), params);
} catch (Exception ex) {
log.trace("agent already loaded", ex);
}
}
开发者ID:jooby-project,项目名称:jooby,代码行数:23,代码来源:EbeanAgentEnhancer.java
示例2: loadAgentFromClasspath
import org.avaje.agentloader.AgentLoader; //导入依赖的package包/类
/**
* Load the agent from the classpath using its name and passing params.
*/
public synchronized static boolean loadAgentFromClasspath(String agentName, String params) {
if (loaded.contains(agentName)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(S.concat("agent already loaded: ", agentName));
}
// the agent is already loaded
return true;
}
try {
// Search for the agent jar in the classpath
ClassLoader cl0 = AgentLoader.class.getClassLoader();
if (!(cl0 instanceof URLClassLoader)) {
cl0 = cl0.getParent();
}
if (cl0 instanceof URLClassLoader) {
URLClassLoader cl = (URLClassLoader) (cl0);
for (URL url : cl.getURLs()) {
if (isMatch(url, agentName)) {
// We have found the agent jar in the classpath
String fullName = url.toURI().getPath();
if (fullName.startsWith("/") && isWindows()) {
fullName = fullName.substring(1);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(S.concat("loading agent: ", fullName));
}
loadAgent(fullName, params);
loaded.add(agentName);
return true;
}
}
}
// Agent not found and not loaded
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("agent not found");
}
return false;
} catch (URISyntaxException use) {
throw new RuntimeException(use);
}
}
开发者ID:actframework,项目名称:act-ebean,代码行数:47,代码来源:EbeanAgentLoader.java
示例3: runOnce
import org.avaje.agentloader.AgentLoader; //导入依赖的package包/类
/**
* This is needed to be done once to enhance all the entity objects for Ebean ORM.
*/
@BeforeClass
public static void runOnce() {
AgentLoader.loadAgentFromClasspath("avaje-ebeanorm-agent", "debug=1");
}
开发者ID:shailesh17,项目名称:spring-boot-ebean-starter,代码行数:8,代码来源:AppTestSupport.java
注:本文中的org.avaje.agentloader.AgentLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论