protected void generateNewFcControllerInstantiationMethod( ClassSourceCodeVisitor cv ) { BlockSourceCodeVisitor mv = cv.visitMethod( Modifier.PUBLIC, null, Component.class.getName(), "newFcControllerInstantiation", new String[]{InitializationContext.class.getName()+" ic"}, new String[]{InstantiationException.class.getName()} ); generateNewFcControllerInstantiationMethod(mv); mv.visitEnd(); }
@Override public void generateConstructors( ClassSourceCodeVisitor cv ) { super.generateConstructors(cv); // public constructor() BlockSourceCodeVisitor mv = cv.visitConstructor(Modifier.PUBLIC,null,null,null); mv.visitEnd(); // public constructor(Component,String,Type,boolean,Object) String[] parameters = new String[]{ Component.class.getName()+" component", "String s", Type.class.getName()+" type", "boolean flag", "Object obj" }; mv = cv.visitConstructor(Modifier.PUBLIC,null,parameters,null); mv.visitIns("super(component,s,type,flag,obj);"); mv.visitEnd(); }
String type = "java.lang.reflect.Method[]"; String name = "METHODS"; cv.visitField( modifiers, type, name, null );
BlockSourceCodeVisitor bv = cv.visitStaticPart(); if( proxymethods.length > 0 ) { bv.visitln(" try {");
protected void generateNewFcInitializationContextMethod( ClassSourceCodeVisitor cv ) { BlockSourceCodeVisitor mv = cv.visitMethod( Modifier.PUBLIC, null, InitializationContext.class.getName(), "newFcInitializationContext", new String[]{"Object content"}, new String[]{InstantiationException.class.getName()} ); generateNewFcInitializationContextMethod(mv); mv.visitEnd(); }
@Override public void generateConstructors( ClassSourceCodeVisitor cv ) { super.generateConstructors(cv); /* * Create the signature of the proxy interface with generic parameters * if any. */ String signature = it.getFcItfSignature(); String[] tpnames = ClassHelper.getTypeParameterNames(proxycl); if( tpnames.length != 0 ) { String s = ClassHelper.getTypeParameterNamesSignature(tpnames); signature += s; } // public constructor(Class<B>,B) String[] parameters = new String[]{ "Class<"+signature+"> businessInterface", signature+" service" }; BlockSourceCodeVisitor mv = cv.visitConstructor(Modifier.PUBLIC,null,parameters,null); mv.visitIns("super(businessInterface,service)"); mv.visitEnd(); }
@Override protected void generateExtraCode( ClassSourceCodeVisitor cv ) { BlockSourceCodeVisitor mv = cv.visitMethod( Modifier.PRIVATE, null, "Object", "getFcInterface", new String[]{Component.class.getName()+" c","String name"}, new String[]{InstantiationException.class.getName()} ); mv.visitln(" try {"); mv.visitln(" return c.getFcInterface(name);"); mv.visitln(" }"); mv.visitln(" catch( "+NoSuchInterfaceException.class.getName()+" nsie ) {"); mv.visit (" throw new "+ChainedInstantiationException.class.getName()); mv.visitln("(nsie,null,\"No such interface: \"+nsie.getMessage());"); mv.visitln(" }"); mv.visitEnd(); } }
/** * @since 1.4.1 */ @Override public void generateMethods( ClassSourceCodeVisitor cv ) { super.generateMethods(cv); /* * Override the getService method inherited from ServiceReferenceImpl. * The idea is that in generated subclasses of ServiceReferenceImpl we * can directly return "this" for getService. Whereas when getService is * invoked on an instance of ServiceReferenceImpl, getService should * return an instance which implements both the ServiceReference * interface and the business interface. This is the case of generated * subclass instances. */ String signature = it.getFcItfSignature(); BlockSourceCodeVisitor mv = cv.visitMethod( Modifier.PUBLIC, null, signature, "getService", null, null ); mv.visitIns("return this"); mv.visitEnd(); }
@Override public void generateMethods( ClassSourceCodeVisitor cv ) { super.generateMethods(cv); BlockSourceCodeVisitor mv = cv.visitMethod( Modifier.PUBLIC, null, ServiceReference.class.getName()+'<'+it.getFcItfSignature()+'>', "getServiceReference", null, null ); SourceCodeGeneratorItf cg = new ServiceReferenceClassGenerator( it,this.proxycl,pkgRoot,membraneDesc,mergeable); String srclname = cg.getTargetTypeName(); mv.visit (" return new "); mv.visit (srclname); mv.visit ("("); mv.visit (it.getFcItfSignature()); mv.visitln(".class,this);"); mv.visitEnd(); }