org.jboss.deployment.cache
Class FileDeploymentStore

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended byorg.jboss.system.ServiceMBeanSupport
          extended byorg.jboss.deployment.cache.FileDeploymentStore
All Implemented Interfaces:
DeploymentStore, DeploymentStoreMBean, FileDeploymentStoreMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, Service, ServiceMBean

public class FileDeploymentStore
extends ServiceMBeanSupport
implements DeploymentStore, FileDeploymentStoreMBean

A local file based DeploymentStore.

Version:
$Revision: 1.3.4.1 $
Author:
Jason Dillon

Field Summary
protected  File dir
          The local directory where cache data will be stored.
protected  File mapFile
          The file where the mapping is located.
protected  Map urlMap
          The URL to local file mapping.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean
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(URL source, File dest)
          Copy the data at the given source URL to the given file.
protected  void createService()
          Setup the url map.
 URL get(URL url)
          Get the stored URL for the given deployment URL.
 File getDirectory()
          Returns the local directory where cache data is stored.
 String getDirectoryName()
          Get the name of the local directory where cache data is stored.
protected  URL getURLFromFile(File file)
           
 URL put(URL url)
          Put a deployment URL into storage.
protected  Map readMap()
          Read the url map from serialized state.
 void setDirectory(File dir)
          Set the local directory where cache data will be stored.
 void setDirectoryName(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
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
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

dir

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


mapFile

protected File mapFile
The file where the mapping is located.


urlMap

protected Map urlMap
The URL to local file mapping.

Constructor Detail

FileDeploymentStore

public FileDeploymentStore()
Method Detail

setDirectory

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

Specified by:
setDirectory in interface FileDeploymentStoreMBean
Parameters:
dir - The local directory where cache data will be stored.
Throws:
IOException - File not found, not a directory, can't write...

getDirectory

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

Specified by:
getDirectory in interface FileDeploymentStoreMBean
Returns:
The local directory where cache data is stored.

setDirectoryName

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

Invokes setDirectory(java.io.File).

Specified by:
setDirectoryName in interface FileDeploymentStoreMBean
Parameters:
dirname - The name of the local directory where cache data will be stored.
Throws:
IOException - File not found, not a directory, can't write...

getDirectoryName

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

Specified by:
getDirectoryName in interface FileDeploymentStoreMBean
Returns:
The name of the local directory where cache data is stored.

getURLFromFile

protected URL getURLFromFile(File file)

get

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

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

put

public URL put(URL url)
        throws Exception
Description copied from interface: DeploymentStore
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
Parameters:
url - The original deployment URL.
Returns:
The stored URL.
Throws:
Exception - Failed to put deployment URL into the store.

copyURL

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

Throws:
IOException

readMap

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

Throws:
ClassNotFoundException
IOException

writeMap

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

Throws:
IOException

createService

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

Overrides:
createService in class ServiceMBeanSupport
Throws:
Exception


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.