use of org.eclipse.ecf.core.sharedobject.ISharedObjectManager in project ecf by eclipse.
the class PresenceContainerAdapterFactory method getAdapter.
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adapterType.equals(IPresenceContainerAdapter.class)) {
TCPClientSOContainer container = (TCPClientSOContainer) adaptableObject;
ISharedObjectManager manager = container.getSharedObjectManager();
ID[] ids = manager.getSharedObjectIDs();
for (int i = 0; i < ids.length; i++) {
ISharedObject object = manager.getSharedObject(ids[i]);
if (object instanceof EclipseCollabSharedObject) {
EclipseCollabSharedObject ecso = (EclipseCollabSharedObject) object;
return ecso.getPresenceContainer();
}
}
}
return null;
}
use of org.eclipse.ecf.core.sharedobject.ISharedObjectManager 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];
}
use of org.eclipse.ecf.core.sharedobject.ISharedObjectManager in project ecf by eclipse.
the class PubSubAdapterFactory method getDirectory.
protected IPublishedServiceDirectory getDirectory(ISharedObjectContainer container) {
ID directoryID;
try {
directoryID = IDFactory.getDefault().createStringID(PublishedServiceDirectory.SHARED_OBJECT_ID);
} catch (IDCreateException e) {
throw new RuntimeException(e);
}
final ISharedObjectManager mgr = container.getSharedObjectManager();
IPublishedServiceDirectory directory = (IPublishedServiceDirectory) mgr.getSharedObject(directoryID);
if (directory != null)
return directory;
try {
SharedObjectDescription desc = createDirectoryDescription(directoryID);
mgr.createSharedObject(desc);
return (IPublishedServiceDirectory) mgr.getSharedObject(directoryID);
} catch (SharedObjectCreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
use of org.eclipse.ecf.core.sharedobject.ISharedObjectManager in project ecf by eclipse.
the class PublishedServiceDirectory method activated.
protected void activated(final ID sharedObjectID) {
if (sharedObjectID.equals(config.getSharedObjectID())) {
ISharedObjectManager mgr = config.getContext().getSharedObjectManager();
if (discoveryAgentID == null) {
try {
discoveryAgentID = IDFactory.getDefault().createGUID();
mgr.createSharedObject(createDiscoveryAgentDescription());
} catch (ECFException e) {
// TODO Log me!
e.printStackTrace();
}
}
}
}
use of org.eclipse.ecf.core.sharedobject.ISharedObjectManager in project ecf by eclipse.
the class AddSharedObjectTest method testAddSharedObject.
public void testAddSharedObject() throws Exception {
final ISharedObjectManager manager = getClientSOManager(0);
assertNotNull(manager);
final ID id = manager.addSharedObject(IDFactory.getDefault().createStringID("foo"), new TestSharedObject(TEST_USERNAME0), null);
assertNotNull(id);
final ISharedObject sharedObject = manager.getSharedObject(id);
assertNotNull(sharedObject);
sleep(1000);
}
Aggregations