Source Code Cross Referenced for DeploymentRegistry.java in  » ESB » open-esb » com » sun » jbi » binding » file » 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 » ESB » open esb » com.sun.jbi.binding.file 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)DeploymentRegistry.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.binding.file;
030:
031:        import com.sun.jbi.binding.file.FileBindingContext;
032:        import com.sun.jbi.binding.file.util.StringTranslator;
033:
034:        import java.util.ArrayList;
035:        import java.util.Collection;
036:        import java.util.HashMap;
037:        import java.util.Iterator;
038:        import java.util.LinkedList;
039:        import java.util.List;
040:        import java.util.Set;
041:        import java.util.logging.Logger;
042:
043:        import com.sun.jbi.binding.file.util.ConfigData;
044:        import javax.xml.namespace.QName;
045:
046:        /**
047:         * This is a registry which maintains the servicename, endpoint name    across
048:         * the bean object. This is an in-memory representation of all endpoints
049:         * deployed to file binding.
050:         *
051:         * @author Sun Microsystems, Inc.
052:         */
053:        public final class DeploymentRegistry implements  FileBindingResources {
054:            /**
055:             * Singleton reference.
056:             */
057:            private static DeploymentRegistry sMe;
058:
059:            /**
060:             * List of all registered channels.
061:             */
062:            private HashMap mDeployments;
063:
064:            /**
065:             * Logger object
066:             */
067:            private Logger mLog;
068:
069:            /**
070:             * Helper for i18n
071:             */
072:            private StringTranslator mTranslator;
073:
074:            /**
075:             * Private constructor.
076:             */
077:            private DeploymentRegistry() {
078:                mDeployments = new HashMap();
079:                mLog = FileBindingContext.getInstance().getLogger();
080:                mTranslator = new StringTranslator();
081:            }
082:
083:            /**
084:             * Used to grab a reference of this object.
085:             *
086:             * @return an initialized DeploymentRegistry reference
087:             */
088:            public static synchronized DeploymentRegistry getInstance() {
089:                if (sMe == null) {
090:                    sMe = new DeploymentRegistry();
091:                }
092:
093:                return sMe;
094:            }
095:
096:            /**
097:             * Returns all the deployments to file binding.
098:             *
099:             * @return an array of Deployment Ids.
100:             */
101:            public synchronized String[] getAllDeployments() {
102:                List deps = new ArrayList();
103:                Collection col = mDeployments.values();
104:                String[] deployments = null;
105:
106:                try {
107:                    Iterator iter = col.iterator();
108:
109:                    while (iter.hasNext()) {
110:                        EndpointBean eb = (EndpointBean) iter.next();
111:                        String depid = eb.getDeploymentId();
112:
113:                        if (!deps.contains(depid)) {
114:                            deps.add(depid);
115:                        }
116:                    }
117:
118:                    deployments = new String[deps.size()];
119:
120:                    Iterator depiter = deps.iterator();
121:                    int i = 0;
122:
123:                    while (depiter.hasNext()) {
124:                        deployments[i] = (String) depiter.next();
125:                        i++;
126:                    }
127:                } catch (Exception e) {
128:                    e.printStackTrace();
129:                }
130:
131:                return deployments;
132:            }
133:
134:            /**
135:             * Util method to find if a service has been deployed.
136:             *
137:             * @param serviceendpoint serviceendpoint information.
138:             *
139:             * @return true if deployed, false otherwise.
140:             */
141:            public boolean isDeployed(String serviceendpoint) {
142:                if (mDeployments.get(serviceendpoint) == null) {
143:                    return false;
144:                }
145:
146:                return true;
147:            }
148:
149:            /**
150:             * Gets the status of the su id.
151:             *
152:             * @param suId SU Id
153:             *
154:             * @return true if deployed , false otherwise.
155:             */
156:            public boolean getDeploymentStatus(String suId) {
157:                Set keyset = mDeployments.keySet();
158:                Iterator iter = keyset.iterator();
159:
160:                while (iter.hasNext()) {
161:                    String ser = (String) iter.next();
162:                    EndpointBean eb = (EndpointBean) mDeployments.get(ser);
163:
164:                    if (eb.getDeploymentId().trim().equals(suId)) {
165:                        return true;
166:                    }
167:                }
168:
169:                return false;
170:            }
171:
172:            /**
173:             * Gets the enpoint list associated with the SU id.
174:             *
175:             * @param suId SU ID.
176:             *
177:             * @return list of endpoint Beans.
178:             */
179:            public List getEndpoints(String suId) {
180:                Set keyset = mDeployments.keySet();
181:                Iterator iter = keyset.iterator();
182:                List eplist = new LinkedList();
183:
184:                while (iter.hasNext()) {
185:                    String ser = (String) iter.next();
186:                    EndpointBean eb = (EndpointBean) mDeployments.get(ser);
187:
188:                    if (eb.getDeploymentId().trim().equals(suId)) {
189:                        eplist.add(eb);
190:                    }
191:                }
192:
193:                return eplist;
194:            }
195:
196:            /**
197:             * Removes all the entries from the registry.
198:             */
199:            public void clearRegistry() {
200:                if (mDeployments == null) {
201:                    return;
202:                }
203:
204:                mDeployments = new HashMap();
205:            }
206:
207:            /**
208:             * Removes an endpoint from the registry.
209:             *
210:             * @param serviceendpoint service:endpoint combination.
211:             */
212:            public synchronized void deregisterEndpoint(String serviceendpoint) {
213:                mLog.info(mTranslator.getString(FBC_DEREGISTER_ENDPOINT,
214:                        serviceendpoint));
215:
216:                EndpointBean eb = null;
217:
218:                try {
219:                    eb = (EndpointBean) mDeployments.remove(serviceendpoint);
220:                } catch (Exception e) {
221:                    ;
222:                }
223:
224:                if (eb == null) {
225:                    mLog.severe(mTranslator.getString(
226:                            FBC_DEREGISTER_ENDPOINT_FAILED, serviceendpoint));
227:                }
228:            }
229:
230:            /**
231:             * Used to find a registered endpoint which matches the specified service.
232:             *
233:             * @param serviceendpoint the service to match against
234:             *
235:             * @return the appropriate endpoint bean, or no such endpoint exists.
236:             */
237:            public EndpointBean findEndpoint(String serviceendpoint) {
238:                EndpointBean eb;
239:                eb = (EndpointBean) mDeployments.get(serviceendpoint);
240:
241:                return eb;
242:            }
243:
244:            /**
245:             * Used to find a registered endpoint which matches the specified interface.
246:             *
247:             * @param interface name the service to match against
248:             *
249:             * @return the appropriate endpoint bean, or no such endpoint exists.
250:             */
251:            public EndpointBean findEndpointByInterface(String interfacename) {
252:                Set keyset = mDeployments.keySet();
253:                Iterator iter = keyset.iterator();
254:
255:                while (iter.hasNext()) {
256:                    String ser = (String) iter.next();
257:                    EndpointBean eb = (EndpointBean) mDeployments.get(ser);
258:                    QName in = new QName(eb
259:                            .getValue(ConfigData.INTERFACE_NAMESPACE), eb
260:                            .getValue(ConfigData.INTERFACE_LOCALNAME));
261:                    if ((in.toString().trim().equals(interfacename))
262:                            && (eb.getRole() == ConfigData.CONSUMER)) {
263:                        return eb;
264:                    }
265:                }
266:                return null;
267:            }
268:
269:            /**
270:             * List all endpoints currently present in the registry.
271:             *
272:             * @return an iterator over all endpoints in the registry.
273:             */
274:            public Iterator listAllEndpoints() {
275:                if (mDeployments == null) {
276:                    return null;
277:                }
278:
279:                Set tmp = mDeployments.keySet();
280:
281:                if (tmp == null) {
282:                    return null;
283:                }
284:
285:                return tmp.iterator();
286:            }
287:
288:            /**
289:             * Registers an endpoint with the registry.  Duplicates are allowed and no
290:             * validation is performed at this point.
291:             *
292:             * @param serviceendpoint the endpoint to register
293:             * @param endpoint endpoint bean object.
294:             */
295:            public synchronized void registerEndpoint(String serviceendpoint,
296:                    EndpointBean endpoint) {
297:                mLog.info(mTranslator.getString(FBC_REGISTER_ENDPOINT,
298:                        serviceendpoint));
299:                mDeployments.put(serviceendpoint, endpoint);
300:            }
301:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.