Jetty
  1. Jetty
  2. JETTY-505

WebAppDeployer should allow using a subclass of WebAppContext

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 6.1.7
    • Fix Version/s: None
    • Component/s: HTTP
    • Labels:
      None
    • Number of attachments :
      0

      Description

      I am investigating how to add Zeroconf support to jetty, and some investigation with the 6.1.7 source have indicated that the appropriate place to do the necessary registration and deregistration of the zeroconf service is in the doStart() and doStop() methods of WebAppContext, and would fit well in a subclass of WebAppContext with the registration after the super.doStart() and the deregistration before the super.doStop().

      Unfortunately the scan() method in WebAppDeployer is hardcoded to create a new WebAppContext object, so there is no easy way to use my subclassed WebAppContext. The only other alternative would be to have a ContextHandlerCollection which can be assigned to a WebAppContext, which I do not think is a good way to do this.

      Could the hardcoded new be replaced with a call to a user customizable factory method?

        Activity

        Hide
        Jan Bartel added a comment -

        Thorbjørn,

        Have you tried using the ContextDeployer? In the context xml file you should be able to specify whatever type of WebAppContext subclass you want:

        <Configure class="my.special.WebAppContext">
        ...
        </Configure>

        cheers
        Jan

        Show
        Jan Bartel added a comment - Thorbjørn, Have you tried using the ContextDeployer? In the context xml file you should be able to specify whatever type of WebAppContext subclass you want: <Configure class="my.special.WebAppContext"> ... </Configure> cheers Jan
        Hide
        Thorbjørn Ravn Andersen added a comment -

        Thank you. This works with the proof-of-concept code, but I need to explicit add the jmdns.jar and a jar containing my subclass to jetty/lib.

        Is there a way to add extra entries to the classpath from within the context snippet to avoid this?

        Show
        Thorbjørn Ravn Andersen added a comment - Thank you. This works with the proof-of-concept code, but I need to explicit add the jmdns.jar and a jar containing my subclass to jetty/lib. Is there a way to add extra entries to the classpath from within the context snippet to avoid this?
        Hide
        Jan Bartel added a comment -

        Thorbjørn,

        Yes. In the context xml file, you can use the WebAppContext.setExtraClasspath(String) method:

        <Configure class="my.special.WebAppContext">
        .
        .
        .
        <extraClasspath>my/path/to/my/extra/jar;other/classes</extraClasspath>
        </Configure>

        However, clearly you won't be able to use this method to set up the classpath to your WebAppContext classfile (because your class will already need to have been loaded).

        Other than copying the jar with your subclass to jetty/lib (which is definitely the easiest thing to do) you could:

        1. edit the start.config file to include what you want (see http://docs.codehaus.org/display/JETTY/A+look+at+the+start.jar+mechanism)
        or
        2. using one of the methods on this page: http://docs.codehaus.org/display/JETTY/Classloading

        cheers
        Jan

        Show
        Jan Bartel added a comment - Thorbjørn, Yes. In the context xml file, you can use the WebAppContext.setExtraClasspath(String) method: <Configure class="my.special.WebAppContext"> . . . <extraClasspath>my/path/to/my/extra/jar;other/classes</extraClasspath> </Configure> However, clearly you won't be able to use this method to set up the classpath to your WebAppContext classfile (because your class will already need to have been loaded). Other than copying the jar with your subclass to jetty/lib (which is definitely the easiest thing to do) you could: 1. edit the start.config file to include what you want (see http://docs.codehaus.org/display/JETTY/A+look+at+the+start.jar+mechanism ) or 2. using one of the methods on this page: http://docs.codehaus.org/display/JETTY/Classloading cheers Jan
        Hide
        Greg Wilkins added a comment -

        I'm closing this as I think the context deployer covers this use case.

        If you think there is still other things to be improved in jetty, please reopen.

        cheers

        Show
        Greg Wilkins added a comment - I'm closing this as I think the context deployer covers this use case. If you think there is still other things to be improved in jetty, please reopen. cheers

          People

          • Assignee:
            Unassigned
            Reporter:
            Thorbjørn Ravn Andersen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: