org.apache.jdo.impl.fostore
Class FOStoreLocalConnection

java.lang.Object
  extended byjava.net.URLConnection
      extended byorg.apache.jdo.impl.fostore.FOStoreClientConnectionImpl
          extended byorg.apache.jdo.impl.fostore.FOStoreLocalConnection
All Implemented Interfaces:
FOStoreClientConnection, FOStoreConnection

class FOStoreLocalConnection
extends FOStoreClientConnectionImpl

Implements the client and server/store connections for the case in which the client and store are running in the same address space.

Author:
Dave Bristor

Field Summary
(package private)  FOStoreConnectionFactory connectionFactory
           
(package private)  FOStoreConnectionId connectionId
           
(package private) static org.apache.commons.logging.Log logger
          Logger
(package private)  Message message
          Message to handle connection-to-connection messages (login).
private  FOStoreServerConnection server
          The server that implements the requests
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
 
Constructor Summary
(package private) FOStoreLocalConnection(java.net.URL url)
          Provides a connection to the database, using the URL support in the superclass.
 
Method Summary
 void close()
          Return this connection to the connection pool.
 void closeDatabase()
          Close the database associated with this connection.
 void connect()
          This connects to the data store, and verifies the user name and password..
 FOStoreConnectionFactory getConnectionFactory()
          Get the connection Factory used to create this connection.
 FOStoreConnectionId getConnectionId()
          Get the connection id used to create this connection.
 java.io.DataInput getInputFromServer()
          Provides DataInput from which the client can read replies from the server.
protected  java.lang.String localizePath(java.lang.String path)
           
protected  void login()
          Log in to the datastore.
 void sendToStore(byte[] buffer, int offset, int length)
          Write bytes to the store.
 void setConnectionFactory(FOStoreConnectionFactory cf)
          Set the connection id used to create this connection.
 void setConnectionId(FOStoreConnectionId id)
          Set the connection id used to create this connection.
 
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getContent, getContent, getContentEncoding, getContentLength, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFields, getIfModifiedSince, getInputStream, getLastModified, getOutputStream, getPermission, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setRequestProperty, setUseCaches, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

server

private FOStoreServerConnection server
The server that implements the requests


message

Message message
Message to handle connection-to-connection messages (login).


connectionFactory

FOStoreConnectionFactory connectionFactory

connectionId

FOStoreConnectionId connectionId

logger

static final org.apache.commons.logging.Log logger
Logger

Constructor Detail

FOStoreLocalConnection

FOStoreLocalConnection(java.net.URL url)
Provides a connection to the database, using the URL support in the superclass.

Method Detail

getInputFromServer

public java.io.DataInput getInputFromServer()
                                     throws java.io.IOException
Description copied from interface: FOStoreClientConnection
Provides DataInput from which the client can read replies from the server.

Returns:
DataInput from which the client can read replies.
Throws:
java.io.IOException
See Also:
FOStoreClientConnection.getInputFromServer()

sendToStore

public void sendToStore(byte[] buffer,
                        int offset,
                        int length)
                 throws java.io.IOException
Write bytes to the store. The data is used to construct a FOStoreInput for the server to use; then the server is called to process the requests.

Throws:
java.io.IOException

connect

public void connect()
             throws java.io.IOException
This connects to the data store, and verifies the user name and password..

Throws:
java.io.IOException

closeDatabase

public void closeDatabase()
                   throws FOStoreDatabaseException
Close the database associated with this connection. This closes the local server, which causes the remote database to be closed.

Throws:
FOStoreDatabaseException

localizePath

protected java.lang.String localizePath(java.lang.String path)
Specified by:
localizePath in class FOStoreClientConnectionImpl
Returns:
The path as given.

close

public void close()
           throws java.io.IOException
Return this connection to the connection pool.

Specified by:
close in interface FOStoreClientConnection
Throws:
java.io.IOException

login

protected void login()
              throws java.io.IOException
Log in to the datastore. This will be done for both local and remote connections.

Throws:
java.io.IOException

setConnectionFactory

public void setConnectionFactory(FOStoreConnectionFactory cf)
Description copied from interface: FOStoreClientConnection
Set the connection id used to create this connection. This is used to determine which connection pool is used.

Specified by:
setConnectionFactory in interface FOStoreClientConnection

getConnectionFactory

public FOStoreConnectionFactory getConnectionFactory()
Get the connection Factory used to create this connection. Connections are pooled based on this connection Factory.

Specified by:
getConnectionFactory in interface FOStoreClientConnection

setConnectionId

public void setConnectionId(FOStoreConnectionId id)
Set the connection id used to create this connection. This is used to determine which connection pool is used.

Specified by:
setConnectionId in interface FOStoreClientConnection

getConnectionId

public FOStoreConnectionId getConnectionId()
Get the connection id used to create this connection. The id encapsulates URL, user, and password. Connections are pooled based on this connection id.

Specified by:
getConnectionId in interface FOStoreClientConnection