Return-Path: Delivered-To: apmail-avalon-dev-archive@www.apache.org Received: (qmail 23703 invoked from network); 12 Nov 2003 21:36:45 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 12 Nov 2003 21:36:45 -0000 Received: (qmail 30377 invoked by uid 500); 12 Nov 2003 21:36:28 -0000 Delivered-To: apmail-avalon-dev-archive@avalon.apache.org Received: (qmail 30347 invoked by uid 500); 12 Nov 2003 21:36:27 -0000 Mailing-List: contact dev-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon Developers List" Reply-To: "Avalon Developers List" Delivered-To: mailing list dev@avalon.apache.org Received: (qmail 30269 invoked from network); 12 Nov 2003 21:36:26 -0000 Received: from unknown (HELO main.gmane.org) (80.91.224.249) by daedalus.apache.org with SMTP; 12 Nov 2003 21:36:26 -0000 Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AK2f9-0005d8-00 for ; Wed, 12 Nov 2003 22:36:31 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: dev@avalon.apache.org Received: from sea.gmane.org ([80.91.224.252]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AK2f8-0005d0-00 for ; Wed, 12 Nov 2003 22:36:30 +0100 Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AK2f8-00047N-00 for ; Wed, 12 Nov 2003 22:36:30 +0100 From: "Timothy Bennett" Subject: Re: [avalon-http] SessionManager Date: Wed, 12 Nov 2003 15:37:01 -0600 Lines: 99 Message-ID: References: <3FACE85C.4090909@apache.org> <3FB02BBB.4000406@apache.org> <002201c3a7f9$1f667710$6664a8c0@ge6xx42ojt093o> <3FB1BE26.8030900@apache.org> <3FB29C4D.4090907@apache.org> X-Complaints-To: usenet@sea.gmane.org X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Sender: news X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N "Stephen McConnell" wrote in message news:3FB29C4D.4090907@apache.org... > > Timothy Bennett wrote: > > > > >Hmmmmmm... Can you give me code example of where/when you were getting a > >cast exception? I wasn't having this problem, nor can I understand under > >what circumstances you were trying to do a class cast. > > > > Sure. > > The SessionManager interface is defined as follows: > > package org.apache.avalon.merlin.http; > public interface SessionManager {} > > In JettyWebServer which implements Serviceable > > /** > * stuff > * @avalon.dependency > type="org.apache.avalon.merlin.http.SessionManager" version="1.1" > */ > public void service(ServiceManager manager) > > Based on @avalon.dependency, Merlin will generate a xinfo descriptor and > a SessionManager appliance will be assigned within the service manager > applied to the JettyWebServer. However, down in the > setSessionManager(HttpContext context) method, the following code is > invoked: > > String clazzName = > org.apache.avalon.merlin.http.SessionManager.class.getName(); > servletHandler.setSessionManager((SessionManager) > m_serviceManager.lookup(clazzName)); > > The casting reference to SessionManager is not > org.apache.avalon.merlin.http.SessionManager, instead its > org.mortbay.jetty.servlet.SessionManager - bingo - ClassCastException > because http.SessionManager does not extend servlet.SessionManager (at > least it didn't but now it does but that screws up the API because we > are exposing a jetty class). > The package as coded was meant to keep the Jetty-specific stuff in the impl and keep the Jetty stuff out of the spi side of things. Here is how it is supposed to work, and maybe I screwed up the doclets or something: o.a.a.m.http.SessionManager is a place-holder empty interface in the api. That looks fine. In the impl side, the o.a.a.m.http.AvalonSessionManager implements this avalon-http SessionManager interface, BUT extends the org.mortbay.jetty.servlet.AbstractSessionManager class. This AvalonSessionManager is a merlin component and is a subclass of Jetty's SessionManager. But we don't use this component directory in any application we assembly. We construct our own "custom" extension of AvalonSessionManager that is also a merlin component that overrides the service() lifecycle method (just calling super(...)), so that our custom SessionManager (see o.a.a.m.http.example.ExampleSessionManager) can have doclet tags exposing the services that we are dependent on. But since this component is an extension of AvalonSessionManager, it is also a subclass of Jetty's AbstractSessionManager. Now the meta-info should tie the service dependency on o.a.a.m.http.SessionManager in JettyWebServer to the component implementation of that service that we define in our block.xml (and doclets) to our customized extension of AvalonSessionManager (such as the ExampleSessionManager). The block.xml shows this intention: Through the doclet's the JettyWebServer component should resolve its service dependency to the avalon-http SessionManager to the ExampleSessionManager implementation (which is also a Jetty Session Manager subclass because it extends AvalonSessionManager). The o.a.a.m.http.SessionManager interface SHOULD NOT extend Jetty Session Manager. That is what the AvalonSessionManager in the impl package is supposed to do. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org For additional commands, e-mail: dev-help@avalon.apache.org