Source Code Cross Referenced for RegistrationPersistenceManagerImpl.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » registration » impl » 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 » Portal » jboss portal 2.6.4 » org.jboss.portal.registration.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.registration.impl;
023:
024:        import org.jboss.portal.common.util.ParameterValidation;
025:        import org.jboss.portal.jems.as.system.AbstractJBossService;
026:        import org.jboss.portal.registration.Consumer;
027:        import org.jboss.portal.registration.ConsumerGroup;
028:        import org.jboss.portal.registration.DuplicateRegistrationException;
029:        import org.jboss.portal.registration.NoSuchRegistrationException;
030:        import org.jboss.portal.registration.Registration;
031:        import org.jboss.portal.registration.RegistrationException;
032:        import org.jboss.portal.registration.RegistrationPersistenceManager;
033:        import org.jboss.portal.registration.RegistrationStatus;
034:
035:        import java.util.Collection;
036:        import java.util.Collections;
037:        import java.util.HashMap;
038:        import java.util.Map;
039:
040:        /**
041:         * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
042:         * @version $Revision: 8784 $
043:         * @since 2.6
044:         */
045:        public class RegistrationPersistenceManagerImpl extends
046:                AbstractJBossService implements  RegistrationPersistenceManager {
047:            private long lastRegistrationId;
048:            private Map consumers = new HashMap();
049:            private Map groups = new HashMap();
050:            private Map registrations = new HashMap();
051:
052:            public Consumer createConsumer(String consumerId,
053:                    String consumerName) throws RegistrationException {
054:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
055:                        consumerId, "Consumer identity", null);
056:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
057:                        consumerName, "Consumer name", null);
058:
059:                ConsumerImpl consumer = new ConsumerImpl(consumerId,
060:                        consumerName);
061:                consumer.setStatus(RegistrationStatus.PENDING);
062:                consumers.put(consumerId, consumer);
063:
064:                return consumer;
065:            }
066:
067:            public ConsumerGroup getConsumerGroup(String name)
068:                    throws RegistrationException {
069:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name,
070:                        "ConsumerGroup name", null);
071:
072:                return (ConsumerGroup) groups.get(name);
073:            }
074:
075:            public ConsumerGroup createConsumerGroup(String name)
076:                    throws RegistrationException {
077:                ConsumerGroup group = getConsumerGroup(name);
078:                if (group != null) {
079:                    throw new DuplicateRegistrationException(
080:                            "A ConsumerGroup named '" + name
081:                                    + "' has already been registered.");
082:                } else {
083:                    group = new ConsumerGroupImpl(name);
084:                    groups.put(name, group);
085:                    return group;
086:                }
087:            }
088:
089:            public void removeConsumerGroup(String name)
090:                    throws RegistrationException {
091:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name,
092:                        "ConsumerGroup name", null);
093:                if (groups.remove(name) == null) {
094:                    throw new NoSuchRegistrationException(
095:                            "There is no ConsumerGroup named '" + name + "'.");
096:                }
097:            }
098:
099:            public void removeConsumer(String consumerId)
100:                    throws RegistrationException {
101:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
102:                        consumerId, "Consumer identity", null);
103:                if (consumers.remove(consumerId) == null) {
104:                    throw new RegistrationException(
105:                            "There is no Consumer with identity '" + consumerId
106:                                    + "'.");
107:                }
108:            }
109:
110:            public void removeRegistration(String registrationId)
111:                    throws RegistrationException {
112:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
113:                        registrationId, "Registration identity", null);
114:
115:                RegistrationImpl registration = (RegistrationImpl) registrations
116:                        .get(registrationId);
117:                if (registration == null) {
118:                    throw new NoSuchRegistrationException(
119:                            "There is no Registration with id '"
120:                                    + registrationId + "'");
121:                }
122:
123:                ConsumerImpl consumer = (ConsumerImpl) registration
124:                        .getConsumer();
125:                consumer.removeRegistration(registration);
126:                registrations.remove(registrationId);
127:            }
128:
129:            public Consumer getConsumerById(String consumerId)
130:                    throws RegistrationException {
131:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
132:                        consumerId, "Consumer identity", null);
133:
134:                return (Consumer) consumers.get(consumerId);
135:            }
136:
137:            public Registration addRegistrationFor(String consumerId,
138:                    Map registrationProperties) throws RegistrationException {
139:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
140:                        consumerId, "Consumer identity", null);
141:                ParameterValidation.throwIllegalArgExceptionIfNull(
142:                        registrationProperties, "Registration properties");
143:
144:                ConsumerImpl consumer = (ConsumerImpl) getConsumerById(consumerId);
145:                if (consumer == null) {
146:                    throw new NoSuchRegistrationException(
147:                            "There is no Consumer with identity '" + consumerId
148:                                    + "' to add a Registration to...");
149:                }
150:
151:                RegistrationImpl registration = new RegistrationImpl(""
152:                        + lastRegistrationId++, consumer,
153:                        RegistrationStatus.PENDING, registrationProperties);
154:                consumer.addRegistration(registration);
155:
156:                registrations.put(registration.getId(), registration);
157:
158:                return registration;
159:            }
160:
161:            public Consumer addConsumerToGroupNamed(String consumerId,
162:                    String groupName) throws RegistrationException {
163:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
164:                        consumerId, "Consumer identity", null);
165:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
166:                        groupName, "ConsumerGroup name", null);
167:
168:                ConsumerGroupImpl group = (ConsumerGroupImpl) getConsumerGroup(groupName);
169:                if (group == null) {
170:                    throw new NoSuchRegistrationException(
171:                            "There is no ConsumerGroup named '" + groupName
172:                                    + "' to add a Consumer to...");
173:                }
174:
175:                ConsumerImpl consumer = (ConsumerImpl) getConsumerById(consumerId);
176:                if (consumer == null) {
177:                    throw new NoSuchRegistrationException(
178:                            "There is no Consumer with identity '" + consumerId
179:                                    + "' to add to ConsumerGroup named '"
180:                                    + groupName + "'. Did you create it?");
181:                }
182:
183:                group.addConsumer(consumer);
184:
185:                return consumer;
186:            }
187:
188:            public Collection getConsumers() {
189:                return Collections.unmodifiableCollection(consumers.values());
190:            }
191:
192:            public Collection getRegistrations() {
193:                return Collections.unmodifiableCollection(registrations
194:                        .values());
195:            }
196:
197:            public Collection getConsumerGroups() {
198:                return Collections.unmodifiableCollection(groups.values());
199:            }
200:
201:            public Registration getRegistration(String registrationId) {
202:                ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(
203:                        registrationId, "Registration id", null);
204:
205:                return (Registration) registrations.get(registrationId);
206:            }
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.