當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。