[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tomcat-user
Subject:    RE: Using EL expressions in an ObjectFactory
From:       Xavier Dury <kalgon () hotmail ! com>
Date:       2013-08-30 7:41:09
Message-ID: DUB111-W5778772D12ED35D16199A9CF350 () phx ! gbl
[Download RAW message or body]

Hi,

I don't think you understood me. The point here is not about the ${catalina.base}, \
it's about the whole expression \
"CacheManager.newInstance(URI('file:${catalina.base}/conf/ehcache.xml').toURL())".

The ${catalina.base} will of course be expanded and give something like:

"CacheManager.newInstance(URI('file:/home/tomcat/conf/ehcache.xml').toURL())"

And then, this expression can be evaluated through EL and give a real CacheManager \
instance.

I could have written this that way:

"CacheManager.newInstance(URI('file:'+System.getProperty('catalina.base')+'/conf/ehcache.xml').toURL())"


The important thing here is that the whole expression parameter could be given to an \
ELProcessor instead of having specialized ObjectFactory for each case (I would of \
course use a specific ObjectFactory if there's one, like BasicDataSourceFactory... \
but for exotic and rare cases where no ObjectFactory exist, a generic EL-based one \
could be helpful).

Xavier

----------------------------------------
> Date: Thu, 29 Aug 2013 14:53:31 -0400
> From: chris@christopherschultz.net
> To: users@tomcat.apache.org
> Subject: Re: Using EL expressions in an ObjectFactory
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Xavier,
> 
> On 8/29/13 3:06 AM, Xavier Dury wrote:
> > Could it be possible for the tomcat team to include a
> > javax.naming.spi.ObjectFactory which would use EL3.0 expressions?
> > 
> > It would be great if you want to have resource-ref which are not of
> > the usual types.
> > 
> > I always wanted to have an ObjectFactory for URLs but having one
> > for each type is too much work... so now, that we have a more
> > powerful EL engine, maybe it would a great opportunity to use it.
> > 
> > <Resource name="/url/SomeService" type="java.net.URL"
> > factory="org.apache.tomcat.jndi.ELObjectFactory"
> > importClass="java.net.URI"
> > expression="URI('http://some.service.url').toURL()" />
> > 
> > <Resource name="/cache/CacheManager"
> > type="net.sf.ehcache.CacheManager"
> > factory="org.apache.tomcat.jndi.ELObjectFactory"
> > importClass="net.sf.ehcache.CacheManager,java.net.URI"
> > importStatic="net.sf.ehcache.CacheManager.newInstance"
> > expression="CacheManager.newInstance(URI('file:${catalina.base}/conf/ehcache.xml').toURL())"
> > 
> 
> What's
> > 
> wrong with just using $catalina.base within your context.xml?
> It will expand appropriately already... no EL needed.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.14 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iQIcBAEBCAAGBQJSH5irAAoJEBzwKT+lPKRYRoYP/03+hC07yLehUBQHuaIghRTB
> 6NWcWrzcZ3bCy/uFtQDLH12am7sbE2zQ+VO6HPlOJaRJul8UQLCdZlTXmQuquz+G
> 8SGoGb4BWqPcluMrhbO+8v7f4aMPN7NenxBRpzNvWlQPtOo2h7+9cmz2bwh+XikU
> 5J8IGE2e7wb8dAQBu6DJtFsQi+fAhOGaiLfBtorwDLYrpJ4nN0tr28LSFrX9VKtD
> d0Fwga1zzHrBiGFzNAoUUujuGaPYCfbGugNJogWQO0dvHKQMmAM9GGLStnJbyy4U
> vehGGU4lRq6mhkD0KCUJ/zVxM1fuFxK+Q4hRah97Mw7r8jHgqyQEqdfGV9EjUZh4
> GVg0Y5W308ZTZfiutb7N++GTFrYq9qohHmI8pQyJ2jQLPtIo7gZv9KKBgFHUggpM
> 2lg4ZL6/3wjALScRsQ5/NKUpg4s0NIb25LPOKViCW1fHF2euUcEH/lkkelgGMgFP
> 2BXVszGOhQghePXFg6hkpAa4zhF0HRJQj8T5a1kJIBnf4QW3mm/g2Xv19EVNyiOs
> ZrkC6dSXZXnJZ0aYxusxRNKvSplTGm6ywuftxy17H89Mblib8qb0G+5MNwRJwceF
> tOkvHoMEY20dbhRZpQDL79a5dVL7YLc4M8hXBR1JQkmo1RyslHU/Y/+782OSs5+w
> ZFM1iRO6JYbxLrGdwQ3n
> =9lxu
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 		 	   		  
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic