The Artima Developer Community
Sponsored Link

Java Buzz Forum
Spring ME on Java ME

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Wilfred Springer

Posts: 176
Nickname: springerw
Registered: Sep, 2006

Wilfred Springer is a Software Architect at Xebia
Spring ME on Java ME Posted: Apr 20, 2009 6:28 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Wilfred Springer.
Original Post: Spring ME on Java ME
Feed Title: Distributed Reflections of the Third Kind
Feed URL: http://blog.flotsam.nl/feeds/posts/default/-/Java
Feed Description: Anything coming to my mind having to do with Java
Latest Java Buzz Posts
Latest Java Buzz Posts by Wilfred Springer
Latest Posts From Distributed Reflections of the Third Kind

Advertisement
Since last week, Spring ME provides a demo on how to use Spring ME ina Java ME context. The actual application is fairly trivial: it only lists some movies. These movies might either get loaded from an in memory list of movies, or they might get loaded from an RMS record store.

Simple Example



In order to run the simple example, you simply invoke mvn package. Note that - when you have never build the entire system before - you will need to run mvn install from the project root first; otherwise the build will not be able to locate the plugin or the API this example relies upon.

After running mvn package, the build should have created a spring-movies-me.jar and spring-movies-me.jad. You can use those files to run the application in an emulator (tested for MPP SDK, microemulator and WTK), or on your phone.

If you build the simple example, then the assembly will be based on the configuration in src/main/conf/in-memory-context.xml. As you will see, it simply wires an InMemoryMovieStore to a number of BaseMovie instances. Those are the movies that will get listed in the application.

Slightly Less Trivial Example



The other example - the one that illustrates using Spring ME to have an application that accesses a record store - is slightly more complicated. You build it using the command mvn -Pexample-rms install.

As a consequence of specifying the profile, the build will generate another BeanFactory (with the same name), based on an alternative Spring configuration file: src/main/conf/record-store-context.xml. This configuration file also defines an object called "movieFinder", but in this case, it's an instance of RecordStoreMovieFinder. This object is wired to a RecordStoreTemplate, which will load a bunch of movies from a record store.

The RecordStoreTemplate is not part of the Spring ME libraries. It's provided for illustrative purposes only. The most important property on RecordStoreTemplate is the 'name' property. This property defines the name of the record store that will be accessed. Another important property is the 'autoCreate' property. This will cause the record store to be created if it doesn't exist yet.

In many cases, it does not make an aweful lot of sense to have a record store without any data loaded by default. The RecordStoreTemplate allows you to preload a new database by accepting a defaultSource, and a defaultCodec. If these two properties are set, then the RecordStoreTemplate will take the list of objects from defaultSource, and translate the values of these objects into records using the defaultCodec. In this case, the defaultSource is using a factory method to get all objects from an InMemoryMovieStore.

You run the application in exactly the same way as the simple example.

Read: Spring ME on Java ME

Topic: New tabs, top sites, and how you learn to not be a hater Previous Topic   Next Topic Topic: JSF 2.0 Managed Beans in Maia

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use