Apache Tomcat 7.0.42

## org.apache.catalina.ha.deploy
Class FarmWarDeployer

    java.lang.Object
      org.apache.catalina.ha.ClusterListener
          org.apache.catalina.ha.deploy.FarmWarDeployer

All Implemented Interfaces:
  ClusterDeployer, FileChangeListener, ChannelListener

    public class FarmWarDeployer

extends ClusterListener
implements ClusterDeployer, FileChangeListener

A farm war deployer is a class that is able to deploy/undeploy web applications in WAR from within the cluster.

Any host can act as the admin, and will have three directories

- deployDir - the directory where we watch for changes
- applicationDir - the directory where we install applications
- tempDir - a temporaryDirectory to store binary data when downloading a war from the cluster

Currently we only support deployment of WAR files since they are easier to send across the wire.

Version:
  $Revision: 1479807 $
Author:
  Filip Hanik, Peter Rossbach

Field Summary
`protected File` `appBase` The host appBase.
`protected File` `configBase` Path where context descriptors should be deployed.
`protected String` `deployDir` Deployment directory.
`protected HashMap<String,FileMessageFactory>` `fileFactories`
`protected Host` `host` The associated host.
`protected int` `maxValidTime` The maximum valid time(in seconds) for FileMessageFactory.
`protected MBeanServer` `mBeanServer` MBean server.
`protected ObjectName` `oname` The associated deployer ObjectName.
`protected int` `processDeployFrequency` Frequency of the Farm watchDir check.
`protected boolean` `started`
`protected String` `tempDir` Temporary directory.
`protected String` `watchDir` Watch directory.
`protected boolean` `watchEnabled`
`protected WarWatcher` `watcher`

Fields inherited from class org.apache.catalina.ha.ClusterListener
`cluster`

Constructor Summary
`FarmWarDeployer()`

Method Summary
`boolean` `accept(ClusterMessage msg)` Before the cluster invokes messageReceived the cluster will ask the receiver to accept or decline the message, In the future, when messages get big, the accept method will only take a message header
`protected void` `addServiced(String name)` Invoke the check method on the deployer.
`void` `backgroundProcess()` call from container Background Process
`protected void` `check(String name)` Invoke the check method on the deployer.
`void` `cleanDeployDir()`
`protected boolean` `copy(File from, File to)` Copy a file to the specified temp directory.
`boolean` `equals(Object listener)`
`void` `fileModified(File newWar)`
`void` `fileRemoved(File removeWar)`
`protected File` `getAppBase()` Return a File object representing the "application root" directory for our associated Host.
`String` `getDeployDir()`
`File` `getDeployDirFile()`
`FileMessageFactory` `getFactory(FileMessage msg)` create factory for all transported war files
`String` `getInfo()` Return descriptive information about this deployer implementation and the corresponding version number, in the format `<description>/<version>`.
`int` `getMaxValidTime()`
`int` `getProcessDeployFrequency()` Return the frequency of watcher checks.
`String` `getTempDir()`
`File` `getTempDirFile()`
`String` `getWatchDir()`
`File` `getWatchDirFile()`
`boolean` `getWatchEnabled()`
`int` `hashCode()`
`void` `install(String contextName, File webapp)` Install a new web application, whose web application archive is at the specified URL, into this container and all the other members of the cluster with the specified context name.
`protected boolean` `isServiced(String name)` Invoke the check method on the deployer.
`boolean` `isWatchEnabled()`
`void` `messageReceived(ClusterMessage msg)` Callback from the cluster, when a message is received, The cluster will broadcast it invoking the messageReceived on the receiver.
`protected void` `remove(String contextName)` Invoke the remove method on the deployer.
`void` `remove(String contextName, boolean undeploy)` Remove an existing web application, attached to the specified context name.
`void` `removeFactory(FileMessage msg)` Remove file (war) from messages)
`protected void` `removeInvalidFileFactories()`
`protected void` `removeServiced(String name)` Invoke the check method on the deployer.
`void` `setDeployDir(String deployDir)`
`void` `setMaxValidTime(int maxValidTime)`
`void` `setProcessDeployFrequency(int processExpiresFrequency)` Set the watcher checks frequency.
`void` `setTempDir(String tempDir)`
`void` `setWatchDir(String watchDir)`
`void` `setWatchEnabled(boolean watchEnabled)`
`void` `start()` Start the cluster deployer, the owning container will invoke this
`void` `stop()` Stops the cluster deployer, the owning container will invoke this
`protected void` `undeployDir(File dir)` Delete the specified directory, including all of its contents and subdirectories recursively.

