|
db4o 7.4 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Db4oService
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.
Db4o
,
Reflector
,
"org.osgi.framework.BundleContext"Method Summary | |
---|---|
com.db4o.config.Configuration |
newConfiguration()
Creates a fresh Configuration instance. |
com.db4o.ObjectContainer |
openClient(com.db4o.config.Configuration config,
java.lang.String hostName,
int port,
java.lang.String user,
java.lang.String password)
opens an ObjectContainer
client and connects it to the specified named server and port. |
com.db4o.ObjectContainer |
openClient(java.lang.String hostName,
int port,
java.lang.String user,
java.lang.String password)
Operates just like Db4o.openClient(Configuration, String, int, String, String) , but uses
a newly created, vanilla Configuration context. |
com.db4o.ObjectContainer |
openFile(com.db4o.config.Configuration config,
java.lang.String databaseFileName)
opens an ObjectContainer
on the specified database file for local use. |
com.db4o.ObjectContainer |
openFile(java.lang.String databaseFileName)
Operates just like Db4o.openFile(Configuration, String) , but uses
a newly created, vanilla Configuration context. |
com.db4o.ObjectServer |
openServer(com.db4o.config.Configuration config,
java.lang.String databaseFileName,
int port)
opens an ObjectServer
on the specified database file and port. |
com.db4o.ObjectServer |
openServer(java.lang.String databaseFileName,
int port)
Operates just like Db4o.openServer(Configuration, String, int) , but uses
a newly created, vanilla Configuration context. |
Method Detail |
---|
com.db4o.config.Configuration newConfiguration()
Configuration
instance.
com.db4o.ObjectContainer openClient(java.lang.String hostName, int port, java.lang.String user, java.lang.String password) throws com.db4o.ext.Db4oException
Db4o.openClient(Configuration, String, int, String, String)
, but uses
a newly created, vanilla Configuration
context.
opens an ObjectContainer
client and connects it to the specified named server and port.
allow access
for the specified user and password.
ObjectContainer
can be cast to
ExtClient
to use extended
ExtObjectContainer
and ExtClient
methods.
hostName
- the host nameport
- the port the server is usinguser
- the user namepassword
- the user password
ObjectContainer
com.db4o.ext.Db4oException
ObjectServer.grantAccess(java.lang.String, java.lang.String)
com.db4o.ObjectContainer openClient(com.db4o.config.Configuration config, java.lang.String hostName, int port, java.lang.String user, java.lang.String password) throws com.db4o.ext.Db4oException
ObjectContainer
client and connects it to the specified named server and port.
allow access
for the specified user and password.
ObjectContainer
can be cast to
ExtClient
to use extended
ExtObjectContainer
and ExtClient
methods.
config
- a custom Configuration
instance to be obtained via Db4o.newConfiguration()
hostName
- the host nameport
- the port the server is usinguser
- the user namepassword
- the user password
ObjectContainer
com.db4o.ext.Db4oException
ObjectServer.grantAccess(java.lang.String, java.lang.String)
com.db4o.ObjectContainer openFile(java.lang.String databaseFileName) throws com.db4o.ext.Db4oException
Db4o.openFile(Configuration, String)
, but uses
a newly created, vanilla Configuration
context.
opens an ObjectContainer
on the specified database file for local use.
ObjectContainer
against the same file will result in
a DatabaseFileLockedException
.
databaseFileName
- an absolute or relative path to the database file
ObjectContainer
com.db4o.ext.Db4oException
Configuration.readOnly(boolean)
,
Configuration.encrypt(boolean)
,
Configuration.password(java.lang.String)
com.db4o.ObjectContainer openFile(com.db4o.config.Configuration config, java.lang.String databaseFileName) throws com.db4o.ext.Db4oException
ObjectContainer
on the specified database file for local use.
ObjectContainer
against the same file will result in
a DatabaseFileLockedException
.
config
- a custom Configuration
instance to be obtained via Db4o.newConfiguration()
databaseFileName
- an absolute or relative path to the database file
ObjectContainer
com.db4o.ext.Db4oException
Configuration.readOnly(boolean)
,
Configuration.encrypt(boolean)
,
Configuration.password(java.lang.String)
com.db4o.ObjectServer openServer(java.lang.String databaseFileName, int port) throws com.db4o.ext.Db4oException
Db4o.openServer(Configuration, String, int)
, but uses
a newly created, vanilla Configuration
context.
opens an ObjectServer
on the specified database file and port.
ObjectServer.openClient()
, specify '0' as the
port number.
databaseFileName
- an absolute or relative path to the database fileport
- the port to be used, or 0, if the server should not open a port,
because it will only be used with ObjectServer.openClient()
ObjectServer
listening
on the specified port.
com.db4o.ext.Db4oException
Configuration.readOnly(boolean)
,
Configuration.encrypt(boolean)
,
Configuration.password(java.lang.String)
com.db4o.ObjectServer openServer(com.db4o.config.Configuration config, java.lang.String databaseFileName, int port) throws com.db4o.ext.Db4oException
ObjectServer
on the specified database file and port.
ObjectServer.openClient()
, specify '0' as the
port number.
config
- a custom Configuration
instance to be obtained via Db4o.newConfiguration()
databaseFileName
- an absolute or relative path to the database fileport
- the port to be used, or 0, if the server should not open a port,
because it will only be used with ObjectServer.openClient()
ObjectServer
listening
on the specified port.
com.db4o.ext.Db4oException
Configuration.readOnly(boolean)
,
Configuration.encrypt(boolean)
,
Configuration.password(java.lang.String)
|
db4o 7.4 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |