@Override public void generateMethodInitFcController( BlockSourceCodeVisitor mv ) { mv.visitln(" initIntentHandlersMap(METHODS);"); }
@Override public void generateMethodClone( BlockSourceCodeVisitor mv ) { mv.visitln(" clone.initIntentHandlersMap(METHODS);"); }
@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(); } }
@Override public void generateProxyMethodBodyAfterReturningCode( BlockSourceCodeVisitor mv, Method proxym ) { // End of the try block mv.visitln(" }"); mv.visitln(" finally {"); // Release the content instance mv.visit(" releaseContent(impl,"); if( proxym.getAnnotation(EndsConversation.class) == null ) { mv.visit("false"); } else { mv.visit("true"); } mv.visitln(");"); // End of the finally block mv.visitln(" }"); } }
@Override protected void generateNewFcContentMethod( BlockSourceCodeVisitor mv ) { String ctrlDesc = membraneDesc.getDescriptor(); String contentClassName = JuliacHelper.getContentClassName(ctrlDesc,contentDesc); if( contentClassName == null ) { mv.visitln(" return null;"); } else { mv.visitln(" try {"); mv.visit (" Object content = new "); mv.visit (contentClassName); mv.visitln("();"); mv.visitln(" return content;"); mv.visitln(" }"); mv.visitln(" catch( Throwable t ) {"); mv.visit (" throw new "); mv.visit (ChainedInstantiationException.class.getName()); mv.visitln("(t,null,\"\");"); mv.visitln(" }"); } }
mv.visitln(" }"); mv.visitln(" }"); mv.visitln(" catch( Throwable t ) {"); mv.visit (" if( t instanceof "); mv.visit (except.getName()); mv.visitln(" ) {"); mv.visit (" throw ("); mv.visit (except.getName()); mv.visitln(") t;"); mv.visitln(" }"); mv.visitln(" if( t instanceof RuntimeException ) {"); mv.visitln(" throw (RuntimeException) t;"); mv.visitln(" }"); mv.visitln("(t);"); mv.visitln(" }");
@Override protected void generateNewFcContentMethod( BlockSourceCodeVisitor mv ) { String ctrlDesc = membraneDesc.getDescriptor(); String contentClassName = JuliacHelper.getContentClassName(ctrlDesc,contentDesc); mv.visit(" Object content = "); if( contentClassName == null ) { mv.visitln("null;"); } else { mv.visit ("new "); mv.visit (contentClassName); mv.visitln("();"); } mv.visitln(" return content;"); }
@Override protected void generateGetFcContentDescMethod( BlockSourceCodeVisitor mv ) { mv.visit (" return "); mv.visit (JuliacHelper.javaifyContentDesc(contentDesc).toString()); mv.visitln(";"); }
@Override protected void generateGetFcContentDescMethod( BlockSourceCodeVisitor mv ) { mv.visit (" return "); mv.visit (JuliacHelper.javaifyContentDesc(contentDesc).toString()); mv.visitln(";"); }
@Override protected void generateGetFcContentDescMethod( BlockSourceCodeVisitor mv ) { mv.visit (" return "); mv.visit (JuliacHelper.javaifyContentDesc(contentDesc).toString()); mv.visitln(";"); }
@Override protected void generateGetFcControllerDescMethod( BlockSourceCodeVisitor mv ) { mv.visit (" return \""); mv.visit (membraneDesc.getDescriptor()); mv.visitln("\";"); }
@Override protected void generateGetFcControllerDescMethod( BlockSourceCodeVisitor mv ) { mv.visit (" return \""); mv.visit (membraneDesc.getDescriptor()); mv.visitln("\";"); }
@Override protected void generateGetFcControllerDescMethod( BlockSourceCodeVisitor mv ) { mv.visit (" return \""); mv.visit (membraneDesc.getDescriptor()); mv.visitln("\";"); }
protected void generateNFICMExternalInterface( BlockSourceCodeVisitor mv, InterfaceType it, boolean attrimplgenerated ) { String itname = it.getFcItfName(); if( it.isFcCollectionItf() ) { // Julia naming convention for collection interfaces itname = "/collection/" + itname; } // External interface SourceCodeGeneratorItf itfscg = fcscg.getInterfaceClassGenerator(it); String fcitfClassname = itfscg.getTargetTypeName(); String itstring = InterfaceTypeHelper.javaify(it).toString(); mv.visit(" proxy = "); mv.visit("new "+fcitfClassname+"("); mv.visit("proxyForCompCtrl,\""+itname+"\","+itstring+",false,"); if( itname.equals("attribute-controller") && attrimplgenerated ) { mv.visit("attrimpl"); } else { mv.visit("intercept"); // interceptor or content or null } mv.visitln(");"); mv.visitln(" ic.interfaces.put(\""+itname+"\",proxy);"); }
@Override public void generateProxyMethodBodyBeforeCode( BlockSourceCodeVisitor mv, Method proxym ) { /* * Regiqter the request context and get the content instance which * corresponds to the current scope policy. */ mv.visit (" "); mv.visit (it.getFcItfSignature()); String[] tpnames = ClassHelper.getTypeParameterNames(proxycl); if( tpnames.length != 0 ) { String s = ClassHelper.getTypeParameterNamesSignature(tpnames); mv.visit(s); } mv.visit (" impl = setRequestContextAndGet(\""); mv.visit (it.getFcItfName()); mv.visitln("\","+it.getFcItfSignature()+".class,this);"); // TODO the request context created by setRequestContextAndGet should be given a client proxy (not this which is a server one) // Begin of the try block mv.visitln(" try {"); }
@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(); }