Methods inherited from class org.apache.catalina.ha.ClusterListener
`accept, getCluster, messageReceived, setCluster`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.catalina.ha.ClusterDeployer
`getCluster, setCluster`

Methods inherited from interface org.apache.catalina.tribes.ChannelListener
`accept, messageReceived`

Field Detail

### started

    protected boolean started

### fileFactories

    protected HashMap<String,FileMessageFactory> fileFactories

### deployDir

    protected String deployDir

  Deployment directory.

### tempDir

    protected String tempDir

  Temporary directory.

### watchDir

    protected String watchDir

  Watch directory.

### watchEnabled

    protected boolean watchEnabled

### watcher

    protected WarWatcher watcher

### processDeployFrequency

    protected int processDeployFrequency

  Frequency of the Farm watchDir check. Cluster wide deployment will be done once for the specified amount of backgrondProcess calls (ie, the lower the amount, the most often the checks will occur).

### configBase

    protected File configBase

  Path where context descriptors should be deployed.

### host

    protected Host host

  The associated host.

### appBase

    protected File appBase

  The host appBase.

### mBeanServer

    protected MBeanServer mBeanServer

  MBean server.

### oname

    protected ObjectName oname

  The associated deployer ObjectName.

### maxValidTime

    protected int maxValidTime

  The maximum valid time(in seconds) for FileMessageFactory.

Constructor Detail

### FarmWarDeployer

    public FarmWarDeployer()

Method Detail

### getInfo

    public String getInfo()

  Return descriptive information about this deployer implementation and the corresponding version number, in the format `<description>/<version>`.

### start

    public void start()
               throws Exception

  Description copied from interface: `ClusterDeployer`
  Start the cluster deployer, the owning container will invoke this

  Specified by:
    `start` in interface `ClusterDeployer`
  Throws:
    `Exception` - - if failure to start cluster

### stop

    public void stop()
              throws LifecycleException

  Description copied from interface: `ClusterDeployer`
  Stops the cluster deployer, the owning container will invoke this

  Specified by:
    `stop` in interface `ClusterDeployer`
  Throws:
    `LifecycleException`

### cleanDeployDir

    public void cleanDeployDir()

### messageReceived

    public void messageReceived(ClusterMessage msg)

  Callback from the cluster, when a message is received, The cluster will broadcast it invoking the messageReceived on the receiver.

  Specified by:
    `messageReceived` in class `ClusterListener`
  Parameters:
    `msg` - ClusterMessage - the message received from the cluster

### getFactory

    public FileMessageFactory getFactory(FileMessage msg)
                                  throws FileNotFoundException,
                                         IOException

  create factory for all transported war files

  Parameters:
    `msg` -
  Returns:
    Factory for all app message (war files)
  Throws:
    `FileNotFoundException`
    `IOException`

### removeFactory

    public void removeFactory(FileMessage msg)

  Remove file (war) from messages)

  Parameters:
    `msg` -

### accept

    public boolean accept(ClusterMessage msg)

  Before the cluster invokes messageReceived the cluster will ask the receiver to accept or decline the message, In the future, when messages get big, the accept method will only take a message header

  Specified by:
    `accept` in class `ClusterListener`
  Parameters:
    `msg` - ClusterMessage
  Returns:
    boolean - returns true to indicate that messageReceived should be invoked. If false is returned, the messageReceived method will not be invoked.

### install

    public void install(String contextName,
                        File webapp)
                 throws IOException

  Install a new web application, whose web application archive is at the specified URL, into this container and all the other members of the cluster with the specified context name.

  If this application is successfully installed locally, a ContainerEvent of type `INSTALL_EVENT` will be sent to all registered listeners, with the newly created `Context` as an argument.

  Specified by:
    `install` in interface `ClusterDeployer`
  Parameters:
    `contextName` - The context name to which this application should be installed (must be unique)
    `webapp` - A WAR file or unpacked directory structure containing the web application to be installed
  Throws:
    `IllegalArgumentException` - if the specified context name is malformed
    `IllegalStateException` - if the specified context name is already deployed
    `IOException` - if an input/output error was encountered during installation

