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 IMAPStoreGBean extends ProtocolGBean { 40 41 static public final String IMAP_PORT = "mail.imap.port"; 43 static public final String IMAP_CONNECTION_TIMEOUT = "mail.imap.connectiontimeout"; 44 static public final String IMAP_TIMEOUT = "mail.imap.timeout"; 45 static public final String IMAP_FACTORY_CLASS = "mail.imap.socketFactory.class"; 46 static public final String IMAP_FACTORY_FALLBACK = "mail.imap.socketFactory.fallback"; 47 static public final String IMAP_FACTORY_PORT = "mail.imap.socketFactory.port"; 48 static public final String IMAP_LOCALHOST = "mail.imap.localhost"; 49 static public final String IMAP_LOCALADDRESS = "mail.imap.localaddress"; 50 static public final String IMAP_LOCALPORT = "mail.imap.localport"; 51 static public final String IMAP_PARTIAL_FETCH = "mail.imap.partialfetch"; 52 static public final String IMAP_FETCH_SIZE = "mail.imap.fetchsize"; 53 static public final String IMAP_STATUS_TIMEOUT = "mail.imap.statuscachetimeout"; 54 static public final String IMAP_APPEND_SIZE = "mail.imap.appendbuffersize"; 55 static public final String IMAP_POOL_SIZE = "mail.imap.connectionpoolsize"; 56 static public final String IMAP_POOL_TIMEOUT = "mail.imap.connectionpooltimeout"; 57 static public final String IMAP_SEPARATE_STORE_CONNECTION = "mail.imap.separatestoreconnection"; 58 static public final String IMAP_READONLY_SELECT = "mail.imap.alloreadonlyselect"; 59 static public final String IMAP_LOGIN_DISABLE = "mail.imap.auth.login.disable"; 60 static public final String IMAP_PLAIN_DISABLE = "mail.imap.auth.plain.disable"; 61 static public final String IMAP_STARTTLS_ENABLE = "mail.imap.auth.starttls.enable"; 62 static public final String IMAP_SASL_ENABLE = "mail.imap.sasl.enable"; 63 static public final String IMAP_SASL_MECHANISMS = "mail.imap.sasl.mechanisms"; 64 static public final String IMAP_SASL_AUTHORIZATIONID = "mail.imap.sasl.authorizationid"; 65 66 67 static public final String GBEAN_PARTIAL_FETCH = "partialFetch"; 69 static public final String GBEAN_FETCH_SIZE = "fetchSize"; 70 static public final String GBEAN_STATUS_TIMEOUT = "statusCacheTimeout"; 71 static public final String GBEAN_APPEND_SIZE = "appendBufferSize"; 72 static public final String GBEAN_POOL_SIZE = "connectionPoolSize"; 73 static public final String GBEAN_POOL_TIMEOUT = "connectionPoolTimeout"; 74 static public final String GBEAN_SEPARATE_STORE_CONNECTION = "separateStoreConnection"; 75 static public final String GBEAN_READONLY_SELECT = "allowReadOnlySelect"; 76 static public final String GBEAN_LOGIN_DISABLE = "authLoginDisable"; 77 static public final String GBEAN_PLAIN_DISABLE = "authPlainDisable"; 78 static public final String GBEAN_STARTTLS_ENABLE = "startTLSEnable"; 79 static public final String GBEAN_SASL_ENABLE = "saslEnable"; 80 static public final String GBEAN_SASL_MECHANISMS = "saslMechanisms"; 81 static public final String GBEAN_SASL_AUTHORIZATIONID = "saslAuthorizationId"; 82 83 private final Log log = LogFactory.getLog(IMAPStoreGBean.class); 84 85 private Integer port; 86 private Boolean partialFetch; 87 private Integer fetchSize; 88 private Integer connectionTimeout; 89 private Integer timeout; 90 private Integer statusCacheTimeout; 91 private Integer appendBufferSize; 92 private Integer connectionPoolSize; 93 private Integer connectionPoolTimeout; 94 private Boolean separateStoreConnection; 95 private Boolean allowReadOnlySelect; 96 private Boolean authLoginDisable; 97 private Boolean authPlainDisable; 98 private Boolean startTLSEnable; 99 private String localaddress; 100 private Integer localport; 101 private Boolean saslEnable; 102 private String saslMechanisms; 103 private String saslAuthorizationId; 104 private String socketFactoryClass; 105 private Boolean socketFactoryFallback; 106 private Integer socketFactoryPort; 107 108 109 144 public IMAPStoreGBean(String objectName, Properties properties, String host, String user, 145 Integer port, 146 Boolean partialFetch, 147 Integer fetchSize, 148 Integer connectionTimeout, 149 Integer timeout, 150 Integer statusCacheTimeout, 151 Integer appendBufferSize, 152 Integer connectionPoolSize, 153 Integer connectionPoolTimeout, 154 Boolean separateStoreConnection, 155 Boolean allowReadOnlySelect, 156 Boolean authLoginDisable, 157 Boolean authPlainDisable, 158 Boolean startTLSEnable, 159 String localaddress, 160 Integer localport, 161 Boolean saslEnable, 162 String saslMechanisms, 163 String saslAuthorizationId, 164 String socketFactoryClass, 165 Boolean socketFactoryFallback, 166 Integer socketFactoryPort) { 167 super(objectName, "imap", properties, host, user); 168 169 setPort(port); 170 setPartialFetch(partialFetch); 171 setFetchSize(fetchSize); 172 setConnectionTimeout(connectionTimeout); 173 setTimeout(timeout); 174 setStatusCacheTimeout(statusCacheTimeout); 175 setAppendBufferSize(appendBufferSize); 176 setConnectionPoolSize(connectionPoolSize); 177 setConnectionPoolTimeout(connectionPoolTimeout); 178 setSeparateStoreConnection(separateStoreConnection); 179 setAllowReadOnlySelect(allowReadOnlySelect); 180 setAuthLoginDisable(authLoginDisable); 181 setAuthPlainDisable(authPlainDisable); 182 setStartTLSEnable(startTLSEnable); 183 setLocaladdress(localaddress); 184 setLocalport(localport); 185 setSaslEnable(saslEnable); 186 setSaslMechanisms(saslMechanisms); 187 setSaslAuthorizationId(saslAuthorizationId); 188 setSocketFactoryClass(socketFactoryClass); 189 setSocketFactoryFallback(socketFactoryFallback); 190 setSocketFactoryPort(socketFactoryPort); 191 } 192 193 197 public Integer getPort() { 198 return port; 199 } 200 201 213 public void setPort(Integer port) { 214 this.port = port; 215 } 216 217 223 public Boolean getPartialFetch() { 224 return partialFetch; 225 } 226 227 238 public void setPartialFetch(Boolean partialFetch) { 239 this.partialFetch = partialFetch; 240 } 241 242 247 public Integer getFetchSize() { 248 return fetchSize; 249 } 250 251 261 public void setFetchSize(Integer fetchSize) { 262 this.fetchSize = fetchSize; 263 } 264 265 268 public Integer getConnectionTimeout() { 269 return connectionTimeout; 270 } 271 272 282 public void setConnectionTimeout(Integer connectionTimeout) { 283 this.connectionTimeout = connectionTimeout; 284 } 285 286 289 public Integer getTimeout() { 290 return timeout; 291 } 292 293 303 public void setTimeout(Integer timeout) { 304 this.timeout = timeout; 305 } 306 307 313 public Integer getStatusCacheTimeout() { 314 return statusCacheTimeout; 315 } 316 317 328 public void setStatusCacheTimeout(Integer statusCacheTimeout) { 329 this.statusCacheTimeout = statusCacheTimeout; 330 } 331 332 344 public Integer getAppendBufferSize() { 345 return appendBufferSize; 346 } 347 348 366 public void setAppendBufferSize(Integer appendBufferSize) { 367 this.appendBufferSize = appendBufferSize; 368 } 369 370 375 public Integer getConnectionPoolSize() { 376 return connectionPoolSize; 377 } 378 379 389 public void setConnectionPoolSize(Integer connectionPoolSize) { 390 this.connectionPoolSize = connectionPoolSize; 391 } 392 393 398 public Integer getConnectionPoolTimeout() { 399 return connectionPoolTimeout; 400 } 401 402 412 public void setConnectionPoolTimeout(Integer connectionPoolTimeout) { 413 this.connectionPoolTimeout = connectionPoolTimeout; 414 } 415 416 423 public Boolean getSeparateStoreConnection() { 424 return separateStoreConnection; 425 } 426 427 440 public void setSeparateStoreConnection(Boolean separateStoreConnection) { 441 this.separateStoreConnection = separateStoreConnection; 442 } 443 444 456 public Boolean getAllowReadOnlySelect() { 457 return allowReadOnlySelect; 458 } 459 460 477 public void setAllowReadOnlySelect(Boolean allowReadOnlySelect) { 478 this.allowReadOnlySelect = allowReadOnlySelect; 479 } 480 481 487 public Boolean getAuthLoginDisable() { 488 return authLoginDisable; 489 } 490 491 503 public void setAuthLoginDisable(Boolean authLoginDisable) { 504 this.authLoginDisable = authLoginDisable; 505 } 506 507 512 public Boolean getAuthPlainDisable() { 513 return authPlainDisable; 514 } 515 516 526 public void setAuthPlainDisable(Boolean authPlainDisable) { 527 this.authPlainDisable = authPlainDisable; 528 } 529 530 541 public Boolean getStartTLSEnable() { 542 return startTLSEnable; 543 } 544 545 563 public void setStartTLSEnable(Boolean startTLSEnable) { 564 this.startTLSEnable = startTLSEnable; 565 } 566 567 570 public String getLocaladdress() { 571 return localaddress; 572 } 573 574 587 public void setLocaladdress(String localaddress) { 588 this.localaddress = localaddress; 589 } 590 591 594 public Integer getLocalport() { 595 return localport; 596 } 597 598 609 public void setLocalport(Integer localport) { 610 this.localport = localport; 611 } 612 613 619 public Boolean getSaslEnable() { 620 return saslEnable; 621 } 622 623 635 public void setSaslEnable(Boolean saslEnable) { 636 this.saslEnable = saslEnable; 637 } 638 639 642 public String getSaslMechanisms() { 643 return saslMechanisms; 644 } 645 646 654 public void setSaslMechanisms(String saslMechanisms) { 655 this.saslMechanisms = saslMechanisms; 656 } 657 658 663 public String getSaslAuthorizationId() { 664 return saslAuthorizationId; 665 } 666 667 677 public void setSaslAuthorizationId(String saslAuthorizationId) { 678 this.saslAuthorizationId = saslAuthorizationId; 679 } 680 681 688 public String getSocketFactoryClass() { 689 return socketFactoryClass; 690 } 691 692 704 public void setSocketFactoryClass(String socketFactoryClass) { 705 this.socketFactoryClass = socketFactoryClass; 706 } 707 708 716 public Boolean getSocketFactoryFallback() { 717 return socketFactoryFallback; 718 } 719 720 734 public void setSocketFactoryFallback(Boolean socketFactoryFallback) { 735 this.socketFactoryFallback = socketFactoryFallback; 736 } 737 738 744 public Integer getSocketFactoryPort() { 745 return socketFactoryPort; 746 } 747 748 759 public void setSocketFactoryPort(Integer socketFactoryPort) { 760 this.socketFactoryPort = socketFactoryPort; 761 } 762 763 766 public void addOverrides(Properties props) { 767 super.addOverrides(props); 768 769 if (port != null) props.setProperty(IMAP_PORT, port.toString()); 770 if (partialFetch != null) props.setProperty(IMAP_PARTIAL_FETCH, partialFetch.toString()); 771 if (fetchSize != null) props.setProperty(IMAP_FETCH_SIZE, fetchSize.toString()); 772 if (connectionTimeout != null) props.setProperty(IMAP_CONNECTION_TIMEOUT, connectionTimeout.toString()); 773 if (timeout != null) props.setProperty(IMAP_TIMEOUT, timeout.toString()); 774 if (statusCacheTimeout != null) props.setProperty(IMAP_STATUS_TIMEOUT, statusCacheTimeout.toString()); 775 if (appendBufferSize != null) props.setProperty(IMAP_APPEND_SIZE, appendBufferSize.toString()); 776 if (connectionPoolSize != null) props.setProperty(IMAP_POOL_SIZE, connectionPoolSize.toString()); 777 if (connectionPoolTimeout != null) props.setProperty(IMAP_POOL_TIMEOUT, connectionPoolTimeout.toString()); 778 if (separateStoreConnection != null) props.setProperty(IMAP_SEPARATE_STORE_CONNECTION, separateStoreConnection.toString()); 779 if (allowReadOnlySelect != null) props.setProperty(IMAP_READONLY_SELECT, allowReadOnlySelect.toString()); 780 if (authLoginDisable != null) props.setProperty(IMAP_LOGIN_DISABLE, authLoginDisable.toString()); 781 if (authPlainDisable != null) props.setProperty(IMAP_PLAIN_DISABLE, authPlainDisable.toString()); 782 if (startTLSEnable != null) props.setProperty(IMAP_STARTTLS_ENABLE, startTLSEnable.toString()); 783 if (localaddress != null) props.setProperty(IMAP_LOCALADDRESS, localaddress); 784 if (localport != null) props.setProperty(IMAP_LOCALPORT, localport.toString()); 785 if (saslEnable != null) props.setProperty(IMAP_SASL_ENABLE, saslEnable.toString()); 786 if (saslMechanisms != null) props.setProperty(IMAP_SASL_MECHANISMS, saslMechanisms); 787 if (saslAuthorizationId != null) props.setProperty(IMAP_SASL_AUTHORIZATIONID, saslAuthorizationId); 788 if (socketFactoryClass != null) props.setProperty(IMAP_FACTORY_CLASS, socketFactoryClass); 789 if (socketFactoryFallback != null) props.setProperty(IMAP_FACTORY_FALLBACK, socketFactoryFallback.toString()); 790 if (socketFactoryPort != null) props.setProperty(IMAP_FACTORY_PORT, socketFactoryPort.toString()); 791 } 792 793 public void doStart() throws Exception { 794 log.debug("Started " + getObjectName()); 795 } 796 797 public void doStop() throws Exception { 798 log.debug("Stopped " + getObjectName()); 799 } 800 801 public void doFail() { 802 log.warn("Failed " + getObjectName()); 803 } 804 805 public static final GBeanInfo GBEAN_INFO; 806 807 static { 808 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(IMAPStoreGBean.class, ProtocolGBean.GBEAN_INFO); 809 810 infoFactory.addAttribute(GBEAN_PORT, Integer .class, true); 811 infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT, Integer .class, true); 812 infoFactory.addAttribute(GBEAN_TIMEOUT, Integer .class, true); 813 infoFactory.addAttribute(GBEAN_LOCALADDRESS, String .class, true); 814 infoFactory.addAttribute(GBEAN_LOCALPORT, Integer .class, true); 815 infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String .class, true); 816 infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean .class, true); 817 infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer .class, true); 818 infoFactory.addAttribute(GBEAN_PARTIAL_FETCH, Boolean .class, true); 819 infoFactory.addAttribute(GBEAN_FETCH_SIZE, Integer .class, true); 820 infoFactory.addAttribute(GBEAN_STATUS_TIMEOUT, Integer .class, true); 821 infoFactory.addAttribute(GBEAN_APPEND_SIZE, Integer .class, true); 822 infoFactory.addAttribute(GBEAN_POOL_SIZE, Integer .class, true); 823 infoFactory.addAttribute(GBEAN_POOL_TIMEOUT, Integer .class, true); 824 infoFactory.addAttribute(GBEAN_SEPARATE_STORE_CONNECTION, Boolean .class, true); 825 infoFactory.addAttribute(GBEAN_READONLY_SELECT, Boolean .class, true); 826 infoFactory.addAttribute(GBEAN_LOGIN_DISABLE, Boolean .class, true); 827 infoFactory.addAttribute(GBEAN_PLAIN_DISABLE, Boolean .class, true); 828 infoFactory.addAttribute(GBEAN_STARTTLS_ENABLE, Boolean .class, true); 829 infoFactory.addAttribute(GBEAN_SASL_ENABLE, Boolean .class, true); 830 infoFactory.addAttribute(GBEAN_SASL_MECHANISMS, String .class, true); 831 infoFactory.addAttribute(GBEAN_SASL_AUTHORIZATIONID, String .class, true); 832 833 infoFactory.addAttribute(GBEAN_OBJECTNAME, String .class, false); 834 infoFactory.addAttribute(GBEAN_PROTOCOL, String .class, true); 835 infoFactory.addAttribute(GBEAN_PROPERTIES, Properties .class, true); 836 infoFactory.addAttribute(GBEAN_HOST, String .class, true); 837 infoFactory.addAttribute(GBEAN_USER, String .class, true); 838 infoFactory.addOperation(GBEAN_ADD_OVERRIDES, new Class []{Properties .class}); 839 840 infoFactory.setConstructor(new String []{GBEAN_OBJECTNAME, GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, 841 GBEAN_PORT, 842 GBEAN_PARTIAL_FETCH, 843 GBEAN_FETCH_SIZE, 844 GBEAN_CONNECTION_TIMEOUT, 845 GBEAN_TIMEOUT, 846 GBEAN_STATUS_TIMEOUT, 847 GBEAN_APPEND_SIZE, 848 GBEAN_POOL_SIZE, 849 GBEAN_POOL_TIMEOUT, 850 GBEAN_SEPARATE_STORE_CONNECTION, 851 GBEAN_READONLY_SELECT, 852 GBEAN_LOGIN_DISABLE, 853 GBEAN_PLAIN_DISABLE, 854 GBEAN_STARTTLS_ENABLE, 855 GBEAN_LOCALADDRESS, 856 GBEAN_LOCALPORT, 857 GBEAN_SASL_ENABLE, 858 GBEAN_SASL_MECHANISMS, 859 GBEAN_SASL_AUTHORIZATIONID, 860 GBEAN_FACTORY_CLASS, 861 GBEAN_FACTORY_FALLBACK, 862 GBEAN_FACTORY_PORT}); 863 864 GBEAN_INFO = infoFactory.getBeanInfo(); 865 } 866 867 public static GBeanInfo getGBeanInfo() { 868 return GBEAN_INFO; 869 } 870 } 871 | Popular Tags |