Package java.lang.instrument

Examples of java.lang.instrument.ClassFileTransformer


    public static void premain(
        final String agentArgs,
        final Instrumentation inst)
    {
        inst.addTransformer(new ClassFileTransformer() {
            public byte[] transform(
                final ClassLoader loader,
                final String className,
                final Class<?> classBeingRedefined,
                final ProtectionDomain domain,
View Full Code Here


    public static void premain(
        final String agentArgs,
        final Instrumentation inst)
    {
        inst.addTransformer(new ClassFileTransformer() {
            public byte[] transform(
                final ClassLoader loader,
                final String className,
                final Class<?> classBeingRedefined,
                final ProtectionDomain domain,
View Full Code Here

        Log log = conf.getLog(OpenJPAConfiguration.LOG_ENHANCE);
        if (classes == null || classes.size() == 0)
            return;

        Instrumentation inst = null;
        ClassFileTransformer t = null;
        try {
            inst = InstrumentationFactory.getInstrumentation();

            Class[] array = classes.keySet().toArray(new Class[classes.size()]);
            if (JavaVersions.VERSION >= 6) {
                log.trace(_loc.get("retransform-types", classes.keySet()));

                t = new ClassFileTransformer() {
                    public byte[] transform(ClassLoader loader, String clsName,
                        Class<?> classBeingRedefined, ProtectionDomain pd,
                        byte[] classfileBuffer) {
                        return classes.get(classBeingRedefined);
                    }
View Full Code Here

            public ClassLoader getNewTempClassLoader(ClassLoader classLoader) {
                return new TempClassLoader(classLoader);
            }
        };

        Agent.getInstrumentation().addTransformer(new ClassFileTransformer() {
            public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
                if (!className.equals("org/apache/openejb/core/cmp/jpa/Employee")) {
                    return null;
                }
                byte[] newBytes = addNewField(classfileBuffer);
View Full Code Here

        // resolve against the system loader and injection into bootstrap classes fails. But that's still ok
        // because the byteman classes are still only foudn in one place.

        boolean isRedefine = inst.isRedefineClassesSupported();

        ClassFileTransformer transformer;
        ClassLoader loader = ClassLoader.getSystemClassLoader();
        Class transformerClazz;

        if (allowRedefine && isRedefine) {
            transformerClazz = loader.loadClass("org.jboss.byteman.agent.Retransformer");
View Full Code Here

            public ClassLoader getNewTempClassLoader(ClassLoader classLoader) {
                return new TemporaryClassLoader(classLoader);
            }
        };

        Agent.getInstrumentation().addTransformer(new ClassFileTransformer() {
            public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) {
                if (!className.equals("org/apache/openejb/core/cmp/jpa/Employee")) {
                    return null;
                }
                byte[] newBytes = addNewField(classfileBuffer);
View Full Code Here

        // resolve against the system loader and injection into bootstrap classes fails. But that's still ok
        // because the byteman classes are still only foudn in one place.

        boolean isRedefine = inst.isRedefineClassesSupported();

        ClassFileTransformer transformer;
        ClassLoader loader = ClassLoader.getSystemClassLoader();
        Class transformerClazz;

        if (allowRedefine && isRedefine) {
            transformerClazz = loader.loadClass("org.jboss.byteman.agent.Retransformer");
View Full Code Here

        }

        ProtectionDomain protectionDomain = null;

        for (int i = 0; i < _classFileTransformerList.size(); i++) {
          ClassFileTransformer transformer = _classFileTransformerList.get(i);

          try {
            byte []enhancedBuffer = transformer.transform(this,
                                                          className,
                                                          redefineClass,
                                                          protectionDomain,
                                                          bBuf);
View Full Code Here

    @Override
    public void addTransformer(final ClassTransformer transformer) {

        // wrap in a ClassFileTransformer
        ClassFileTransformer transformerWrapper = new ClassFileTransformer() {

            public byte[] transform(
                    ClassLoader loader,
                    String className,
                    Class<?> classBeingRedefined,
View Full Code Here

            EntityMapLoader loader = new EntityMapLoader(unit);

            // add transformer before DataMapConverter starts loading the classes via app
            // class loader
            ClassFileTransformer enhancer = new Enhancer(new JpaEnhancerVisitorFactory(
                    loader.getEntityMap()));
            Map<String, JpaClassDescriptor> managedClasses = loader
                    .getEntityMap()
                    .getManagedClasses();
            unit.addTransformer(new UnitClassTransformer(managedClasses, loader
View Full Code Here

TOP

Related Classes of java.lang.instrument.ClassFileTransformer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.