Hi,

On Tue, 20 Aug 2002 20:46, Tomasz Skutnik wrote:
> I've got this simple question. Can someone tell me what is preferred way
> of accessing application working directory in Phoenix(I assume it is
> 'apps/<app-name>/', correct me if I'm wrong) ? So far I did it by
> obtaining configuration location during configuration phase and than
> converting it to URL, and then invoking 'getFile()' method, followed by
> ~ double 'getParent()' - which doesn't seem to be very elegant IMHO.

public class MyBlock implements Contextualizable
{
  private BlockContext _context;

  public void contextualize( final Context context )
  {
    _context = (BlockContext)context;
  }

  public void someMethod()
  {
     File f = _context.getBaseDirectory();
     ...
  }

> Another problem, a bit more complex. I'm developing Phoenix-based server
> for remote invocation of Ant (to speedup development by avoiding Java
> startup overhead each time Ant is invoked) + simple Python client to
> forward requests. 

sounds koool.

> 1. How can I access arbitrary jar archive placed inside SAR archive
> (e.g. construct URL pointing at it)? - FWIR Phoenix does not extract any
> files from SAR except configuration, so there should(?) be the way to
> access it's content other way - can someone help me with this ?

Phoenix extracts everything not in SAR-INF so you could store them in 
something like

/SAR-INF/*.xml
/ant/lib/ant.jar
/ant/lib/ant-optional.jar

You can then reference these jars via 

File f = _context.getBaseDirectory()
final File antFile = new File( f, "ant/lib/ant.jar" );
URL url = antFile.toURL();

URLCassLoader loader = new URLCassLoader( new URL[] { url } );

> 2. Is there some better (simpler) way to implement the feature I've
> described? I don't want to reinvent the wheel - if someone knows details
> about Phoenix classloader handling and how this could be exploited to
> achieve desired effect - please share your knowledge :-)

I am not sure whay you can't just copy $ANT_HOME/lib/* into /SAR-INF/lib
?

-- 
Cheers,

Peter Donald
*-----------------------------------------------------*
* "Faced with the choice between changing one's mind, *
* and proving that there is no need to do so - almost *
* everyone gets busy on the proof."                   *
*              - John Kenneth Galbraith               *
*-----------------------------------------------------* 


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

Reply via email to