Announcement Announcement Module
No announcement yet.
Is there a way to scope the containment? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is there a way to scope the containment?

    I have a busieness tier that has a few Services that are for the web tier for consume. There are however services that I do not want to expose to the web tier.

    For example, say I have a QueryManager and the web tier supplies a criteria that the manager sifts thru. It should decide whether to construct a SQL stmt and query the DB or use DAO (beacuse criteria is a parameter to one of the DAO's methods) manager to access the objects. DAO manager is only seen by the QueryManager. However if I configure my contexts all the services appear to have one global scope. So the web tier can get the reference to DAO service which in my case should be disallowed.

    Does anyone have any ideas on how I would achieve this?

  • #2
    You can use ref local="bean name" in order to keep the related beans into the same file and inside your Java code start using visibility keywords (protected, friendly) in order to isolate your java code. However, I'm not aware of any functionality inside Spring as it is a developer framework - that is you want to control your code and Spring doesn't want to get in your way.
    It's more of a framework then a container in that aspect.

    Another approach would be to add method interceptors to create domains - see acegiframework which uses this in order to add security inside the application. However, I think this is a huge overhead considering what you are trying to solve.
    Hope it helps.


    • #3
      Could you not write a custom bean factory which takes the name of a context and exports a single bean from that context, i.e.:

        <bean id="myService" class="ChildBeanFactory">
          <property name="beanToExport" value="myServiceImpl"/>

      Would be suprised if Spring doesn't already have something to do this


      • #4
        You could use a separate configuration file for the service layer to use. The web layer will look up a <context>-servlet.xml to reference the service layer alone. This way the web app can only look up the service layer.
        You can init a separate class to load a BeanFactory for the service layer which has the DAO FActory definitions.