Search in sources :

Example 1 with ISharedObjectActivatedEvent

use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.

the class SharedObjectDatashareContainerAdapter method initialize.

protected void initialize() throws SharedObjectInitException {
    super.initialize();
    addEventProcessor(new IEventProcessor() {

        public boolean processEvent(Event event) {
            if (event instanceof ISharedObjectActivatedEvent) {
                final ISharedObjectActivatedEvent soae = (ISharedObjectActivatedEvent) event;
                if (!soae.getActivatedID().equals(getID()))
                    fireChannelContainerListeners(new IChannelContainerChannelActivatedEvent() {

                        public ID getChannelID() {
                            return soae.getActivatedID();
                        }

                        public ID getChannelContainerID() {
                            return soae.getLocalContainerID();
                        }

                        public String toString() {
                            // $NON-NLS-1$
                            StringBuffer buf = new StringBuffer("ChannelActivatedEvent[");
                            // $NON-NLS-1$ //$NON-NLS-2$
                            buf.append("channelid=").append(soae.getActivatedID()).append(";");
                            // $NON-NLS-1$ //$NON-NLS-2$
                            buf.append("containerid=").append(soae.getLocalContainerID()).append("]");
                            return buf.toString();
                        }
                    });
            } else if (event instanceof ISharedObjectDeactivatedEvent) {
                final ISharedObjectDeactivatedEvent sode = (ISharedObjectDeactivatedEvent) event;
                if (!sode.getDeactivatedID().equals(getID()))
                    fireChannelContainerListeners(new IChannelContainerChannelDeactivatedEvent() {

                        public ID getChannelID() {
                            return sode.getDeactivatedID();
                        }

                        public ID getChannelContainerID() {
                            return sode.getLocalContainerID();
                        }

                        public String toString() {
                            // $NON-NLS-1$
                            StringBuffer buf = new StringBuffer("ChannelDeactivatedEvent[");
                            // $NON-NLS-1$ //$NON-NLS-2$
                            buf.append("channelid=").append(sode.getDeactivatedID()).append(";");
                            // $NON-NLS-1$ //$NON-NLS-2$
                            buf.append("containerid=").append(sode.getLocalContainerID()).append("]");
                            return buf.toString();
                        }
                    });
            }
            return false;
        }
    });
}
Also used : ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) ISharedObjectDeactivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectDeactivatedEvent) ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) ISharedObjectDeactivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectDeactivatedEvent)

Example 2 with ISharedObjectActivatedEvent

use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.

the class GenericSharedObject method handleEvent.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.core.ISharedObject#handleEvent(org.eclipse.ecf.core.util.Event)
	 */
public void handleEvent(Event event) {
    if (event instanceof ISharedObjectActivatedEvent) {
        ISharedObjectActivatedEvent ae = (ISharedObjectActivatedEvent) event;
        ID myID = getID();
        if (myID == null)
            return;
        if (myID.equals(ae.getActivatedID())) {
            activated(getContext().getSharedObjectManager().getSharedObjectIDs());
        } else {
            otherActivated(ae.getActivatedID());
        }
    } else if (event instanceof ISharedObjectDeactivatedEvent) {
        ISharedObjectDeactivatedEvent ae = (ISharedObjectDeactivatedEvent) event;
        ID myID = getID();
        if (myID == null)
            return;
        if (myID.equals(ae.getDeactivatedID())) {
            deactivated();
        } else {
            otherDeactivated(ae.getDeactivatedID());
        }
    } else if (event instanceof IContainerConnectedEvent) {
        memberAdded(((IContainerConnectedEvent) event).getTargetID());
    } else if (event instanceof IContainerDisconnectedEvent) {
        memberRemoved(((IContainerDisconnectedEvent) event).getTargetID());
    } else if (event instanceof ISharedObjectMessageEvent) {
        handleSharedObjectMessageEvent(((ISharedObjectMessageEvent) event));
    }
}
Also used : ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) ISharedObjectDeactivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectDeactivatedEvent) IContainerDisconnectedEvent(org.eclipse.ecf.core.events.IContainerDisconnectedEvent) ISharedObjectMessageEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent) ID(org.eclipse.ecf.core.identity.ID) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent)

Example 3 with ISharedObjectActivatedEvent

use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.

the class SharedModelFactory method createSharedDataSource.

public IMasterModel createSharedDataSource(ISharedObjectContainer container, final ID id, Object data, String updaterID) throws SharedObjectCreateException {
    final ISharedObjectManager mgr = container.getSharedObjectManager();
    final Object[] result = new Object[1];
    final Object monitor = new Object();
    IContainerListener listener = new IContainerListener() {

        public void handleEvent(IContainerEvent event) {
            if (event instanceof ISharedObjectActivatedEvent) {
                ISharedObjectActivatedEvent e = (ISharedObjectActivatedEvent) event;
                if (e.getActivatedID().equals(id)) {
                    result[0] = mgr.getSharedObject(id);
                    synchronized (monitor) {
                        monitor.notify();
                    }
                }
            }
        }
    };
    try {
        container.addListener(listener);
        /*			SharedObjectDescription desc = createLocalAgentDescription(id, container.getID(), data, updaterID);
			synchronized (monitor) {
				mgr.createSharedObject(desc);
				if (result[0] == null)
					monitor.wait(getCreationTimeout());
			}
*/
        synchronized (monitor) {
            addSharedObject(mgr, id, data, updaterID);
            if (result[0] == null)
                monitor.wait(getCreationTimeout());
        }
    } catch (InterruptedException e) {
        throw new SharedObjectCreateException(e);
    } finally {
        container.removeListener(listener);
    }
    return (IMasterModel) result[0];
}
Also used : ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) SharedObjectCreateException(org.eclipse.ecf.core.sharedobject.SharedObjectCreateException) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) IContainerListener(org.eclipse.ecf.core.IContainerListener)

