Search in sources :

Example 1 with IContainerManager

use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.

the class Activator method getContainerManager.

/**
 * @return IContainerManager instance
 */
public IContainerManager getContainerManager() {
    if (containerManagerTracker == null) {
        containerManagerTracker = new ServiceTracker(this.context, IContainerManager.class.getName(), null);
        containerManagerTracker.open();
    }
    return (IContainerManager) containerManagerTracker.getService();
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) IContainerManager(org.eclipse.ecf.core.IContainerManager)

Example 2 with IContainerManager

use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.

the class ConnectedTester method getContainerByConnectID.

/**
 * @param connectID
 *            The conected ID for which an IContainer is to be returned
 * @return a IContainer instance of null
 */
// TODO push this functionality down into the ContainerManager
private IContainer getContainerByConnectID(ID connectID) {
    final IContainerManager containerManager = Activator.getDefault().getContainerManager();
    final IContainer[] containers = containerManager.getAllContainers();
    if (containers == null) {
        return null;
    }
    for (int i = 0; i < containers.length; i++) {
        ID connectedId = containers[i].getConnectedID();
        if (connectedId != null && connectedId.equals(connectID)) {
            return containers[i];
        }
    }
    return null;
}
Also used : IContainerManager(org.eclipse.ecf.core.IContainerManager) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Example 3 with IContainerManager

use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.

the class Activator method getContainerManager.

public IContainerManager getContainerManager() {
    if (containerManagerTracker == null) {
        containerManagerTracker = new ServiceTracker(context, IContainerManager.class.getName(), null);
        containerManagerTracker.open();
    }
    return (IContainerManager) containerManagerTracker.getService();
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) IContainerManager(org.eclipse.ecf.core.IContainerManager)

Example 4 with IContainerManager

use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.

the class BrowseHandler method execute.

/**
 * the command has been executed, so extract extract the needed information
 * from the application context.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
    IContainerManager containerManager = Activator.getDefault().getContainerManager();
    IContainer[] containers = containerManager.getAllContainers();
    BrowseDialog dialog = new BrowseDialog(window.getShell(), containers);
    int status = dialog.open();
    if (status == Window.OK) {
        Object[] object = dialog.getResult();
        IRosterEntry entry = (IRosterEntry) object[0];
        IRoster roster = entry.getRoster();
        if (roster != null) {
            IChatManager manager = roster.getPresenceContainerAdapter().getChatManager();
            IChatMessageSender icms = manager.getChatMessageSender();
            ITypingMessageSender itms = manager.getTypingMessageSender();
            try {
                MessagesView view = (MessagesView) window.getActivePage().showView(MessagesView.VIEW_ID);
                view.selectTab(icms, itms, roster.getUser().getID(), entry.getUser().getID(), entry.getUser().getName());
            } catch (PartInitException e) {
                e.printStackTrace();
            }
        }
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IContainerManager(org.eclipse.ecf.core.IContainerManager) IRoster(org.eclipse.ecf.presence.roster.IRoster) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) PartInitException(org.eclipse.ui.PartInitException) IContainer(org.eclipse.ecf.core.IContainer) MessagesView(org.eclipse.ecf.presence.ui.MessagesView)

Example 5 with IContainerManager

use of org.eclipse.ecf.core.IContainerManager in project ecf by eclipse.

the class Activator method createAndConfigureHostContainer.

private void createAndConfigureHostContainer(BundleContext context) throws Exception {
    // Get IContainerManager singleton
    ServiceTracker<IContainerManager, IContainerManager> containerManagerTracker = new ServiceTracker<IContainerManager, IContainerManager>(context, IContainerManager.class.getName(), null);
    containerManagerTracker.open();
    IContainerManager containerManager = containerManagerTracker.getService();
    if (containerManager == null)
        throw new NullPointerException("Cannot get IContainerManager service");
    containerManagerTracker.close();
    // Now create a hostContainer instance
    hostContainer = containerManager.getContainerFactory().createContainer("ecf.generic.server");
    // Get the ISharedObjectContainerGroupManager adapter interface
    ISharedObjectContainerGroupManager hostManager = (ISharedObjectContainerGroupManager) hostContainer.getAdapter(ISharedObjectContainerGroupManager.class);
    // Set connect policy
    hostManager.setConnectPolicy(new IConnectHandlerPolicy() {

        public void refresh() {
        }

        public PermissionCollection checkConnect(Object address, ID fromID, ID targetID, String targetGroup, Object connectData) throws Exception {
            // What we will do when we receive a check connect call is to call
            // verifyClientConnect
            verifyClientConnect(fromID, connectData);
            return null;
        }
    });
}
Also used : PermissionCollection(java.security.PermissionCollection) ISharedObjectContainerGroupManager(org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager) IConnectHandlerPolicy(org.eclipse.ecf.core.security.IConnectHandlerPolicy) ServiceTracker(org.osgi.util.tracker.ServiceTracker) IContainerManager(org.eclipse.ecf.core.IContainerManager) ID(org.eclipse.ecf.core.identity.ID)

Aggregations

IContainerManager (org.eclipse.ecf.core.IContainerManager)31 ServiceTracker (org.osgi.util.tracker.ServiceTracker)20 IContainer (org.eclipse.ecf.core.IContainer)4 ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)3 ID (org.eclipse.ecf.core.identity.ID)3 IConnectHandlerPolicy (org.eclipse.ecf.core.security.IConnectHandlerPolicy)3 IHello (org.eclipse.ecf.examples.remoteservices.hello.IHello)2 IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)2 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)2 PermissionCollection (java.security.PermissionCollection)1 ISharedObjectContainerGroupManager (org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager)1 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)1 Hello (org.eclipse.ecf.examples.remoteservices.hello.impl.Hello)1 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)1 IRoster (org.eclipse.ecf.presence.roster.IRoster)1 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)1 MessagesView (org.eclipse.ecf.presence.ui.MessagesView)1 IRemoteServiceReference (org.eclipse.ecf.remoteservice.IRemoteServiceReference)1 SyndFeedResponseDeserializer (org.eclipse.ecf.remoteservice.rest.synd.SyndFeedResponseDeserializer)1 RemoteServiceTracker (org.eclipse.ecf.remoteservice.util.tracker.RemoteServiceTracker)1