com.cloudcontrolled.api.client.util.Header Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cctrl-api-client Show documentation
Show all versions of cctrl-api-client Show documentation
Java cloudControl API client
The newest version!
package com.cloudcontrolled.api.client.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;
import org.apache.cxf.jaxrs.client.WebClient;
/**
*
* Header class.
*
*
* @author Denis Neuling ([email protected])
*
*/
public class Header {
/** Constant PROPERTIESLOACTION="header.properties"
*/
public static final String PROPERTIESLOACTION = "header.properties";
private static Header INSTANCE;
private Properties header = new Properties();
private Header() {
}
/**
*
* @return
*/
private Properties getHeader() {
return header;
}
/**
*
* @param properties
*/
private void setHeader(Properties properties) {
header = properties;
}
/**
*
* @throws IOException
*/
private void load() throws IOException {
InputStream inputStream = ClassLoader.getSystemResourceAsStream(PROPERTIESLOACTION);
Properties properties = new Properties();
try {
properties.load(inputStream);
} catch (IOException ioe) {
throw ioe;
} finally {
inputStream.close();
}
setHeader(properties);
}
/**
*
* getInstance.
*
*
* @return a {@link com.cloudcontrolled.api.client.util.Header} object.
*/
public static Header getInstance() {
if (INSTANCE == null) {
INSTANCE = new Header();
try {
INSTANCE.load();
} catch (Exception e) {
INSTANCE.setHeader(new Properties());
}
}
return INSTANCE;
}
/**
*
* Setter for the field header
.
*
*
* @param webClient
* a {@link org.apache.cxf.jaxrs.client.WebClient} object.
* @return a {@link org.apache.cxf.jaxrs.client.WebClient} object.
*/
public static WebClient setHeader(WebClient webClient) {
Properties properties = getInstance().getHeader();
Enumeration