com.perforce.p4java.ant.tasks
Class ServerTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.perforce.p4java.ant.tasks.PerforceTask
              extended by com.perforce.p4java.ant.tasks.ServerTask
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
ClientTask, CounterTask, JobTask

public abstract class ServerTask
extends PerforceTask

Base class for Perforce server specific Ant tasks. It initializes an instance of the Perforce server.

See Also:
PerforceTask

Nested Class Summary
 class ServerTask.GlobalOption
          This inner class is used for handling nested "globaloption" elements.
 
Nested classes/interfaces inherited from class com.perforce.p4java.ant.tasks.PerforceTask
PerforceTask.Field, PerforceTask.File
 
Field Summary
protected  boolean allHosts
          If true, corresponds to -a flag on login.
protected  Options commandOptions
          Options for Perforce command.
protected  java.util.List<ServerTask.GlobalOption> globaloptions
          Collection of globaloptions (name-value pairs) contained in the "globaloption" nested elements.
protected  java.lang.String hostName
          If not null, specifies the host name used by the server's commands.
static java.lang.String P4_SERVER_PROTOCOL_PROPERTIES_FILE
          Default Perforce server protocol-specific properties file name.
static java.lang.String P4_SERVER_USAGE_PROPERTIES_FILE
          Default Perforce server usage properties file name.
protected  IOptionsServer p4Server
          Perforce server.
protected  java.lang.String programName
          If not null, will be used to identify the P4Java application's program name to the Perforce server.
protected  java.lang.String programVersion
          If not null, will be used to identify the P4Java application's program version to the Perforce server.
protected  java.lang.String protocolPropertiesFile
          Perforce server protocol-specific properties file.
protected  java.util.Properties protocolProps
          Protocol-specific properties.
protected  java.lang.String textLanguage
          If not null, use this field to tell the server which language to use in text messages it sends back to the client.
protected  java.lang.String unsetClientName
          If set, this will be used as the name of the client when no client has actually been explicitly set for the associated server(s).
protected  java.lang.String unsetUserName
          What will be sent to the Perforce server with each command as the user name if no user name has been explicitly set for servers associated with this UsageOption.
protected  java.lang.String usagePropertiesFile
          Perforce server usage properties file.
protected  java.util.Properties usageProps
          Perforce server usage properties.
protected  java.lang.String workingDirectory
          If not null, this specifies the Perforce server's idea of each command's working directory for the associated server object.
 
Fields inherited from class com.perforce.p4java.ant.tasks.PerforceTask
charset, client, failOnError, fields, FILE_TOKEN_REGEX_PATTERN, fileList, files, fileSpecs, LINE_PADDING, LINE_SEPARATOR, p4Messages, passwd, port, protocol, retFileSpecs, retStatusMessage, user
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
ServerTask()
          Default constructor.
 
Method Summary
protected  void cleanupP4()
          Cleanup the Perforce server instance.
protected  void cleanupP4Server()
          Cleanup the Perforce server instance.
 ServerTask.GlobalOption createGlobalOption()
          This method is called by an Ant factory method to instantiates a collection of "globaloption" nested elements.
protected  java.util.Properties getGlobalOptions()
          Combine all of the globaloptions specified by the "globaloption" nested elements.
 IOptionsServer getP4Server()
          Gets the p4 server.
protected  void initP4()
          Initialize the Perforce server instance.
protected  void initP4Server()
          Initialize an instance of the Perforce server from the factory using the specified protocol, server port, protocol specific properties and usage options.
