Search in sources :

Example 6 with ContainerTypeDescription

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

the class AbstractGenericServer method createAndInitializeServer.

protected void createAndInitializeServer(String path, int keepAlive) throws IDCreateException {
    if (// $NON-NLS-1$
    path == null || path.equals(""))
        // $NON-NLS-1$
        throw new NullPointerException("Cannot create ID with null or empty path");
    GenericServerContainer s = new GenericServerContainer(this, createServerConfig(path), serverGroup, path, keepAlive);
    IContainerManager containerManager = Activator.getDefault().getContainerManager();
    if (containerManager != null) {
        // $NON-NLS-1$
        ContainerTypeDescription ctd = containerManager.getContainerFactory().getDescriptionByName("ecf.generic.server");
        containerManager.addContainer(s, ctd);
    }
    IConnectHandlerPolicy policy = createConnectHandlerPolicy(s, path);
    if (policy != null)
        s.setConnectPolicy(policy);
}
Also used : IConnectHandlerPolicy(org.eclipse.ecf.core.security.IConnectHandlerPolicy) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) IContainerManager(org.eclipse.ecf.core.IContainerManager)

Example 7 with ContainerTypeDescription

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

the class RssClientSOContainer method main.

public static final void main(String[] args) throws Exception {
    // Get server identity
    // String targetURL =
    // "http://"+java.net.InetAddress.getLocalHost().getHostName();
    String targetURL = "http://feeds.feedburner.com";
    if (args.length > 0) {
        targetURL = args[0];
    }
    final ContainerTypeDescription contd = new ContainerTypeDescription(RssContainerInstantiator.class.getName(), RssContainerInstantiator.class.getName(), null);
    ContainerFactory.getDefault().addDescription(contd);
    final RssClientSOContainer container = new RssClientSOContainer();
    // now connect to rss service
    final ID serverID = IDFactory.getDefault().createStringID(targetURL);
    container.connect(serverID, null);
    // get IMergeableChannelContainer adapter
    final IMergeableChannelContainerAdapter channelContainer = (IMergeableChannelContainerAdapter) container.getAdapter(IMergeableChannelContainerAdapter.class);
    // create channel listener
    final IChannelListener listener = new IChannelListener() {

        public void handleChannelEvent(IChannelEvent event) {
            System.out.println("listener.handleChannelEvent(" + event + ")");
        }
    };
    // create a new channel
    final ID channelID = IDFactory.getDefault().createStringID("/reuters/worldNews/");
    // ID channelID = IDFactory.getDefault().createStringID("/feed.xml");
    final IMergeableChannel channel = channelContainer.createMergeableChannel(channelID, listener, new HashMap());
    if (channel instanceof FeedSharedObject) {
        // get remote feed (subscribed)
        final RssFeed remoteFeed = ((FeedSharedObject) channel).getFeed();
        // get local feed (published)
        final File feedFile = new File("feed.xml");
        RssFeed localFeed = RssFeed.load(feedFile);
        if (localFeed == null) {
            localFeed = new RssFeed(remoteFeed.getTitle(), remoteFeed.getLink(), remoteFeed.getDescription());
            localFeed.setVersion(RssVersion.RSS_2_0);
        }
        // merge remote feed with local one
        localFeed.merge(remoteFeed);
        // add a new item to feed
        localFeed.addItem(new RssItem("New Google Item", "This is a new item", "http://www.google.com"));
        // publish updated feed
        localFeed.save(feedFile);
        // print item titles
        final java.util.List items = localFeed.getItems();
        for (int i = 0; i < items.size(); i++) {
            System.out.println(" " + i + " " + ((RssItem) items.get(i)).getTitle());
        }
    }
    // remove the channel
    channelContainer.removeChannel(channelID);
    // disconnect the service
    container.disconnect();
    container.dispose();
    System.out.println("Exiting.");
}
Also used : RssFeed(org.eclipse.higgins.rsse.RssFeed) IChannelListener(org.eclipse.ecf.datashare.IChannelListener) IChannelEvent(org.eclipse.ecf.datashare.events.IChannelEvent) HashMap(java.util.HashMap) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) IMergeableChannel(org.eclipse.ecf.datashare.mergeable.IMergeableChannel) List(java.util.List) RssItem(org.eclipse.higgins.rsse.RssItem) ID(org.eclipse.ecf.core.identity.ID) StringID(org.eclipse.ecf.core.identity.StringID) IMergeableChannelContainerAdapter(org.eclipse.ecf.datashare.mergeable.IMergeableChannelContainerAdapter) File(java.io.File)

