You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Will Glass-Husain <wg...@forio.com> on 2002/05/21 22:58:59 UTC

conflicts between Singleton and Instance

Hi,

If I try and use VelocityEngine (Velocity as an instance) in the same memory
space as an app (like Turbine) which uses the singleton Velocity, is there a
conflict?

As a side note, I tried this; it doesn't seem to work.  Is there a simple
work-around to make VelocityEngine work?  (without changing the app that
uses the Singleton).  I suspect not, but its worthwhile to check.

Thanks, WILL
_______________________________________
Forio Business Simulations
Will Glass-Husain
(415) 440-7500 phone
(415) 235-4293 mobile

wglass@forio.com
www.forio.com



RE: how does merge work?

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
It is related to my poorly posted question yesterday concerning jsp.
I cannot win over some stodgy developers with Velocity but I have
gotten them to accept no java in a jsp page.  Well, if that is the
case then why can't the jsp page be treated as a "template"?  So my
thinking is to try to have jsp pages parsed as templates.  Now, this
is way too much work and most likely way too difficult for someone
like me, but I wanted to see where it would lead.  And if I am going
to be copying an idea, might as well start with the best example around.

So yeah, I'm going to see if I can hack together a copy of how velocity
merges and use it for jsp with taglibs.  Pretty disgusting isn't it.

Thanks for the info though - quite helpful.

Charlie

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Wednesday, May 22, 2002 11:09 AM
> To: velocity-user@jakarta.apache.org
> Subject: Re: how does merge work?
>
>
> On 5/22/02 11:01 AM, "Charles N. Harvey III" <ch...@alloy.com> wrote:
>
> > I am trying to dig through the code to figure out how the merge
> > functionality
> > works.  I am getting there but could use a few pointers.
> >
> > From what I understand it works thusly:
> >
> > - look for template
> > - if not present, send rnfe error to log
> > - if present, check for syntax errors
> > - if template has syntax errors, send error to log
> > - if template is good, parse template
> > - get any #parse(d) and #include(d) templates
> > - look for template
> > - if not present...
> > ...
> > ...
> > - extract context objects into variables in template
> > - display
> >
> >
> > That's what I've got so far.  I understand the looking for and parsing
> > parts.  Well, the looking for mostly, I am digging around to understand
> > the parsing.  But I really need help with the extracting of context info
> > and how a page actually gets displayed (how it is read in and
> pumped out).
>
> There are actually a few things going on when you merge, and the word
> 'merge' means a few things depending on context.
>
> The upshot :
>
> 1) find the template.  If not found, error.  If found and not
> cached, parse
> and put in cache.  Parse problem?  Error.  If in cache and not
> expired, just
> use.
>
> 2) take the context with data, do some wrapping for housekeeping, and then
> with a writer, send it down the syntax tree of the template.  If anything
> goes wrong (like a method  $foo.bar() throws an exception, and no handler)
> stop.
>
> 3) going down the tree, render each node into the writer.
>
> What exactly are you trying to figure out? (Or is there a specific problem
> you are trying to solve?)
>
> --
> Geir Magnusson Jr.
> Research & Development, Adeptra Inc.
> geirm@adeptra.com
> +1-203-247-1713
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


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


Re: how does merge work?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/22/02 11:01 AM, "Charles N. Harvey III" <ch...@alloy.com> wrote:

> I am trying to dig through the code to figure out how the merge
> functionality
> works.  I am getting there but could use a few pointers.
> 
> From what I understand it works thusly:
> 
> - look for template
> - if not present, send rnfe error to log
> - if present, check for syntax errors
> - if template has syntax errors, send error to log
> - if template is good, parse template
> - get any #parse(d) and #include(d) templates
> - look for template
> - if not present...
> ...
> ...
> - extract context objects into variables in template
> - display
> 
> 
> That's what I've got so far.  I understand the looking for and parsing
> parts.  Well, the looking for mostly, I am digging around to understand
> the parsing.  But I really need help with the extracting of context info
> and how a page actually gets displayed (how it is read in and pumped out).

There are actually a few things going on when you merge, and the word
'merge' means a few things depending on context.

The upshot :

1) find the template.  If not found, error.  If found and not cached, parse
and put in cache.  Parse problem?  Error.  If in cache and not expired, just
use.

2) take the context with data, do some wrapping for housekeeping, and then
with a writer, send it down the syntax tree of the template.  If anything
goes wrong (like a method  $foo.bar() throws an exception, and no handler)
stop.

3) going down the tree, render each node into the writer.

What exactly are you trying to figure out? (Or is there a specific problem
you are trying to solve?)

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


