• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DestinationConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sap.core.connectivity.api.configuration.DestinationConfiguration的典型用法代码示例。如果您正苦于以下问题:Java DestinationConfiguration类的具体用法?Java DestinationConfiguration怎么用?Java DestinationConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DestinationConfiguration类属于com.sap.core.connectivity.api.configuration包,在下文中一共展示了DestinationConfiguration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testCreateURL

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
@Test
public void testCreateURL() throws MalformedURLException {

	Map<String, String> properties = new HashMap<>();
	properties.put("api_key", "DEMO_KEY");
	properties.put("format", "json");
	properties.put("scheme", "http");
	properties.put("path", "/ndb/search/");
	properties.put("URL", "http://api.nal.usda.gov");
	DestinationConfiguration destConf = Mockito.mock(DestinationConfiguration.class);
	Mockito.when(destConf.getAllProperties()).thenReturn(properties);
	List<NameValuePair> parameters = new ArrayList<>();
	parameters.add(new BasicNameValuePair("q", "tomatoes"));
	URL expectedURL = new URL(
			"http://api.nal.usda.gov/ndb/search/?q=tomatoes&api_key=DEMO_KEY&format=json");
	URL actualURL = HTTPUtils.createURL(destConf.getAllProperties(), parameters);
	assertEquals(expectedURL, actualURL);
}
 
开发者ID:svilenkomitov,项目名称:Food-Calculator,代码行数:19,代码来源:HTTPUtilsTest.java


示例2: retrieveDestinationProperties

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private Map<String, String> retrieveDestinationProperties(String destinationName) {
	DestinationConfiguration destinationConfiguration = ConnectivityConfigurationProvider
			.retrieveConnectivityConfiguration().getConfiguration(destinationName);

	if (destinationConfiguration == null) {
		String errorMessage = MessageFormat.format(ERROR_DESTINATION_NOT_FOUND, destinationName);
		logger.error(errorMessage);
		throw new IllegalArgumentException(errorMessage);
	}

	return destinationConfiguration.getAllProperties();
}
 
开发者ID:SAP,项目名称:cloud-ariba-partner-flow-extension-ext,代码行数:13,代码来源:Destination.java


