001    // $HeadURL:
002    // /cvsroot/deegree/src/org/deegree/ogcwebservices/wcs/WCSServiceFactory.java,v
003    // 1.4 2004/06/18 15:50:30 tf Exp $
004    /*----------------------------------------------------------------------------
005     This file is part of deegree, http://deegree.org/
006     Copyright (C) 2001-2009 by:
007       Department of Geography, University of Bonn
008     and
009       lat/lon GmbH
010    
011     This library is free software; you can redistribute it and/or modify it under
012     the terms of the GNU Lesser General Public License as published by the Free
013     Software Foundation; either version 2.1 of the License, or (at your option)
014     any later version.
015     This library is distributed in the hope that it will be useful, but WITHOUT
016     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
017     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
018     details.
019     You should have received a copy of the GNU Lesser General Public License
020     along with this library; if not, write to the Free Software Foundation, Inc.,
021     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022    
023     Contact information:
024    
025     lat/lon GmbH
026     Aennchenstr. 19, 53177 Bonn
027     Germany
028     http://lat-lon.de/
029    
030     Department of Geography, University of Bonn
031     Prof. Dr. Klaus Greve
032     Postfach 1147, 53001 Bonn
033     Germany
034     http://www.geographie.uni-bonn.de/deegree/
035    
036     e-mail: info@deegree.org
037    ----------------------------------------------------------------------------*/
038    package org.deegree.ogcwebservices.wcs;
039    
040    import java.io.IOException;
041    import java.net.URL;
042    
043    import org.deegree.framework.log.ILogger;
044    import org.deegree.framework.log.LoggerFactory;
045    import org.deegree.framework.util.StringTools;
046    import org.deegree.ogcwebservices.getcapabilities.InvalidCapabilitiesException;
047    import org.deegree.ogcwebservices.wcs.configuration.InvalidConfigurationException;
048    import org.deegree.ogcwebservices.wcs.configuration.WCSConfiguration;
049    import org.xml.sax.SAXException;
050    
051    /**
052     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
053     * @author last edited by: $Author: mschneider $
054     *
055     * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
056     *
057     * @todo Usage of org.deegree.ogcwebservices.OGCServiceFactory OGC service factory
058     */
059    
060    public final class WCServiceFactory {
061    
062        private static WCSConfiguration CONFIG;
063    
064        private static final ILogger LOG = LoggerFactory.getLogger( WCServiceFactory.class );
065    
066        private WCServiceFactory() {
067            // private constructor
068        }
069    
070        /**
071         *
072         * @param config
073         * @return a new WCSService instance
074         */
075        public static WCService getInstance( WCSConfiguration config ) {
076            return new WCService( config );
077        }
078    
079        /**
080         *
081         * @param wcsConfiguration
082         */
083        public static void setConfiguration( WCSConfiguration wcsConfiguration ) {
084            CONFIG = wcsConfiguration;
085            // if service instance are already created
086            // destroy all instances
087            // create new service instances and put in pool
088            LOG.logInfo( StringTools.concat( 200, CONFIG.getService().getName(), " (", CONFIG.getVersion(),
089                                             ") service pool initialized." ) );
090        }
091    
092        /**
093         *
094         * @param serviceConfigurationUrl
095         * @throws InvalidConfigurationException
096         */
097        public static void setConfiguration( URL serviceConfigurationUrl )
098                                throws InvalidConfigurationException {
099            try {
100                WCServiceFactory.setConfiguration( WCSConfiguration.create( serviceConfigurationUrl ) );
101            } catch ( InvalidCapabilitiesException e ) {
102                LOG.logError( e.getMessage(), e );
103                throw new InvalidConfigurationException( "WCSServiceFactory", e.getMessage() );
104            } catch ( IOException e ) {
105                LOG.logError( e.getMessage(), e );
106                throw new InvalidConfigurationException( "WCSServiceFactory", e.getMessage() );
107            } catch ( SAXException e ) {
108                LOG.logError( e.getMessage(), e );
109                throw new InvalidConfigurationException( "WCSServiceFactory", e.getMessage() );
110            }
111    
112        }
113    
114        /**
115         *
116         * @return service with default configuration (see {@link #setConfiguration(WCSConfiguration)})
117         * @todo
118         */
119        public static WCService getService() {
120            return WCServiceFactory.getInstance( CONFIG );
121        }
122    
123    }