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.client.config; 023 024/** 025 * An {@link de.novanic.eventservice.client.config.EventServiceConfigurationTransferable} holds the configuration options for 026 * {@link de.novanic.eventservice.client.event.service.EventService} which could be usable by the client side. 027 * The whole covered configuration for {@link de.novanic.eventservice.client.event.service.EventService} is only available 028 * to the server side and isn't transferable / serializable. 029 * 030 * @author sstrohschein 031 * <br>Date: 29.03.2010 032 * <br>Time: 22:11:06 033 */ 034public class RemoteEventServiceConfigurationTransferable implements EventServiceConfigurationTransferable 035{ 036 private Integer myMinWaitingTime; 037 private Integer myMaxWaitingTime; 038 private Integer myTimeoutTime; 039 private Integer myReconnectAttemptCount; 040 private String myConnectionId; 041 private String myConnectionStrategyClientConnector; 042 043 /** 044 * This constructor is only required for serialization. 045 */ 046 public RemoteEventServiceConfigurationTransferable() {} 047 048 /** 049 * Creates a new RemoteEventServiceConfigurationTransferable. 050 * @param aMinWaitingTime min waiting time before listen returns (in milliseconds) 051 * @param aMaxWaitingTime max waiting time before listen returns, when no events recognized (in milliseconds) 052 * @param aTimeoutTime timeout time for a listen cycle (in milliseconds) 053 * @param aReconnectAttemptCount number of reconnect attempts to execute 054 * @param aConnectionId unique id to identify the client 055 * @param aConnectionStrategyClientConnector class name of the configured connection strategy (client side part) 056 */ 057 public RemoteEventServiceConfigurationTransferable(int aMinWaitingTime, int aMaxWaitingTime, int aTimeoutTime, int aReconnectAttemptCount, 058 String aConnectionId, String aConnectionStrategyClientConnector) { 059 myMinWaitingTime = aMinWaitingTime; 060 myMaxWaitingTime = aMaxWaitingTime; 061 myTimeoutTime = aTimeoutTime; 062 myReconnectAttemptCount = aReconnectAttemptCount; 063 myConnectionId = aConnectionId; 064 myConnectionStrategyClientConnector = aConnectionStrategyClientConnector; 065 } 066 067 /** 068 * Returns the min waiting time. Listening should hold at least for min waiting time. 069 * @return min waiting time 070 */ 071 public Integer getMinWaitingTime() { 072 return myMinWaitingTime; 073 } 074 075 /** 076 * Returns the max waiting time. Listening shouldn't hold longer than max waiting time. 077 * @return max waiting time 078 */ 079 public Integer getMaxWaitingTime() { 080 return myMaxWaitingTime; 081 } 082 083 /** 084 * Returns the timeout time. The timeout time is the max time for a listen cycle. If the timeout time is exceeded, 085 * the client will be deregistered. 086 * @return timeout time 087 */ 088 public Integer getTimeoutTime() { 089 return myTimeoutTime; 090 } 091 092 /** 093 * Returns the number of reconnect attempts to execute. 094 * @return number of reconnect attempts 095 */ 096 public Integer getReconnectAttemptCount() { 097 return myReconnectAttemptCount; 098 } 099 100 /** 101 * Returns the connection / client id. 102 * @return connection / client id 103 */ 104 public String getConnectionId() { 105 return myConnectionId; 106 } 107 108 /** 109 * Returns the class name of the configured connection strategy (client side part). 110 * @return connection strategy (client side part) 111 */ 112 public String getConnectionStrategyClientConnector() { 113 return myConnectionStrategyClientConnector; 114 } 115 116 public boolean equals(Object anObject) { 117 if(this == anObject) { 118 return true; 119 } 120 if(anObject == null || getClass() != anObject.getClass()) { 121 return false; 122 } 123 124 RemoteEventServiceConfigurationTransferable theOther = (RemoteEventServiceConfigurationTransferable) anObject; 125 126 if(myConnectionId != null ? !myConnectionId.equals(theOther.myConnectionId) : theOther.myConnectionId != null) { 127 return false; 128 } 129 if(myMaxWaitingTime != null ? !myMaxWaitingTime.equals(theOther.myMaxWaitingTime) : theOther.myMaxWaitingTime != null) { 130 return false; 131 } 132 if(myMinWaitingTime != null ? !myMinWaitingTime.equals(theOther.myMinWaitingTime) : theOther.myMinWaitingTime != null) { 133 return false; 134 } 135 if(myReconnectAttemptCount != null ? !myReconnectAttemptCount.equals(theOther.myReconnectAttemptCount) : theOther.myReconnectAttemptCount != null) { 136 return false; 137 } 138 if(myTimeoutTime != null ? !myTimeoutTime.equals(theOther.myTimeoutTime) : theOther.myTimeoutTime != null) { 139 return false; 140 } 141 return true; 142 } 143 144 public int hashCode() { 145 int theResult = myMinWaitingTime != null ? myMinWaitingTime.hashCode() : 0; 146 theResult = 31 * theResult + (myMaxWaitingTime != null ? myMaxWaitingTime.hashCode() : 0); 147 theResult = 31 * theResult + (myTimeoutTime != null ? myTimeoutTime.hashCode() : 0); 148 theResult = 31 * theResult + (myReconnectAttemptCount != null ? myReconnectAttemptCount.hashCode() : 0); 149 theResult = 31 * theResult + (myConnectionId != null ? myConnectionId.hashCode() : 0); 150 return theResult; 151 } 152}