Example 8 with ContainerTypeDescription

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

the class ClientApplication method init.

public void init(String[] args) throws Exception {
    serverName = TCPServerSOContainer.getDefaultServerURL();
    if (args.length > 0) {
        // $NON-NLS-1$
        if (!args[0].equals("-"))
            serverName = args[0];
    }
    if (args.length > 1) {
        sharedObjectClassNames = new String[args.length - 1];
        for (int i = 0; i < args.length - 1; i++) {
            sharedObjectClassNames[i] = args[i + 1];
        }
    }
    // Setup factory descriptions since Eclipse does not do this for us
    contd = new ContainerTypeDescription(CONTAINER_FACTORY_NAME, CONTAINER_FACTORY_CLASS, null);
    ContainerFactory.getDefault().addDescription(contd);
    for (int i = 0; i < clientCount; i++) {
        sm[i] = createClient();
    }
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription)

Example 9 with ContainerTypeDescription

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

the class SSLAbstractGenericServer method createAndInitializeServer.

protected void createAndInitializeServer(String path, int keepAlive) throws IDCreateException {
    if (// $NON-NLS-1$
    path == null || path.equals(""))
        // $NON-NLS-1$
        throw new NullPointerException("Cannot create ID with null or empty path");
    SSLGenericServerContainer s = new SSLGenericServerContainer(this, createServerConfig(path), serverGroup, path, keepAlive);
    IContainerManager containerManager = Activator.getDefault().getContainerManager();
    if (containerManager != null) {
        // $NON-NLS-1$
        ContainerTypeDescription ctd = containerManager.getContainerFactory().getDescriptionByName("ecf.generic.server");
        containerManager.addContainer(s, ctd);
    }
    IConnectHandlerPolicy policy = createConnectHandlerPolicy(s, path);
    if (policy != null)
        s.setConnectPolicy(policy);
}
Also used : IConnectHandlerPolicy(org.eclipse.ecf.core.security.IConnectHandlerPolicy) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) IContainerManager(org.eclipse.ecf.core.IContainerManager)

Example 10 with ContainerTypeDescription

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

the class ServerManager method createServerContainer.

private TCPServerSOContainer createServerContainer(String id, TCPServerSOContainerGroup group, String path, int keepAlive) throws IDCreateException {
    final ID newServerID = IDFactory.getDefault().createStringID(id);
    TCPServerSOContainer container = new TCPServerSOContainer(new SOContainerConfig(newServerID), group, path, keepAlive);
    IContainerManager containerManager = Activator.getDefault().getContainerManager();
    if (containerManager != null) {
        // $NON-NLS-1$
        ContainerTypeDescription ctd = containerManager.getContainerFactory().getDescriptionByName("ecf.generic.server");
        containerManager.addContainer(container, ctd);
    }
    return container;
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) IContainerManager(org.eclipse.ecf.core.IContainerManager) IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID)

Aggregations

ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)54 IContainer (org.eclipse.ecf.core.IContainer)20 List (java.util.List)5 Namespace (org.eclipse.ecf.core.identity.Namespace)5 ExtensionRegistryRunnable (org.eclipse.ecf.core.util.ExtensionRegistryRunnable)5 ArrayList (java.util.ArrayList)3 Dictionary (java.util.Dictionary)3 Properties (java.util.Properties)3 IContainerManager (org.eclipse.ecf.core.IContainerManager)3 IRemoteServiceContainer (org.eclipse.ecf.remoteservice.IRemoteServiceContainer)3 URI (java.net.URI)2 URL (java.net.URL)2 Hashtable (java.util.Hashtable)2 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)2 ID (org.eclipse.ecf.core.identity.ID)2 IConnectHandlerPolicy (org.eclipse.ecf.core.security.IConnectHandlerPolicy)2 RestClientContainer (org.eclipse.ecf.remoteservice.rest.client.RestClientContainer)2 RpcClientContainer (org.eclipse.ecf.remoteservice.rpc.client.RpcClientContainer)2 Bundle (org.osgi.framework.Bundle)2 ServiceFactory (org.osgi.framework.ServiceFactory)2