org.jboss.deployment.cache
Class FileDeploymentStore

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.deployment.cache.FileDeploymentStore
All Implemented Interfaces:
DeploymentStore (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)

public class FileDeploymentStore
extends ServiceMBeanSupport (src)
implements DeploymentStore (src)

A local file based DeploymentStore (src) .


Field Summary
protected  java.io.File dir
          The local directory where cache data will be stored.
protected  java.io.File mapFile
          The file where the mapping is located.
protected  java.util.Map urlMap
          The URL to local file mapping.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
FileDeploymentStore()
           
 
Method Summary
protected  void copyURL(java.net.URL source, java.io.File dest)
          Copy the data at the given source URL to the given file.
protected  void createService()
          Setup the url map.
 java.net.URL get(java.net.URL url)
          Get the stored URL for the given deployment URL.
 java.io.File getDirectory()
          Returns the local directory where cache data is stored.
 java.lang.String getDirectoryName()
          Get the name of the local directory where cache data is stored.
protected  java.net.URL getURLFromFile(java.io.File file)
           
 java.net.URL put(java.net.URL url)
          Put a deployment URL into storage.
protected  java.util.Map readMap()
          Read the url map from serialized state.
 void setDirectory(java.io.File dir)
          Set the local directory where cache data will be stored.
 void setDirectoryName(java.lang.String dirname)
          Set the name of the local directory where cache data will be stored.
protected  void writeMap()
          Write the url map to serialized state.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, startService, stop, stopService
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dir

protected java.io.File dir
The local directory where cache data will be stored.


mapFile

protected java.io.File mapFile
The file where the mapping is located.


urlMap

protected java.util.Map urlMap
The URL to local file mapping.

Constructor Detail

FileDeploymentStore

public FileDeploymentStore()
Method Detail

setDirectory

public void setDirectory(java.io.File dir)
                  throws java.io.IOException
Set the local directory where cache data will be stored.

Parameters:
dir - The local directory where cache data will be stored.
Throws:
java.io.IOException - File not found, not a directory, can't write...

getDirectory

public java.io.File getDirectory()
Returns the local directory where cache data is stored.

Returns:
The local directory where cache data is stored.

setDirectoryName

public void setDirectoryName(java.lang.String dirname)
                      throws java.io.IOException
Set the name of the local directory where cache data will be stored.

Invokes setDirectory(java.io.File).

Parameters:
dirname - The name of the local directory where cache data will be stored.
Throws:
java.io.IOException - File not found, not a directory, can't write...

getDirectoryName

public java.lang.String getDirectoryName()
Get the name of the local directory where cache data is stored.

Returns:
The name of the local directory where cache data is stored.

getURLFromFile

protected java.net.URL getURLFromFile(java.io.File file)

get

public java.net.URL get(java.net.URL url)
Description copied from interface: DeploymentStore (src)
Get the stored URL for the given deployment URL.

Specified by:
get in interface DeploymentStore (src)
Parameters:
url - The original deployment URL.
Returns:
The stored URL or null if not stored.

put

public java.net.URL put(java.net.URL url)
                 throws java.lang.Exception
Description copied from interface: DeploymentStore (src)
Put a deployment URL into storage. This will cause the data associated with the given URL to be downloaded.

If there is already a stored URL it will be overwritten.

Specified by:
put in interface DeploymentStore (src)
Parameters:
url - The original deployment URL.
Returns:
The stored URL.
Throws:
java.lang.Exception - Failed to put deployment URL into the store.

copyURL

protected void copyURL(java.net.URL source,
                       java.io.File dest)
                throws java.io.IOException
Copy the data at the given source URL to the given file.

Throws:
java.io.IOException

readMap

protected java.util.Map readMap()
                         throws java.lang.ClassNotFoundException,
                                java.io.IOException
Read the url map from serialized state.

Throws:
java.lang.ClassNotFoundException
java.io.IOException

writeMap

protected void writeMap()
                 throws java.io.IOException
Write the url map to serialized state.

Throws:
java.io.IOException

createService

protected void createService()
                      throws java.lang.Exception
Setup the url map.

Overrides:
createService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception