当前位置: 首页>>代码示例>>Java>>正文


Java URLName.getProtocol方法代码示例

本文整理汇总了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;
}
 
开发者ID:spring-cloud-stream-app-starters,项目名称:mail,代码行数:39,代码来源:MailSourceConfiguration.java

示例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);
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:36,代码来源:JavaMailContainer.java

示例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;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:48,代码来源:MailSourceConfiguration.java


注:本文中的javax.mail.URLName.getProtocol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。