mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-18 21:55:45 +02:00
[197167][persistence][api] Need callback API to know when RSE model is fully restored
https://bugs.eclipse.org/bugs/show_bug.cgi?id=197167
This commit is contained in:
parent
14a9495ad6
commit
98486aac9b
20 changed files with 966 additions and 51 deletions
|
@ -22,6 +22,7 @@ extPoint.persistenceProviders=RSE Persistence Providers
|
|||
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
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
<!-- ================================================================================== -->
|
||||
|
||||
<extension-point id="subsystemConfigurations" name="%extPoint.subsystemConfigurations" schema="schema/subsystemConfigurations.exsd"/>
|
||||
<extension-point id="modelInitializers" name="%extPoint.modelInitializers" schema="schema/modelInitializers.exsd"/>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- PreferencesInitializers -->
|
||||
|
|
100
rse/plugins/org.eclipse.rse.core/schema/modelInitializers.exsd
Normal file
100
rse/plugins/org.eclipse.rse.core/schema/modelInitializers.exsd
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.rse.core" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.eclipse.rse.core" id="modelInitializers" name="Model Initializers"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
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.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="modelInitializer" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="modelInitializer">
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
A class that implements <b>org.eclipse.rse.core.IRSEModelInitializer</b>.
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.rse.core.model.RSEModelInitializer"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
3.0
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
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>
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="copyright"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
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
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
</schema>
|
|
@ -0,0 +1,25 @@
|
|||
/********************************************************************************
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* An IRSEInitListener will be invoked when the initialization of RSE reaches the
|
||||
* completion of each phase.
|
||||
*/
|
||||
public interface IRSEInitListener {
|
||||
|
||||
/**
|
||||
* @param phase The phase of initialization that has completed.
|
||||
* @see RSECorePlugin#INIT_MODEL
|
||||
* @see RSECorePlugin#INIT_ALL
|
||||
*/
|
||||
public void phaseComplete(int phase);
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
@ -31,12 +32,14 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.rse.core.comm.SystemKeystoreProviderManager;
|
||||
import org.eclipse.rse.core.model.ISystemProfileManager;
|
||||
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||
import org.eclipse.rse.core.subsystems.ISubSystemConfigurationProxy;
|
||||
import org.eclipse.rse.internal.core.InitRSEJob;
|
||||
import org.eclipse.rse.internal.core.RSECoreRegistry;
|
||||
import org.eclipse.rse.internal.core.model.SystemProfileManager;
|
||||
import org.eclipse.rse.internal.core.model.SystemRegistry;
|
||||
|
@ -56,18 +59,39 @@ import org.osgi.framework.BundleContext;
|
|||
*/
|
||||
public class RSECorePlugin extends Plugin {
|
||||
|
||||
/**
|
||||
* The plugin id for this plugin. Value "org.eclipse.rse.core".
|
||||
*/
|
||||
public static final String PLUGIN_ID = "org.eclipse.rse.core"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Current release as a number (multiplied by 100). E.g. 300 is for release 3.0.0
|
||||
*/
|
||||
public static final int CURRENT_RELEASE = 200; // updated to new release
|
||||
|
||||
public static final String PLUGIN_ID = "org.eclipse.rse.core";
|
||||
|
||||
/**
|
||||
* Current release as a string.
|
||||
*/
|
||||
public static final String CURRENT_RELEASE_NAME = "2.0.0"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Value 1.
|
||||
* Used in isInitComplete(int) which will return true if the model phase of the
|
||||
* initialization is complete.
|
||||
* Clients must not assume any particular ordering
|
||||
* among phases based on the value.
|
||||
*/
|
||||
public static final int INIT_MODEL = 1;
|
||||
|
||||
/**
|
||||
* Value 999.
|
||||
* Used in isInitComplete(int) which will return true if all phases of
|
||||
* initialization are complete.
|
||||
* Clients must not assume any particular ordering
|
||||
* among phases based on the value.
|
||||
*/
|
||||
public static final int INIT_ALL = 999;
|
||||
|
||||
private static RSECorePlugin plugin = null; // the singleton instance of this plugin
|
||||
private Logger logger = null;
|
||||
private ISystemRegistry _systemRegistry = null;
|
||||
|
@ -81,6 +105,49 @@ public class RSECorePlugin extends Plugin {
|
|||
public static RSECorePlugin getDefault() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits until the RSE model has been fully restored from its persistent form. Should be used
|
||||
* before accessing pieces of the model.
|
||||
* @return an IStatus indicating how the initialization ended.
|
||||
* @throws InterruptedException if this wait was interrupted for some reason.
|
||||
*/
|
||||
public static IStatus waitForInitCompletion() throws InterruptedException {
|
||||
return InitRSEJob.getInstance().waitForCompletion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param phase the phase identifier.
|
||||
* @return true if initialization of the RSE model is complete for that phase.
|
||||
* It will return true if the
|
||||
* initialization for that phase has completed regardless its status of that completion.
|
||||
* @throws IllegalArgumentException if the phase is undefined.
|
||||
* @see #INIT_ALL
|
||||
* @see #INIT_MODEL
|
||||
*/
|
||||
public static boolean isInitComplete(int phase) {
|
||||
return InitRSEJob.getInstance().isComplete(phase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new listener to the set of listeners to be notified when initialization phases complete.
|
||||
* If the listener is added after the phase has completed it will not be invoked.
|
||||
* If the listener is already in the set it will not be added again.
|
||||
* Listeners may be notified in any order.
|
||||
* @param listener the listener to be added
|
||||
*/
|
||||
public static void addInitListener(IRSEInitListener listener) {
|
||||
InitRSEJob.getInstance().addInitListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a listener to the set of listeners to be notified when phases complete.
|
||||
* If the listener is not in the set this does nothing.
|
||||
* @param listener the listener to be removed
|
||||
*/
|
||||
public static void removeInitListener(IRSEInitListener listener) {
|
||||
InitRSEJob.getInstance().removeInitListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* A static convenience method - fully equivalent to
|
||||
|
@ -185,6 +252,8 @@ public class RSECorePlugin extends Plugin {
|
|||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
registerKeystoreProviders();
|
||||
InitRSEJob job = InitRSEJob.getInstance();
|
||||
job.schedule();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,231 @@
|
|||
/********************************************************************************
|
||||
* 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.internal.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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.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.core.IRSEInitListener;
|
||||
import org.eclipse.rse.core.IRSEModelInitializer;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public final static String NAME = "Initialize RSE"; //$NON-NLS-1$
|
||||
|
||||
private static InitRSEJob singleton = null;
|
||||
|
||||
private boolean isComplete = false;
|
||||
private boolean isModelComplete = false;
|
||||
private Set listeners = new HashSet(10);
|
||||
private Logger logger = null;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
private InitRSEJob() {
|
||||
super(NAME);
|
||||
logger = RSECorePlugin.getDefault().getLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new listener to the set of listeners to be notified when initialization phases complete.
|
||||
* If the listener is added after the phase has completed it will not be invoked.
|
||||
* If the listener is already in the set it will not be added again.
|
||||
* Listeners may be notified in any order.
|
||||
* @param listener the listener to be added
|
||||
*/
|
||||
public void addInitListener(IRSEInitListener listener) {
|
||||
synchronized (listeners) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a listener to the set of listeners to be notified when phases complete.
|
||||
* If the listener is not in the set this does nothing.
|
||||
* @param listener the listener to be removed
|
||||
*/
|
||||
public void removeInitListener(IRSEInitListener listener) {
|
||||
synchronized (listeners) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify all registered listeners of a phase completion
|
||||
* @param phase the phase just completed.
|
||||
*/
|
||||
private void notifyListeners(int phase) {
|
||||
List myListeners = new ArrayList(listeners.size());
|
||||
synchronized (listeners) {
|
||||
myListeners.addAll(listeners);
|
||||
}
|
||||
for (Iterator z = myListeners.iterator(); z.hasNext();) {
|
||||
IRSEInitListener listener = (IRSEInitListener) z.next();
|
||||
try {
|
||||
listener.phaseComplete(phase);
|
||||
} catch (RuntimeException e) {
|
||||
logger.logError(RSECoreMessages.InitRSEJob_listener_ended_in_error, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IStatus run(IProgressMonitor monitor) {
|
||||
IStatus result = Status.OK_STATUS;
|
||||
Logger logger = RSECorePlugin.getDefault().getLogger();
|
||||
// get and initialize the profile manager
|
||||
RSECorePlugin.getTheSystemProfileManager();
|
||||
isModelComplete = true;
|
||||
notifyListeners(RSECorePlugin.INIT_MODEL);
|
||||
// instantiate initializers
|
||||
List initializers = new ArrayList(10);
|
||||
IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.rse.core.modelInitializers"); //$NON-NLS-1$
|
||||
IStatus status = Status.OK_STATUS;
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
IConfigurationElement element = elements[i];
|
||||
String initializerName = element.getAttribute("class"); //$NON-NLS-1$
|
||||
try {
|
||||
IRSEModelInitializer initializer = (IRSEModelInitializer) element.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
initializers.add(initializer);
|
||||
} catch (CoreException e) {
|
||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_initializer_failed_to_load, initializerName);
|
||||
logger.logError(message, e);
|
||||
status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, message, e);
|
||||
}
|
||||
if (result.getSeverity() < status.getSeverity()) {
|
||||
result = status;
|
||||
}
|
||||
}
|
||||
// run initializers
|
||||
monitor.beginTask(RSECoreMessages.InitRSEJob_initializing_rse, elements.length);
|
||||
for (Iterator z = initializers.iterator(); z.hasNext() && !monitor.isCanceled();) {
|
||||
IRSEModelInitializer initializer = (IRSEModelInitializer) z.next();
|
||||
IProgressMonitor submonitor = new SubProgressMonitor(monitor, 1);
|
||||
String initializerName = initializer.getClass().getName();
|
||||
try {
|
||||
status = initializer.run(submonitor);
|
||||
if (status.getSeverity() < IStatus.ERROR) {
|
||||
try {
|
||||
while (!initializer.isComplete()) {
|
||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_waiting_for_initializer, initializerName);
|
||||
logger.logInfo(message);
|
||||
Thread.sleep(1000l); // wait 1 second
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_initializer_interrupted, initializerName);
|
||||
logger.logWarning(message, e);
|
||||
status = new Status(IStatus.WARNING, RSECorePlugin.PLUGIN_ID, message);
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_initializer_ended_in_error, initializerName);
|
||||
logger.logError(message, e);
|
||||
status = new Status(IStatus.ERROR, RSECorePlugin.PLUGIN_ID, message, e);
|
||||
}
|
||||
if (result.getSeverity() < status.getSeverity()) {
|
||||
result = status;
|
||||
}
|
||||
submonitor.done();
|
||||
}
|
||||
if (monitor.isCanceled()) {
|
||||
result = Status.CANCEL_STATUS;
|
||||
} else {
|
||||
monitor.done();
|
||||
}
|
||||
// finish up
|
||||
isComplete = true;
|
||||
notifyListeners(RSECorePlugin.INIT_ALL);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 IStatus waitForCompletion() throws InterruptedException {
|
||||
IStatus result = Status.OK_STATUS;
|
||||
while (!isComplete(RSECorePlugin.INIT_ALL)) {
|
||||
try {
|
||||
if (getState() != Job.RUNNING) {
|
||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_waiting_for_job, NAME);
|
||||
logger.logInfo(message);
|
||||
Thread.sleep(1000l);
|
||||
} else {
|
||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_joining_job, NAME);
|
||||
logger.logInfo(message);
|
||||
join();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
String message = NLS.bind(RSECoreMessages.InitRSEJob_job_interrupted, NAME);
|
||||
logger.logError(message, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
result = getResult();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param phase the phase for which completion is requested.
|
||||
* Phases are defined in {@link RSECorePlugin}.
|
||||
* @return true if this phase has completed.
|
||||
* @throws IllegalArgumentException if the phase is undefined.
|
||||
* @see RSECorePlugin#INIT_ALL
|
||||
* @see RSECorePlugin#INIT_MODEL
|
||||
*/
|
||||
public boolean isComplete(int phase) {
|
||||
boolean result = false;
|
||||
switch (phase) {
|
||||
case RSECorePlugin.INIT_MODEL:
|
||||
result = isModelComplete;
|
||||
break;
|
||||
case RSECorePlugin.INIT_ALL:
|
||||
result = isComplete;
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("undefined phase"); //$NON-NLS-1$
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -54,6 +54,17 @@ public class RSECoreMessages extends NLS {
|
|||
// Password Persistence Manager
|
||||
public static String DefaultSystemType_Label;
|
||||
|
||||
// InitRSEJob
|
||||
public static String InitRSEJob_initializer_ended_in_error;
|
||||
public static String InitRSEJob_initializer_failed_to_load;
|
||||
public static String InitRSEJob_initializer_interrupted;
|
||||
public static String InitRSEJob_initializing_rse;
|
||||
public static String InitRSEJob_job_interrupted;
|
||||
public static String InitRSEJob_joining_job;
|
||||
public static String InitRSEJob_listener_ended_in_error;
|
||||
public static String InitRSEJob_waiting_for_initializer;
|
||||
public static String InitRSEJob_waiting_for_job;
|
||||
|
||||
// SystemRegistry: Loading Profile Warning Messages - See also ISystemMessages
|
||||
public static String MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REFS;
|
||||
public static String MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REF;
|
||||
|
|
|
@ -49,6 +49,17 @@ SerializingProvider_UnexpectedException=Unexpected Exception
|
|||
# Password Persistence Manager
|
||||
DefaultSystemType_Label=Default
|
||||
|
||||
# InitRSEJob
|
||||
InitRSEJob_initializer_ended_in_error=Initializer {0} ended in error.
|
||||
InitRSEJob_initializer_failed_to_load=Failed to load initializer {0}.
|
||||
InitRSEJob_initializer_interrupted=Initializer {0} interrupted.
|
||||
InitRSEJob_initializing_rse=Initializing RSE
|
||||
InitRSEJob_job_interrupted=Job {0} interrupted.
|
||||
InitRSEJob_joining_job=Joining job {0}.
|
||||
InitRSEJob_listener_ended_in_error=Listener ended in error.
|
||||
InitRSEJob_waiting_for_initializer=Waiting for initializer {0} to complete.
|
||||
InitRSEJob_waiting_for_job=Waiting for job {0} to start.
|
||||
|
||||
# SystemRegistry: Loading Profile Warning Messages - See also ISystemMessages
|
||||
MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REFS=RSEG1069: De-Activating profile {0} for which there are subsystems containing references to filter pools:
|
||||
MSG_LOADING_PROFILE_WARNING_FILTERPOOL_REF=\ in connection {1} in profile {2}
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/*********************************************************************************
|
||||
* Copyright (c) 2008 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) - [197167] 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;
|
||||
}
|
||||
}
|
|
@ -30,28 +30,20 @@
|
|||
* 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.subsystems.ISubSystemConfiguration;
|
||||
|
@ -59,7 +51,6 @@ 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 +70,6 @@ import org.osgi.framework.BundleContext;
|
|||
*/
|
||||
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 +407,6 @@ public class RSEUIPlugin extends SystemBasePlugin
|
|||
svraf = new SystemTeamViewResourceAdapterFactory();
|
||||
svraf.registerWithManager(manager);
|
||||
|
||||
InitRSEJob initJob = new InitRSEJob();
|
||||
initJob.schedule();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -490,5 +490,11 @@ Martin Oberhuber (Wind River) - [185552] Remove remoteSystemsViewPreferencesActi
|
|||
</includes>
|
||||
</viewerContentBinding>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.rse.core.modelInitializers">
|
||||
<modelInitializer
|
||||
class="org.eclipse.rse.internal.ui.RSEUIPluginModelInitializer">
|
||||
</modelInitializer>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -71,4 +71,12 @@
|
|||
name="Tests Only">
|
||||
</systemType>
|
||||
</extension>
|
||||
|
||||
<extension point="org.eclipse.rse.core.modelInitializers">
|
||||
<modelInitializer class="org.eclipse.rse.tests.initialization.GoodInitializer"/>
|
||||
<modelInitializer class="org.eclipse.rse.tests.initialization.BadInitializer"/>
|
||||
<modelInitializer class="org.eclipse.rse.tests.initialization.UglyInitializer"/>
|
||||
<modelInitializer class="org.eclipse.rse.tests.initialization.ListenerInitializer"/>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*********************************************************************************
|
||||
* Copyright (c) 2008 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) - [197167] initial contribution.
|
||||
*********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.tests.initialization;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.rse.core.IRSEModelInitializer;
|
||||
|
||||
/**
|
||||
* An ill-behaved initializer that returns a lousy status
|
||||
*/
|
||||
public class BadInitializer implements IRSEModelInitializer {
|
||||
|
||||
private static BadInitializer instance = null;
|
||||
private boolean isComplete = false;
|
||||
private boolean wasRun = false;
|
||||
|
||||
public static BadInitializer getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public BadInitializer() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEModelInitializer#isComplete()
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return isComplete;
|
||||
}
|
||||
|
||||
public boolean wasRun() {
|
||||
return wasRun;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEModelInitializer#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IStatus run(IProgressMonitor monitor) {
|
||||
wasRun = true;
|
||||
IStatus result = new Status(IStatus.ERROR, "org.eclipse.rse.tests", "bwaahahaha");
|
||||
// oh darn, forgot to set the "isComplete"!
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*********************************************************************************
|
||||
* Copyright (c) 2008 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) - [197167] initial contribution.
|
||||
*********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.tests.initialization;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.rse.core.IRSEModelInitializer;
|
||||
|
||||
/**
|
||||
* A plain vanilla initializer that does its thing without exceptions.
|
||||
*/
|
||||
public class GoodInitializer implements IRSEModelInitializer {
|
||||
|
||||
private static GoodInitializer instance = null;
|
||||
private boolean isComplete = false;
|
||||
private boolean wasRun = false;
|
||||
|
||||
public static GoodInitializer getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public GoodInitializer() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEModelInitializer#isComplete()
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return isComplete;
|
||||
}
|
||||
|
||||
public boolean wasRun() {
|
||||
return wasRun;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEModelInitializer#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IStatus run(IProgressMonitor monitor) {
|
||||
wasRun = true;
|
||||
isComplete = true;
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*********************************************************************************
|
||||
* Copyright (c) 2008 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) - [197167] initial contribution.
|
||||
*********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.tests.initialization;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.rse.core.IRSEInitListener;
|
||||
|
||||
/**
|
||||
* A listener for initialization
|
||||
*/
|
||||
public class InitListener implements IRSEInitListener {
|
||||
|
||||
Set phases = new HashSet();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEInitListener#phaseComplete(int)
|
||||
*/
|
||||
public void phaseComplete(int phase) {
|
||||
phases.add(new Integer(phase));
|
||||
}
|
||||
|
||||
public boolean sawPhase(int phase) {
|
||||
return phases.contains(new Integer(phase));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*******************************************************************************
|
||||
* 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 contribution.
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.tests.initialization;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
|
||||
/**
|
||||
* Should be run on a clean workspace.
|
||||
*/
|
||||
public class InitializationTest extends TestCase {
|
||||
|
||||
public InitializationTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.tests.core.RSECoreTestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.tests.core.RSECoreTestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testInitialization() {
|
||||
//-test-author-:DavidDykstal
|
||||
try {
|
||||
RSECorePlugin.waitForInitCompletion();
|
||||
} catch (InterruptedException e) {
|
||||
fail("interrupted");
|
||||
}
|
||||
assertTrue("not indicating complete", RSECorePlugin.isInitComplete(RSECorePlugin.INIT_ALL));
|
||||
GoodInitializer goodInitializer = GoodInitializer.getInstance();
|
||||
BadInitializer badInitializer = BadInitializer.getInstance();
|
||||
UglyInitializer uglyInitializer = UglyInitializer.getInstance();
|
||||
ListenerInitializer listenerInitializer = ListenerInitializer.getInstance();
|
||||
assertTrue("good initializer not run", goodInitializer.wasRun() && goodInitializer.isComplete());
|
||||
assertTrue("bad initializer not run", badInitializer.wasRun() && !badInitializer.isComplete());
|
||||
assertTrue("ugly initializer not run", uglyInitializer.wasRun() && uglyInitializer.isComplete());
|
||||
assertTrue("listener initializer not run", listenerInitializer.wasRun() && listenerInitializer.isComplete());
|
||||
InitListener listener = listenerInitializer.getListener();
|
||||
assertFalse("listener saw phase INIT_MODEL", listener.sawPhase(RSECorePlugin.INIT_MODEL)); // shouldn't see this since it occurs before the listener is added
|
||||
assertTrue("listener missed phase INIT_ALL", listener.sawPhase(RSECorePlugin.INIT_ALL));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* 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 contribution
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.tests.initialization;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
public class InitializationTestSuite extends TestSuite {
|
||||
/**
|
||||
* Standard Java application main method. Allows to launch the test
|
||||
* suite from outside as part of nightly runs, headless runs or other.
|
||||
* <p><b>Note:</b> Use only <code>junit.textui.TestRunner</code> here as
|
||||
* it is explicitly supposed to output the test output to the shell the
|
||||
* test suite has been launched from.
|
||||
* <p>
|
||||
* @param args The standard Java application command line parameters passed in.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
junit.textui.TestRunner.run(suite());
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine all tests into a suite and returns the test suite instance.
|
||||
* <p>
|
||||
* <b>Note: This method must be always called <i><code>suite</code></i> ! Otherwise
|
||||
* the JUnit plug-in test launcher will fail to detect this class!</b>
|
||||
* <p>
|
||||
* @return The test suite instance.
|
||||
*/
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite("RSE Initialization Test Suite"); //$NON-NLS-1$
|
||||
suite.addTest(new InitializationTest("testInitialization"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.tests.framework.AbstractTestSuiteHolder#getTestSuite()
|
||||
*/
|
||||
public TestSuite getTestSuite() {
|
||||
return (TestSuite)InitializationTestSuite.suite();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*********************************************************************************
|
||||
* Copyright (c) 2008 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) - [197167] initial contribution.
|
||||
*********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.tests.initialization;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.rse.core.IRSEModelInitializer;
|
||||
import org.eclipse.rse.core.RSECorePlugin;
|
||||
|
||||
/**
|
||||
* A plain vanilla initializer that does its thing without exceptions.
|
||||
*/
|
||||
public class ListenerInitializer implements IRSEModelInitializer {
|
||||
|
||||
private static ListenerInitializer instance = null;
|
||||
private boolean isComplete = false;
|
||||
private boolean wasRun = false;
|
||||
private InitListener listener = new InitListener();
|
||||
|
||||
public static ListenerInitializer getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ListenerInitializer() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEModelInitializer#isComplete()
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return isComplete;
|
||||
}
|
||||
|
||||
public boolean wasRun() {
|
||||
return wasRun;
|
||||
}
|
||||
|
||||
public InitListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEModelInitializer#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IStatus run(IProgressMonitor monitor) {
|
||||
RSECorePlugin.addInitListener(listener);
|
||||
wasRun = true;
|
||||
isComplete = true;
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/*********************************************************************************
|
||||
* Copyright (c) 2008 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) - [197167] initial contribution.
|
||||
*********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.tests.initialization;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.rse.core.IRSEModelInitializer;
|
||||
|
||||
/**
|
||||
* An initializer that does asynchronous work.
|
||||
*/
|
||||
public class UglyInitializer implements IRSEModelInitializer {
|
||||
|
||||
private static UglyInitializer instance = null;
|
||||
boolean isComplete = false;
|
||||
boolean wasRun = false;
|
||||
|
||||
public static UglyInitializer getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public UglyInitializer() {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEModelInitializer#isComplete()
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return isComplete;
|
||||
}
|
||||
|
||||
public boolean wasRun() {
|
||||
return wasRun;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.core.IRSEModelInitializer#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IStatus run(IProgressMonitor monitor) {
|
||||
wasRun = true;
|
||||
Job job = new Job("test initializer job") {
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
Thread.sleep(5000l); // sleep for a bit
|
||||
} catch (InterruptedException e) {
|
||||
// eat the exception
|
||||
}
|
||||
isComplete = true;
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job.schedule(1000l);
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue