Details

    • Type: Wish Wish
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0
    • Fix Version/s: None
    • Component/s: PicoContainer Gems
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Not rightly sure how to go about it. The idea is like this.

      Given a request level service:

           public MyRequestService {
                   public MyRequestService(HttpServletResponse request, HttpServletResponse response) {
                       /*..... */
                   }
          }
      

      It would be nice to be able to assemble it in Pico like this:

      MutablePicoContainer appContainer = new PicoBuilder( /*..... */).build()
                                        .as(DEMOTABLE).addComponent(MyRequestService.class)
      
      
      MutablePicoContainer requestContainer = appContainer.makeChildContainer()
                                      .addComponent(HttpServletResponse.class, response)
                                      .addComponent(HttpServletRequest.class, request)    
      
      assert requestContainer.getComponent(MyRequestService.class) != null;                  
      

      When MyRequestService is installed, it would have a new instance demoted to the request container (and stored whatever
      storage facility the request container used).

      It might seem a little hokey, but the thing is... if we had something like this, we could actually get rid of forcing end-user configuration management of 3 containers. In my own code base, I have something like:

      appContainer.as(REQUEST).addComponent(MyService.class)

      where the lifecycle and storage is handled by a ServletFilter, but MyService still can't depend on request-level only stuff (such as servlet request, servlet response, servlet session).

      I suppose if we ignored the storage issue using TheadLocals, so we would have:

             mpc.as(THREAD_LOCAL, DEMOTABLE).addComponent(MyRequestService.class);
      

      then the only responsibility of the DemotableBehavior would be to register the requestservice in the request container and then get component instance from there. But the container references strike me as tricky.

        People

        • Assignee:
          Unassigned
          Reporter:
          Michael Rimov
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated: