Added abstraction layer to move out config
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import de.rwu.easydrop.util.Config;
|
||||
|
||||
/**
|
||||
* Factory for Buyer API accessors.
|
||||
*
|
||||
* @since 0.3.0
|
||||
*/
|
||||
public class PurchaserFactory {
|
||||
|
||||
/**
|
||||
* The data source config.
|
||||
*/
|
||||
private Config config;
|
||||
|
||||
/**
|
||||
* @param newConfig the config to set
|
||||
*/
|
||||
public void setConfig(final Config newConfig) throws ConfigurationException {
|
||||
this.config = newConfig;
|
||||
this.config.loadConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newConfig
|
||||
*/
|
||||
public PurchaserFactory(final Config newConfig) throws ConfigurationException {
|
||||
this.setConfig(newConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Amazon purchaser.
|
||||
*
|
||||
* @return AmazonPurchaser
|
||||
*/
|
||||
public AmazonPurchaser createAmazonPurchaser() {
|
||||
String apiUrl = config.getProperty("AMAZON_API_URL");
|
||||
String apiKey = config.getProperty("AMAZON_API_KEY");
|
||||
return new AmazonPurchaser(apiUrl, apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an eBay purchaser.
|
||||
*
|
||||
* @return EbayPurchaser
|
||||
*/
|
||||
public EbayPurchaser createEbayPurchaser() {
|
||||
String apiUrl = config.getProperty("EBAY_API_URL");
|
||||
String apiKey = config.getProperty("EBAY_API_KEY");
|
||||
return new EbayPurchaser(apiUrl, apiKey);
|
||||
}
|
||||
}
|
||||
55
src/main/java/de/rwu/easydrop/api/client/SellerFactory.java
Normal file
55
src/main/java/de/rwu/easydrop/api/client/SellerFactory.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package de.rwu.easydrop.api.client;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import de.rwu.easydrop.util.Config;
|
||||
|
||||
/**
|
||||
* Factory for Sales API accessors.
|
||||
*
|
||||
* @since 0.3.0
|
||||
*/
|
||||
public class SellerFactory {
|
||||
|
||||
/**
|
||||
* The data source config.
|
||||
*/
|
||||
private Config config;
|
||||
|
||||
/**
|
||||
* @param newConfig the config to set
|
||||
*/
|
||||
public void setConfig(final Config newConfig) throws ConfigurationException {
|
||||
this.config = newConfig;
|
||||
this.config.loadConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param newConfig
|
||||
*/
|
||||
public SellerFactory(final Config newConfig) throws ConfigurationException {
|
||||
this.setConfig(newConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Amazon Seller.
|
||||
*
|
||||
* @return AmazonSeller
|
||||
*/
|
||||
public AmazonSeller createAmazonSeller() {
|
||||
String apiUrl = config.getProperty("AMAZON_API_URL");
|
||||
String apiKey = config.getProperty("AMAZON_API_KEY");
|
||||
return new AmazonSeller(apiUrl, apiKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an eBay Seller.
|
||||
*
|
||||
* @return EbaySeller
|
||||
*/
|
||||
public EbaySeller createEbaySeller() {
|
||||
String apiUrl = config.getProperty("EBAY_API_URL");
|
||||
String apiKey = config.getProperty("EBAY_API_KEY");
|
||||
return new EbaySeller(apiUrl, apiKey);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user