本文整理汇总了Java中javax.mail.URLName.getProtocol方法的典型用法代码示例。如果您正苦于以下问题:Java URLName.getProtocol方法的具体用法?Java URLName.getProtocol怎么用?Java URLName.getProtocol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.mail.URLName
的用法示例。
在下文中一共展示了URLName.getProtocol方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFlowBuilder
import javax.mail.URLName; //导入方法依赖的package包/类
/**
* Method to build Integration Flow for Mail. Suppress Warnings for
* MailInboundChannelAdapterSpec.
* @return Integration Flow object for Mail Source
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private IntegrationFlowBuilder getFlowBuilder() {
IntegrationFlowBuilder flowBuilder;
URLName urlName = this.properties.getUrl();
if (this.properties.isIdleImap()) {
flowBuilder = getIdleImapFlow(urlName);
}
else {
MailInboundChannelAdapterSpec adapterSpec;
switch (urlName.getProtocol().toUpperCase()) {
case "IMAP":
case "IMAPS":
adapterSpec = getImapFlowBuilder(urlName);
break;
case "POP3":
case "POP3S":
adapterSpec = getPop3FlowBuilder(urlName);
break;
default:
throw new IllegalArgumentException(
"Unsupported mail protocol: " + urlName.getProtocol());
}
flowBuilder = IntegrationFlows.from(
adapterSpec.javaMailProperties(getJavaMailProperties(urlName))
.userFlag(this.properties.getUserFlag())
.selectorExpression(this.properties.getExpression())
.shouldDeleteMessages(this.properties.isDelete()));
}
return flowBuilder;
}
示例2: updateUrlName
import javax.mail.URLName; //导入方法依赖的package包/类
protected URLName updateUrlName(URLName urlName, Properties props) {
String protocol = urlName.getProtocol();
String userName = urlName.getUsername();
String password = urlName.getPassword();
String host = urlName.getHost();
String file = urlName.getFile();
int port = urlName.getPort();
// check the username
if (UtilValidate.isEmpty(userName)) {
userName = props.getProperty("mail." + protocol + ".user");
if (UtilValidate.isEmpty(userName)) {
userName = props.getProperty("mail.user");
}
}
// check the password; update with the non-standard property
if (UtilValidate.isEmpty(password)) {
password = props.getProperty("mail." + protocol + ".pass");
if (UtilValidate.isEmpty(password)) {
password = props.getProperty("mail.pass");
}
}
// check the host
if (UtilValidate.isEmpty(host)) {
host = props.getProperty("mail." + protocol + ".host");
if (UtilValidate.isEmpty(host)) {
host = props.getProperty("mail.host");
}
}
if (Debug.verboseOn()) Debug.logVerbose("Update URL - " + protocol + "://" + userName + "@" + host + ":" + port + "!" + password + ";" + file, module);
return new URLName(protocol, host, port, file, userName, password);
}
示例3: getFlowBuilder
import javax.mail.URLName; //导入方法依赖的package包/类
/**
* Method to build Integration Flow for Mail. Suppress Warnings for
* MailInboundChannelAdapterSpec.
* @return Integration Flow object for Mail Source
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private IntegrationFlowBuilder getFlowBuilder() {
IntegrationFlowBuilder flowBuilder;
URLName urlName = this.properties.getUrl();
if (this.properties.isIdleImap()) {
flowBuilder = getIdleImapFlow(urlName);
}
else {
MailInboundChannelAdapterSpec adapterSpec;
switch (urlName.getProtocol().toUpperCase()) {
case "IMAP":
case "IMAPS":
adapterSpec = getImapFlowBuilder(urlName);
break;
case "POP3":
case "POP3S":
adapterSpec = getPop3FlowBuilder(urlName);
break;
default:
throw new IllegalArgumentException(
"Unsupported mail protocol: " + urlName.getProtocol());
}
flowBuilder = IntegrationFlows.from(
adapterSpec.javaMailProperties(getJavaMailProperties(urlName))
.selectorExpression(this.properties.getExpression())
.shouldDeleteMessages(this.properties.isDelete()),
new Consumer<SourcePollingChannelAdapterSpec>() {
@Override
public void accept(
SourcePollingChannelAdapterSpec sourcePollingChannelAdapterSpec) {
sourcePollingChannelAdapterSpec.poller(MailSourceConfiguration.this.defaultPoller);
}
});
}
return flowBuilder;
}