• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

I want to develop a spring boot rest app

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have these files using these I have to develop a spring boot rest app.
How to do that?

I have these dependencies need to put in the pom.xml
<dependency>
        <groupId>com.scientiamobile.wurfl</groupId>
         <artifactId>wurfl</artifactId>
         <version>1.9.0.0</version>
   </dependency>


and the repositories


<repositories>
         <repository>
         <!-- Define the ID that was added in your Maven's settings.xml -->
         <id>com.scientiamobile.wurfl</id>
         <!---You do not need to change the following lines -->
         <name>com.scientiamobile.wurfl</name>
         <url>http://maven.scientiamobile.com:8081/nexus/content/repositories/private-repository</url>;
         </repository>
    </repositories>

I have the wurfl-helloworld-spring.jar and zip file which need to be placed in the the resources folder under src
Need to put a web.xml file and we should include these in the 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>

and The wurfl.ctx context file will contain:


<bean id="WurflHolder" class="com.scientiamobile.wurfl.core.GeneralWURFLEngine">
 <constructor-arg index="0" value="classpath:/wurfl.zip" />
 <!-- <constructor-arg index="1" value="<< patch here >>"/> -->
 <!-- <constructor-arg index="2" value="<< more patches here >>"/> -->
</bean>

<!-- DeviceCacheProvider -->
<bean id="deviceCacheProvider" class="com.scientiamobile.wurfl.core.cache.LRUMapCacheProvider" />
<!-- <bean id="deviceCacheProvider" class="com.scientiamobile.wurfl.core.cache.DoubleLRUMapCacheProvider" /> -->
<!-- <bean id="deviceCacheProvider" class="com.scientiamobile.wurfl.core.cache.HashMapCacheProvider" /> -->
<!-- <bean id="deviceCacheProvider" class="com.scientiamobile.wurfl.core.cache.NullCacheProvider" /> -->
<!-- <bean id="deviceCacheProvider" class="com.scientiamobile.wurfl.core.cache.EhCacheProvider" /> -->

If you would like to set a capability filter, you will need to add the following properties to your wurfl-ctx.xml:


<property name="capabilityFilter">
   <set>
   device_os
   brand_name
   model_name
   release_date
   has_qwerty_keyboard
   </set>
</property>


Finally, we can simply access the WURFLEngine instance with the code here (taken from a common Servlet method):

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
 WURFLEngine engine = (WURFLEngine)wac.getBean(WURFLEngine.class.getName());
 [...]
}



and the main program looks like this:

import com.scientiamobile.wurfl.core.Device;
import com.scientiamobile.wurfl.core.GeneralWURFLEngine;

public class Wurfl {

   public static void main(String[] args) {
       GeneralWURFLEngine wurfl = new GeneralWURFLEngine("wurfl.xml");
       // load method is available on API version 1.8.1.0 and above
       wurfl.load();

       String user_agent = "Mozilla/5.0 (Linux; Android 4.2.1; N9600 Build/JOP40D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.111 Mobile Safari/537.36";

       Device device = wurfl.getDeviceForRequest(user_agent);
       System.out.println("Is Tablet: " + device.getCapability('is_tablet'));
       System.out.println("Can Assign Phone Number: " + device.getCapability('can_assign_phone_number'));
   }
}


Please guide me how to develop this as a spring boot rest app.

Thanks.

reply
    Bookmark Topic Watch Topic
  • New Topic