Examples of AnnotationsAttribute


Examples of javassist.bytecode.AnnotationsAttribute

    sb.append("return f;");
    sb.append("}");
    mnew = CtNewMethod.make(sb.toString(), mainClass);

    ConstPool cp = mnew.getMethodInfo().getConstPool();
    AnnotationsAttribute attr = new AnnotationsAttribute(cp,
        AnnotationsAttribute.visibleTag);

    javassist.bytecode.annotation.Annotation producesAnnotation = new javassist.bytecode.annotation.Annotation(
        "javax.enterprise.inject.Produces", cp);
    javassist.bytecode.annotation.Annotation zkScopedAnnotation = new javassist.bytecode.annotation.Annotation(
        "org.zkoss.cdi.context.IdSpaceScoped", cp);
    javassist.bytecode.annotation.Annotation zkCompAnnotation = new javassist.bytecode.annotation.Annotation(
        "org.zkoss.cdi.inject.ComponentId", cp);
    zkCompAnnotation.addMemberValue("value", new StringMemberValue(field
        .getName(), cp));
   
    attr.addAnnotation(producesAnnotation);
    attr.addAnnotation(zkScopedAnnotation);
    attr.addAnnotation(zkCompAnnotation);
    mnew.getMethodInfo().addAttribute(attr);
   
    mainClass.addMethod(mnew);
  }
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

      final String typeName = SOAPMessage.class.getName().replace('.', '/') ;
      final String signature = 'L' + superClassName + ';' + 'L' + interfaceName + "<L" + typeName + ";>;" ;
      final SignatureAttribute signatureAttribute = new SignatureAttribute(constantPool, signature) ;
      seiClass.getClassFile().addAttribute(signatureAttribute) ;

      AnnotationsAttribute attribute = new AnnotationsAttribute(
          constantPool, AnnotationsAttribute.visibleTag);
      Annotation annotation = new Annotation(
          "javax.xml.ws.WebServiceProvider", constantPool);
      StringMemberValue strValue1 = new StringMemberValue(constantPool);
      strValue1.setValue(epInfo.getWSDLFileName());
      annotation.addMemberValue("wsdlLocation", strValue1);
      StringMemberValue strValue2 = new StringMemberValue(constantPool);
      strValue2.setValue(epInfo.getServiceName());
      annotation.addMemberValue("serviceName", strValue2);
      StringMemberValue strValue3 = new StringMemberValue(constantPool);
      strValue3.setValue(epInfo.getPortName());
      annotation.addMemberValue("portName", strValue3);

      StringMemberValue strValue4 = new StringMemberValue(constantPool);
      strValue4.setValue(epInfo.getNamespace());
      annotation.addMemberValue("targetNamespace", strValue4);

      attribute.addAnnotation(annotation);

      Annotation annotation2 = new Annotation("javax.xml.ws.ServiceMode",
          constantPool);
      EnumMemberValue enumValue = new EnumMemberValue(constantPool);
      enumValue.setType("javax.xml.ws.Service$Mode");
      enumValue.setValue("MESSAGE");
      annotation2.addMemberValue("value", enumValue);
      attribute.addAnnotation(annotation2);

      if (epInfo.isAddressing() && JBossDeployerUtil.getWSImpl().equals(JBossDeployerUtil.WSIMPL_CXF))
      {
        Annotation annotation3 = new Annotation("javax.xml.ws.soap.Addressing", constantPool);
        BooleanMemberValue boolEnabled = new BooleanMemberValue(constantPool);
        boolEnabled.setValue(true);
        BooleanMemberValue boolRequired = new BooleanMemberValue(constantPool);
        boolRequired.setValue(true);
        annotation3.addMemberValue("enabled", boolEnabled);
        annotation3.addMemberValue("required", boolEnabled);
        attribute.addAnnotation(annotation3);
      }

      if (includeHandlers)
      {
        final Annotation handlerChainAnnotation = new Annotation("javax.jws.HandlerChain", constantPool) ;
        final StringMemberValue handlerValue = new StringMemberValue(constantPool) ;
        handlerValue.setValue("esb-jaxws-handlers.xml") ;
        handlerChainAnnotation.addMemberValue("file", handlerValue) ;
        attribute.addAnnotation(handlerChainAnnotation) ;
      }
     
      seiClass.getClassFile().addAttribute(attribute);
     
      final String siClassName = ServiceInvoker.class.getName() ;
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

            //we'll be adding new constants to the class file (for generics and annotations)
            ConstPool constPool = newClassFile.getConstPool();

            //copy the annotations on the class
            AnnotationsAttribute annotations = (AnnotationsAttribute) originalClassFile
                .getAttribute(AnnotationsAttribute.visibleTag);
            AnnotationsAttribute newAnnotations = copyAnnotations(annotations, constPool);

            //add our @Simplified annotation to the new class
            newAnnotations = addSimplifiedClassAnnotation(originalClass.getName(), newAnnotations, constPool);
            newClassFile.addAttribute(newAnnotations);
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

            Annotation[] newClassAnnotations = new Annotation[origAnnotations.length];
            for (int i = 0; i < newClassAnnotations.length; ++i) {
                newClassAnnotations[i] = cloneAnnotation(origAnnotations[i], constPool);
            }

            AnnotationsAttribute newAnnotations = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
            newAnnotations.setAnnotations(newClassAnnotations);

            return newAnnotations;
        }

        return null;
