Source Code Cross Referenced for ProtocolGBean.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » mail » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server geronimo » plugins » org.apache.geronimo.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.mail;
017:
018:        import java.util.Enumeration;
019:        import java.util.Properties;
020:
021:        import org.apache.commons.logging.Log;
022:        import org.apache.commons.logging.LogFactory;
023:
024:        import org.apache.geronimo.gbean.GBeanInfo;
025:        import org.apache.geronimo.gbean.GBeanInfoBuilder;
026:        import org.apache.geronimo.gbean.GBeanLifecycle;
027:
028:        /**
029:         * A generic GBean that provides for the configuration of a JavaMail protocol.
030:         * <p/>
031:         * Values that are set in the individual member variables will override any of
032:         * the corresponding values that have been set in the properties set.
033:         *
034:         * @version $Rev: 486195 $ $Date: 2006-12-12 07:42:02 -0800 (Tue, 12 Dec 2006) $
035:         */
036:        public class ProtocolGBean implements  GBeanLifecycle {
037:
038:            // common attributes exported by all ProtocolBeans
039:            static public final String GBEAN_OBJECTNAME = "objectName";
040:            static public final String GBEAN_PROTOCOL = "protocol";
041:            static public final String GBEAN_PROPERTIES = "properties";
042:            static public final String GBEAN_HOST = "host";
043:            static public final String GBEAN_USER = "user";
044:            static public final String GBEAN_ADD_OVERRIDES = "addOverrides";
045:
046:            // common constants for GBEAN properties that are used by a number of transports.
047:            static public final String GBEAN_PORT = "port";
048:            static public final String GBEAN_CONNECTION_TIMEOUT = "connectionTimeout";
049:            static public final String GBEAN_TIMEOUT = "timeout";
050:            static public final String GBEAN_FROM = "from";
051:            static public final String GBEAN_AUTH = "auth";
052:            static public final String GBEAN_REALM = "saslRealm";
053:            static public final String GBEAN_QUITWAIT = "quitWait";
054:            static public final String GBEAN_FACTORY_CLASS = "socketFactoryClass";
055:            static public final String GBEAN_FACTORY_FALLBACK = "socketFactoryFallback";
056:            static public final String GBEAN_FACTORY_PORT = "socketFactoryPort";
057:            static public final String GBEAN_LOCALHOST = "localhost";
058:            static public final String GBEAN_LOCALADDRESS = "localaddress";
059:            static public final String GBEAN_LOCALPORT = "localport";
060:
061:            private final Log log = LogFactory.getLog(ProtocolGBean.class);
062:
063:            private final String objectName;
064:            private Properties properties;
065:            private final String protocol;
066:            private String host;
067:            private String user;
068:
069:            /**
070:             * Construct an instance of ProtocolGBean
071:             */
072:            public ProtocolGBean() {
073:                this .objectName = null;
074:                this .protocol = null;
075:                this .properties = null;
076:            }
077:
078:            /**
079:             * Construct an instance of ProtocolGBean
080:             * <p/>
081:             * Values that are set in the individual member variables will override any of
082:             * the corresponding values that have been set in the properties set.
083:             *
084:             * @param objectName the object name of the protocol
085:             * @param protocol   the name of the protocol
086:             * @param properties the set of default properties for the protocol
087:             * @param host       the host the protocol connects to
088:             * @param user       the default name for the protocol
089:             */
090:            public ProtocolGBean(String objectName, String protocol,
091:                    Properties properties, String host, String user) {
092:                assert protocol != null;
093:
094:                this .objectName = objectName;
095:                this .protocol = protocol;
096:                this .properties = (properties == null ? new Properties()
097:                        : properties);
098:                this .host = host;
099:                this .user = user;
100:            }
101:
102:            /**
103:             * Returns the object name of this protocol GBean
104:             */
105:            public String getObjectName() {
106:                return objectName;
107:            }
108:
109:            /**
110:             * Returns the set of default properties for the protocol.
111:             * <p/>
112:             * Values that are set in the individual member variables will override any of
113:             * the corresponding values that have been set in the properties set.
114:             */
115:            public Properties getProperties() {
116:                return properties;
117:            }
118:
119:            /**
120:             * Sets the set of default properties for the protocol.
121:             * <p/>
122:             * Values that are set in the individual member variables will override any of
123:             * the corresponding values that have been set in the properties set.
124:             *
125:             * @param properties set of default properties for the protocol
126:             */
127:            public void setProperties(Properties properties) {
128:                this .properties = properties;
129:            }
130:
131:            /**
132:             * Returns the name of the protocol
133:             */
134:            public String getProtocol() {
135:                return protocol;
136:            }
137:
138:            /**
139:             * Returns the host the protocol connects to.
140:             */
141:            public String getHost() {
142:                return host;
143:            }
144:
145:            /**
146:             * Set the host the protocol connects to.
147:             *
148:             * @param host the host the protocol connects to
149:             */
150:            public void setHost(String host) {
151:                this .host = host;
152:            }
153:
154:            /**
155:             * Returns the default user name for the protocol.
156:             */
157:            public String getUser() {
158:                return user;
159:            }
160:
161:            /**
162:             * Sets the default user name for the protocol.
163:             *
164:             * @param user the default user name for the protocol
165:             */
166:            public void setUser(String user) {
167:                this .user = user;
168:            }
169:
170:            /**
171:             * Add the overrides from the member variables to the properties file.
172:             */
173:            public void addOverrides(Properties props) {
174:                Enumeration keys = properties.propertyNames();
175:
176:                // copy the properties attribute into the over rides as well.  These are copied
177:                // with the key names unchanged, so they must be specified fully qualified.
178:                while (keys.hasMoreElements()) {
179:                    String key = (String) keys.nextElement();
180:                    props.put(key, properties.getProperty(key));
181:                }
182:
183:                if (host != null)
184:                    props.put("mail." + protocol + ".host", host);
185:                if (user != null)
186:                    props.put("mail." + protocol + ".user", user);
187:            }
188:
189:            public void doStart() throws Exception {
190:                log.debug("Started " + objectName);
191:            }
192:
193:            public void doStop() throws Exception {
194:                log.debug("Stopped " + objectName);
195:            }
196:
197:            public void doFail() {
198:                log.warn("Failed " + objectName);
199:            }
200:
201:            public static final GBeanInfo GBEAN_INFO;
202:
203:            static {
204:                GBeanInfoBuilder infoFactory = GBeanInfoBuilder
205:                        .createStatic(ProtocolGBean.class); //TODO just a gbean?
206:
207:                infoFactory.addAttribute(GBEAN_OBJECTNAME, String.class, false);
208:                infoFactory.addAttribute(GBEAN_PROTOCOL, String.class, true);
209:                infoFactory.addAttribute(GBEAN_PROPERTIES, Properties.class,
210:                        true);
211:                infoFactory.addAttribute(GBEAN_HOST, String.class, true);
212:                infoFactory.addAttribute(GBEAN_USER, String.class, true);
213:                infoFactory.addOperation(GBEAN_ADD_OVERRIDES,
214:                        new Class[] { Properties.class });
215:
216:                infoFactory.setConstructor(new String[] { GBEAN_OBJECTNAME,
217:                        GBEAN_PROTOCOL, GBEAN_PROPERTIES, GBEAN_HOST,
218:                        GBEAN_USER });
219:
220:                GBEAN_INFO = infoFactory.getBeanInfo();
221:            }
222:
223:            public static GBeanInfo getGBeanInfo() {
224:                return GBEAN_INFO;
225:            }
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.