public class OServerObjectFactory extends Object implements ObjectFactory
Return a singleton OServer
instance as a JNDI resource. When embedding the database in a container such as
Tomcat it allows the server to be shutdown cleanly by calling the OServer.shutdown()
method.
This resource is always a singleton regardless of the resource configuration. When using with Tomcat it should still
be configured as a singleton however. This is so that the shutdown()
method will be called appropriately
by the container.
If the configFile
attribute does not refer to a valid readable OrientDB server configuration file the
OServer
instance will not be created and started. Either a NamingException
or
RuntimeException
will be thrown.
An example resource declaration:
<Resource auth="Container" closeMethod="shutdown" configFile="/mnt/share/orientdb-community-2.1.3/config/orientdb-server-config.xml" factory="com.ashtonit.odb.jndi.OServerObjectFactory" name="oserver" singleton="true" type="com.orientechnologies.orient.server.OServer" />
Constructor and Description |
---|
OServerObjectFactory() |
Modifier and Type | Method and Description |
---|---|
com.orientechnologies.orient.server.OServer |
getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable<?,?> environment)
Starts and returns an embedded
OServer instance. |
public com.orientechnologies.orient.server.OServer getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment) throws NamingException
OServer
instance. This instance is always a singleton, regardless of
configuration. It is important to declare it as singleton in the resource declaration though, to ensure it is
shut down cleanly.getObjectInstance
in interface ObjectFactory
obj
- the naming referencename
- not usednameCtx
- not usedenvironment
- not usedOServer
instanceNamingException
- if the configuration file cannot be readRuntimeException
- if the OServer instance throws an exception during startupObjectFactory.getObjectInstance(Object, Name, Context, Hashtable)
Copyright © 2016. All rights reserved.