how does merge work?

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
I am trying to dig through the code to figure out how the merge
functionality
works.  I am getting there but could use a few pointers.

>From what I understand it works thusly:

- look for template
	- if not present, send rnfe error to log
	- if present, check for syntax errors
		- if template has syntax errors, send error to log
		- if template is good, parse template
			- get any #parse(d) and #include(d) templates
				- look for template
					- if not present...
					...
					...
			- extract context objects into variables in template
			- display


That's what I've got so far.  I understand the looking for and parsing
parts.  Well, the looking for mostly, I am digging around to understand
the parsing.  But I really need help with the extracting of context info
and how a page actually gets displayed (how it is read in and pumped out).

Thanks so much.

Charlie


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


Re: conflicts between Singleton and Instance

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/21/02 5:57 PM, "Will Glass-Husain" <wg...@forio.com> wrote:

> Hi,
> 
> Feeling a bit foolish about replying to myself (before someone else does),
> I'll note that the Log4J collision is solvable with the following code.
> (RTFM, WGH!)
> 
> String LogPath = "newvelocity.log";
> String CategoryName = "newcategoryname";
> 
> ve.setProperty("runtime.log",LogPath);
> ve.setProperty( VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS,
> "org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );
> ve.setProperty("runtime.log.logsystem.log4j.category",CategoryName);
> 
> before the...
> 
> ve.init()
> 

:)  Sorry - I just mentioned the same thing in the response to your previous
post...

Glad it's working.

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


Re: [Veltools] Ready made jars

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/22/02 9:58 AM, "Charles N. Harvey III" <ch...@alloy.com> wrote:

> I would like to keep up with the latest veltools but I am not so proficient
> with cvs.  I have tried, but I just can't seem to get it to do what it
> should.
> So I was wondering if there was a way to get nightly builds, or even monthly
> builds of the veltools projects?  Thanks a lot.
> 

Nightly builds are coming.  I will keep on it..

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


[Veltools] Ready made jars

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
I would like to keep up with the latest veltools but I am not so proficient
with cvs.  I have tried, but I just can't seem to get it to do what it
should.
So I was wondering if there was a way to get nightly builds, or even monthly
builds of the veltools projects?  Thanks a lot.

Charlie


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


RE: conflicts between Singleton and Instance

Posted by Will Glass-Husain <wg...@forio.com>.
Hi,

Feeling a bit foolish about replying to myself (before someone else does),
I'll note that the Log4J collision is solvable with the following code.
(RTFM, WGH!)

String LogPath = "newvelocity.log";
String CategoryName = "newcategoryname";

ve.setProperty("runtime.log",LogPath);
ve.setProperty( VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS,
"org.apache.velocity.runtime.log.SimpleLog4JLogSystem" );
ve.setProperty("runtime.log.logsystem.log4j.category",CategoryName);

before the...

ve.init()

Cheers, Will


-----Original Message-----
From: Will Glass-Husain [mailto:wglass@forio.com]
Sent: Tuesday, May 21, 2002 2:47 PM
To: Velocity Users List
Subject: RE: conflicts between Singleton and Instance


Thanks for the quick response.  Saved me a lot of time (I was going to
investigate custom classloaders and other obscure topics).  Instead I tried
a little harder and it worked fine.

One caveat.  If both systems use Log4J, there is a conflict with the logging
system.  So I set up one system (Turbine) to use Log4J and the other to use
Avalon.  I may end up having these both be in Log4J during production.

Best, WILL

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Tuesday, May 21, 2002 2:05 PM
To: velocity-user@jakarta.apache.org
Subject: Re: conflicts between Singleton and Instance


On 5/21/02 4:58 PM, "Will Glass-Husain" <wg...@forio.com> wrote:

> Hi,
>
> If I try and use VelocityEngine (Velocity as an instance) in the same
memory
> space as an app (like Turbine) which uses the singleton Velocity, is there
a
> conflict?

There shouldn't be - they each have their own RuntimeInstance.  That's what
is inside the singleton...

>
> As a side note, I tried this; it doesn't seem to work.

What version, and *what* didn't seem to work?  You will have to be careful
about collisions re log files and such..


> Is there a simple
> work-around to make VelocityEngine work?  (without changing the app that
> uses the Singleton).  I suspect not, but its worthwhile to check.
>
> Thanks, WILL
> _______________________________________
> Forio Business Simulations
> Will Glass-Husain
> (415) 440-7500 phone
> (415) 235-4293 mobile
>
> wglass@forio.com
> www.forio.com
>
>
>

--
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


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


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


