use of org.eclipse.osgi.service.datalocation.Location in project MonjaDB by Kanatoko.
the class Activator method loadConfig.
//--------------------------------------------------------------------------------
public void loadConfig() throws IOException {
Location location = Platform.getConfigurationLocation();
if (location != null) {
URL configURL = location.getURL();
if (configURL != null && configURL.getProtocol().startsWith("file")) {
File platformDir = new File(configURL.getFile(), Activator.PLUGIN_ID);
MSystemUtil.createDir(platformDir.getAbsolutePath());
String configFileName = platformDir.getAbsolutePath() + "/" + DEFAULT_CONFIG_FILE_NAME;
loadConfig(configFileName);
}
} else {
loadConfig("_dummy_not_exist_");
}
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testSystemBundle07.
public void testSystemBundle07() {
// test init twice
// $NON-NLS-1$
File config = OSGiTestsActivator.getContext().getDataFile("testSystemBundle07_01");
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
Equinox equinox = new Equinox(configuration);
try {
equinox.init();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected exception in init()", e);
}
try {
equinox.init();
} catch (Exception e) {
// $NON-NLS-1$
fail("Unexpected exception in init()", e);
}
try {
equinox.start();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to start the framework", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState());
BundleContext systemContext = equinox.getBundleContext();
// $NON-NLS-1$
assertNotNull("SystemBundle context is null", systemContext);
try {
equinox.init();
} catch (Exception e) {
// $NON-NLS-1$
fail("Unexpected exception in init()", e);
}
ServiceReference[] refs = null;
try {
// $NON-NLS-1$
refs = systemContext.getServiceReferences(Location.class.getName(), "(type=osgi.configuration.area)");
} catch (InvalidSyntaxException e) {
// $NON-NLS-1$
fail("Unexpected syntax error", e);
}
// $NON-NLS-1$
assertNotNull("Configuration Location refs is null", refs);
// $NON-NLS-1$
assertEquals("config refs length is wrong", 1, refs.length);
Location configLocation = (Location) systemContext.getService(refs[0]);
URL configURL = configLocation.getURL();
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("incorrect configuration location", configURL.toExternalForm().endsWith("testSystemBundle07_01/"));
try {
equinox.stop();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected erorr stopping framework", e);
}
try {
equinox.waitForStop(10000);
} catch (InterruptedException e) {
// $NON-NLS-1$
fail("Unexpected interrupted exception", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState());
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class SystemBundleTests method testSystemBundle01.
public void testSystemBundle01() {
// simple test to create an embedded framework
// $NON-NLS-1$
File config = OSGiTestsActivator.getContext().getDataFile("testSystemBundle01");
Map<String, Object> configuration = new HashMap<String, Object>();
configuration.put(Constants.FRAMEWORK_STORAGE, config.getAbsolutePath());
Equinox equinox = new Equinox(configuration);
try {
equinox.init();
equinox.start();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Failed to start the framework", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.ACTIVE, equinox.getState());
BundleContext systemContext = equinox.getBundleContext();
// $NON-NLS-1$
assertNotNull("SystemBundle context is null", systemContext);
ServiceReference[] refs = null;
try {
// $NON-NLS-1$
refs = systemContext.getServiceReferences(Location.class.getName(), "(type=osgi.configuration.area)");
} catch (InvalidSyntaxException e) {
// $NON-NLS-1$
fail("Unexpected syntax error", e);
}
// $NON-NLS-1$
assertNotNull("Configuration Location refs is null", refs);
// $NON-NLS-1$
assertEquals("config refs length is wrong", 1, refs.length);
Location configLocation = (Location) systemContext.getService(refs[0]);
URL configURL = configLocation.getURL();
// $NON-NLS-1$ //$NON-NLS-2$
assertTrue("incorrect configuration location", configURL.toExternalForm().endsWith("testSystemBundle01/"));
try {
equinox.stop();
} catch (BundleException e) {
// $NON-NLS-1$
fail("Unexpected erorr stopping framework", e);
}
try {
equinox.waitForStop(10000);
} catch (InterruptedException e) {
// $NON-NLS-1$
fail("Unexpected interrupted exception", e);
}
// $NON-NLS-1$
assertEquals("Wrong state for SystemBundle", Bundle.RESOLVED, equinox.getState());
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class BasicLocationTests method testUNC.
public void testUNC() throws Exception {
if (!windows)
return;
Map<String, String> fwkConfig = new HashMap<String, String>();
fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA + EquinoxLocations.READ_ONLY_AREA_SUFFIX, "true");
fwkConfig.put(EquinoxLocations.PROP_USER_AREA, "//server/share/a");
fwkConfig.put(EquinoxLocations.PROP_INSTANCE_AREA, "//server/share/b");
fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA, "//server/share/c");
fwkConfig.put(EquinoxLocations.PROP_INSTALL_AREA, "file://server/share/g");
Equinox equinox = new Equinox(fwkConfig);
equinox.init();
try {
Map<String, Location> locations = getLocations(equinox);
checkLocation(locations.get(Location.USER_FILTER), true, true, "file");
checkLocation(locations.get(Location.INSTANCE_FILTER), true, true, "file");
checkLocation(locations.get(Location.CONFIGURATION_FILTER), true, true, "file");
checkLocation(locations.get(Location.INSTALL_FILTER), true, true, "file");
} finally {
equinox.stop();
}
}
use of org.eclipse.osgi.service.datalocation.Location in project rt.equinox.framework by eclipse.
the class BasicLocationTests method testDebugLogOnGetURL.
public void testDebugLogOnGetURL() throws Exception {
Properties debugOptions = new Properties();
debugOptions.put("org.eclipse.osgi/debug/location", "true");
File debugOptionsFile = OSGiTestsActivator.getContext().getDataFile(getName() + ".options");
debugOptions.store(new FileOutputStream(debugOptionsFile), getName());
Map<String, String> fwkConfig = new HashMap<String, String>();
fwkConfig.put(EquinoxLocations.PROP_CONFIG_AREA + EquinoxLocations.READ_ONLY_AREA_SUFFIX, "true");
fwkConfig.put(EquinoxLocations.PROP_INSTALL_AREA, "file:" + prefix + "/g");
fwkConfig.put(EquinoxConfiguration.PROP_DEBUG, debugOptionsFile.getAbsolutePath());
fwkConfig.put("eclipse.consoleLog", "true");
Equinox equinox = new Equinox(fwkConfig);
equinox.init();
try {
final List<LogEntry> logEntries = new ArrayList<LogEntry>();
LogReaderService logReaderService = getLogReaderService(equinox);
LogListener logListener = new SynchronousLogListener() {
@Override
public void logged(LogEntry entry) {
logEntries.add(entry);
}
};
logReaderService.addLogListener(logListener);
Map<String, Location> locations = getLocations(equinox);
Location userLocation = locations.get(Location.USER_FILTER);
Location instanceLocation = locations.get(Location.INSTANCE_FILTER);
assertNotNull("User locatoin is not null.", userLocation.getURL());
assertNotNull("Instance location is not null.", instanceLocation.getURL());
assertEquals("Wrong number of log entries", 2, logEntries.size());
} finally {
equinox.stop();
}
}
Aggregations