|
From: <tr...@us...> - 2003-06-27 02:20:03
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/service In directory sc8-pr-cvs1:/tmp/cvs-serv700/src/com/babeldoc/core/service Modified Files: ServiceException.java ServiceFactory.java Log Message: reformatted and updated license header Index: ServiceException.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/service/ServiceException.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ServiceException.java 15 Mar 2003 22:54:11 -0000 1.2 --- ServiceException.java 27 Jun 2003 02:20:00 -0000 1.3 *************** *** 1,26 **** ! /* ! * $Header$ ! * $DateTime: 2002/07/21 17:01:20 $ * * ! * babeldoc: universal document processor * ! * This program is free software; you can redistribute it and/or ! * modify it under the terms of the GNU General Public License ! * as published by the Free Software Foundation; either version 2 ! * of the License, or (at your option) any later version. * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package com.babeldoc.core.service; - /** * Handling service exceptions. This is straight specialization of --- 1,69 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 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" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * 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/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.service; /** * Handling service exceptions. This is straight specialization of *************** *** 30,36 **** * @version 1.0 */ ! public class ServiceException ! extends com.babeldoc.core.GeneralException { ! /** * Service exception --- 73,77 ---- * @version 1.0 */ ! public class ServiceException extends com.babeldoc.core.GeneralException { /** * Service exception *************** *** 54,58 **** /** * Service exception - * */ public ServiceException() { --- 95,98 ---- Index: ServiceFactory.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/service/ServiceFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ServiceFactory.java 22 May 2003 03:20:29 -0000 1.5 --- ServiceFactory.java 27 Jun 2003 02:20:00 -0000 1.6 *************** *** 1,22 **** ! /* ! * $Header$ ! * $DateTime: 2002/07/21 17:01:20 $ * * ! * babeldoc: universal document processor * ! * This program is free software; you can redistribute it and/or ! * modify it under the terms of the GNU General Public License ! * as published by the Free Software Foundation; either version 2 ! * of the License, or (at your option) any later version. * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package com.babeldoc.core.service; --- 1,66 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 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" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * 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/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.service; *************** *** 29,37 **** import java.util.Iterator; /** ! * Simple name to object mapping. This is a critical part of the system ! * and it allows for names to be associated with classes in various ! * decoupled ways. The various Types provide an easy look into this ! * service system. * * @author bmcdonald --- 73,81 ---- import java.util.Iterator; + /** ! * Simple name to object mapping. This is a critical part of the system and it ! * allows for names to be associated with classes in various decoupled ways. ! * The various Types provide an easy look into this service system. * * @author bmcdonald *************** *** 39,50 **** */ public class ServiceFactory { ! /** ! * Configuration constants ! */ public static String CONFIG_NAME = "service/query"; ! /** ! * singleton configuration ! */ private static ServiceFactory instance = null; --- 83,90 ---- */ public class ServiceFactory { ! /** Configuration constants */ public static String CONFIG_NAME = "service/query"; ! /** singleton configuration */ private static ServiceFactory instance = null; *************** *** 56,98 **** /** ! * Get the singleton reference ! */ ! protected static ServiceFactory getInstance() { ! if (instance == null) { ! instance = new ServiceFactory(); ! } ! return instance; ! } ! ! /** ! * get the service class for the service name. * - * @param name of the service * @return - * @throws ServiceException */ ! public static Class getServiceClass(String name) ! throws ServiceException { ! String classname = ConfigService.getString(CONFIG_NAME, name); ! if (classname == null) { ! throw new ServiceException(I18n.get("000043", name), null); } ! return com.babeldoc.core.ResourceLoader.getClass(classname); } /** ! * Get the instantiated service object for the service name. This ! * object must have a default (no-argument) constructor or this will ! * fail. * * @param name * @return instantiated object (must have a null constructor) * @throws ServiceException */ ! public static Object getService(String name) ! throws ServiceException { try { Class theClass = getServiceClass(name); Object service = theClass.newInstance(); return service; } catch (Exception e) { --- 96,145 ---- /** ! * Return all services of the given type. This is used to discover all ! * relevant named services for display, iteration purposes. ! * ! * @param serviceType hashmap of matching services. * * @return */ ! public static HashMap getAllServices(String serviceType) { ! //put dot at the end of type to get prefix ! if (!serviceType.endsWith(".")) { ! serviceType = serviceType + "."; } ! ! IConfig serviceConfig = ConfigService.getInstance().getConfig(CONFIG_NAME); ! HashMap services = new HashMap(); ! Iterator keys = serviceConfig.keys().iterator(); ! ! while (keys.hasNext()) { ! String key = (String) keys.next(); ! ! //if key starts with service name then it is of that type ! if (key.startsWith(serviceType)) { ! //put it without prefix ! services.put(key.substring(serviceType.length()), ! serviceConfig.getString(key)); ! } ! } ! ! return services; } /** ! * Get the instantiated service object for the service name. This object ! * must have a default (no-argument) constructor or this will fail. * * @param name + * * @return instantiated object (must have a null constructor) + * * @throws ServiceException */ ! public static Object getService(String name) throws ServiceException { try { Class theClass = getServiceClass(name); Object service = theClass.newInstance(); + return service; } catch (Exception e) { *************** *** 102,129 **** /** ! * Return all services of the given type. This is used to ! * discover all relevant named services for display, iteration ! * purposes. * - * @param serviceType hashmap of matching services. * @return */ ! public static HashMap getAllServices(String serviceType) { ! //put dot at the end of type to get prefix ! if (!serviceType.endsWith(".")) { ! serviceType = serviceType + "."; } ! IConfig serviceConfig = ConfigService.getInstance().getConfig(CONFIG_NAME); ! HashMap services = new HashMap(); ! Iterator keys = serviceConfig.keys().iterator(); ! while (keys.hasNext()) { ! String key = (String) keys.next(); ! //if key starts with service name then it is of that type ! if (key.startsWith(serviceType)) { ! //put it without prefix ! services.put(key.substring(serviceType.length()), serviceConfig.getString(key)); ! } } ! return services; } } --- 149,181 ---- /** ! * get the service class for the service name. ! * ! * @param name of the service * * @return + * + * @throws ServiceException */ ! public static Class getServiceClass(String name) throws ServiceException { ! String classname = ConfigService.getString(CONFIG_NAME, name); ! ! if (classname == null) { ! throw new ServiceException(I18n.get("000043", name), null); } ! ! return com.babeldoc.core.ResourceLoader.getClass(classname); ! } ! ! /** ! * Get the singleton reference ! * ! * @return DOCUMENT ME! ! */ ! protected static ServiceFactory getInstance() { ! if (instance == null) { ! instance = new ServiceFactory(); } ! ! return instance; } } |