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-2008 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.wmps;
047
048 import java.net.URL;
049
050 import org.deegree.framework.log.ILogger;
051 import org.deegree.framework.log.LoggerFactory;
052 import org.deegree.ogcwebservices.wcs.configuration.InvalidConfigurationException;
053 import org.deegree.ogcwebservices.wmps.configuration.WMPSConfiguration;
054 import org.deegree.ogcwebservices.wmps.configuration.WMPSConfigurationDocument;
055
056 /**
057 * Service Factory class handles the WMPService Instance.
058 *
059 * @author <a href="mailto:deshmukh@lat-lon.de">Anup Deshmukh</a>
060 * @version 2.0
061 */
062 public final class WMPServiceFactory {
063
064 private static final ILogger LOG = LoggerFactory.getLogger( WMPServiceFactory.class );
065
066 private static WMPSConfiguration CONFIG;
067
068 /**
069 * Returns a WMPService instance
070 *
071 * @return WMPService
072 */
073 public static WMPService getService() {
074 return WMPServiceFactory.getInstance( CONFIG );
075 }
076
077 /**
078 * Returns a WMPService instance
079 *
080 * @param config
081 * @return WMPService
082 */
083 public static WMPService getInstance( WMPSConfiguration config ) {
084 return new WMPService( config );
085 }
086
087 /**
088 * Returns true/false depending on the initialized state of the instance.
089 *
090 * @return boolean
091 */
092 public static boolean isInitialized() {
093 return CONFIG != null;
094 }
095
096 /**
097 * Sets the WMPSConfiguration
098 *
099 * @param wmpsConfiguration
100 */
101 public static void setConfiguration( WMPSConfiguration wmpsConfiguration ) {
102 CONFIG = wmpsConfiguration;
103 /**
104 * if service instance are already created destroy all instances create new service
105 * instances and put in pool
106 */
107 LOG.logInfo( CONFIG.getServiceIdentification().getTitle() + " (" + CONFIG.getVersion()
108 + ") service pool initialized." );
109 }
110
111 /**
112 * Sets the service configuration
113 *
114 * @param serviceConfigurationUrl
115 * @throws InvalidConfigurationException
116 */
117 public static void setConfiguration( URL serviceConfigurationUrl )
118 throws InvalidConfigurationException {
119
120 try {
121 WMPSConfigurationDocument doc = new WMPSConfigurationDocument();
122 doc.load( serviceConfigurationUrl );
123 WMPSConfiguration conf = doc.parseConfiguration();
124 WMPServiceFactory.setConfiguration( conf );
125 } catch ( Exception e ) {
126 e.printStackTrace();
127 throw new InvalidConfigurationException( "WPSServiceFactory", e.getMessage() );
128 }
129 }
130 }