04-07-2009, 10:58 PM
|
#1 (permalink)
|
| New Member
Join Date: Apr 2009 Model: 7100 PIN: N/A Carrier: airtel
Posts: 6
Post Thanks: 0 Thanked 0 Times in 0 Posts
| Multiple queries around CodeModuleManager, Class.forClass Please Login to Remove! I've searched through the forums, and got a few bits and pieces, enough to be able to do the following:
1) Programmatically download and "launch" a "CLDC Application" COD file: I "stream" a COD file (size less than 85KB) to the Blackberry device, extract its contents into a byte buffer,do CodeModuleManager.createNewModule() on the byte buffer, use CodeModuleManager.saveNewModule() to register into library, get a CMM_OK (or whatever the notification was for successful load). After this, I can use ApplicationManager to get the app descriptor for the code module, and then ApplicationManager.launch() it. This works fine.
2) Programmatically download a "CLDC" library, and TRIED to load a class from it:
This is a little more involved:
a) created a library COD defining an interface IUsable with a foo() method
b) wrote a CLDC application COD that references this COD, and can therefore call foo() on any object implementing IUsable
c) wrote a library COD containing a class that implements IUsable (of course, it too references the library COD in a).). Let the class that implements IUsable be "com.test.Usable".
Now... I deploy COD a) and COD b) through the Eclipse IDE (I use a simulator) normally. And then.. I "programmatically" stream the COD c) to the device, and I am even able to follow steps in test 1) to "save" the code module into library (note that I do not reset the device or anything after it).
I thought that the only thing I would have to do in COD b) is:
IUsable usable = (IUsable) Class.forClass("com.test.Usable").newInstance();
if(null == usable) {
usable.foo();
}
However, when I do this, I get a ClassCastException.. which i assume means that I've missed some step in "linking" my COD c) at run-time to the COD b).
Now, my questions:
1. I wanted to know, IS there a step I'm missing in order to accomplish above test? In essence, what I'm trying to do is like a "dynamic" classloader, where you can get new classes merely by "downloading" library CODs containing those classes, and then use CodeModuleManager APIs to install those modules into the Blackberry. The problem here is that the library COD gets installed, but I'm still unable to load classes from it. I wonder if there's a way to dynamically define a dependency (like what we do in .JAD files)?
2. What sort of checks will I have to do when I try "updating" such library modules (assuming my question 1. gets solved)? I'm guessing that everytime I want to update the library, I'll have to: a) stop other modules using it b) delete the module c) replace the COD d) install the COD? Or can I make use of the "overwrite code module" feature in CodeModuleManager to make it easier?
Last edited by neeltiwari : 04-07-2009 at 10:59 PM.
Reason: some wrong references.. corrected it now
|
| Offline
| |