protected  void initP4ServerOptions()
          Initialize the Perforce server options, such as protocol-specific properties and usage options.
 void setAllHosts(boolean allHosts)
          Sets the all hosts.
 void setHostName(java.lang.String hostName)
          Sets the host name.
 void setP4Server(IOptionsServer p4Server)
          Sets the p4 server.
 void setProgramName(java.lang.String programName)
          Sets the program name.
 void setProgramVersion(java.lang.String programVersion)
          Sets the program version.
 void setProtocolPropertiesFile(java.lang.String protocolPropertiesFile)
          Sets the protocol properties file.
 void setProtocolProps(java.util.Properties protocolProps)
          Sets the protocol props.
 void setTextLanguage(java.lang.String textLanguage)
          Sets the text language.
 void setUnsetClientName(java.lang.String unsetClientName)
          Sets the unset client name.
 void setUnsetUserName(java.lang.String unsetUserName)
          Sets the unset user name.
 void setUsagePropertiesFile(java.lang.String usagePropertiesFile)
          Sets the usage properties file.
 void setUsageProps(java.util.Properties usageProps)
          Sets the usage props.
 void setWorkingDirectory(java.lang.String workingDirectory)
          Sets the working directory.
 
Methods inherited from class com.perforce.p4java.ant.tasks.PerforceTask
addFileset, createField, createFile, execP4Command, execute, getFields, getFiles, getFileSpecs, getRetFileSpecs, getRetStatusMessage, init, isEmpty, logChangelistSummaries, logChangelistSummary, logExtendedFileSpec, logExtendedFileSpecs, logFileDiff, logFileDiffs, logFileLineMatch, logFileLineMatches, logFileSpec, logFileSpecs, logFix, logFixes, logJob, logJobs, parseChangelist, setCharset, setClient, setFailOnError, setFiles, setPasswd, setPort, setProtocol, setUser
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

globaloptions

protected java.util.List<ServerTask.GlobalOption> globaloptions
Collection of globaloptions (name-value pairs) contained in the "globaloption" nested elements.


P4_SERVER_PROTOCOL_PROPERTIES_FILE

public static final java.lang.String P4_SERVER_PROTOCOL_PROPERTIES_FILE
Default Perforce server protocol-specific properties file name.

See Also:
Constant Field Values

P4_SERVER_USAGE_PROPERTIES_FILE

public static final java.lang.String P4_SERVER_USAGE_PROPERTIES_FILE
Default Perforce server usage properties file name.

See Also:
Constant Field Values

p4Server

protected IOptionsServer p4Server
Perforce server.


protocolPropertiesFile

protected java.lang.String protocolPropertiesFile
Perforce server protocol-specific properties file.


usagePropertiesFile

protected java.lang.String usagePropertiesFile
Perforce server usage properties file.


protocolProps

protected java.util.Properties protocolProps
Protocol-specific properties. Note that these are typically described in usage or implementation notes supplied elsewhere, and are not typically used by end-users.


usageProps

protected java.util.Properties usageProps
Perforce server usage properties. Note that these properties are potentially accessed for each command.


programName

protected java.lang.String programName
If not null, will be used to identify the P4Java application's program name to the Perforce server.


programVersion

protected java.lang.String programVersion
If not null, will be used to identify the P4Java application's program version to the Perforce server.


workingDirectory

protected java.lang.String workingDirectory
If not null, this specifies the Perforce server's idea of each command's working directory for the associated server object. Corresponds to the p4 -d usage option.

This affects all commands on the associated server from this point on, and the passed-in path should be both absolute and valid, otherwise strange errors may appear from the server. If workingDirectory is null, the Java VM's actual current working directory at the time this object is constructed is used instead (which is almost always a safe option unless you're using Perforce alt roots).

Note: no checking is done at any time for correctness (or otherwise) of the workingDirectory option.


hostName

protected java.lang.String hostName
If not null, specifies the host name used by the server's commands. Set to null by the default constructor. Corresponds to the p4 -H usage option. HostName is not live -- that is, unlike many other UsageOption fields, its value is only read once when the associated server is created; subsequent changes will not be reflected in the associated server.


textLanguage

protected java.lang.String textLanguage
If not null, use this field to tell the server which language to use in text messages it sends back to the client. Corresponds to the p4 -L option, with the same limitations. Set to null by the default constructor.


unsetUserName

protected java.lang.String unsetUserName
What will be sent to the Perforce server with each command as the user name if no user name has been explicitly set for servers associated with this UsageOption.


unsetClientName