示例3: executeGET

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
public SimpleHttpResponse executeGET(String path) throws InvalidResponseException, IOException {
	DestinationConfiguration destinationConfiguration = lookupDestinationConfiguration();
	URL requestURL = getRequestURL(destinationConfiguration, path);
	LOGGER.info(INFO_REQUEST_METHOD, requestURL.toString());
	HttpURLConnection urlConnection = openConnection(destinationConfiguration, requestURL);
	return executeMethodGET(urlConnection);
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:8,代码来源:HTTPConnector.java


示例4: openConnection

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private HttpURLConnection openConnection(DestinationConfiguration destinationConfiguration, URL requestURL)
		throws IOException, ProtocolException {
	HttpURLConnection urlConnection = (HttpURLConnection) requestURL.openConnection();
	urlConnection.addRequestProperty(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
	injectAuthenticationHeaders(urlConnection, destinationConfiguration);
	urlConnection.setRequestMethod(GET_METHOD);
	return urlConnection;
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:9,代码来源:HTTPConnector.java


示例5: injectAuthenticationHeaders

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private void injectAuthenticationHeaders(HttpURLConnection urlConnection,
		DestinationConfiguration destinationConfiguration) throws IOException {
	List<AuthenticationHeader> authenticationHeaders = getAuthenticationHeaders(destinationConfiguration);
	for (AuthenticationHeader authenticationHeader : authenticationHeaders) {
		urlConnection.addRequestProperty(authenticationHeader.getName(), authenticationHeader.getValue());
	}
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:8,代码来源:HTTPConnector.java


示例6: getRequestURL

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private URL getRequestURL(DestinationConfiguration destinationConfiguration, String path) throws IOException {
	String requestBaseURLString = destinationConfiguration.getProperty(DESTINATION_URL);
	if (StringUtils.isEmpty(requestBaseURLString)) {
		String errorMessage = MessageFormat.format(ERROR_NOT_CONFIGURED_DESTINATION_URL, destinationName);
		LOGGER.error(errorMessage);
		throw new IOException(errorMessage);
	}
	if (!requestBaseURLString.endsWith(PATH_SUFFIX)) {
		requestBaseURLString += PATH_SUFFIX;
	}
	LOGGER.info(INFO_DESTINATION_REQUEST, destinationName,	requestBaseURLString, path);
	URL baseURL = new URL(requestBaseURLString);
	return new URL(baseURL, path);
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:15,代码来源:HTTPConnector.java


示例7: getAuthenticationHeaders

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private List<AuthenticationHeader> getAuthenticationHeaders(DestinationConfiguration destinationConfiguration)
		throws IOException {
	String authenticationType = destinationConfiguration.getProperty(DESTINATION_AUTHENTICATION_PROPERTY);
	List<AuthenticationHeader> authenticationHeaders = new ArrayList<>();
	if (BASIC_AUTHENTICATION_PROPERTY.equals(authenticationType)) {
		BasicAuthenticationHeaderProvider headerProvider = new BasicAuthenticationHeaderProvider();
		authenticationHeaders.add(headerProvider.getAuthenticationHeader(destinationConfiguration));
	}
	return authenticationHeaders;
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:11,代码来源:HTTPConnector.java


示例8: lookupDestinationConfiguration

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private DestinationConfiguration lookupDestinationConfiguration() throws IOException {
	ConnectivityConfiguration connectivityConfiguration = lookupConnectivityConfiguration();

	DestinationConfiguration destinationConfiguration = connectivityConfiguration.getConfiguration(destinationName);
	if (destinationConfiguration == null) {
		String errorMessage = MessageFormat.format(ERROR_DESTINATION_NOT_FOUND, destinationName);
		LOGGER.error(errorMessage);
		throw new IOException(errorMessage);
	}
	return destinationConfiguration;
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:12,代码来源:HTTPConnector.java


示例9: getAuthenticationHeader

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
public AuthenticationHeader getAuthenticationHeader(DestinationConfiguration destinationConfiguration) {
    StringBuilder userPass = new StringBuilder();
    userPass.append(destinationConfiguration.getProperty(USER_PROPERTY));
    userPass.append(SEPARATOR);
    userPass.append(destinationConfiguration.getProperty(PASSWORD_PROPERTY));
    String encodedPassword = DatatypeConverter.printBase64Binary(userPass.toString().getBytes(StandardCharsets.UTF_8));
    return new AuthenticationHeaderImpl(HttpHeaders.AUTHORIZATION, MessageFormat.format(BASIC_AUTHENTICATION_PREFIX, encodedPassword));
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:9,代码来源:BasicAuthenticationHeaderProvider.java


示例10: getPlantsOnPremiseData

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON })
public String getPlantsOnPremiseData() throws Exception {
	DestinationConfiguration destConfiguration = getDestConfiguration();
	// Get the destination URL
	String value = destConfiguration.getProperty("URL");
	URL destinationURL = new URL(value);
	String result = retrieveOnPremisePlantDetails(destConfiguration, destinationURL);
	return result;

}
 
开发者ID:AnujMehta07,项目名称:cloud-pollutionmonitoringapp,代码行数:13,代码来源:PlantDataService.java


示例11: getDestConfiguration

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private DestinationConfiguration getDestConfiguration() throws NamingException {
	// Look up the connectivity configuration API
	javax.naming.Context ctx = new InitialContext();
	ConnectivityConfiguration configuration = (ConnectivityConfiguration) ctx
			.lookup("java:comp/env/connectivityConfiguration");
	// Get destination configuration for "destinationName"
	DestinationConfiguration destConfiguration = configuration.getConfiguration("onprem-plantdata-dest");
	return destConfiguration;
}
 
开发者ID:AnujMehta07,项目名称:cloud-pollutionmonitoringapp,代码行数:10,代码来源:PlantDataService.java


示例12: getPlantOnPremiseData

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
public String getPlantOnPremiseData(String plant_id) throws Exception {
	DestinationConfiguration destConfiguration = getDestConfiguration();
	// Get the destination URL
	String baseURL = destConfiguration.getProperty("URL");
	String formattedURL = null;
	formattedURL = MessageFormat.format("{0}?id={1}", baseURL, plant_id);
	URL destinationURL=new URL(formattedURL);
	String result = retrieveOnPremisePlantDetails(destConfiguration, destinationURL);
	return result;
}
 
开发者ID:AnujMehta07,项目名称:cloud-pollutionmonitoringapp,代码行数:11,代码来源:PlantDataService.java


示例13: retrieveOnPremisePlantDetails

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private String retrieveOnPremisePlantDetails(DestinationConfiguration destConfiguration, URL destinationURL)
		throws MalformedURLException, IOException, Exception {
	HttpURLConnection urlConnection;
	String proxyType = destConfiguration.getProperty("ProxyType");
	Proxy proxy = getProxy(proxyType);
	urlConnection = (HttpURLConnection) destinationURL.openConnection(proxy);
	injectHeader(urlConnection, proxyType);
	// Copy content from the incoming response to the outgoing response
	InputStream instream = urlConnection.getInputStream();
	String result = getResponseBodyAsString(instream);
	return result;
}
 
开发者ID:AnujMehta07,项目名称:cloud-pollutionmonitoringapp,代码行数:13,代码来源:PlantDataService.java


示例14: getDestinationProperties

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
/**
 * Returns a map containing the destination properties for the given destination
 */
private Map<String, String> getDestinationProperties(String destinationName) throws ConfigurationException {
	DestinationConfiguration destConfiguration = configuration.getConfiguration(destinationName);
	if (destConfiguration == null) {
		throw new ConfigurationException(
				String.format("Destination [ %s ] not found. Hint: Make sure to have the destination configured.", destinationName));
	}
	logDebug("Getting destination properties for destination [ {} ]", destinationName);
	return destConfiguration.getAllProperties();
}
 
开发者ID:SAP,项目名称:cloud-concur-expenses-ext,代码行数:13,代码来源:ExpensesServlet.java


示例15: getDestinationUrl

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
/**
 * @see {@link AbstractDispatcherServlet#getDestinationUrl()}
 */
@Override
protected String getDestinationUrl()
throws IOException {
	DestinationConfiguration destination = getDestinationConfiguration();

	String url = destination.getProperty("URL");
	// normalization
	url = StringUtil.disjoin(url, "/");
	// backward compatibility for old destination formats
	url = StringUtil.disjoin(url, "/http/push");
	url = StringUtil.disjoin(url, "/v1/api");

	return url;
}
 
开发者ID:SAP,项目名称:iot-starterkit,代码行数:18,代码来源:MmsDispatcherServlet.java


示例16: getDestinationConfiguration

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
/**
 * Returns a concrete destination configuration object from JNDI connectivity configuration
 */
protected DestinationConfiguration getDestinationConfiguration()
throws IOException {
	String name = getDestinationName();
	DestinationConfiguration destination = geConnectivityConfiguration().getConfiguration(name);
	if (destination == null) {
		throw new IOException(
			"Unable to establish a connectivity to the destination [" + name + "]");
	}
	return destination;
}
 
开发者ID:SAP,项目名称:iot-starterkit,代码行数:14,代码来源:AbstractDispatcherServlet.java


示例17: getDestinationUrl

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
/**
 * @see {@link AbstractDispatcherServlet#getDestinationUrl()}
 */
@Override
protected String getDestinationUrl()
throws IOException {
	DestinationConfiguration destination = getDestinationConfiguration();

	String url = destination.getProperty("URL");
	// normalization
	url = StringUtil.disjoin(url, "/");
	// backward compatibility for old destination formats
	url = StringUtil.disjoin(url, "/v1/api");

	return url;
}
 
开发者ID:SAP,项目名称:iot-starterkit,代码行数:17,代码来源:RdmsDispatcherServlet.java


示例18: getAuthenticationHeader

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
public AuthenticationHeader getAuthenticationHeader(DestinationConfiguration destinationConfiguration) {
    StringBuilder userPass = new StringBuilder();
    userPass.append(destinationConfiguration.getProperty(USER_PROPERTY));
    userPass.append(SEPARATOR);
    userPass.append(destinationConfiguration.getProperty(PASSWORD_PROPERTY));
    String encodedPassword = DatatypeConverter.printBase64Binary(userPass.toString().getBytes(StandardCharsets.UTF_8));
    AuthenticationHeaderImpl basicAuthentication = new AuthenticationHeaderImpl(AUTHORIZATION_HEADER, BASIC_AUTHENTICATION_PREFIX
            + encodedPassword);
    return basicAuthentication;
}
 
开发者ID:SAP,项目名称:cloud-sfsf-benefits-ext,代码行数:11,代码来源:BasicAuthenticationHeaderProvider.java


示例19: prepareCompanyPollutionData

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
private CompanyPollutionData prepareCompanyPollutionData(List<Plant> mfPlantList, HttpServletResponse response)
		throws Exception {
	HttpsURLConnection urlConnection = null;
	CompanyPollutionData companyPollutionData = new CompanyPollutionData();
	List<PlantPollutionDayData> plantPollutionDayDataList = new ArrayList<PlantPollutionDayData>();
	// Look up the connectivity configuration API
	javax.naming.Context ctx = new InitialContext();
	ConnectivityConfiguration configuration = (ConnectivityConfiguration) ctx
			.lookup("java:comp/env/connectivityConfiguration");
	// Get destination configuration for "destinationName"
	DestinationConfiguration destConfiguration = configuration.getConfiguration("openaq-api-dest");
	SSLSocketFactory socketFactory = null;
	// Get the destination URL
	String value = destConfiguration.getProperty("URL");
	URL baseUrl = new URL(value);
	socketFactory = establishedSSLConnection(response, baseUrl.getHost(), 443);
	for (Iterator<Plant> iterator = mfPlantList.iterator(); iterator.hasNext();) {
		Plant ogPlant = (Plant) iterator.next();
		final String destinationUrl = value + "?parameter=o3&location=" + ogPlant.getLocation() + "&date_from="
				+ ogPlant.getDateField() + "&date_to=" + ogPlant.getDateField();
		URL url = new URL(destinationUrl.replaceAll(" ", "%20"));
		urlConnection = (HttpsURLConnection) url.openConnection();
		urlConnection.setSSLSocketFactory(socketFactory);
		// Copy content from the incoming response to the outgoing response
		InputStream instream = urlConnection.getInputStream();
		String msgBody = getResponseBodyasJSONArray(instream);
		JSONObject cityO3 = new JSONObject(msgBody);
		PlantPollutionDayData plantPollutionDayData = new PlantPollutionDayData();
		plantPollutionDayData.setPlant(ogPlant);
		JSONArray jsonArray = cityO3.getJSONArray("results");
		if (!jsonArray.isNull(0) && jsonArray.get(0) != null) {
			JSONObject jsonObject = (JSONObject) jsonArray.get(0);
			if (jsonObject != null) {
				Double o3value = (Double) jsonObject.get("value");
				plantPollutionDayData.setCityOzoneLevel(o3value.toString());
			}
		} else {
			// Value is not available
			plantPollutionDayData.setCityOzoneLevel(" ");
		}
		plantPollutionDayDataList.add(plantPollutionDayData);
	}
	int size = plantPollutionDayDataList.size();
	int i = 0;
	int j = 5;
	int k = 0;
	while (size > 0) {
		companyPollutionData.getPlantsPollutionWeeklyData().put(Integer.toString(k),
				plantPollutionDayDataList.subList(i, j));
		i = i + 5;
		j = j + 5;
		size = size - 5;
		k++;
	}
	return companyPollutionData;
}
 
开发者ID:AnujMehta07,项目名称:cloud-pollutionmonitoringapp,代码行数:57,代码来源:PollutionDataService.java


示例20: getDestinationProperties

import com.sap.core.connectivity.api.configuration.DestinationConfiguration; //导入依赖的package包/类
/**
 * Connects to the destination by name and returns its configuration
 * properties
 * 
 * @param destinationName
 *            the destination name
 * @return map of all properties for the given destination
 */
public static Map<String, String> getDestinationProperties(String destinationName) {

	DestinationConfiguration destinationConfiguration = null;

	try {

		Context context = new InitialContext();
		ConnectivityConfiguration configuration = (ConnectivityConfiguration) context
				.lookup(CONNECTIVITY_CONFIGURATION);
		destinationConfiguration = configuration.getConfiguration(destinationName);

	} catch (NamingException e) {

		String message = MessageFormatter
				.format(ERROR_UNABLE_TO_CONNECT_TO_CONNECTIVITY_SERVICE_MESSAGE, destinationName).getMessage();
		LOGGER.error(message, e);
	}

	return destinationConfiguration.getAllProperties();

}
 
开发者ID:svilenkomitov,项目名称:Food-Calculator,代码行数:30,代码来源:HTTPUtils.java



注:本文中的com.sap.core.connectivity.api.configuration.DestinationConfiguration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DispatchImpl类代码示例发布时间:2022-05-23
下一篇:
Java JobQueueChangeEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap