本文整理汇总了Java中net.bytebuddy.utility.JavaModule类的典型用法代码示例。如果您正苦于以下问题:Java JavaModule类的具体用法?Java JavaModule怎么用?Java JavaModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaModule类属于net.bytebuddy.utility包,在下文中一共展示了JavaModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(
final DynamicType.Builder<?> builder,
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module) {
final AsmVisitorWrapper methodsVisitor =
Advice.to(EnterAdvice.class, ExitAdviceMethods.class)
.on(ElementMatchers.isAnnotatedWith(CollectMetrics.class)
.and(ElementMatchers.isMethod()));
final AsmVisitorWrapper constructorsVisitor =
Advice.to(EnterAdvice.class, ExitAdviceConstructors.class)
.on(ElementMatchers.isAnnotatedWith(CollectMetrics.class)
.and(ElementMatchers.isConstructor()));
return builder.visit(methodsVisitor).visit(constructorsVisitor);
}
示例2: testIgnoredTypeMatcherOnlyAppliedOnceWithMultipleTransformations
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Test
public void testIgnoredTypeMatcherOnlyAppliedOnceWithMultipleTransformations() throws Exception {
AgentBuilder.RawMatcher ignored = mock(AgentBuilder.RawMatcher.class);
ClassFileTransformer classFileTransformer = new AgentBuilder.Default(byteBuddy)
.with(initializationStrategy)
.with(poolStrategy)
.with(typeStrategy)
.with(installationListener)
.with(listener)
.disableNativeMethodPrefix()
.ignore(ignored)
.type(typeMatcher).transform(transformer)
.type(typeMatcher).transform(transformer)
.installOn(instrumentation);
assertThat(transform(classFileTransformer, JavaModule.ofType(REDEFINED), REDEFINED.getClassLoader(), REDEFINED.getName(), REDEFINED, REDEFINED.getProtectionDomain(), QUX), nullValue(byte[].class));
verify(listener).onDiscovery(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
verify(listener).onIgnored(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
verify(listener).onComplete(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
verifyNoMoreInteractions(listener);
verify(ignored).matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain());
verifyNoMoreInteractions(ignored);
}
示例3: doTransform
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
/**
* Applies a transformation for a class that was captured by this {@link ClassFileTransformer}.
*
* @param module The instrumented class's Java module in its wrapped form or {@code null} if the current VM does not support modules.
* @param classLoader The instrumented class's class loader.
* @param typeName The binary name of the instrumented class.
* @param classBeingRedefined The loaded {@link Class} being redefined or {@code null} if no such class exists.
* @param loaded {@code true} if the instrumented type is loaded.
* @param protectionDomain The instrumented type's protection domain.
* @param typePool The type pool to use.
* @param classFileLocator The class file locator to use.
* @return The transformed class file or an empty byte array if this transformer does not apply an instrumentation.
*/
private byte[] doTransform(JavaModule module,
ClassLoader classLoader,
String typeName,
Class<?> classBeingRedefined,
boolean loaded,
ProtectionDomain protectionDomain,
TypePool typePool,
ClassFileLocator classFileLocator) {
return resolve(module, classLoader, typeName, classBeingRedefined, loaded, protectionDomain, typePool).apply(initializationStrategy,
classFileLocator,
typeStrategy,
byteBuddy,
nativeMethodStrategy,
bootstrapInjectionStrategy,
accessControlContext,
listener);
}
示例4: onTransformation
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public void onTransformation(
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module,
boolean loaded,
DynamicType dynamicType) {
logger.log(Level.FINE, "{0}", typeDescription);
}
示例5: onError
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public void onError(
String typeName,
ClassLoader classLoader,
JavaModule module,
boolean loaded,
Throwable throwable) {
logger.log(Level.WARNING, "Failed to handle " + typeName, throwable);
}
示例6: transform
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(
DynamicType.Builder<?> builder,
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module) {
return builder.visit(Advice.to(GetContent.class).on(named("getContent")));
}
示例7: transform
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(
DynamicType.Builder<?> builder,
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module) {
return builder
.visit(Advice.to(Start.class).on(named("start")))
.visit(Advice.to(Run.class).on(named("run")));
}
示例8: transform
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Override
public DynamicType.Builder<?> transform(
DynamicType.Builder<?> builder,
TypeDescription typeDescription,
ClassLoader classLoader,
JavaModule module) {
return builder.visit(Advice.to(Execute.class).on(named("execute")));
}
示例9: onDiscovery
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onDiscovery(
final String typeName,
final ClassLoader classLoader,
final JavaModule module,
final boolean loaded)
{
}
示例10: onTransformation
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onTransformation(
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module,
final boolean loaded,
final DynamicType dynamicType)
{
System.out.println("TRANSFORM " + typeDescription.getName());
}
示例11: onIgnored
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onIgnored(
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module,
final boolean loaded)
{
}
示例12: onError
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onError(
final String typeName,
final ClassLoader classLoader,
final JavaModule module,
final boolean loaded,
final Throwable throwable)
{
System.out.println("ERROR " + typeName);
throwable.printStackTrace(System.out);
}
示例13: onComplete
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onComplete(
final String typeName,
final ClassLoader classLoader,
final JavaModule module,
final boolean loaded)
{
}
示例14: onTransformation
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onTransformation(
final TypeDescription typeDescription,
final ClassLoader classLoader,
final JavaModule module,
final boolean loaded,
final DynamicType dynamicType)
{
}
示例15: testRetransformationConsiderationException
import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
@Test
public void testRetransformationConsiderationException() throws Exception {
RuntimeException exception = new RuntimeException();
when(instrumentation.isRetransformClassesSupported()).thenReturn(true);
when(instrumentation.getAllLoadedClasses()).thenReturn(new Class<?>[]{REDEFINED});
when(instrumentation.isModifiableClass(REDEFINED)).thenReturn(true);
when(typeMatcher.matches(new TypeDescription.ForLoadedType(REDEFINED), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), REDEFINED, REDEFINED.getProtectionDomain()))
.thenThrow(exception);
ResettableClassFileTransformer classFileTransformer = new AgentBuilder.Default(byteBuddy)
.with(initializationStrategy)
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
.with(poolStrategy)
.with(typeStrategy)
.with(installationListener)
.with(listener)
.disableNativeMethodPrefix()
.ignore(none())
.type(typeMatcher).transform(transformer)
.installOn(instrumentation);
verify(instrumentation).addTransformer(classFileTransformer, true);
verify(listener).onError(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true, exception);
verify(listener).onComplete(REDEFINED.getName(), REDEFINED.getClassLoader(), JavaModule.ofType(REDEFINED), true);
verifyNoMoreInteractions(listener);
verify(installationListener).onBeforeInstall(instrumentation, classFileTransformer);
verify(installationListener).onInstall(instrumentation, classFileTransformer);
verifyNoMoreInteractions(installationListener);
}