|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.perforce.p4java.server.ServerFactory
public class ServerFactory
The main P4Java server factory class. This class is used to obtain an IServer interface onto a particular Perforce server using a specific (or default) protocol. Usage is described below with the getServer method.
Field Summary | |
---|---|
static String |
DEFAULT_PROTOCOL_NAME
Default protocol name, i.e. |
static String |
DEFAULT_PROTOCOL_SPEC
The pseudo-protocol used in URIs to signal that the factory should make its own decision about what protocol and server to use. |
static String |
DEFAULT_SSL_PROTOCOL_NAME
Default SSL protocol name, i.e. |
static String |
TRACE_PREFIX
|
static String |
ZEROCONF_CLASS_NAME
|
Constructor Summary | |
---|---|
ServerFactory()
|
Method Summary | |
---|---|
static List<IServerImplMetadata> |
getAvailableImplementationMetadata()
Return a non-null list of implementation metadata about available IServer implementations. |
static IOptionsServer |
getOptionsServer(String serverUriString,
Properties props)
Return an IOptionsServer onto an underlying Perforce server at the host address specified by serverUriString using the protocol implementation and passed-in properties and a default UsageOptions object. |
static IOptionsServer |
getOptionsServer(String serverUriString,
Properties props,
UsageOptions opts)
Return an IOptionsServer interface onto an underlying Perforce server at the host address specified by serverUriString using the protocol implementation and passed-in properties and usage options. |
static ISystemFileCommandsHelper |
getRpcFileSystemHelper()
Return the current SystemFileCommands helper, if any. |
static IServer |
getServer(String serverUriString,
Properties props)
Return an IServer interface onto an underlying Perforce server at the host address specified by serverUriString using the protocol implementation and passed-in properties. |
static IServer |
getServer(URI serverUrl,
Properties props)
Deprecated. as of the 2009.2 release, use the getServer(String, Properties) method due to that Java's URI class does not accept hostnames with anything other than alphanumeric characters: even common hostnames like "perforce_p" will fail, often silently. |
static List<ZeroconfServerInfo> |
getZeroconfServers()
Deprecated. As of release 2013.1, ZeroConf is no longer supported by the Perforce server 2013.1. |
static boolean |
isZeroConfAvailable()
Deprecated. As of release 2013.1, ZeroConf is no longer supported by the Perforce server 2013.1. |
static void |
setRpcFileSystemHelper(ISystemFileCommandsHelper fsCmdHelper)
Register an ISystemFileCommandsHelper for the RPC implementations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TRACE_PREFIX
public static final String DEFAULT_PROTOCOL_SPEC
public static final String DEFAULT_PROTOCOL_NAME
public static final String DEFAULT_SSL_PROTOCOL_NAME
public static final String ZEROCONF_CLASS_NAME
Constructor Detail |
---|
public ServerFactory()
Method Detail |
---|
public static List<IServerImplMetadata> getAvailableImplementationMetadata()
public static IServer getServer(String serverUriString, Properties props) throws URISyntaxException, ConnectionException, NoSuchObjectException, ConfigException, ResourceException
The format of the server URI string is protocol + "://" + hostaddr [+ ":" + port] [+ queryString], e.g. "p4java://server.perforce.com:1666" or "p4java://192.168.1.12:999" or "p4jrpc://play.perforce.com:1199?progName=p4javaTest21&progVersion=Alpha203B". The protocol, port, and hostaddr fields can't be missing, but the port and hostaddr fields can be anything acceptable to the protocol, e.g. typically something like an IP address or hostname coupled with a port number.
The protocol part specifies which network implementation to use; the value "p4java" (DEFAULT_PROTOCOL_NAME) will tell the factory to use the default protocol, the details of which are not spelled out here, and which should always be used unless you have good reason to use an alternative (other protocol part values are possible, but should not generally be used unless suggested by Perforce support staff).
To connect to an SSL-enabled Perforce server, use one of the SSL protocols defined in the IServerAddress.Protocol enum (i.e. "p4javassl", "p4rpcssl" or "p4jrpcntsssl").
For advanced users, the optional queryString part can be used to set P4Java properties from the URI; these override any correspondingly-named properties sent programmatically through the props parameter (see next paragraph). These URI query strings are not interpreted, but are simply put as-is into the properties passed to the individual server implementation class. Note: this method does not do any query string replacement of things like %20 to spaces, etc. (this really isn't needed here as the query parts are passed as-is to the underlying implementation(s)).
The props argument can be used to pass in any protocol-specific properties; these are typically described in usage or implementation notes supplied elsewhere, and are not typically used by end-users.
IServer objects returned by this method may have been retrieved from a cache of previously-used objects, but they are guaranteed to be ready for use by the consumer, and to be for that consumer's exclusive use only.
serverUriString
- non-null server address in URI form.props
- protocol-specific properties; may be null
URISyntaxException
- if the passed-in URI string does not conform to
the Perforce URI specs detailed above.
ConnectionException
- if the factory is unable to connect to the server
named by serverUrl
NoSuchObjectException
- if no implementation class can be found for
the protocol specified in the passed-in URI protocol (scheme part);
ConfigException
- if the underlying protocol supplier detects a misconfiguration
ResourceException
- if the factory does not have the resources available to
service the requestpublic static IOptionsServer getOptionsServer(String serverUriString, Properties props) throws URISyntaxException, ConnectionException, NoSuchObjectException, ConfigException, ResourceException
Basically a convenience wrapper for calling the main getOptionsServer method with a null UsageOptions argument -- see that method's Javadoc for full documentation.
serverUriString
- non-null server address in URI form.props
- protocol-specific properties; may be null
URISyntaxException
- if the passed-in URI string does not conform to
the Perforce URI specs detailed above.
ConnectionException
- if the factory is unable to connect to the server
named by serverUrl
NoSuchObjectException
- if no implementation class can be found for
the protocol specified in the passed-in URI protocol (scheme part);
ConfigException
- if the underlying protocol supplier detects a misconfiguration
ResourceException
- if the factory does not have the resources available to
service the requestpublic static IOptionsServer getOptionsServer(String serverUriString, Properties props, UsageOptions opts) throws URISyntaxException, ConnectionException, NoSuchObjectException, ConfigException, ResourceException
The format of the server URI string is protocol + "://" + hostaddr [+ ":" + port] [+ queryString], e.g. "p4java://server.perforce.com:1666" or "p4java://192.168.1.12:999" or "p4java://play.perforce.com:1199?progName=p4javaTest21&progVersion=Alpha203B". The protocol, port, and hostaddr fields can't be missing, but the port and hostaddr fields can be anything acceptable to the protocol, e.g. typically something like an IP address or hostname coupled with a port number.
The protocol part specifies which network implementation to use; the value "p4java" (DEFAULT_PROTOCOL_NAME) will tell the factory to use the default protocol, the details of which are not spelled out here, and which should always be used unless you have good reason to use an alternative (other protocol part values are possible, but should not generally be used unless suggested by Perforce support staff).
To connect to an SSL-enabled Perforce server, use one of the SSL protocols defined in the IServerAddress.Protocol enum (i.e. "p4javassl", "p4rpcssl" or "p4jrpcntsssl").
For advanced users, the optional queryString part can be used to set P4Java properties from the URI; these override any correspondingly-named properties sent programmatically through the props parameter (see next paragraph). These URI query strings are not interpreted, but are simply put as-is into the properties passed to the individual server implementation class. Note: this method does not do any query string replacement of things like %20 to spaces, etc. (this really isn't needed here as the query parts are passed as-is to the underlying implementation(s)).
The props argument can be used to pass in any protocol-specific properties; these are typically described in usage or implementation notes supplied elsewhere, and are not typically used by end-users.
IServer objects returned by this method may have been retrieved from a cache of previously-used objects, but they are guaranteed to be ready for use by the consumer, and to be for that consumer's exclusive use only.
serverUriString
- non-null server address in URI form.props
- protocol-specific properties; may be null.opts
- UsageOptions object to be associated with the new server object
specifying the server's usage options; if null, a new usage options object
is constructed using the default UsageOptions constructor and associated
default values using the passed-in properties object (if not null); this is
then associated with the new server object.
URISyntaxException
- if the passed-in URI string does not conform to
the Perforce URI specs detailed above.
ConnectionException
- if the factory is unable to connect to the server
named by serverUrl
NoSuchObjectException
- if no implementation class can be found for
the protocol specified in the passed-in URI protocol (scheme part);
ConfigException
- if the underlying protocol supplier detects a misconfiguration
ResourceException
- if the factory does not have the resources available to
service the request@Deprecated public static IServer getServer(URI serverUrl, Properties props) throws ConnectionException, NoSuchObjectException, ConfigException, ResourceException, URISyntaxException
serverUrl
- non-null server URI in the format described aboveprops
- protocol-specific properties; may be null
ConnectionException
- if the factory is unable to connect to the server
named by serverUrl
NoSuchObjectException
- if no implementation class can be found for
the protocol specified in the passed-in URI protocol (scheme part);
ConfigException
- if the underlying protocol supplier detects a misconfiguration
ResourceException
- if the factory does not have the resources available to
service the request
URISyntaxException
- if the passed-in URI is malformed.public static void setRpcFileSystemHelper(ISystemFileCommandsHelper fsCmdHelper)
Helper classes are needed for certain hosted implementations and for some JDK 5 installations, and are shared across an entire instance of P4Java. Please do not register a helper class unless you know what you're doing and you're OK with the dire consequences of getting a helper class implementation wrong.
Note that if the fsCmdHelper parameter is null, the default internal implementation will be used, which is usually fine for JDK 6 systems.
fsCmdHelper
- file helper interface implementation; if null, use the
JVM default implementation(s).ISystemFileCommandsHelper
public static ISystemFileCommandsHelper getRpcFileSystemHelper()
@Deprecated public static List<ZeroconfServerInfo> getZeroconfServers() throws ConfigException
This method uses the javax.jmdns JmDNS package (available through Sourceforge, etc.), and that package must be visible to the current class loader for this method to work. If the server factory is unable to find a suitable JmDNS package using the current class loader, this method will throw a ConfigException. The JmDNS package is not supplied with P4Java and must be downloaded and installed separately.
Note that zeroconf discovery can take some time (in the order of tens of seconds in some cases), and only works for local subnets, so the first call to this method may return nothing even though there's a suitable server out there on the same subnet. Subsequent calls are usually more successful.
Note also that we recommend you call the associated isZeroconfAvailable method first to check whether zeroconf is even available for this P4Java instance -- this can save a lot of overhead and / or annoying log messages.
ConfigException
- if the server factory can't load and use a suitable
JmDNS zeroconf package using the current class loader.@Deprecated public static boolean isZeroConfAvailable()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |