| com.db4o.osgi.Db4oService
All known Subclasses: com.db4o.osgi.Db4oServiceImpl,
Db4oService | public interface Db4oService (Code) | | This API is registered as an OSGi service by the db4o_osgi bundle. It can be accessed like this:
ServiceReference serviceRef = _context.getServiceReference(Db4oService.class.getName());
Db4oService db4oService = (Db4oService)bundleContext.getService(serviceRef);
Configuration config = db4oService.newConfiguration();
// ...
ObjectContainer database = db4oService.openFile(config,fileName);
Subsequently, the database reference can be handled like any other db4o instance.
The main purpose of this service is to configure an OSGi bundle aware reflector for
the database instance, so classes that are owned by the client bundle are accessible
to the db4o engine. To emulate this behavior when using db4o directly through the
exported packages of the db4o_osgi plugin, db4o can be configured like this:
Configuration config = Db4o.newConfiguration();
config.reflectWith(new JdkReflector(SomeData.class.getClassLoader()));
// ...
ObjectContainer database = Db4o.openFile(config,fileName);
Access through the service is recommended over direct usage, though, as the service
may implement further OSGi specific features in the future.
See Also: Db4o See Also: com.db4o.reflect.Reflector See Also: "org.osgi.framework.BundleContext" |
Method Summary | |
Configuration | newConfiguration() Creates a fresh
Configuration Configuration instance. | ObjectContainer | openClient(String hostName, int port, String user, String password) Operates just like
Db4o.openClient(ConfigurationStringintStringString) , but uses
a newly created, vanilla
Configuration Configuration context. | ObjectContainer | openClient(Configuration config, String hostName, int port, String user, String password) opens an
ObjectContainer ObjectContainer client and connects it to the specified named server and port. | ObjectContainer | openFile(String databaseFileName) Operates just like
Db4o.openFile(ConfigurationString) , but uses
a newly created, vanilla
Configuration Configuration context.
opens an
ObjectContainer ObjectContainer on the specified database file for local use.
A database file can only be opened once, subsequent attempts to open
another
ObjectContainer ObjectContainer against the same file will result in
a
DatabaseFileLockedException DatabaseFileLockedException .
Database files can only be accessed for readwrite access from one process
(one Java VM) at one time. | ObjectContainer | openFile(Configuration config, String databaseFileName) opens an
ObjectContainer ObjectContainer on the specified database file for local use.
A database file can only be opened once, subsequent attempts to open
another
ObjectContainer ObjectContainer against the same file will result in
a
DatabaseFileLockedException DatabaseFileLockedException .
Database files can only be accessed for readwrite access from one process
(one Java VM) at one time. | ObjectServer | openServer(String databaseFileName, int port) Operates just like
Db4o.openServer(ConfigurationStringint) , but uses
a newly created, vanilla
Configuration Configuration context. | ObjectServer | openServer(Configuration config, String databaseFileName, int port) opens an
ObjectServer ObjectServer on the specified database file and port. |
newConfiguration | Configuration newConfiguration()(Code) | | Creates a fresh
Configuration Configuration instance.
a fresh, independent configuration with all options set to their default values |
|
|