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


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