use of org.eclipse.osgi.framework.log.FrameworkLogEntry in project rt.equinox.framework by eclipse.
the class EclipseStarter method ensureBundlesActive.
private static void ensureBundlesActive(Bundle[] bundles) {
for (int i = 0; i < bundles.length; i++) {
if (bundles[i].getState() != Bundle.ACTIVE) {
if (bundles[i].getState() == Bundle.INSTALLED) {
// Log that the bundle is not resolved
log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED, bundles[i].getLocation()), 0, null, null));
continue;
}
// check that the startlevel allows the bundle to be active (111550)
FrameworkStartLevel fwStartLevel = context.getBundle().adapt(FrameworkStartLevel.class);
BundleStartLevel bundleStartLevel = bundles[i].adapt(BundleStartLevel.class);
if (fwStartLevel != null && (bundleStartLevel.getStartLevel() <= fwStartLevel.getStartLevel())) {
log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_ACTIVE, bundles[i]), 0, null, null));
}
}
}
}
use of org.eclipse.osgi.framework.log.FrameworkLogEntry in project rt.equinox.framework by eclipse.
the class EclipseStarter method uninstallBundles.
private static void uninstallBundles(Bundle[] curInitBundles, InitialBundle[] newInitBundles, List<Bundle> toRefresh) {
for (int i = 0; i < curInitBundles.length; i++) {
boolean found = false;
for (int j = 0; j < newInitBundles.length; j++) {
if (curInitBundles[i].getLocation().equalsIgnoreCase(newInitBundles[j].locationString)) {
found = true;
break;
}
}
if (!found)
try {
curInitBundles[i].uninstall();
toRefresh.add(curInitBundles[i]);
} catch (BundleException e) {
FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_FAILED_UNINSTALL, curInitBundles[i].getLocation()), 0, e, null);
log.log(entry);
}
}
}
use of org.eclipse.osgi.framework.log.FrameworkLogEntry in project rt.equinox.framework by eclipse.
the class EclipseStarter method getInitialBundles.
private static InitialBundle[] getInitialBundles(String[] installEntries) {
searchCandidates.clear();
List<InitialBundle> result = new ArrayList<>(installEntries.length);
int defaultStartLevel = Integer.parseInt(getProperty(PROP_BUNDLES_STARTLEVEL, DEFAULT_BUNDLES_STARTLEVEL));
String syspath = getSysPath();
// should canonicalize the syspath.
try {
syspath = new File(syspath).getCanonicalPath();
} catch (IOException ioe) {
// do nothing
}
Collection<ServiceReference<Location>> installLocRef;
try {
installLocRef = context.getServiceReferences(Location.class, Location.INSTALL_FILTER);
} catch (InvalidSyntaxException e) {
throw new RuntimeException(e);
}
Location installLocation = installLocRef == null ? null : context.getService(installLocRef.iterator().next());
if (installLocation == null) {
throw new IllegalStateException(Msg.EclipseStarter_InstallLocation);
}
for (int i = 0; i < installEntries.length; i++) {
String name = installEntries[i];
int level = defaultStartLevel;
boolean start = false;
int index = name.lastIndexOf('@');
if (index >= 0) {
// $NON-NLS-1$
String[] attributes = getArrayFromList(name.substring(index + 1, name.length()), ":");
for (int j = 0; j < attributes.length; j++) {
String attribute = attributes[j];
if (// $NON-NLS-1$
attribute.equals("start"))
start = true;
else {
try {
level = Integer.parseInt(attribute);
} catch (NumberFormatException e) {
// bug 188089
index = name.length();
continue;
}
}
}
name = name.substring(0, index);
}
try {
URL location = searchForBundle(name, syspath);
if (location == null) {
FrameworkLogEntry entry = new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, NLS.bind(Msg.ECLIPSE_STARTUP_BUNDLE_NOT_FOUND, installEntries[i]), 0, null, null);
log.log(entry);
// skip this entry
continue;
}
location = makeRelative(installLocation.getURL(), location);
String locationString = INITIAL_LOCATION + location.toExternalForm();
result.add(new InitialBundle(locationString, location, level, start));
} catch (IOException e) {
log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, e.getMessage(), 0, e, null));
}
}
return result.toArray(new InitialBundle[result.size()]);
}
use of org.eclipse.osgi.framework.log.FrameworkLogEntry 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.framework.log.FrameworkLogEntry in project rt.equinox.framework by eclipse.
the class HookRegistry method initialize.
/**
* Initializes the hook configurators. The following steps are used to initialize the hook configurators. <p>
* 1. Get a list of hook configurators from all hook configurators properties files on the classpath,
* add this list to the overall list of hook configurators, remove duplicates. <p>
* 2. Get a list of hook configurators from the ("osgi.hook.configurators.include") system property
* and add this list to the overall list of hook configurators, remove duplicates. <p>
* 3. Get a list of hook configurators from the ("osgi.hook.configurators.exclude") system property
* and remove this list from the overall list of hook configurators. <p>
* 4. Load each hook configurator class, create a new instance, then call the {@link HookConfigurator#addHooks(HookRegistry)} method <p>
* 5. Set this HookRegistry object to read only to prevent any other hooks from being added. <p>
*/
public void initialize() {
List<String> configurators = new ArrayList<>(5);
// optimistic that no errors will occur
List<FrameworkLogEntry> errors = new ArrayList<>(0);
mergeFileHookConfigurators(configurators, errors);
mergePropertyHookConfigurators(configurators);
synchronized (this) {
addClassLoaderHook(new DevClassLoadingHook(container.getConfiguration()));
addClassLoaderHook(new EclipseLazyStarter(container));
addClassLoaderHook(new WeavingHookConfigurator(container));
configurators.add(SignedBundleHook.class.getName());
loadConfigurators(configurators, errors);
// set to read-only
initialized = true;
}
for (FrameworkLogEntry error : errors) {
container.getLogServices().getFrameworkLog().log(error);
}
}
Aggregations