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 NNTPTransportGBean 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 String from; 47 private Boolean auth; 48 private String saslRealm; 49 private Boolean quitWait; 50 private String socketFactoryClass; 51 private Boolean socketFactoryFallback; 52 private Integer socketFactoryPort; 53 54 55 78 public NNTPTransportGBean(String objectName, Properties properties, String host, String user, 79 Integer port, 80 Integer connectionTimeout, 81 Integer timeout, 82 String from, 83 Boolean auth, 84 String saslRealm, 85 Boolean quitWait, 86 String socketFactoryClass, 87 Boolean socketFactoryFallback, 88 Integer socketFactoryPort) { 89 super(objectName, "nntp-post", properties, host, user); 90 91 setPort(port); 92 setConnectionTimeout(connectionTimeout); 93 setTimeout(timeout); 94 setFrom(from); 95 setAuth(auth); 96 setSaslRealm(saslRealm); 97 setQuitWait(quitWait); 98 setSocketFactoryClass(socketFactoryClass); 99 setSocketFactoryFallback(socketFactoryFallback); 100 setSocketFactoryPort(socketFactoryPort); 101 } 102 103 107 public Integer getPort() { 108 return port; 109 } 110 111 122 public void setPort(Integer port) { 123 this.port = port; 124 } 125 126 129 public Integer getConnectionTimeout() { 130 return connectionTimeout; 131 } 132 133 143 public void setConnectionTimeout(Integer connectionTimeout) { 144 this.connectionTimeout = connectionTimeout; 145 } 146 147 150 public Integer getTimeout() { 151 return timeout; 152 } 153 154 164 public void setTimeout(Integer timeout) { 165 this.timeout = timeout; 166 } 167 168 171 public String getFrom() { 172 return from; 173 } 174 175 186 public void setFrom(String from) { 187 this.from = from; 188 } 189 190 195 public Boolean getAuth() { 196 return auth; 197 } 198 199 209 public void setAuth(Boolean auth) { 210 this.auth = auth; 211 } 212 213 216 public String getSaslRealm() { 217 return saslRealm; 218 } 219 220 228 public void setSaslRealm(String saslRealm) { 229 this.saslRealm = saslRealm; 230 } 231 232 239 public Boolean getQuitWait() { 240 return quitWait; 241 } 242 243 255 public void setQuitWait(Boolean quitWait) { 256 this.quitWait = quitWait; 257 } 258 259 266 public String getSocketFactoryClass() { 267 return socketFactoryClass; 268 } 269 270 282 public void setSocketFactoryClass(String socketFactoryClass) { 283 this.socketFactoryClass = socketFactoryClass; 284 } 285 286 294 public Boolean getSocketFactoryFallback() { 295 return socketFactoryFallback; 296 } 297 298 312 public void setSocketFactoryFallback(Boolean socketFactoryFallback) { 313 this.socketFactoryFallback = socketFactoryFallback; 314 } 315 316 322 public Integer getSocketFactoryPort() { 323 return socketFactoryPort; 324 } 325 326 337 public void setSocketFactoryPort(Integer socketFactoryPort) { 338 this.socketFactoryPort = socketFactoryPort; 339 } 340 341 344 public void addOverrides(Properties props) { 345 super.addOverrides(props); 346 347 if (port != null) props.setProperty(NNTP_PORT, port.toString()); 348 if (connectionTimeout != null) props.setProperty(NNTP_CONNECTION_TIMEOUT, connectionTimeout.toString()); 349 if (timeout != null) props.setProperty(NNTP_TIMEOUT, timeout.toString()); 350 if (from != null) props.setProperty(NNTP_FROM, from); 351 if (auth != null) props.setProperty(NNTP_AUTH, auth.toString()); 352 if (saslRealm != null) props.setProperty(NNTP_REALM, saslRealm); 353 if (quitWait != null) props.setProperty(NNTP_QUITWAIT, quitWait.toString()); 354 if (socketFactoryClass != null) props.setProperty(NNTP_FACTORY_CLASS, socketFactoryClass); 355 if (socketFactoryFallback != null) props.setProperty(NNTP_FACTORY_FALLBACK, socketFactoryFallback.toString()); 356 if (socketFactoryPort != null) props.setProperty(NNTP_FACTORY_PORT, socketFactoryPort.toString()); 357 } 358 359 public void doStart() throws Exception { 360 log.debug("Started " + getObjectName()); 361 } 362 363 public void doStop() throws Exception { 364 log.debug("Stopped " + getObjectName()); 365 } 366 367 public void doFail() { 368 log.warn("Failed " + getObjectName()); 369 } 370 371 public static final GBeanInfo GBEAN_INFO; 372 373 static { 374 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(NNTPTransportGBean.class); 375 376 infoFactory.addAttribute(GBEAN_PORT, Integer .class, true); 377 infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT, Integer .class, true); 378 infoFactory.addAttribute(GBEAN_TIMEOUT, Integer .class, true); 379 infoFactory.addAttribute(GBEAN_AUTH, Boolean .class, true); 380 infoFactory.addAttribute(GBEAN_FROM, String .class, true); 381 infoFactory.addAttribute(GBEAN_REALM, String .class, true); 382 infoFactory.addAttribute(GBEAN_QUITWAIT, Boolean .class, true); 383 infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String .class, true); 384 infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean .class, true); 385 infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer .class, true); 386 387 infoFactory.addAttribute(GBEAN_OBJECTNAME, String .class, false); 388 infoFactory.addAttribute(GBEAN_PROTOCOL, String .class, true); 389 infoFactory.addAttribute(GBEAN_PROPERTIES, Properties .class, true); 390 infoFactory.addAttribute(GBEAN_HOST, String .class, true); 391 infoFactory.addAttribute(GBEAN_USER, String .class, true); 392 infoFactory.addOperation(GBEAN_ADD_OVERRIDES, new Class []{Properties .class}); 393 394 infoFactory.setConstructor(new String []{GBEAN_OBJECTNAME, GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, 395 GBEAN_PORT, 396 GBEAN_CONNECTION_TIMEOUT, 397 GBEAN_TIMEOUT, 398 GBEAN_FROM, 399 GBEAN_AUTH, 400 GBEAN_REALM, 401 GBEAN_QUITWAIT, 402 GBEAN_FACTORY_CLASS, 403 GBEAN_FACTORY_FALLBACK, 404 GBEAN_FACTORY_PORT}); 405 406 GBEAN_INFO = infoFactory.getBeanInfo(); 407 } 408 409 public static GBeanInfo getGBeanInfo() { 410 return GBEAN_INFO; 411 } 412 } 413 414 | Popular Tags |