use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class EclipseStarter method run.
/**
* Runs the application for which the platform was started. The platform
* must be running.
* <p>
* The given argument is passed to the application being run. If it is <code>null</code>
* then the command line arguments used in starting the platform, and not consumed
* by the platform code, are passed to the application as a <code>String[]</code>.
* </p>
* @param argument the argument passed to the application. May be <code>null</code>
* @return the result of running the application
* @throws Exception if anything goes wrong
*/
public static Object run(Object argument) throws Exception {
if (!running)
throw new IllegalStateException(Msg.ECLIPSE_STARTUP_NOT_RUNNING);
// if we are just initializing, do not run the application just return.
if (initialize)
return Integer.valueOf(0);
try {
if (appLauncher == null) {
// $NON-NLS-1$
boolean launchDefault = Boolean.valueOf(getProperty(PROP_APPLICATION_LAUNCHDEFAULT, "true")).booleanValue();
// create the ApplicationLauncher and register it as a service
appLauncher = new EclipseAppLauncher(context, Boolean.valueOf(getProperty(PROP_ALLOW_APPRELAUNCH)).booleanValue(), launchDefault, log, equinoxConfig);
appLauncherRegistration = context.registerService(ApplicationLauncher.class.getName(), appLauncher, null);
// will return only after the application has stopped.
return appLauncher.start(argument);
}
return appLauncher.reStart(argument);
} catch (Exception e) {
if (log != null && context != null) {
// context can be null if OSGi failed to launch (bug 151413)
ResolutionReport report = context.getBundle().adapt(Module.class).getContainer().resolve(null, false);
for (Resource unresolved : report.getEntries().keySet()) {
String bsn = ((ModuleRevision) unresolved).getSymbolicName();
FrameworkLogEntry logEntry = new FrameworkLogEntry(bsn != null ? bsn : EquinoxContainer.NAME, FrameworkLogEntry.WARNING, 0, Msg.Module_ResolveError + report.getResolutionReportMessage(unresolved), 1, null, null);
log.log(logEntry);
}
}
throw e;
}
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class Module method start.
/**
* Starts this module
* @param options the options for starting
* @throws BundleException if an errors occurs while starting
*/
public void start(StartOptions... options) throws BundleException {
revisions.getContainer().checkAdminPermission(getBundle(), AdminPermission.EXECUTE);
if (options == null) {
options = new StartOptions[0];
}
ModuleEvent event;
if (StartOptions.LAZY_TRIGGER.isContained(options)) {
setTrigger();
if (stateChangeLock.getHoldCount() > 0 && stateTransitionEvents.contains(ModuleEvent.STARTED)) {
// nothing to do here; the current thread is activating the bundle.
return;
}
}
BundleException startError = null;
boolean lockedStarted = false;
// Indicate we are in the middle of a start.
// This must be incremented before we acquire the STARTED lock the first time.
inStart.incrementAndGet();
try {
lockStateChange(ModuleEvent.STARTED);
lockedStarted = true;
checkValid();
if (StartOptions.TRANSIENT_IF_AUTO_START.isContained(options) && !settings.contains(Settings.AUTO_START)) {
// Do nothing; this is a request to start only if the module is set for auto start
return;
}
checkFragment();
persistStartOptions(options);
if (getStartLevel() > getRevisions().getContainer().getStartLevel()) {
if (StartOptions.TRANSIENT.isContained(options)) {
// it is an error to attempt to transient start a bundle without its start level met
throw new BundleException(Msg.Module_Transient_StartError, BundleException.START_TRANSIENT_ERROR);
}
// Do nothing; start level is not met
return;
}
if (State.ACTIVE.equals(getState()))
return;
if (getState().equals(State.INSTALLED)) {
ResolutionReport report;
// must unlock to avoid out of order locks when multiple unresolved
// bundles are started at the same time from different threads
unlockStateChange(ModuleEvent.STARTED);
lockedStarted = false;
try {
report = getRevisions().getContainer().resolve(Arrays.asList(this), true);
} finally {
lockStateChange(ModuleEvent.STARTED);
lockedStarted = true;
}
// need to check valid again in case someone uninstalled the bundle
checkValid();
ResolutionException e = report.getResolutionException();
if (e != null) {
if (e.getCause() instanceof BundleException) {
throw (BundleException) e.getCause();
}
}
if (State.ACTIVE.equals(getState()))
return;
if (getState().equals(State.INSTALLED)) {
String reportMessage = report.getResolutionReportMessage(getCurrentRevision());
throw new BundleException(Msg.Module_ResolveError + reportMessage, BundleException.RESOLVE_ERROR);
}
}
try {
event = doStart(options);
} catch (BundleException e) {
// must return state to resolved
setState(State.RESOLVED);
startError = e;
// must always publish the STOPPED event on error
event = ModuleEvent.STOPPED;
}
} finally {
if (lockedStarted) {
unlockStateChange(ModuleEvent.STARTED);
}
inStart.decrementAndGet();
}
if (event != null) {
if (!EnumSet.of(ModuleEvent.STARTED, ModuleEvent.LAZY_ACTIVATION, ModuleEvent.STOPPED).contains(event))
// $NON-NLS-1$
throw new IllegalStateException("Wrong event type: " + event);
publishEvent(event);
}
if (startError != null) {
throw startError;
}
}
Aggregations