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


Java JavaModule类代码示例

本文整理汇总了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);
}
 
开发者ID:ivanyu,项目名称:java-agents-demo,代码行数:20,代码来源:MetricsCollectionByteBuddyAgent.java

示例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);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:23,代码来源:AgentBuilderDefaultTest.java

示例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);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:31,代码来源:AgentBuilder.java

示例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);
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:10,代码来源:AgentBuilderListener.java

示例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);
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:10,代码来源:AgentBuilderListener.java

示例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")));
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:9,代码来源:UrlInstrumentation.java

示例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")));
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:11,代码来源:ThreadInstrumentation.java

示例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")));
}
 
开发者ID:census-instrumentation,项目名称:opencensus-java,代码行数:9,代码来源:ExecutorInstrumentation.java

示例9: onDiscovery

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onDiscovery(
    final String typeName,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded)
{
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:8,代码来源:EventLogAgent.java

示例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());
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:10,代码来源:EventLogAgent.java

示例11: onIgnored

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onIgnored(
    final TypeDescription typeDescription,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded)
{
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:8,代码来源:EventLogAgent.java

示例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);
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:11,代码来源:EventLogAgent.java

示例13: onComplete

import net.bytebuddy.utility.JavaModule; //导入依赖的package包/类
public void onComplete(
    final String typeName,
    final ClassLoader classLoader,
    final JavaModule module,
    final boolean loaded)
{
}
 
开发者ID:real-logic,项目名称:aeron,代码行数:8,代码来源:EventLogAgent.java

示例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)
{
}
 
开发者ID:real-logic,项目名称:agrona,代码行数:9,代码来源:BufferAlignmentAgent.java

示例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);
}
 
开发者ID:raphw,项目名称:byte-buddy,代码行数:28,代码来源:AgentBuilderDefaultTest.java


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