List of usage examples for org.objectweb.asm.tree MethodNode MethodNode
public MethodNode()
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.NamesTestCase.java
License:Apache License
public void testNoPatternRecognized() throws Exception { MethodNode node = new MethodNode(); node.name = "notify"; node.desc = "()V"; assertNull(getMethodIdentifier(node)); }
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.NamesTestCase.java
License:Apache License
public void testSpecificationRecognized() throws Exception { MethodNode node = new MethodNode(); node.name = "handle"; node.desc = "(Lmy/Service;)V"; assertEquals("my.Service", getMethodIdentifier(node)); }
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.NamesTestCase.java
License:Apache License
public void testSpecificationRecognizedWithMap() throws Exception { MethodNode node = new MethodNode(); node.name = "handle"; node.desc = "(Lmy/Service;Ljava/util/Map;)V"; assertEquals("my.Service", getMethodIdentifier(node)); }
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.NamesTestCase.java
License:Apache License
public void testSpecificationRecognizedWithDictionary() throws Exception { MethodNode node = new MethodNode(); node.name = "handle"; node.desc = "(Lmy/Service;Ljava/util/Dictionary;)V"; assertEquals("my.Service", getMethodIdentifier(node)); }
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.NamesTestCase.java
License:Apache License
public void testSpecificationRecognizedWithServiceReference() throws Exception { MethodNode node = new MethodNode(); node.name = "handle"; node.desc = "(Lmy/Service;Lorg/osgi/framework/ServiceReference;)V"; assertEquals("my.Service", getMethodIdentifier(node)); }
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.NamesTestCase.java
License:Apache License
public void testSpecificationRecognizedOnlyMap() throws Exception { MethodNode node = new MethodNode(); node.name = "handle"; node.desc = "(Ljava/util/Map;)V"; assertNull(getMethodIdentifier(node)); }
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.NamesTestCase.java
License:Apache License
public void testSpecificationRecognizedOnlyDictionary() throws Exception { MethodNode node = new MethodNode(); node.name = "handle"; node.desc = "(Ljava/util/Dictionary;)V"; assertNull(getMethodIdentifier(node)); }
From source file:org.apache.felix.ipojo.manipulator.metadata.annotation.visitor.util.NamesTestCase.java
License:Apache License
public void testSpecificationRecognizedOnlyServiceReference() throws Exception { MethodNode node = new MethodNode(); node.name = "handle"; node.desc = "(Lorg/osgi/framework/ServiceReference;)V"; assertNull(getMethodIdentifier(node)); }
From source file:org.diorite.inject.controller.Transformer.java
License:Open Source License
private void addGlobalInjectInvokes() { MethodNode codeBefore = new MethodNode(); MethodNode codeAfter = new MethodNode(); this.fillMethodInvokes(codeBefore, codeAfter, this.classData); for (Entry<MethodNode, TransformerInitMethodData> initEntry : this.inits.entrySet()) { MethodNode init = initEntry.getKey(); TransformerInitMethodData initPair = initEntry.getValue(); MethodInsnNode superInvoke = initPair.superInvoke; if (codeAfter.instructions.size() > 0) { for (InsnNode node : initPair.returns) { init.instructions.insertBefore(node, codeAfter.instructions); }/*from w ww . j av a2 s. co m*/ } if (codeBefore.instructions.size() > 0) { init.instructions.insert(superInvoke, codeBefore.instructions); } } }
From source file:org.diorite.inject.controller.TransformerFieldInjector.java
License:Open Source License
private void injectField(TransformerFieldPair fieldPair, TransformerInjectTracker result) { ControllerFieldData<?> fieldData = fieldPair.data; assert fieldData != null; MethodInsnNode injectionInvokeNode = result.getResult(); FieldInsnNode putfieldNode = result.getFieldInsnNode(); // insert invoke methods: MethodNode codeBefore = new MethodNode(); MethodNode codeAfter = new MethodNode(); this.injectTransformer.fillMethodInvokes(codeBefore, codeAfter, fieldData); // node list for PUTFIELD InsnList initNodeList = result.getInitNodeList(); // node list for invoke execution InsnList resultNodeList = result.getResultNodeList(); if (codeBefore.instructions.size() != 0) { // invoke before should be added before PUTFIELD and before INVOKE resultNodeList.insertBefore(injectionInvokeNode, codeBefore.instructions); }/* w w w . j a v a 2 s . c om*/ if (codeAfter.instructions.size() != 0) { // invoke after should be added after PUTFIELD initNodeList.insert(putfieldNode, codeAfter.instructions); } // and replace placeholder node with real injections: { MethodNode tempNode = new MethodNode(); TransformerInvokerGenerator.generateFieldInjection(this.injectTransformer.classData, fieldData, tempNode, -1); resultNodeList.insertBefore(injectionInvokeNode, tempNode.instructions); resultNodeList.remove(injectionInvokeNode); } }