Search in sources :

Example 1 with SharedObjectInitException

use of org.eclipse.ecf.core.sharedobject.SharedObjectInitException in project ecf by eclipse.

the class FeedSharedObject method init.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.core.ISharedObject#init(org.eclipse.ecf.core.ISharedObjectConfig)
	 */
public void init(ISharedObjectConfig initData) throws SharedObjectInitException {
    if (config == null) {
        config = initData;
    } else {
        throw new SharedObjectInitException("Already initialized.");
    }
    trace("init(" + initData + ")");
    // get local publish path
    publishPathName = (String) initData.getProperties().get(PUBLISH_PROPERTY_NAME);
    publishPathName = publishPathName == null ? "feed.xml" : publishPathName;
    // get local channel container first...throw if we can't get it
    IMergeableChannelContainerAdapter container = (IMergeableChannelContainerAdapter) config.getContext().getAdapter(IMergeableChannelContainerAdapter.class);
    if (container == null) {
        throw new SharedObjectInitException("Channel container is null/not available");
    }
    if (container instanceof RssClientSOContainer) {
        // get rss feed
        try {
            feed = ((RssClientSOContainer) container).receiveFeed(getID().getName());
        } catch (IOException ioe) {
            throw new SharedObjectInitException(ioe);
        }
    }
}
Also used : IOException(java.io.IOException) IMergeableChannelContainerAdapter(org.eclipse.ecf.datashare.mergeable.IMergeableChannelContainerAdapter) SharedObjectInitException(org.eclipse.ecf.core.sharedobject.SharedObjectInitException)

Example 2 with SharedObjectInitException

use of org.eclipse.ecf.core.sharedobject.SharedObjectInitException in project ecf by eclipse.

the class SubscriptionAgent method init.

public void init(ISharedObjectConfig config) throws SharedObjectInitException {
    Map props = config.getProperties();
    if (config.getContext().getLocalContainerID().equals(config.getHomeContainerID())) {
        containerID = (ID) props.get(CONTAINER_ID_KEY);
        if (containerID == null)
            throw new SharedObjectInitException("containerID is required");
        callback = (ISubscriptionCallback) props.get(CALLBACK_KEY);
        if (callback == null)
            throw new SharedObjectInitException("callback is required");
    }
    sharedObjectID = (ID) props.get(SHARED_OBJECT_ID_KEY);
    if (sharedObjectID == null)
        throw new SharedObjectInitException("sharedObjectID is required");
    this.config = config;
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) SharedObjectInitException(org.eclipse.ecf.core.sharedobject.SharedObjectInitException)

Example 3 with SharedObjectInitException

use of org.eclipse.ecf.core.sharedobject.SharedObjectInitException in project ecf by eclipse.

the class AgentBase method init.

public void init(ISharedObjectConfig config) throws SharedObjectInitException {
    Map props = config.getProperties();
    initializeData(props.get(INITIAL_DATA_KEY));
    updaterID = (String) props.get(MODEL_UPDATER_KEY);
    if (updaterID == null)
        throw new SharedObjectInitException("Model Updater is required.");
    initializeUpdater();
    this.config = config;
}
Also used : Map(java.util.Map) SharedObjectInitException(org.eclipse.ecf.core.sharedobject.SharedObjectInitException)

Example 4 with SharedObjectInitException

use of org.eclipse.ecf.core.sharedobject.SharedObjectInitException in project ecf by eclipse.

the class RemoteAgent method initializeUpdater.

protected void initializeUpdater() throws SharedObjectInitException {
    IExtensionRegistry registry = Platform.getExtensionRegistry();
    if (registry == null)
        throw new SharedObjectInitException("No Platform Extension Registry.");
    IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.ecf.example.pubsub.modelUpdater");
    for (int i = 0; i < elements.length; ++i) {
        if (updaterID.equals(elements[i].getAttribute("id"))) {
            try {
                updater = (IModelUpdater) elements[i].createExecutableExtension("class");
            } catch (CoreException e) {
                throw new SharedObjectInitException(e);
            } catch (ClassCastException e) {
                throw new SharedObjectInitException(e);
            }
            break;
        }
    }
    if (updater == null)
        throw new SharedObjectInitException("Could not find specified Model Updater.");
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) SharedObjectInitException(org.eclipse.ecf.core.sharedobject.SharedObjectInitException)

Aggregations

SharedObjectInitException (org.eclipse.ecf.core.sharedobject.SharedObjectInitException)4 Map (java.util.Map)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 IExtensionRegistry (org.eclipse.core.runtime.IExtensionRegistry)1 IMergeableChannelContainerAdapter (org.eclipse.ecf.datashare.mergeable.IMergeableChannelContainerAdapter)1