1 6 7 package SOFA.Connector.EEG.EEM.Elements; 8 9 import SOFA.Connector.EEG.CodeWriter.JWriterDirectorException; 10 import SOFA.Connector.EEG.EEM.Actions.JIfaceCN; 11 import SOFA.Connector.EEG.EEM.Actions.JIfaceCNRMI; 12 import SOFA.Connector.EEG.EEM.Actions.JImplWriterDirectorBase; 13 import SOFA.SOFAnode.Made.TIR.OperationDef; 14 15 20 public class RMIStubGen extends JImplWriterDirectorBase { 21 22 23 public RMIStubGen(String provIfaceCDL, SOFA.Connector.Property[] params) { 24 super(provIfaceCDL,params); 25 } 26 27 public String [] getImplements() { 28 return new String [] {"SOFA.Connector.EEG.Types.Stub"}; 29 } 30 31 public String getClassBody() { 32 String reqIfaceMapped=SOFA.Connector.Property.findFirst(params,"reqIfaceMapped"); 33 return managerTieImpl() + "\n" + 34 "\tprotected "+reqIfaceMapped+" target;\n\n"+ 35 "\tpublic void link(SOFA.Connector.TaggedProfile target) throws SOFA.Connector.LinkException {\n"+ 36 "\t\ttry {\n"+ 37 "\t\t\tthis.target=("+reqIfaceMapped+")java.rmi.Naming.lookup(((SOFA.Connector.ECG.Profiles.RMIProfile)target).URL);\n"+ 38 "\t\t} catch (Exception e) {\n"+ 39 "\t\t\tthrow new SOFA.Connector.LinkException(\"Can't link to '\"+((SOFA.Connector.ECG.Profiles.RMIProfile)target).URL+\"'.\",e);\n"+ 40 "\t\t}\n"+ 41 "\t}\n\n"+ 42 "\tpublic String[] getSupportedProfiles() {\n"+ 43 "\t\treturn new String[] {\"RMI\"};\n"+ 44 "\t}\n\n"+ 45 "\tpublic org.objectweb.fractal.api.Type getFcItfType() { return null; }\n"+ 46 "\tpublic boolean isFcInternalItf() { return false; }\n"+ 47 "\tpublic String getFcItfName() { try { return this.target.getFcItfName(); } catch (java.rmi.RemoteException e) { throw new SOFA.Connector.ConnectorTransportException(\"Can't call method '::SOFA::demos::logdemo::LogInterface ::log'.\",e); }}\n\n"+ 48 "\tpublic org.objectweb.fractal.api.Component getFcItfOwner() {\n"+ 49 "\t\ttry {\n"+ 50 "\t\t\tbyte [] s = this.target.getFcItfOwner();\n"+ 51 "\t\t\tSOFA.Connector.Reference ref = new SOFA.Connector.Reference ();\n"+ 52 "\t\t\tref._read(new cz.cuni.sofa.lib.Impl.ByteArrayInputStream(s));\n"+ 53 "\t\t\treturn (org.objectweb.fractal.api.Component) SOFA.Connector.Boot.DCUPComponentManagerConnector.createClt(ref);\n"+ 54 "\t\t} catch (java.rmi.RemoteException e) {\n"+ 55 "\t\t\tthrow new SOFA.Connector.ConnectorTransportException(\"Remote exception in the \\\"getFcItfOwner\\\".\", e);\n"+ 56 "\t\t} catch (java.io.IOException e) {\n"+ 57 "\t\t\tthrow new SOFA.Connector.ConnectorTransportException(\"IOException in the \\\"getFcItfOwner\\\".\", e);\n"+ 58 "\t\t} catch (SOFA.Connector.ConnectorException e) {\n"+ 59 "\t\t\tthrow new SOFA.Connector.ConnectorTransportException(\"ConnectorException in the \\\"getFcItfOwner\\\".\", e);\n"+ 60 "\t\t}\n"+ 61 "\t}\n\n"; 62 } 63 64 public String getMethodDef(OperationDef mt) throws JWriterDirectorException { 65 return JIfaceCN.getMethodDef(mt); 66 } 67 68 public String getMethodBody(OperationDef method) throws JWriterDirectorException { 69 try { 70 return 71 "\t\ttry {\n"+ 72 "\t\t\t"+declareRet(method,"ret")+"\n"+ 73 "\t\t\t"+assignRet(method,"ret")+targetCall(method,JIfaceCNRMI.targetCallParams(method))+";\n"+ 74 "\t\t\t"+returnRet(method,"ret")+"\n"+ 75 "\t\t} catch (java.rmi.RemoteException e) {\n"+ 76 "\t\t\tthrow new SOFA.Connector.ConnectorTransportException(\"Can't call method '"+method.get_identification().absolute_name().name()+"'.\",e);\n"+ 77 "\t\t}\n"; 78 } catch (java.rmi.RemoteException e) { 79 throw new JWriterDirectorException("Cannot access TIR.",e); 80 } 81 } 82 } 83 | Popular Tags |