Source Code Cross Referenced for NNTPTransportGBean.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.Properties;
019:
020:        import org.apache.commons.logging.Log;
021:        import org.apache.commons.logging.LogFactory;
022:
023:        import org.apache.geronimo.gbean.GBeanInfo;
024:        import org.apache.geronimo.gbean.GBeanInfoBuilder;
025:
026:        /**
027:         * A GBean that provides for the configuration of a JavaMail NNTP transport
028:         * protocol.
029:         * <p/>
030:         * NNTP transport properties that are common to all NNTP transports are
031:         * provided via member variables of this class.  Values that are set in the
032:         * individual member variables will override any of the corresponding values
033:         * that have been set in the properties set.
034:         *
035:         * @version $Rev: 486195 $ $Date: 2006-12-12 07:42:02 -0800 (Tue, 12 Dec 2006) $
036:         * @see MailGBean
037:         */
038:        public class NNTPTransportGBean extends ProtocolGBean implements 
039:                NNTPGBeanConstants {
040:
041:            private final Log log = LogFactory.getLog(NNTPTransportGBean.class);
042:
043:            private Integer port;
044:            private Integer connectionTimeout;
045:            private Integer timeout;
046:            private String from;
047:            private Boolean auth;
048:            private String saslRealm;
049:            private Boolean quitWait;
050:            private String socketFactoryClass;
051:            private Boolean socketFactoryFallback;
052:            private Integer socketFactoryPort;
053:
054:            /**
055:             * Construct an instance of NNTPTransportGBean
056:             * <p/>
057:             * Values that are set in the individual member variables will override any of
058:             * the corresponding values that have been set in the properties set.
059:             *
060:             * @param objectName            the object name of the protocol
061:             * @param properties            the set of default properties for the protocol
062:             * @param host                  the host the protocol connects to
063:             * @param user                  the default name for the protocol
064:             * @param port                  the NNTP server port
065:             * @param connectionTimeout     the socket connection timeout value in milliseconds
066:             * @param timeout               the socket I/O timeout value in milliseconds
067:             * @param from                  the email address to use for NNTP POST command
068:             * @param auth                  whether an attempt will be made to authenticate the user
069:             * @param saslRealm             the realm to use with DIGEST-MD5 authentication
070:             * @param quitWait              whether the transport will wait for the response to the QUIT command
071:             * @param socketFactoryClass    the class that will be used to create NNTP sockets
072:             * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
073:             *                              socket factory class cannot be created
074:             * @param socketFactoryPort     whether java.net.Socket class will be created if the specified
075:             *                              socket factory class cannot be created
076:             */
077:            public NNTPTransportGBean(String objectName, Properties properties,
078:                    String host, String user, Integer port,
079:                    Integer connectionTimeout, Integer timeout, String from,
080:                    Boolean auth, String saslRealm, Boolean quitWait,
081:                    String socketFactoryClass, Boolean socketFactoryFallback,
082:                    Integer socketFactoryPort) {
083:                super (objectName, "nntp-post", properties, host, user);
084:
085:                setPort(port);
086:                setConnectionTimeout(connectionTimeout);
087:                setTimeout(timeout);
088:                setFrom(from);
089:                setAuth(auth);
090:                setSaslRealm(saslRealm);
091:                setQuitWait(quitWait);
092:                setSocketFactoryClass(socketFactoryClass);
093:                setSocketFactoryFallback(socketFactoryFallback);
094:                setSocketFactoryPort(socketFactoryPort);
095:            }
096:
097:            /**
098:             * Returns the NNTP server port to connect to, if the connect() method
099:             * doesn't explicitly specify one.
100:             */
101:            public Integer getPort() {
102:                return port;
103:            }
104:
105:            /**
106:             * Sets the NNTP server port to connect to, if the connect() method
107:             * doesn't explicitly specify one.
108:             * <p/>
109:             * Defaults to 25.
110:             * <p/>
111:             * Values that are set here will override any of the corresponding value
112:             * that has been set in the properties.
113:             *
114:             * @param port the NNTP server port to connect to
115:             */
116:            public void setPort(Integer port) {
117:                this .port = port;
118:            }
119:
120:            /**
121:             * Returns the socket connection timeout value in milliseconds.
122:             */
123:            public Integer getConnectionTimeout() {
124:                return connectionTimeout;
125:            }
126:
127:            /**
128:             * Sets the socket connection timeout value in milliseconds.
129:             * <p/>
130:             * Default is infinite timeout.
131:             * <p/>
132:             * Values that are set here will override any of the corresponding value
133:             * that has been set in the properties.
134:             *
135:             * @param connectionTimeout the socket connection timeout value in milliseconds.
136:             */
137:            public void setConnectionTimeout(Integer connectionTimeout) {
138:                this .connectionTimeout = connectionTimeout;
139:            }
140:
141:            /**
142:             * Returns the socket I/O timeout value in milliseconds.
143:             */
144:            public Integer getTimeout() {
145:                return timeout;
146:            }
147:
148:            /**
149:             * Sets the socket I/O timeout value in milliseconds.
150:             * <p/>
151:             * Default is infinite timeout.
152:             * <p/>
153:             * Values that are set here will override any of the corresponding value
154:             * that has been set in the properties.
155:             *
156:             * @param timeout the socket I/O timeout value in milliseconds
157:             */
158:            public void setTimeout(Integer timeout) {
159:                this .timeout = timeout;
160:            }
161:
162:            /**
163:             * Returns the email address to use for NNTP POST command.
164:             */
165:            public String getFrom() {
166:                return from;
167:            }
168:
169:            /**
170:             * Sets the email address to use for NNTP POST command
171:             * <p/>
172:             * Email address to use for NNTP POST command. This sets the envelope
173:             * return address. Defaults to msg.getFrom() or InternetAddress.getLocalAddress().
174:             * <p/>
175:             * Values that are set here will override any of the corresponding value
176:             * that has been set in the properties.
177:             *
178:             * @param from the email address to use for NNTP POST command
179:             */
180:            public void setFrom(String from) {
181:                this .from = from;
182:            }
183:
184:            /**
185:             * Returns whether an attempt will be made to authenticate the user
186:             * <p/>
187:             * Defaults to false.
188:             */
189:            public Boolean getAuth() {
190:                return auth;
191:            }
192:
193:            /**
194:             * Sets whether an attempt will be made to authenticate the user.
195:             * <p/>
196:             * Defaults to false.
197:             * <p/>
198:             * Values that are set here will override any of the corresponding value
199:             * that has been set in the properties.
200:             *
201:             * @param auth whether an attempt will be made to authenticate the user.
202:             */
203:            public void setAuth(Boolean auth) {
204:                this .auth = auth;
205:            }
206:
207:            /**
208:             * Returns the realm to use with DIGEST-MD5 authentication.
209:             */
210:            public String getSaslRealm() {
211:                return saslRealm;
212:            }
213:
214:            /**
215:             * Sets the realm to use with DIGEST-MD5 authentication.
216:             * <p/>
217:             * Values that are set here will override any of the corresponding value
218:             * that has been set in the properties.
219:             *
220:             * @param saslRealm the realm to use with DIGEST-MD5 authentication
221:             */
222:            public void setSaslRealm(String saslRealm) {
223:                this .saslRealm = saslRealm;
224:            }
225:
226:            /**
227:             * Returns whether the transport will wait for the response to the QUIT command.
228:             * <p/>
229:             * If set to true, causes the transport to wait for the response to the QUIT
230:             * command. If set to false (the default), the QUIT command is sent and the
231:             * connection is immediately closed.
232:             */
233:            public Boolean getQuitWait() {
234:                return quitWait;
235:            }
236:
237:            /**
238:             * Sets whether the transport will wait for the response to the QUIT command
239:             * <p/>
240:             * If set to true, causes the transport to wait for the response to the QUIT
241:             * command. If set to false (the default), the QUIT command is sent and the
242:             * connection is immediately closed.
243:             * <p/>
244:             * Values that are set here will override any of the corresponding value
245:             * that has been set in the properties.
246:             *
247:             * @param quitWait whether the transport will wait for the response to the QUIT command
248:             */
249:            public void setQuitWait(Boolean quitWait) {
250:                this .quitWait = quitWait;
251:            }
252:
253:            /**
254:             * Returns the class that will be used to create NNTP sockets.
255:             * <p/>
256:             * If set, specifies the name of a class that implements the
257:             * javax.net.SocketFactory interface. This class will be used to create NNTP
258:             * sockets.
259:             */
260:            public String getSocketFactoryClass() {
261:                return socketFactoryClass;
262:            }
263:
264:            /**
265:             * Sets the class that will be used to create NNTP sockets.
266:             * <p/>
267:             * If set, specifies the name of a class that implements the
268:             * javax.net.SocketFactory interface. This class will be used to create NNTP
269:             * sockets.
270:             * <p/>
271:             * Values that are set here will override any of the corresponding value
272:             * that has been set in the properties.
273:             *
274:             * @param socketFactoryClass the class that will be used to create NNTP sockets
275:             */
276:            public void setSocketFactoryClass(String socketFactoryClass) {
277:                this .socketFactoryClass = socketFactoryClass;
278:            }
279:
280:            /**
281:             * Returns whether java.net.Socket class will be created if the specified
282:             * socket factory class cannot be created.
283:             * <p/>
284:             * If set to true, failure to create a socket using the specified socket
285:             * factory class will cause the socket to be created using the
286:             * java.net.Socket class. Defaults to true.
287:             */
288:            public Boolean getSocketFactoryFallback() {
289:                return socketFactoryFallback;
290:            }
291:
292:            /**
293:             * Sets whether java.net.Socket class will be created if the specified
294:             * socket factory class cannot be created.
295:             * <p/>
296:             * If set to true, failure to create a socket using the specified socket
297:             * factory class will cause the socket to be created using the
298:             * java.net.Socket class. Defaults to true.
299:             * <p/>
300:             * Values that are set here will override any of the corresponding value
301:             * that has been set in the properties.
302:             *
303:             * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
304:             *                              socket factory class cannot be created
305:             */
306:            public void setSocketFactoryFallback(Boolean socketFactoryFallback) {
307:                this .socketFactoryFallback = socketFactoryFallback;
308:            }
309:
310:            /**
311:             * Returns the port to connect to when using the specified socket factory.
312:             * <p/>
313:             * Specifies the port to connect to when using the specified socket
314:             * factory. If not set, the default port will be used.
315:             */
316:            public Integer getSocketFactoryPort() {
317:                return socketFactoryPort;
318:            }
319:
320:            /**
321:             * Sets the port to connect to when using the specified socket factory.
322:             * <p/>
323:             * Specifies the port to connect to when using the specified socket
324:             * factory. If not set, the default port will be used.
325:             * <p/>
326:             * Values that are set here will override any of the corresponding value
327:             * that has been set in the properties.
328:             *
329:             * @param socketFactoryPort the port to connect to when using the specified socket factory
330:             */
331:            public void setSocketFactoryPort(Integer socketFactoryPort) {
332:                this .socketFactoryPort = socketFactoryPort;
333:            }
334:
335:            /**
336:             * Add the overrides from the member variables to the properties file.
337:             */
338:            public void addOverrides(Properties props) {
339:                super .addOverrides(props);
340:
341:                if (port != null)
342:                    props.setProperty(NNTP_PORT, port.toString());
343:                if (connectionTimeout != null)
344:                    props.setProperty(NNTP_CONNECTION_TIMEOUT,
345:                            connectionTimeout.toString());
346:                if (timeout != null)
347:                    props.setProperty(NNTP_TIMEOUT, timeout.toString());
348:                if (from != null)
349:                    props.setProperty(NNTP_FROM, from);
350:                if (auth != null)
351:                    props.setProperty(NNTP_AUTH, auth.toString());
352:                if (saslRealm != null)
353:                    props.setProperty(NNTP_REALM, saslRealm);
354:                if (quitWait != null)
355:                    props.setProperty(NNTP_QUITWAIT, quitWait.toString());
356:                if (socketFactoryClass != null)
357:                    props.setProperty(NNTP_FACTORY_CLASS, socketFactoryClass);
358:                if (socketFactoryFallback != null)
359:                    props.setProperty(NNTP_FACTORY_FALLBACK,
360:                            socketFactoryFallback.toString());
361:                if (socketFactoryPort != null)
362:                    props.setProperty(NNTP_FACTORY_PORT, socketFactoryPort
363:                            .toString());
364:            }
365:
366:            public void doStart() throws Exception {
367:                log.debug("Started " + getObjectName());
368:            }
369:
370:            public void doStop() throws Exception {
371:                log.debug("Stopped " + getObjectName());
372:            }
373:
374:            public void doFail() {
375:                log.warn("Failed " + getObjectName());
376:            }
377:
378:            public static final GBeanInfo GBEAN_INFO;
379:
380:            static {
381:                GBeanInfoBuilder infoFactory = GBeanInfoBuilder
382:                        .createStatic(NNTPTransportGBean.class);
383:
384:                infoFactory.addAttribute(GBEAN_PORT, Integer.class, true);
385:                infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT,
386:                        Integer.class, true);
387:                infoFactory.addAttribute(GBEAN_TIMEOUT, Integer.class, true);
388:                infoFactory.addAttribute(GBEAN_AUTH, Boolean.class, true);
389:                infoFactory.addAttribute(GBEAN_FROM, String.class, true);
390:                infoFactory.addAttribute(GBEAN_REALM, String.class, true);
391:                infoFactory.addAttribute(GBEAN_QUITWAIT, Boolean.class, true);
392:                infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String.class,
393:                        true);
394:                infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean.class,
395:                        true);
396:                infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer.class,
397:                        true);
398:
399:                infoFactory.addAttribute(GBEAN_OBJECTNAME, String.class, false);
400:                infoFactory.addAttribute(GBEAN_PROTOCOL, String.class, true);
401:                infoFactory.addAttribute(GBEAN_PROPERTIES, Properties.class,
402:                        true);
403:                infoFactory.addAttribute(GBEAN_HOST, String.class, true);
404:                infoFactory.addAttribute(GBEAN_USER, String.class, true);
405:                infoFactory.addOperation(GBEAN_ADD_OVERRIDES,
406:                        new Class[] { Properties.class });
407:
408:                infoFactory.setConstructor(new String[] { GBEAN_OBJECTNAME,
409:                        GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, GBEAN_PORT,
410:                        GBEAN_CONNECTION_TIMEOUT, GBEAN_TIMEOUT, GBEAN_FROM,
411:                        GBEAN_AUTH, GBEAN_REALM, GBEAN_QUITWAIT,
412:                        GBEAN_FACTORY_CLASS, GBEAN_FACTORY_FALLBACK,
413:                        GBEAN_FACTORY_PORT });
414:
415:                GBEAN_INFO = infoFactory.getBeanInfo();
416:            }
417:
418:            public static GBeanInfo getGBeanInfo() {
419:                return GBEAN_INFO;
420:            }
421:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.