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