org.apache.jdo.impl.fostore
Class FOStoreClientConnectionImpl

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

abstract class FOStoreClientConnectionImpl
extends java.net.URLConnection
implements FOStoreClientConnection

Implementation of the client side of a FOStore connection.

Version:
1.0
Author:
Craig Russell

Field Summary
(package private)  FOStoreConnectionFactory connectionFactory
           
(package private)  FOStoreConnectionId connectionId
           
(package private) static org.apache.commons.logging.Log logger
          Logger
private  boolean loggingIn
          Flag set while logging in.
(package private)  Message message
          Message to handle connection-to-connection messages (login).
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
 
Constructor Summary
FOStoreClientConnectionImpl(java.net.URL url)
          Creates new FOStoreClientConnectionImpl
 
Method Summary
 void close()
          Return this connection to the connection pool.
 void closeDatabase()
          Close the database associated with this connection.
 void connect()
          Connect to the data source.
 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 abstract  java.lang.String localizePath(java.lang.String path)
           
protected  void login()
          Log in to the datastore.
 void sendToStore(byte[] buffer, int start, int length)
          Indicates that the client has finished writing.
 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

message

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


connectionFactory

FOStoreConnectionFactory connectionFactory

connectionId

FOStoreConnectionId connectionId

loggingIn

private boolean loggingIn
Flag set while logging in. This flag, when set, causes close() to retain the connection instead of returning the connection to the pool.


logger

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

Constructor Detail

FOStoreClientConnectionImpl

public FOStoreClientConnectionImpl(java.net.URL url)
Creates new FOStoreClientConnectionImpl

Method Detail

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

localizePath

protected abstract java.lang.String localizePath(java.lang.String path)
Returns:
The path, modified as required for the kind of connection.

connect

public void connect()
             throws java.io.IOException
Connect to the data source.

Throws:
java.io.IOException

getInputFromServer

public java.io.DataInput getInputFromServer()
                                     throws java.io.IOException
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

sendToStore

public void sendToStore(byte[] buffer,
                        int start,
                        int length)
                 throws java.io.IOException
Indicates that the client has finished writing. The data is sent to the server and processed there.

Throws:
java.io.IOException

closeDatabase

public void closeDatabase()
                   throws java.io.IOException,
                          FOStoreDatabaseException
Close the database associated with this connection. In the remote case, close the socket.

Throws:
java.io.IOException
FOStoreDatabaseException