Kommons
-
Upload
antonio-terreno -
Category
Technology
-
view
1.499 -
download
0
description
Transcript of Kommons
![Page 1: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/1.jpg)
Kommons: reusable objects for j2me
Antonio Terreno
Mobile DevelopmentFluidtime DataServices GmbH
[email protected]://kommons.java2me.org/
![Page 2: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/2.jpg)
Long-term Goal● To have a collection of J2ME classes
– Stable– Easy to use, to integrate– Tested (j2meunit)– Open– Well coded
![Page 3: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/3.jpg)
Kommons logging● Logger “like” log4j
– Appenders● Console● Bluetooth● Http
– Debugging levels● Enabled/Disabled● Debug level● Info level
– Easy to use● Perfect integration with Log4E
![Page 4: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/4.jpg)
Kommons loggingprivate final static Logger logger =
Logger.getLogger("LoggerExampleMIDlet");
protected void startApp() { logger.addAppender(AppenderType.CONSOLE); logger.addAppender(AppenderType.PHONE); logger.setDebugEnabled(true);
if (logger.isDebugEnabled()) { logger.debug("startApp() - start"); }
initDisplay();
![Page 5: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/5.jpg)
Midp Worker● Before/After pattern simple implementation
public abstract class MIDPWorker extends TimerTask
public final void run() { before();
try { doWork(); } catch (LogicalException e) { doCatch(e); } finally { after();
![Page 6: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/6.jpg)
ISO helpers● IsoDate Helper
– IsoDate parser for ISO 8601 format– http://www.w3.org/TR/xmlschema-2/#date–
● IsoDuration Helper– IsoDuration parser for ISO 8601 format.– http://www.w3.org/TR/xmlschema-2/#duration– IsoDuration format is (-)PnYnMnDTnHnMnS
![Page 7: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/7.jpg)
ISO helpers● IsoDate Helper
– IsoDate parser for ISO 8601 format– http://www.w3.org/TR/xmlschema-2/#date–
● IsoDuration Helper– IsoDuration parser for ISO 8601 format.– http://www.w3.org/TR/xmlschema-2/#duration– IsoDuration format is (-)PnYnMnDTnHnMnS
![Page 8: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/8.jpg)
I/O● Bluetooth
– A simple send & receive client● Needs your help! :-)● Integration with BtFree??? Federico Paparoni???
● HTTP– A complete http client (post/get)– URL encoding– Cookie auth supported– Easy parameters use
![Page 9: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/9.jpg)
Http example try { String xml = XMLAdapter.getInstance().toXML(msg); logger.debug("Posting", xml); xml = HttpClient.URLencode(xml);
HttpClient httpClient = new HttpClient(); String[][] params = { { "sXmlMobileRequest", xml }, { "userName", UserPropertiesWrapper.currentUser() }, };
String response = httpClient.post(Fluidtime.ENDPOINT + "TimeWindow/update.action", params);
msg = (Message) XMLAdapter.getInstance().fromXML(response); } catch (LogicalException e) { logger.debug(e);
![Page 10: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/10.jpg)
The cache● A persistence cache for MIDP 2.0
– save(PersistentObject e)– delete(PersistentObject e)– PersistentObject find(String id)– reset()– boolean isEmpty()
![Page 11: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/11.jpg)
RMS-xml cache● Runtime cache:
– An hash table containing objects● Shutting down?
– Storing objects in xml format● Starting up?
– Retrive of the objects from the rms
![Page 12: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/12.jpg)
Problems● How to retrive the objects in cache?
– EntityRecordMapping idea– It contains the reference from an Entity id and
Its Record Store Id
● How to find an object?● 1. in the runtime cache● 2. in the rms● 3. if found it will be putted on the cache & used
![Page 13: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/13.jpg)
RMS-xml cache
RMSE.R.mapping
Cache
Model
![Page 14: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/14.jpg)
Benefits● Possibility to store any kind of object● Possibility to store collection of objects
![Page 15: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/15.jpg)
Next Steps of Action● Involve developers● Merge other interesting project into ● Javadoc● Website● Licence● Junit testing● Receive feedbacks● ...
![Page 16: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/16.jpg)
Credits to● Alberto Lagna (CTO Fluidtime GmbH)● Jean-Marie Dautelle (Javolution.org)● Fluidtime GmbH● Java2me.org forum :-)● Jmdf of course!
![Page 17: Kommons](https://reader035.fdocuments.net/reader035/viewer/2022081811/54631161b4af9f581c8b4aa8/html5/thumbnails/17.jpg)
Q&A● Questions? Suggestions?