Examples of ClassTransformer


Examples of org.hibernate.bytecode.spi.ClassTransformer

            if ( !entry.isDirectory() ) {
              // see if the entry represents a class file
              final DataInputStream din = new DataInputStream( new ByteArrayInputStream( byteCode ) );
              if ( din.readInt() == CLASS_MAGIC ) {
                final ClassDescriptor descriptor = getClassDescriptor( byteCode );
                final ClassTransformer transformer = getClassTransformer( descriptor, classNames );
                if ( transformer == null ) {
                  logger.debug( "no transformer for zip entry :  " + entry.toString() );
                }
                else {
                  logger.info( "processing class : " + descriptor.getName() + ";  entry = " + file.getAbsolutePath() );
                  byteCode = transformer.transform(
                      getClass().getClassLoader(),
                      descriptor.getName(),
                      null,
                      null,
                      descriptor.getBytes()
View Full Code Here

Examples of org.hibernate.bytecode.spi.ClassTransformer

   * @throws Exception Indicates an issue either access files or applying the transformations.
   */
  protected void processClassFile(File file, Set<String> classNames) throws Exception {
    byte[] bytes = ByteCodeHelper.readByteCode( file );
    ClassDescriptor descriptor = getClassDescriptor( bytes );
    ClassTransformer transformer = getClassTransformer( descriptor, classNames );
    if ( transformer == null ) {
      logger.debug( "no trasformer for class file : " + file.getAbsolutePath() );
      return;
    }

    logger.info( "processing class : " + descriptor.getName() + ";  file = " + file.getAbsolutePath() );
    byte[] transformedBytes = transformer.transform(
        getClass().getClassLoader(),
        descriptor.getName(),
        null,
        null,
        descriptor.getBytes()
View Full Code Here

Examples of org.hibernate.bytecode.spi.ClassTransformer

                if ( !entry.isDirectory() ) {
                  // see if the entry represents a class file
                  DataInputStream din = new DataInputStream( new ByteArrayInputStream( byteCode ) );
                  if ( din.readInt() == CLASS_MAGIC ) {
                    ClassDescriptor descriptor = getClassDescriptor( byteCode );
                    ClassTransformer transformer = getClassTransformer( descriptor, classNames );
                    if ( transformer == null ) {
                      logger.debug( "no transformer for zip entry :  " + entry.toString() );
                    }
                    else {
                      logger.info( "processing class : " + descriptor.getName() + ";  entry = " + file.getAbsolutePath() );
                      byteCode = transformer.transform(
                          getClass().getClassLoader(),
                          descriptor.getName(),
                          null,
                          null,
                          descriptor.getBytes()
View Full Code Here

Examples of org.hibernate.repackage.cglib.transform.ClassTransformer

      throw new HibernateException( "Unable to read class: " + e.getMessage() );
    }

    String[] names = ClassNameReader.getClassInfo( reader );
    ClassWriter w = new DebuggingClassWriter( true );
    ClassTransformer t = getClassTransformer( names );
    if ( t != null ) {
      if ( log.isDebugEnabled() ) {
        log.debug( "Enhancing " + className );
      }
      ByteArrayOutputStream out;
View Full Code Here

Examples of org.jboss.weld.resources.ClassTransformer

    * @param interceptionSupport
    * @return
    */
    public static <T> WeldInjectionTarget<T> createInjectionTarget(Class<?> componentClass, Bean<T> bean, BeanManagerImpl beanManager,
            boolean interceptionSupport) {
        final ClassTransformer transformer = beanManager.getServices().get(ClassTransformer.class);
        @SuppressWarnings("unchecked")
        final Class<T> clazz = (Class<T>) componentClass;
        EnhancedAnnotatedType<T> type = transformer.getEnhancedAnnotatedType(clazz, beanManager.getId());

        if (!type.getJavaClass().equals(componentClass)) {
            /*
             * Jasper loads a class with multiple classloaders which is not supported by Weld.
             * If this happens, use a combination of a bean archive identifier and class' classloader hashCode as the BDA ID.
             * This breaks AnnotatedType serialization but that does not matter as these are non-contextual components.
             */
            final String bdaId = beanManager.getId() + componentClass.getClassLoader().hashCode();
            type = transformer.getEnhancedAnnotatedType(clazz, bdaId);
        }

        if (Beans.getBeanConstructor(type) == null) {
            /*
             * For example, AsyncListeners may be CDI-incompatible as long as the application never calls javax.servletAsyncContext#createListener(Class)
View Full Code Here

Examples of org.jboss.weld.resources.ClassTransformer

    class CustomInjectionPoint implements InjectionPoint {
        private final EnhancedAnnotatedField<CustomWindowFrame, ?> windowField;

        public CustomInjectionPoint() {
            TypeStore ts = new TypeStore();
            ClassTransformer transformer = new ClassTransformer(ts, new SharedObjectCache(), ReflectionCacheFactory.newInstance(ts), RegistrySingletonProvider.STATIC_INSTANCE);
            EnhancedAnnotatedType<?> targetClass = transformer.getEnhancedAnnotatedType(CustomWindowFrame.class, AnnotatedTypeIdentifier.NULL_BDA_ID);
            windowField = targetClass.getDeclaredEnhancedField("window");
        }
View Full Code Here

Examples of org.jboss.weld.resources.ClassTransformer

    @Test
    public void testInterceptorModel() {
        TypeStore typeStore = new TypeStore();
        InterceptorBindingModel<SecondaryInterceptionBinding> interceptorBindingModel
                = new InterceptorBindingModel<SecondaryInterceptionBinding>(new ClassTransformer(typeStore, new SharedObjectCache(), ReflectionCacheFactory.newInstance(typeStore), RegistrySingletonProvider.STATIC_INSTANCE).getEnhancedAnnotation(SecondaryInterceptionBinding.class));
        Set<Annotation> annotations = interceptorBindingModel.getInheritedInterceptionBindingTypes();
        assert annotations.size() != 0;
    }
View Full Code Here

Examples of org.jboss.weld.resources.ClassTransformer

    * description = "WELD-568"
    */
    @Test
    public void testWeldClassForGenericSuperclass() {
        TypeStore ts = new TypeStore();
        EnhancedAnnotatedType<StringProcessor> weldClass = new ClassTransformer(ts, new SharedObjectCache(), ReflectionCacheFactory.newInstance(ts), RegistrySingletonProvider.STATIC_INSTANCE).getEnhancedAnnotatedType(StringProcessor.class, AnnotatedTypeIdentifier.NULL_BDA_ID);
        Collection<EnhancedAnnotatedMethod<?, ? super StringProcessor>> methods = weldClass.getEnhancedMethods();
        //assert methods.size() == 2;
        List<EnhancedAnnotatedMethod<?, ?>> interceptableMethods = Beans.getInterceptableMethods(weldClass);
        Assert.assertEquals(3, interceptableMethods.size());
    }
View Full Code Here

Examples of org.jboss.weld.resources.ClassTransformer

    @BeforeMethod
    public void beforeMethod() {
        BeanIdentifierIndex beanIdentifierIndex = new BeanIdentifierIndex();
        beanIdentifierIndex.build(Collections.<Bean<?>>emptySet());
        this.typeStore = new TypeStore();
        this.classTransformer = new ClassTransformer(typeStore, new SharedObjectCache(), ReflectionCacheFactory.newInstance(typeStore), RegistrySingletonProvider.STATIC_INSTANCE);
        this.services = new SimpleServiceRegistry();
        this.services.add(MetaAnnotationStore.class, new MetaAnnotationStore(classTransformer));
        this.services.add(ContextualStore.class, new ContextualStoreImpl(STATIC_INSTANCE, beanIdentifierIndex));
        this.services.add(ClassTransformer.class, classTransformer);
        this.services.add(SharedObjectCache.class, new SharedObjectCache());
View Full Code Here

Examples of org.jboss.weld.resources.ClassTransformer

     */
    @Test
    public void testComparison() throws SecurityException, NoSuchFieldException, NoSuchMethodException {
        //check that two weld classes on the same underlying are equal
        TypeStore ts = new TypeStore();
        ClassTransformer ct = new ClassTransformer(ts, new SharedObjectCache(), ReflectionCacheFactory.newInstance(ts), RegistrySingletonProvider.STATIC_INSTANCE);
        EnhancedAnnotatedType<Chair> chair1 = EnhancedAnnotatedTypeImpl.of(BackedAnnotatedType.of(Chair.class, ct.getSharedObjectCache(), ct.getReflectionCache(), RegistrySingletonProvider.STATIC_INSTANCE, AnnotatedTypeIdentifier.NULL_BDA_ID), ct);
        EnhancedAnnotatedType<Chair> chair2 = EnhancedAnnotatedTypeImpl.of(BackedAnnotatedType.of(Chair.class, ct.getSharedObjectCache(), ct.getReflectionCache(), RegistrySingletonProvider.STATIC_INSTANCE, AnnotatedTypeIdentifier.NULL_BDA_ID), ct);
        Assert.assertTrue(AnnotatedTypes.compareAnnotatedTypes(chair1, chair2));

        //check that a different implementation of annotated type is equal to the weld implementation
        TestAnnotatedTypeBuilder<Chair> builder = new TestAnnotatedTypeBuilder<Chair>(Chair.class);
        builder.addToClass(new DefaultLiteral());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.