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


001:        /*
002:         * $Id: DefaultEndpointFactory.java 11278 2008-03-07 20:26:34Z dfeist $
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.endpoint;
012:
013:        import org.mule.RegistryContext;
014:        import org.mule.api.MuleContext;
015:        import org.mule.api.MuleException;
016:        import org.mule.api.endpoint.EndpointBuilder;
017:        import org.mule.api.endpoint.EndpointException;
018:        import org.mule.api.endpoint.EndpointFactory;
019:        import org.mule.api.endpoint.EndpointURI;
020:        import org.mule.api.endpoint.ImmutableEndpoint;
021:        import org.mule.api.endpoint.InboundEndpoint;
022:        import org.mule.api.endpoint.OutboundEndpoint;
023:        import org.mule.api.registry.RegistrationException;
024:        import org.mule.config.i18n.CoreMessages;
025:
026:        import org.apache.commons.logging.Log;
027:        import org.apache.commons.logging.LogFactory;
028:
029:        public class DefaultEndpointFactory implements  EndpointFactory {
030:            /** logger used by this class */
031:            protected static final Log logger = LogFactory
032:                    .getLog(DefaultEndpointFactory.class);
033:
034:            public static final String ENDPOINT_REGISTRY_PREFIX = "endpoint:";
035:
036:            protected MuleContext muleContext;
037:
038:            public InboundEndpoint getInboundEndpoint(String uri)
039:                    throws MuleException {
040:                logger
041:                        .debug("DefaultEndpointFactory request for inbound endpoint for uri: "
042:                                + uri);
043:                EndpointBuilder endpointBuilder = lookupEndpointBuilder(uri);
044:                if (endpointBuilder == null) {
045:                    logger
046:                            .debug("Named EndpointBuilder not found, creating endpoint from uri");
047:                    endpointBuilder = new EndpointURIEndpointBuilder(uri,
048:                            muleContext);
049:                }
050:                return getInboundEndpoint(endpointBuilder);
051:            }
052:
053:            public OutboundEndpoint getOutboundEndpoint(String uri)
054:                    throws MuleException {
055:                logger
056:                        .debug("DefaultEndpointFactory request for outbound endpoint for uri: "
057:                                + uri);
058:                EndpointBuilder endpointBuilder = lookupEndpointBuilder(uri);
059:                if (endpointBuilder == null) {
060:                    logger
061:                            .debug("Named EndpointBuilder not found, creating endpoint from uri");
062:                    endpointBuilder = new EndpointURIEndpointBuilder(uri,
063:                            muleContext);
064:
065:                }
066:                return getOutboundEndpoint(endpointBuilder);
067:            }
068:
069:            protected EndpointBuilder lookupEndpointBuilder(String endpointName) {
070:                logger.debug("Looking up EndpointBuilder with name:"
071:                        + endpointName + " in registry");
072:                // TODO DF: Do some simple parsing of endpointName to not lookup endpoint builder if endpointName is
073:                // obviously a uri and not a substituted name ??
074:                EndpointBuilder endpointBuilder = RegistryContext.getRegistry()
075:                        .lookupEndpointBuilder(endpointName);
076:                if (endpointBuilder != null) {
077:                    logger.debug("EndpointBuilder with name:" + endpointName
078:                            + " FOUND");
079:                }
080:                return endpointBuilder;
081:            }
082:
083:            public InboundEndpoint getInboundEndpoint(EndpointBuilder builder)
084:                    throws MuleException {
085:                InboundEndpoint endpoint = builder.buildInboundEndpoint();
086:                return (InboundEndpoint) registerEndpoint(endpoint);
087:            }
088:
089:            public OutboundEndpoint getOutboundEndpoint(EndpointBuilder builder)
090:                    throws MuleException {
091:                OutboundEndpoint endpoint = builder.buildOutboundEndpoint();
092:                return (OutboundEndpoint) registerEndpoint(endpoint);
093:            }
094:
095:            /**
096:             * 
097:             * @param endpoint
098:             * @return
099:             * @throws RegistrationException
100:             */
101:            protected ImmutableEndpoint registerEndpoint(
102:                    ImmutableEndpoint endpoint) throws RegistrationException {
103:                ImmutableEndpoint registryEndpoint = (ImmutableEndpoint) muleContext
104:                        .getRegistry().lookupObject(
105:                                ENDPOINT_REGISTRY_PREFIX + endpoint.hashCode());
106:                if (registryEndpoint == null) {
107:                    muleContext.getRegistry().registerObject(
108:                            ENDPOINT_REGISTRY_PREFIX + endpoint.hashCode(),
109:                            endpoint);
110:                    registryEndpoint = endpoint;
111:                }
112:                return registryEndpoint;
113:            }
114:
115:            public EndpointBuilder getEndpointBuilder(String uri)
116:                    throws MuleException {
117:                logger
118:                        .debug("DefaultEndpointFactory request for endpoint builder for uri: "
119:                                + uri);
120:                EndpointBuilder endpointBuilder = lookupEndpointBuilder(uri);
121:                if (endpointBuilder != null) {
122:                    try {
123:                        endpointBuilder = (EndpointBuilder) endpointBuilder
124:                                .clone();
125:                    } catch (Exception e) {
126:                        throw new EndpointException(
127:                                CoreMessages
128:                                        .failedToClone("global endpoint EndpointBuilder"),
129:                                e);
130:                    }
131:                } else {
132:                    logger
133:                            .debug("Named EndpointBuilder not found, creating endpoint builder for uri");
134:                    endpointBuilder = new EndpointURIEndpointBuilder(uri,
135:                            muleContext);
136:                }
137:                return endpointBuilder;
138:            }
139:
140:            public void setMuleContext(MuleContext context) {
141:                this .muleContext = context;
142:            }
143:
144:            public org.mule.api.endpoint.InboundEndpoint getInboundEndpoint(
145:                    EndpointURI uri) throws MuleException {
146:                return (InboundEndpoint) getEndpoint(uri, new EndpointSource() {
147:                    public ImmutableEndpoint getEndpoint(EndpointBuilder builder)
148:                            throws MuleException {
149:                        return getInboundEndpoint(builder);
150:                    }
151:                });
152:            }
153:
154:            public OutboundEndpoint getOutboundEndpoint(EndpointURI uri)
155:                    throws MuleException {
156:                return (OutboundEndpoint) getEndpoint(uri,
157:                        new EndpointSource() {
158:                            public ImmutableEndpoint getEndpoint(
159:                                    EndpointBuilder builder)
160:                                    throws MuleException {
161:                                return getOutboundEndpoint(builder);
162:                            }
163:                        });
164:            }
165:
166:            protected ImmutableEndpoint getEndpoint(EndpointURI uri,
167:                    EndpointSource source) throws MuleException {
168:                logger
169:                        .debug("DefaultEndpointFactory request for endpoint for: "
170:                                + uri);
171:                EndpointBuilder endpointBuilder = null;
172:                if (uri.getEndpointName() != null) {
173:                    endpointBuilder = lookupEndpointBuilder(uri
174:                            .getEndpointName());
175:                    if (endpointBuilder == null) {
176:                        throw new IllegalArgumentException(
177:                                "The endpoint with name: "
178:                                        + uri.getEndpointName()
179:                                        + "was not found.");
180:                    }
181:                } else {
182:                    logger
183:                            .debug("Named EndpointBuilder not found, creating endpoint from uri");
184:                    endpointBuilder = new EndpointURIEndpointBuilder(uri,
185:                            muleContext);
186:                }
187:                return source.getEndpoint(endpointBuilder);
188:            }
189:
190:            private interface EndpointSource {
191:                ImmutableEndpoint getEndpoint(EndpointBuilder endpointBuilder)
192:                        throws MuleException;
193:            }
194:
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.