Java Doc for Fiber.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) 


java.lang.Object
   com.sun.xml.ws.api.pipe.Fiber

Fiber
final public class Fiber implements Runnable(Code)
User-level thread. Represents the execution of one request/response processing.

JAX-WS RI is capable of running a large number of request/response concurrently by using a relatively small number of threads. This is made possible by utilizing a Fiber — a user-level thread that gets created for each request/response processing.

A fiber remembers where in the pipeline the processing is at, what needs to be executed on the way out (when processing response), and other additional information specific to the execution of a particular request/response.

Suspend/Resume

Fiber can be NextAction.suspend suspended by a Tube . When a fiber is suspended, it will be kept on the side until it is Fiber.resume(Packet) resumed . This allows threads to go execute other runnable fibers, allowing efficient utilization of smaller number of threads.

Context-switch Interception

FiberContextSwitchInterceptor allows Tube s and Adapter s to perform additional processing every time a thread starts running a fiber and stops running it.

Context ClassLoader

Just like thread, a fiber has a context class loader (CCL.) A fiber's CCL becomes the thread's CCL when it's executing the fiber. The original CCL of the thread will be restored when the thread leaves the fiber execution.

Debugging Aid

Because Fiber doesn't keep much in the call stack, and instead use Fiber.conts to store the continuation, debugging fiber related activities could be harder.

Setting the Fiber.LOGGER for FINE would give you basic start/stop/resume/suspend level logging. Using FINER would cause more detailed logging, which includes what tubes are executed in what order and how they behaved.

When you debug the server side, consider setting Fiber.serializeExecution to true, so that execution of fibers are serialized. Debugging a server with more than one running threads is very tricky, and this switch will prevent that. This can be also enabled by setting the system property on. See the source code.
author:
   Kohsuke Kawaguchi
author:
   Jitendra Kotamraju


Inner Class :public interface CompletionCallback

Field Summary
final public  Engineowner
    
public static volatile  booleanserializeExecution
     Set this boolean to true to execute fibers sequentially one by one.

Constructor Summary
 Fiber(Engine engine)
    

Method Summary
public  voidaddInterceptor(FiberContextSwitchInterceptor interceptor)
     Adds a new FiberContextSwitchInterceptor to this fiber.
public static  Fibercurrent()
     Gets the current fiber that's running.
public  ClassLoadergetContextClassLoader()
     Gets the context ClassLoader of this fiber.
public  PacketgetPacket()
     Gets the current Packet associated with this fiber.
public  booleanisAlive()
     Returns true if this fiber is still running or suspended.
public static  booleanisSynchronous()
     (ADVANCED) Returns true if the current fiber is being executed synchronously.

Fiber may run synchronously for various reasons.

public  booleanremoveInterceptor(FiberContextSwitchInterceptor interceptor)
     Removes a FiberContextSwitchInterceptor from this fiber.

The removal of the interceptor takes effect immediately after the current tube returns from its Tube.processRequest(Packet) or Tube.processResponse(Packet) , before the next tube begins processing.

So when the tubeline consists of X and Y, and when Y uninstalls an interceptor on the way out, then the order of execution will be as follows:

  1. Y.processResponse() (notice that this happens with interceptor.execute() in the callstack)
  2. interceptor gets uninstalled
  3. interceptor.execute() returns
  4. X.processResponse()
true if the specified interceptor was removed.
public synchronized  voidresume(Packet response)
     Wakes up a suspended fiber.

If a fiber was suspended from the Tube.processRequest(Packet) method, then the execution will be resumed from the corresponding Tube.processResponse(Packet) method with the specified response packet as the parameter.

If a fiber was suspended from the Tube.processResponse(Packet) method, then the execution will be resumed from the next tube's Tube.processResponse(Packet) method with the specified response packet as the parameter.

This method is implemented in a race-free way.

public  voidrun()
     DO NOT CALL THIS METHOD.
public synchronized  PacketrunSync(Tube tubeline, Packet request)
     Runs a given Tube (and everything thereafter) synchronously.

This method blocks and returns only when all the successive Tube s complete their request/response processing.

public  ClassLoadersetContextClassLoader(ClassLoader contextClassLoader)
     Sets the context ClassLoader of this fiber.
public  voidstart(Tube tubeline, Packet request, CompletionCallback completionCallback)
     Starts the execution of this fiber asynchronously.
public  StringtoString()
    

Field Detail
owner
final public Engine owner(Code)



serializeExecution
public static volatile boolean serializeExecution(Code)
Set this boolean to true to execute fibers sequentially one by one. See class javadoc.




Constructor Detail
Fiber
Fiber(Engine engine)(Code)




