org.ow2.petals.registry.database
Class RegistryClient

java.lang.Object
  extended by org.ow2.petals.registry.database.RegistryClient
Direct Known Subclasses:
MySqlClient, PostgreSqlClient

public abstract class RegistryClient
extends java.lang.Object


Nested Class Summary
protected  class RegistryClient.ClientKey
           
protected  class RegistryClient.IsContextException
           
 
Field Summary
protected  int batchSize
           
protected  int connectionPoolSize
           
protected  java.lang.String connectionUrl
           
protected  javax.sql.DataSource dataSource
           
protected static java.util.concurrent.ConcurrentMap<RegistryClient.ClientKey,javax.sql.DataSource> DATASOURCES
           
protected  org.ow2.petals.util.LoggingUtil log
           
protected  java.lang.String password
           
protected static java.lang.String ROOT_CONTEXT
           
protected  java.lang.String username
           
 
Constructor Summary
RegistryClient(java.lang.String connectionUrl, java.lang.String username, java.lang.String password, int connectionPoolSize, int batchSize, boolean checkTables, org.ow2.petals.util.LoggingUtil log)
           
 
Method Summary
 void bind(javax.naming.CompositeName contextName, java.lang.String objectName, java.lang.Object object)
          Bind a name to an object or create a subcontext
 void close()
           
protected  boolean isContextExist(java.lang.String contextName, java.sql.Connection jdbcConnection)
           
abstract  java.util.Map<java.lang.String,java.lang.Object> list(javax.naming.CompositeName contextName)
          Enumerates the names bound in a context with their object class name.
 java.lang.Object lookup(javax.naming.CompositeName contextName, java.lang.String objectName)
          Retrieve a named object that can be a value object.or a context.
protected static java.lang.Object readObject(java.sql.ResultSet rs, int idx)
           
 void rebind(javax.naming.CompositeName contextName, java.lang.String objectName, java.lang.Object object)
          Rebind a name to an object, overwriting an existing one
 void unbind(javax.naming.CompositeName contextName, java.lang.String objectName)
          Unbind a named object or delete a subcontext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_CONTEXT

protected static final java.lang.String ROOT_CONTEXT
See Also:
Constant Field Values

DATASOURCES

protected static java.util.concurrent.ConcurrentMap<RegistryClient.ClientKey,javax.sql.DataSource> DATASOURCES

connectionUrl

protected final java.lang.String connectionUrl

username

protected final java.lang.String username

password

protected final java.lang.String password

connectionPoolSize

protected final int connectionPoolSize

batchSize

protected final int batchSize

dataSource

protected javax.sql.DataSource dataSource

log

protected org.ow2.petals.util.LoggingUtil log
Constructor Detail

RegistryClient

public RegistryClient(java.lang.String connectionUrl,
                      java.lang.String username,
                      java.lang.String password,
                      int connectionPoolSize,
                      int batchSize,
                      boolean checkTables,
                      org.ow2.petals.util.LoggingUtil log)
               throws javax.naming.NamingException
Throws:
javax.naming.NamingException
Method Detail

close

public void close()

bind

public void bind(javax.naming.CompositeName contextName,
                 java.lang.String objectName,
                 java.lang.Object object)
          throws javax.naming.NameAlreadyBoundException,
                 javax.naming.NamingException
Bind a name to an object or create a subcontext

Parameters:
contextName - Context name, not null.
objectName - Name of the object to bind in the context contextName. If null, the subcontext contextName will be created.
object - Object to bind. If null, the subcontext contextName will be created.
Throws:
javax.naming.NameAlreadyBoundException - The name is already bound
javax.naming.NamingException - An SQL error occurs.

rebind

public void rebind(javax.naming.CompositeName contextName,
                   java.lang.String objectName,
                   java.lang.Object object)
            throws javax.naming.NamingException
Rebind a name to an object, overwriting an existing one

Parameters:
contextName - Context name, not null.
objectName - Name of the object binding, not null.
object - Object to bind, not null.
Throws:
javax.naming.NamingException - An SQL error occurs.

unbind

public void unbind(javax.naming.CompositeName contextName,
                   java.lang.String objectName)
            throws javax.naming.NotContextException,
                   javax.naming.NameNotFoundException,
                   javax.naming.ContextNotEmptyException,
                   javax.naming.NamingException
Unbind a named object or delete a subcontext

Parameters:
contextName - Context name, not null.
objectName - Name of the object binding. If null, the subcontext contextName will be destroyed.
Throws:
javax.naming.NotContextException - In case of context deletion, contextName is not a context.
javax.naming.NameNotFoundException - contextName/objectName does not exist.
javax.naming.ContextNotEmptyException - In case of context deletion, contextName is not empty.
javax.naming.NamingException - An SQL error occurs.

lookup

public java.lang.Object lookup(javax.naming.CompositeName contextName,
                               java.lang.String objectName)
                        throws RegistryClient.IsContextException,
                               javax.naming.NameNotFoundException,
                               javax.naming.NamingException
Retrieve a named object that can be a value object.or a context.

Parameters:
contextName - Context name, not null.
objectName - Name, only into contextName, no directory, of the named object to retrieve, not null.
Returns:
The named value object.
Throws:
javax.naming.NameNotFoundException - No named object found.
javax.naming.NamingException - An SQL error occurs.
RegistryClient.IsContextException - The named object to retrieve is a context.

list

public abstract java.util.Map<java.lang.String,java.lang.Object> list(javax.naming.CompositeName contextName)
                                                               throws javax.naming.NameNotFoundException,
                                                                      javax.naming.NamingException
Enumerates the names bound in a context with their object class name. In case of a sub context, the object class name is set to null.

Parameters:
contextName - Context name, not null.
Returns:
A map the names and class names of the bindings in this context. Each element of the map is of type <String, Object>, Object is null in case of a sub context.
Throws:
javax.naming.NameNotFoundException - The context name does not exist.
javax.naming.NamingException - An SQL error occurs.

isContextExist

protected boolean isContextExist(java.lang.String contextName,
                                 java.sql.Connection jdbcConnection)
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

readObject

protected static final java.lang.Object readObject(java.sql.ResultSet rs,
                                                   int idx)
                                            throws java.sql.SQLException,
                                                   java.io.IOException,
                                                   java.lang.ClassNotFoundException
Throws:
java.sql.SQLException
java.io.IOException
java.lang.ClassNotFoundException


Copyright © 2005-2011 Petals Link (EBM Websourcing). All Rights Reserved.