Skip to main content

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

Why don't you guys write an RFP for the OSGi with these needs? We are
starting to work on R5 and if this is a real issue.

Kind regards,

     Peter Kriens

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

SK>   
SK> Hi again,
SK>   
SK>  
SK>   
SK> thanks for your answers to my question. Seems to be    correct
SK> that there isn't a system property for setting a global session   
SK> timeout. I was only thinking about that since we only have to deal with on    servlet in RAP.
SK>   
SK>  
SK>   
SK> The code snippet of Ben brought me to the idea of a    solution
SK> in the Activator of    org.eclipse.equinox.http.jetty:
SK>   
SK>   
SK>   public void    start(BundleContext context) throws Exception {
SK>     server =    new HttpServer();
SK>     SocketListener httpListener =    createHttpListener(context);
SK>     if (httpListener != null)    {
SK>          server.addListener(httpListener);
SK>        }
SK>     SocketListener httpsListener =    createHttpsListener(context);
SK>     if (httpsListener != null)    {
SK>          server.addListener(httpsListener);
SK>        }
SK>     ServletHandler servlets = new    ServletHandler();
SK>        servlets.setAutoInitializeServlets(true);
SK>     ServletHolder    holder 
SK>       = servlets.addServlet("/*",   
SK> InternalHttpServiceServlet.class.getName());
SK>        holder.setInitOrder(0);
SK>     HttpContext httpContext =    createHttpContext(context);
SK>        httpContext.addHandler(servlets);
SK>   
SK>       
SK> //////////////////////////////////////////////////////////////////
SK>        // read session timeout property something    like this
SK>     
SK>     int    sessionTimeout = -1;
SK>     String    sessionTimeoutProperty
SK>       =    context.getProperty(
SK> "org.osgi.service.http.sessiontimeout"    );
SK>     if( sessionTimeoutProperty != null )    {
SK>       try    {
SK>         sessionTimeout =    Integer.parseInt( sessionTimeoutProperty    );
SK>            servlets.setSessionInactiveInterval( sessionTimeout    );
SK>       } catch (NumberFormatException e)    {
SK>         //(log this) ignore and use    default
SK>       }
SK>     }
SK>   
SK>       
SK> /////////////////////////////////////////////////////////////////
SK>                 
SK>     server.addContext(httpContext);
SK>        server.start();
SK>   }
SK>   
SK> This would work like the system property used to set the    port.
SK> Setting the timeouts for each servlet would need a different
SK> solution.    I'm not quite sure if this would be conform to the
SK> servlet specification    anyway, since a deployment descriptor
SK> defines a session timeout per webapp and    not per servlet. At
SK> least I think this makes sense since requests to different   
SK> servlets can be done in one and the same session. Maybe it would
SK> be better to    set the session timeout per context, but looking
SK> at the implementation I    wonder if there is really a strict
SK> separation between the    contexts?
SK>   
SK>  
SK>   
SK> Ciao
SK>   
SK> Frank

SK>   
SK>   

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

SK>   
SK> Simon,

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

SK> -Jeremy

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

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

SK> -Simon

SK> -----      Original Message ----- 
SK> From: "Benjamin Schmaus" <benjamin.schmaus@xxxxxxxxx>
SK> To:      "Equinox development mailing list" <equinox-dev@xxxxxxxxxxx >
SK> Sent: Monday, February 12, 2007 1:32 PM
SK> 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

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


SK>   
SK>   

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


SK>   

-- 
Peter Kriens                              Tel +33467542167
9C, Avenue St. Drézéry                    AOL,Yahoo: pkriens
34160 Beaulieu, France                    ICQ 255570717
Skype pkriens                             Fax +1 8153772599



Back to the top