Research Log of Web Science Students

Computer Science is not simply programming

Wiring my first factory in Spring

leave a comment »

I felt the need to have only one instance of google’s user service in our app. Instatiating it in different places is clearly shotgun surgery!

I had this piece of code all over our controllers!

UserService userService = UserServiceFactory.getUserService();

The solution: instantiate it only once in the Spring Container and
inject it into all objects that need it. Like so:

<bean id="googleUserService"

Sample controller that needs the user service:

<bean id="IndexController"
 	<property name="userService"

I am glad that went well. Sheesh I need to start blogging about our research. Nuff of the technical stuff for now.


Written by Jose Asuncion

August 30, 2009 at 5:33 pm

Posted in Hardwire

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: