How can I use Java WURFL API in a standalone manner?
How can I use Java WURFL API in a standalone manner?
Is it possible to use WURFL Java API in a standalone environment, outside a Server or a Servlet Container?
Re: How can I use Java WURFL API in a standalone manner?
The simplest way is a Spring3 - Maven project.
You can instantiate an Application Context by hand,
and lookup for a 'wurflManager'.
E.g.:
The context file may be (API 1.3.5-SNAPSHOT):
You can run it using Maven exec plugin.
A minimal but running example can be downloaded at
http://dl.dropbox.com/u/3009836/wurfl/wurfl-cli.zip
You can instantiate an Application Context by hand,
and lookup for a 'wurflManager'.
E.g.:
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>
A minimal but running example can be downloaded at
http://dl.dropbox.com/u/3009836/wurfl/wurfl-cli.zip
Who is online
Users browsing this forum: No registered users and 65 guests