The Connection Service is the framework-specific mechanism by which instantiated components establish communication links with one another via their typed ports. Only those ports which have the same PortInfo description will be able to participate in a connection. A component can use the Connection Service to connect its own ports to another component. It can also connect two other components for which it has ComponentIDs. The Connection Service can also be used to "export" ports of components for which a ComponentID is known, that is, component A can provide Provides Ports of component B as if they belonged to A - to other components the Provides Port will appear to belong to A, not to B. Finally, if a component does not with to provide one of its ports to the entire world, it can provide it to other components specifically on a "need to know" basis.
By providing an external mechanism for connecting ports, the port types and descriptions themselves can remain free of any connection semantics. As ports are passive participants in the act of connection, we must expose some of their internal structure to the Connection Service, hence the use of ComponentIDs throughout. The relationship of ports to the CCAServices object is what allows us to make this Port-Independent Connection Service available.
Back to top
value CCAConnectionService : CCAPort {
void connect(in ComponentID idUser, in String usesportname,
in ComponentID idProv, in String provportname)
raises (ConnectionException);
void disconnect(in ComponentID idUser, in String usesportname,
in ComponentID idProv, in String provportname,
in double timeout)
raises (DisonnectionException);
void exportAs(in ComponentID idSub, in String portname,
in String myPortname);
raises (ExportAsException);
void provideTo(in ComponentID idSub, in String usesPortname,
in Port port);
raises (ProvideToException);
}
class CCAConnectionService : CCAPort {
public:
virtual void connect(const ComponentID *idUser, char *usesportname,
const ComponentID *idProv, char *provportname)
throw (ConnectionException) = 0;
virtual void disconnect(const ComponentID *idUser, char *usesportname,
const ComponentID *idProv, char *provportname,
const double timeout)
throw (DisconnectionException) = 0;
virtual void exportAs(const ComponentID *idSub, char *portname, char *newportname)
throw (ExportAsException) = 0;
virtual void provideTo(const ComponentID *idSub, char *usesportname, CCAPort port)
throw (ProvideToException) = 0;
}
interface CCAConnectionService extends CCAPort {
public:
public void connect(ComponentID idUser, String usesportname,
ComponentID idProv, String provportname)
throws ConnectionException;
public void disconnect(ComponentID idUser, String usesportname,
ComponentID idProv, String provportname,
double timeout)
throws DisconnectionException;
public void exportAs(ComponentID idSub, String portname, String newportname)
throws ExportAsException;
public void provideTo(ComponentID idSub, String usesportname, CCAPort port)
throws ProvideToException;
}
void connect(in ComponentID idUser, in String usesPortname,
in ComponentID idProv, in String provPortname)
raises ConnectionException; [1]
void disconnect(in ComponentID idUser, in String usesportname,
in ComponentID idProv, in String provportname,
in double timeout);
raises DisconnectionException; [2]
void exportAs(in ComponentID idSub, in String portname, in String myPortname);
raises ExportAsException; [3]
void provideTo(in ComponentID idSub, in String usesPortname, in Port providesPort);
raises ProvidesToException; [4]
This is the baseline example of the connection service. A Component will instantiate two other Components and connect them via their ports. After waiting for 30 seconds, the main component will then give the "using" component 5 seconds to disconnect.
// Inside the "main" Component
CCAServices myS;
CCACreationService myCreate;
CCAConnectionService myConnect;
Env creationEnv = new Env();
creationEnv.put("userData","ninetynineluftballoons"); // There's more to this, of course!
// get a creation service
myCreate=myS.getPort("CCACreationService");
// create the first component
ComponentID cid1 = myCreate.createInstance(component1URL,creationEnv);
creationEnv.put("userData","seventysixtrombones"); // There's more to this, of course!
// create the second component
ComponentID cid2 = myCreate.createInstance(component2URL,creationEnv);
//get a connection service
myConnect = CCAServices.getPort("CCAConnectionService");
// now connect
myConnect.connect(cid1, "someUsesPort", cid2, "someProvidesPort");
// At this point Component 1 can use Component 2!!
// let them go at it for 30 seconds
sleep(30);
// Now disconnect them, giving them a 5 second grace period.
myConnect.disconnect(cid1, "someUsesPort", cid2, "someProvidesPort", 5.00);
// If after 5 seconds they haven't disconnected then they get disconnected
// rudely. At this point we know the disconnect was finished and can continue
// along.
[1]
[2] There has been much discussion as to whether disconnect() is "polite" or not. That is, does disconnect() mean to immediately disconnect regardless of any activity on that connection, or does it mean that only once the component Using the connection is through should the disconnect occur? The second case is easier to implement, as it means there will be no nasty cleanups to take care of. However, both are going to be needed, since a user might want to simply kill a connection that's causing a resource drain. For the purposes of SC99 we will be implementing a "rude" disconnect, as we don't have time to wait for things to finish before we scurry away to debugging. Disconnects are also non-blocking, so that the Component attempting the disconnect can get on with what needs to be done.
[3] There is no limitation on which Ports a component can Export, provided it has a valid ComponentID. This means that if Component A passes its ComponentID to Component B, then B can export all of the Ports of Component A as if they were its own. There currently is no way to prevent this from happening. The only way to keep your Ports from being exportable via your ComponentID is by not registering them.
[4] If you don't register your ports so that they cannot be exported, then you can still provide them to other Components via the provideTo function. This is the only real security measure we are taking at this time for Ports. Our motto is, if you register it, be ready to share it. It is now, anyway.
Last modified: Tue Sep 28 00:11:22 EST 1999