Use API outside web application
Posted: Tue Dec 17, 2013 5:02 am
Hi,
we want to use the WURFL/ScientiaMobile API within a plain Java application, without ServletContext and without Spring. We use the API as follows to build the WURFLEngine manually:
We want to know if that is the right way to manually build and use the WURFLEngine and/or if something is missing?
Thanks,
Stefan
we want to use the WURFL/ScientiaMobile API within a plain Java application, without ServletContext and without Spring. We use the API as follows to build the WURFLEngine manually:
Code: Select all
// setup WURFL engine
InputStream in = WurflRawClassifier.class.getResourceAsStream("/path/to/wurfl.xml");
WURFLResource resource = new XMLResource(in, "wurfl.xml");
GeneralWURFLEngine engine = new GeneralWURFLEngine(resource);
engine.setEngineTarget(EngineTarget.accuracy);
engine.setCacheProvider(new LRUMapCacheProvider());
// get device information
Device device = engine.getDeviceForRequest("Some user agent string");
String deviceId = device.getId();
String deviceRootId = device.getDeviceRootId();
String matchType = device.getMatchType().name();
Map<String, String> capabilities = device.getCapabilities();
Map<String, String> virtualCapabilities = device.getVirtualCapabilities();
Thanks,
Stefan