Quote:
Originally Posted by kosh
So now, if 1.cod were to call a method from a class in 2.cod, doesnt this mean that 2.cod has to be set up as a library project and 1.cod has to have a dependency on 2.cod (in order to access its modules)?
|
There are ways to do that while avoiding library semantics, but since this is a collaborative effort what I would recommend is that 1.cod expose a class and method specifically for 2.cod (and others perhaps) to call to set the data in a way similar to the RIM libraries:
My1CodClass.getInstance().setURL(String url);
When 1.cod is compiled a JAR file will be produced. Use that JAR as an external library to compile 2.cod, 3.cod, 4.cod, etc. In this case 1.cod doesn't need any prior knowledge about where the data is going to come from.
If 1.cod must control when the data is fetched, then you can use:
Code:
try {
Class class = Class.forName("my.cod.DataClass");
my.cod.DataClass dataClass = class.newInstance();
String url = dataClass.getUrl();
} catch (ClassNotFoundException e) {
// Processing for class not found, for example if 2.cod is not loaded on the device.
}
In this case 1.cod and 2.cod would have to share the definition of my.cod.DataClass.
I've used both of these methods.
You could also use the RuntimeStore and global events as suggested above