1 6 7 package SOFA.Connector.EEG.EEM.Elements; 8 9 import SOFA.Connector.EEG.CodeWriter.CDL2JavaMapping; 10 import SOFA.Connector.EEG.CodeWriter.CodeWriterException; 11 import SOFA.Connector.EEG.CodeWriter.JWriterDirectorException; 12 import SOFA.Connector.EEG.EEM.Actions.JIfaceCN; 13 import SOFA.Connector.EEG.EEM.Actions.JIfaceCNCORBA; 14 import SOFA.Connector.EEG.EEM.Actions.JImplWriterDirectorBase; 15 import SOFA.SOFAnode.Made.TIR.OperationDef; 16 import SOFA.SOFAnode.Made.TIR.ParamDescr; 17 import SOFA.SOFAnode.Made.TIR.ParamMode; 18 import SOFA.SOFAnode.Made.TIR.TIRExceptLock; 19 20 25 public class CORBASkeletonGen extends JImplWriterDirectorBase { 26 27 28 public CORBASkeletonGen(String provIfaceCDL, SOFA.Connector.Property[] params) { 29 super(provIfaceCDL,params); 30 } 31 32 public String getExtends() { 33 String corbaIface=SOFA.Connector.Property.findFirst(params,"provIfaceMapped"); 34 return corbaIface+"POA"; 35 } 36 37 public String [] getImplements() { 38 return new String [] {"SOFA.Connector.EEG.Types.Skeleton"}; 39 } 40 41 public boolean defaultImplements() { 42 return false; 43 } 44 45 public String getClassBody() { 46 return managerTieImpl() + "\n" + linkImpl() + "\n" + 47 "\tprotected String corbaIOR;\n"+ 48 "\tprotected org.omg.CORBA.Object corbaObject;\n\n"+ 49 "\tpublic CORBASkeleton() throws SOFA.Connector.ConnectorException {\n"+ 50 "\t\tsuper();\n"+ 51 "\t\ttry {\n"+ 52 "\t\t\tcorbaObject=SOFA.Util.CORBAAccess.activate_object(this);\n"+ 53 "\t\t\tcorbaIOR=SOFA.Util.CORBAAccess.object_to_string(corbaObject);\n"+ 54 "\t\t} catch (Exception e) {\n"+ 55 "\t\t\tthrow new SOFA.Connector.ConnectorException(\"Can't bind CORBASkeleton to '\"+corbaIOR+\"'.\",e);\n"+ 56 "\t\t}\n"+ 57 "\t}\n\n"+ 58 "\tpublic SOFA.Connector.TaggedProfile[] getProfiles() {\n"+ 59 "\t\treturn new SOFA.Connector.TaggedProfile[] { new SOFA.Connector.ECG.Profiles.CORBAProfile(corbaIOR) };\n"+ 60 "\t}\n"; 61 } 62 63 public String getMethodDef(OperationDef mt) throws JWriterDirectorException { 64 return JIfaceCNCORBA.getMethodDef(mt); 65 } 66 67 public String getMethodBody(OperationDef method) throws JWriterDirectorException { 68 try { 69 String ret=""; 70 71 int i; 72 ParamDescr[] params=method.params(); 73 74 for (i=0;i<params.length;i++) { 75 int mode=params[i].mode().value(); 76 if (mode==ParamMode.PARAM_INOUT || mode==ParamMode.PARAM_OUT) { 77 String holderName=CDL2JavaMapping.getTypeName(params[i].type(),mode); 78 ret+="\t\t"+holderName+" "+params[i].name()+"=new "+holderName+"(); "+params[i].name()+".value=_corbaholder_"+params[i].name()+".value;\n"; 79 } 80 } 81 82 ret+="\t\t"+declareRet(method,"ret")+"\n"+ 83 "\t\t"+assignRet(method,"ret")+targetCall(method,JIfaceCN.targetCallParams(method))+";\n"; 84 85 for (i=0;i<params.length;i++) { 86 int mode=params[i].mode().value(); 87 if (mode==ParamMode.PARAM_INOUT || mode==ParamMode.PARAM_OUT) { 88 ret+="\t\t_corbaholder_"+params[i].name()+".value="+params[i].name()+".value;\n"; 89 } 90 } 91 92 ret+="\t\t"+returnRet(method,"ret")+"\n"; 93 94 return ret; 95 96 } catch (java.rmi.RemoteException e) { 97 throw new JWriterDirectorException("Cannot access TIR.",e); 98 } catch (TIRExceptLock e) { 99 throw new JWriterDirectorException("Cannot access TIR.",e); 100 } catch (CodeWriterException e) { 101 throw new JWriterDirectorException("Cannot map operation to Java.",e); 102 } 103 } 104 } 105 | Popular Tags |