protected java.lang.String unsetClientName
If set, this will be used as the name of the client when no client has actually been explicitly set for the associated server(s).


allHosts

protected boolean allHosts
If true, corresponds to -a flag on login.


commandOptions

protected Options commandOptions
Options for Perforce command.

Constructor Detail

ServerTask

public ServerTask()
Default constructor.

Method Detail

createGlobalOption

public ServerTask.GlobalOption createGlobalOption()
This method is called by an Ant factory method to instantiates a collection of "globaloption" nested elements. It saves the reference to the collection and returns it to Ant Core.

Returns:
the globaloption

getP4Server

public IOptionsServer getP4Server()
Gets the p4 server.

Returns:
the p4 server

setP4Server

public void setP4Server(IOptionsServer p4Server)
Sets the p4 server.

Parameters:
p4Server - the new p4 server

setProtocolPropertiesFile

public void setProtocolPropertiesFile(java.lang.String protocolPropertiesFile)
Sets the protocol properties file.

Parameters:
protocolPropertiesFile - the new protocol properties file

setUsagePropertiesFile

public void setUsagePropertiesFile(java.lang.String usagePropertiesFile)
Sets the usage properties file.

Parameters:
usagePropertiesFile - the new usage properties file

setProtocolProps

public void setProtocolProps(java.util.Properties protocolProps)
Sets the protocol props.

Parameters:
protocolProps - the new protocol props

setUsageProps

public void setUsageProps(java.util.Properties usageProps)
Sets the usage props.

Parameters:
usageProps - the new usage props

setProgramName

public void setProgramName(java.lang.String programName)
Sets the program name.

Parameters:
programName - the new program name

setProgramVersion

public void setProgramVersion(java.lang.String programVersion)
Sets the program version.

Parameters:
programVersion - the new program version

setWorkingDirectory

public void setWorkingDirectory(java.lang.String workingDirectory)
Sets the working directory.

Parameters:
workingDirectory - the new working directory

setHostName

public void setHostName(java.lang.String hostName)
Sets the host name.

Parameters:
hostName - the new host name

setTextLanguage

public void setTextLanguage(java.lang.String textLanguage)
Sets the text language.

Parameters:
textLanguage - the new text language

setUnsetUserName

public void setUnsetUserName(java.lang.String unsetUserName)
Sets the unset user name.

Parameters:
unsetUserName - the new unset user name

setUnsetClientName

public void setUnsetClientName(java.lang.String unsetClientName)
Sets the unset client name.

Parameters:
unsetClientName - the new unset client name

setAllHosts

public void setAllHosts(boolean allHosts)
Sets the all hosts.

Parameters:
allHosts - the new all hosts

initP4Server

protected void initP4Server()
Initialize an instance of the Perforce server from the factory using the specified protocol, server port, protocol specific properties and usage options. Register callback on the server. Connect to server; set the user (if present) to server and login to the server with the user's password (if present).


initP4ServerOptions

protected void initP4ServerOptions()
Initialize the Perforce server options, such as protocol-specific properties and usage options.


cleanupP4Server

protected void cleanupP4Server()
Cleanup the Perforce server instance. Logout the user and disconnect from the Perforce server. Also, set the server to null.


initP4

protected void initP4()
               throws org.apache.tools.ant.BuildException
Initialize the Perforce server instance.

Specified by:
initP4 in class PerforceTask
Throws:
org.apache.tools.ant.BuildException - the build exception
See Also:
PerforceTask.initP4()

cleanupP4

protected void cleanupP4()
                  throws org.apache.tools.ant.BuildException
Cleanup the Perforce server instance.

Specified by:
cleanupP4 in class PerforceTask
Throws:
org.apache.tools.ant.BuildException - the build exception
See Also:
PerforceTask.cleanupP4()

getGlobalOptions

protected java.util.Properties getGlobalOptions()
Combine all of the globaloptions specified by the "globaloption" nested elements.

Returns:
the properties


Copyright (c) 2010 Perforce Software. All rights reserved.