Java Doc for Tube.java in  » 6.0-JDK-Modules » jax-ws-runtime » com » sun » xml » ws » api » pipe » 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 » 6.0 JDK Modules » jax ws runtime » com.sun.xml.ws.api.pipe 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.sun.xml.ws.api.pipe.Tube

All known Subclasses:   com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl,
Tube
public interface Tube (Code)
Abstraction of the intermediate layers in the processing chain and transport.

What is a Tube ?

Tube is a basic processing unit that represents SOAP-level protocol handling code. Mutliple tubes are often put together in a line (it needs not one dimensional — more later), and act on Packet s in a sequential fashion.

Tube s run asynchronously. That is, there is no guarantee that Tube.processRequest(Packet) and Tube.processResponse(Packet) runs in the same thread, nor is there any guarantee that this tube and next tube runs in the same thread. Furthermore, one thread may be used to run multiple pipeline in turn (just like a real CPU runs multiple threads in turn.)

Tube examples

Transport is a kind of tube. It sends the Packet through, say, HTTP connection, and receives the data back into another Packet .

More often, a tube works like a filter. It acts on a packet, and then it tells the JAX-WS that the packet should be passed into another tube. It can do the same on the way back.

For example, XWSS will be a Tube . It will act on a request Packet , then perhaps wrap it into another Packet to encrypt the body and add a header, then the processing will go on to the next tube.

Yet another kind of filter tube is those that wraps LogicalHandler and SOAPHandler . These tubes are heavy-weight; they often consume a message in a packet and create a new one, and then pass it to the next tube.

There would be a Tube implementation that invokes Provider . There would be a Tube implementation that invokes a service method on the user's code. There would be a Dispatch implementation that invokes a Tube .

WS-MEX can be implemented as a Tube that looks for Message.getPayloadNamespaceURI and serves the request.

Tube Lifecycle

Pipeline is expensive to set up, so once it's created it will be reused. A pipeline is not reentrant; one pipeline is used to process one request/response at at time. The same pipeline instance may serve multiple request/response, if one comes after another and they don't overlap.

Where a need arises to process multiple requests concurrently, a pipeline gets cloned through TubeCloner . Note that this need may happen on both server (because it quite often serves multiple requests concurrently) and client (because it needs to support asynchronous method invocations.)

