Source Code Cross Referenced for AbstractEndpointFactory.java in  » Web-Services-apache-cxf-2.0.1 » frontend » org » apache » cxf » frontend » 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 » Web Services apache cxf 2.0.1 » frontend » org.apache.cxf.frontend 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements. See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership. The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License. You may obtain a copy of the License at
009:         *
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied. See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */package org.apache.cxf.frontend;
019:
020:        import java.util.ArrayList;
021:        import java.util.List;
022:        import java.util.Map;
023:        import java.util.logging.Logger;
024:
025:        import javax.xml.namespace.QName;
026:
027:        import org.apache.cxf.Bus;
028:        import org.apache.cxf.BusException;
029:        import org.apache.cxf.BusFactory;
030:        import org.apache.cxf.binding.BindingConfiguration;
031:        import org.apache.cxf.binding.BindingFactory;
032:        import org.apache.cxf.binding.BindingFactoryManager;
033:        import org.apache.cxf.binding.soap.SoapBindingConfiguration;
034:        import org.apache.cxf.binding.soap.model.SoapBindingInfo;
035:        import org.apache.cxf.common.i18n.Message;
036:        import org.apache.cxf.common.logging.LogUtils;
037:        import org.apache.cxf.databinding.DataBinding;
038:        import org.apache.cxf.endpoint.ConduitSelector;
039:        import org.apache.cxf.endpoint.Endpoint;
040:        import org.apache.cxf.endpoint.EndpointException;
041:        import org.apache.cxf.endpoint.EndpointImpl;
042:        import org.apache.cxf.feature.AbstractFeature;
043:        import org.apache.cxf.interceptor.AbstractBasicInterceptorProvider;
044:        import org.apache.cxf.service.Service;
045:        import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
046:        import org.apache.cxf.service.factory.ServiceConstructionException;
047:        import org.apache.cxf.service.model.BindingInfo;
048:        import org.apache.cxf.service.model.EndpointInfo;
049:        import org.apache.cxf.service.model.ServiceModelUtil;
050:        import org.apache.cxf.transport.DestinationFactory;
051:        import org.apache.cxf.transport.DestinationFactoryManager;
052:        import org.apache.cxf.transport.local.LocalTransportFactory;
053:        import org.apache.cxf.ws.addressing.EndpointReferenceType;
054:        import org.apache.cxf.wsdl11.WSDLEndpointFactory;
055:
056:        public abstract class AbstractEndpointFactory extends
057:                AbstractBasicInterceptorProvider {
058:            private static final Logger LOG = LogUtils
059:                    .getL7dLogger(AbstractEndpointFactory.class);
060:
061:            private Bus bus;
062:            private String address;
063:            private String transportId;
064:            private String bindingId;
065:            private Class serviceClass;
066:            private DataBinding dataBinding;
067:            private BindingFactory bindingFactory;
068:            private DestinationFactory destinationFactory;
069:            private ReflectionServiceFactoryBean serviceFactory;
070:            private QName endpointName;
071:            private Map<String, Object> properties;
072:            private List<AbstractFeature> features;
073:            private BindingConfiguration bindingConfig;
074:            private EndpointReferenceType endpointReference;
075:            private ConduitSelector conduitSelector;
076:
077:            protected Endpoint createEndpoint() throws BusException,
078:                    EndpointException {
079:                Service service = serviceFactory.getService();
080:
081:                if (service == null) {
082:                    initializeServiceFactory();
083:                    service = serviceFactory.create();
084:                }
085:
086:                if (endpointName == null) {
087:                    endpointName = serviceFactory.getEndpointName();
088:                }
089:                EndpointInfo ei = service.getEndpointInfo(endpointName);
090:                if (ei != null) {
091:                    if (transportId != null
092:                            && !ei.getTransportId().equals(transportId)) {
093:                        ei = null;
094:                    } else {
095:                        BindingFactoryManager bfm = getBus().getExtension(
096:                                BindingFactoryManager.class);
097:                        bindingFactory = bfm.getBindingFactory(ei.getBinding()
098:                                .getBindingId());
099:                    }
100:                }
101:
102:                if (ei == null) {
103:                    if (getAddress() == null) {
104:                        ei = ServiceModelUtil.findBestEndpointInfo(
105:                                serviceFactory.getInterfaceName(), service
106:                                        .getServiceInfos());
107:                    }
108:                    if (ei == null) {
109:                        ei = createEndpointInfo();
110:                    }
111:                } else if (getAddress() != null) {
112:                    ei.setAddress(getAddress());
113:                }
114:
115:                if (endpointReference != null) {
116:                    ei.setAddress(endpointReference);
117:                }
118:                Endpoint ep = service.getEndpoints().get(ei.getName());
119:
120:                if (ep == null) {
121:                    ep = serviceFactory.createEndpoint(ei);
122:                    ((EndpointImpl) ep).initializeActiveFeatures(getFeatures());
123:                } else {
124:                    serviceFactory.setEndpointName(ei.getName());
125:                    if (ep.getActiveFeatures() == null) {
126:                        ((EndpointImpl) ep)
127:                                .initializeActiveFeatures(getFeatures());
128:                    }
129:                }
130:
131:                if (properties != null) {
132:                    ep.putAll(properties);
133:                }
134:
135:                service.getEndpoints().put(ep.getEndpointInfo().getName(), ep);
136:
137:                if (getInInterceptors() != null) {
138:                    ep.getInInterceptors().addAll(getInInterceptors());
139:                }
140:                if (getOutInterceptors() != null) {
141:                    ep.getOutInterceptors().addAll(getOutInterceptors());
142:                }
143:                if (getInFaultInterceptors() != null) {
144:                    ep.getInFaultInterceptors()
145:                            .addAll(getInFaultInterceptors());
146:                }
147:                if (getOutFaultInterceptors() != null) {
148:                    ep.getOutFaultInterceptors().addAll(
149:                            getOutFaultInterceptors());
150:                }
151:                return ep;
152:            }
153:
154:            protected void initializeServiceFactory() {
155:                Class cls = getServiceClass();
156:
157:                serviceFactory.setServiceClass(cls);
158:                serviceFactory.setBus(getBus());
159:                if (dataBinding != null) {
160:                    serviceFactory.setDataBinding(dataBinding);
161:                }
162:            }
163:
164:            protected EndpointInfo createEndpointInfo() throws BusException {
165:                if (transportId == null && getAddress() != null) {
166:                    DestinationFactory df = getDestinationFactory();
167:                    if (df == null) {
168:                        DestinationFactoryManager dfm = getBus().getExtension(
169:                                DestinationFactoryManager.class);
170:                        df = dfm.getDestinationFactoryForUri(getAddress());
171:                    }
172:
173:                    if (df != null) {
174:                        transportId = df.getTransportIds().get(0);
175:                    }
176:                }
177:
178:                // Get the Service from the ServiceFactory if specified
179:                Service service = serviceFactory.getService();
180:                // SOAP nonsense
181:                BindingInfo bindingInfo = createBindingInfo();
182:                if (bindingInfo instanceof  SoapBindingInfo
183:                        && (((SoapBindingInfo) bindingInfo).getTransportURI() == null || LocalTransportFactory.TRANSPORT_ID
184:                                .equals(transportId))) {
185:                    ((SoapBindingInfo) bindingInfo)
186:                            .setTransportURI(transportId);
187:                    transportId = "http://schemas.xmlsoap.org/wsdl/soap/";
188:                }
189:
190:                if (transportId == null) {
191:                    if (bindingInfo instanceof  SoapBindingInfo) {
192:                        // TODO: we shouldn't have to do this, but the DF is null because the
193:                        // LocalTransport doesn't return for the http:// uris
194:                        // People also seem to be supplying a null JMS getAddress(), which is worrying
195:                        transportId = "http://schemas.xmlsoap.org/wsdl/soap/";
196:                    } else {
197:                        transportId = "http://schemas.xmlsoap.org/wsdl/http/";
198:                    }
199:                }
200:
201:                service.getServiceInfos().get(0).addBinding(bindingInfo);
202:
203:                setTransportId(transportId);
204:
205:                if (destinationFactory == null) {
206:                    DestinationFactoryManager dfm = getBus().getExtension(
207:                            DestinationFactoryManager.class);
208:                    destinationFactory = dfm.getDestinationFactory(transportId);
209:                }
210:
211:                EndpointInfo ei;
212:                if (destinationFactory instanceof  WSDLEndpointFactory) {
213:                    ei = ((WSDLEndpointFactory) destinationFactory)
214:                            .createEndpointInfo(service.getServiceInfos()
215:                                    .get(0), bindingInfo, null);
216:                    ei.setTransportId(transportId);
217:                } else {
218:                    ei = new EndpointInfo(service.getServiceInfos().get(0),
219:                            transportId);
220:                }
221:                int count = 1;
222:                while (service.getEndpointInfo(endpointName) != null) {
223:                    endpointName = new QName(endpointName.getNamespaceURI(),
224:                            endpointName.getLocalPart() + count);
225:                    count++;
226:                }
227:                ei.setName(endpointName);
228:                ei.setAddress(getAddress());
229:                ei.setBinding(bindingInfo);
230:
231:                if (destinationFactory instanceof  WSDLEndpointFactory) {
232:                    WSDLEndpointFactory we = (WSDLEndpointFactory) destinationFactory;
233:
234:                    we.createPortExtensors(ei, service);
235:                } else {
236:                    // ?
237:                }
238:                service.getServiceInfos().get(0).addEndpoint(ei);
239:                return ei;
240:            }
241:
242:            protected BindingInfo createBindingInfo() {
243:                BindingFactoryManager mgr = bus
244:                        .getExtension(BindingFactoryManager.class);
245:                String binding = bindingId;
246:
247:                if (binding == null && bindingConfig != null) {
248:                    binding = bindingConfig.getBindingId();
249:                }
250:
251:                if (binding == null) {
252:                    // default to soap binding
253:                    binding = "http://schemas.xmlsoap.org/soap/";
254:                }
255:
256:                try {
257:                    if ("http://schemas.xmlsoap.org/soap/".equals(binding)) {
258:                        if (bindingConfig == null) {
259:                            bindingConfig = new SoapBindingConfiguration();
260:                        }
261:                        if (bindingConfig instanceof  SoapBindingConfiguration) {
262:                            ((SoapBindingConfiguration) bindingConfig)
263:                                    .setStyle(serviceFactory.getStyle());
264:                        }
265:                    }
266:
267:                    bindingFactory = mgr.getBindingFactory(binding);
268:
269:                    return bindingFactory.createBindingInfo(serviceFactory
270:                            .getService(), binding, bindingConfig);
271:                } catch (BusException ex) {
272:                    throw new ServiceConstructionException(new Message(
273:                            "COULD.NOT.RESOLVE.BINDING", LOG, bindingId), ex);
274:                }
275:            }
276:
277:            public String getAddress() {
278:                return address;
279:            }
280:
281:            public void setAddress(String address) {
282:                this .address = address;
283:            }
284:
285:            public Bus getBus() {
286:                if (bus == null) {
287:                    bus = BusFactory.getThreadDefaultBus();
288:                }
289:                return bus;
290:            }
291:
292:            public void setBus(Bus bus) {
293:                this .bus = bus;
294:            }
295:
296:            public String getTransportId() {
297:                return transportId;
298:            }
299:
300:            public void setTransportId(String transportId) {
301:                this .transportId = transportId;
302:            }
303:
304:            public void setBindingId(String bind) {
305:                bindingId = bind;
306:            }
307:
308:            public String getBindingId() {
309:                return bindingId;
310:            }
311:
312:            public void setBindingConfig(BindingConfiguration obj) {
313:                bindingConfig = obj;
314:            }
315:
316:            public BindingConfiguration getBindingConfig() {
317:                return bindingConfig;
318:            }
319:
320:            public Class getServiceClass() {
321:                return serviceClass;
322:            }
323:
324:            public void setServiceClass(Class serviceClass) {
325:                this .serviceClass = serviceClass;
326:            }
327:
328:            public DestinationFactory getDestinationFactory() {
329:                return destinationFactory;
330:            }
331:
332:            public void setDestinationFactory(
333:                    DestinationFactory destinationFactory) {
334:                this .destinationFactory = destinationFactory;
335:            }
336:
337:            public ReflectionServiceFactoryBean getServiceFactory() {
338:                return serviceFactory;
339:            }
340:
341:            public void setServiceFactory(
342:                    ReflectionServiceFactoryBean serviceFactory) {
343:                this .serviceFactory = serviceFactory;
344:            }
345:
346:            public QName getEndpointName() {
347:                return endpointName;
348:            }
349:
350:            public void setEndpointName(QName endpointName) {
351:                this .endpointName = endpointName;
352:            }
353:
354:            public void setEndpointReference(EndpointReferenceType epr) {
355:                endpointReference = epr;
356:            }
357:
358:            public Map<String, Object> getProperties() {
359:                return properties;
360:            }
361:
362:            public void setProperties(Map<String, Object> properties) {
363:                this .properties = properties;
364:            }
365:
366:            public List<AbstractFeature> getFeatures() {
367:                if (features == null) {
368:                    features = new ArrayList<AbstractFeature>();
369:                }
370:                return features;
371:            }
372:
373:            public void setFeatures(List<AbstractFeature> features) {
374:                this .features = features;
375:            }
376:
377:            public String getWsdlURL() {
378:                return getServiceFactory().getWsdlURL();
379:            }
380:
381:            public void setWsdlURL(String wsdlURL) {
382:                getServiceFactory().setWsdlURL(wsdlURL);
383:            }
384:
385:            public BindingFactory getBindingFactory() {
386:                return bindingFactory;
387:            }
388:
389:            public ConduitSelector getConduitSelector() {
390:                return conduitSelector;
391:            }
392:
393:            public void setConduitSelector(ConduitSelector selector) {
394:                conduitSelector = selector;
395:            }
396:
397:            public DataBinding getDataBinding() {
398:                return dataBinding;
399:            }
400:
401:            public void setDataBinding(DataBinding dataBinding) {
402:                this.dataBinding = dataBinding;
403:            }
404:
405:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.