Re: conflicts between Singleton and Instance

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/21/02 5:46 PM, "Will Glass-Husain" <wg...@forio.com> wrote:

> Thanks for the quick response.  Saved me a lot of time (I was going to
> investigate custom classloaders and other obscure topics).  Instead I tried
> a little harder and it worked fine.
> 

Well, sorry.  Classloaders are a lot of fun. :)

> One caveat.  If both systems use Log4J, there is a conflict with the logging
> system.  So I set up one system (Turbine) to use Log4J and the other to use
> Avalon.  I may end up having these both be in Log4J during production.

Why is there a conflict? You can give each one a separate category to log to
- instead of using the 'flail-o-matic' auto-finding of the logger, you can
configure it to use log4j and hand it the category to log to...

> 
> Best, WILL
> 
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Tuesday, May 21, 2002 2:05 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: conflicts between Singleton and Instance
> 
> 
> On 5/21/02 4:58 PM, "Will Glass-Husain" <wg...@forio.com> wrote:
> 
>> Hi,
>> 
>> If I try and use VelocityEngine (Velocity as an instance) in the same
> memory
>> space as an app (like Turbine) which uses the singleton Velocity, is there
> a
>> conflict?
> 
> There shouldn't be - they each have their own RuntimeInstance.  That's what
> is inside the singleton...
> 
>> 
>> As a side note, I tried this; it doesn't seem to work.
> 
> What version, and *what* didn't seem to work?  You will have to be careful
> about collisions re log files and such..
> 
> 
>> Is there a simple
>> work-around to make VelocityEngine work?  (without changing the app that
>> uses the Singleton).  I suspect not, but its worthwhile to check.
>> 
>> Thanks, WILL
>> _______________________________________
>> Forio Business Simulations
>> Will Glass-Husain
>> (415) 440-7500 phone
>> (415) 235-4293 mobile
>> 
>> wglass@forio.com
>> www.forio.com
>> 
>> 
>> 
> 
> --
> Geir Magnusson Jr.
> Research & Development, Adeptra Inc.
> geirm@adeptra.com
> +1-203-247-1713
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


RE: conflicts between Singleton and Instance

Posted by Will Glass-Husain <wg...@forio.com>.
Thanks for the quick response.  Saved me a lot of time (I was going to
investigate custom classloaders and other obscure topics).  Instead I tried
a little harder and it worked fine.

One caveat.  If both systems use Log4J, there is a conflict with the logging
system.  So I set up one system (Turbine) to use Log4J and the other to use
Avalon.  I may end up having these both be in Log4J during production.

Best, WILL

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Tuesday, May 21, 2002 2:05 PM
To: velocity-user@jakarta.apache.org
Subject: Re: conflicts between Singleton and Instance


On 5/21/02 4:58 PM, "Will Glass-Husain" <wg...@forio.com> wrote:

> Hi,
>
> If I try and use VelocityEngine (Velocity as an instance) in the same
memory
> space as an app (like Turbine) which uses the singleton Velocity, is there
a
> conflict?

There shouldn't be - they each have their own RuntimeInstance.  That's what
is inside the singleton...

>
> As a side note, I tried this; it doesn't seem to work.

What version, and *what* didn't seem to work?  You will have to be careful
about collisions re log files and such..


> Is there a simple
> work-around to make VelocityEngine work?  (without changing the app that
> uses the Singleton).  I suspect not, but its worthwhile to check.
>
> Thanks, WILL
> _______________________________________
> Forio Business Simulations
> Will Glass-Husain
> (415) 440-7500 phone
> (415) 235-4293 mobile
>
> wglass@forio.com
> www.forio.com
>
>
>

--
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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


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


Re: conflicts between Singleton and Instance

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/21/02 4:58 PM, "Will Glass-Husain" <wg...@forio.com> wrote:

> Hi,
> 
> If I try and use VelocityEngine (Velocity as an instance) in the same memory
> space as an app (like Turbine) which uses the singleton Velocity, is there a
> conflict?

There shouldn't be - they each have their own RuntimeInstance.  That's what
is inside the singleton...

> 
> As a side note, I tried this; it doesn't seem to work.

What version, and *what* didn't seem to work?  You will have to be careful
about collisions re log files and such..


> Is there a simple
> work-around to make VelocityEngine work?  (without changing the app that
> uses the Singleton).  I suspect not, but its worthwhile to check.
> 
> Thanks, WILL
> _______________________________________
> Forio Business Simulations
> Will Glass-Husain
> (415) 440-7500 phone
> (415) 235-4293 mobile
> 
> wglass@forio.com
> www.forio.com
> 
> 
> 

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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