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 28 40 public class POP3StoreGBean extends ProtocolGBean { 41 42 static public final String POP3_PORT = "mail.pop3.port"; 44 static public final String POP3_CONNECTION_TIMEOUT = "mail.pop3.connectiontimeout"; 45 static public final String POP3_TIMEOUT = "mail.pop3.timeout"; 46 static public final String POP3_FACTORY_CLASS = "mail.pop3.socketFactory.class"; 47 static public final String POP3_FACTORY_FALLBACK = "mail.pop3.socketFactory.fallback"; 48 static public final String POP3_FACTORY_PORT = "mail.pop3.socketFactory.port"; 49 static public final String POP3_LOCALHOST = "mail.pop3.localhost"; 50 static public final String POP3_LOCALADDRESS = "mail.pop3.localaddress"; 51 static public final String POP3_LOCALPORT = "mail.pop3.localport"; 52 static public final String POP3_RESET = "mail.pop3.resetbeforequit"; 53 static public final String POP3_MESSAGE_CLASS = "mail.pop3.message.class"; 54 static public final String POP3_APOP = "mail.pop3.apop.enable"; 55 56 static public final String GBEAN_RESET = "rsetBeforeQuit"; 57 static public final String GBEAN_APOP = "apopEnable"; 58 static public final String GBEAN_MESSAGE_CLASS = "messageClass"; 59 60 private final Log log = LogFactory.getLog(POP3StoreGBean.class); 61 62 private Integer port; 63 private Integer connectionTimeout; 64 private Integer timeout; 65 private Boolean rsetBeforeQuit; 66 private String messageClass; 67 private String localaddress; 68 private Integer localport; 69 private Boolean apopEnable; 70 private String socketFactoryClass; 71 private Boolean socketFactoryFallback; 72 private Integer socketFactoryPort; 73 74 75 101 public POP3StoreGBean(String objectName, Properties properties, String host, String user, 102 Integer port, 103 Integer connectionTimeout, 104 Integer timeout, 105 Boolean rsetBeforeQuit, 106 String messageClass, 107 String localaddress, 108 Integer localport, 109 Boolean apopEnable, 110 String socketFactoryClass, 111 Boolean socketFactoryFallback, 112 Integer socketFactoryPort) { 113 super(objectName, "pop3", properties, host, user); 114 115 setPort(port); 116 setConnectionTimeout(connectionTimeout); 117 setTimeout(timeout); 118 setRsetBeforeQuit(rsetBeforeQuit); 119 setMessageClass(messageClass); 120 setLocaladdress(localaddress); 121 setLocalport(localport); 122 setApopEnable(apopEnable); 123 setSocketFactoryClass(socketFactoryClass); 124 setSocketFactoryFallback(socketFactoryFallback); 125 setSocketFactoryPort(socketFactoryPort); 126 } 127 128 134 public Integer getPort() { 135 return port; 136 } 137 138 150 public void setPort(Integer port) { 151 this.port = port; 152 } 153 154 157 public Integer getConnectionTimeout() { 158 return connectionTimeout; 159 } 160 161 171 public void setConnectionTimeout(Integer connectionTimeout) { 172 this.connectionTimeout = connectionTimeout; 173 } 174 175 178 public Integer getTimeout() { 179 return timeout; 180 } 181 182 192 public void setTimeout(Integer timeout) { 193 this.timeout = timeout; 194 } 195 196 206 public Boolean getRsetBeforeQuit() { 207 return rsetBeforeQuit; 208 } 209 210 225 public void setRsetBeforeQuit(Boolean rsetBeforeQuit) { 226 this.rsetBeforeQuit = rsetBeforeQuit; 227 } 228 229 237 public String getMessageClass() { 238 return messageClass; 239 } 240 241 254 public void setMessageClass(String messageClass) { 255 this.messageClass = messageClass; 256 } 257 258 261 public String getLocaladdress() { 262 return localaddress; 263 } 264 265 278 public void setLocaladdress(String localaddress) { 279 this.localaddress = localaddress; 280 } 281 282 285 public Integer getLocalport() { 286 return localport; 287 } 288 289 300 public void setLocalport(Integer localport) { 301 this.localport = localport; 302 } 303 304 312 public Boolean isApopEnable() { 313 return apopEnable; 314 } 315 316 327 public void setApopEnable(Boolean apopEnable) { 328 this.apopEnable = apopEnable; 329 } 330 331 338 public String getSocketFactoryClass() { 339 return socketFactoryClass; 340 } 341 342 354 public void setSocketFactoryClass(String socketFactoryClass) { 355 this.socketFactoryClass = socketFactoryClass; 356 } 357 358 366 public Boolean isSocketFactoryFallback() { 367 return socketFactoryFallback; 368 } 369 370 384 public void setSocketFactoryFallback(Boolean socketFactoryFallback) { 385 this.socketFactoryFallback = socketFactoryFallback; 386 } 387 388 394 public Integer getSocketFactoryPort() { 395 return socketFactoryPort; 396 } 397 398 409 public void setSocketFactoryPort(Integer socketFactoryPort) { 410 this.socketFactoryPort = socketFactoryPort; 411 } 412 413 416 public void addOverrides(Properties props) { 417 super.addOverrides(props); 418 419 if (port != null) props.setProperty(POP3_PORT, port.toString()); 420 if (connectionTimeout != null) props.setProperty(POP3_CONNECTION_TIMEOUT, connectionTimeout.toString()); 421 if (timeout != null) props.setProperty(POP3_TIMEOUT, timeout.toString()); 422 if (rsetBeforeQuit != null) props.setProperty(POP3_RESET, rsetBeforeQuit.toString()); 423 if (messageClass != null) props.setProperty(POP3_MESSAGE_CLASS, messageClass); 424 if (localaddress != null) props.setProperty(POP3_LOCALADDRESS, localaddress); 425 if (localport != null) props.setProperty(POP3_LOCALPORT, localport.toString()); 426 if (apopEnable != null) props.setProperty(POP3_APOP, apopEnable.toString()); 427 if (socketFactoryClass != null) props.setProperty(POP3_FACTORY_CLASS, socketFactoryClass); 428 if (socketFactoryFallback != null) props.setProperty(POP3_FACTORY_FALLBACK, socketFactoryFallback.toString()); 429 if (socketFactoryPort != null) props.setProperty(POP3_FACTORY_PORT, socketFactoryPort.toString()); 430 } 431 432 public void doStart() throws Exception { 433 log.debug("Started " + getObjectName()); 434 } 435 436 public void doStop() throws Exception { 437 log.debug("Stopped " + getObjectName()); 438 } 439 440 public void doFail() { 441 log.warn("Failed " + getObjectName()); 442 } 443 444 public static final GBeanInfo GBEAN_INFO; 445 446 static { 447 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(POP3StoreGBean.class, ProtocolGBean.GBEAN_INFO); 448 449 infoFactory.addAttribute(GBEAN_PORT, Integer .class, true); 450 infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT, Integer .class, true); 451 infoFactory.addAttribute(GBEAN_TIMEOUT, Integer .class, true); 452 infoFactory.addAttribute(GBEAN_RESET, Boolean .class, true); 453 infoFactory.addAttribute(GBEAN_MESSAGE_CLASS, String .class, true); 454 infoFactory.addAttribute(GBEAN_LOCALADDRESS, String .class, true); 455 infoFactory.addAttribute(GBEAN_LOCALPORT, Integer .class, true); 456 infoFactory.addAttribute(GBEAN_APOP, Boolean .class, true); 457 infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String .class, true); 458 infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean .class, true); 459 infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer .class, true); 460 461 infoFactory.addAttribute(GBEAN_OBJECTNAME, String .class, false); 462 infoFactory.addAttribute(GBEAN_PROTOCOL, String .class, true); 463 infoFactory.addAttribute(GBEAN_PROPERTIES, Properties .class, true); 464 infoFactory.addAttribute(GBEAN_HOST, String .class, true); 465 infoFactory.addAttribute(GBEAN_USER, String .class, true); 466 infoFactory.addOperation(GBEAN_ADD_OVERRIDES, new Class []{Properties .class}); 467 468 infoFactory.setConstructor(new String []{GBEAN_OBJECTNAME, GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, 469 GBEAN_PORT, 470 GBEAN_CONNECTION_TIMEOUT, 471 GBEAN_TIMEOUT, 472 GBEAN_RESET, 473 GBEAN_MESSAGE_CLASS, 474 GBEAN_LOCALADDRESS, 475 GBEAN_LOCALPORT, 476 GBEAN_APOP, 477 GBEAN_FACTORY_CLASS, 478 GBEAN_FACTORY_FALLBACK, 479 GBEAN_FACTORY_PORT}); 480 481 GBEAN_INFO = infoFactory.getBeanInfo(); 482 } 483 484 public static GBeanInfo getGBeanInfo() { 485 return GBEAN_INFO; 486 } 487 } 488 | Popular Tags |