protected boolean isPrimary() {
return config.getContext().getLocalContainerID().equals(config.getHomeContainerID());
}
protected void activated() {
ISharedObjectContext ctx = config.getContext();
if (isPrimary()) {
try {
ctx.sendCreate(containerID, createReplicaDescription());
} catch (IOException e) {
callback.requestFailed(e);
ctx.getSharedObjectManager().removeSharedObject(config.getSharedObjectID());
}
return;
}
ISharedObjectManager mgr = ctx.getSharedObjectManager();
ISharedObject so = mgr.getSharedObject(sharedObjectID);
try {
ID homeContainerID = config.getHomeContainerID();
if (so instanceof IPublishedService) {
IPublishedService svc = (IPublishedService) so;
svc.subscribe(homeContainerID, config.getSharedObjectID());
} else {
ctx.sendCreateResponse(homeContainerID, new IllegalArgumentException("Not an IPublishedService."), -1);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
ctx.getSharedObjectManager().removeSharedObject(config.getSharedObjectID());
}
}