本文整理汇总了Java中org.mule.api.ConnectionException类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionException类的具体用法?Java ConnectionException怎么用?Java ConnectionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionException类属于org.mule.api包,在下文中一共展示了ConnectionException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectToApi
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Opens the API connection and validates the service, else throws
* a {@link ConnectionException} for Mulesoft.
*
* @throws ConnectionException
*/
protected synchronized void connectToApi() throws ConnectionException {
Service service;
// Connect to the Anaplan API.
try {
service = apiConn.openConnection();
} catch (AnaplanConnectionException e) {
throw new org.mule.api.ConnectionException(
ConnectionExceptionCode.INCORRECT_CREDENTIALS, null,
e.getMessage(), e);
}
if (service == null) {
throw new org.mule.api.ConnectionException(
ConnectionExceptionCode.UNKNOWN, null, "No service "
+ "object acquired after opening connStrategy to Anaplan "
+ "API!", null);
} else {
logger.info("Successfully connected to Anaplan API!");
}
}
示例2: login
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Logs in into the NEst service and captures session information
*
* @throws ConnectionException if the credentials are incorrect
* @throws IOException if the response date cannot be parsed
*/
@Start
public void login() throws ConnectionException, IOException
{
httpClient.addFilter(new LoggingFilter());
MultivaluedMap<String, String> map = new MultivaluedMapImpl();
map.putSingle("username", getUsername());
map.putSingle("password", getPassword());
WebResource webResource = httpClient.resource("https://home.nest.com/user/login");
ClientResponse response = webResource.type("application/x-www-form-urlencoded")
.post(ClientResponse.class, map);
if (response.getStatus()> 399)
{
throw new ConnectionException(ConnectionExceptionCode.INCORRECT_CREDENTIALS, "unauthorized user", response.toString());
}
String res = response.getEntity(String.class);
System.out.println("Login: " + res);
login = mapper.readValue(res, Login.class);
baseUri = login.getUrls().getTransportUrl();
getMetaData();
}
示例3: connect
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Connect
*
* @param username A username
* @param password A password
* @throws ConnectionException
*/
@Connect
public void connect(@ConnectionKey String username, @Password String password)
throws ConnectionException {
/*
* CODE FOR ESTABLISHING A CONNECTION GOES HERE
*/
}
示例4: connect
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Establishes the database connection using the given bucket name and password.
*
* @param bucketName The bucket name in the cluster you wish to use.
* @param password The password for the bucket. Default is empty.
* @throws ConnectionException
*/
@Connect
public void connect(@ConnectionKey String bucketName, String password) throws ConnectionException {
this.BucketName = bucketName;
List<URI> uris = new LinkedList<URI>();
uris.add(URI.create(this.Uri));
try {
client = new CouchbaseClient(uris, bucketName, password);
} catch (IOException e) {
e.printStackTrace();
}
}
示例5: connect
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Connect to the DynamoDB service
*
* @param accessKey
* the access key provided to you through your Amazon AWS account
* @param secretKey
* the secret key provided to you through your Amazon AWS account
*/
@Connect
// TODO: try this => @Default (value = Query.MILES) @Optional String unit
public void connect(@ConnectionKey String accessKey, String secretKey) throws ConnectionException {
if (StringUtils.isNotEmpty(accessKey) && StringUtils.isNotEmpty(secretKey)) {
createDynamoDBClient(accessKey, secretKey);
} else {
createDynamoDBClient();
}
Region regionEnum = Region.getRegion(getRegionAsEnum());
getDynamoDBClient().setRegion(regionEnum);
}
示例6: connect
import org.mule.api.ConnectionException; //导入依赖的package包/类
@Connect
public void connect(@ConnectionKey String username, @Password String password)
throws ConnectionException
{
this.client = DrupalClientFactory.getClient(endpoint, new CookieAuthenticationStrategy(
username, password, endpoint + "/user"));
}
示例7: connect
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Connect to KissMetrics.
*
* @param apiKey The API Key from your KissMetrics settings screen.
* @throws ConnectionException
*/
@Connect
@TestConnectivity(active=false)
public void connect(@ConnectionKey String apiKey)
throws ConnectionException {
this.apiKey = apiKey;
final ClientConfig clientConfig = new ClientConfig();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JacksonJsonProvider jsonProvider = new JacksonJsonProvider(mapper);
clientConfig.register(JacksonJsonProvider.class);
this.client = ClientBuilder.newClient(clientConfig);
}
示例8: connect
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Connect to Nuxeo Server via Automation java client
*
* @param username Nuxeo user name
* @param password Nuxeo password
* @throws ConnectionException
*/
@Connect
public void connect(@ConnectionKey
String username, @Password
String password) throws ConnectionException {
AutomationClient client = new HttpAutomationClient(getServerUrl());
session = client.getSession(username, password);
session.setDefaultSchemas(defaultSchemas);
docService = session.getAdapter(DocumentService.class);
logger.info("Connect Nuxeo Connector");
}
示例9: connect
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Connect
*
* @throws ConnectionException
*/
@Start
public void connect() throws ConnectionException
{
String res = httpClient.resource(getBaseUri()).get(String.class);
if (res.contains("error"))
{
throw new ConnectionException(ConnectionExceptionCode.INCORRECT_CREDENTIALS, "unauthorized user", res);
}
}
示例10: disconnect
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Disconnect
*
* @throws ConnectionException
*/
@Disconnect
public void disconnect() throws ConnectionException
{
}
示例11: createDynamoDBClient
import org.mule.api.ConnectionException; //导入依赖的package包/类
/**
* Creates a DynamoDB client using the security values passed in
*
* @param accessKey
* the access key provided to you through your Amazon AWS account
* @param secretKey
* the secret key provided to you through your Amazon AWS account
*
* @throws ConnectionException
*/
private void createDynamoDBClient(String accessKey, String secretKey) throws ConnectionException {
try {
AWSCredentials credentialsProvider = new BasicAWSCredentials(accessKey, secretKey);
setDynamoDBClient(new AmazonDynamoDBClient(credentialsProvider));
} catch (Exception e) {
throw new ConnectionException(ConnectionExceptionCode.UNKNOWN, null, e.getMessage(), e);
}
}