use of org.eclipse.ecf.core.sharedobject.ISharedObject 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.ISharedObject 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);
}
use of org.eclipse.ecf.core.sharedobject.ISharedObject in project ecf by eclipse.
the class RssClientSOContainer method createSharedObject.
private ISharedObject createSharedObject(SharedObjectTypeDescription sotypedesc, IChannelListener listener) throws SharedObjectCreateException {
Class clazz;
try {
clazz = Class.forName(sotypedesc.getClassName());
} catch (final ClassNotFoundException e) {
throw new SharedObjectCreateException("No constructor for shared object of class " + sotypedesc.getClassName(), e);
}
Constructor cons = null;
try {
cons = clazz.getDeclaredConstructor(new Class[] { IChannelListener.class });
} catch (final NoSuchMethodException e) {
throw new SharedObjectCreateException("No constructor for shared object of class " + sotypedesc.getClassName(), e);
}
ISharedObject so = null;
try {
so = (ISharedObject) cons.newInstance(new Object[] { listener });
} catch (final Exception e) {
throw new SharedObjectCreateException("Cannot create instance of class " + sotypedesc.getClassName(), e);
}
return so;
}
use of org.eclipse.ecf.core.sharedobject.ISharedObject in project ecf by eclipse.
the class RssClientSOContainer method createChannel.
public IMergeableChannel createChannel(IChannelConfig newChannelConfig) throws ECFException {
final IChannelListener listener = newChannelConfig.getListener();
final SharedObjectDescription sodesc = new SharedObjectDescription(FeedSharedObject.class, IDFactory.getDefault().createGUID(), new HashMap());
final SharedObjectTypeDescription sotypedesc = sodesc.getTypeDescription();
ISharedObject sharedObject = null;
if (sotypedesc.getName() != null) {
sharedObject = SharedObjectFactory.getDefault().createSharedObject(sotypedesc, new Object[] { listener });
} else {
sharedObject = createSharedObject(sotypedesc, listener);
}
final IMergeableChannel channel = (IMergeableChannel) sharedObject.getAdapter(IMergeableChannel.class);
if (channel == null) {
throw new SharedObjectCreateException("Cannot coerce object " + channel + " to be of type IChannel");
}
ID newID = sodesc.getID();
if (newID == null) {
newID = IDFactory.getDefault().createGUID();
}
Map properties = sodesc.getProperties();
if (properties == null) {
properties = new HashMap();
}
// Now add channel to container...this will block
getSharedObjectManager().addSharedObject(newID, sharedObject, properties);
return channel;
}
use of org.eclipse.ecf.core.sharedobject.ISharedObject in project ecf by eclipse.
the class AbstractChatRoomSOAddTest method testAddTwoSharedObjects.
public void testAddTwoSharedObjects() throws Exception {
if (chatRoomContainer[0] == null)
return;
final IContainer client0Container = chatRoomContainer[0];
assertNotNull(client0Container);
final ISharedObjectContainer socontainer = (ISharedObjectContainer) client0Container.getAdapter(ISharedObjectContainer.class);
final ISharedObjectManager manager = socontainer.getSharedObjectManager();
assertNotNull(manager);
final ID objectID0 = createSharedObjectID();
final ID id0 = manager.addSharedObject(objectID0, createSharedObject(objectID0), null);
assertNotNull(id0);
final ID objectID1 = createSharedObjectID();
final ID id1 = manager.addSharedObject(objectID1, createSharedObject(objectID1), null);
assertNotNull(id1);
final ISharedObject sharedObject0 = manager.getSharedObject(id0);
assertNotNull(sharedObject0);
final ISharedObject sharedObject1 = manager.getSharedObject(id1);
assertNotNull(sharedObject1);
sleep(5000);
}
Aggregations