001/* 002 * GWTEventService 003 * Copyright (c) 2011 and beyond, strawbill UG (haftungsbeschr?nkt) 004 * 005 * This is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Lesser General Public License as 007 * published by the Free Software Foundation; either version 3 of 008 * the License, or (at your option) any later version. 009 * Other licensing for GWTEventService may also be possible on request. 010 * Please view the license.txt of the project for more information. 011 * 012 * This software is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this software; if not, write to the Free 019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 021 */ 022package de.novanic.eventservice.config.loader; 023 024import de.novanic.eventservice.client.connection.strategy.connector.DefaultClientConnector; 025import de.novanic.eventservice.config.EventServiceConfiguration; 026import de.novanic.eventservice.config.RemoteEventServiceConfiguration; 027import de.novanic.eventservice.service.connection.id.SessionConnectionIdGenerator; 028import de.novanic.eventservice.service.connection.strategy.connector.longpolling.LongPollingServerConnector; 029 030/** 031 * DefaultConfigurationLoader is used by {@link de.novanic.eventservice.config.EventServiceConfigurationFactory} if no 032 * configuration could be found. 033 * <br>The default values: 034 * <br> - Min waiting time: 0 035 * <br> - Max waiting time: 20000 036 * <br> - Timeout time: 90000 037 * 038 * A description for the values can be found in {@link de.novanic.eventservice.config.EventServiceConfiguration} or in 039 * the manual. 040 * 041 * @author sstrohschein 042 * <br>Date: 23.10.2008 043 * <br>Time: 14:42:26 044 */ 045public class DefaultConfigurationLoader implements ConfigurationLoader 046{ 047 private static final String DEFAULT_CONFIG_DESCRIPTION = "Default Configuration"; 048 private static final int DEFAULT_MIN_WAITING_TIME = 0; 049 private static final int DEFAULT_MAX_WAITING_TIME = 20000; 050 private static final int DEFAULT_TIME_OUT = 90000; 051 private static final int DEFAULT_RECONNECT_ATTEMPTS = 0; 052 private static final String DEFAULT_CONNECTION_ID_GENERATOR_CLASS_NAME = SessionConnectionIdGenerator.class.getName(); 053 private static final String DEFAULT_CONNECTION_STRATEGY_CLIENT_CONNECTOR = DefaultClientConnector.class.getName(); 054 private static final String DEFAULT_CONNECTION_STRATEGY_SERVER_CONNECTOR = LongPollingServerConnector.class.getName(); 055 private static final String DEFAULT_CONNECTION_STRATEGY_ENCODING = "utf-8"; 056 private static final int DEFAULT_MAX_EVENTS = 1000; 057 058 /** 059 * Checks if the configuration is available and can be loaded. If no configuration is available, the load method 060 * {@link ConfigurationLoader#load()} shouldn't called. In the case of {@link DefaultConfigurationLoader} it returns 061 * always true, because the default configuration is available in any case. 062 * @return true when available, otherwise false. In the case of {@link DefaultConfigurationLoader} it returns 063 * always true, because the default configuration is available in any case. 064 */ 065 public boolean isAvailable() { 066 return true; 067 } 068 069 /** 070 * Loads the configuration with the loader. 071 * @return the loaded configuration ({@link de.novanic.eventservice.config.EventServiceConfiguration}) 072 */ 073 public EventServiceConfiguration load() { 074 return new RemoteEventServiceConfiguration(DEFAULT_CONFIG_DESCRIPTION, DEFAULT_MIN_WAITING_TIME, DEFAULT_MAX_WAITING_TIME, DEFAULT_TIME_OUT, 075 DEFAULT_RECONNECT_ATTEMPTS, 076 DEFAULT_CONNECTION_ID_GENERATOR_CLASS_NAME, DEFAULT_CONNECTION_STRATEGY_CLIENT_CONNECTOR, DEFAULT_CONNECTION_STRATEGY_SERVER_CONNECTOR, DEFAULT_CONNECTION_STRATEGY_ENCODING, 077 DEFAULT_MAX_EVENTS); 078 } 079 080 public boolean equals(Object anObject) { 081 return (anObject instanceof DefaultConfigurationLoader); 082 } 083}