KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > InOut > Connector > InOut2ClientCRole


1 /**
2  * InOut2ClientCRole.java is a part of the SOFA project.
3  * This file was created by pepan on 16.4.2003.
4  */

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 /**
16  * @author Petr Panuska
17  */

18 public class InOut2ClientCRole extends RoleBaseImpl implements InOut2Client {
19   private CNInOut2Client target;
20
21   public void link (Object JavaDoc 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 JavaDoc e) {
40       throw new LinkException("Can't link InOut2ClientCRole. ", e);
41     }
42   }
43
44 /*
45   public void obtainComponent (String fullName, String sofanode) throws InOutException {
46     target.obtainComponent(fullName, sofanode);
47   }
48
49   public void distributeComponent (String fullName, String[] sofanodes) throws InOutException {
50     target.distributeComponent(fullName, sofanodes);
51   }
52 */

53
54   public void obtain (String JavaDoc[] offers, String JavaDoc[] components, String JavaDoc sofaNode) throws InOutException {
55     target.obtain(offers, components, sofaNode);
56   }
57
58   public void distribute (String JavaDoc[] offers, String JavaDoc[] components, String JavaDoc[] sofaNodes) throws InOutException {
59     target.distribute(offers, components, sofaNodes);
60   }
61
62   public void obtainOffers (String JavaDoc[] offers, String JavaDoc sofaNode) throws InOutException {
63     target.obtainOffers(offers, sofaNode);
64   }
65
66   public void distributeOffers (String JavaDoc[] offers, String JavaDoc[] sofaNodes) throws InOutException {
67     target.distributeOffers(offers, sofaNodes);
68   }
69
70   public void obtainComponents (String JavaDoc[] components, String JavaDoc sofaNode) throws InOutException {
71     target.obtainComponents(components, sofaNode);
72   }
73
74   public void distributeComponents (String JavaDoc[] components, String JavaDoc[] 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