You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by John Davis <jo...@bellsouth.net> on 2002/08/26 02:15:11 UTC

Action and Pull Service

Within a VelocityAction class I am trying to dynamically load classes that implement an interface with an execute() method. How do I utilize the pull service so that I can access session and request scope data within these classes? 
For example:

public interface LoadClass
{
    public void execute();
}

public class LoadClassImpl implements LoadClass
{
   public LoadClass(){}
   public void execute()
   {
      // how do I access session and request data in this method
   }
}

public class MyAction extends VelocityAction
{
   public void doPerform(RunData data, Context context) throws Exception
   {
      LoadClass c = (LoadClass) Class.forName("LoadClassImpl").newInstance();
      c.execute();
   }


Any help would be appreciated.

John Davis
johnrdavis@bellsouth.net

RE: Action and Pull Service

Posted by Stephen Haberman <st...@chase3000.com>.
How about:

public interface LoadClass
{
  public void execute(RunData data, Context context);
}

or:

  public void setContext(RunData data, Context context);

then call execute() after having setContext().

If you can't modify the LoadClass interface, must only guess would be
some kind of thread-context ... but that's out of my range of
experience. It's only a guess.

- Stephen
   
> -----Original Message-----
> From: John Davis [mailto:johnrdavis@bellsouth.net]
> Sent: Sunday, August 25, 2002 7:15 PM
> To: turbine-user@jakarta.apache.org
> Subject: Action and Pull Service
> 
> Within a VelocityAction class I am trying to dynamically load classes
that implement
> an interface with an execute() method. How do I utilize the pull
service so that I can
> access session and request scope data within these classes?
> For example:
> 
> public interface LoadClass
> {
>     public void execute();
> }
> 
> public class LoadClassImpl implements LoadClass
> {
>    public LoadClass(){}
>    public void execute()
>    {
>       // how do I access session and request data in this method
>    }
> }
> 
> public class MyAction extends VelocityAction
> {
>    public void doPerform(RunData data, Context context) throws
Exception
>    {
>       LoadClass c = (LoadClass)
Class.forName("LoadClassImpl").newInstance();
>       c.execute();
>    }
> 
> 
> Any help would be appreciated.
> 
> John Davis
> johnrdavis@bellsouth.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>