Source Code Cross Referenced for AvalonUsersStore.java in  » Web-Mail » james-2.3.1 » org » apache » james » core » 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 » Web Mail » james 2.3.1 » org.apache.james.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /****************************************************************
002:         * Licensed to the Apache Software Foundation (ASF) under one   *
003:         * or more contributor license agreements.  See the NOTICE file *
004:         * distributed with this work for additional information        *
005:         * regarding copyright ownership.  The ASF licenses this file   *
006:         * to you under the Apache License, Version 2.0 (the            *
007:         * "License"); you may not use this file except in compliance   *
008:         * with the License.  You may obtain a copy of the License at   *
009:         *                                                              *
010:         *   http://www.apache.org/licenses/LICENSE-2.0                 *
011:         *                                                              *
012:         * Unless required by applicable law or agreed to in writing,   *
013:         * software distributed under the License is distributed on an  *
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
015:         * KIND, either express or implied.  See the License for the    *
016:         * specific language governing permissions and limitations      *
017:         * under the License.                                           *
018:         ****************************************************************/package org.apache.james.core;
019:
020:        import org.apache.avalon.framework.activity.Initializable;
021:        import org.apache.avalon.framework.component.Composable;
022:        import org.apache.avalon.framework.configuration.Configurable;
023:        import org.apache.avalon.framework.configuration.Configuration;
024:        import org.apache.avalon.framework.configuration.ConfigurationException;
025:        import org.apache.avalon.framework.container.ContainerUtil;
026:        import org.apache.avalon.framework.context.Context;
027:        import org.apache.avalon.framework.context.ContextException;
028:        import org.apache.avalon.framework.context.Contextualizable;
029:        import org.apache.avalon.framework.logger.AbstractLogEnabled;
030:        import org.apache.avalon.framework.service.ServiceException;
031:        import org.apache.avalon.framework.service.ServiceManager;
032:        import org.apache.avalon.framework.service.Serviceable;
033:        import org.apache.james.services.UsersRepository;
034:        import org.apache.james.services.UsersStore;
035:
036:        import java.util.HashMap;
037:        import java.util.Iterator;
038:
039:        /**
040:         * Provides a registry of user repositories.
041:         *
042:         */
043:        public class AvalonUsersStore extends AbstractLogEnabled implements 
044:                Contextualizable, Serviceable, Configurable, Initializable,
045:                UsersStore {
046:
047:            /**
048:             * A mapping of respository identifiers to actual repositories
049:             * This mapping is obtained from the component configuration
050:             */
051:            private HashMap repositories;
052:
053:            /**
054:             * The Avalon context used by the instance
055:             */
056:            protected Context context;
057:
058:            /**
059:             * The Avalon configuration used by the instance
060:             */
061:            protected Configuration configuration;
062:
063:            /**
064:             * The Avalon component manager used by the instance
065:             */
066:            protected ServiceManager manager;
067:
068:            /**
069:             * @see org.apache.avalon.framework.context.Contextualizable#contextualize(Context)
070:             */
071:            public void contextualize(final Context context)
072:                    throws ContextException {
073:                this .context = context;
074:            }
075:
076:            /**
077:             * @see org.apache.avalon.framework.service.Serviceable#compose(ServiceManager)
078:             */
079:            public void service(final ServiceManager manager)
080:                    throws ServiceException {
081:                this .manager = manager;
082:            }
083:
084:            /**
085:             * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
086:             */
087:            public void configure(final Configuration configuration)
088:                    throws ConfigurationException {
089:                this .configuration = configuration;
090:            }
091:
092:            /**
093:             * @see org.apache.avalon.framework.activity.Initializable#initialize()
094:             */
095:            public void initialize() throws Exception {
096:
097:                getLogger().info("AvalonUsersStore init...");
098:                repositories = new HashMap();
099:
100:                Configuration[] repConfs = configuration
101:                        .getChildren("repository");
102:                ClassLoader theClassLoader = null;
103:                for (int i = 0; i < repConfs.length; i++) {
104:                    Configuration repConf = repConfs[i];
105:                    String repName = repConf.getAttribute("name");
106:                    String repClass = repConf.getAttribute("class");
107:
108:                    if (getLogger().isDebugEnabled()) {
109:                        getLogger().debug("Starting " + repClass);
110:                    }
111:
112:                    if (theClassLoader == null) {
113:                        theClassLoader = this .getClass().getClassLoader();
114:                    }
115:
116:                    UsersRepository rep = (UsersRepository) theClassLoader
117:                            .loadClass(repClass).newInstance();
118:
119:                    setupLogger(rep);
120:
121:                    ContainerUtil.contextualize(rep, context);
122:                    ContainerUtil.service(rep, manager);
123:                    if (rep instanceof  Composable) {
124:                        final String error = "no implementation in place to support Composable";
125:                        getLogger().error(error);
126:                        throw new IllegalArgumentException(error);
127:                    }
128:                    ContainerUtil.configure(rep, repConf);
129:                    ContainerUtil.initialize(rep);
130:
131:                    repositories.put(repName, rep);
132:                    if (getLogger().isInfoEnabled()) {
133:                        StringBuffer logBuffer = new StringBuffer(64).append(
134:                                "UsersRepository ").append(repName).append(
135:                                " started.");
136:                        getLogger().info(logBuffer.toString());
137:                    }
138:                }
139:                getLogger().info("AvalonUsersStore ...init");
140:            }
141:
142:            /** 
143:             * Get the repository, if any, whose name corresponds to
144:             * the argument parameter
145:             *
146:             * @param name the name of the desired repository
147:             *
148:             * @return the UsersRepository corresponding to the name parameter
149:             */
150:            public UsersRepository getRepository(String name) {
151:                UsersRepository response = (UsersRepository) repositories
152:                        .get(name);
153:                if ((response == null) && (getLogger().isWarnEnabled())) {
154:                    getLogger().warn("No users repository called: " + name);
155:                }
156:                return response;
157:            }
158:
159:            /** 
160:             * Yield an <code>Iterator</code> over the set of repository
161:             * names managed internally by this store.
162:             *
163:             * @return an Iterator over the set of repository names
164:             *         for this store
165:             */
166:            public Iterator getRepositoryNames() {
167:                return this.repositories.keySet().iterator();
168:            }
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.