Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] HttpService, Jetty, Session timeout

Hi Frank,
 
Answering an earlier question...
The set of properties that can be set on Jetty Http are listed in OSGI-INF/metada/config.xml.
 
These properties can be used in three ways:
1) BundleContext properties to configure the "autostarted" instance of the HttpService. The full property names are "org.eclipse.equinox.http.jetty." + {short property name}. The autostarted implementation can be disabled by setting "org.eclipse.equinox.http.jetty.autostart=false".
2) Using ConfigAdmin with the property names in config.xml to create a new instance of the HttpService.
3) Using org.eclipse.equinox.http.jetty.JettyConfigurator  with the property names in config.xml to create a new instance of the HttpService.
 
 
For session timeout see the patch in  https://bugs.eclipse.org/bugs/show_bug.cgi?id=173913 
 
The patch adds a property named "context.setsessioninactiveinterval" for configuring session timeout. This setting is global to the configured instance of the HttpService (e.g. not per servlet or per HttpContext as you're the implementation does not support this).
 
If you want to set this using a System Property then try something like:
 -Dorg.eclipse.equinox.http.jetty.context.sessioninactiveinterval=600
 
HTH
-Simon
 
----- Original Message -----
Sent: Tuesday, February 13, 2007 6:10 AM
Subject: AW: [equinox-dev] HttpService, Jetty, Session timeout

Hi again,
 
thanks for your answers to my question. Seems to be correct that there isn't a system property for setting a global session timeout. I was only thinking about that since we only have to deal with on servlet in RAP.
 
The code snippet of Ben brought me to the idea of a solution in the Activator of org.eclipse.equinox.http.jetty:

  public void start(BundleContext context) throws Exception {
    server = new HttpServer();
    SocketListener httpListener = createHttpListener(context);
    if (httpListener != null) {
      server.addListener(httpListener);
    }
    SocketListener httpsListener = createHttpsListener(context);
    if (httpsListener != null) {
      server.addListener(httpsListener);
    }
    ServletHandler servlets = new ServletHandler();
    servlets.setAutoInitializeServlets(true);
    ServletHolder holder
      = servlets.addServlet("/*", InternalHttpServiceServlet.class.getName());
    holder.setInitOrder(0);
    HttpContext httpContext = createHttpContext(context);
    httpContext.addHandler(servlets);

    //////////////////////////////////////////////////////////////////
    // read session timeout property something like this
    
    int sessionTimeout = -1;
    String sessionTimeoutProperty
      = context.getProperty( "org.osgi.service.http.sessiontimeout" );
    if( sessionTimeoutProperty != null ) {
      try {
        sessionTimeout = Integer.parseInt( sessionTimeoutProperty );
        servlets.setSessionInactiveInterval( sessionTimeout );
      } catch (NumberFormatException e) {
        //(log this) ignore and use default
      }
    }

    /////////////////////////////////////////////////////////////////
               
    server.addContext(httpContext);
    server.start();
  }

This would work like the system property used to set the port. Setting the timeouts for each servlet would need a different solution. I'm not quite sure if this would be conform to the servlet specification anyway, since a deployment descriptor defines a session timeout per webapp and not per servlet. At least I think this makes sense since requests to different servlets can be done in one and the same session. Maybe it would be better to set the session timeout per context, but looking at the implementation I wonder if there is really a strict separation between the contexts?
 
Ciao
Frank


Von: equinox-dev-bounces@xxxxxxxxxxx [mailto:equinox-dev-bounces@xxxxxxxxxxx] Im Auftrag von Jeremy Volkman
Gesendet: Montag, 12. Februar 2007 20:22
An: Equinox development mailing list
Betreff: Re: [equinox-dev] HttpService, Jetty, Session timeout

Simon,

I don't quite understand the solution that you have in mind.  We set the timeout value on a per-Servlet basis (using the reflection code that Ben posted).  Does your solution support this, or is it an HttpService-global setting?

-Jeremy

On 2/12/07, Simon Kaegi <simon.kaegi@xxxxxxxxx> wrote:
Hi Frank and Ben,

Please create an enhancement request in bugzilla.
This could be added to the ServletHandler when the Jetty Server instance is
being created very easily.

-Simon

----- Original Message -----
From: "Benjamin Schmaus" <benjamin.schmaus@xxxxxxxxx>
To: "Equinox development mailing list" <equinox-dev@xxxxxxxxxxx >
Sent: Monday, February 12, 2007 1:32 PM
Subject: Re: [equinox-dev] HttpService, Jetty, Session timeout


> Hi Frank -
>
> I've run into this issue before.  Since the OSGi HTTP service doesn't
> support the use of a web.xml file (to the best of my knowledge
> anyway), session timeouts can't be set in the standard way.
>
> What I've done to work around this is to use reflection to invoke a
> Jetty-specific method for setting session timeouts.
>
> For example:
>
>    public void setSessionTimeout(HttpServlet servlet, int timeoutSeconds)
> {
>        ServletContext sc = servlet.getServletContext();
>
>        Object handler = reflector.invokeMethod(sc,
> "getServletHandler", null, null);
>        reflector.invokeMethod(
>                handler,
>                "setSessionInactiveInterval",
>                new Class[]{Integer.TYPE},
>                new Object[]{new Integer(timeoutSeconds)}
>        );
>    }
>
> (The 'reflector' object uses the java.lang.reflect API under the hood.)
>
> AOP might be another approach to setting session timeout under Jetty
> that's worth investigating.
>
> HTH
>
> - Ben
>
> On 2/12/07, Frank Appel < fappel@xxxxxxxxxxxxxx> wrote:
>>
>> Hi,
>>
>> I've been looking a while for a possibility to set the session timeout of
>> the HttpService using Jetty as the underlying engine. Is there a simple
>> system property like org.osgi.service.http.port which is used to set the
>> port and if so, where can I find documentation about the available
>> properties?
>>
>> Thanks
>> Frank Appel
>> _______________________________________________
>> equinox-dev mailing list
>> equinox-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>>
>>
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev

_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev


_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Back to the top