### remove

    public void remove(String contextName,
                       boolean undeploy)
                throws IOException

  Remove an existing web application, attached to the specified context name. If this application is successfully removed, a ContainerEvent of type `REMOVE_EVENT` will be sent to all registered listeners, with the removed `Context` as an argument. Deletes the web application war file and/or directory if they exist in the Host's appBase.

  Specified by:
    `remove` in interface `ClusterDeployer`
  Parameters:
    `contextName` - The context name of the application to be removed
    `undeploy` - boolean flag to remove web application from server
  Throws:
    `IllegalArgumentException` - if the specified context name is malformed
    `IllegalArgumentException` - if the specified context name does not identify a currently installed web application
    `IOException` - if an input/output error occurs during removal

### fileModified

    public void fileModified(File newWar)

  Specified by:
    `fileModified` in interface `FileChangeListener`

### fileRemoved

    public void fileRemoved(File removeWar)

  Specified by:
    `fileRemoved` in interface `FileChangeListener`

### getAppBase

    protected File getAppBase()

  Return a File object representing the "application root" directory for our associated Host.

### remove

    protected void remove(String contextName)
                   throws Exception

  Invoke the remove method on the deployer.

  Throws:
    `Exception`

### undeployDir

    protected void undeployDir(File dir)

  Delete the specified directory, including all of its contents and subdirectories recursively.

  Parameters:
    `dir` - File object representing the directory to be deleted

### backgroundProcess

    public void backgroundProcess()

  Description copied from interface: `ClusterDeployer`
  call from container Background Process

  Specified by:
    `backgroundProcess` in interface `ClusterDeployer`

### check

    protected void check(String name)
                  throws Exception

  Invoke the check method on the deployer.

  Throws:
    `Exception`

### isServiced

    protected boolean isServiced(String name)
                          throws Exception

  Invoke the check method on the deployer.

  Throws:
    `Exception`

### addServiced

    protected void addServiced(String name)
                        throws Exception

  Invoke the check method on the deployer.

  Throws:
    `Exception`

### removeServiced

    protected void removeServiced(String name)
                           throws Exception

  Invoke the check method on the deployer.

  Throws:
    `Exception`

### equals

    public boolean equals(Object listener)

  Specified by:
    `equals` in interface `ChannelListener`
  Overrides:
    `equals` in class `ClusterListener`
  Parameters:
    `listener` - Object
  Returns:
    boolean
  See Also:
    `Object.equals(Object)`

### hashCode

    public int hashCode()

  Specified by:
    `hashCode` in interface `ChannelListener`
  Overrides:
    `hashCode` in class `ClusterListener`
  Returns:
    int
  See Also:
    `Object.hashCode()`

### getDeployDir

    public String getDeployDir()

### getDeployDirFile

    public File getDeployDirFile()

### setDeployDir

    public void setDeployDir(String deployDir)

### getTempDir

    public String getTempDir()

### getTempDirFile

    public File getTempDirFile()

### setTempDir

    public void setTempDir(String tempDir)

### getWatchDir

    public String getWatchDir()

### getWatchDirFile

    public File getWatchDirFile()

### setWatchDir

    public void setWatchDir(String watchDir)

### isWatchEnabled

    public boolean isWatchEnabled()

### getWatchEnabled

    public boolean getWatchEnabled()

### setWatchEnabled

    public void setWatchEnabled(boolean watchEnabled)

### getProcessDeployFrequency

    public int getProcessDeployFrequency()

  Return the frequency of watcher checks.

### setProcessDeployFrequency

    public void setProcessDeployFrequency(int processExpiresFrequency)

  Set the watcher checks frequency.

  Parameters:
    `processExpiresFrequency` - the new manager checks frequency

### getMaxValidTime

    public int getMaxValidTime()

### setMaxValidTime

    public void setMaxValidTime(int maxValidTime)

### copy

    protected boolean copy(File from,
                           File to)

  Copy a file to the specified temp directory.

  Parameters:
    `from` - copy from temp
    `to` - to host appBase directory
  Returns:
    true, copy successful

### removeInvalidFileFactories

    protected void removeInvalidFileFactories()

Apache Tomcat 7.0.42

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.