Source Code Cross Referenced for SpringRegistry.java in  » ESB » mule » org » mule » config » spring » 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 » mule » org.mule.config.spring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: SpringRegistry.java 11371 2008-03-15 03:12:09Z tcarlson $
003:         * --------------------------------------------------------------------------------------
004:         * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
005:         *
006:         * The software in this package is published under the terms of the CPAL v1.0
007:         * license, a copy of which has been included with this distribution in the
008:         * LICENSE.txt file.
009:         */
010:
011:        package org.mule.config.spring;
012:
013:        import org.mule.api.MuleException;
014:        import org.mule.api.agent.Agent;
015:        import org.mule.api.config.MuleConfiguration;
016:        import org.mule.api.endpoint.EndpointBuilder;
017:        import org.mule.api.endpoint.ImmutableEndpoint;
018:        import org.mule.api.lifecycle.Disposable;
019:        import org.mule.api.lifecycle.Initialisable;
020:        import org.mule.api.lifecycle.LifecycleManager;
021:        import org.mule.api.model.Model;
022:        import org.mule.api.registry.RegistrationException;
023:        import org.mule.api.registry.ServiceDescriptor;
024:        import org.mule.api.registry.ServiceDescriptorFactory;
025:        import org.mule.api.registry.ServiceException;
026:        import org.mule.api.service.Service;
027:        import org.mule.api.transformer.Transformer;
028:        import org.mule.api.transport.Connector;
029:        import org.mule.config.i18n.CoreMessages;
030:        import org.mule.config.i18n.MessageFactory;
031:        import org.mule.lifecycle.ContainerManagedLifecyclePhase;
032:        import org.mule.lifecycle.GenericLifecycleManager;
033:        import org.mule.registry.AbstractRegistry;
034:        import org.mule.util.SpiUtils;
035:        import org.mule.util.StringUtils;
036:
037:        import java.util.Collection;
038:        import java.util.Map;
039:        import java.util.Properties;
040:
041:        import javax.transaction.TransactionManager;
042:
043:        import org.springframework.beans.factory.NoSuchBeanDefinitionException;
044:        import org.springframework.context.ConfigurableApplicationContext;
045:
046:        public class SpringRegistry extends AbstractRegistry {
047:            public static final String REGISTRY_ID = "org.mule.Registry.Spring";
048:
049:            protected ConfigurableApplicationContext applicationContext;
050:
051:            public SpringRegistry() {
052:                super (REGISTRY_ID);
053:            }
054:
055:            public SpringRegistry(String id) {
056:                super (id);
057:            }
058:
059:            public SpringRegistry(
060:                    ConfigurableApplicationContext applicationContext) {
061:                super (REGISTRY_ID);
062:                this .applicationContext = applicationContext;
063:            }
064:
065:            public SpringRegistry(String id,
066:                    ConfigurableApplicationContext applicationContext) {
067:                super (id);
068:                this .applicationContext = applicationContext;
069:            }
070:
071:            protected LifecycleManager createLifecycleManager() {
072:                GenericLifecycleManager lcm = new GenericLifecycleManager();
073:                lcm.registerLifecycle(new ContainerManagedLifecyclePhase(
074:                        Initialisable.PHASE_NAME, Initialisable.class,
075:                        Disposable.PHASE_NAME));
076:                lcm.registerLifecycle(new ContainerManagedLifecyclePhase(
077:                        Disposable.PHASE_NAME, Disposable.class,
078:                        Initialisable.PHASE_NAME));
079:                return lcm;
080:            }
081:
082:            protected Object doLookupObject(String key) {
083:                if (StringUtils.isBlank(key)) {
084:                    logger
085:                            .warn(
086:                                    MessageFactory
087:                                            .createStaticMessage("Detected a lookup attempt with an empty or null key"),
088:                                    new Throwable().fillInStackTrace());
089:                    return null;
090:                }
091:
092:                try {
093:                    return applicationContext.getBean(key);
094:                } catch (NoSuchBeanDefinitionException e) {
095:                    logger.debug(e);
096:                    return null;
097:                }
098:            }
099:
100:            protected Collection doLookupObjects(Class type) {
101:                Map map = applicationContext.getBeansOfType(type);
102:                // MULE-2762
103:                //if (logger.isDebugEnabled())
104:                //{
105:                //    MapUtils.debugPrint(System.out, "Beans of type " + type, map);
106:                //}
107:                return map.values();
108:            }
109:
110:            public ServiceDescriptor lookupServiceDescriptor(String type,
111:                    String name, Properties overrides) throws ServiceException {
112:                Properties props = SpiUtils.findServiceDescriptor(type, name);
113:                if (props == null) {
114:                    throw new ServiceException(CoreMessages.failedToLoad(type
115:                            + " " + name));
116:                }
117:                return ServiceDescriptorFactory.create(type, name, props,
118:                        overrides, this );
119:            }
120:
121:            /** {@inheritDoc} */
122:            public TransactionManager getTransactionManager() {
123:                try {
124:                    return (TransactionManager) lookupObject(TransactionManager.class);
125:                } catch (RegistrationException e) {
126:                    throw new RuntimeException(e);
127:                }
128:            }
129:
130:            public Collection getModels() {
131:                return applicationContext.getBeansOfType(Model.class).values();
132:            }
133:
134:            /** {@inheritDoc} */
135:            public Collection getConnectors() {
136:                return applicationContext.getBeansOfType(Connector.class)
137:                        .values();
138:            }
139:
140:            public Collection getAgents() {
141:                return applicationContext.getBeansOfType(Agent.class).values();
142:            }
143:
144:            /** {@inheritDoc} */
145:            public Collection getEndpoints() {
146:                return applicationContext.getBeansOfType(
147:                        ImmutableEndpoint.class).values();
148:            }
149:
150:            /** {@inheritDoc} */
151:            public Collection getTransformers() {
152:                return applicationContext.getBeansOfType(Transformer.class)
153:                        .values();
154:            }
155:
156:            public boolean isReadOnly() {
157:                return true;
158:            }
159:
160:            public boolean isRemote() {
161:                return false;
162:            }
163:
164:            public void registerConnector(Connector connector)
165:                    throws MuleException {
166:                unsupportedOperation("registerConnector", connector);
167:            }
168:
169:            public void unregisterConnector(String connectorName)
170:                    throws MuleException {
171:                unsupportedOperation("unregisterConnector", connectorName);
172:            }
173:
174:            public void registerEndpoint(ImmutableEndpoint endpoint)
175:                    throws MuleException {
176:                unsupportedOperation("registerEndpoint", endpoint);
177:            }
178:
179:            public void unregisterEndpoint(String endpointName) {
180:                unsupportedOperation("unregisterEndpoint", endpointName);
181:            }
182:
183:            protected void doRegisterTransformer(Transformer transformer)
184:                    throws MuleException {
185:                unsupportedOperation("registerTransformer", transformer);
186:            }
187:
188:            public void unregisterTransformer(String transformerName) {
189:                unsupportedOperation("unregistertransformer", transformerName);
190:            }
191:
192:            /** {@inheritDoc} */
193:            public void registerService(Service service) throws MuleException {
194:                unsupportedOperation("registerService", service);
195:            }
196:
197:            public void unregisterService(String serviceName) {
198:                unsupportedOperation("unregisterService", serviceName);
199:            }
200:
201:            public void registerModel(Model model) throws MuleException {
202:                unsupportedOperation("registerModel", model);
203:            }
204:
205:            public void unregisterModel(String modelName) {
206:                unsupportedOperation("unregisterModel", modelName);
207:            }
208:
209:            public void registerAgent(Agent agent) throws MuleException {
210:                unsupportedOperation("registerAgent", agent);
211:            }
212:
213:            public void unregisterAgent(String agentName) throws MuleException {
214:                unsupportedOperation("unregisterAgent", agentName);
215:            }
216:
217:            protected void doRegisterObject(String key, Object value,
218:                    Object metadata) throws RegistrationException {
219:                unsupportedOperation("doRegisterObject", key);
220:            }
221:
222:            public void unregisterObject(String key) {
223:                unsupportedOperation("unregisterObject", key);
224:            }
225:
226:            public void registerObjects(Map objects)
227:                    throws RegistrationException {
228:                unsupportedOperation("registryObjects", objects);
229:            }
230:
231:            public void setConfiguration(MuleConfiguration config) {
232:                unsupportedOperation("setConfiguration", config);
233:            }
234:
235:            public void registerEndpointBuilder(String name,
236:                    EndpointBuilder builder) throws MuleException {
237:                unsupportedOperation("registerEndpointBuilder", builder);
238:            }
239:
240:            protected void doDispose() {
241:                super.doDispose();
242:                applicationContext.close();
243:            }
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.