Java API configuration with Spring

sm_support2
Posts: 294
Joined: Mon Jun 20, 2011 5:04 pm

Java API configuration with Spring

Postby sm_support2 » Fri Jun 24, 2011 1:28 pm

What's the simplest and fastes way to configure the Java API with Spring?

sm_support2
Posts: 294
Joined: Mon Jun 20, 2011 5:04 pm

Re: Java API configuration with Spring

Postby sm_support2 » Fri Jun 24, 2011 1:39 pm

Starting with version 1.3 of the API, ScientiaMobile enabled a super-simple one-liner Spring config for the WURFL API which you can adopt as long as you stick to certain conventions about the name and the position of certain files.

Write a simple XML Spring config file, such as (usual Spring namespace and schema prologue omitted, see http://static.springsource.org/spring/d ... y-metadata) :

<beans default-autowire="no">
<bean class="net.sourceforge.wurfl.spring.SpringWurflManager"/>
</beans>

You can name the file whatever you want, we recommend wurfl-ctx.xml. Place the file under /WEB-INF/.

Note: if you name the file 'applicationContext.xml', Spring will find it without the need for further configuration.

Of course, you'll need to configure the Servlet API to let it kow about Spring's presence.
This is business as usual for /WEB-INF/web.xml

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/wurfl-ctx.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

You can omit the <context-param> part, if the file is called /WEB-INF/applicationContext.xml.

Thsi simplified configuration assumes that the wirfl file is available as: /WEB-INF/wurfl.zip.

If this is not the case or you also want to pull in extra patch files, you'll need to configure SpringWurflManager to let it know where those file can be found. More info at the javadocs:

http://www.scientiamobile.com/api-doc/java/


Who is online

Users browsing this forum: No registered users and 13 guests