Spring in Workbrain - Part 3 - Service Layer

So far in our Spring module in Workbrain, we have our Spring beans being automatically added to the Application Context and we have our database tables accessible via Spring in the data layer. Next we would like to add in our business logic and provide a service layer which can be used by our presentation layer.



The service layer in Workbrain is very much just core Spring. You'll need your Java interface class defining the public methods which will be accessible to our web layer and via other services. And then you'll need your implementation of those interfaces.

Within your services, you may need to access legacy non-Spring based code and DB connections. To do this, use the following code block, within which you can pass the retrieved DBConnection object:

DBConnection conn = null;
try {
    conn = (DBConnection)WbDataSourceUtil.getConnection();
    ...
}
finally {
    WbDataSourceUtil.releaseConnection(conn);
}

Once you have completed your service layer code, you'll need to create a bean in the previously defined service-config.xml. Restart your JEE server and you are well on your way to your Spring module in Workbrain!

0 comments:

Post a Comment