|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.force.sdk.connector.ForceServiceConnector
public class ForceServiceConnector
A connector to the Force.com service.
This connector will manage and provide connections to the Force.com service. It can provide the following connection types:
ForceConnectorConfig
to provide connection
properties. They can handle ForceConnectorConfig
s from the following
sources (Note that sources will be checked in this order):
ForceConnectorConfig
ForceConnectorUtils.loadConnectorPropsFromName(String)
)ForceConnectorConfig
stored in the connector's ThreadLocal
cacheForceConnectorConfig
objects both in a ThreadLocalCache
and an in memory cache. The ThreadLocalCache
is directly controlled by the caller. The in memory
cache is controlled internally by the connector. By default, a connector will cache a ForceConnectorConfig
in memory whenever it constructs a connection. However, this can be turned off by the caller.
A ForceServiceConnector
provides several additional features beyond the traditional
Force.com API Connector
. Namely:
ForceConnectorConfig.setAuthEndpoint(String)
and ForceConnectorUtils.buildForceApiEndpoint(String)
)
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.sforce.ws.SessionRenewer |
---|
com.sforce.ws.SessionRenewer.SessionRenewalHeader |
Field Summary | |
---|---|
static QName |
SESSION_HEADER_QNAME
The qualified name for session SOAP requests. |
Fields inherited from interface com.force.sdk.connector.ForceConnector |
---|
PROXY_HOST, PROXY_PORT |
Constructor Summary | |
---|---|
ForceServiceConnector()
Initializes a ForceServiceConnector with no ForceConnectorConfig source. |
|
ForceServiceConnector(ForceConnectorConfig config)
Initializes a ForceServiceConnector which will use the given ForceConnectorConfig
to get Force.com connections. |
|
ForceServiceConnector(String connectionName)
Initializes a ForceServiceConnector with a named ForceConnectorConfig source . |
Method Summary | |
---|---|
void |
close()
Clears this ForceServiceConnector 's local state. |
com.sforce.async.BulkConnection |
getBulkConnection()
Returns a Force.com API BulkConnection . |
com.sforce.soap.partner.PartnerConnection |
getConnection()
Returns a Force.com API PartnerConnection . |
String |
getConnectionName()
Returns the named ForceConnectorConfig source in
this ForceServiceConnector . |
com.sforce.soap.metadata.MetadataConnection |
getMetadataConnection()
Returns a Force.com API MetadataConnection . |
String |
getNamespace()
Returns the namespace of the Force.com store to which this ForceServiceConnector
is getting a connection. |
static ForceConnectorConfig |
getThreadLocalConnectorConfig()
Retrieves the ForceConnectorConfig found in the
ForceServiceConnector ThreadLocal cache. |
com.sforce.ws.SessionRenewer.SessionRenewalHeader |
renewSession(com.sforce.ws.ConnectorConfig connectorConfig)
Automatically renews Force.com timed out sessions. |
void |
setClientId(String clientId)
Sets the Force.com connection client id. |
void |
setConnectionName(String connectionName)
Sets the named ForceConnectorConfig source in
this ForceServiceConnector . |
void |
setConnectorConfig(ForceConnectorConfig connectorConfig)
Sets the ForceConnectorConfig state in this ForceServiceConnector . |
void |
setSkipCache(boolean skipCache)
Indicates whether or not this ForceServiceConnector should skip
in memory ForceConnectorConfig cache reads and writes. |
static void |
setThreadLocalConnectorConfig(ForceConnectorConfig config)
Sets the ForceConnectorConfig in the ForceServiceConnector
ThreadLocal . |
void |
setTimeout(int timeout)
Sets the read timeout for all Force.com connections gotten by this ForceServiceConnector . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final QName SESSION_HEADER_QNAME
Constructor Detail |
---|
public ForceServiceConnector()
ForceServiceConnector
with no ForceConnectorConfig
source.
If using this constructor, the caller must provider a ForceConnetorConfig
source
via setters before getting a Force.com connection.
setConnectorConfig(ForceConnectorConfig)
,
setConnectionName(String)
,
setThreadLocalConnectorConfig(ForceConnectorConfig)
public ForceServiceConnector(String connectionName)
ForceServiceConnector
with a named ForceConnectorConfig
source .
connectionName
- the named ForceConnectorConfig
source from which a valid ForceConnectorConfig
can be constructed and used to get Force.com connectionsForceConnectorUtils.loadConnectorPropsFromName(String)
public ForceServiceConnector(ForceConnectorConfig config) throws com.sforce.ws.ConnectionException
ForceServiceConnector
which will use the given ForceConnectorConfig
to get Force.com connections.
config
- the ForceConnectorConfig
to be used when getting Force.com connections
IllegalArgumentException
- if the given ForceConnectorConfig
is null
com.sforce.ws.ConnectionException
- if the given ForceConnectorConfig
is incomplete (i.e.
cannot be used to get a Force.com connection)Method Detail |
---|
public static ForceConnectorConfig getThreadLocalConnectorConfig()
ForceConnectorConfig
found in the
ForceServiceConnector
ThreadLocal
cache.
ForceConnectorConfig
from the ThreadLocal
;
null
if no such ForceConnectorConfig
existspublic static void setThreadLocalConnectorConfig(ForceConnectorConfig config)
ForceConnectorConfig
in the ForceServiceConnector
ThreadLocal
.
config
- the ForceConnectorConfig
to be set in the ThreadLocal
public com.sforce.soap.partner.PartnerConnection getConnection() throws com.sforce.ws.ConnectionException
PartnerConnection
.
This connection type can be use to make SOAP API calls to the Force.com
service. The PartnerConnection
will be lazily constructed and
stored in this ForceServiceConnector
's state. This state
can be cleared with a call to close
PartnerConnection
from the ForceConnectorConfig
state found in this ForceServiceConnector
com.sforce.ws.ConnectionException
- if the ForceConnectorConfig
state cannot be found
or otherwise constructed
com.sforce.ws.ConnectionException
- if this ForceServiceConnector
cannot get a connection
to the Force.com service with its ForceConnectorConfig
staterenewSession(ConnectorConfig)
,
close()
public com.sforce.soap.metadata.MetadataConnection getMetadataConnection() throws com.sforce.ws.ConnectionException
MetadataConnection
.
This connection type can be use to make Force.com Metadata API calls to the Force.com
service. The MetadataConnection
will be lazily constructed and
stored in this ForceServiceConnector
's state. This state
can be cleared with a call to close
MetadataConnection
from the ForceConnectorConfig
state found in this ForceServiceConnector
com.sforce.ws.ConnectionException
- if the ForceConnectorConfig
state cannot be found
or otherwise constructed
com.sforce.ws.ConnectionException
- if this ForceServiceConnector
cannot get a connection
to the Force.com service with its ForceConnectorConfig
staterenewSession(ConnectorConfig)
,
close()
public com.sforce.async.BulkConnection getBulkConnection() throws com.sforce.ws.ConnectionException, com.sforce.async.AsyncApiException
BulkConnection
.
This connection type can be use to make Force.com Bulk API calls to the Force.com
service. The BulkConnection
will be lazily constructed and
stored in this ForceServiceConnector
's state. This state
can be cleared with a call to close
BulkConnection
from the ForceConnectorConfig
state found in this ForceServiceConnector
com.sforce.ws.ConnectionException
- if the ForceConnectorConfig
state cannot be found
or otherwise constructed
com.sforce.ws.ConnectionException
- if this ForceServiceConnector
cannot get a connection
to the Force.com service with its ForceConnectorConfig
state
com.sforce.async.AsyncApiException
- if this ForceServiceConnector
cannot load a BulkConnection
to the Force.com service with its ForceConnectorConfig
staterenewSession(ConnectorConfig)
,
close()
public String getNamespace() throws com.sforce.ws.ConnectionException
ForceServiceConnector
is getting a connection.
A namespace uniquely identifies a Force.com store on the Force.com service. This ForceServiceConnector
will retrieve the namespace by getting a Force.com connection with its ForceConnectorConfig
state.
null
is no such namespace exists
com.sforce.ws.ConnectionException
- if the ForceConnectorConfig
state cannot be found
or otherwise constructed
com.sforce.ws.ConnectionException
- if this ForceServiceConnector
cannot get a connection
to the Force.com service with its ForceConnectorConfig
state
com.sforce.ws.ConnectionException
- if the namespace cannot be retrieved over the Force.com connectionpublic void close()
ForceServiceConnector
's local state.
The connections gotten by a ForceServiceConnector
are lazily
constructed and stored in the ForceServiceConnector
's local state. Thus
multiple calls to get a connection will return the same connection object without
re-establishing a connection to the Force.com service. The close
method
forces this ForceServiceConnector
to re-establish a connection with the
Force.com service by clearing its local state.
getConnection()
,
getMetadataConnection()
,
getBulkConnection()
,
renewSession(ConnectorConfig)
public com.sforce.ws.SessionRenewer.SessionRenewalHeader renewSession(com.sforce.ws.ConnectorConfig connectorConfig) throws com.sforce.ws.ConnectionException
The connections gotten by a ForceServiceConnector
are lazily
constructed and stored in the ForceServiceConnector
's local state. Thus
multiple calls to get a connection will return the same connection object without
re-establishing a connection to the Force.com service. However, this presents
a problem should the Force.com session expire. In that case, stored connections
will have their session automatically renewed by the renewSession
.
renewSession
in interface com.sforce.ws.SessionRenewer
connectorConfig
- the ForceConnectorConfig
to be used to re-establish a
Force.com connection
com.sforce.ws.ConnectionException
- if the Force.com connection cannot be re-establishedgetConnection()
,
getMetadataConnection()
,
getBulkConnection()
,
close()
public void setClientId(String clientId)
The client id is a String
identifier which will be set on the Force.com
connection gotten by this ForceServiceConnector
. Note that the client
id set here will override the client id in this ForceServiceConnector
's
ForceConnectorConfig
state.
clientId
- any non null
, non empty String
that is
to be used as a Force.com connection identifierpublic String getConnectionName()
ForceConnectorConfig
source in
this ForceServiceConnector
.
A named ForceConnectorConfig
source specifies connection
properties in a named location. These properties can be used to construct
a ForceConnectorConfig
.
ForceConnectorConfig
sourceForceConnectorUtils.loadConnectorPropsFromName(String)
public void setConnectionName(String connectionName)
ForceConnectorConfig
source in
this ForceServiceConnector
.
A named ForceConnectorConfig
source specifies connection
properties in a named location. These properties can be used to construct
a ForceConnectorConfig
. Note that a named connection ForceConnectorConfig
source can be overridden by directly injecting ForceConnectorConfig
state.
connectionName
- the name of a ForceConnectorConfig
sourceForceConnectorUtils.loadConnectorPropsFromName(String)
,
setConnectorConfig(ForceConnectorConfig)
public void setConnectorConfig(ForceConnectorConfig connectorConfig)
ForceConnectorConfig
state in this ForceServiceConnector
.
The ForceConnectorConfig
state is used by a ForceServiceConnector
to get connections to the Force.com service. Note that setting this state
will override any named ForceConnectorConfig
source set
in this ForceServiceConnector
.
connectorConfig
- the ForceConnectorConfig
be to used to get Force.com connection
within this ForceServiceConnector
ForceConnectorUtils.loadConnectorPropsFromName(String)
,
setConnectionName(String)
public void setSkipCache(boolean skipCache)
ForceServiceConnector
should skip
in memory ForceConnectorConfig
cache reads and writes.
By default, a ForceServiceConnector
will cache ForceConnectorConfig
objects when getting a connection to the Force.com service. This state allows
the caller to control whether that cache is used or not.
skipCache
- boolean to indicate whether this ForceServiceConnector
should
ignore the ForceConnectorConfig
in memory cachepublic void setTimeout(int timeout)
ForceServiceConnector
.
Note that this timeout value will override any read timeout value set in
a ForceConnectorConfig
.
timeout
- the Force.com connection read timeout in milliseconds
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |