Source Code Cross Referenced for JavaMail.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » mail » factory » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.mail.factory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or 1any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * Initial developer(s): Florent BENOIT & Ludovic BERT
022:         * --------------------------------------------------------------------------
023:         * $Id: JavaMail.java 6661 2005-04-28 08:43:27Z benoitf $
024:         * --------------------------------------------------------------------------
025:         */package org.objectweb.jonas.mail.factory;
026:
027:        //import java
028:        import java.io.Serializable;
029:        import java.util.Properties;
030:
031:        import javax.naming.NamingException;
032:        import javax.naming.Reference;
033:        import javax.naming.Referenceable;
034:
035:        import org.objectweb.jonas.common.Log;
036:        import org.objectweb.jonas.common.PropDump;
037:        import org.objectweb.jonas.mail.MailService;
038:        import org.objectweb.jonas.mail.MailServiceImpl;
039:        import org.objectweb.jonas.service.ServiceManager;
040:        import org.objectweb.util.monolog.api.BasicLevel;
041:        import org.objectweb.util.monolog.api.Logger;
042:
043:        /**
044:         * This class implements JOnAS mail factory objects. It gets the properties from mail factory properties file
045:         * and build a properties object for the Session.
046:         * @author Florent Benoit
047:         * @author Ludovic Bert
048:         * Contributor(s):
049:         * Adriana Danes :
050:         * Refactor code: rename the management methods (use straightforward
051:         * names, as they are to be used in a Management Console)
052:         * 03/04/01 : JavaMail extends ReconfigDispatcher in order to send reconfiguration Notifications to ReconfigManager
053:         *
054:         * Markus Karg : Change the JOnAS mail factory initialisation strategy in order
055:         * to allow any initialisation parameters for a javax.mail.Session object (not
056:         * only a known set pf initialisation parameters as before).
057:         *
058:         * Adriana Danes :
059:         * 03/11/20 : J2EEManagement conformance - replaces old JMail class
060:         */
061:        public abstract class JavaMail implements  Serializable, Referenceable {
062:
063:            /**
064:             * The logger used in JOnAS
065:             */
066:            private static Logger logger = null;
067:
068:            /**
069:             * The name of the factory.
070:             */
071:            private String factoryName = null;
072:
073:            /**
074:             * The jndi name of this object.
075:             */
076:            private String name = null;
077:
078:            /**
079:             * Properties for the javax.mail.Session object.
080:             * Keep only the values used for configuring the javax.mail.Session object.
081:             */
082:            private Properties mailSessionProperties = null;
083:
084:            /**
085:             * Properties for the authentication.
086:             */
087:            private Properties authenticationProperties = null;
088:
089:            /**
090:             * JOnAS-specific property that authenticates the user name
091:             */
092:            private static final String PROPERTY_AUTHENTICATION_USERNAME = "mail.authentication.username";
093:
094:            /**
095:             * JOnAS-specific property that authenticates the user password
096:             */
097:            private static final String PROPERTY_AUTHENTICATION_PASSWORD = "mail.authentication.password";
098:
099:            /**
100:             * Constructor of a JavaMail Object with the given name and properties.
101:             * @param factoryName the name of the factory.
102:             * @param name the jndi name.
103:             * @param mailProperties properties for configuring and manageing this object.
104:             */
105:            public JavaMail(String factoryName, String name,
106:                    Properties mailProperties) {
107:                //Get the logger
108:                if (logger == null) {
109:                    logger = Log.getLogger(Log.JONAS_MAIL_PREFIX);
110:                }
111:                this .factoryName = factoryName;
112:                this .name = name;
113:
114:                this .mailSessionProperties = (Properties) mailProperties
115:                        .clone();
116:
117:                // Retrieve JOnAS specific properties 'type' and 'name' from props
118:                mailSessionProperties.remove(MailServiceImpl.PROPERTY_NAME);
119:                mailSessionProperties.remove(MailServiceImpl.PROPERTY_TYPE);
120:
121:                // Construct authentication properties from well-known JOnAS properties only
122:                this .authenticationProperties = new Properties();
123:                String propValue = null;
124:                propValue = (String) mailSessionProperties
125:                        .remove(PROPERTY_AUTHENTICATION_USERNAME);
126:                if (propValue != null) {
127:                    authenticationProperties.setProperty(
128:                            PROPERTY_AUTHENTICATION_USERNAME, propValue);
129:                }
130:                propValue = (String) mailSessionProperties
131:                        .remove(PROPERTY_AUTHENTICATION_PASSWORD);
132:                if (propValue != null) {
133:                    authenticationProperties.setProperty(
134:                            PROPERTY_AUTHENTICATION_PASSWORD, propValue);
135:                }
136:            }
137:
138:            /**
139:             * Return the jndi name of this object
140:             * @return the jndi name
141:             */
142:            public String getName() {
143:                return name;
144:            }
145:
146:            /**
147:             * Set the jndi name of this object.
148:             * @param name the jndi name
149:             */
150:            void setName(String name) {
151:                String oldName = this .name;
152:                this .name = new String(name);
153:                try {
154:                    ((MailService) ServiceManager.getInstance()
155:                            .getMailService()).renameJavaMailFactory(oldName,
156:                            this );
157:                } catch (Exception e) {
158:                    // should never occurs at this time
159:                }
160:            }
161:
162:            /**
163:             * Return the name of this mail factory
164:             * @return name of this mail factory.
165:             */
166:            public String getFactoryName() {
167:                return factoryName;
168:            }
169:
170:            /**
171:             * Return the type of the factory
172:             * @return the type of the mail factory
173:             */
174:            public abstract String getType();
175:
176:            /**
177:             * Retrieves the session properties of this object.
178:             * @return the session properties of this object.
179:             */
180:            Properties getSessionProperties() {
181:                return mailSessionProperties;
182:            }
183:
184:            /**
185:             * Set the session properties.
186:             * @param props the session properties.
187:             */
188:            void setSessionProperties(Properties props) {
189:                this .mailSessionProperties = props;
190:                // rebind the mail factory in JNDI
191:                try {
192:                    ((MailService) ServiceManager.getInstance()
193:                            .getMailService()).recreateJavaMailFactory(this );
194:                } catch (Exception e) {
195:                    // should never occurs
196:                }
197:                //notifyReconfiguration(props);
198:                if (logger.isLoggable(BasicLevel.DEBUG)) {
199:                    PropDump.print("These are the udated session properties",
200:                            this .mailSessionProperties, logger,
201:                            BasicLevel.DEBUG);
202:                }
203:            }
204:
205:            /**
206:             * Retrieves the authentication properties of this object.
207:             * @return the authentication properties of this object.
208:             */
209:            Properties getAuthenticationProperties() {
210:                return authenticationProperties;
211:            }
212:
213:            /**
214:             * Set the authentication properties.
215:             * @param props the authentication properties.
216:             */
217:            void setAuthenticationProperties(Properties props) {
218:                this .authenticationProperties = props;
219:                // rebind the mail factory in JNDI
220:                try {
221:                    ((MailService) ServiceManager.getInstance()
222:                            .getMailService()).recreateJavaMailFactory(this );
223:                } catch (Exception e) {
224:                    // should never occurs
225:                }
226:                //notifyReconfiguration(props);
227:                if (logger.isLoggable(BasicLevel.DEBUG)) {
228:                    PropDump.print("These are the udated auth properties",
229:                            this .authenticationProperties, logger,
230:                            BasicLevel.DEBUG);
231:                }
232:            }
233:
234:            /**
235:             * Retrieves the Reference of the object.
236:             * The Reference contains the factory used to create this object
237:             * and the optional parameters used to configure the factory.
238:             * @return the non-null Reference of the object.
239:             * @throws NamingException if a naming exception was encountered while
240:             * retrieving the reference.
241:             */
242:            public abstract Reference getReference() throws NamingException;
243:
244:            /**
245:             * @return Returns the logger.
246:             */
247:            public static Logger getLogger() {
248:                return logger;
249:            }
250:
251:            /**
252:             * @param logger The logger to set.
253:             */
254:            public static void setLogger(Logger logger) {
255:                JavaMail.logger = logger;
256:            }
257:
258:            /**
259:             * @return Returns the mailSessionProperties.
260:             */
261:            public Properties getMailSessionProperties() {
262:                return mailSessionProperties;
263:            }
264:
265:            /**
266:             * @param mailSessionProperties The mailSessionProperties to set.
267:             */
268:            public void setMailSessionProperties(
269:                    Properties mailSessionProperties) {
270:                this.mailSessionProperties = mailSessionProperties;
271:            }
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.