Source Code Cross Referenced for EndpointImpl.java in  » Web-Services-apache-cxf-2.0.1 » frontend » org » apache » cxf » jaxws » 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.jaxws 
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.jaxws;
019:
020:        import java.security.AccessController;
021:        import java.util.ArrayList;
022:        import java.util.List;
023:        import java.util.Map;
024:        import java.util.concurrent.Executor;
025:
026:        import javax.xml.namespace.QName;
027:        import javax.xml.transform.Source;
028:        import javax.xml.ws.Binding;
029:        import javax.xml.ws.WebServicePermission;
030:
031:        import org.apache.cxf.Bus;
032:        import org.apache.cxf.BusFactory;
033:        import org.apache.cxf.binding.BindingConfiguration;
034:        import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
035:        import org.apache.cxf.configuration.Configurable;
036:        import org.apache.cxf.configuration.Configurer;
037:        import org.apache.cxf.endpoint.Server;
038:        import org.apache.cxf.endpoint.ServerImpl;
039:        import org.apache.cxf.feature.AbstractFeature;
040:        import org.apache.cxf.interceptor.Interceptor;
041:        import org.apache.cxf.interceptor.InterceptorProvider;
042:        import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
043:        import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
044:        import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
045:        import org.apache.cxf.service.Service;
046:        import org.apache.cxf.service.invoker.Invoker;
047:
048:        public class EndpointImpl extends javax.xml.ws.Endpoint implements 
049:                InterceptorProvider, Configurable {
050:            /**
051:             * This property controls whether the 'publishEndpoint' permission is checked 
052:             * using only the AccessController (i.e. when SecurityManager is not installed).
053:             * By default this check is not done as the system property is not set.
054:             */
055:            public static final String CHECK_PUBLISH_ENDPOINT_PERMISSON_PROPERTY = "org.apache.cxf.jaxws.checkPublishEndpointPermission";
056:
057:            private static final WebServicePermission PUBLISH_PERMISSION = new WebServicePermission(
058:                    "publishEndpoint");
059:
060:            private Bus bus;
061:            private Object implementor;
062:            private Server server;
063:            private JaxWsServerFactoryBean serverFactory;
064:            private JaxWsServiceFactoryBean serviceFactory;
065:            private Service service;
066:            private Map<String, Object> properties;
067:            private List<Source> metadata;
068:            private Invoker invoker;
069:            private Executor executor;
070:            private String bindingUri;
071:            private String wsdlLocation;
072:            private String address;
073:            private QName endpointName;
074:            private QName serviceName;
075:            private Class implementorClass;
076:
077:            private List<AbstractFeature> features;
078:            private List<Interceptor> in = new ModCountCopyOnWriteArrayList<Interceptor>();
079:            private List<Interceptor> out = new ModCountCopyOnWriteArrayList<Interceptor>();
080:            private List<Interceptor> outFault = new ModCountCopyOnWriteArrayList<Interceptor>();
081:            private List<Interceptor> inFault = new ModCountCopyOnWriteArrayList<Interceptor>();
082:
083:            public EndpointImpl(Object implementor) {
084:                this (BusFactory.getThreadDefaultBus(), implementor);
085:            }
086:
087:            public EndpointImpl(Bus b, Object implementor,
088:                    JaxWsServerFactoryBean sf) {
089:                this .bus = b;
090:                this .serverFactory = sf;
091:                this .implementor = implementor;
092:            }
093:
094:            /**
095:             * 
096:             * @param b
097:             * @param i The implementor object.
098:             * @param bindingUri The URI of the Binding being used. Optional.
099:             * @param wsdl The URL of the WSDL for the service, if different than the URL specified on the
100:             * WebService annotation. Optional.
101:             */
102:            public EndpointImpl(Bus b, Object i, String bindingUri, String wsdl) {
103:                bus = b;
104:                implementor = i;
105:                this .bindingUri = bindingUri;
106:                wsdlLocation = wsdl == null ? null : new String(wsdl);
107:                serverFactory = new JaxWsServerFactoryBean();
108:            }
109:
110:            public EndpointImpl(Bus b, Object i, String bindingUri) {
111:                this (b, i, bindingUri, (String) null);
112:            }
113:
114:            public EndpointImpl(Bus bus, Object implementor) {
115:                this (bus, implementor, (String) null);
116:            }
117:
118:            public Binding getBinding() {
119:                return ((JaxWsEndpointImpl) getEndpoint()).getJaxwsBinding();
120:            }
121:
122:            public void setExecutor(Executor executor) {
123:                this .executor = executor;
124:            }
125:
126:            public Executor getExecutor() {
127:                return executor;
128:            }
129:
130:            public Service getService() {
131:                return service;
132:            }
133:
134:            public JaxWsServiceFactoryBean getServiceFactory() {
135:                return serviceFactory;
136:            }
137:
138:            @Override
139:            public Object getImplementor() {
140:                return implementor;
141:            }
142:
143:            /**
144:             * Gets the class of the implementor.
145:             * @return the class of the implementor object
146:             */
147:            public Class getImplementorClass() {
148:                return implementorClass != null ? implementorClass
149:                        : implementor.getClass();
150:            }
151:
152:            public List<Source> getMetadata() {
153:                return metadata;
154:            }
155:
156:            @Override
157:            public Map<String, Object> getProperties() {
158:                return properties;
159:            }
160:
161:            @Override
162:            public boolean isPublished() {
163:                return server != null;
164:            }
165:
166:            @Override
167:            public void publish(Object arg0) {
168:                // Since this does not do anything now, just check the permission
169:                checkPublishPermission();
170:            }
171:
172:            @Override
173:            public void publish(String addr) {
174:                doPublish(addr);
175:            }
176:
177:            public void setServiceFactory(JaxWsServiceFactoryBean sf) {
178:                serviceFactory = sf;
179:            }
180:
181:            public void setMetadata(List<Source> metadata) {
182:                this .metadata = metadata;
183:            }
184:
185:            @Override
186:            public void setProperties(Map<String, Object> properties) {
187:                this .properties = properties;
188:
189:                if (server != null) {
190:                    server.getEndpoint().putAll(properties);
191:                }
192:            }
193:
194:            @Override
195:            public void stop() {
196:                if (null != server) {
197:                    server.stop();
198:                }
199:            }
200:
201:            public String getBeanName() {
202:                return endpointName.toString() + ".jaxws-endpoint";
203:            }
204:
205:            protected void checkProperties() {
206:                if (properties != null) {
207:                    if (properties.containsKey("javax.xml.ws.wsdl.description")) {
208:                        wsdlLocation = properties.get(
209:                                "javax.xml.ws.wsdl.description").toString();
210:                    }
211:                    if (properties.containsKey(javax.xml.ws.Endpoint.WSDL_PORT)) {
212:                        endpointName = (QName) properties
213:                                .get(javax.xml.ws.Endpoint.WSDL_PORT);
214:                    }
215:                    if (properties
216:                            .containsKey(javax.xml.ws.Endpoint.WSDL_SERVICE)) {
217:                        serviceName = (QName) properties
218:                                .get(javax.xml.ws.Endpoint.WSDL_SERVICE);
219:                    }
220:                }
221:            }
222:
223:            protected void doPublish(String addr) {
224:                checkPublishPermission();
225:
226:                ServerImpl serv = getServer(addr);
227:                if (addr != null) {
228:                    serv.getEndpoint().getEndpointInfo().setAddress(addr);
229:                }
230:                serv.start();
231:            }
232:
233:            public ServerImpl getServer() {
234:                return getServer(null);
235:            }
236:
237:            public synchronized ServerImpl getServer(String addr) {
238:                if (server == null) {
239:                    checkProperties();
240:
241:                    // Initialize the endpointName so we can do configureObject
242:                    if (endpointName == null) {
243:                        JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(
244:                                getImplementorClass());
245:                        endpointName = implInfo.getEndpointName();
246:                    }
247:
248:                    if (serviceFactory != null) {
249:                        serverFactory.setServiceFactory(serviceFactory);
250:                    }
251:
252:                    /*if (serviceName != null) {
253:                        serverFactory.getServiceFactory().setServiceName(serviceName);
254:                    }*/
255:
256:                    configureObject(this );
257:
258:                    // Set up the server factory
259:                    serverFactory.setAddress(addr);
260:                    serverFactory.setStart(false);
261:                    serverFactory.setEndpointName(endpointName);
262:                    serverFactory.setServiceBean(implementor);
263:                    serverFactory.setBus(bus);
264:                    serverFactory.setFeatures(features);
265:                    serverFactory.setInvoker(invoker);
266:
267:                    // Be careful not to override any serverfactory settings as a user might
268:                    // have supplied their own.
269:                    if (getWsdlLocation() != null) {
270:                        serverFactory.setWsdlURL(getWsdlLocation());
271:                    }
272:
273:                    if (bindingUri != null) {
274:                        serverFactory.setBindingId(bindingUri);
275:                    }
276:
277:                    if (serviceName != null) {
278:                        serverFactory.getServiceFactory().setServiceName(
279:                                serviceName);
280:                    }
281:
282:                    if (implementorClass != null) {
283:                        serverFactory.setServiceClass(implementorClass);
284:                    }
285:
286:                    configureObject(serverFactory);
287:
288:                    server = serverFactory.create();
289:
290:                    org.apache.cxf.endpoint.Endpoint endpoint = getEndpoint();
291:                    if (getInInterceptors() != null) {
292:                        endpoint.getInInterceptors()
293:                                .addAll(getInInterceptors());
294:                    }
295:                    if (getOutInterceptors() != null) {
296:                        endpoint.getOutInterceptors().addAll(
297:                                getOutInterceptors());
298:                    }
299:                    if (getInFaultInterceptors() != null) {
300:                        endpoint.getInFaultInterceptors().addAll(
301:                                getInFaultInterceptors());
302:                    }
303:                    if (getOutFaultInterceptors() != null) {
304:                        endpoint.getOutFaultInterceptors().addAll(
305:                                getOutFaultInterceptors());
306:                    }
307:
308:                    if (properties != null) {
309:                        endpoint.putAll(properties);
310:                    }
311:
312:                    configureObject(endpoint.getService());
313:                    configureObject(endpoint);
314:                    this .service = endpoint.getService();
315:
316:                    if (getWsdlLocation() == null) {
317:                        //hold onto the wsdl location so cache won't clear till we go away
318:                        setWsdlLocation(serverFactory.getWsdlURL());
319:                    }
320:                }
321:                return (ServerImpl) server;
322:            }
323:
324:            org.apache.cxf.endpoint.Endpoint getEndpoint() {
325:                return ((ServerImpl) getServer(null)).getEndpoint();
326:            }
327:
328:            private void configureObject(Object instance) {
329:                Configurer configurer = bus.getExtension(Configurer.class);
330:                if (null != configurer) {
331:                    configurer.configureBean(instance);
332:                }
333:            }
334:
335:            protected void checkPublishPermission() {
336:                SecurityManager sm = System.getSecurityManager();
337:                if (sm != null) {
338:                    sm.checkPermission(PUBLISH_PERMISSION);
339:                } else if (Boolean
340:                        .getBoolean(CHECK_PUBLISH_ENDPOINT_PERMISSON_PROPERTY)) {
341:                    AccessController.checkPermission(PUBLISH_PERMISSION);
342:                }
343:            }
344:
345:            public void publish() {
346:                publish(getAddress());
347:            }
348:
349:            public String getAddress() {
350:                return address;
351:            }
352:
353:            public void setAddress(String address) {
354:                this .address = address;
355:            }
356:
357:            public QName getEndpointName() {
358:                return endpointName;
359:            }
360:
361:            public void setEndpointName(QName endpointName) {
362:                this .endpointName = endpointName;
363:            }
364:
365:            public QName getServiceName() {
366:                return serviceName;
367:            }
368:
369:            public void setServiceName(QName serviceName) {
370:                this .serviceName = serviceName;
371:            }
372:
373:            public String getWsdlLocation() {
374:                return wsdlLocation;
375:            }
376:
377:            public void setWsdlLocation(String wsdlLocation) {
378:                this .wsdlLocation = wsdlLocation;
379:            }
380:
381:            public void setBindingUri(String binding) {
382:                this .bindingUri = binding;
383:            }
384:
385:            public String getBindingUri() {
386:                return this .bindingUri;
387:            }
388:
389:            public List<Interceptor> getOutFaultInterceptors() {
390:                return outFault;
391:            }
392:
393:            public List<Interceptor> getInFaultInterceptors() {
394:                return inFault;
395:            }
396:
397:            public List<Interceptor> getInInterceptors() {
398:                return in;
399:            }
400:
401:            public List<Interceptor> getOutInterceptors() {
402:                return out;
403:            }
404:
405:            public void setInInterceptors(List<Interceptor> interceptors) {
406:                in = interceptors;
407:            }
408:
409:            public void setInFaultInterceptors(List<Interceptor> interceptors) {
410:                inFault = interceptors;
411:            }
412:
413:            public void setOutInterceptors(List<Interceptor> interceptors) {
414:                out = interceptors;
415:            }
416:
417:            public void setOutFaultInterceptors(List<Interceptor> interceptors) {
418:                outFault = interceptors;
419:            }
420:
421:            public List<AbstractFeature> getFeatures() {
422:                if (features == null) {
423:                    features = new ArrayList<AbstractFeature>();
424:                }
425:                return features;
426:            }
427:
428:            public void setFeatures(List<AbstractFeature> features) {
429:                this .features = features;
430:            }
431:
432:            public Invoker getInvoker() {
433:                return invoker;
434:            }
435:
436:            public void setInvoker(Invoker invoker) {
437:                this .invoker = invoker;
438:            }
439:
440:            public void setImplementorClass(Class implementorClass) {
441:                this .implementorClass = implementorClass;
442:            }
443:
444:            public void setBindingConfig(BindingConfiguration config) {
445:                serverFactory.setBindingConfig(config);
446:            }
447:
448:            public BindingConfiguration getBindingConfig() {
449:                return serverFactory.getBindingConfig();
450:            }
451:
452:            /*
453:            //TODO JAX-WS 2.1
454:            public EndpointReference getEndpointReference(Element... referenceParameters) {
455:                // TODO
456:                throw new UnsupportedOperationException();
457:            }
458:
459:            public <T extends EndpointReference> T getEndpointReference(Class<T> clazz,
460:                                                                        Element... referenceParameters) {
461:                // TODO
462:                throw new UnsupportedOperationException();
463:            }
464:             */
465:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.