You can subscribe to this list here.
| 2003 |
Jan
|
Feb
(55) |
Mar
(100) |
Apr
(203) |
May
(330) |
Jun
(190) |
Jul
(302) |
Aug
(323) |
Sep
(197) |
Oct
(245) |
Nov
(490) |
Dec
(330) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(194) |
Feb
(400) |
Mar
(416) |
Apr
(415) |
May
(359) |
Jun
(381) |
Jul
(491) |
Aug
(311) |
Sep
(291) |
Oct
(273) |
Nov
(355) |
Dec
(266) |
| 2005 |
Jan
(306) |
Feb
(303) |
Mar
(520) |
Apr
(346) |
May
(255) |
Jun
(221) |
Jul
(171) |
Aug
(247) |
Sep
(147) |
Oct
(125) |
Nov
(165) |
Dec
(65) |
| 2006 |
Jan
(90) |
Feb
(53) |
Mar
(121) |
Apr
(103) |
May
(113) |
Jun
(103) |
Jul
(104) |
Aug
(67) |
Sep
(78) |
Oct
(82) |
Nov
(78) |
Dec
(70) |
| 2007 |
Jan
(77) |
Feb
(76) |
Mar
(63) |
Apr
(30) |
May
(47) |
Jun
(41) |
Jul
(44) |
Aug
(44) |
Sep
(49) |
Oct
(33) |
Nov
(25) |
Dec
(21) |
| 2008 |
Jan
(45) |
Feb
(13) |
Mar
(15) |
Apr
(12) |
May
(9) |
Jun
(33) |
Jul
(30) |
Aug
(7) |
Sep
(20) |
Oct
(17) |
Nov
(20) |
Dec
(10) |
| 2009 |
Jan
(8) |
Feb
(5) |
Mar
(12) |
Apr
(17) |
May
(19) |
Jun
(97) |
Jul
(77) |
Aug
(33) |
Sep
(24) |
Oct
(41) |
Nov
(16) |
Dec
(32) |
| 2010 |
Jan
(24) |
Feb
(14) |
Mar
(50) |
Apr
(71) |
May
(70) |
Jun
(64) |
Jul
(45) |
Aug
(62) |
Sep
(32) |
Oct
(4) |
Nov
(12) |
Dec
(2) |
| 2011 |
Jan
(1) |
Feb
(3) |
Mar
(4) |
Apr
(3) |
May
(6) |
Jun
(1) |
Jul
(4) |
Aug
(3) |
Sep
(4) |
Oct
(6) |
Nov
(3) |
Dec
(3) |
| 2012 |
Jan
(4) |
Feb
(8) |
Mar
(6) |
Apr
(10) |
May
(2) |
Jun
(3) |
Jul
(11) |
Aug
(10) |
Sep
(4) |
Oct
|
Nov
(1) |
Dec
(1) |
| 2013 |
Jan
(4) |
Feb
(1) |
Mar
(9) |
Apr
(1) |
May
(8) |
Jun
(2) |
Jul
(5) |
Aug
(2) |
Sep
|
Oct
(3) |
Nov
(10) |
Dec
(8) |
| 2014 |
Jan
(3) |
Feb
(12) |
Mar
(9) |
Apr
(12) |
May
(2) |
Jun
|
Jul
(3) |
Aug
(1) |
Sep
(1) |
Oct
(4) |
Nov
|
Dec
(2) |
| 2015 |
Jan
(1) |
Feb
(3) |
Mar
(4) |
Apr
(9) |
May
(2) |
Jun
(2) |
Jul
|
Aug
(2) |
Sep
(7) |
Oct
(9) |
Nov
(7) |
Dec
(9) |
| 2016 |
Jan
(7) |
Feb
(5) |
Mar
(5) |
Apr
(5) |
May
(8) |
Jun
(4) |
Jul
(5) |
Aug
(4) |
Sep
(6) |
Oct
(7) |
Nov
(2) |
Dec
(3) |
| 2017 |
Jan
(7) |
Feb
(8) |
Mar
(7) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(5) |
Aug
(8) |
Sep
(4) |
Oct
(2) |
Nov
(3) |
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2022 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2025 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(2) |
Aug
(5) |
Sep
(2) |
Oct
|
Nov
|
Dec
(1) |
| 2026 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Rod J. <rod...@in...> - 2003-11-28 18:47:39
|
Chris, Unfortunately I think there's a fatal flaw in my solution using CGLIB 1.0. There are now two objects, even if the enhanced one starts off with the same state. "Optimized" invocations go to the original target, advised ones to the enhanced class and never to the original object. This is fine if there's no conversational state but the results can, ahem, be rather interesting if there is. I can't see a way round this with CGLIB 1.0. It seems that CGLIB 2.0 solves this problem, if the LazyLoaderCallback works as I understand. If it does solve this problem, could you please send me the sample code? Also, since that would be a killer reason to go to CGLIB 2.0, I guess it brings the whole version thing up again. CGLIB 2.0 isn't backward compatible, is it, so it will break old versions of Hibernate? Regards, Rod ----- Original Message ----- From: "Rod Johnson" <rod...@in...> To: <spr...@li...> Sent: Friday, November 28, 2003 4:42 PM Subject: Re: [Springframework-developer] Re: CGLIB question > Thanks Chris. > > Comments inline. > > > With CGLIB2 this would be pretty easy, since you can have multiple > > interceptors per object. You could continue to use one MethodInterceptor > as > > usual for the advised methods, and for the others you could use something > > like the LazyLoader Callback, to redirect the method invocations to the > > original object. This wouldn't use any reflection and wouldn't have to > > build up an argument array, etc. I can send you sample code if you want. > Sounds great. In the meantime I've written a little utility called > ReflectionUtils.shallowCopyFieldState to copy fields from the target to the > new instance of the enhanced class created by CGLIB. Works nicely and it's a > useful little class anyway. > > > This is another option. The interceptor route still has a tiny bit of > > overhead (an extra field dereference and method call), and you have to > > carry around the old bean for the life of the proxy. If they really are > > just JavaBeans you can use the net.sf.cglib.beans.BeanCopier class to > > efficiently copy all of the properties from the old bean to the new bean > > (it is really fast). In this case you would want to return false from your > > MethodFilter (in CGLIB1, in CGLIB2 you would use a NoOp Callback) to allow > > the original methods to be invoked (essentially it prevents the methods > > from being generated in the new class, allowing the super version to be > > used). > I considered the bean copy route, but the object I was using in my > application was actually Type 3 and we must now consider that as well. Also, > there may not be getter methods on the source: only setters. > > > >> It appears that now CGLIB is creating a new instance of the target and > > >> somehow now copying its state. Previously a property I'd set on the > > >> target was visible through the proxy; now it isn't. > > It extends the class but does not copy any fields--it doesn't know > anything > > about an actual "target" object instance, only the Class. I'm not sure > what > > the behavior you were seeing before was. > I was puzzled for a while too. But it was behaving correctly because the > reflective interception was hitting the old object in all cases. > > Thanks again. This optimization gives us a big performance increase on > methods with no advice, as there's no Spring (or CGLIB) interception at all > now. So I'm adding methods to force the use of CGLIB for this optimization, > and we'll be using CGLIB in our benchmarks. > > Interestingly, CGLIB 1.0 performance vs DP performance seems pretty much the > same otherwise. > > Regards, > Rod > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Rod J. <rod...@in...> - 2003-11-28 18:42:58
|
The performance improvement is so big that perhaps we could autodect the CGLIB version. E.g. have two versions of the present CgligProxyFactory and load whichever is appropriate, based on checking some class for CGLIB version. The only problem is how do we make it compile? Class.forName would be nasty. Regards, Rod ----- Original Message ----- From: "Rod Johnson" <rod...@in...> To: <spr...@li...> Sent: Friday, November 28, 2003 4:42 PM Subject: Re: [Springframework-developer] Re: CGLIB question > Thanks Chris. > > Comments inline. > > > With CGLIB2 this would be pretty easy, since you can have multiple > > interceptors per object. You could continue to use one MethodInterceptor > as > > usual for the advised methods, and for the others you could use something > > like the LazyLoader Callback, to redirect the method invocations to the > > original object. This wouldn't use any reflection and wouldn't have to > > build up an argument array, etc. I can send you sample code if you want. > Sounds great. In the meantime I've written a little utility called > ReflectionUtils.shallowCopyFieldState to copy fields from the target to the > new instance of the enhanced class created by CGLIB. Works nicely and it's a > useful little class anyway. > > > This is another option. The interceptor route still has a tiny bit of > > overhead (an extra field dereference and method call), and you have to > > carry around the old bean for the life of the proxy. If they really are > > just JavaBeans you can use the net.sf.cglib.beans.BeanCopier class to > > efficiently copy all of the properties from the old bean to the new bean > > (it is really fast). In this case you would want to return false from your > > MethodFilter (in CGLIB1, in CGLIB2 you would use a NoOp Callback) to allow > > the original methods to be invoked (essentially it prevents the methods > > from being generated in the new class, allowing the super version to be > > used). > I considered the bean copy route, but the object I was using in my > application was actually Type 3 and we must now consider that as well. Also, > there may not be getter methods on the source: only setters. > > > >> It appears that now CGLIB is creating a new instance of the target and > > >> somehow now copying its state. Previously a property I'd set on the > > >> target was visible through the proxy; now it isn't. > > It extends the class but does not copy any fields--it doesn't know > anything > > about an actual "target" object instance, only the Class. I'm not sure > what > > the behavior you were seeing before was. > I was puzzled for a while too. But it was behaving correctly because the > reflective interception was hitting the old object in all cases. > > Thanks again. This optimization gives us a big performance increase on > methods with no advice, as there's no Spring (or CGLIB) interception at all > now. So I'm adding methods to force the use of CGLIB for this optimization, > and we'll be using CGLIB in our benchmarks. > > Interestingly, CGLIB 1.0 performance vs DP performance seems pretty much the > same otherwise. > > Regards, > Rod > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Rod J. <rod...@in...> - 2003-11-28 16:48:05
|
Thanks Chris. Comments inline. > With CGLIB2 this would be pretty easy, since you can have multiple > interceptors per object. You could continue to use one MethodInterceptor as > usual for the advised methods, and for the others you could use something > like the LazyLoader Callback, to redirect the method invocations to the > original object. This wouldn't use any reflection and wouldn't have to > build up an argument array, etc. I can send you sample code if you want. Sounds great. In the meantime I've written a little utility called ReflectionUtils.shallowCopyFieldState to copy fields from the target to the new instance of the enhanced class created by CGLIB. Works nicely and it's a useful little class anyway. > This is another option. The interceptor route still has a tiny bit of > overhead (an extra field dereference and method call), and you have to > carry around the old bean for the life of the proxy. If they really are > just JavaBeans you can use the net.sf.cglib.beans.BeanCopier class to > efficiently copy all of the properties from the old bean to the new bean > (it is really fast). In this case you would want to return false from your > MethodFilter (in CGLIB1, in CGLIB2 you would use a NoOp Callback) to allow > the original methods to be invoked (essentially it prevents the methods > from being generated in the new class, allowing the super version to be > used). I considered the bean copy route, but the object I was using in my application was actually Type 3 and we must now consider that as well. Also, there may not be getter methods on the source: only setters. > >> It appears that now CGLIB is creating a new instance of the target and > >> somehow now copying its state. Previously a property I'd set on the > >> target was visible through the proxy; now it isn't. > It extends the class but does not copy any fields--it doesn't know anything > about an actual "target" object instance, only the Class. I'm not sure what > the behavior you were seeing before was. I was puzzled for a while too. But it was behaving correctly because the reflective interception was hitting the old object in all cases. Thanks again. This optimization gives us a big performance increase on methods with no advice, as there's no Spring (or CGLIB) interception at all now. So I'm adding methods to force the use of CGLIB for this optimization, and we'll be using CGLIB in our benchmarks. Interestingly, CGLIB 1.0 performance vs DP performance seems pretty much the same otherwise. Regards, Rod |
|
From: Chris N. <ch...@si...> - 2003-11-28 16:29:53
|
Rod Johnson wrote: > Chris, > > Actually I guess what I'm trying to do here doesn't make sense, and that > CGLIB's behavior is correct. I think your analysis is correct. :-) > I need to override the method to invoke the original target via > reflection. Otherwise I guess CGLIB creates a new subclass that won't > invoke my instance, which is in the state I want after its properties have > been set. With CGLIB2 this would be pretty easy, since you can have multiple interceptors per object. You could continue to use one MethodInterceptor as usual for the advised methods, and for the others you could use something like the LazyLoader Callback, to redirect the method invocations to the original object. This wouldn't use any reflection and wouldn't have to build up an argument array, etc. I can send you sample code if you want. > Does CGLIB provide any way of copying the state from my original instance > of the class into the new subclass? Or would I need to write code to do > that manually, assuming I could rely on the no-arg constructor and copy > JavaBean properties? This is another option. The interceptor route still has a tiny bit of overhead (an extra field dereference and method call), and you have to carry around the old bean for the life of the proxy. If they really are just JavaBeans you can use the net.sf.cglib.beans.BeanCopier class to efficiently copy all of the properties from the old bean to the new bean (it is really fast). In this case you would want to return false from your MethodFilter (in CGLIB1, in CGLIB2 you would use a NoOp Callback) to allow the original methods to be invoked (essentially it prevents the methods from being generated in the new class, allowing the super version to be used). >> It appears that now CGLIB is creating a new instance of the target and >> somehow now copying its state. Previously a property I'd set on the >> target was visible through the proxy; now it isn't. It extends the class but does not copy any fields--it doesn't know anything about an actual "target" object instance, only the Class. I'm not sure what the behavior you were seeing before was. >> Overall I really like CGLIB: it does what I expect of it with no fuss, >> and it's a cool concept. But the Javadoc really is inadequate. I know, it is improving for CGLIB2...another reason to upgrade ;-) Chris |
|
From: Rod J. <rod...@in...> - 2003-11-28 15:24:08
|
Chris,
Actually I guess what I'm trying to do here doesn't make sense, and that
CGLIB's behavior is correct.
I need to override the method to invoke the original target via reflection.
Otherwise I guess CGLIB creates a new subclass that won't invoke my
instance, which is in the state I want after its properties have been set.
Does CGLIB provide any way of copying the state from my original instance of
the class into the new subclass? Or would I need to write code to do that
manually, assuming I could rely on the no-arg constructor and copy JavaBean
properties?
Regards,
Rod
----- Original Message -----
From: "Rod Johnson" <rod...@in...>
To: <spr...@li...>
Sent: Friday, November 28, 2003 2:47 PM
Subject: [Springframework-developer] CGLIB question
> Chris,
>
> I'm sure you can help with this one.
>
> I guessed that the CGLIB MethodFilter interface was what I needed to get
> CGLIB override to get only those methods with advice overloaded. However,
> when I do that I find that behavior changes.
>
> Here's how I've changed the inner classes in
> org.springframework.aop.framework.AopProxy. I want only methods that have
an
> advice chain to be proxied.
>
>
> private class CglibProxyFactory {
>
> private Object createProxy() {
> try {
> return Enhancer.enhance(advised.getTarget().getClass(),
> completeProxiedInterfaces(),
> new MethodInterceptor() {
> public Object intercept(Object handler, Method method, Object[]
> objects, MethodProxy methodProxy) throws Throwable {
> return invoke(handler, method, objects);
> }
> },
> // I've added the three following arguments
> null, // ClassLoader: use default
> null, // Method replace: what does this mean? I couldn't work out
from
> CGLIB Javadoc
> new SelectiveOverrideMethodFilter()
> );
> }
> catch (CodeGenerationException ex) {
> throw new AspectException("Couldn't generate CGLIB subclass of class
'"
> + advised.getTarget().getClass() + "': " +
> "Common causes of this problem include using a final class, or a
> non-visible class", ex);
> }
> }
> }
>
>
> private class SelectiveOverrideMethodFilter implements MethodFilter {
>
> public boolean accept(Member member) {
> // Proxy is not yet available, but that shouldn't matter
> //List chain =
>
advised.getAdvisorChainFactory().getInterceptorsAndDynamicInterceptionAdvice
> (advised, null, (Method) member, advised.getTarget().getClass());
> //return !chainIsOptimizableToDirectTargetInvocation(chain);
> return true;
> }
>
> }
>
> The two lines I've commented out in the accept() method produce a 2.5x
> performance improvement in non-advised methods (as you'd expect) but they
> also produce different behavior, compared to returning true.
>
> It appears that now CGLIB is creating a new instance of the target and
> somehow now copying its state. Previously a property I'd set on the target
> was visible through the proxy; now it isn't.
>
> Overall I really like CGLIB: it does what I expect of it with no fuss, and
> it's a cool concept. But the Javadoc really is inadequate.
>
> Regards,
> Rod
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive? Does it
> help you create better code? SHARE THE LOVE, and help us help
> YOU! Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
|
|
From: Rod J. <rod...@in...> - 2003-11-28 14:51:12
|
Chris,
I'm sure you can help with this one.
I guessed that the CGLIB MethodFilter interface was what I needed to get
CGLIB override to get only those methods with advice overloaded. However,
when I do that I find that behavior changes.
Here's how I've changed the inner classes in
org.springframework.aop.framework.AopProxy. I want only methods that have an
advice chain to be proxied.
private class CglibProxyFactory {
private Object createProxy() {
try {
return Enhancer.enhance(advised.getTarget().getClass(),
completeProxiedInterfaces(),
new MethodInterceptor() {
public Object intercept(Object handler, Method method, Object[]
objects, MethodProxy methodProxy) throws Throwable {
return invoke(handler, method, objects);
}
},
// I've added the three following arguments
null, // ClassLoader: use default
null, // Method replace: what does this mean? I couldn't work out from
CGLIB Javadoc
new SelectiveOverrideMethodFilter()
);
}
catch (CodeGenerationException ex) {
throw new AspectException("Couldn't generate CGLIB subclass of class '"
+ advised.getTarget().getClass() + "': " +
"Common causes of this problem include using a final class, or a
non-visible class", ex);
}
}
}
private class SelectiveOverrideMethodFilter implements MethodFilter {
public boolean accept(Member member) {
// Proxy is not yet available, but that shouldn't matter
//List chain =
advised.getAdvisorChainFactory().getInterceptorsAndDynamicInterceptionAdvice
(advised, null, (Method) member, advised.getTarget().getClass());
//return !chainIsOptimizableToDirectTargetInvocation(chain);
return true;
}
}
The two lines I've commented out in the accept() method produce a 2.5x
performance improvement in non-advised methods (as you'd expect) but they
also produce different behavior, compared to returning true.
It appears that now CGLIB is creating a new instance of the target and
somehow now copying its state. Previously a property I'd set on the target
was visible through the proxy; now it isn't.
Overall I really like CGLIB: it does what I expect of it with no fuss, and
it's a cool concept. But the Javadoc really is inadequate.
Regards,
Rod
|
|
From: Rod J. <rod...@in...> - 2003-11-28 12:47:14
|
All, I've been doing a lot of performance work lately, and I'm sure you'll be happy with the results. I've made two significant changes: - AopProxy now optimizes out empty advice chains, invoking the target directly if there's a local target invoked by reflection. This optimization doesn't apply if AdvisedSupport is configured to expose proxy or invocation, which supposedly advised code may depend on. Performance benefit for invoking non-advised methods on an advised object is about 30%. (Assuming the method does not work itself, of course.) - TransactionProxyFactoryBean now creates an InterceptionAroundAdvisor with a pointcut that includes only transaction methods, rather than always adding TransactionInterceptor. So TransactionInterceptor only runs if there _is_ a transaction. Thus advice chain caching in the AOP framework can do its work. Performance improvement around 50% in invoking non-advised methods on a transaction proxy (no change in transactional methods, obviously.) I've changed the TransactionAttributeSource to take Method and Class not MethodInvocation, to make this work. It's an improvement anyway. Also: - Various logging guards which produce a slight boost in performance of Spring transaction management. Note that I've refactored MethodInvocationFactory into two: MethodInvocationFactory and AdviceChainFactory. This was necessary to allow the AOP optimization, but is an improvement I was planning anyway. This would make something like a Commons Pooling approach to MethodInvocations easy to implement. (However I would be surprised if there's much gain from doing that as such short-lived objects never get out of eden.) Now it would be nice if it were possible to get a CGLIB proxy that didn't override the methods with no advice. Is this possible? I'll look in the docs. Regards, Rod ____________________________________________________ Rod Johnson J2EE Consultant and Author +44 7973 409 132 rod...@in... Author of "Expert One-on-One J2EE Design and Development" (October 2002). http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ Founder, Spring Framework: http://www.springframework.org "Introducing the Spring Framework" (ServerSide article) http://www.theserverside.com/resources/article.jsp?l=SpringFramework |
|
From: Colin S. <col...@ex...> - 2003-11-28 03:23:12
|
Ok, I've been meaning to write for weeks about a solution I have for
doing hierarchical, on-demand loading of contexts (to be used by the
glue code between application layers), but I kept wanting to work on the
code a bit more. However, I'm going on vacation for a week now, and it
seems like people are interested in the subject, so I'll post what I have...
I have an app that's made up of multiple layers, basically some utility
jars, a data-access layer, a services layer, and on top of this 3
separate web-apps as WARs, all living in an EAR. At some point, all the
legacy EJB stuff will be gone, and we can move away from the ejb server,
but for the time being it's a mix of newer Hibernate persistence and
POJO services, and older Session EJBs and Entity Beans.
Because there are 3 webapps sitting at the top, I can't use the typical
Spring scenario, one application context at the top, living in the one
web app (whether assembled from one XML file or multiple XML files). The
tree structure forces me to load multiple contexts in a hierarchy (at
the very least, one context for the bottom layers, which is the parent
of 3 separate web app contexts), and stuff has to load on demand or at
least be findable by some sort of glue code to assemble them.
I had a solution I wasn't that happy with, which I posted here in
September. What I am doing now instead is using a Spring context itself
to load other contexts, on demand, in a tree fashion. So, the basic
premise is that you work with a Context group, which consists of one or
more ApplicationContexts, loaded on demand. The definition of the
context group is an ApplicationContext itself. You have a locator
interface, to which you feed a context group id (a name), and the
context (a name) within that group you want.
package com.whatever.coreserv.util.context;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
/**
* Defines interface for an ApplicationContext factory.
*
* @version $Revision: 1.1 $
* @author colin
*/
public interface ContextLocator {
/**
* Use the ApplicationContext specified by the key parameter. The
context is possibly
* loaded/created as needed.
*
* @param key a value specifying which context to use
* @return the ApplicationContext instance
* @throws ApplicationContextException if there is an error loading
one or more contexts
*/
ApplicationContext useContext(String group, String contextId) throws
ApplicationContextException;
/**
* Indicate that the specified ApplicationContext instance is not
needed by a user of it,
* who has previsouly obtained it via {@link useContext}. It is an
error for releaseContext
* to be called a greater number of times than useContext. Calling
this release method may
* cause close() to be called on the specified context, if this is the
last user of it.
*
* @param ac the ApplicationContext instance
* @throws ApplicationContextException
*/
void releaseContext(ApplicationContext ac) throws
ApplicationContextException;
}
Here's a factory to get a ContextLocator:
package com.whatever.coreserv.util.context;
import org.springframework.beans.factory.support.BootstrapException;
import org.springframework.context.ApplicationContextException;
/**
* @version $Revision: 1.1 $
* @author colin sampaleanu
*/
public class ContextLocatorFactory {
private static KeyedSingletonGroupContextLocator instance;
// Do initialization when this class is loaded to avoid potential
// concurrency issues or the need to synchronize later
static {
initializeSingleton();
}
private static void initializeSingleton() {
instance = new KeyedSingletonGroupContextLocator();;
}
/**
* Return the singleton instance of the ContextLocator factory
* @return ContextLocator
* @throws BeansException
*/
public static ContextLocator getInstance() throws
ApplicationContextException {
// introduce mechanism (property) to get another implementation instead
if (instance == null)
throw new BootstrapException("Anomaly: instance is null", null);
return instance;
}
}
Now here's an implementation of ContextLocator, called
KeyedSingletonGroupContextLocator. What it does is treat the group name
as a keyed singleton value which represents an ApplicationContext to be
loaded once, which contains other contexts. Please see the JavaDoc.
package com.whatever.coreserv.util.context;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import org.apache.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.config.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Implementation of ContextLocator. <br />In this implementation, the
key is
* actually the name of an application context definition, accessed as a
resource.
* This is loaded once on demand (at the first useContext() call with
that group key),
* as a singleton. It is expected that within this application context
is defined a
* hierarchy of other application contexts. When useContext() is called
with a
* specified contextId to get from the group, the group's singleton
application
* context is queried via getBean for the specified application context
within it.
* Each application context in the parent group context is just a bean
definition, and
* points to a parent context. Depending on the singleton setting, they
will all load
* initially, or on demamd.
*
* @version $Revision: 1.1 $
* @author colin
* @see ContextFactory
*/
public class KeyedSingletonGroupContextLocator implements ContextLocator {
// --- statics
public static final Logger _log =
Logger.getLogger(KeyedSingletonGroupContextLocator.class);
// we map ContextInfo objects by String keys, and by Contexts
private static HashMap instancesByKey = new HashMap();
private static HashMap instancesByObj = new HashMap();
// --- methods
/*
* (non-Javadoc)
*
* @see
com.whatever.coreserv.webutil.ContextFactory#useContext(java.lang.String)
*/
public ApplicationContext useContext(String groupKey, String contextId)
throws ApplicationContextException {
synchronized (instancesByKey) {
ContextInfo ci = (ContextInfo) instancesByKey.get(groupKey);
if (ci != null) {
_log.debug("Context with key '" + groupKey + "' requested.
Returning existing instances");
ci.refcount++;
}
else {
_log.debug("Context group '" + groupKey + "' requested. Creating
new instance.");
// this context doesn't exist, we need to try to load it
InputStream is = getClass().getResourceAsStream(groupKey);
ClassPathXmlApplicationContext groupContext = null;
if (is == null)
throw new ApplicationContextException(
"Unable to load context(s). Context group key does not point
to a valid resource: "
+ groupKey);
try {
is.close();
groupContext = new ClassPathXmlApplicationContext(groupKey);
}
catch (IOException e) {
throw new ApplicationContextException(
"Unable to loaded(s) specified by context group key: " +
groupKey,
e);
}
ci = new ContextInfo();
ci.context = groupContext;
ci.key = groupKey;
ci.refcount = 1;
instancesByKey.put(groupKey, ci);
instancesByObj.put(groupContext, ci);
}
ApplicationContext groupContext = ci.context;
ApplicationContext appContext;
try {
appContext = (ApplicationContext) groupContext.getBean(contextId);
}
catch (BeansException e) {
throw new ApplicationContextException(
"Unable to return specified context. Group:" + groupKey + ",
contextId:" + contextId,
e);
}
return appContext;
}
}
/**
* Releases the specified ApplicationContext instance. If there are no
more
* users of this context, close() will be called on it. Note that
close will
* be called on its parents as well, recursively.
*
* @see
com.whatever.coreserv.webutil.ContextFactory#ReleaseContext(org.springframework.context.ApplicationContext)
*/
public void releaseContext(ApplicationContext ac) throws
ApplicationContextException {
//TODO: implement
}
// we track contexts with this class
private class ContextInfo {
public ConfigurableApplicationContext context;
public String key;
public int refcount = 0;
}
}
Now here's an actual context group definition. In the group are 4
contexts. A client of the group can ask for any of the contexts within
it. Depending on the singleton settings, all the contexts will have
loaded at the beginning, or will load on demand.
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: core-context-hierarchy.xml,v 1.2 2003/11/14 23:15:20 colin Exp
$ -->
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<!-- core Application Contexts -->
<beans>
<bean id="data-access-context"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<value>/data-access-applicationContext.xml</value>
</constructor-arg>
</bean>
<bean id="packaging-context"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg index="0">
<list><value>/packaging-applicationContext.xml</value></list>
</constructor-arg>
<constructor-arg index="1">
<ref bean="data-access-context"/>
</constructor-arg>
</bean>
<bean id="qa-util-context"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg index="0">
<list><value>/qa-util-applicationContext.xml</value></list>
</constructor-arg>
<constructor-arg index="1">
<ref bean="packaging-context"/>
</constructor-arg>
</bean>
<bean id="core-services-context"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg index="0">
<list><value>/core-services-applicationContext.xml</value></list>
</constructor-arg>
<constructor-arg index="1">
<ref bean="qa-util-context"/>
</constructor-arg>
</bean>
</beans>
Now this takes care of my lower layers. What I have in my 3 web apps is
a small variation of Spring's standard ContextLoader, which is aware of
context groups. When it is constructs the web app's application context,
it uses an extra couple of params as a context group key and context
from that context group, to set as the parent of the web-app's context.
As you can see, I never finished rewriting the releaseContext method
after I switched to this code. My initial implementation did reference
counting on the returned contexts, and I want to do it here too at some
point.
Although there are a lot of ways you could do this, I think that some
sort of mechanism needs to exist in Spring to allow glue code inside an
application stack to glue contexts together in one fashion or another,
and to do it on demand. As such, if anybody agrees, I'd like to work on
a solution that everybody's happy with. Using the contexts within a
context approach is pretty cool, because it leverages Spring in several
ways, and allows the end user to extend as needed via interceptors and
the like...
Regards,
Colin
Mike Cannon-Brookes wrote:
>OK - but can't we have an include syntax that's automatically processed? It
>would be much simpler for those writing unit tests etc - you then wire your
>files together explicitly.
>
><include resource="/foobar.xml" />
><include file="c:\foobar.xml" />
>
>(for classpath loading and file loading respectively)
>
>Cheers,
>Mike
>
>PS This is also the same syntax xwork.xml uses and it works quite well
>
>On 28/11/03 10:26 AM, "jürgen höller [werk3AT]"
>(jue...@we...) penned the words:
>
>
>
>>You can't load one file from another (except for standard XML entity
>>includes), but you can simply define multiple XML file locations as
>>"contextConfigLocation" context-param:
>>
>><context-param>
>><param-name>contextConfigLocation</param-name>
>><param-value>
>> /WEB-INF/applicationContext1.xml
>> /WEB-INF/applicationContext2.xml
>></param-value>
>></context-param>
>>
>>All those bean definition files will be loaded into one single root
>>application context instance. You can also separate the locations with spaces
>>or commas - the parsing is pretty lenient.
>>
>>Any bean references between those files can be resolved, but we recommend to
>>keep dependencies one way, e.g. applicationContext1 references beans from
>>applicationContext2 but not the other way round.
>>
>>The obvious benefit of such separation is that the individual files can be
>>reused in other environments, like unit tests or standalone apps, in a
>>fine-granular fashion.
>>
>>Juergen
>>
>>
>>________________________________
>>
>>Von: spr...@li... im Auftrag von Mike
>>Cannon-Brookes
>>Gesendet: Fr 28.11.2003 00:19
>>An: Spring User ML
>>Betreff: Re: [Springframework-user] BeanFactories loadable from classpath?
>>
>>
>>
>>Maybe I missed it, but how can you load one file from another? This would be
>>_very_ useful for us, especially in the area of breaking up unit test .xml
>>files.
>>
>>Mike
>>
>>On 28/11/03 9:09 AM, "jürgen höller [werk3AT]" (jue...@we...)
>>penned the words:
>>
>>
>>
>>>Neill,
>>>
>>>We've already considered support for loading web application context
>>>definitions from the class path, possibly via a "classpath:" prefix for
>>>context config locations, analogous to "file:" and "http:" which are already
>>>supported. Non-prefix paths will still be interpreted as web app resource,
>>>like currently. I'll address this tomorrow, as it is straightforward to
>>>implement.
>>>
>>>Note that an XmlBeanFactory itself can be loaded from any InputStream. It's
>>>just application context implementations like XmlWebApplicationContext,
>>>FileSystemXmlApplicationContext and ClassPathXmlApplicationContext that are
>>>customized for a specific environment.
>>>
>>>Juergen
>>>
>>>
>>>________________________________
>>>
>>>Von: spr...@li... im Auftrag von Neill
>>>Robbins
>>>Gesendet: Do 27.11.2003 15:48
>>>An: spr...@li...
>>>Betreff: [Springframework-user] BeanFactories loadable from classpath?
>>>
>>>
>>>I have the following scenario. I have a couple of applications that operate
>>>on a core set of domain objects and business functions. To this end I have a
>>>core.jar that contains the domain objects, associated core business objects,
>>>and an applicationContextCore.xml that wire the business objects to DAOs and
>>>such like.
>>>
>>>One of my apps that requires access the business objects in this core.jar is
>>>a
>>>web app, the other is a client app that calls an ejb that uses core.jar
>>>
>>>What I would like to do is distribute applicationContextCore.xml with
>>>core.jar
>>>and then reference it when creating the contexts for the ejb and web.
>>>
>>>In particular for the war then, in web.xml it would be good to be able to
>>>specify applicationContextCore.xml (and any other web specific application
>>>context) for the war context listener.
>>>
>>>But at the moment it appears as though XmlWebApplicationContext only uses
>>>paths relative to the webapp root and does not search the web app classloader
>>>classpath for the file.
>>>
>>>Are there any plans to add this functionality? Currenly I am copying the
>>>applicationContextCore.xml into the war at build time, which works but feels
>>>a
>>>bit messy...
>>>
>>>Cheers,
>>>N
>>>
>>>
>>>
>>>-------------------------------------------------------
>>>This SF.net email is sponsored by: SF.net Giveback Program.
>>>Does SourceForge.net help you be more productive? Does it
>>>help you create better code? SHARE THE LOVE, and help us help
>>>YOU! Click Here: http://sourceforge.net/donate/
>>>_______________________________________________
>>>Springframework-user mailing list
>>>Spr...@li...
>>>https://lists.sourceforge.net/lists/listinfo/springframework-user
>>>
>>>
>>
>>-------------------------------------------------------
>>This SF.net email is sponsored by: SF.net Giveback Program.
>>Does SourceForge.net help you be more productive? Does it
>>help you create better code? SHARE THE LOVE, and help us help
>>YOU! Click Here: http://sourceforge.net/donate/
>>_______________________________________________
>>Springframework-user mailing list
>>Spr...@li...
>>https://lists.sourceforge.net/lists/listinfo/springframework-user
>>
>>
>>
>>
>>-------------------------------------------------------
>>This SF.net email is sponsored by: SF.net Giveback Program.
>>Does SourceForge.net help you be more productive? Does it
>>help you create better code? SHARE THE LOVE, and help us help
>>YOU! Click Here: http://sourceforge.net/donate/
>>_______________________________________________
>>Springframework-user mailing list
>>Spr...@li...
>>https://lists.sourceforge.net/lists/listinfo/springframework-user
>>
>>
|
|
From: <jue...@we...> - 2003-11-27 21:59:39
|
On second thought, I agree. They won't be used for such existing beans = anyway, so it's probably be better to not support them at all. = Currently, existing beans also go through the BeanPostProcessor chain - = that won't be really needed for that case either, so we could decide to = not support that too. =20 Juergen =20 ________________________________ Von: spr...@li... im Auftrag = von Colin Sampaleanu Gesendet: Do 27.11.2003 22:37 An: spr...@li... Cc: spr...@li... Betreff: [Springframework-developer] Re: [Springframework-user] wiring = beans created outside a BeanFactory Are you sure it's appropriate to call the BeanFactoryAware and ApplicationContextAware callbacks? After all, the bean is not in fact in the bean factory or application context. To me the callbacks imply that it is... j=FCrgen h=F6ller [werk3AT] wrote: >I've just added two methods to DefaultListableBeanFactory: >- autowireByName(Object existingBean, boolean dependencyCheck) >- autowireByType(Object existingBean, boolean dependencyCheck) > >Both will also invoke lifecycle methods if the corresponding interfaces = are implemented, like = InitializingBean/BeanFactoryAware/ApplicationContextAware. I'll commit = the changes to CVS promptly. > >For the time being, those autowire methods will just be defined in = DefaultListableBeanFactory and thus its subclass XmlBeanFactory. I guess = we don't want to require this functionality for all bean factories, so = we shouldn't include them in the BeanFactory/ListableBeanFactory = interfaces. The methods aren't concerned with configuration of the bean = factory either, so Configurable(Listable)BeanFactory isn't the right = place for them either. > >Juergen > > >-----Original Message----- >From: spr...@li... >[mailto:spr...@li...]On Behalf Of >Federico Spinazzi >Sent: Thursday, November 27, 2003 5:42 PM >To: spr...@li... >Subject: Re: [springframework] Re: [Springframework-user] wiring beans >created outside a BeanFactory > > >Rod Johnson wrote: > >=20 > >>Yes, I realised when I saw my post on the list that I'd missed the = point. >>Sorry Frederico for assuming you had a much simpler problem... >> >> =20 >> >And sorry I once thought you have just developed just another framework >... :-) >I would like to try to work on this, with maybe some guidance, it's OK? >Thanks you all. >Federico > > >=20 > >>----- Original Message ----- >>From: "j=FCrgen h=F6ller [werk3AT]" <jue...@we...> >>To: <spr...@li...> >>Sent: Thursday, November 27, 2003 3:21 PM >>Subject: RE: [Springframework-user] wiring beans created outside a >>BeanFactory >> >> >>I think what Frederico wants to do is pass an *existing instance* = (coming in >> =20 >> >>from a network) to a bean factory for filling in dependencies. Of = course, >=20 > >>without a bean definition in the factory, just autowiring would be >>possible - but that's something we could consider supporting. >> >>Juergen >> >> >>-----Original Message----- >>From: spr...@li... >>[mailto:spr...@li...]On Behalf Of >>Rod Johnson >>Sent: Thursday, November 27, 2003 3:56 PM >>To: spr...@li... >>Subject: Re: [Springframework-user] wiring beans created outside a >>BeanFactory >> >> >>Frederico, >> >>Dependencies can be resolved by the context using Inversion of = Control. >>Please look at the example and my article on TSS: >> >>http://www.theserverside.com/resources/article.jsp?l=3DSpringFramework >> >>Simply put something like: >> >><property name=3D"store"><ref local=3D"myStoreBeanName"/></property> >><-- resolve other properties as well --> >> >>In the bean definition for your StoreCommand, using the = XmlBeanFactory. >> >>Or just define it with >> >><bean id=3D"store" class=3D"StoreCommand" >> autwire=3D"byType" >> >>and Spring will find the collaborators automagically. >> >>You don't need to subclass Spring classes or work with bean = definitions >>directly. >> >>Regards, >>Rod >> >> >> >> =20 >> >>>Hy, >>> >>>I would like to know if it is possible to ask a context to resolve = the >>>dipendencies for a given object. >>>Assume I get a Command object from the network and I need to resolve >>>some dependencies before execution: >>> >>>public class StoreCommand implements Command, Serializable { >>> private Entity entityToBeStored; >>> private Store store; >>> private Logger logger; >>> >>> public StoreCommand(Entity entity) { >>> this.entityToBeStored =3D entity; >>> } >>> >>> public void execute() { >>> try { >>> store.store(entityToBeStored); >>> } catch (StoreException e) { >>> logger.error("exception rised while storing entity " + >>>entityToBeStored, e); >>> } >>> } >>> >>> public void setStore(Store store) { >>> this.store =3D store; >>> } >>> >>> >>> public void setLogger(Logger logger) { >>> this.logger =3D logger; >>> } >>>} >>> >>>It would be fine if the dependencies on store and logger could be >>>resolved dinamically by a BeanFactory. >>>I think I've to write something like this (in a subclass of >>>AbstractBeanfactory): >>> >>>RootBeanDefinition beanDefinition =3D new >>>RootBeanDefinition(StoreCommand.class, null, false); >>>beanDefinition.setAutowire(RootBeanDefinition.AUTOWIRE_BY_TYPE); >>>autowireByType("to be wired", beanDefinition, ????); >>> >>>but then I'm stuck as I connot figure how to get an instance back. >>>Thanks, >>>Federico >>> >>> >>> >>> >>>------------------------------------------------------- >>>This SF.net email is sponsored by: SF.net Giveback Program. >>>Does SourceForge.net help you be more productive? Does it >>>help you create better code? SHARE THE LOVE, and help us help >>>YOU! Click Here: http://sourceforge.net/donate/ >>>_______________________________________________ >>>Springframework-user mailing list >>>Spr...@li... >>>https://lists.sourceforge.net/lists/listinfo/springframework-user >>> =20 >>> >>> =20 >>> >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: SF.net Giveback Program. >>Does SourceForge.net help you be more productive? Does it >>help you create better code? SHARE THE LOVE, and help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Springframework-user mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-user >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: SF.net Giveback Program. >>Does SourceForge.net help you be more productive? Does it >>help you create better code? SHARE THE LOVE, and help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Springframework-user mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-user >> >> >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: SF.net Giveback Program. >>Does SourceForge.net help you be more productive? Does it >>help you create better code? SHARE THE LOVE, and help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Springframework-user mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-user >> >> >> >> >> >> =20 >> > > > > >------------------------------------------------------- >This SF.net email is sponsored by: SF.net Giveback Program. >Does SourceForge.net help you be more productive? Does it >help you create better code? SHARE THE LOVE, and help us help >YOU! Click Here: http://sourceforge.net/donate/ >_______________________________________________ >Springframework-user mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-user > > >------------------------------------------------------- >This SF.net email is sponsored by: SF.net Giveback Program. >Does SourceForge.net help you be more productive? Does it >help you create better code? SHARE THE LOVE, and help us help >YOU! Click Here: http://sourceforge.net/donate/ >_______________________________________________ >Springframework-user mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-user >=20 > ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Colin S. <col...@ex...> - 2003-11-27 21:37:08
|
Are you sure it's appropriate to call the BeanFactoryAware and ApplicationContextAware callbacks? After all, the bean is not in fact in the bean factory or application context. To me the callbacks imply that it is... jürgen höller [werk3AT] wrote: >I've just added two methods to DefaultListableBeanFactory: >- autowireByName(Object existingBean, boolean dependencyCheck) >- autowireByType(Object existingBean, boolean dependencyCheck) > >Both will also invoke lifecycle methods if the corresponding interfaces are implemented, like InitializingBean/BeanFactoryAware/ApplicationContextAware. I'll commit the changes to CVS promptly. > >For the time being, those autowire methods will just be defined in DefaultListableBeanFactory and thus its subclass XmlBeanFactory. I guess we don't want to require this functionality for all bean factories, so we shouldn't include them in the BeanFactory/ListableBeanFactory interfaces. The methods aren't concerned with configuration of the bean factory either, so Configurable(Listable)BeanFactory isn't the right place for them either. > >Juergen > > >-----Original Message----- >From: spr...@li... >[mailto:spr...@li...]On Behalf Of >Federico Spinazzi >Sent: Thursday, November 27, 2003 5:42 PM >To: spr...@li... >Subject: Re: [springframework] Re: [Springframework-user] wiring beans >created outside a BeanFactory > > >Rod Johnson wrote: > > > >>Yes, I realised when I saw my post on the list that I'd missed the point. >>Sorry Frederico for assuming you had a much simpler problem... >> >> >> >And sorry I once thought you have just developed just another framework >... :-) >I would like to try to work on this, with maybe some guidance, it's OK? >Thanks you all. >Federico > > > > >>----- Original Message ----- >>From: "jürgen höller [werk3AT]" <jue...@we...> >>To: <spr...@li...> >>Sent: Thursday, November 27, 2003 3:21 PM >>Subject: RE: [Springframework-user] wiring beans created outside a >>BeanFactory >> >> >>I think what Frederico wants to do is pass an *existing instance* (coming in >> >> >>from a network) to a bean factory for filling in dependencies. Of course, > > >>without a bean definition in the factory, just autowiring would be >>possible - but that's something we could consider supporting. >> >>Juergen >> >> >>-----Original Message----- >>From: spr...@li... >>[mailto:spr...@li...]On Behalf Of >>Rod Johnson >>Sent: Thursday, November 27, 2003 3:56 PM >>To: spr...@li... >>Subject: Re: [Springframework-user] wiring beans created outside a >>BeanFactory >> >> >>Frederico, >> >>Dependencies can be resolved by the context using Inversion of Control. >>Please look at the example and my article on TSS: >> >>http://www.theserverside.com/resources/article.jsp?l=SpringFramework >> >>Simply put something like: >> >><property name="store"><ref local="myStoreBeanName"/></property> >><-- resolve other properties as well --> >> >>In the bean definition for your StoreCommand, using the XmlBeanFactory. >> >>Or just define it with >> >><bean id="store" class="StoreCommand" >> autwire="byType" >> >>and Spring will find the collaborators automagically. >> >>You don't need to subclass Spring classes or work with bean definitions >>directly. >> >>Regards, >>Rod >> >> >> >> >> >>>Hy, >>> >>>I would like to know if it is possible to ask a context to resolve the >>>dipendencies for a given object. >>>Assume I get a Command object from the network and I need to resolve >>>some dependencies before execution: >>> >>>public class StoreCommand implements Command, Serializable { >>> private Entity entityToBeStored; >>> private Store store; >>> private Logger logger; >>> >>> public StoreCommand(Entity entity) { >>> this.entityToBeStored = entity; >>> } >>> >>> public void execute() { >>> try { >>> store.store(entityToBeStored); >>> } catch (StoreException e) { >>> logger.error("exception rised while storing entity " + >>>entityToBeStored, e); >>> } >>> } >>> >>> public void setStore(Store store) { >>> this.store = store; >>> } >>> >>> >>> public void setLogger(Logger logger) { >>> this.logger = logger; >>> } >>>} >>> >>>It would be fine if the dependencies on store and logger could be >>>resolved dinamically by a BeanFactory. >>>I think I've to write something like this (in a subclass of >>>AbstractBeanfactory): >>> >>>RootBeanDefinition beanDefinition = new >>>RootBeanDefinition(StoreCommand.class, null, false); >>>beanDefinition.setAutowire(RootBeanDefinition.AUTOWIRE_BY_TYPE); >>>autowireByType("to be wired", beanDefinition, ????); >>> >>>but then I'm stuck as I connot figure how to get an instance back. >>>Thanks, >>>Federico >>> >>> >>> >>> >>>------------------------------------------------------- >>>This SF.net email is sponsored by: SF.net Giveback Program. >>>Does SourceForge.net help you be more productive? Does it >>>help you create better code? SHARE THE LOVE, and help us help >>>YOU! Click Here: http://sourceforge.net/donate/ >>>_______________________________________________ >>>Springframework-user mailing list >>>Spr...@li... >>>https://lists.sourceforge.net/lists/listinfo/springframework-user >>> >>> >>> >>> >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: SF.net Giveback Program. >>Does SourceForge.net help you be more productive? Does it >>help you create better code? SHARE THE LOVE, and help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Springframework-user mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-user >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: SF.net Giveback Program. >>Does SourceForge.net help you be more productive? Does it >>help you create better code? SHARE THE LOVE, and help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Springframework-user mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-user >> >> >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: SF.net Giveback Program. >>Does SourceForge.net help you be more productive? Does it >>help you create better code? SHARE THE LOVE, and help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Springframework-user mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-user >> >> >> >> >> >> >> > > > > >------------------------------------------------------- >This SF.net email is sponsored by: SF.net Giveback Program. >Does SourceForge.net help you be more productive? Does it >help you create better code? SHARE THE LOVE, and help us help >YOU! Click Here: http://sourceforge.net/donate/ >_______________________________________________ >Springframework-user mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-user > > >------------------------------------------------------- >This SF.net email is sponsored by: SF.net Giveback Program. >Does SourceForge.net help you be more productive? Does it >help you create better code? SHARE THE LOVE, and help us help >YOU! Click Here: http://sourceforge.net/donate/ >_______________________________________________ >Springframework-user mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-user > > |
|
From: <jue...@we...> - 2003-11-27 18:06:17
|
I've just added two methods to DefaultListableBeanFactory: - autowireByName(Object existingBean, boolean dependencyCheck) - autowireByType(Object existingBean, boolean dependencyCheck) Both will also invoke lifecycle methods if the corresponding interfaces = are implemented, like = InitializingBean/BeanFactoryAware/ApplicationContextAware. I'll commit = the changes to CVS promptly. For the time being, those autowire methods will just be defined in = DefaultListableBeanFactory and thus its subclass XmlBeanFactory. I guess = we don't want to require this functionality for all bean factories, so = we shouldn't include them in the BeanFactory/ListableBeanFactory = interfaces. The methods aren't concerned with configuration of the bean = factory either, so Configurable(Listable)BeanFactory isn't the right = place for them either. Juergen =20 -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Federico Spinazzi Sent: Thursday, November 27, 2003 5:42 PM To: spr...@li... Subject: Re: [springframework] Re: [Springframework-user] wiring beans created outside a BeanFactory Rod Johnson wrote: >Yes, I realised when I saw my post on the list that I'd missed the = point. >Sorry Frederico for assuming you had a much simpler problem... > And sorry I once thought you have just developed just another framework=20 ... :-) I would like to try to work on this, with maybe some guidance, it's OK? Thanks you all. Federico >----- Original Message -----=20 >From: "j=FCrgen h=F6ller [werk3AT]" <jue...@we...> >To: <spr...@li...> >Sent: Thursday, November 27, 2003 3:21 PM >Subject: RE: [Springframework-user] wiring beans created outside a >BeanFactory > > >I think what Frederico wants to do is pass an *existing instance* = (coming in >from a network) to a bean factory for filling in dependencies. Of = course, >without a bean definition in the factory, just autowiring would be >possible - but that's something we could consider supporting. > >Juergen > > >-----Original Message----- >From: spr...@li... >[mailto:spr...@li...]On Behalf Of >Rod Johnson >Sent: Thursday, November 27, 2003 3:56 PM >To: spr...@li... >Subject: Re: [Springframework-user] wiring beans created outside a >BeanFactory > > >Frederico, > >Dependencies can be resolved by the context using Inversion of Control. >Please look at the example and my article on TSS: > >http://www.theserverside.com/resources/article.jsp?l=3DSpringFramework > >Simply put something like: > ><property name=3D"store"><ref local=3D"myStoreBeanName"/></property> ><-- resolve other properties as well --> > >In the bean definition for your StoreCommand, using the XmlBeanFactory. > >Or just define it with > ><bean id=3D"store" class=3D"StoreCommand" > autwire=3D"byType" > >and Spring will find the collaborators automagically. > >You don't need to subclass Spring classes or work with bean definitions >directly. > >Regards, >Rod > > =20 > >>Hy, >> >>I would like to know if it is possible to ask a context to resolve the >>dipendencies for a given object. >>Assume I get a Command object from the network and I need to resolve >>some dependencies before execution: >> >>public class StoreCommand implements Command, Serializable { >> private Entity entityToBeStored; >> private Store store; >> private Logger logger; >> >> public StoreCommand(Entity entity) { >> this.entityToBeStored =3D entity; >> } >> >> public void execute() { >> try { >> store.store(entityToBeStored); >> } catch (StoreException e) { >> logger.error("exception rised while storing entity " + >>entityToBeStored, e); >> } >> } >> >> public void setStore(Store store) { >> this.store =3D store; >> } >> >> >> public void setLogger(Logger logger) { >> this.logger =3D logger; >> } >>} >> >>It would be fine if the dependencies on store and logger could be >>resolved dinamically by a BeanFactory. >>I think I've to write something like this (in a subclass of >>AbstractBeanfactory): >> >>RootBeanDefinition beanDefinition =3D new >>RootBeanDefinition(StoreCommand.class, null, false); >>beanDefinition.setAutowire(RootBeanDefinition.AUTOWIRE_BY_TYPE); >>autowireByType("to be wired", beanDefinition, ????); >> >>but then I'm stuck as I connot figure how to get an instance back. >>Thanks, >>Federico >> >> >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: SF.net Giveback Program. >>Does SourceForge.net help you be more productive? Does it >>help you create better code? SHARE THE LOVE, and help us help >>YOU! Click Here: http://sourceforge.net/donate/ >>_______________________________________________ >>Springframework-user mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-user >> =20 >> > > > > >------------------------------------------------------- >This SF.net email is sponsored by: SF.net Giveback Program. >Does SourceForge.net help you be more productive? Does it >help you create better code? SHARE THE LOVE, and help us help >YOU! Click Here: http://sourceforge.net/donate/ >_______________________________________________ >Springframework-user mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-user > > >------------------------------------------------------- >This SF.net email is sponsored by: SF.net Giveback Program. >Does SourceForge.net help you be more productive? Does it >help you create better code? SHARE THE LOVE, and help us help >YOU! Click Here: http://sourceforge.net/donate/ >_______________________________________________ >Springframework-user mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-user > > > > >------------------------------------------------------- >This SF.net email is sponsored by: SF.net Giveback Program. >Does SourceForge.net help you be more productive? Does it >help you create better code? SHARE THE LOVE, and help us help >YOU! Click Here: http://sourceforge.net/donate/ >_______________________________________________ >Springframework-user mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-user > > > > =20 > ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Springframework-user mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-user |
|
From: <jue...@we...> - 2003-11-27 15:41:57
|
I'm pretty sure it's not expensive at all with MySQL and MyISAM as table = manager ;-) Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Rod Johnson Sent: Thursday, November 27, 2003 4:35 PM To: spr...@li... Subject: Re: [Springframework-developer] Commons Pooling and DBCP With Oracle an optimization I've committed today to only call setAutoCommit() if it needs to restored to true should give another 10% improvement in performance of the DataSourceTransactionManager. setAutoCommit() is a very expensive operation on an Oracle connection. = Don't know about other databases, but I wouldn't be surprised if they're = similar. Regards, Rod ----- Original Message -----=20 From: "Trevor Cook" <pr...@se...> To: <spr...@li...> Sent: Thursday, November 27, 2003 2:35 PM Subject: RE: [Springframework-developer] Commons Pooling and DBCP > We don't do heavy benchmarking, but our early tests showed about 15% = gains > (but this wasn't white paper benchmarking, this was just running our > client's project tests). BTW, we use postgres 7.3 > > Speed wasn't actually the reason we switched though. We had a really weird > (as in unreproducable) bug that cropped up every 2 weeks and crashed = the > connection which is why we updated. Since the update the problem has > disappeared (4 weeks, no crash :) ). > > Trevor > > > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On = Behalf > Of Rod Johnson > Sent: November 27, 2003 9:16 AM > To: spr...@li... > Subject: Re: [Springframework-developer] Commons Pooling and DBCP > > > Trevor, > > Have you found significant benefits? I've seen +30% in a benchmark due = to > adding prepared statement caching. > > Regards, > Rod > > ----- Original Message ----- > From: "Trevor Cook" <pr...@se...> > To: <spr...@li...> > Sent: Thursday, November 27, 2003 2:05 PM > Subject: RE: [Springframework-developer] Commons Pooling and DBCP > > > > +1 (we're already using it) > > > > Trevor > > > > -----Original Message----- > > From: spr...@li... > > [mailto:spr...@li...]On = Behalf > > Of Rod Johnson > > Sent: November 27, 2003 8:09 AM > > To: spr...@li... > > Subject: [Springframework-developer] Commons Pooling and DBCP > > > > > > Anyone object if I upgrade the versions in CVS to 1.1 for each? DBCP = 1.1 > > certainly performs better. > > > > Regards, > > Rod > > > > ____________________________________________________ > > Rod Johnson > > J2EE Consultant and Author > > +44 7973 409 132 > > rod...@in... > > > > Author of "Expert One-on-One J2EE Design and Development" > > (October 2002). > > http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ > > > > Founder, Spring Framework: > > http://www.springframework.org > > > > "Introducing the Spring Framework" (ServerSide article) > > = http://www.theserverside.com/resources/article.jsp?l=3DSpringFramework > > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: SF.net Giveback Program. > > Does SourceForge.net help you be more productive? Does it > > help you create better code? SHARE THE LOVE, and help us help > > YOU! Click Here: http://sourceforge.net/donate/ > > _______________________________________________ > > Springframework-developer mailing list > > Spr...@li... > > = https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: SF.net Giveback Program. > > Does SourceForge.net help you be more productive? Does it > > help you create better code? SHARE THE LOVE, and help us help > > YOU! Click Here: http://sourceforge.net/donate/ > > _______________________________________________ > > Springframework-developer mailing list > > Spr...@li... > > = https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Rod J. <rod...@in...> - 2003-11-27 15:35:47
|
With Oracle an optimization I've committed today to only call setAutoCommit() if it needs to restored to true should give another 10% improvement in performance of the DataSourceTransactionManager. setAutoCommit() is a very expensive operation on an Oracle connection. Don't know about other databases, but I wouldn't be surprised if they're similar. Regards, Rod ----- Original Message ----- From: "Trevor Cook" <pr...@se...> To: <spr...@li...> Sent: Thursday, November 27, 2003 2:35 PM Subject: RE: [Springframework-developer] Commons Pooling and DBCP > We don't do heavy benchmarking, but our early tests showed about 15% gains > (but this wasn't white paper benchmarking, this was just running our > client's project tests). BTW, we use postgres 7.3 > > Speed wasn't actually the reason we switched though. We had a really weird > (as in unreproducable) bug that cropped up every 2 weeks and crashed the > connection which is why we updated. Since the update the problem has > disappeared (4 weeks, no crash :) ). > > Trevor > > > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On Behalf > Of Rod Johnson > Sent: November 27, 2003 9:16 AM > To: spr...@li... > Subject: Re: [Springframework-developer] Commons Pooling and DBCP > > > Trevor, > > Have you found significant benefits? I've seen +30% in a benchmark due to > adding prepared statement caching. > > Regards, > Rod > > ----- Original Message ----- > From: "Trevor Cook" <pr...@se...> > To: <spr...@li...> > Sent: Thursday, November 27, 2003 2:05 PM > Subject: RE: [Springframework-developer] Commons Pooling and DBCP > > > > +1 (we're already using it) > > > > Trevor > > > > -----Original Message----- > > From: spr...@li... > > [mailto:spr...@li...]On Behalf > > Of Rod Johnson > > Sent: November 27, 2003 8:09 AM > > To: spr...@li... > > Subject: [Springframework-developer] Commons Pooling and DBCP > > > > > > Anyone object if I upgrade the versions in CVS to 1.1 for each? DBCP 1.1 > > certainly performs better. > > > > Regards, > > Rod > > > > ____________________________________________________ > > Rod Johnson > > J2EE Consultant and Author > > +44 7973 409 132 > > rod...@in... > > > > Author of "Expert One-on-One J2EE Design and Development" > > (October 2002). > > http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ > > > > Founder, Spring Framework: > > http://www.springframework.org > > > > "Introducing the Spring Framework" (ServerSide article) > > http://www.theserverside.com/resources/article.jsp?l=SpringFramework > > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: SF.net Giveback Program. > > Does SourceForge.net help you be more productive? Does it > > help you create better code? SHARE THE LOVE, and help us help > > YOU! Click Here: http://sourceforge.net/donate/ > > _______________________________________________ > > Springframework-developer mailing list > > Spr...@li... > > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: SF.net Giveback Program. > > Does SourceForge.net help you be more productive? Does it > > help you create better code? SHARE THE LOVE, and help us help > > YOU! Click Here: http://sourceforge.net/donate/ > > _______________________________________________ > > Springframework-developer mailing list > > Spr...@li... > > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Trevor C. <pr...@se...> - 2003-11-27 14:35:30
|
We don't do heavy benchmarking, but our early tests showed about 15% gains (but this wasn't white paper benchmarking, this was just running our client's project tests). BTW, we use postgres 7.3 Speed wasn't actually the reason we switched though. We had a really weird (as in unreproducable) bug that cropped up every 2 weeks and crashed the connection which is why we updated. Since the update the problem has disappeared (4 weeks, no crash :) ). Trevor -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Rod Johnson Sent: November 27, 2003 9:16 AM To: spr...@li... Subject: Re: [Springframework-developer] Commons Pooling and DBCP Trevor, Have you found significant benefits? I've seen +30% in a benchmark due to adding prepared statement caching. Regards, Rod ----- Original Message ----- From: "Trevor Cook" <pr...@se...> To: <spr...@li...> Sent: Thursday, November 27, 2003 2:05 PM Subject: RE: [Springframework-developer] Commons Pooling and DBCP > +1 (we're already using it) > > Trevor > > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On Behalf > Of Rod Johnson > Sent: November 27, 2003 8:09 AM > To: spr...@li... > Subject: [Springframework-developer] Commons Pooling and DBCP > > > Anyone object if I upgrade the versions in CVS to 1.1 for each? DBCP 1.1 > certainly performs better. > > Regards, > Rod > > ____________________________________________________ > Rod Johnson > J2EE Consultant and Author > +44 7973 409 132 > rod...@in... > > Author of "Expert One-on-One J2EE Design and Development" > (October 2002). > http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ > > Founder, Spring Framework: > http://www.springframework.org > > "Introducing the Spring Framework" (ServerSide article) > http://www.theserverside.com/resources/article.jsp?l=SpringFramework > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Rod J. <rod...@in...> - 2003-11-27 14:16:45
|
Trevor, Have you found significant benefits? I've seen +30% in a benchmark due to adding prepared statement caching. Regards, Rod ----- Original Message ----- From: "Trevor Cook" <pr...@se...> To: <spr...@li...> Sent: Thursday, November 27, 2003 2:05 PM Subject: RE: [Springframework-developer] Commons Pooling and DBCP > +1 (we're already using it) > > Trevor > > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On Behalf > Of Rod Johnson > Sent: November 27, 2003 8:09 AM > To: spr...@li... > Subject: [Springframework-developer] Commons Pooling and DBCP > > > Anyone object if I upgrade the versions in CVS to 1.1 for each? DBCP 1.1 > certainly performs better. > > Regards, > Rod > > ____________________________________________________ > Rod Johnson > J2EE Consultant and Author > +44 7973 409 132 > rod...@in... > > Author of "Expert One-on-One J2EE Design and Development" > (October 2002). > http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ > > Founder, Spring Framework: > http://www.springframework.org > > "Introducing the Spring Framework" (ServerSide article) > http://www.theserverside.com/resources/article.jsp?l=SpringFramework > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > ------------------------------------------------------- > This SF.net email is sponsored by: SF.net Giveback Program. > Does SourceForge.net help you be more productive? Does it > help you create better code? SHARE THE LOVE, and help us help > YOU! Click Here: http://sourceforge.net/donate/ > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Colin S. <col...@ex...> - 2003-11-27 14:14:39
|
Rob Butler wrote: >>So options include: >>- description element for bean and description attribute for finer-grained >>elements >> >> > >Why not just keep things consistent and use the element everywhere instead >of an element in some areas and attributes in others. Since the element >will be optional it won't make the xml any more complex when not used. Also >it allows for greater flexibiliy. Someone might need to put in an extended >comment (a la element) where you only allow for attribute comments. > > > I think I have to agree... |
|
From: Colin S. <col...@ex...> - 2003-11-27 14:13:28
|
+1. We use 1.1 already with Spring on one app of ours that runs outside of the J2EE container... Rod Johnson wrote: >Anyone object if I upgrade the versions in CVS to 1.1 for each? DBCP 1.1 >certainly performs better. > >Regards, >Rod > >____________________________________________________ >Rod Johnson >J2EE Consultant and Author >+44 7973 409 132 >rod...@in... > >Author of "Expert One-on-One J2EE Design and Development" >(October 2002). >http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ > >Founder, Spring Framework: >http://www.springframework.org > >"Introducing the Spring Framework" (ServerSide article) >http://www.theserverside.com/resources/article.jsp?l=SpringFramework > > > > >------------------------------------------------------- >This SF.net email is sponsored by: SF.net Giveback Program. >Does SourceForge.net help you be more productive? Does it >help you create better code? SHARE THE LOVE, and help us help >YOU! Click Here: http://sourceforge.net/donate/ >_______________________________________________ >Springframework-developer mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-developer > > |
|
From: Trevor C. <pr...@se...> - 2003-11-27 14:05:49
|
+1 (we're already using it) Trevor -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Rod Johnson Sent: November 27, 2003 8:09 AM To: spr...@li... Subject: [Springframework-developer] Commons Pooling and DBCP Anyone object if I upgrade the versions in CVS to 1.1 for each? DBCP 1.1 certainly performs better. Regards, Rod ____________________________________________________ Rod Johnson J2EE Consultant and Author +44 7973 409 132 rod...@in... Author of "Expert One-on-One J2EE Design and Development" (October 2002). http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ Founder, Spring Framework: http://www.springframework.org "Introducing the Spring Framework" (ServerSide article) http://www.theserverside.com/resources/article.jsp?l=SpringFramework ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: <jue...@we...> - 2003-11-27 13:39:36
|
+1 - we're using DBCP 1.1 for company projects, works nicely. (We don't ship DBCP with Spring, though, so it's doesn't matter in that = respect) Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Rod Johnson Sent: Thursday, November 27, 2003 2:09 PM To: spr...@li... Subject: [Springframework-developer] Commons Pooling and DBCP Anyone object if I upgrade the versions in CVS to 1.1 for each? DBCP 1.1 certainly performs better. Regards, Rod ____________________________________________________ Rod Johnson J2EE Consultant and Author +44 7973 409 132 rod...@in... Author of "Expert One-on-One J2EE Design and Development" (October 2002). http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ Founder, Spring Framework: http://www.springframework.org "Introducing the Spring Framework" (ServerSide article) http://www.theserverside.com/resources/article.jsp?l=3DSpringFramework ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Rod J. <rod...@in...> - 2003-11-27 13:14:08
|
Anyone object if I upgrade the versions in CVS to 1.1 for each? DBCP 1.1 certainly performs better. Regards, Rod ____________________________________________________ Rod Johnson J2EE Consultant and Author +44 7973 409 132 rod...@in... Author of "Expert One-on-One J2EE Design and Development" (October 2002). http://www.amazon.com/exec/obidos/tg/detail/-/0764543857/ Founder, Spring Framework: http://www.springframework.org "Introducing the Spring Framework" (ServerSide article) http://www.theserverside.com/resources/article.jsp?l=SpringFramework |
|
From: Rob B. <rob...@ve...> - 2003-11-27 12:44:23
|
> So options include: > - description element for bean and description attribute for finer-grained > elements Why not just keep things consistent and use the element everywhere instead of an element in some areas and attributes in others. Since the element will be optional it won't make the xml any more complex when not used. Also it allows for greater flexibiliy. Someone might need to put in an extended comment (a la element) where you only allow for attribute comments. > Another decision is whether to expose bean-level descriptions > programmatically via the BeanDefinition. This may be useful, although I > think it's lower priority than getting the DTD right. Any thoughts on this? > Practical situations in which it would be useful? I can't see how this would be useful in a J2EE environment.. But it could (possibly) be useful when using Spring for Swing apps, or other apps that are "visually" contructed from Javabeans. Later Rob |
|
From: Rod J. <rod...@in...> - 2003-11-27 10:09:55
|
All,
As I believe someone brought up on the forums, we should allow users to add
optional documentation in Spring XML files. This could be as simple as a
change to the DTD, but there are a few issues around how we do it.
It should be possible to attach descriptive text to any bean element, such
as bean, property, constructor-arg, in particular. Also to the document as a
whole.
However, we need to decide on the tradeoff between verbosity and power. E.g.
we could have this:
<bean id="foo" class="whatever" description="This is the application's
magical foo service">
<property name="delay" description="Milliseconds to delay before
starting another pass">...
This is concise, but attributes are not suited to lengthy text, and some
characters are problematic. So we could promote the description to element
level like this:
<bean id="foo" class="whatever">
<description>This is the application's magical foo service</description>
<property name="delay">
<description>Milliseconds to delay before starting another
pass</description>
<value>...
</property>
Now I think this makes sense for the <bean> element. But I don't think it
makes sense for properties. I hate verbose XML formats like anything from
Sun, where they'll never use an attribute where an element would do.
So options include:
- description element for bean and description attribute for finer-grained
elements
- all element can support a description attribute or element a la Ant. I'm
not sure how elegant this is but it would be optimally expressive.
- different names for attribute and element: attribute is shortInfo perhaps
and description element can be longer. Thus it would be rare, but legal, to
add a description element to a property.
We also need to allow a top-level description element for the beans element,
as the first thing.
Of course, all descriptions would be optional, so it wouldn't break existing
applications or add work for those developers who don't care about adding
descriptions.
Another decision is whether to expose bean-level descriptions
programmatically via the BeanDefinition. This may be useful, although I
think it's lower priority than getting the DTD right. Any thoughts on this?
Practical situations in which it would be useful?
Just having descriptions in the XML could be useful, but it would be
particularly good to use that information in XSLT to generate nicely
formated "SpringDoc". This could start off fairly simply, just showing bean
name, description, class, hyperlinked dependencies etc. However, there are
many potential refinements:
- Generating something showing the relationship to related bean factories,
the other factories probably supplied in the tool arguments
- HTML that allows information about a particular bean to be expanded or
collapsed.
- Hyperlinks to the Javadoc for the relevant class if its location is
supplied
- Recognition and possibly "collapsing" of common idioms. E.g. it could
display that "foo" is a bean of type "com.myco.Foo" and that it's an AOP
proxy with the following interceptors.
I will change the DTD based on what we decide and possibly implement any
support for it in the BeanDefinitions, but we need a volunteer to tackle the
XSLT stuff. Hopefully an XSLT wizard with time to take this on will step
forward!
Regards,
Rod
PS Please reply to the dev list. I've cross posted this as I thought that a
user, rather than existing developer, might have the XSLT skills and
willingness to work on this...
|
|
From: <tri...@tr...> - 2003-11-26 23:39:47
|
All,
I have finally had a block of time to devote to implementing the "Mapping"
feature for rows in the resultsets returned by a stored procedure. It is
similar to the mapping of results returned in a query except that a stored
procedure can return multiple resultsets. Each resultset's rows will be mapped
to an object that is placed in a List. This List is returned in the Map
returned by execute - the same way return values for other output parameters are
returned.
To use this feature you must create a class (probably an inner class defined in
your class that extends StoredProcedure) that implements the new interface
RowMapper. Here is an example:
private class PetMapper implements RowMapper {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
Pet p = new Pet();
p.setId(rs.getInt(1));
p.setName(rs.getString(2));
return p;
}
}
When you specify the out parameter that returns the resultset you pass in this
RowMapper class as the third parameter. Here is an Oracle example:
declareParameter(new SqlOutParameter("rs", oracle.jdbc.OracleTypes.CURSOR, new
PetMapper()));
If you use SQL Server or Sybase and I think DB2 then you would use
SqlReturnResultSet with the RowMapper as the second parameter. Like this:
declareParameter(new SqlReturnResultSet("rs", new PetMapper()));
You would retrieve the List of rows from the Map returned by the execute method
of the StoredProcedure.
List rs = (List) resultMap.get("rs");
I have added a test to the StoredProcedureTestSuite and I have also added a test
for the recently reintroduced ParameterMapper interface. You can look at these
for an example on how to use this feature. If you want a complete example, let
me know and I will post one.
Thomas
|
|
From: Colin S. <col...@ex...> - 2003-11-26 19:36:16
|
In the meantime, I've done a somewhat smarter/dumber solution (depending on your point of view). At afterPropertiesSet time, MethodInvokingFactoryBean will try to match a target method with the exact same name and exact same arg types. If that doesn't work, it will try to find one (and only one) method with the exact same name, and the same number of arguments. In this case, it will potentially match an improper method, but it relies on a runtime failuer (IllegalArgumentException) when getObject is called, if the specified method arguments can not be assigned to the target method arguments, by the invoke call. Colin Sampaleanu wrote: > W/regards to doing proper method matching based on argument types in > MethodInvokingFactoryBean, there are a few different levels it can be > taken to. The current code is pretty dumb, it uses reflection to try > to find a target method with the exact same argument types as the > supplied arguments. This won't even work for calling methods which > take arguments which are superclasses of the specified arguments. What > would be pretty easy to do is to rip out the MethodUtils class from > Apache BeanUtils, which can do proper method matching via a method > called getMatchingAccessibleMethod(). The main downside to this is > that MethodUtils compiles to about 7.5k of bytecode. This could > probably be whittled down to about 5k by stripping out some items, but > still, it would increase the base bean handling code by that amount. > The third level would be to do coercion on the level of List -> Array, > etc. > > I don't think the latter is worth it, but I am wondering about the 2nd... > > > Rod Johnson wrote: > >> This is excellent. We had a question about this on the forums >> recently. It's >> pretty powerful to be able to do arbitrary nesting. >> >> Regards, >> Rod >> >> ----- Original Message ----- From: "jürgen höller [werk3AT]" >> <jue...@we...> >> To: <spr...@li...> >> Sent: Wednesday, November 26, 2003 4:37 PM >> Subject: RE: [Springframework-developer] How hard is is to add >> support for >> list inside of a list, in an XML beanfactory def? >> >> >> This is actually pretty simple: We just need to allow for <list> (and >> <map>) >> as sub-element of <list> in the DTD - the bean factory can already >> handle >> any kind of nested element! I've just patched the DTD accordingly and >> committed it; a corresponding unit test passes (not committed yet due to >> other work). >> >> Juergen >> >> >> -----Original Message----- >> From: spr...@li... >> [mailto:spr...@li...]On Behalf >> Of Colin Sampaleanu >> Sent: Wednesday, November 26, 2003 5:15 PM >> To: spr...@li... >> Subject: [Springframework-developer] How hard is is to add support for >> list inside of a list, in an XML beanfactory def? >> >> >> Right now in a bean factory xml definition, a list can not contain a >> list. Can somebody who is more familiar with the bean wrapping estimate >> how big a deal this would be to add? >> >> The issue comes in using the MethodInvokingFactoryBean to invoke a >> method which takes an array or list as an argument. Right now there is >> no way to do it unfortunately. > |
|
From: Chris N. <ch...@si...> - 2003-11-26 19:09:50
|
Rod Johnson wrote: > I've just added a HotSwappableInvokerInterceptor that allows such swapping > for advised objects. I think it's better to do this via AOP than via an ad > hoc DP solution. This way it will work for classes proxied by CGLIB also. Hot-swapping is a pretty specialized case in that it doesn't require a Method object or a boxed argument array, just a reference to the object to delegate to. CGLIB2 has different interceptor types that can take advantage of this, so you may not want to be reusing the generic AOP code anyway. Chris |