Created pipelines (including cloned ones and the original) may be discarded and GC-ed at any time at the discretion of whoever owns pipelines. Tubes can, however, expect at least one copy (or original) of pipeline to live at any given time while a pipeline owner is interested in the given pipeline configuration (in more concerete terms, for example, as long as a dispatch object lives, it's going to keep at least one copy of a pipeline alive.)

Before a pipeline owner dies, it may invoke Tube.preDestroy() on the last remaining pipeline. It is "may" for pipeline owners that live in the client-side of JAX-WS (such as dispatches and proxies), but it is a "must" for pipeline owners that live in the server-side of JAX-WS.

This last invocation gives a chance for some pipes to clean up any state/resource acquired (such as WS-RM's sequence, WS-Trust's SecurityToken), although as stated above, this is not required for clients.

Tube and state

The lifecycle of pipelines is designed to allow a Tube to store various state in easily accessible fashion.

Per-packet state

Any information that changes from a packet to packet should be stored in Packet (if such informaton is specific to your problem domain, then most likely Packet.invocationProperties .) This includes information like transport-specific headers.

Per-thread state

Any expensive-to-create objects that are non-reentrant can be stored either in instance variables of a Tube , or a static ThreadLocal .

The first approach works, because Tube is non reentrant. When a tube is copied, new instances should be allocated so that two Tube instances don't share thread-unsafe resources. Similarly the second approach works, since ThreadLocal guarantees that each thread gets its own private copy.

The former is faster to access, and you need not worry about clean up. On the other hand, because there can be many more concurrent requests than # of threads, you may end up holding onto more resources than necessary.

This includes state like canonicalizers, JAXB unmarshallers, SimpleDateFormat , etc.

Per-proxy/per-endpoint state

Information that is tied to a particular proxy/dispatch can be stored in a separate object that is referenced from a tube. When a new tube is copied, you can simply hand out a reference to the newly created one, so that all copied tubes refer to the same instance. See the following code as an example:

 class TubeImpl {
 // this object stores per-proxy state
 class DataStore {
 int counter;
 }
 private DataStore ds;
 // create a fresh new pipe
 public TubeImpl(...) {
 ....
 ds = new DataStore();
 }
 // copy constructor
 private TubeImpl(TubeImpl that, PipeCloner cloner) {
 cloner.add(that,this);
 ...
 this.ds = that.ds;
 }
 public TubeImpl copy(PipeCloner pc) {
 return new TubeImpl(this,pc);
 }
 }
 

Note that access to such resource may need to be synchronized, since multiple copies of pipelines may execute concurrently.

VM-wide state

static is always there for you to use.
See Also:   AbstractTubeImpl
See Also:   AbstractFilterTubeImpl
author:
   Kohsuke Kawaguchi
author:
   Jitendra Kotamraju





Method Summary
 Tubecopy(TubeCloner cloner)
     Creates an identical clone of this Tube .

This method creates an identical pipeline that can be used concurrently with this pipeline.

 voidpreDestroy()
     Invoked before the last copy of the pipeline is about to be discarded, to give Tube s a chance to clean up any resources.

This can be used to invoke PreDestroy lifecycle methods on user handler.

 NextActionprocessException(Throwable t)
     Acts on a exception and performs some clean up operations.

If a Tube.processRequest(Packet) , Tube.processResponse(Packet) , Tube.processException(Throwable) throws an exception, this method will be always invoked on all the Tube s in the remaining NextAction s.

On the server side, the Throwable thrown will be propagated to the top-most transport.

 NextActionprocessRequest(Packet request)
     Acts on a request and perform some protocol specific operation. TODO: exception handling semantics need more discussion
throws:
  WebServiceException - On the server side, this signals an error condition wherea fault reply is in order (or the exception gets eaten bythe top-most transport Adapter if it's one-way.)This frees each Tube from try/catching aWebServiceException in every layer.Note that this method is also allowed to returnNextAction.returnWith(Packet) witha Packet that has a fault as the payload.

On the client side, the WebServiceException thrownwill be propagated all the way back to the calling clientapplications.

 NextActionprocessResponse(Packet response)
     Acts on a response and performs some protocol specific operation.

Once a Tube.processRequest(Packet) is invoked, this method will be always invoked with the response, before this Tube processes another request.
Parameters:
  response - If the packet has a non-null message, it must bea valid unconsumed Message.




Method Detail
copy
Tube copy(TubeCloner cloner)(Code)
Creates an identical clone of this Tube .

This method creates an identical pipeline that can be used concurrently with this pipeline. When the caller of a pipeline is multi-threaded and need concurrent use of the same pipeline, it can do so by creating copies through this method.

Implementation Note

It is the implementation's responsibility to call TubeCloner.add(TubeTube) to register the copied pipe with the original. This is required before you start copying the other Tube references you have, or else there's a risk of infinite recursion.

For most Tube implementations that delegate to another Tube , this method requires that you also copy the Tube that you delegate to.

For limited number of Tube s that do not maintain any thread unsafe resource, it is allowed to simply return this from this method (notice that even if you are stateless, if you got a delegating Tube and that one isn't stateless, you still have to copy yourself.)

Note that this method might be invoked by one thread while another thread is executing the other process method. See the Codec.copy for more discussion about this.
Parameters:
  cloner - Use this object (in particular its TubeCloner.copy(Tube) methodto clone other pipe references you havein your pipe. See TubeCloner for more discussionabout why.always non-null Tube.
Parameters:
  cloner -




preDestroy
void preDestroy()(Code)
Invoked before the last copy of the pipeline is about to be discarded, to give Tube s a chance to clean up any resources.

This can be used to invoke PreDestroy lifecycle methods on user handler. The invocation of it is optional on the client side, but mandatory on the server side.

When multiple copies of pipelines are created, this method is called only on one of them.
throws:
  WebServiceException - If the clean up fails, WebServiceException can be thrown.This exception will be propagated to users (if this is client),or recorded (if this is server.)




processException
NextAction processException(Throwable t)(Code)
Acts on a exception and performs some clean up operations.

If a Tube.processRequest(Packet) , Tube.processResponse(Packet) , Tube.processException(Throwable) throws an exception, this method will be always invoked on all the Tube s in the remaining NextAction s.

On the server side, the Throwable thrown will be propagated to the top-most transport. The transport converts the exception to fault reply or simply logs in case of one-way MEP. If you are a filtering Tube like AbstractTubeImpl , you don't have to override the implementation). On the other hand, any intermediate Tube may want to convert the exception to a fault message.

On the client side, the Throwable thrown will be propagated all the way back to the calling client applications. (The consequence of that is that if you are a filtering Tube like AbstractTubeImpl , you don't have to override the implementation)
Parameters:
  t - A NextAction object that represents the next actionto be taken by the JAX-WS runtime.




processRequest
NextAction processRequest(Packet request)(Code)
Acts on a request and perform some protocol specific operation. TODO: exception handling semantics need more discussion
throws:
  WebServiceException - On the server side, this signals an error condition wherea fault reply is in order (or the exception gets eaten bythe top-most transport Adapter if it's one-way.)This frees each Tube from try/catching aWebServiceException in every layer.Note that this method is also allowed to returnNextAction.returnWith(Packet) witha Packet that has a fault as the payload.

On the client side, the WebServiceException thrownwill be propagated all the way back to the calling clientapplications. (The consequence of that is that if you area filtering Tube, you must not eat the exceptionthat was given to Tube.processException(Throwable) .
throws:
  RuntimeException - Other runtime exception thrown by this method mustbe treated as a bug in the tube implementation,and therefore should not be converted into a fault.(Otherwise it becomes very difficult to debug implementationproblems.)

On the server side, this exception should be most likelyjust logged. On the client-side it gets propagated to theclient application.

The consequence of this is that if a pipe callsinto an user application (such as SOAPHandleror LogicalHandler), where a RuntimeExceptionis *not* a bug in the JAX-WS implementation, it must be catchedand wrapped into a WebServiceException.
Parameters:
  request - The packet that represents a request message.If the packet has a non-null message, it must be a validunconsumed Message. This message represents theSOAP message to be sent as a request.

The packet is also allowed to carry no message, which indicatesthat this is an output-only request.(that's called "solicit", right? - KK)A NextAction object that represents the next actionto be taken by the JAX-WS runtime.




processResponse
NextAction processResponse(Packet response)(Code)
Acts on a response and performs some protocol specific operation.

Once a Tube.processRequest(Packet) is invoked, this method will be always invoked with the response, before this Tube processes another request.
Parameters:
  response - If the packet has a non-null message, it must bea valid unconsumed Message. This message representsa response to the request message passed toTube.processRequest(Packet) earlier.

The packet is also allowed to carry no message, which indicatesthat there was no response. This is used for things likeone-way message and/or one-way transports.TODO: exception handling semantics need more discussionA NextAction object that represents the next actionto be taken by the JAX-WS runtime.




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.