Thank you all for your replies.
Here's a snippet of the code:
*This is my class and my constructor. If you notice the first line of the
constructor calls the super method.*
public class ELODaoImpl extends AbstractJcrDAO<CmsELOImpl<IMetadataKey>> {
private static final String[] MIXIN_TYPES = { "mix:versionable" };
public ELODaoImpl( Session session, Jcrom jcrom ) {
super(<CmsELOImpl<IMetadataKey>> ,session , jcrom, MIXIN_TYPES);
}
My problem is that on the first parameter of super I have to send the Class
object for CmsELOImpl<IMetadada> and I don't know how.
Here's the signature of AbstractJcrDAO's constructor
public abstract class AbstractJcrDAO<T> implements JcrDAO<T> {
/**
* Constructor.
*
* @param entityClass the class handled by this DAO implementation
* @param session the current JCR session
* @param jcrom the Jcrom instance to use for object mapping
* @param mixinTypes an array of mixin types to apply to new nodes
*/
public AbstractJcrDAO( Class<T> entityClass, Session session, Jcrom
jcrom, String[] mixinTypes ) {
Thank you in advance,
Rokham
On Wed, Oct 8, 2008 at 12:11 PM, Scott Cytacki <[EMAIL PROTECTED]> wrote:
>
> Stephen Bannasch wrote:
> >> Hi all,
> >>
> >> I'm having a hard time loading the '.class' object of a java generic
> class. In the older java if I had a class Student, I could simply call
> Student.class and get its Class object. But now if I have a Class <A <B>>,
> I've tried all the possible ways I could think of to get it's class object
> but I wasn't able. I've tried the net as well but I was out of luck :(....
> My work is kind of halted unless I solve this little problem so if anyone
> has more experience with Java Generics, your help is much appreciated.
> >>
> >
> > Can you show the simplest code which demonstrates the problem?
> >
>
> My guess is that you want to get the class object from a type parameter.
> That is something I wanted to do too, but that is actually not possible.
> The fundamental reason is that the type information for generics is not
> available at runtime.
>
> For example the following isn't possible:
>
> <T> void addNew(List<T> list) throws Exception{
> list.add(T.class.newInstance());
>
> }
>
>
> If you need to get the class from a type parameter, the best you can do
> is pass it in. So the
> method above would look like this:
>
> <T> void addNew(List<T> list, Class<T> klass) throws Exception{
> list.add(klass.newInstance());
> }
>
> Scott
>
> >
>
--
Rokham
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SAIL-Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/SAIL-Dev?hl=en
-~----------~----~----~----~------~----~------~--~---