ColdSpring and Service Layers: Always Proxy?

I've been using ColdSpring for a long time. I love it. And I love it when I learn something new about it or hear about a technique that I hadn't considered before.

Chris Scott recently commented on the ColdSpring list that he always creates proxy objects for his service layer objects. Even if he's not using AOP at that time for that particular object. Barney Boisvert chimed in to mention that he even goes the extra step of configuring his actual service objects as unnamed inner beans when he creates the proxies, like this:

<bean id="userService" class="coldspring.aop.framework.ProxyFactoryBean">
	<property name="target">
		<bean class="project.services.UserService" />
	</property>
</bean>

		

That way someone can't even accidentally get the original service object itself from ColdSpring, the only thing available is the proxied object. I thought this was a great idea and am going to do this all the time going forward.

There is a very small one time performance cost for using the proxy that happens at application startup. But that cost is virtually nothing, and now you have the ability to easily apply AOP interceptors to any of your service objects at any time.

I thought I'd blog about it for two reasons. First, to spread the good idea to anyone else who isn't on the ColdSpring list, and second, to see if I'm just the only person who wasn't already doing this. Do most of you fellow ColdSpring users just proxy your service objects by default like this?

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Wow, great idea. I use ColdSpring but have only read up on AOP but not used it yet. Its on the TODO list. This is a great idea if you even think you might need AOP later or even a retrofit. Thanks for the post.
# Posted By Ryan TJ | 1/2/08 2:31 PM
Brian,

Is there any other specific advantage in creating proxy objects for all service layer objects?
# Posted By Shimju David | 3/25/08 1:50 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1. Contact Blog Owner