Hi,
I am a new comer here. And I am programming a mid-sized program. Currently, I feel a little bit uncomfortable for the archetecture. Most uncomfortable comes from the transfer of an object everywhere in the program. I have a little background of IOC. So I am wondering whether we can apply IOC in our program to make things better. The scenario is as below:
We want to build a portal program to provide the service to others (one of the goal is the insurance application). We want to make part of the common functionality reusable. So one decision point is to separate the program to two parts, one is the portal (using jsf), and the other is the reusable utility (such as connection pool, caching and etc). The utility classes use a lot of static methods since they don't need to maintain the internal state. And the utility class will be used in other scenarios. So we don't want it know something related to the portal, such as session and request.
The problem comes from the token. The token comes from the SSO (single sign on) feature. That token is used to identify a user's identification. Since the SSO is outside of the web server, so its lifetime is not controlled by the web sever. In order to align the lifecycle of token with the session, we put it to a object (for example, UserConfigInfo). That object is per-session based. When the session is created, the object will be created explicitly by portal side, and then if the session is timeout, the object will be automatically gabage collected.
The problem comes. Since the utility classes does not maintain the state, so the utility class will ask the caller from portal side to transfer a UserConfigInfo object for every call. So basically, every method in utility classes has that parameter. And the only usage of the object is to get the token. I think it is a problem that every method signatures are polluted by a UserConfigInfo object.
I think the problem comes because we do not have a mechnism to make a session wide singleton object. And from my knowledge of IOC, I think IOC can bring that feature. But I don't know whether it is a good scenario for applying IOC and how to apply it effectively.
Could anyone share some insights with me?
Thanks.


Reply With Quote