### Eclipse Workspace Patch 1.0 #P org.eclipse.rse.core Index: plugin.properties =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/plugin.properties,v retrieving revision 1.9 diff -u -r1.9 plugin.properties --- plugin.properties 12 May 2007 01:39:37 -0000 1.9 +++ plugin.properties 4 Mar 2008 02:46:52 -0000 @@ -22,6 +22,7 @@ extPoint.systemTypes=RSE System Types extPoint.systemTypeProviders=RSE System Type Providers extPoint.subsystemConfigurations = Remote Subsystem Configurations +extPoint.modelInitializers = RSE Model Initializers systemType.windows.label=Windows systemType.unix.label=Unix Index: plugin.xml =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/plugin.xml,v retrieving revision 1.12 diff -u -r1.12 plugin.xml --- plugin.xml 5 Feb 2008 21:58:12 -0000 1.12 +++ plugin.xml 4 Mar 2008 02:46:52 -0000 @@ -142,6 +142,7 @@ + Index: src/org/eclipse/rse/core/RSECorePlugin.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/RSECorePlugin.java,v retrieving revision 1.25 diff -u -r1.25 RSECorePlugin.java --- src/org/eclipse/rse/core/RSECorePlugin.java 20 Feb 2008 21:24:46 -0000 1.25 +++ src/org/eclipse/rse/core/RSECorePlugin.java 4 Mar 2008 02:46:52 -0000 @@ -20,6 +20,7 @@ * Uwe Stieber (Wind River) - [192611] RSE Core plugin may fail to initialize because of cyclic code invocation * Martin Oberhuber (Wind River) - [165674] Sort subsystem configurations by priority then Id * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core + * David Dykstal (IBM) - [197167] adding notification and waiting for RSE model ********************************************************************************/ package org.eclipse.rse.core; @@ -61,7 +62,7 @@ */ public static final int CURRENT_RELEASE = 200; // updated to new release - public static final String PLUGIN_ID = "org.eclipse.rse.core"; + public static final String PLUGIN_ID = "org.eclipse.rse.core"; //$NON-NLS-1$ /** * Current release as a string. @@ -185,6 +186,7 @@ public void start(BundleContext context) throws Exception { super.start(context); registerKeystoreProviders(); + InitRSEJob.getInstance().schedule(); } /* Index: src/org/eclipse/rse/core/IRSEModelInitializer.java =================================================================== RCS file: src/org/eclipse/rse/core/IRSEModelInitializer.java diff -N src/org/eclipse/rse/core/IRSEModelInitializer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/rse/core/IRSEModelInitializer.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,40 @@ +/******************************************************************************** + * Copyright (c) 2008 IBM Corporation and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * David Dykstal (IBM) - [197167] adding notification and waiting for RSE model + ********************************************************************************/ +package org.eclipse.rse.core; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; + +/** + * A model initializer creates objects an RSE profile. + * For example, initializers can be used to create initial connections, filter pools, and filters. + * + */ +public interface IRSEModelInitializer { + + /** + * Runs the initializer. The initializer should set the monitor to done when complete. + * @param monitor the monitor that measures progress of this initializer. + * @return an IStatus indicating the success of the initializer. The status will + * be logged if it is not an OK status. If a status is an IStatus.Error then the + * initializer will be assumed to have failed and will not be queried for its + * completion status. + */ + public IStatus run(IProgressMonitor monitor); + + /** + * Reports if an initializer is complete. If an initializer runs synchronously then it must + * report true immediately after it is run. + * An initializer may choose to do some of its work asynchronously. If so, it must + * report true when the initializer considers its work to be complete. + * @return true if the initializer has completed its initialization. + */ + public boolean isComplete(); +} Index: src/org/eclipse/rse/core/InitRSEJob.java =================================================================== RCS file: src/org/eclipse/rse/core/InitRSEJob.java diff -N src/org/eclipse/rse/core/InitRSEJob.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/rse/core/InitRSEJob.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,150 @@ +/******************************************************************************** + * Copyright (c) 2008 IBM Corporation and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * David Dykstal (IBM) - [197167] adding notification and waiting for RSE model + ********************************************************************************/ +package org.eclipse.rse.core; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.osgi.util.NLS; +import org.eclipse.rse.logging.Logger; + +/** + * The InitRSEJob is a job named "Initialize RSE". It is instantiated and run during + * RSE startup. It must not be run at any other time. The job restores the + * persistent form of the RSE model. Use the extension point + * org.eclipse.rse.core.modelInitializers to supplement the model once it is + * restored. + *

+ * Clients wishing to find out when this job completes can use {@link #waitForCompletion()} or + * add a JobChangeListener to the job and listen for the RUNNING->NONE transition. + */ +public final class InitRSEJob extends Job { + + /** + * The name of this job. This is API. Clients may use this name to find this job by name. + * However, it is recommended to use InitRSEJob.getInstance() instead. + */ + public final static String NAME = "Initialize RSE"; //$NON-NLS-1$ + + private static InitRSEJob singleton = null; + + private boolean isComplete = false; + + /** + * Returns the singleton instance of this job. + * @return the InitRSEJob instance for this workbench. + */ + public synchronized static InitRSEJob getInstance() { + if (singleton == null) { + singleton = new InitRSEJob(); + } + return singleton; + } + + /** + * Waits until the job is completed. + * @return the status of the job upon its completion. + * @throws InterruptedException if the job is interrupted while waiting. + */ + public static IStatus waitForCompletion() throws InterruptedException { + IStatus result = Status.OK_STATUS; + Logger logger = RSECorePlugin.getDefault().getLogger(); + InitRSEJob job = getInstance(); + while (!job.isComplete()) { + try { + if (job.getState() != Job.RUNNING) { + String message = NLS.bind(Messages.InitRSEJob_waiting_for_job_to_start, NAME); + logger.logInfo(message); + Thread.sleep(1000l); + } else { + String message = NLS.bind(Messages.InitRSEJob_joining_job, NAME); + logger.logInfo(message); + job.join(); + } + } catch (InterruptedException e) { + String message = NLS.bind(Messages.InitRSEJob_job_interrupted, NAME); + logger.logError(message, e); + throw e; + } + } + result = job.getResult(); + return result; + } + + private InitRSEJob() { + super(NAME); + } + + public IStatus run(IProgressMonitor monitor) { + IStatus result = Status.OK_STATUS; + Logger logger = RSECorePlugin.getDefault().getLogger(); + // get and initialize the profile manager + RSECorePlugin.getTheSystemProfileManager(); + // get all the initializer definitions + IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.rse.core.modelInitializers"); //$NON-NLS-1$ + // instantiate and run the initializers + monitor.beginTask(Messages.InitRSEJob_initializing, elements.length); + for (int i = 0; i < elements.length && !monitor.isCanceled(); i++) { + IConfigurationElement element = elements[i]; + IProgressMonitor submonitor = new SubProgressMonitor(monitor, 1); + IStatus status = Status.OK_STATUS; + String initializerName = element.getAttribute("class"); //$NON-NLS-1$ + try { + IRSEModelInitializer initializer = (IRSEModelInitializer) element.createExecutableExtension("class"); //$NON-NLS-1$ + status = initializer.run(submonitor); + if (status.getSeverity() < IStatus.ERROR) { + try { + while (!initializer.isComplete()) { + String message = NLS.bind(Messages.InitRSEJob_waiting_for_initializer, initializerName); + logger.logInfo(message); + Thread.sleep(1000l); // wait 1 second + } + } catch (InterruptedException e) { + String message = NLS.bind(Messages.InitRSEJob_initializer_interrupted, initializerName); + logger.logWarning(message, e); + status = new Status(IStatus.WARNING, RSECorePlugin.PLUGIN_ID, message); + } + } + } catch (CoreException e) { + String message = NLS.bind(Messages.InitRSEJob_initializer_load_failure, initializerName); + logger.logError(message, e); + status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, message, e); + } catch (Throwable t) { + String message = NLS.bind(Messages.InitRSEJob_initializer_error, initializerName); + logger.logError(message, t); + status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, message, t); + } + if (result.getSeverity() < status.getSeverity()) { + result = status; + } + submonitor.done(); + } + if (monitor.isCanceled()) { + result = Status.CANCEL_STATUS; + } else { + monitor.done(); + } + isComplete = true; + return result; + } + + /** + * @return true if this job has been run and finished regardless of its completion status. + */ + public boolean isComplete() { + return isComplete; + } +} Index: schema/modelInitializers.exsd =================================================================== RCS file: schema/modelInitializers.exsd diff -N schema/modelInitializers.exsd --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ schema/modelInitializers.exsd 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,100 @@ + + + + + + + + + A model initializer is used to create supplemental connections and filter pools after the RSE model has been restored from its persistent form. The base RSE uses this extension point to supply the "Local" connection if one has not already been created for this workspace. Other extenders of RSE may use this to augment the mode in other ways. An initializer is run at the end of the initialization job begun by RSE when it is activated. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A class that implements <b>org.eclipse.rse.core.IRSEModelInitializer</b>. + + + + + + + + + + + + + + + 3.0 + + + + + + + + + An example taken from the plug-in org.eclipse.rse.ui: +<pre> +<extension point="org.eclipse.rse.core.modelInitializers"> + <modelInitializer class="org.eclipse.rse.internal.ui.RSEUIPluginModelInitializer"/> +</extension> +</pre> + + + + + + + + + + + Copyright (c) 2008 IBM Corporation and others. All rights reserved. +This program and the accompanying materials are made available under the terms +of the Eclipse Public License v1.0 which accompanies this distribution, and is +available at http://www.eclipse.org/legal/epl-v10.html +<br/> +<br/>Contributors: +<br/>David Dykstal (IBM) - [197167] adding notification and waiting for RSE model + + + + Index: src/org/eclipse/rse/core/Messages.java =================================================================== RCS file: src/org/eclipse/rse/core/Messages.java diff -N src/org/eclipse/rse/core/Messages.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/rse/core/Messages.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +/******************************************************************************** + * Copyright (c) 2008 IBM Corporation and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * David Dykstal (IBM) - [197167] adding notification and waiting for RSE model + ********************************************************************************/ +package org.eclipse.rse.core; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.rse.core.messages"; //$NON-NLS-1$ + public static String InitRSEJob_initializer_error; + public static String InitRSEJob_initializer_interrupted; + public static String InitRSEJob_initializer_load_failure; + public static String InitRSEJob_initializing; + public static String InitRSEJob_job_interrupted; + public static String InitRSEJob_joining_job; + public static String InitRSEJob_waiting_for_initializer; + public static String InitRSEJob_waiting_for_job_to_start; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} Index: src/org/eclipse/rse/core/messages.properties =================================================================== RCS file: src/org/eclipse/rse/core/messages.properties diff -N src/org/eclipse/rse/core/messages.properties --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/rse/core/messages.properties 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,22 @@ +############################################################################### +# Copyright (c) 2008 IBM Corporation and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# David Dykstal (IBM) - [197167] initial API and implementation +############################################################################### + +# NLS_MESSAGEFORMAT_VAR +# NLS_ENCODING=UTF-8 + +InitRSEJob_initializer_error=Initializer {0} ended in error. +InitRSEJob_initializer_interrupted=Initializer {0} interrupted. +InitRSEJob_initializer_load_failure=Failed to load initializer {0}. +InitRSEJob_initializing=Initializing RSE +InitRSEJob_job_interrupted=Job {0} interrupted. +InitRSEJob_joining_job=Joining job {0}. +InitRSEJob_waiting_for_initializer=Waiting for initializer {0} to complete. +InitRSEJob_waiting_for_job_to_start=Waiting for job {0} to start. #P org.eclipse.rse.ui Index: plugin.xml =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/plugin.xml,v retrieving revision 1.51 diff -u -r1.51 plugin.xml --- plugin.xml 6 Dec 2007 12:15:26 -0000 1.51 +++ plugin.xml 4 Mar 2008 02:46:52 -0000 @@ -490,5 +490,11 @@ + + + + Index: UI/org/eclipse/rse/ui/RSEUIPlugin.java =================================================================== RCS file: /cvsroot/dsdp/org.eclipse.tm.rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java,v retrieving revision 1.71 diff -u -r1.71 RSEUIPlugin.java --- UI/org/eclipse/rse/ui/RSEUIPlugin.java 26 Feb 2008 15:02:05 -0000 1.71 +++ UI/org/eclipse/rse/ui/RSEUIPlugin.java 4 Mar 2008 02:46:52 -0000 @@ -30,36 +30,28 @@ * David McKnight (IBM) - [196838] Don't recreate local after it has been deleted * David Dykstal (IBM) - [197036] formatted the initialize job to be able to read it * Martin Oberhuber (Wind River) - [215820] Move SystemRegistry implementation to Core + * David Dykstal (IBM) - [197167] adding notification and waiting for RSE model ********************************************************************************/ package org.eclipse.rse.ui; -import java.io.File; import java.net.URL; import java.util.Vector; -import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.rse.core.IRSESystemType; import org.eclipse.rse.core.RSECorePlugin; import org.eclipse.rse.core.SystemResourceManager; import org.eclipse.rse.core.events.ISystemResourceChangeEvents; import org.eclipse.rse.core.events.SystemResourceChangeEvent; -import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfileManager; import org.eclipse.rse.core.model.ISystemRegistry; +//import org.eclipse.rse.core.model.InitRSEJob; import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy; import org.eclipse.rse.internal.core.model.SystemProfileManager; import org.eclipse.rse.internal.core.model.SystemRegistry; import org.eclipse.rse.internal.ui.RSESystemTypeAdapterFactory; -import org.eclipse.rse.internal.ui.SystemResourceListener; import org.eclipse.rse.internal.ui.SystemResources; import org.eclipse.rse.internal.ui.actions.SystemShowPreferencesPageAction; import org.eclipse.rse.internal.ui.subsystems.SubSystemConfigurationProxyAdapterFactory; @@ -79,43 +71,6 @@ */ public class RSEUIPlugin extends SystemBasePlugin { - public class InitRSEJob extends Job { - public InitRSEJob() { - // IMPORTANT: The name of this job must not ever be changed. It is part of the API, - // because clients can use it to find the InitRSEJob by name, such that they can join it. - super("Initialize RSE"); //$NON-NLS-1$ - } - - public IStatus run(IProgressMonitor monitor) { - //System.err.println("InitRSEJob started"); //$NON-NLS-1$ - ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); - RSECorePlugin.getTheSystemProfileManager(); // create folders per profile - // add workspace listener for our project - IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(false); - SystemResourceListener listener = SystemResourceListener.getListener(remoteSystemsProject); - SystemResourceManager.startResourceEventListening(listener); - // determining whether to create an initial local connection - IPath statePath = RSECorePlugin.getDefault().getStateLocation(); - IPath markPath = statePath.append("localHostCreated.mark"); //$NON-NLS-1$ - File markFile = new File(markPath.toOSString()); - if (!markFile.exists() && SystemPreferencesManager.getShowLocalConnection()) { - // create the connection only if the local system type is enabled - IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID); - if (systemType != null && systemType.isEnabled()) { - ISystemProfileManager profileManager = RSECorePlugin.getTheSystemProfileManager(); - ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile(); - String userName = System.getProperty("user.name"); //$NON-NLS-1$ - registry.createLocalHost(profile, SystemResources.TERM_LOCAL, userName); - try { - markFile.createNewFile(); - } - catch(Exception e){} - } - } - //System.err.println("InitRSEJob done"); //$NON-NLS-1$ - return Status.OK_STATUS; - } - } public static final String PLUGIN_ID = "org.eclipse.rse.ui"; //$NON-NLS-1$ public static final String HELPPREFIX = "org.eclipse.rse.ui."; //$NON-NLS-1$ @@ -453,8 +408,8 @@ svraf = new SystemTeamViewResourceAdapterFactory(); svraf.registerWithManager(manager); - InitRSEJob initJob = new InitRSEJob(); - initJob.schedule(); +// InitRSEJob initJob = new InitRSEJob(); +// initJob.schedule(); } /** Index: UI/org/eclipse/rse/internal/ui/RSEUIPluginModelInitializer.java =================================================================== RCS file: UI/org/eclipse/rse/internal/ui/RSEUIPluginModelInitializer.java diff -N UI/org/eclipse/rse/internal/ui/RSEUIPluginModelInitializer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ UI/org/eclipse/rse/internal/ui/RSEUIPluginModelInitializer.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,71 @@ +/* ******************************************************************************* + * Copyright (c) 2006 IBM Corporation. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * David Dykstal (IBM) - initial contribution. + * *******************************************************************************/ + +package org.eclipse.rse.internal.ui; + +import java.io.File; +import java.io.IOException; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.IRSEModelInitializer; +import org.eclipse.rse.core.SystemResourceManager; +import org.eclipse.rse.core.model.ISystemProfile; +import org.eclipse.rse.core.model.ISystemProfileManager; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.SystemPreferencesManager; + +public class RSEUIPluginModelInitializer implements IRSEModelInitializer { + + private boolean isComplete = false; + + public IStatus run(IProgressMonitor monitor) { + IStatus status = Status.OK_STATUS; + // create a local host object if one is desired and one has not yet been created in this workspace. + ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); + IPath statePath = RSECorePlugin.getDefault().getStateLocation(); + IPath markPath = statePath.append("localHostCreated.mark"); //$NON-NLS-1$ + File markFile = new File(markPath.toOSString()); + if (!markFile.exists() && SystemPreferencesManager.getShowLocalConnection()) { + // create the connection only if the local system type is enabled + IRSESystemType systemType = RSECorePlugin.getTheCoreRegistry().getSystemTypeById(IRSESystemType.SYSTEMTYPE_LOCAL_ID); + if (systemType != null && systemType.isEnabled()) { + ISystemProfileManager profileManager = RSECorePlugin.getTheSystemProfileManager(); + ISystemProfile profile = profileManager.getDefaultPrivateSystemProfile(); + String userName = System.getProperty("user.name"); //$NON-NLS-1$ + registry.createLocalHost(profile, SystemResources.TERM_LOCAL, userName); + try { + markFile.createNewFile(); + } catch (IOException e) { + status = new Status(IStatus.ERROR, RSEUIPlugin.PLUGIN_ID, "IOException creating mark file during local host creation", e); //$NON-NLS-1$ + } + } + } + monitor.done(); + // listen for project change events if a project is being used + IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(false); + if (remoteSystemsProject.exists()) { + SystemResourceListener listener = SystemResourceListener.getListener(remoteSystemsProject); + SystemResourceManager.startResourceEventListening(listener); + } + isComplete = true; + return status; + } + + public boolean isComplete() { + return isComplete; + } +}