net.plsar.RouteAttributesResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plsar Show documentation
Show all versions of plsar Show documentation
PLSA.R is an Open Source Java Server + API for high demand, low latency requirements. There are no static references, no file reads, access to static fields per request. Everything is either cached and or instantiated on the fly. PLSA.R runs via one command so there are no .war files to deploy, no additional plugins to install it is a simple yet powerful alternative to container deployment environments. PLSA.R even boasts a little dependency injection for data logic. www.plsar.net
The newest version!
package net.plsar;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Enumeration;
import java.util.Properties;
public class RouteAttributesResolver {
String propertiesFile;
public RouteAttributesResolver(String propertiesFile){
this.propertiesFile = propertiesFile;
}
public RouteAttributes resolve(){
RouteAttributes routeAttributes = new RouteAttributes();
Path filePath = Paths.get("src", "main", "resources", propertiesFile);
String propertiesPath = filePath.toAbsolutePath().toString();
File file = new File(propertiesPath);
if(!file.exists())return routeAttributes;
try {
InputStream is = new FileInputStream(file);
if(is == null)return null;
Properties prop = new Properties();
prop.load(is);
Enumeration properties = prop.propertyNames();
while (properties.hasMoreElements()) {
String key = (String) properties.nextElement();
String value = prop.getProperty(key);
routeAttributes.getAttributes().put(key, value);
}
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
return routeAttributes;
}
}