for (int i = 0; i < startInitBundles.length; i++) { Bundle bundle = startInitBundles[i]; if (bundle.getState() == Bundle.INSTALLED) throw new IllegalStateException(EclipseAdaptorMsg.formatter.getString("ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED", bundle.getLocation())); try { bundle.start(); } catch (BundleException e) { FrameworkLogEntry entry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, EclipseAdaptorMsg.formatter.getString("ECLIPSE_STARTUP_FAILED_START", bundle.getLocation()), 0, e, null); log.log(entry); } } context.ungetService(reference);
startBundles(startInitBundles);
	private static Bundle[] loadBasicBundles() throws IOException {		long startTime = System.currentTimeMillis();		ServiceReference reference = context.getServiceReference(StartLevel.class.getName());		StartLevel startService = null;		if (reference != null)			startService = (StartLevel) context.getService(reference);		String[] installEntries = getArrayFromList(System.getProperty(PROP_BUNDLES), ","); //$NON-NLS-1$		int defaultStartLevel = Integer.parseInt(System.getProperty(PROP_BUNDLES_STARTLEVEL));		String syspath = getSysPath();		Bundle[] curInitBundles = getInitialBundles();		ArrayList newInitBundles = new ArrayList(installEntries.length);		ArrayList startBundles = new ArrayList(installEntries.length);		boolean refresh = false;		for (int i = 0; i < installEntries.length; i++) {			String name = installEntries[i];			int level = defaultStartLevel;			boolean start = false;			int index = name.indexOf('@');			if (index >= 0) {				String[] attributes = getArrayFromList(name.substring(index + 1, name.length()), ":"); //$NON-NLS-1$				name = name.substring(0, index);				for (int j = 0; j < attributes.length; j++) {					String attribute = attributes[j];					if (attribute.equals("start")) //$NON-NLS-1$						start = true;					else						level = Integer.parseInt(attribute);				}			}			URL location = searchForBundle(name, syspath);			if (location == null)				throw new IllegalArgumentException(EclipseAdaptorMsg.formatter.getString("ECLIPSE_STARTUP_BUNDLE_NOT_FOUND", name)); //$NON-NLS-1$			// don't need to install if it is already installed			String locationString = INITIAL_LOCATION + location.toExternalForm();			Bundle osgiBundle = getBundleByLocation(locationString, curInitBundles);			try {				if (osgiBundle == null) {					InputStream in = location.openStream();					osgiBundle = context.installBundle(locationString, in);					refresh = true;					if (level >= 0 && startService != null)						startService.setBundleStartLevel(osgiBundle, level);				}				if (start)					startBundles.add(osgiBundle);				newInitBundles.add(osgiBundle);			} catch (BundleException e) {				FrameworkLogEntry entry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, EclipseAdaptorMsg.formatter.getString("ECLIPSE_STARTUP_FAILED_INSTALL", name), 0, e, null); //$NON-NLS-1$				log.log(entry);			}		}		Bundle[] initBundles = (Bundle[]) newInitBundles.toArray(new Bundle[newInitBundles.size()]);		// check if something was removed from the bundle list		for (int i = 0; i < curInitBundles.length; i++) {			if (getBundleByLocation(curInitBundles[i].getLocation(), initBundles) == null) {				try {					curInitBundles[i].uninstall();				} catch (BundleException e) {					FrameworkLogEntry entry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, EclipseAdaptorMsg.formatter.getString("ECLIPSE_STARTUP_FAILED_UNINSTALL", curInitBundles[i].getLocation()), 0, e, null); //$NON-NLS-1$					log.log(entry);				}				refresh = true;			}		}		// If we installed/uninstalled something, force all basic bundles we installed to be resolved		if (refresh)			refreshPackages(initBundles);		// schedule all basic bundles to be started		Bundle[] startInitBundles = (Bundle[]) startBundles.toArray(new Bundle[startBundles.size()]);		for (int i = 0; i < startInitBundles.length; i++) {			Bundle bundle = startInitBundles[i];			if (bundle.getState() == Bundle.INSTALLED)				throw new IllegalStateException(EclipseAdaptorMsg.formatter.getString("ECLIPSE_STARTUP_ERROR_BUNDLE_NOT_RESOLVED", bundle.getLocation())); //$NON-NLS-1$			try {				bundle.start();			} catch (BundleException e) {				FrameworkLogEntry entry = new FrameworkLogEntry(FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME, EclipseAdaptorMsg.formatter.getString("ECLIPSE_STARTUP_FAILED_START", bundle.getLocation()), 0, e, null); //$NON-NLS-1$				log.log(entry);			}		}		context.ungetService(reference);		if (debug)			System.out.println("Time to load bundles: " + (System.currentTimeMillis() - startTime)); //$NON-NLS-1$		return startInitBundles;	}