How can I use Java WURFL API in a standalone manner?
Posted: Wed Oct 12, 2011 11:15 am
Is it possible to use WURFL Java API in a standalone environment, outside a Server or a Servlet Container?
Community Support Forum
https://forum.scientiamobile.com/
Code: Select all
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("/spring/wurfl-standard-import-ctx.xml");
WURFLManager wurflManager = (WURFLManager) ctx.getBean("wurflManager");
String ua="Mozilla/5.0 (Linux; U; Android 2.1-update1; en-us; Nexus One Build/ERE27) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17";
Device device = wurflManager.getDeviceForRequest(ua);
System.out.println(device.getCapabilities());
}
Code: Select all
<beans xmlns=(usual Spring 3 prologue...) >
<import resource="classpath:/META-INF/wurfl-api-service.xml"/>
<bean id="wurflModel" class="net.sourceforge.wurfl.spring.SpringWURFLModel">
<!-- default value is "/WEB-INF/wurfl.zip" -->
<property name="wurfl" value="classpath:/wurfl-2.2.zip"/>
<!--if you have only one patchfile , you can write this way-->
<property name="wurflPatch" value="classpath:/web_browsers_patch.xml"/>
</bean>
<bean id="wurflManager"
class="net.sourceforge.wurfl.spring.SpringWurflManager">
<property name="wurflModel" ref="wurflModel"/>
</bean>
</beans>