Example 4 with ISharedObjectActivatedEvent

use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.

the class AgentBase method handleEvent.

public void handleEvent(Event event) {
    if (event instanceof ISharedObjectActivatedEvent) {
        ISharedObjectActivatedEvent e = (ISharedObjectActivatedEvent) event;
        if (e.getActivatedID().equals(config.getSharedObjectID()))
            activated();
        else
            activated(e.getActivatedID());
    } else if (event instanceof ISharedObjectDeactivatedEvent) {
        ISharedObjectDeactivatedEvent e = (ISharedObjectDeactivatedEvent) event;
        if (e.getDeactivatedID().equals(config.getSharedObjectID()))
            deactivated();
        else
            deactivated(e.getDeactivatedID());
    } else if (event instanceof IContainerConnectedEvent) {
        IContainerConnectedEvent e = (IContainerConnectedEvent) event;
        if (e.getTargetID().equals(e.getLocalContainerID()))
            connected();
        else
            connected(e.getTargetID());
    } else if (event instanceof IContainerDisconnectedEvent) {
        IContainerDisconnectedEvent e = (IContainerDisconnectedEvent) event;
        if (e.getTargetID().equals(e.getLocalContainerID()))
            disconnected();
        else
            disconnected(e.getTargetID());
    } else if (event instanceof ISharedObjectMessageEvent) {
        ISharedObjectMessageEvent e = (ISharedObjectMessageEvent) event;
        received(e.getRemoteContainerID(), e.getData());
    }
}
Also used : ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) ISharedObjectDeactivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectDeactivatedEvent) IContainerDisconnectedEvent(org.eclipse.ecf.core.events.IContainerDisconnectedEvent) ISharedObjectMessageEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent)

Example 5 with ISharedObjectActivatedEvent

use of org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent in project ecf by eclipse.

the class DiscoveryAgent method handleEvent.

public void handleEvent(Event event) {
    if (event instanceof ISharedObjectActivatedEvent) {
        ISharedObjectActivatedEvent e = (ISharedObjectActivatedEvent) event;
        if (e.getActivatedID().equals(config.getSharedObjectID()))
            activated();
        else
            activated(e.getActivatedID());
    } else if (event instanceof ISharedObjectDeactivatedEvent) {
        ISharedObjectDeactivatedEvent e = (ISharedObjectDeactivatedEvent) event;
        if (e.getDeactivatedID().equals(config.getSharedObjectID()))
            deactivated();
        else
            deactivated(e.getDeactivatedID());
    } else if (event instanceof IContainerConnectedEvent) {
        IContainerConnectedEvent e = (IContainerConnectedEvent) event;
        if (e.getTargetID().equals(e.getLocalContainerID()))
            connected();
        else
            connected(e.getTargetID());
    } else if (event instanceof IContainerDisconnectedEvent) {
        IContainerDisconnectedEvent e = (IContainerDisconnectedEvent) event;
        if (e.getTargetID().equals(e.getLocalContainerID()))
            disconnected();
        else
            disconnected(e.getTargetID());
    } else if (event instanceof ISharedObjectMessageEvent)
        received((ISharedObjectMessageEvent) event);
}
Also used : ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) ISharedObjectDeactivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectDeactivatedEvent) IContainerDisconnectedEvent(org.eclipse.ecf.core.events.IContainerDisconnectedEvent) ISharedObjectMessageEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent)

Aggregations

ISharedObjectActivatedEvent (org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent)9 IContainerConnectedEvent (org.eclipse.ecf.core.events.IContainerConnectedEvent)5 ISharedObjectDeactivatedEvent (org.eclipse.ecf.core.sharedobject.events.ISharedObjectDeactivatedEvent)5 IContainerDisconnectedEvent (org.eclipse.ecf.core.events.IContainerDisconnectedEvent)4 ISharedObjectMessageEvent (org.eclipse.ecf.core.sharedobject.events.ISharedObjectMessageEvent)4 Event (org.eclipse.ecf.core.util.Event)3 IEventProcessor (org.eclipse.ecf.core.util.IEventProcessor)3 ID (org.eclipse.ecf.core.identity.ID)2 IContainerListener (org.eclipse.ecf.core.IContainerListener)1 IContainerEvent (org.eclipse.ecf.core.events.IContainerEvent)1 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)1 SharedObjectCreateException (org.eclipse.ecf.core.sharedobject.SharedObjectCreateException)1