SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Record Management Store
By using the RMS…let’s see how.
Persistent Storage Basics
• Simple record-oriented database (RMS) stored
in Flash mem
• Device-independent API
• Records are arrays of bytes that live in record
stores
• Record stores are shared within MIDlet suite
– MIDP 2.0 allows for optional sharing of record
stores between MIDlet suites

• Support for enumeration, sorting, and filtering
RMS Classes and Interfaces
• Defined in javax.microedition.rms package
• RecordStore
– Collection of records

• RecordEnumerator
– RecordStore enumerator

• Interfaces
– RecordComparator
– RecordFilter
– RecordListener
J2ME
Using Recordsint id
RecordStore

byte[] data

int id

byte[] data

int id

byte[] data

Old
RecordStore

• Nothing fancy here
– Array of bytes

• Integer values used a unique ID
• Records can be written using java.io API’s in
CLDC support:
– DataInputStream DataOutputStream
– ByteArrayInputStream ByteArrayOutputStream
RecordStore Operations
• Standard operations you would expect:
– openRecordStore(name,create)
– removeRecordStore(name)

• Get list of all known record stores in a MIDlet
suite
– listRecordStores()

• Get the size of the RS
– int getSize() - # of bytes used by the RS
– Int getSizeAvailable() – get amount of space
available for both record data and overhead
Creating a RecordStore
• Centered around record stores
– Small database that contains data called records

