use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.
the class TestSharedObject method initialize.
/* (non-Javadoc)
* @see org.eclipse.ecf.core.sharedobject.BaseSharedObject#initialize()
*/
protected void initialize() throws SharedObjectInitException {
super.initialize();
if (isPrimary()) {
// If primary, then add an event processor that handles activated
// event by replicating to all current remote containers
addEventProcessor(new IEventProcessor() {
public boolean processEvent(Event event) {
if (event instanceof ISharedObjectActivatedEvent) {
ISharedObjectActivatedEvent ae = (ISharedObjectActivatedEvent) event;
if (ae.getActivatedID().equals(getID()) && isConnected()) {
TestSharedObject.this.replicateToRemoteContainers(null);
}
}
return false;
}
});
System.out.println("Primary(" + getContext().getLocalContainerID() + ") says Hello " + name);
} else {
// This is a replica, so initialize the name from property
name = (String) getConfig().getProperties().get(NAME_PROPERTY);
System.out.println("Replica(" + getContext().getLocalContainerID() + ") says Hello " + name);
}
}
use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.
the class FeedSharedObject method handleEvent.
/*
* (non-Javadoc)
*
* @see org.eclipse.ecf.core.util.IEventHandler#handleEvent(org.eclipse.ecf.core.util.Event)
*/
public void handleEvent(Event event) {
trace("handleEvent(" + event + ")");
if (event instanceof ISharedObjectMessageEvent) {
ISharedObjectMessageEvent e = (ISharedObjectMessageEvent) event;
handleMessage(e);
} else if (event instanceof IContainerConnectedEvent) {
IContainerConnectedEvent e = (IContainerConnectedEvent) event;
if (e.getTargetID().equals(config.getContext().getLocalContainerID())) {
// this container joined
// handleJoined();
} else if (config.getContext().isGroupManager()) {
// some other container joined and we're the server
handleJoined(e.getTargetID());
}
} else if (event instanceof IContainerDisconnectedEvent) {
IContainerDisconnectedEvent e = (IContainerDisconnectedEvent) event;
// some other container departed -- same as peer deactivation
if (!e.getTargetID().equals(config.getContext().getLocalContainerID())) {
handleLeave(e.getTargetID());
}
} else if (event instanceof ISharedObjectActivatedEvent) {
/*
* ISharedObjectActivatedEvent
* e =
* (ISharedObjectActivatedEvent)
* event;
* if(e.getActivatedID().equals(config.getSharedObjectID())) { //
* we're
* being
* activated
* handleActivated(); }
*/
} else if (event instanceof ISharedObjectDeactivatedEvent) {
/*
* ISharedObjectDeactivatedEvent
* e =
* (ISharedObjectDeactivatedEvent)
* event;
* if(e.getDeactivatedID().equals(config.getSharedObjectID())) { //
* we're
* being
* deactivated
* handleDeactivated(); }
* else
* if(table.contains(e.getDeactivatedID())) { //
* a local
* graph we
* track is
* being
* deactivated
* handleRemoved(e.getDeactivatedID()); }
*/
}
}
use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.
the class OptimisticSharedObject method initialize.
protected void initialize() throws SharedObjectInitException {
super.initialize();
Trace.entering(Activator.PLUGIN_ID, SharedObjectDebugOptions.METHODS_ENTERING, OptimisticSharedObject.class, // $NON-NLS-1$
"initialize");
addEventProcessor(new IEventProcessor() {
public boolean processEvent(Event event) {
if (event instanceof ISharedObjectActivatedEvent) {
// then replicate to all remotes
if (isPrimary() && isConnected()) {
OptimisticSharedObject.this.replicateToRemoteContainers(null);
}
} else if (event instanceof IContainerConnectedEvent) {
// then replicate to the newly arrived container
if (isPrimary()) {
ID targetID = ((IContainerConnectedEvent) event).getTargetID();
OptimisticSharedObject.this.replicateToRemoteContainers(new ID[] { targetID });
}
}
return false;
}
});
Trace.exiting(Activator.PLUGIN_ID, SharedObjectDebugOptions.METHODS_EXITING, OptimisticSharedObject.class, // $NON-NLS-1$
"initialize");
}
use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.
the class TestMessagingSharedObject method initialize.
/* (non-Javadoc)
* @see org.eclipse.ecf.core.sharedobject.BaseSharedObject#initialize()
*/
protected void initialize() throws SharedObjectInitException {
super.initialize();
if (isPrimary()) {
// If primary, then add an event processor that handles activated
// event by replicating to all current remote containers
addEventProcessor(new IEventProcessor() {
public boolean processEvent(Event event) {
if (event instanceof ISharedObjectActivatedEvent) {
ISharedObjectActivatedEvent ae = (ISharedObjectActivatedEvent) event;
if (ae.getActivatedID().equals(getID()) && isConnected()) {
TestMessagingSharedObject.this.replicateToRemoteContainers(null);
}
}
return false;
}
});
System.out.println("Primary(" + getContext().getLocalContainerID() + ") says Hello " + name);
} else {
// This is a replica, so initialize the name from property
name = (String) getConfig().getProperties().get(NAME_PROPERTY);
System.out.println("Replica(" + getContext().getLocalContainerID() + ") says Hello " + name);
}
}
Aggregations