Return-Path: Delivered-To: apmail-avalon-dev-archive@avalon.apache.org Received: (qmail 15258 invoked by uid 500); 7 Jul 2003 14:06:38 -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 15189 invoked from network); 7 Jul 2003 14:06:37 -0000 Received: from node1a14f.a2000.nl (HELO naomi.webworks.nl) (24.132.161.79) by daedalus.apache.org with SMTP; 7 Jul 2003 14:06:37 -0000 Subject: [SourceResolve] need for mime-type mappings Date: Mon, 7 Jul 2003 16:03:34 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Message-ID: <84F0A43A4248CE45B5C0E20F4C40779C60A2@naomi.webworks.nl> X-MS-Has-Attach: content-class: urn:content-classes:message X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 X-MS-TNEF-Correlator: Thread-Topic: [SourceResolve] need for mime-type mappings Thread-Index: AcNEkI3+6aU+6EJtTZG4Zc9s7Rzfvw== From: "Unico Hommes" To: "Avalon Developers List" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hi all, I was thinking that we need a common way to map mime-types in Avalon and that sourceresolve package is the place to put it. I have two use cases that raise the need for such a utility both related to sourceresolve: one is FTPSource where I need to determine what FTP transfer mode to use (ascii or binary) and the other is a XML database backed Source that stores both DOM objects and Blob objects. Depending on whether the location string identifies one or the other I want to the SourceFactory to return an XMLIzable Source or a plain one. Now in Cocoon there exists a utility class MIMEUtils that loads a mapping file for cases that the Cocoon Context object is not in the know about such things. I'd like to have a more general solution to this problem, and one that resides in the avalon namespace. The fact that systems have existing ways of providing such a service (Servlet API provides ServletContext.getMimeType() method and web.xml markup for declaring these mappings) suggests to me a service role instead of a static utility class. interface MimeTypeMapping { String getMimeType( String file ); } class ServletMimeTypeMapping { private ServletContext m_servletContext; void contextualize( Context context ) { m_servletContext =3D context.get( "servlet-context" ); } String getMimeType( String file ) { return m_servletContext.getMimeType( file ); } } class ConfigurableMimeTypeMapping { private Map mimeTypeMap; void configure( Configuration configuration ) { Configuration[] children =3D configuration.getChildren( "mime-mapping" ); for ( int i =3D 0; children.length < i; i++ ) { mimeTypeMap.put( children[i].getChild( "extension" ).getValue(),=20 children[i].getChild( "mime-type" ).getValue(); }=20 } String getMimeType( String file ) { return mimeTypeMap.get( file.getExtension() ); } } Etc. What do you think. Would this be a useful addition to sourceresolve? Regards, Unico --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org For additional commands, e-mail: dev-help@avalon.apache.org