I think that's only necessary if you want a non-public method. I don't exactly know in 
which cases the
SecurityManager allows you to get or invoke non-public Method objects

Age

> I think you may have to use
>
> Method method = peerClass.getDeclaredMethod("doSelect", types).
>
> john mcnally
>
> Age Mooy wrote:
> >
> > Static methods can be invoked with a null object reference.
> > It would look something like this:
> >
> > String className = "com.mywebsite.application. " + tablename + "Peer";
> >
> > Class[] types = new Class[] {Criteria.class};
> > Object[] parameters = new Object[] {new Criteria()};
> >
> > Class peerClass = Class.forName(className);
> > Method select = peerClass.getMethod("doSelect", types);
> >
> > List results = (List) m.invoke(null, parameters);
> >
> > Untested of course but it should be close.
> > Age
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
> > > John McNally
> > > Sent: Friday, September 21, 2001 17:33
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Get static instance of Peer dynamically
> > >
> > >
> > > I am not an expert using reflection but I think you will need to get an
> > > instance to pass to the Method.invoke command whether the method is
> > > static or not.  Is there some other way to invoke the method?  It seems
> > > like there should be so that you could use reflection on an abstract
> > > class.  It is not required in the case of Peers however since nothing
> > > prevents you from getting an instance of the class.  You should be able
> > > to invoke the method regardless of it being static.
> > >
> > > john mcnally
> > >
> > > John Colvin wrote:
> > > >
> > > > Hi
> > > > Is there a way that I can get a static instance of a peer class by using 
>Class.forName() or a
> > > class loader. I am writing an application that contructs simple forms for 
>updating databases
> > > dynamically by reading the database Map, TableMap and ColumnMaps an generating 
>the forms on the fly.
> > > >
> > > > When I come to do a select/update/delete I would like to load a static 
>instance by constructing a
> > > string for the class name and then load this class statically.
> > > >
> > > > ie from this :
> > > >
> > > > String class name = "com.mywebsite.application. " + tablename + "Peer";
> > > >
> > > > I know how to get an instance but I want the class as a static as the peer 
>methods are static and
> > > I would like to call them.
> > > >
> > > > Rgrds
> > > > John
> > > >
> > > > ---
> > > > Outgoing mail is certified Virus Free.
> > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > Version: 6.0.281 / Virus Database: 149 - Release Date: 9/18/2001
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to