1 17 package org.apache.geronimo.mail; 18 19 import java.util.Properties ; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 24 import org.apache.geronimo.gbean.GBeanInfo; 25 import org.apache.geronimo.gbean.GBeanInfoBuilder; 26 27 39 public class NNTPStoreGBean extends ProtocolGBean implements NNTPGBeanConstants { 40 41 private final Log log = LogFactory.getLog(NNTPTransportGBean.class); 42 43 private Integer port; 44 private Integer connectionTimeout; 45 private Integer timeout; 46 private Boolean auth; 47 private String saslRealm; 48 private Boolean quitWait; 49 private String socketFactoryClass; 50 private Boolean socketFactoryFallback; 51 private Integer socketFactoryPort; 52 53 54 76 public NNTPStoreGBean(String objectName, Properties properties, String host, String user, 77 Integer port, 78 Integer connectionTimeout, 79 Integer timeout, 80 Boolean auth, 81 String saslRealm, 82 Boolean quitWait, 83 String socketFactoryClass, 84 Boolean socketFactoryFallback, 85 Integer socketFactoryPort) { 86 super(objectName, "nntp", properties, host, user); 87 88 setPort(port); 89 setConnectionTimeout(connectionTimeout); 90 setTimeout(timeout); 91 setAuth(auth); 92 setSaslRealm(saslRealm); 93 setQuitWait(quitWait); 94 setSocketFactoryClass(socketFactoryClass); 95 setSocketFactoryFallback(socketFactoryFallback); 96 setSocketFactoryPort(socketFactoryPort); 97 } 98 99 103 public Integer getPort() { 104 return port; 105 } 106 107 118 public void setPort(Integer port) { 119 this.port = port; 120 } 121 122 125 public Integer getConnectionTimeout() { 126 return connectionTimeout; 127 } 128 129 139 public void setConnectionTimeout(Integer connectionTimeout) { 140 this.connectionTimeout = connectionTimeout; 141 } 142 143 146 public Integer getTimeout() { 147 return timeout; 148 } 149 150 160 public void setTimeout(Integer timeout) { 161 this.timeout = timeout; 162 } 163 164 165 170 public Boolean getAuth() { 171 return auth; 172 } 173 174 184 public void setAuth(Boolean auth) { 185 this.auth = auth; 186 } 187 188 191 public String getSaslRealm() { 192 return saslRealm; 193 } 194 195 203 public void setSaslRealm(String saslRealm) { 204 this.saslRealm = saslRealm; 205 } 206 207 214 public Boolean getQuitWait() { 215 return quitWait; 216 } 217 218 230 public void setQuitWait(Boolean quitWait) { 231 this.quitWait = quitWait; 232 } 233 234 241 public String getSocketFactoryClass() { 242 return socketFactoryClass; 243 } 244 245 257 public void setSocketFactoryClass(String socketFactoryClass) { 258 this.socketFactoryClass = socketFactoryClass; 259 } 260 261 269 public Boolean getSocketFactoryFallback() { 270 return socketFactoryFallback; 271 } 272 273 287 public void setSocketFactoryFallback(Boolean socketFactoryFallback) { 288 this.socketFactoryFallback = socketFactoryFallback; 289 } 290 291 297 public Integer getSocketFactoryPort() { 298 return socketFactoryPort; 299 } 300 301 312 public void setSocketFactoryPort(Integer socketFactoryPort) { 313 this.socketFactoryPort = socketFactoryPort; 314 } 315 316 319 public void addOverrides(Properties props) { 320 super.addOverrides(props); 321 322 if (port != null) props.setProperty(NNTPS_PORT, port.toString()); 323 if (connectionTimeout != null) props.setProperty(NNTPS_CONNECTION_TIMEOUT, connectionTimeout.toString()); 324 if (timeout != null) props.setProperty(NNTPS_TIMEOUT, timeout.toString()); 325 if (auth != null) props.setProperty(NNTPS_AUTH, auth.toString()); 326 if (saslRealm != null) props.setProperty(NNTPS_REALM, saslRealm); 327 if (quitWait != null) props.setProperty(NNTPS_QUITWAIT, quitWait.toString()); 328 if (socketFactoryClass != null) props.setProperty(NNTPS_FACTORY_CLASS, socketFactoryClass); 329 if (socketFactoryFallback != null) props.setProperty(NNTPS_FACTORY_FALLBACK, socketFactoryFallback.toString()); 330 if (socketFactoryPort != null) props.setProperty(NNTPS_FACTORY_PORT, socketFactoryPort.toString()); 331 } 332 333 public void doStart() throws Exception { 334 log.debug("Started " + getObjectName()); 335 } 336 337 public void doStop() throws Exception { 338 log.debug("Stopped " + getObjectName()); 339 } 340 341 public void doFail() { 342 log.warn("Failed " + getObjectName()); 343 } 344 345 public static final GBeanInfo GBEAN_INFO; 346 347 static { 348 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(NNTPStoreGBean.class); 349 350 infoFactory.addAttribute(GBEAN_PORT, Integer .class, true); 351 infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT, Integer .class, true); 352 infoFactory.addAttribute(GBEAN_TIMEOUT, Integer .class, true); 353 infoFactory.addAttribute(GBEAN_AUTH, Boolean .class, true); 354 infoFactory.addAttribute(GBEAN_REALM, String .class, true); 355 infoFactory.addAttribute(GBEAN_QUITWAIT, Boolean .class, true); 356 infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String .class, true); 357 infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean .class, true); 358 infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer .class, true); 359 360 infoFactory.addAttribute(GBEAN_OBJECTNAME, String .class, false); 361 infoFactory.addAttribute(GBEAN_PROTOCOL, String .class, true); 362 infoFactory.addAttribute(GBEAN_PROPERTIES, Properties .class, true); 363 infoFactory.addAttribute(GBEAN_HOST, String .class, true); 364 infoFactory.addAttribute(GBEAN_USER, String .class, true); 365 infoFactory.addOperation(GBEAN_ADD_OVERRIDES, new Class []{Properties .class}); 366 367 infoFactory.setConstructor(new String []{GBEAN_OBJECTNAME, GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, 368 GBEAN_PORT, 369 GBEAN_CONNECTION_TIMEOUT, 370 GBEAN_TIMEOUT, 371 GBEAN_AUTH, 372 GBEAN_REALM, 373 GBEAN_QUITWAIT, 374 GBEAN_FACTORY_CLASS, 375 GBEAN_FACTORY_FALLBACK, 376 GBEAN_FACTORY_PORT}); 377 378 GBEAN_INFO = infoFactory.getBeanInfo(); 379 } 380 381 public static GBeanInfo getGBeanInfo() { 382 return GBEAN_INFO; 383 } 384 } 385 386 387 | Popular Tags |