View Full Code Here

Examples of javassist.bytecode.AnnotationsAttribute

    private static AnnotationsAttribute addSimplifiedClassAnnotation(String originalClassName,
        AnnotationsAttribute annotations, ConstPool constPool) {

        if (annotations == null) {
            annotations = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
        }

        Annotation simplified = new Annotation(SimplifiedClass.class.getName(), constPool);
        simplified.addMemberValue("originalClass", new ClassMemberValue(originalClassName, constPool));
View Full Code Here

Examples of org.hotswap.agent.javassist.bytecode.AnnotationsAttribute

    /**
     * Check if the file contains annotation.
     */
    protected boolean hasAnnotation(ClassFile cf) throws IOException {

        AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
        if (visible != null) {
            for (Annotation ann : visible.getAnnotations()) {
                if (annotation.equals(ann.getTypeName())) {
                    return true;
                }
            }
        }
View Full Code Here

Examples of org.jboss.classfilewriter.annotations.AnnotationsAttribute

        this.nameIndex = constPool.addUtf8Entry(name);
        this.descriptorIndex = constPool.addUtf8Entry(descriptor);
        if(signature != null){
            attributes.add(new SignatureAttribute(constPool, signature));
        }
        runtimeVisibleAnnotationsAttribute = new AnnotationsAttribute(AnnotationsAttribute.Type.RUNTIME_VISIBLE, constPool);
        this.attributes.add(runtimeVisibleAnnotationsAttribute);
    }
View Full Code Here

Examples of org.jboss.classfilewriter.annotations.AnnotationsAttribute

            attributes.add(codeAttribute);
        }
        for (String param : this.parameters) {
            DescriptorUtils.validateDescriptor(param);
        }
        this.runtimeVisibleAnnotationsAttribute = new AnnotationsAttribute(AnnotationsAttribute.Type.RUNTIME_VISIBLE, constPool);
        this.attributes.add(runtimeVisibleAnnotationsAttribute);
        this.runtimeVisibleParameterAnnotationsAttribute = new ParameterAnnotationsAttribute(
                ParameterAnnotationsAttribute.Type.RUNTIME_VISIBLE, constPool, parameters.length);
        this.attributes.add(runtimeVisibleParameterAnnotationsAttribute);
    }
View Full Code Here

Examples of org.jboss.classfilewriter.annotations.AnnotationsAttribute

        this.superclass = superclass;
        this.accessFlags = AccessFlag.of(AccessFlag.SUPER, AccessFlag.PUBLIC);
        for (String i : interfaces) {
            this.interfaces.add(i);
        }
        runtimeVisibleAnnotationsAttribute = new AnnotationsAttribute(AnnotationsAttribute.Type.RUNTIME_VISIBLE, constPool);
        this.attributes.add(runtimeVisibleAnnotationsAttribute);
    }
View Full Code Here

Examples of org.jboss.classfilewriter.annotations.AnnotationsAttribute

        this.name = name;
        this.descriptor = descriptor;
        this.classFile = classFile;
        this.nameIndex = constPool.addUtf8Entry(name);
        this.descriptorIndex = constPool.addUtf8Entry(descriptor);
        runtimeVisibleAnnotationsAttribute = new AnnotationsAttribute(AnnotationsAttribute.Type.RUNTIME_VISIBLE, constPool);
        this.attributes.add(runtimeVisibleAnnotationsAttribute);
    }
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.