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);
}
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.");
}
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();
}
}
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);
}
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;
}
Aggregations