epugh 2004/11/04 12:49:25
Modified: mimetype/impl/src/java/org/apache/fulcrum/mimetype
DefaultMimeTypeService.java
mimetype/impl project.xml
Added: mimetype/impl/src/test/org/apache/fulcrum/mimetype
MimeTypeServiceFacadeTest.java
mimetype/api/src/java/org/apache/fulcrum/mimetype
MimeTypeServiceFacade.java
Log:
Add a facade helper class
Revision Changes Path
1.1
jakarta-turbine-fulcrum/mimetype/impl/src/test/org/apache/fulcrum/mimetype/MimeTypeServiceFacadeTest.java
Index: MimeTypeServiceFacadeTest.java
===================================================================
package org.apache.fulcrum.mimetype;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
//
import org.apache.fulcrum.testcontainer.BaseUnitTest;
/**
* Test the MimeTypeServiceFacade.
*
* @author <a href="[EMAIL PROTECTED]">Eric Pugh</a>
* @version $Id: MimeTypeServiceFacadeTest.java,v 1.1 2004/11/04 20:49:25 epugh Exp $
*/
public class MimeTypeServiceFacadeTest extends BaseUnitTest
{
/**
* Defines the testcase name for JUnit.
*
* @param name the testcase's name.
*/
public MimeTypeServiceFacadeTest(String name)
{
super(name);
}
public void testFacadeNotConfigured() throws Exception
{
assertNull(MimeTypeServiceFacade.getService());
}
public void testFacadeConfigured() throws Exception
{
// this.lookup causes the service to be configured.
this.lookup(MimeTypeService.ROLE);
assertNotNull(MimeTypeServiceFacade.getService());
}
}
1.5 +13 -2
jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/DefaultMimeTypeService.java
Index: DefaultMimeTypeService.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/mimetype/impl/src/java/org/apache/fulcrum/mimetype/DefaultMimeTypeService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultMimeTypeService.java 30 Jun 2004 13:35:53 -0000 1.4
+++ DefaultMimeTypeService.java 4 Nov 2004 20:49:25 -0000 1.5
@@ -63,6 +63,8 @@
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
import org.apache.fulcrum.mimetype.util.CharSetMap;
import org.apache.fulcrum.mimetype.util.MimeType;
import org.apache.fulcrum.mimetype.util.MimeTypeMap;
@@ -92,7 +94,7 @@
*/
public class DefaultMimeTypeService
extends AbstractLogEnabled
- implements MimeTypeService, Configurable, Initializable, Contextualizable
+ implements MimeTypeService, Configurable, Initializable, Contextualizable,
Serviceable
{
private String applicationRoot;
/**
@@ -360,4 +362,13 @@
this.context = context;
this.applicationRoot = context.get( "urn:avalon:home" ).toString();
}
+
+ /**
+ * Avalon component lifecycle method
+ */
+ public void service( ServiceManager manager) {
+
+ MimeTypeServiceFacade.setMimeTypeService(this);
+
+ }
}
1.8 +1 -1 jakarta-turbine-fulcrum/mimetype/impl/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-fulcrum/mimetype/impl/project.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- project.xml 1 Nov 2004 13:29:22 -0000 1.7
+++ project.xml 4 Nov 2004 20:49:25 -0000 1.8
@@ -9,7 +9,7 @@
<dependency>
<groupId>fulcrum</groupId>
<artifactId>fulcrum-mimetype-api</artifactId>
- <version>1.0.4</version>
+ <version>1.0.4-dev</version>
</dependency>
<!-- Needed only for testing -->
1.1
jakarta-turbine-fulcrum/mimetype/api/src/java/org/apache/fulcrum/mimetype/MimeTypeServiceFacade.java
Index: MimeTypeServiceFacade.java
===================================================================
package org.apache.fulcrum.mimetype;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/**
* <p> This is a facade class for [EMAIL PROTECTED] MimeTypeService}.
*
* <p> This class provides static methods that retrieve the configured
* implementation of [EMAIL PROTECTED]
* MimeTypeService} and perform certain operations on it. It uses
* constants defined in [EMAIL PROTECTED] MimeTypeService} interface for accessing
* the service's properties and default values for them.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Eric Pugh</a>
* @version $Id: MimeTypeServiceFacade.java,v 1.1 2004/11/04 20:49:25 epugh Exp $
*/
public class MimeTypeServiceFacade
{
private static MimeTypeService mimetypeService;
public static void setMimeTypeService(MimeTypeService uploadService){
MimeTypeServiceFacade.mimetypeService = uploadService;
}
/**
* <p> Retrieves an instance of system's configured implementation
* of <code>UploadService</code>
*
* @return An instance of UploadService
*/
public static MimeTypeService getService()
{
return mimetypeService;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]