You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by piero de salvia <pi...@yahoo.com> on 2001/07/03 23:19:10 UTC

Anakia and jdom

Hi guys,

another "should i forget programming" question.

Should not Anakia use dom4j instead of jdom ? Is not
dom4j vastly superior to jdom, considering that we are
working with java?

consider how to get an XPath engine running in jdom:

DOMParser parser = new DOMParser();
parser.parse(DocName);
Element Site =
parser.getDocument().getDocumentElement();
xpathSupport = new XMLParserLiaisonDefault();
prefixResolver = new PrefixResolverDefault(Site);
xpath = new XPath();
XPathparser = new XPathProcessorImpl(xpathSupport);
XPathparser.initXPath(xpath, PathName,
prefixResolver);

and then eval an xpath expression:

XObject result = xpath.execute(xpathSupport, Site,
prefixResolver);

NodeList foundnodes = result.nodeset();
(...more suffering from not having a standard
Collection...)

same thing with dom4j :

SAXReader reader = new SAXReader();
Site =  reader.read(DocName);
List foundnodes = Site.selectNodes(PathName);

(have a java Collection)

bye

piero de salvia

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: Anakia and jdom

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
piero de salvia wrote:
> 
> Hi guys,
> 
> another "should i forget programming" question.
> 
> Should not Anakia use dom4j instead of jdom ? Is not
> dom4j vastly superior to jdom, considering that we are
> working with java?

JDOM is the Bee's Knees.
 
I heart JDOM.

<fud>
JDOM is also a JSR, so you might find support in the JDK eventually.
</fud>

I actually know nothing about dom4j.

> 
> consider how to get an XPath engine running in jdom:
> 
> DOMParser parser = new DOMParser();
> parser.parse(DocName);
> Element Site =
> parser.getDocument().getDocumentElement();
> xpathSupport = new XMLParserLiaisonDefault();
> prefixResolver = new PrefixResolverDefault(Site);
> xpath = new XPath();
> XPathparser = new XPathProcessorImpl(xpathSupport);
> XPathparser.initXPath(xpath, PathName,
> prefixResolver);
> 
> and then eval an xpath expression:
> 
> XObject result = xpath.execute(xpathSupport, Site,
> prefixResolver);
> 
> NodeList foundnodes = result.nodeset();
> (...more suffering from not having a standard
> Collection...)
> 
> same thing with dom4j :
> 
> SAXReader reader = new SAXReader();
> Site =  reader.read(DocName);
> List foundnodes = Site.selectNodes(PathName);
> 
> (have a java Collection)

How does this affect you as an Anakia user?


-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: singleton Velocity engine

Posted by Jon Stevens <jo...@latchkey.com>.
One solution for this is to load each instance of Velocity in its own
classloader. That way, within the same ServletContext, you will still have a
unique instance of Velocity. The controller servlet that you use can
differentiate between the different applications within the context by
something like the domain name and you can therefore have a mapping of
something like this:

ie:

ServletContext => root
    classloader1 => app1.domain.com
    classloader2 => app2.domain.com
    classloader3 => app1.foo.com

URI's would look like this:

http://app1.domain.com/root/servlet/ControllerServlet
http://app2.domain.com/root/servlet/ControllerServlet
http://app1.foo.com/root/servlet/ControllerServlet

All of the domains can be mapped to the same Context.

It should be relatively easy to implement this and would solve the problem
right away.

-jon


Re: singleton Velocity engine

Posted by piero de salvia <pi...@yahoo.com>.
I can prepend, but...

the second app would have to be a self-contained one,
originally I thought of writing one of those monster
servlets, the ones with Apache's ECS. 

so given one of my customer's websites, I would just
plop the content manager app in a jar under root, the
rendering app in a jar under root, and voila'.

customer gone? pack her templates  + her content, send
her a CD.

I know the answer is still "you can jar and prepend",
but I suppose it comes down to speed.

Also there is another issue. The velocity engine is
extra extra nice for loading other miscellaneous
stuff, like content, sensing when it changes, getting
it from jars, Anakia-ing it etc. The basis for a
content management system.

I would also like to contribute, but I am not sure
about my Java skills.



--- "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> piero de salvia wrote:
> > 
> > Hi Geir,
> > 
> > in reality I did investigate the subject and
> realized
> > I could do that, and I could also prepend/append a
> > string to every template request, indicating a
> > different "application".
> > 
> > reason why i don't want to do that is the apps are
> > really separate. my clients will go to the
> template
> > directory and do their templates directly (like
> with
> > dreamweaver etc.).
> > the other app is a content manager app that takes
> care
> > of content (I know how you guys are fond of MVC so
> I
> > MVC too). If Velocity is singleton, the second
> app's
> > templates will mix up with the customer's
> templates,
> > chances of namespace clashes and so on.
> 
> I guess I would have to see it.  I know some people
> can't work by
> partitioning the templates into different
> directories, one for each app
> for various and sundry reasons.
> 
> However, if the apps are distinct, why can't the
> controller prepend the
> client's directory name for any requests going to
> that client's app?
> 
>  
> > So I hopefully wait. what happens if I un-static
> > everything in source?
> 
> It breaks.  Everything is currently dependant upon
> this.
> 
> -- 
> Geir Magnusson Jr.                          
> geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See
> http://jakarta.apache.org/velocity/
> You have a genius for suggesting things I've come a
> cropper with!


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: singleton Velocity engine

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
piero de salvia wrote:
> 
> Hi Geir,
> 
> in reality I did investigate the subject and realized
> I could do that, and I could also prepend/append a
> string to every template request, indicating a
> different "application".
> 
> reason why i don't want to do that is the apps are
> really separate. my clients will go to the template
> directory and do their templates directly (like with
> dreamweaver etc.).
> the other app is a content manager app that takes care
> of content (I know how you guys are fond of MVC so I
> MVC too). If Velocity is singleton, the second app's
> templates will mix up with the customer's templates,
> chances of namespace clashes and so on.

I guess I would have to see it.  I know some people can't work by
partitioning the templates into different directories, one for each app
for various and sundry reasons.

However, if the apps are distinct, why can't the controller prepend the
client's directory name for any requests going to that client's app?

 
> So I hopefully wait. what happens if I un-static
> everything in source?

It breaks.  Everything is currently dependant upon this.

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: singleton Velocity engine

Posted by piero de salvia <pi...@yahoo.com>.
Hi Geir,

in reality I did investigate the subject and realized
I could do that, and I could also prepend/append a
string to every template request, indicating a
different "application".

reason why i don't want to do that is the apps are
really separate. my clients will go to the template
directory and do their templates directly (like with
dreamweaver etc.). 
the other app is a content manager app that takes care
of content (I know how you guys are fond of MVC so I
MVC too). If Velocity is singleton, the second app's
templates will mix up with the customer's templates,
chances of namespace clashes and so on.

So I hopefully wait. what happens if I un-static
everything in source?

piero

--- "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> piero de salvia wrote:
> > 
> > Hi guys,
> > 
> > I was trying to set up two controller servlets
> under
> > the same app (i.e. the same web-inf) and, because
> of
> > that, they share the file loader resource path
> (not
> > what I wanted). I understand that it would suffice
> to
> > put them under two different web-inf, but since
> the
> > site is hosted at an ISP, I, as many others, don't
> get
> > the luxury of a separate context. It would be
> really
> > convenient to have a non-singleton Velocity
> engine.
> 
> Yes - we know.  We have been talking about it a
> little as interest comes
> up and down.  I was planning to take a few days soon
> and take a good run
> at it.
> 
> I will note here that you do realize that your file
> loader resource path
> can contain multiple directories, right?  While it
> wouldn't be the
> optimal solution, you could always just have each
> controller prefix each
> template name with a directory name?
> 
> geir
> 
> -- 
> Geir Magnusson Jr.                          
> geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See
> http://jakarta.apache.org/velocity/
> You have a genius for suggesting things I've come a
> cropper with!


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: singleton Velocity engine

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
piero de salvia wrote:
> 
> Hi guys,
> 
> I was trying to set up two controller servlets under
> the same app (i.e. the same web-inf) and, because of
> that, they share the file loader resource path (not
> what I wanted). I understand that it would suffice to
> put them under two different web-inf, but since the
> site is hosted at an ISP, I, as many others, don't get
> the luxury of a separate context. It would be really
> convenient to have a non-singleton Velocity engine.

Yes - we know.  We have been talking about it a little as interest comes
up and down.  I was planning to take a few days soon and take a good run
at it.

I will note here that you do realize that your file loader resource path
can contain multiple directories, right?  While it wouldn't be the
optimal solution, you could always just have each controller prefix each
template name with a directory name?

geir

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

singleton Velocity engine

Posted by piero de salvia <pi...@yahoo.com>.
Hi guys,

I was trying to set up two controller servlets under
the same app (i.e. the same web-inf) and, because of
that, they share the file loader resource path (not
what I wanted). I understand that it would suffice to
put them under two different web-inf, but since the
site is hosted at an ISP, I, as many others, don't get
the luxury of a separate context. It would be really
convenient to have a non-singleton Velocity engine.

piero de salvia

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

Re: Anakia and jdom

Posted by bob mcwhirter <bo...@werken.com>.
Just for the record, Anakia's use of JDOM uses my werken.xpath
implementation.  Which, incidently, wasn't the example he gave,
I don't think.  Coincidently, dom4j also uses my werken.xpath
under-the-cover.

So, as far as ease-of-use for either JDOM or dom4j, wrt xpath,
it's all about the same.

	-bob

On Tue, 3 Jul 2001, Jon Stevens wrote:

> I work with Jason Hunter and he is a friend of mine. I'm going to use JDOM.
> 
> Feel free to submit another version of Anakia which uses/does whatever the
> heck you want.
> 
> -jon
> 



Re: Anakia and jdom

Posted by Jon Stevens <jo...@latchkey.com>.
I work with Jason Hunter and he is a friend of mine. I'm going to use JDOM.

Feel free to submit another version of Anakia which uses/does whatever the
heck you want.

-jon