Monday, August 16, 2010

Problem using Reflection and Casting objects on GAE

Hi everybody,

I hope this is right here in the GWT-forum.
OK, what I want to build is a GWT/GAE app, that loads dynamically
different UI´s,
depending on, what the user wants to do. These are not only UI´s these
are Modules, with
there own services and so on. And I want dynamically load these
Modules at runtime!!

So, what I did was the following:

I have datastore-entries, with the different class-names of the
Modules, stored as Stirngs.
Something like this:

public class Module1 implement Serializable, MyModuleInterface{

service xy = new Service .....

public void start(){} <<<< starts the Module (similar to
onModuleLoad())
}


public abstract Interface MyModuleInterface extends Serializable{
public abstract void start()
}


So, now what I do on the server is, I read the String from the
Datastore, and use reflection, to get the class of
the module. My Service implementation looks lioke this:

public myServiceImpl{
....
MyModuleInterface myObject = (MyModuleInterface)
Class.forName(String).newInstance
....
}

I always get an error at this line, it´s a a java castException. I don
´t know why this doesn´t work ar all.

I hope somebody can help me with this.

Thanks a lot.

Greets Alex

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate