search: keywords: ['Java API', 'OServer', 'embed']
Java API - OServer
This class allows you to embed and manage a server instance within your application. Once you start the server, you can interact with it and manage data the same as you would standard instances of the OrientDB Server.
For more information, see Embedding the Server. For the complete
OServer
documentation, see the Javadocs.
Working with OServer
In order to operate on an OrientDB database, you first need to establish a connection with the server. You have two options in this: you can connect to a running OrientDB Server using OrientDB
or you can embed the server within your application using this class. It can be found at com.orientechnologies.orient.server
. For instance,
/* Import OrientDB Classes */
import com.orientechnologies.orient.server.OServer;
Once you've imported the class to your application, you can use one of the constructors to build a particular instance in your code.
Constructors
This class provides two constructors to create instances of OServer
in your application. The first takes no arguments and the second takes a single boolean argument, which defines whether you want to shut the server down on exit.
// CONSTRUCTOR 1
OServer()
// CONSTRUCTOR 2
OServer(boolean shutdownEngineOnExit)
Exception
This class throws the following exceptions.
ClassNotFoundException
MalformedObjectNameException
NullPointerException
InstanceAlreadyExistsException
MBeanRegistrationException
NotCompliantMBeanException
Methods
Once you've initialized the class in your application, you can call the following methods on your instance.
Managing Server Instances
Method | Return Type | Description |
---|---|---|
getInstance() | OServer | Retrieves a server instance by ID. |
getInstanceByPath() | OServer | Retrieve a server instance by its path. |
isActive() | boolean | Checks whether server is active. |
restart() | void | Restarts the server. |
shutdown() | boolean | Shuts down the server. |
startup() | OServer | Starts the server. |
Managing Databases
Method | Return Type | Description |
---|---|---|
getDatabaseDirectory() | java.lang.String | Retrieves the root database directory. |
openDatabase() | ODatabase<T> | Opens the given database. |
Managing Storage
Method | Return Type | Description |
---|---|---|
existsStoragePath() | boolean | Determines whether storage path exists. |
getAvailableStorageNames() | Map <String, String> | Retrieves a map of available storage types. |
getStoragePath() | java.lang.String | Retrieves the storage path. |
User Management
Method | Return Type | Description |
---|---|---|
addTemporaryUser() | void | Adds a temporary user to the server. |
addUser() | void | Adds a user to the server. |
authenticate() | boolean | Authenticates a user on the server. |
dropUser() | void | Removes user from the server. |
isAllowed() | boolean | Checks whether user can access a given resource. |
Configuration
Method | Return Type | Description |
---|---|---|
getConfiguration() | OServerConfiguration | Retrieves the server configuration. |
saveConfiguration() | void | Saves the server configuration to disk. |