• javax.microedition.rms.RecordStore
• Record stores are identified by name
public static final String RS_NAME = "Tasks";
try {
m_RS =
RecordStore.openRecordStore(RS_NAME, bCreateIfNece
ssary);
}
catch (RecordStoreException ex) {
this.m_bRecordStoreError = true;
Closing/Deleting
RecordStore
• Need to make sure that you release the
resource
protected void destroyApp(boolean parm1) throws
javax.microedition.midlet.
MIDletStateChangeException {
try {
m_RS.closeRecordStore();
RecordStore.deleteRecordStore(RS_NAME);
}
catch (RecordStoreException ex) {
ex.printStackTrace();
System.out.println(ex.getMessage());
}
RMSMidlet
•

Sample MIDlet so that you can become familiar with RMS
and take a little tour.
– com.sb.samples.midlet.rms package

•

1.
2.
3.
4.

Our objective is to introduce RMS basics including:

RecordStore creation/closing
Record adding
Record lookup filtering via RecordFilter
RecordStore deletion (no deletions take place
though very easy to add)
5. Encapsulating RecordStore I/O operations in
static Utility Class methods for consistency
RMSMidlet Description
• Very simple
• Creates 5 TaskRow objects.
• Only object 3 has been designated as 'already
uploaded to server'.
• Shows a single form with only those TaskRows
that have not been uploaded to the server
(there are 4 of them in this case).
• On the form is the Record ID of the Task
• User can press 'View' button to see Task
TaskRow Class
• com.sb.samples.midlet.rms.TaskRow class that
acts as:
– Container object for Task values
– Decouples Task data from RecordStore
representation
– Static utility tool for consistent, maintainable
TaskRow-to-RecordStore I/O
Adding Records
• TaskRow offers a number of ways to add, read,
and update a record
public static int addRecord(RecordStore rs, TaskRow
taskRow) throws Exception {
byte[] bData = TaskRow.toByteArray(taskRow);
int iRecordID = rs.addRecord(bData, 0,
bData.length);
return iRecordID;
}
public static void updateRecord(RecordStore rs,
TaskRow taskRow) throws Exception {
byte[] bData = TaskRow.toByteArray(taskRow);
rs.setRecord(taskRow.iID, bData, 0,
bData.length);
}
Read Record
public static TaskRow readRecord(RecordStore rs, int iRecordID) throws Exception {
byte[] bData = rs.getRecord(iRecordID);
TaskRow tr = readRecord(bData);
tr.iID = iRecordID;
return tr;
}
// Maintain a single, consistent InputStream-based read mechanism
// for use by readRecord and any other usage
public static TaskRow readRecord(DataInputStream dis) throws Exception {

TaskRow tr = new TaskRow();
// the order of these reads must match
// the reads in TaskRow.toByteArray() with respect to:
// 1) the ordering of the values
// 2) the data type of each value
tr.iRadioID = dis.readInt();
tr.bUploaded = dis.readBoolean();
tr.sTask = dis.readUTF();
tr.sLongitude = dis.readUTF();
tr.sLatitude = dis.readUTF();
tr.sStatus = dis.readUTF();
return tr;
}
Read Record – Byte Array
// Offer a Byte Array-based reader for parts of the program that
// do not have a reference to RecordStore
// (e.g. by RecordFilter or RecordComparator that receive only
byte arrays)
public static TaskRow readRecord(byte[] bData) throws Exception {
ByteArrayInputStream bais = new ByteArrayInputStream(bData);
DataInputStream dis = new DataInputStream(bais);
try {
return readRecord(dis);
} finally {
if (null != dis){
try {
dis.close();
} catch (Exception e){
}
}
}
}
Lookup Filtering
• The RMSMidlet keeps track of records that
have not been uploaded to a server.
• And then we use a Filter to determine which
records need to be uploaded.
Filter for Records
protected TaskRow[] getUnuploadedTaskRows() throws Exception {
// Filter for tasks not yet uploaded to server
RecordFilter rf = new RecordFilterTaskNotUploaded();
// If we cared about ordering (e.g. Data created), we'd
// create a RecordComparator for that purpose. For now, don't sort.
RecordComparator nullRecordComparator = null;
boolean bKeepUpdated = false;
RecordEnumeration re = m_RS.enumerateRecords(rf,nullRecordComparator,
bKeepUpdated);
TaskRow[] aTaskRows = new TaskRow[re.numRecords()];
int i = 0;
while (re.hasNextElement()) {
int iNextRecord = 0;
try {
iNextRecord = re.nextRecordId();
TaskRow tr = TaskRow.readRecord(m_RS, iNextRecord);
aTaskRows[i] = tr;
i++;
}
catch (Exception ex) {
throw ex;
}
RecordFilterTaskNotUpload
ed Class
public class RecordFilterTaskNotUploaded
implements RecordFilter {
// only allow TaskRows that have not been uploaded to
// be accepted
public boolean matches(byte[] bCandidate) {
try {
TaskRow tr = TaskRow.readRecord(bCandidate);
if (tr.bUploaded == false) {
return true;
}
else {
return false;
}
}
catch (Exception e) {
return false;
}
RMS Tour
• That concludes our RMS tour.
• Unlike most tours, our RMS tour doesn’t end
at a gift shop…
Enterprise J2ME
(The whirlwind tour…)
J2ME and J2EE
• MIDP App’s become a client with Middle-tier
access
• XML data provided by a Servlet at well-known
URL or through Web Services
• Received as streaming data using networking
API’s
• Converted to String for parsing (i.e. kXML)
• Display using MIDP UI elements
Wireless Enterprise
Web Tier

Mobile Services

Tomcat

HTTP

XMLRPC
Servlet

Business Tier
Backend
Systems
kXML-RPC Usage
MIDP & XML
• MIDP networking allows access to data
formats like WML, XML
– We’re just interested in XML

• Upside
– Easy to work with
– Most are familiar with XML

• Downside
– Expensive
– Heavy String manipulation
– Footprint for the parser

• For some devices, not as big a deal because
MIDP XML Parsers
• A few parsers are available for MIDP
• kXML
– http://www.kxml.org
– Pull parser
– SAX and DOM support
– Written for J2ME/CLDC/MIDP

• NanoXml
– http://nanoxml.sourceforge.net/kvm.html
– DOM
– Ported
kXML-RPC
• kXML-RPC is a J2ME implementation of the
XML-RPC protocol built on top of the kXML
parser.
• Extremely lightweight mechanism for
exchanging data and invoking web services in
a neutral, standardized XML format.
• Hides the implementation of kXML
Dealing with Payloads
• Not really all that much to do here when using
kXML-RPC, the payload is handled for you on
the client, and the server uses a TaskHandler
to get the parameters
• Let’s look at making a call, and then a sample
of what a payload might look like if you
wanted to sniff the wire…
Making an XML-RPC Call
• Using XML-RPC is as simple as doing the
following:
String connect =
“http://www.switchbacksoftware.com/service.do”;
String ticker = "Submitting to Server";
updateUI();
XmlRpcClient xmlrpc = new XmlRpcClient(connect);
try {
String result = (String)
xmlrpc.execute(SB.submitTaskInfo, paramsArray);
Payload Example
<methodCall>
<methodName>SB.submitTaskInfo</methodName>
<params>
<param>
<value>
<string>Task1</string>
</value>
</param>
<param>
<value>
<string>W 12.32560</string>
</value>
</param>
<param>
<value>
<string>N 72.09090</string>
</value>
</param>
</params>
</methodCall>
J2ME Web Services API (WSA) JSR-172 (CLDC 1.0 & 1.1) - API's
standardize remote service invocation and XML parsing - subsets
of based on JAX-RPC 1.1 and SAX2
WTK 2.1, includes the libraries you need to develop MIDlets that
take advantage of J2ME WS and also includes a JAX-RPC stub
generator
Good article
http://developers.sun.com/techtopics/mobility/apis/articles/wsa/
Couple more advanced topics…
Timers & System Properties
Timer and TimerTask
• Introduced in J2SE 1.3 to schedule tasks for
execution by a background thread
• MIDP includes the Timer and TimerTask
classes
• Only J2SE classes that are not included in the
CLDC but are included in MIDP
• Timer API identical to J2SE version except
(there’s always an exception…) the constructor
that specifies whether the thread is a daemon
is missing.
Timer MIDlet
• Found in com.sb.samples.midlet.timer
package
• Objectives:
1. Introduce Timer and TimerTask
2. Extend RMS basics to include an ‘Updating
Task Records’
TimerMIDLet Description
• Creates a TimerTask that does the following
each time it is invoked:
– Scans RecordStore for TaskRows that have 'not
yet been uploaded‘
– Picks the first Task in the list and uploads it via
submitTask()
– Updates it's status value and flags it as 'uploaded‘
– Updates the respective record in the RecordStore
– Makes a sound upon upload
– Rebuilds the UI to reflect a dwindling list of 'not
uploaded' Tasks
Developer Note
• We’re not going to walk through the building
of the UI, since we’ve already seen how
Commands are added and handled in other
examples
TimerMidlet
public class TimerMidlet extends RMSMidlet {
Command m_CommandRefresh = null;
Timer m_TimerUpload = null;
TimerTask m_TimerTaskUploadATaskRow = null;
public TimerMidlet() {
super();
// need to create a TimerTask that gets the list
of not uploaded TaskRows and
// uploads them (or just the first) and
// updates the record to bUploade = true;
//
m_TimerTaskUploadATaskRow = new TimerTask(){
TimerMidlet
public void run() {
try {
// Get the list of un-uploaded Tasks
TaskRow[] aTaskRows = getUnuploadedTaskRows();
if (aTaskRows.length > 0){
TaskRow tr = m_aTaskRows[0];
// Submit them to server
submitTask(tr);
try {
// and update the RMS record
TaskRow.updateRecord(m_RS, tr);
}
TimerMidlet
catch (Exception ex) {
Alert a = new Alert("Task", "Error updating task "
+ tr.sTask + ":" + ex.getMessage(), null, AlertType.ERROR);
a.setTimeout(Alert.FOREVER);
AlertType.ERROR.playSound(m_Display);
m_Display.setCurrent(a, m_Display.getCurrent());
}
try {
buildUI();
}
catch (Exception e) {
}
m_Display.setCurrent(m_FormTasks);
}
} catch (Exception e) {
}
}
};
Start the Timer
m_TimerUpload = new Timer();
m_TimerUpload.schedule(this.m_TimerTaskUpl
oadATaskRow, 5000, 10000);
}
Submitting The Task
protected void submitTask(TaskRow tr) {
Vector vParams = new Vector();
vParams.addElement(tr.sTask);
vParams.addElement(tr.sLongitude);
vParams.addElement(tr.sLatitude);
vParams.addElement(new Integer(tr.iRadioID)); // radio Id
String sResult = null;
// normally would use a constants file or properties singleton
// or MIDlet attributes
String sConnect = HomeBase1.HOME_BASE_SERVER + HomeBase1.HOME_BASE_URL_FILE;
XmlRpcClient xmlrpc = new XmlRpcClient(sConnect);
try {
sResult = (String) xmlrpc.execute(HomeBase1.HOME_BASE_SUBMIT_RPC, vParams);
// When not using real phone, sleep so tos
// simulate delay for testing destroyApp(false)
// Thread.sleep(10000);
AlertType.INFO.playSound(m_Display);
tr.bUploaded = true;
}
catch (Exception e) {
sResult = "Error Submitting:" + e.getMessage();
AlertType.ERROR.playSound(m_Display);
}
tr.sStatus = sResult;
System Properties
Use of System Properties
• CLDC does not include the java.util.Properties
class
• Limited set of properties available using
•
•

•
•

System.getProperty( String key)
microedition.platform - Name of the host platform or device
(implementation-dependent)
microedition.encoding - Default character encoding Default
value:“ISO-8859-1”
microedition.configuration - Name and version of the
supported configuration “CLDC-1.1”
microedition.profiles - Names of the supported profiles
(implementation-dependent)
Bootcamp Wrap-up
J2ME is an exciting development opportunity

•
• Fairly easy to transition to if you are at Javaeese.
• Need to make some adjustments in your
programming habits (Come to the J2ME Best
Practices session to find out more!)
• J2ME/J2EE integration will be powerful for a
new breed of applications
If your company is interested in the full 2-day
intensive J2ME developer bootcamp or requires
contracting services for mobile projects, contact
me directly at

Weitere ähnliche Inhalte

Was ist angesagt?

Visualizing HPCC Systems Log Data Using ELK
Visualizing HPCC Systems Log Data Using ELKVisualizing HPCC Systems Log Data Using ELK
Visualizing HPCC Systems Log Data Using ELKHPCC Systems
 
Ordina Oracle Open World
Ordina Oracle Open WorldOrdina Oracle Open World
Ordina Oracle Open WorldMarco Gralike
 
Cloudy with a chance of Hadoop - DataWorks Summit 2017 San Jose
Cloudy with a chance of Hadoop - DataWorks Summit 2017 San JoseCloudy with a chance of Hadoop - DataWorks Summit 2017 San Jose
Cloudy with a chance of Hadoop - DataWorks Summit 2017 San JoseMingliang Liu
 
Intro to YARN (Hadoop 2.0) & Apex as YARN App (Next Gen Big Data)
Intro to YARN (Hadoop 2.0) & Apex as YARN App (Next Gen Big Data)Intro to YARN (Hadoop 2.0) & Apex as YARN App (Next Gen Big Data)
Intro to YARN (Hadoop 2.0) & Apex as YARN App (Next Gen Big Data)Apache Apex
 
Oracle HA, DR, data warehouse loading, and license reduction through edge app...
Oracle HA, DR, data warehouse loading, and license reduction through edge app...Oracle HA, DR, data warehouse loading, and license reduction through edge app...
Oracle HA, DR, data warehouse loading, and license reduction through edge app...Continuent
 
Stephan Ewen - Running Flink Everywhere
Stephan Ewen - Running Flink EverywhereStephan Ewen - Running Flink Everywhere
Stephan Ewen - Running Flink EverywhereFlink Forward
 
Set Up & Operate Tungsten Replicator
Set Up & Operate Tungsten ReplicatorSet Up & Operate Tungsten Replicator
Set Up & Operate Tungsten ReplicatorContinuent
 
Nov. 4, 2011 o reilly webcast-hbase- lars george
Nov. 4, 2011 o reilly webcast-hbase- lars georgeNov. 4, 2011 o reilly webcast-hbase- lars george
Nov. 4, 2011 o reilly webcast-hbase- lars georgeO'Reilly Media
 
Examining Oracle GoldenGate Trail Files
Examining Oracle GoldenGate Trail FilesExamining Oracle GoldenGate Trail Files
Examining Oracle GoldenGate Trail FilesBobby Curtis
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsStephane Manciot
 
Introduction to Spark with Scala
Introduction to Spark with ScalaIntroduction to Spark with Scala
Introduction to Spark with ScalaHimanshu Gupta
 
ORC: 2015 Faster, Better, Smaller
ORC: 2015 Faster, Better, SmallerORC: 2015 Faster, Better, Smaller
ORC: 2015 Faster, Better, SmallerDataWorks Summit
 
Apache Camel - Stéphane Kay - April 2011
Apache Camel - Stéphane Kay - April 2011Apache Camel - Stéphane Kay - April 2011
Apache Camel - Stéphane Kay - April 2011JUG Lausanne
 
Structured Streaming for Columnar Data Warehouses with Jack Gudenkauf
Structured Streaming for Columnar Data Warehouses with Jack GudenkaufStructured Streaming for Columnar Data Warehouses with Jack Gudenkauf
Structured Streaming for Columnar Data Warehouses with Jack GudenkaufDatabricks
 

Was ist angesagt? (16)

Visualizing HPCC Systems Log Data Using ELK
Visualizing HPCC Systems Log Data Using ELKVisualizing HPCC Systems Log Data Using ELK
Visualizing HPCC Systems Log Data Using ELK
 
Ordina Oracle Open World
Ordina Oracle Open WorldOrdina Oracle Open World
Ordina Oracle Open World
 
Cloudy with a chance of Hadoop - DataWorks Summit 2017 San Jose
Cloudy with a chance of Hadoop - DataWorks Summit 2017 San JoseCloudy with a chance of Hadoop - DataWorks Summit 2017 San Jose
Cloudy with a chance of Hadoop - DataWorks Summit 2017 San Jose
 
Os riak1-pdf
Os riak1-pdfOs riak1-pdf
Os riak1-pdf
 
Intro to YARN (Hadoop 2.0) & Apex as YARN App (Next Gen Big Data)
Intro to YARN (Hadoop 2.0) & Apex as YARN App (Next Gen Big Data)Intro to YARN (Hadoop 2.0) & Apex as YARN App (Next Gen Big Data)
Intro to YARN (Hadoop 2.0) & Apex as YARN App (Next Gen Big Data)
 
Oracle HA, DR, data warehouse loading, and license reduction through edge app...
Oracle HA, DR, data warehouse loading, and license reduction through edge app...Oracle HA, DR, data warehouse loading, and license reduction through edge app...
Oracle HA, DR, data warehouse loading, and license reduction through edge app...
 
Apache phoenix
Apache phoenixApache phoenix
Apache phoenix
 
Stephan Ewen - Running Flink Everywhere
Stephan Ewen - Running Flink EverywhereStephan Ewen - Running Flink Everywhere
Stephan Ewen - Running Flink Everywhere
 
Set Up & Operate Tungsten Replicator
Set Up & Operate Tungsten ReplicatorSet Up & Operate Tungsten Replicator
Set Up & Operate Tungsten Replicator
 
Nov. 4, 2011 o reilly webcast-hbase- lars george
Nov. 4, 2011 o reilly webcast-hbase- lars georgeNov. 4, 2011 o reilly webcast-hbase- lars george
Nov. 4, 2011 o reilly webcast-hbase- lars george
 
Examining Oracle GoldenGate Trail Files
Examining Oracle GoldenGate Trail FilesExamining Oracle GoldenGate Trail Files
Examining Oracle GoldenGate Trail Files
 
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streamsPSUG #52 Dataflow and simplified reactive programming with Akka-streams
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
 
Introduction to Spark with Scala
Introduction to Spark with ScalaIntroduction to Spark with Scala
Introduction to Spark with Scala
 
ORC: 2015 Faster, Better, Smaller
ORC: 2015 Faster, Better, SmallerORC: 2015 Faster, Better, Smaller
ORC: 2015 Faster, Better, Smaller
 
Apache Camel - Stéphane Kay - April 2011
Apache Camel - Stéphane Kay - April 2011Apache Camel - Stéphane Kay - April 2011
Apache Camel - Stéphane Kay - April 2011
 
Structured Streaming for Columnar Data Warehouses with Jack Gudenkauf
Structured Streaming for Columnar Data Warehouses with Jack GudenkaufStructured Streaming for Columnar Data Warehouses with Jack Gudenkauf
Structured Streaming for Columnar Data Warehouses with Jack Gudenkauf
 

Andere mochten auch

Record listener interface
Record listener interfaceRecord listener interface
Record listener interfacemyrajendra
 
Interface connection
Interface connectionInterface connection
Interface connectionmyrajendra
 
Session2-J2ME development-environment
Session2-J2ME development-environmentSession2-J2ME development-environment
Session2-J2ME development-environmentmuthusvm
 
Recordmanagment
RecordmanagmentRecordmanagment
Recordmanagmentmyrajendra
 
Session4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) EventsSession4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) Eventsmuthusvm
 
Byte arrayoutputstream
Byte arrayoutputstreamByte arrayoutputstream
Byte arrayoutputstreammyrajendra
 
Interface Record filter
Interface Record filterInterface Record filter
Interface Record filtermyrajendra
 
Session1 j2me introduction
Session1  j2me introductionSession1  j2me introduction
Session1 j2me introductionmuthusvm
 
High-Level Display: Screen J2ME User Interface
High-Level Display: Screen J2ME User InterfaceHigh-Level Display: Screen J2ME User Interface
High-Level Display: Screen J2ME User Interfacesuman sinkhwal
 
Session 3 J2ME Mobile Information Device Profile(MIDP) API
Session 3 J2ME Mobile Information Device Profile(MIDP)  APISession 3 J2ME Mobile Information Device Profile(MIDP)  API
Session 3 J2ME Mobile Information Device Profile(MIDP) APImuthusvm
 
Interface record comparator
Interface record comparatorInterface record comparator
Interface record comparatormyrajendra
 
Interface record enumeration
Interface record enumerationInterface record enumeration
Interface record enumerationmyrajendra
 
Class data outputstream
Class data outputstreamClass data outputstream
Class data outputstreammyrajendra
 
Session11 J2ME MID-Low Level User Interface(LLUI)-graphics
Session11 J2ME MID-Low Level User Interface(LLUI)-graphicsSession11 J2ME MID-Low Level User Interface(LLUI)-graphics
Session11 J2ME MID-Low Level User Interface(LLUI)-graphicsmuthusvm
 

Andere mochten auch (20)

Record listener interface
Record listener interfaceRecord listener interface
Record listener interface
 
Wr ex2
Wr ex2Wr ex2
Wr ex2
 
Interface connection
Interface connectionInterface connection
Interface connection
 
Session2-J2ME development-environment
Session2-J2ME development-environmentSession2-J2ME development-environment
Session2-J2ME development-environment
 
Exceptions
ExceptionsExceptions
Exceptions
 
Recordmanagment
RecordmanagmentRecordmanagment
Recordmanagment
 
Session4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) EventsSession4 J2ME Mobile Information Device Profile(MIDP) Events
Session4 J2ME Mobile Information Device Profile(MIDP) Events
 
Byte arrayoutputstream
Byte arrayoutputstreamByte arrayoutputstream
Byte arrayoutputstream
 
Interface Record filter
Interface Record filterInterface Record filter
Interface Record filter
 
Session1 j2me introduction
Session1  j2me introductionSession1  j2me introduction
Session1 j2me introduction
 
High-Level Display: Screen J2ME User Interface
High-Level Display: Screen J2ME User InterfaceHigh-Level Display: Screen J2ME User Interface
High-Level Display: Screen J2ME User Interface
 
Record store
Record storeRecord store
Record store
 
Session 3 J2ME Mobile Information Device Profile(MIDP) API
Session 3 J2ME Mobile Information Device Profile(MIDP)  APISession 3 J2ME Mobile Information Device Profile(MIDP)  API
Session 3 J2ME Mobile Information Device Profile(MIDP) API
 
Interface record comparator
Interface record comparatorInterface record comparator
Interface record comparator
 
M rec enum
M rec enumM rec enum
M rec enum
 
Interface record enumeration
Interface record enumerationInterface record enumeration
Interface record enumeration
 
J2ME
J2MEJ2ME
J2ME
 
J2 me 1
J2 me 1J2 me 1
J2 me 1
 
Class data outputstream
Class data outputstreamClass data outputstream
Class data outputstream
 
Session11 J2ME MID-Low Level User Interface(LLUI)-graphics
Session11 J2ME MID-Low Level User Interface(LLUI)-graphicsSession11 J2ME MID-Low Level User Interface(LLUI)-graphics
Session11 J2ME MID-Low Level User Interface(LLUI)-graphics
 

Ähnlich wie Recordmanagment2

MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStoreMariaDB plc
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructureharendra_pathak
 
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher - DotNet 7 What's new.pptxTamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher - DotNet 7 What's new.pptxTamir Dresher
 
Riga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSRiga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSAntons Kranga
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS BackendLaurent Cerveau
 
Informix Data Streaming Overview
Informix Data Streaming OverviewInformix Data Streaming Overview
Informix Data Streaming OverviewBrian Hughes
 
DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...
 DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and... DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...
DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...PROIDEA
 
Oracle training-in-hyderabad
Oracle training-in-hyderabadOracle training-in-hyderabad
Oracle training-in-hyderabadsreehari orienit
 
Create C++ Applications with the Persistent Memory Development Kit
Create C++ Applications with the Persistent Memory Development KitCreate C++ Applications with the Persistent Memory Development Kit
Create C++ Applications with the Persistent Memory Development KitIntel® Software
 
'Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash''Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash'Cloud Elements
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentationMichael Keane
 
IBM Cloud Native Day April 2021: Serverless Data Lake
IBM Cloud Native Day April 2021: Serverless Data LakeIBM Cloud Native Day April 2021: Serverless Data Lake
IBM Cloud Native Day April 2021: Serverless Data LakeTorsten Steinbach
 
Data guard logical_r3.1
Data guard logical_r3.1Data guard logical_r3.1
Data guard logical_r3.1Ram Naani
 
Ms sql server architecture
Ms sql server architectureMs sql server architecture
Ms sql server architectureAjeet Singh
 
Redis Streams - Fiverr Tech5 meetup
Redis Streams - Fiverr Tech5 meetupRedis Streams - Fiverr Tech5 meetup
Redis Streams - Fiverr Tech5 meetupItamar Haber
 
Data Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby UsageData Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby UsageSATOSHI TAGOMORI
 

Ähnlich wie Recordmanagment2 (20)

MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStore
 
Architectures, Frameworks and Infrastructure
Architectures, Frameworks and InfrastructureArchitectures, Frameworks and Infrastructure
Architectures, Frameworks and Infrastructure
 
Tamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher - DotNet 7 What's new.pptxTamir Dresher - DotNet 7 What's new.pptx
Tamir Dresher - DotNet 7 What's new.pptx
 
Riga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWSRiga dev day: Lambda architecture at AWS
Riga dev day: Lambda architecture at AWS
 
Elements for an iOS Backend
Elements for an iOS BackendElements for an iOS Backend
Elements for an iOS Backend
 
Informix Data Streaming Overview
Informix Data Streaming OverviewInformix Data Streaming Overview
Informix Data Streaming Overview
 
DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...
 DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and... DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...
DOD 2016 - Stefan Thies - Monitoring and Log Management for Docker Swarm and...
 
Oracle training-in-hyderabad
Oracle training-in-hyderabadOracle training-in-hyderabad
Oracle training-in-hyderabad
 
JavaCro'14 - Using WildFly core to build high performance web server – Tomaž ...
JavaCro'14 - Using WildFly core to build high performance web server – Tomaž ...JavaCro'14 - Using WildFly core to build high performance web server – Tomaž ...
JavaCro'14 - Using WildFly core to build high performance web server – Tomaž ...
 
Create C++ Applications with the Persistent Memory Development Kit
Create C++ Applications with the Persistent Memory Development KitCreate C++ Applications with the Persistent Memory Development Kit
Create C++ Applications with the Persistent Memory Development Kit
 
'Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash''Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash'
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
 
Monitoring and Log Management for
Monitoring and Log Management forMonitoring and Log Management for
Monitoring and Log Management for
 
Bigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_appBigdata meetup dwarak_realtime_score_app
Bigdata meetup dwarak_realtime_score_app
 
IBM Cloud Native Day April 2021: Serverless Data Lake
IBM Cloud Native Day April 2021: Serverless Data LakeIBM Cloud Native Day April 2021: Serverless Data Lake
IBM Cloud Native Day April 2021: Serverless Data Lake
 
Mysql database
Mysql databaseMysql database
Mysql database
 
Data guard logical_r3.1
Data guard logical_r3.1Data guard logical_r3.1
Data guard logical_r3.1
 
Ms sql server architecture
Ms sql server architectureMs sql server architecture
Ms sql server architecture
 
Redis Streams - Fiverr Tech5 meetup
Redis Streams - Fiverr Tech5 meetupRedis Streams - Fiverr Tech5 meetup
Redis Streams - Fiverr Tech5 meetup
 
Data Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby UsageData Analytics Service Company and Its Ruby Usage
Data Analytics Service Company and Its Ruby Usage
 

Mehr von myrajendra (20)

Fundamentals
FundamentalsFundamentals
Fundamentals
 
Data type
Data typeData type
Data type
 
Hibernate example1
Hibernate example1Hibernate example1
Hibernate example1
 
Jdbc workflow
Jdbc workflowJdbc workflow
Jdbc workflow
 
2 jdbc drivers
2 jdbc drivers2 jdbc drivers
2 jdbc drivers
 
3 jdbc api
3 jdbc api3 jdbc api
3 jdbc api
 
4 jdbc step1
4 jdbc step14 jdbc step1
4 jdbc step1
 
Dao example
Dao exampleDao example
Dao example
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Internal
InternalInternal
Internal
 
3. elements
3. elements3. elements
3. elements
 
2. attributes
2. attributes2. attributes
2. attributes
 
1 introduction to html
1 introduction to html1 introduction to html
1 introduction to html
 
Headings
HeadingsHeadings
Headings
 
Forms
FormsForms
Forms
 
Css
CssCss
Css
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Views
ViewsViews
Views
 
Starting jdbc
Starting jdbcStarting jdbc
Starting jdbc
 

Kürzlich hochgeladen

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 

Kürzlich hochgeladen (20)

The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 

Recordmanagment2

  • 1.
  • 3. By using the RMS…let’s see how.
  • 4. Persistent Storage Basics • Simple record-oriented database (RMS) stored in Flash mem • Device-independent API • Records are arrays of bytes that live in record stores • Record stores are shared within MIDlet suite – MIDP 2.0 allows for optional sharing of record stores between MIDlet suites • Support for enumeration, sorting, and filtering
  • 5. RMS Classes and Interfaces • Defined in javax.microedition.rms package • RecordStore – Collection of records • RecordEnumerator – RecordStore enumerator • Interfaces – RecordComparator – RecordFilter – RecordListener
  • 6. J2ME Using Recordsint id RecordStore byte[] data int id byte[] data int id byte[] data Old RecordStore • Nothing fancy here – Array of bytes • Integer values used a unique ID • Records can be written using java.io API’s in CLDC support: – DataInputStream DataOutputStream – ByteArrayInputStream ByteArrayOutputStream
  • 7. RecordStore Operations • Standard operations you would expect: – openRecordStore(name,create) – removeRecordStore(name) • Get list of all known record stores in a MIDlet suite – listRecordStores() • Get the size of the RS – int getSize() - # of bytes used by the RS – Int getSizeAvailable() – get amount of space available for both record data and overhead
  • 8. Creating a RecordStore • Centered around record stores – Small database that contains data called records • javax.microedition.rms.RecordStore • Record stores are identified by name public static final String RS_NAME = "Tasks"; try { m_RS = RecordStore.openRecordStore(RS_NAME, bCreateIfNece ssary); } catch (RecordStoreException ex) { this.m_bRecordStoreError = true;
  • 9. Closing/Deleting RecordStore • Need to make sure that you release the resource protected void destroyApp(boolean parm1) throws javax.microedition.midlet. MIDletStateChangeException { try { m_RS.closeRecordStore(); RecordStore.deleteRecordStore(RS_NAME); } catch (RecordStoreException ex) { ex.printStackTrace(); System.out.println(ex.getMessage()); }
  • 10. RMSMidlet • Sample MIDlet so that you can become familiar with RMS and take a little tour. – com.sb.samples.midlet.rms package • 1. 2. 3. 4. Our objective is to introduce RMS basics including: RecordStore creation/closing Record adding Record lookup filtering via RecordFilter RecordStore deletion (no deletions take place though very easy to add) 5. Encapsulating RecordStore I/O operations in static Utility Class methods for consistency
  • 11. RMSMidlet Description • Very simple • Creates 5 TaskRow objects. • Only object 3 has been designated as 'already uploaded to server'. • Shows a single form with only those TaskRows that have not been uploaded to the server (there are 4 of them in this case). • On the form is the Record ID of the Task • User can press 'View' button to see Task
  • 12. TaskRow Class • com.sb.samples.midlet.rms.TaskRow class that acts as: – Container object for Task values – Decouples Task data from RecordStore representation – Static utility tool for consistent, maintainable TaskRow-to-RecordStore I/O
  • 13. Adding Records • TaskRow offers a number of ways to add, read, and update a record public static int addRecord(RecordStore rs, TaskRow taskRow) throws Exception { byte[] bData = TaskRow.toByteArray(taskRow); int iRecordID = rs.addRecord(bData, 0, bData.length); return iRecordID; } public static void updateRecord(RecordStore rs, TaskRow taskRow) throws Exception { byte[] bData = TaskRow.toByteArray(taskRow); rs.setRecord(taskRow.iID, bData, 0, bData.length); }
  • 14. Read Record public static TaskRow readRecord(RecordStore rs, int iRecordID) throws Exception { byte[] bData = rs.getRecord(iRecordID); TaskRow tr = readRecord(bData); tr.iID = iRecordID; return tr; } // Maintain a single, consistent InputStream-based read mechanism // for use by readRecord and any other usage public static TaskRow readRecord(DataInputStream dis) throws Exception { TaskRow tr = new TaskRow(); // the order of these reads must match // the reads in TaskRow.toByteArray() with respect to: // 1) the ordering of the values // 2) the data type of each value tr.iRadioID = dis.readInt(); tr.bUploaded = dis.readBoolean(); tr.sTask = dis.readUTF(); tr.sLongitude = dis.readUTF(); tr.sLatitude = dis.readUTF(); tr.sStatus = dis.readUTF(); return tr; }
  • 15. Read Record – Byte Array // Offer a Byte Array-based reader for parts of the program that // do not have a reference to RecordStore // (e.g. by RecordFilter or RecordComparator that receive only byte arrays) public static TaskRow readRecord(byte[] bData) throws Exception { ByteArrayInputStream bais = new ByteArrayInputStream(bData); DataInputStream dis = new DataInputStream(bais); try { return readRecord(dis); } finally { if (null != dis){ try { dis.close(); } catch (Exception e){ } } } }
  • 16. Lookup Filtering • The RMSMidlet keeps track of records that have not been uploaded to a server. • And then we use a Filter to determine which records need to be uploaded.
  • 17. Filter for Records protected TaskRow[] getUnuploadedTaskRows() throws Exception { // Filter for tasks not yet uploaded to server RecordFilter rf = new RecordFilterTaskNotUploaded(); // If we cared about ordering (e.g. Data created), we'd // create a RecordComparator for that purpose. For now, don't sort. RecordComparator nullRecordComparator = null; boolean bKeepUpdated = false; RecordEnumeration re = m_RS.enumerateRecords(rf,nullRecordComparator, bKeepUpdated); TaskRow[] aTaskRows = new TaskRow[re.numRecords()]; int i = 0; while (re.hasNextElement()) { int iNextRecord = 0; try { iNextRecord = re.nextRecordId(); TaskRow tr = TaskRow.readRecord(m_RS, iNextRecord); aTaskRows[i] = tr; i++; } catch (Exception ex) { throw ex; }
  • 18. RecordFilterTaskNotUpload ed Class public class RecordFilterTaskNotUploaded implements RecordFilter { // only allow TaskRows that have not been uploaded to // be accepted public boolean matches(byte[] bCandidate) { try { TaskRow tr = TaskRow.readRecord(bCandidate); if (tr.bUploaded == false) { return true; } else { return false; } } catch (Exception e) { return false; }
  • 19. RMS Tour • That concludes our RMS tour. • Unlike most tours, our RMS tour doesn’t end at a gift shop…
  • 21. J2ME and J2EE • MIDP App’s become a client with Middle-tier access • XML data provided by a Servlet at well-known URL or through Web Services • Received as streaming data using networking API’s • Converted to String for parsing (i.e. kXML) • Display using MIDP UI elements
  • 22. Wireless Enterprise Web Tier Mobile Services Tomcat HTTP XMLRPC Servlet Business Tier Backend Systems
  • 24. MIDP & XML • MIDP networking allows access to data formats like WML, XML – We’re just interested in XML • Upside – Easy to work with – Most are familiar with XML • Downside – Expensive – Heavy String manipulation – Footprint for the parser • For some devices, not as big a deal because
  • 25. MIDP XML Parsers • A few parsers are available for MIDP • kXML – http://www.kxml.org – Pull parser – SAX and DOM support – Written for J2ME/CLDC/MIDP • NanoXml – http://nanoxml.sourceforge.net/kvm.html – DOM – Ported
  • 26. kXML-RPC • kXML-RPC is a J2ME implementation of the XML-RPC protocol built on top of the kXML parser. • Extremely lightweight mechanism for exchanging data and invoking web services in a neutral, standardized XML format. • Hides the implementation of kXML
  • 27. Dealing with Payloads • Not really all that much to do here when using kXML-RPC, the payload is handled for you on the client, and the server uses a TaskHandler to get the parameters • Let’s look at making a call, and then a sample of what a payload might look like if you wanted to sniff the wire…
  • 28. Making an XML-RPC Call • Using XML-RPC is as simple as doing the following: String connect = “http://www.switchbacksoftware.com/service.do”; String ticker = "Submitting to Server"; updateUI(); XmlRpcClient xmlrpc = new XmlRpcClient(connect); try { String result = (String) xmlrpc.execute(SB.submitTaskInfo, paramsArray);
  • 30. J2ME Web Services API (WSA) JSR-172 (CLDC 1.0 & 1.1) - API's standardize remote service invocation and XML parsing - subsets of based on JAX-RPC 1.1 and SAX2 WTK 2.1, includes the libraries you need to develop MIDlets that take advantage of J2ME WS and also includes a JAX-RPC stub generator Good article http://developers.sun.com/techtopics/mobility/apis/articles/wsa/
  • 31. Couple more advanced topics… Timers & System Properties
  • 32. Timer and TimerTask • Introduced in J2SE 1.3 to schedule tasks for execution by a background thread • MIDP includes the Timer and TimerTask classes • Only J2SE classes that are not included in the CLDC but are included in MIDP • Timer API identical to J2SE version except (there’s always an exception…) the constructor that specifies whether the thread is a daemon is missing.
  • 33. Timer MIDlet • Found in com.sb.samples.midlet.timer package • Objectives: 1. Introduce Timer and TimerTask 2. Extend RMS basics to include an ‘Updating Task Records’
  • 34. TimerMIDLet Description • Creates a TimerTask that does the following each time it is invoked: – Scans RecordStore for TaskRows that have 'not yet been uploaded‘ – Picks the first Task in the list and uploads it via submitTask() – Updates it's status value and flags it as 'uploaded‘ – Updates the respective record in the RecordStore – Makes a sound upon upload – Rebuilds the UI to reflect a dwindling list of 'not uploaded' Tasks
  • 35. Developer Note • We’re not going to walk through the building of the UI, since we’ve already seen how Commands are added and handled in other examples
  • 36. TimerMidlet public class TimerMidlet extends RMSMidlet { Command m_CommandRefresh = null; Timer m_TimerUpload = null; TimerTask m_TimerTaskUploadATaskRow = null; public TimerMidlet() { super(); // need to create a TimerTask that gets the list of not uploaded TaskRows and // uploads them (or just the first) and // updates the record to bUploade = true; // m_TimerTaskUploadATaskRow = new TimerTask(){
  • 37. TimerMidlet public void run() { try { // Get the list of un-uploaded Tasks TaskRow[] aTaskRows = getUnuploadedTaskRows(); if (aTaskRows.length > 0){ TaskRow tr = m_aTaskRows[0]; // Submit them to server submitTask(tr); try { // and update the RMS record TaskRow.updateRecord(m_RS, tr); }
  • 38. TimerMidlet catch (Exception ex) { Alert a = new Alert("Task", "Error updating task " + tr.sTask + ":" + ex.getMessage(), null, AlertType.ERROR); a.setTimeout(Alert.FOREVER); AlertType.ERROR.playSound(m_Display); m_Display.setCurrent(a, m_Display.getCurrent()); } try { buildUI(); } catch (Exception e) { } m_Display.setCurrent(m_FormTasks); } } catch (Exception e) { } } };
  • 39. Start the Timer m_TimerUpload = new Timer(); m_TimerUpload.schedule(this.m_TimerTaskUpl oadATaskRow, 5000, 10000); }
  • 40. Submitting The Task protected void submitTask(TaskRow tr) { Vector vParams = new Vector(); vParams.addElement(tr.sTask); vParams.addElement(tr.sLongitude); vParams.addElement(tr.sLatitude); vParams.addElement(new Integer(tr.iRadioID)); // radio Id String sResult = null; // normally would use a constants file or properties singleton // or MIDlet attributes String sConnect = HomeBase1.HOME_BASE_SERVER + HomeBase1.HOME_BASE_URL_FILE; XmlRpcClient xmlrpc = new XmlRpcClient(sConnect); try { sResult = (String) xmlrpc.execute(HomeBase1.HOME_BASE_SUBMIT_RPC, vParams); // When not using real phone, sleep so tos // simulate delay for testing destroyApp(false) // Thread.sleep(10000); AlertType.INFO.playSound(m_Display); tr.bUploaded = true; } catch (Exception e) { sResult = "Error Submitting:" + e.getMessage(); AlertType.ERROR.playSound(m_Display); } tr.sStatus = sResult;
  • 42. Use of System Properties • CLDC does not include the java.util.Properties class • Limited set of properties available using • • • • System.getProperty( String key) microedition.platform - Name of the host platform or device (implementation-dependent) microedition.encoding - Default character encoding Default value:“ISO-8859-1” microedition.configuration - Name and version of the supported configuration “CLDC-1.1” microedition.profiles - Names of the supported profiles (implementation-dependent)
  • 43. Bootcamp Wrap-up J2ME is an exciting development opportunity • • Fairly easy to transition to if you are at Javaeese. • Need to make some adjustments in your programming habits (Come to the J2ME Best Practices session to find out more!) • J2ME/J2EE integration will be powerful for a new breed of applications If your company is interested in the full 2-day intensive J2ME developer bootcamp or requires contracting services for mobile projects, contact me directly at