当前位置: 首页>>代码示例>>Java>>正文


Java AgentBuilder.Transformer方法代码示例

本文整理汇总了Java中net.bytebuddy.agent.builder.AgentBuilder.Transformer方法的典型用法代码示例。如果您正苦于以下问题:Java AgentBuilder.Transformer方法的具体用法?Java AgentBuilder.Transformer怎么用?Java AgentBuilder.Transformer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.bytebuddy.agent.builder.AgentBuilder的用法示例。


在下文中一共展示了AgentBuilder.Transformer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAgentBuilder

import net.bytebuddy.agent.builder.AgentBuilder; //导入方法依赖的package包/类
/**
 * Creates the AgentBuilder that will redefine the System class.
 * @param inst instrumentation instance.
 * @return an agent builder.
 */
private static AgentBuilder createAgentBuilder(Instrumentation inst) {

    // Find me a class called "java.lang.System"
    final ElementMatcher.Junction<NamedElement> systemType = ElementMatchers.named("java.lang.System");

    // And then find a method called setSecurityManager and tell MySystemInterceptor to
    // intercept it (the method binding is smart enough to take it from there)
    final AgentBuilder.Transformer transformer =
            (b, typeDescription) -> b.method(ElementMatchers.named("setSecurityManager"))
                    .intercept(MethodDelegation.to(MySystemInterceptor.class));

    // Disable a bunch of stuff and turn on redefine as the only option
    final ByteBuddy byteBuddy = new ByteBuddy().with(Implementation.Context.Disabled.Factory.INSTANCE);
    final AgentBuilder agentBuilder = new AgentBuilder.Default()
            .withByteBuddy(byteBuddy)
            .withInitializationStrategy(AgentBuilder.InitializationStrategy.NoOp.INSTANCE)
            .withRedefinitionStrategy(AgentBuilder.RedefinitionStrategy.REDEFINITION)
            .withTypeStrategy(AgentBuilder.TypeStrategy.Default.REDEFINE)
            .type(systemType)
            .transform(transformer);

    return agentBuilder;
}
 
开发者ID:wsargent,项目名称:securityfixer,代码行数:29,代码来源:SecurityFixerAgent.java

示例2: getTransformer

import net.bytebuddy.agent.builder.AgentBuilder; //导入方法依赖的package包/类
@Override
public AgentBuilder.Transformer getTransformer() {
	return new AgentBuilder.Transformer() {
		@Override
		public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription,
												ClassLoader classLoader, JavaModule module) {
			onTypeMatch(typeDescription);
			return builder;
		}
	};
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:12,代码来源:AbstractClassPathScanner.java

示例3: getTransformer

import net.bytebuddy.agent.builder.AgentBuilder; //导入方法依赖的package包/类
public AgentBuilder.Transformer getTransformer() {
	final AsmVisitorWrapper.ForDeclaredMethods advice = getAdvice();
	if (advice == null) {
		return AgentBuilder.Transformer.NoOp.INSTANCE;
	} else {
		return new AgentBuilder.Transformer() {
			@Override
			public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription,
												    ClassLoader classLoader, JavaModule module) {
				beforeTransformation(typeDescription, classLoader);
				return builder.visit(advice);
			}
		};
	}
}
 
开发者ID:stagemonitor,项目名称:stagemonitor,代码行数:16,代码来源:StagemonitorByteBuddyTransformer.java


注:本文中的net.bytebuddy.agent.builder.AgentBuilder.Transformer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。