Method Detail
addInterceptor
public void addInterceptor(FiberContextSwitchInterceptor interceptor)(Code)
Adds a new FiberContextSwitchInterceptor to this fiber.

The newly installed fiber will take effect immediately after the current tube returns from its Tube.processRequest(Packet) or Tube.processResponse(Packet) , before the next tube begins processing.

So when the tubeline consists of X and Y, and when X installs an interceptor, the order of execution will be as follows:

  1. X.processRequest()
  2. interceptor gets installed
  3. interceptor.execute() is invoked
  4. Y.processRequest()



current
public static Fiber current()(Code)
Gets the current fiber that's running.

This works like Thread.currentThread . This method only works when invoked from Tube .




getContextClassLoader
public ClassLoader getContextClassLoader()(Code)
Gets the context ClassLoader of this fiber.



getPacket
public Packet getPacket()(Code)
Gets the current Packet associated with this fiber.

This method returns null if no packet has been associated with the fiber yet.




isAlive
public boolean isAlive()(Code)
Returns true if this fiber is still running or suspended.



isSynchronous
public static boolean isSynchronous()(Code)
(ADVANCED) Returns true if the current fiber is being executed synchronously.

Fiber may run synchronously for various reasons. Perhaps this is on client side and application has invoked a synchronous method call. Perhaps this is on server side and we have deployed on a synchronous transport (like servlet.)

When a fiber is run synchronously (IOW by Fiber.runSync(Tube,Packet) ), further invocations to Fiber.runSync(Tube,Packet) can be done without degrading the performance.

So this value can be used as a further optimization hint for advanced Tube s to choose the best strategy to invoke the next Tube . For example, a tube may want to install a FiberContextSwitchInterceptor if running async, yet it might find it faster to do Fiber.runSync(Tube,Packet) if it's already running synchronously.




removeInterceptor
public boolean removeInterceptor(FiberContextSwitchInterceptor interceptor)(Code)
Removes a FiberContextSwitchInterceptor from this fiber.

The removal of the interceptor takes effect immediately after the current tube returns from its Tube.processRequest(Packet) or Tube.processResponse(Packet) , before the next tube begins processing.

So when the tubeline consists of X and Y, and when Y uninstalls an interceptor on the way out, then the order of execution will be as follows:

  1. Y.processResponse() (notice that this happens with interceptor.execute() in the callstack)
  2. interceptor gets uninstalled
  3. interceptor.execute() returns
  4. X.processResponse()
true if the specified interceptor was removed. False ifthe specified interceptor was not registered with this fiber to begin with.



resume
public synchronized void resume(Packet response)(Code)
Wakes up a suspended fiber.

If a fiber was suspended from the Tube.processRequest(Packet) method, then the execution will be resumed from the corresponding Tube.processResponse(Packet) method with the specified response packet as the parameter.

If a fiber was suspended from the Tube.processResponse(Packet) method, then the execution will be resumed from the next tube's Tube.processResponse(Packet) method with the specified response packet as the parameter.

This method is implemented in a race-free way. Another thread can invoke this method even before this fiber goes into the suspension mode. So the caller need not worry about synchronizing NextAction.suspend and this method.




run
public void run()(Code)
DO NOT CALL THIS METHOD. This is an implementation detail of Fiber .



runSync
public synchronized Packet runSync(Tube tubeline, Packet request)(Code)
Runs a given Tube (and everything thereafter) synchronously.

This method blocks and returns only when all the successive Tube s complete their request/response processing. This method can be used if a Tube needs to fallback to synchronous processing.

Example:

 class FooTube extends 
AbstractFilterTubeImpl  {
 NextAction processRequest(Packet request) {
 // run everything synchronously and return with the response packet
 return doReturnWith(Fiber.current().runSync(next,request));
 }
 NextAction processResponse(Packet response) {
 // never be invoked
 }
 }
 

Parameters:
  tubeline - The first tube of the tubeline that will act on the packet.
Parameters:
  request - The request packet to be passed to startPoint.processRequest().The response packet to the request.
See Also:   Fiber.start(Tube,Packet,CompletionCallback)



setContextClassLoader
public ClassLoader setContextClassLoader(ClassLoader contextClassLoader)(Code)
Sets the context ClassLoader of this fiber.



start
public void start(Tube tubeline, Packet request, CompletionCallback completionCallback)(Code)
Starts the execution of this fiber asynchronously.

This method works like Thread.start .
Parameters:
  tubeline - The first tube of the tubeline that will act on the packet.
Parameters:
  request - The request packet to be passed to startPoint.processRequest().
Parameters:
  completionCallback - The callback to be invoked when the processing is finished and thefinal response packet is available.
See Also:   Fiber.runSync(Tube,Packet)




toString
public String toString()(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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