Search in sources :

Example 11 with MethodVisitor

use of org.glassfish.hk2.external.org.objectweb.asm.MethodVisitor in project Payara by payara.

the class ASMClassWriter method createGetDeleteCommandForCollectionLeafResource.

@Override
public void createGetDeleteCommandForCollectionLeafResource(String deleteCommandName) {
    MethodVisitor mv = cw.visitMethod(ACC_PROTECTED, "getDeleteCommand", "()Ljava/lang/String;", null, null);
    mv.visitCode();
    mv.visitLdcInsn(deleteCommandName);
    mv.visitInsn(ARETURN);
    mv.visitMaxs(1, 1);
    mv.visitEnd();
}
Also used : MethodVisitor(org.glassfish.hk2.external.org.objectweb.asm.MethodVisitor)

Example 12 with MethodVisitor

use of org.glassfish.hk2.external.org.objectweb.asm.MethodVisitor in project Payara by payara.

the class ASMClassWriter method createGetDisplayNameForCollectionLeafResource.

@Override
public void createGetDisplayNameForCollectionLeafResource(String displayName) {
    MethodVisitor mv = cw.visitMethod(ACC_PROTECTED, "getName", "()Ljava/lang/String;", null, null);
    mv.visitCode();
    mv.visitLdcInsn(displayName);
    mv.visitInsn(ARETURN);
    mv.visitMaxs(1, 1);
    mv.visitEnd();
}
Also used : MethodVisitor(org.glassfish.hk2.external.org.objectweb.asm.MethodVisitor)

Example 13 with MethodVisitor

use of org.glassfish.hk2.external.org.objectweb.asm.MethodVisitor in project Payara by payara.

the class ASMClassWriter method createGetChildResource.

@Override
public void createGetChildResource(String path, String childResourceClassName) {
    String childClass;
    switch(childResourceClassName) {
        case "PropertiesBagResource":
            childClass = "org/glassfish/admin/rest/resources/PropertiesBagResource";
            break;
        case "MonitoredAttributeBagResource":
            childClass = "fish/payara/admin/rest/resources/MonitoredAttributeBagResource";
            break;
        default:
            childClass = generatedPath + childResourceClassName;
            break;
    }
    String methodName = "get" + childResourceClassName;
    if (childClass.equals(generatedMethods.get(methodName))) {
        return;
    }
    generatedMethods.put(methodName, childClass);
    MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "()L" + childClass + ";", null, null);
    RestLogging.restLogger.log(Level.FINE, "Creating resource with path {0} (4)", path);
    AnnotationVisitor av0 = mv.visitAnnotation("Ljavax/ws/rs/Path;", true);
    av0.visit("value", path + "/");
    av0.visitEnd();
    mv.visitCode();
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, generatedPath + className, INJECTOR_FIELD, FORNAME_INJECTOR_TYPE);
    mv.visitLdcInsn(Type.getType("L" + childClass + ";"));
    mv.visitMethodInsn(INVOKEINTERFACE, INTERFACE_INJECTOR_TYPE, CREATE_AND_INITIALIZE, CREATE_AND_INITIALIZE_SIG);
    mv.visitTypeInsn(CHECKCAST, childClass);
    mv.visitVarInsn(ASTORE, 1);
    mv.visitVarInsn(ALOAD, 1);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitMethodInsn(INVOKEVIRTUAL, generatedPath + className, "getEntity", "()Lorg/jvnet/hk2/config/Dom;");
    mv.visitLdcInsn(path);
    mv.visitMethodInsn(INVOKEVIRTUAL, childClass, "setParentAndTagName", "(Lorg/jvnet/hk2/config/Dom;Ljava/lang/String;)V");
    mv.visitVarInsn(ALOAD, 1);
    mv.visitInsn(ARETURN);
    mv.visitMaxs(3, 2);
    mv.visitEnd();
}
Also used : AnnotationVisitor(org.glassfish.hk2.external.org.objectweb.asm.AnnotationVisitor) MethodVisitor(org.glassfish.hk2.external.org.objectweb.asm.MethodVisitor)

Aggregations

MethodVisitor (org.glassfish.hk2.external.org.objectweb.asm.MethodVisitor)13 AnnotationVisitor (org.glassfish.hk2.external.org.objectweb.asm.AnnotationVisitor)5 HashMap (java.util.HashMap)2 Map (java.util.Map)2 JsonString (javax.json.JsonString)2 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)2 ParameterMap (org.glassfish.api.admin.ParameterMap)2 JsonObject (javax.json.JsonObject)1