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(); }
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 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(); }