1 5 package SOFA.SOFAnode.InOut.Connector; 6 7 import SOFA.Connector.LinkException; 8 import SOFA.Connector.Reference; 9 import SOFA.Connector.RoleBaseImpl; 10 import SOFA.Connector.TaggedProfile; 11 import SOFA.SOFAnode.InOut.Bundle; 12 import SOFA.SOFAnode.InOut.InOut2Client; 13 import SOFA.SOFAnode.InOut.InOutException; 14 15 18 public class InOut2ClientCRole extends RoleBaseImpl implements InOut2Client { 19 private CNInOut2Client target; 20 21 public void link (Object target) throws LinkException { 22 try { 23 if (target instanceof Reference) { 24 Reference ref = (Reference) target; 25 setSOFAReference(ref); 26 TaggedProfile[] profiles = ref.profiles; 27 for (int i = 0; i < profiles.length; i++) { 28 if (profiles[i].tag.equals("LOCAL")) { 29 this.target = (CNInOut2Client) ((SOFA.Connector.ECG.Profiles.LocalProfile) profiles[i]).link; 30 return; 31 } else if (profiles[i].tag.equals("RMI")) { 32 this.target = new InOut2ClientRMIStub(((SOFA.Connector.ECG.Profiles.RMIProfile) profiles[i]).URL); 33 return; 34 } 35 } 36 } else { 37 this.target = (CNInOut2Client) target; 38 } 39 } catch (Exception e) { 40 throw new LinkException("Can't link InOut2ClientCRole. ", e); 41 } 42 } 43 44 53 54 public void obtain (String [] offers, String [] components, String sofaNode) throws InOutException { 55 target.obtain(offers, components, sofaNode); 56 } 57 58 public void distribute (String [] offers, String [] components, String [] sofaNodes) throws InOutException { 59 target.distribute(offers, components, sofaNodes); 60 } 61 62 public void obtainOffers (String [] offers, String sofaNode) throws InOutException { 63 target.obtainOffers(offers, sofaNode); 64 } 65 66 public void distributeOffers (String [] offers, String [] sofaNodes) throws InOutException { 67 target.distributeOffers(offers, sofaNodes); 68 } 69 70 public void obtainComponents (String [] components, String sofaNode) throws InOutException { 71 target.obtainComponents(components, sofaNode); 72 } 73 74 public void distributeComponents (String [] components, String [] sofaNodes) throws InOutException { 75 target.distributeComponents(components, sofaNodes); 76 } 77 78 public Bundle list () throws InOutException { 79 return target.list(); 80 } 81 } 82 | Popular Tags |