本文整理汇总了Java中com.sforce.ws.ConnectorConfig.setSessionRenewer方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectorConfig.setSessionRenewer方法的具体用法?Java ConnectorConfig.setSessionRenewer怎么用?Java ConnectorConfig.setSessionRenewer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sforce.ws.ConnectorConfig
的用法示例。
在下文中一共展示了ConnectorConfig.setSessionRenewer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPartnerConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static ConnectorConfig getPartnerConfig(ForceConfigBean conf, SessionRenewer sessionRenewer) throws StageException {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(conf.username.get());
config.setPassword(conf.password.get());
config.setAuthEndpoint("https://"+conf.authEndpoint+"/services/Soap/u/"+conf.apiVersion);
config.setCompression(conf.useCompression);
config.setTraceMessage(conf.showTrace);
config.setSessionRenewer(sessionRenewer);
setProxyConfig(conf, config);
return config;
}
示例2: getBulkConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static BulkConnection getBulkConnection(
ConnectorConfig partnerConfig,
ForceConfigBean conf
) throws ConnectionException, AsyncApiException, StageException, URISyntaxException {
// When PartnerConnection is instantiated, a login is implicitly
// executed and, if successful,
// a valid session is stored in the ConnectorConfig instance.
// Use this key to initialize a BulkConnection:
ConnectorConfig config = conf.mutualAuth.useMutualAuth
? new MutualAuthConnectorConfig(conf.mutualAuth.getUnderlyingConfig().getSslContext())
: new ConnectorConfig();
config.setSessionId(partnerConfig.getSessionId());
// The endpoint for the Bulk API service is the same as for the normal
// SOAP uri until the /Soap/ part. From here it's '/async/versionNumber'
String soapEndpoint = partnerConfig.getServiceEndpoint();
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/"))
+ "async/" + conf.apiVersion;
config.setRestEndpoint(restEndpoint);
config.setCompression(conf.useCompression);
config.setTraceMessage(conf.showTrace);
config.setSessionRenewer(partnerConfig.getSessionRenewer());
setProxyConfig(conf, config);
BulkConnection bulkConnection = new BulkConnection(config);
if (conf.mutualAuth.useMutualAuth) {
setupMutualAuthBulk(config, conf.mutualAuth);
}
return bulkConnection;
}
示例3: createConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public ConnectorConfig createConfig() {
CommonConnectorConfig commonConnConfig = new CommonConnectorConfig();
ConnectorConfig config = commonConnConfig.createConfig();
config.setAuthEndpoint(
CommandLineArguments.getOrgUrl() + "/services/Soap/u/" + ConnectionHandler.SUPPORTED_VERSION);
config.setSessionRenewer(new SFDCSessionRenewer());
LOG.info("Default connection time out value is: " + config.getConnectionTimeout());
config.setConnectionTimeout(ConnectionHandler.MAX_TIME_OUT_IN_MS_INT);
LOG.info("Updated connection time out value(from config.properties file): " + config.getConnectionTimeout());
return config;
}
示例4: connectBulk
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
protected BulkConnection connectBulk(ConnectorConfig config) throws ComponentException {
/*
* When PartnerConnection is instantiated, a login is implicitly executed and, if successful, a valid session is
* stored in the ConnectorConfig instance. Use this key to initialize a BulkConnection:
*/
ConnectorConfig bulkConfig = new ConnectorConfig();
bulkConfig.setSessionId(config.getSessionId());
// For session renew
bulkConfig.setSessionRenewer(config.getSessionRenewer());
bulkConfig.setUsername(config.getUsername());
bulkConfig.setPassword(config.getPassword());
/*
* The endpoint for the Bulk API service is the same as for the normal SOAP uri until the /Soap/ part. From here
* it's '/async/versionNumber'
*/
String soapEndpoint = config.getServiceEndpoint();
// set it by a default property file
String api_version = "34.0";
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + api_version;
bulkConfig.setRestEndpoint(restEndpoint);
bulkConfig.setCompression(true);// This should only be false when doing debugging.
bulkConfig.setTraceMessage(false);
bulkConfig.setValidateSchema(false);
try {
return new BulkConnection(bulkConfig);
} catch (AsyncApiException e) {
throw new ComponentException(e);
}
}
示例5: connectBulk
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
protected BulkConnection connectBulk(ConnectorConfig config) throws ComponentException {
final SalesforceConnectionProperties connProps = getConnectionProperties();
/*
* When PartnerConnection is instantiated, a login is implicitly executed and, if successful, a valid session id is
* stored in the ConnectorConfig instance. Use this key to initialize a BulkConnection:
*/
ConnectorConfig bulkConfig = new ConnectorConfig();
setProxy(bulkConfig);
bulkConfig.setSessionId(config.getSessionId());
// For session renew
bulkConfig.setSessionRenewer(config.getSessionRenewer());
bulkConfig.setUsername(config.getUsername());
bulkConfig.setPassword(config.getPassword());
/*
* The endpoint for the Bulk API service is the same as for the normal SOAP uri until the /Soap/ part. From here
* it's '/async/versionNumber'
*/
String soapEndpoint = config.getServiceEndpoint();
// Service endpoint should be like this:
// https://ap1.salesforce.com/services/Soap/u/37.0/00D90000000eSq3
String apiVersion = soapEndpoint.substring(soapEndpoint.lastIndexOf("/services/Soap/u/") + 17);
apiVersion = apiVersion.substring(0, apiVersion.indexOf("/"));
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + apiVersion;
bulkConfig.setRestEndpoint(restEndpoint);
// This should only be false when doing debugging.
bulkConfig.setCompression(connProps.needCompression.getValue());
bulkConfig.setTraceMessage(connProps.httpTraceMessage.getValue());
bulkConfig.setValidateSchema(false);
try {
return new BulkConnection(bulkConfig);
} catch (AsyncApiException e) {
throw new ComponentException(e);
}
}
示例6: connect
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
ConnectionHolder connect(RuntimeContainer container) throws IOException {
SalesforceRuntimeCommon.enableTLSv11AndTLSv12ForJava7();
final ConnectionHolder ch = new ConnectionHolder();
ConnectorConfig config = new ConnectorConfig();
config.setUsername(datastore.userId.getValue());
String password = datastore.password.getValue();
String securityKey = datastore.securityKey.getValue();
if (!StringUtils.isEmpty(securityKey)) {
password = password + securityKey;
}
config.setPassword(password);
// Notes on how to test this
// http://thysmichels.com/2014/02/15/salesforce-wsc-partner-connection-session-renew-when-session-timeout/
config.setSessionRenewer(new SessionRenewer() {
@Override
public SessionRenewalHeader renewSession(ConnectorConfig connectorConfig) throws ConnectionException {
LOG.debug("renewing session...");
SessionRenewalHeader header = new SessionRenewalHeader();
connectorConfig.setSessionId(null);
PartnerConnection connection = doConnection(connectorConfig);
// update the connection session header
ch.connection.setSessionHeader(connection.getSessionHeader().getSessionId());
header.name = new QName("urn:partner.soap.sforce.com", "SessionHeader");
header.headerElement = connection.getSessionHeader();
LOG.debug("session renewed!");
return header;
}
});
config.setConnectionTimeout(timeout);
config.setCompression(true);// This should only be false when doing debugging.
config.setUseChunkedPost(true);
config.setValidateSchema(false);
try {
ch.connection = doConnection(config);
ch.bulkConnection = connectBulk(ch.connection.getConfig());
return ch;
} catch (ConnectionException e) {
throw new IOException(e);
}
}
示例7: testRenewSession
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
@Test
public void testRenewSession() throws Exception {
SessionRenewer sessionRenewer = mock(SessionRenewer.class);
ConnectorConfig connectorConfig = new ConnectorConfig();
connectorConfig.setSessionRenewer(sessionRenewer);
SalesforceRuntimeCommon.renewSession(connectorConfig);
verify(sessionRenewer, only()).renewSession(eq(connectorConfig));
}