Java Doc for JEntitySwitch.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas_ejb » container » 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 » J2EE » JOnAS 4.8.6 » org.objectweb.jonas_ejb.container 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.objectweb.jonas_ejb.container.JEntitySwitch

All known Subclasses:   org.objectweb.jonas_ejb.container.JEntitySwitchCST,  org.objectweb.jonas_ejb.container.JEntitySwitchCRC,  org.objectweb.jonas_ejb.container.JEntitySwitchDB,
JEntitySwitch
abstract public class JEntitySwitch (Code)
JEntitySwitch is used internally to synchronize accesses to the entity context and thus to the entity bean instance. All parts common to EJBObject and EJBLocalObject should be here. Different policies can be applied to manage context/instance pairs: - only 1 pair (container manages the transaction isolation) - 1 pair for each transaction (transaction isolation managed by DataBase) - 2 pairs (1 for transactional accesses, 1 for non transaction accesses)
author:
   Philippe Durieux
author:
   Philippe Coq


Field Summary
final static  intALL_DONE
    
final protected static  longFEW_SECONDS
    
final static  intNOT_DONE
    
final static  intSTORED
    
protected  JEntityFactorybf
    
protected  ArrayListblockedtx
    
protected  intcountIH
    
protected  intcountIT
    
protected static  intcounter
    
protected  longdeadlockTimeout
    
protected  longestimestamp
     timestamp used to free objects when not used for a specified time.
protected  Stringident
    
protected  booleaninDirtyList
     True if this instance may have been modified outside transactions.
protected  longinactivityTimeout
     time in millisec.
protected  booleanisdetached
     True if this object is no longer referenced by its factory, i.e.
protected  booleanisremoved
     True if this object will be garbaged and must not be used any longer.
protected  booleanlazyregister
     true if we can differ the registration at first write.
protected  JEntityLocallocal
     The EJBLocalObject, or null if bean has no local interface.
protected  intlockpolicy
     Lock policy used for this entity bean.
protected  booleanmustReload
     True if instance has been modified by a Transaction.
protected  booleanmustStore
     True if a TX need this instance currently used outside tx When the last release is done, we must store this instance. Only used when txUpdate is false (i.e.
protected  TimerServicemyTimerService
    
protected  Objectpk
     The Primary Key for this bean instance.
protected  longreadTimeout
     time in millisec.
protected  booleanreentrant
     reentrant=true if a bean instance can be accessed concurrently in the same transaction, or outside transaction.
protected  JEntityRemoteremote
     The EJBObject, or null if bean has no remote interface.
protected  Transactionrunningtx
     transaction on which a Context has been registered.
protected  booleanshared
     shared=true if the bean can be modify outside this container.
protected  booleantodiscard
     True when context/instance has been discarded, to avoids that passivate store its state on storage.
protected  booleantxUpdates
     True if a transaction is mandatory for all modifying methods.
protected  intwaiters
    
protected  Transactionwritingtx
    

Constructor Summary
public  JEntitySwitch()
     empty constructor.

Method Summary
public  voidbindICtx(Transaction tx, JEntityContext bctx)
     bind a JEntityContext for a create method.
protected  voiddetachPk()
     Detach entity switch from PK list.
protected  voiddiscardContext(Transaction tx, boolean forgetpk, boolean pool)
     Discard instance/Context and free all objects.
abstract public  voidendIH()
    
public synchronized  voidforceDiscardICtx(Transaction tx)
    
public  JFactorygetBeanFactory()
    
public  TransactiongetBlockingTx(Transaction testedtx)
     Look if the specified transaction is blocked.
abstract  JEntityContextgetContext4Tx(Transaction tx)
    
public  TimerServicegetEntityTimerService()
    
public  JEntityContextgetICtx(Transaction tx, JEntityContext newctx)
     bind a JEntityContext for a remove method.
public  JEntityContextgetICtx(Transaction tx, boolean checkr)
     Get a context/instance associated with this transaction Called at each request on the bean (including remove)
Parameters:
  tx - - the Transaction object
Parameters:
  checkr - - true if we must check non-reentrance.
public  JEntityLocalgetLocal()
    
public  intgetPolicy()
    
public  ObjectgetPrimaryKey()
    
public  JEntityRemotegetRemote()
    
abstract public  intgetState()
     State of this instance.
public  voidinit(JEntityFactory bf, Object pk)
     constructor.
abstract protected  voidinitpolicy(JEntityFactory bf)
    
public  booleanlazyRegistering()
    
public synchronized  JEntityContextmapICtx(Transaction tx, JEntityContext bctx, boolean forced, boolean holdit, boolean checkreentrance)
     Map a context and its instance.
Parameters:
  tx - - the Transaction object
Parameters:
  bctx - - the JEntityContext to bind if not null
Parameters:
  forced - - force to take this context.
public  voidnotifyTimeout(Timer timer)
    
public synchronized  voidnotifyWriting(Transaction tx, JEntityContext bctx)
     This transaction has just modified this instance.
abstract public  intpassivateIH(boolean store, boolean passivate)
    
protected  voidregisterCtx(Transaction tx, JEntityContext bctx)
     register a Context on the transaction, as a Synchronization.
public synchronized  voidreleaseICtx(Transaction tx, boolean discard)
     Release a context/instance at end of request.
abstract  voidremoveContext4Tx(Transaction tx)
    
abstract  voidsetContext4Tx(Transaction tx, JEntityContext ctx)
    
public synchronized  booleanterminate(Transaction tx)
     Release completely this object, since another one will be used.
public synchronized  booleantryBindICtx(Transaction tx, JEntityContext bctx, boolean simple)
     Try to bind a JEntityContext if none already bound.
public synchronized  voidtxCompleted(Transaction tx, boolean committed)
     This transaction is now over.
abstract  voidwaitmyturn(Transaction tx)
    

Field Detail
ALL_DONE
final static int ALL_DONE(Code)



FEW_SECONDS
final protected static long FEW_SECONDS(Code)



NOT_DONE
final static int NOT_DONE(Code)



STORED
final static int STORED(Code)



bf
protected JEntityFactory bf(Code)
The Factory for this bean



blockedtx
protected ArrayList blockedtx(Code)
List of all transactions currently blocked by runningtx



countIH
protected int countIH(Code)
nb of non transacted requests running



countIT
protected int countIT(Code)
nb of transacted requests running



counter
protected static int counter(Code)



deadlockTimeout
protected long deadlockTimeout(Code)



estimestamp
protected long estimestamp(Code)
timestamp used to free objects when not used for a specified time.



ident
protected String ident(Code)



inDirtyList
protected boolean inDirtyList(Code)
True if this instance may have been modified outside transactions. Avoids to put it twice in dirty list. Only used for CS policy (non transacted modifying methods)



inactivityTimeout
protected long inactivityTimeout(Code)
time in millisec. to keep objects in memory when not used. After this time, objects are freed, if instances have been passivated before.



isdetached
protected boolean isdetached(Code)
True if this object is no longer referenced by its factory, i.e. it is no longer in the PK list.



isremoved
protected boolean isremoved(Code)
True if this object will be garbaged and must not be used any longer.



lazyregister
protected boolean lazyregister(Code)
true if we can differ the registration at first write. Cannot be true if shared or prefetch.



local
protected JEntityLocal local(Code)
The EJBLocalObject, or null if bean has no local interface.



lockpolicy
protected int lockpolicy(Code)
Lock policy used for this entity bean. Possible values are :
  • 0 = LOCK_CONTAINER_READ_UNCOMMITTED (1 instance)
  • 1 = LOCK_CONTAINER_SERIALIZED (1 instance)
  • 2 = LOCK_CONTAINER_READ_COMMITTED (2 instances)
  • 3 = LOCK_DATABASE (n instances)
  • 4 = LOCK_READ_ONLY (1 instance)
  • 5 = LOCK_CONTAINER_READ_WRITE (1 instance)
  • 6 = LOCK_CONTAINER_SERIALIZED_TRANSACTED (1 instance)



  • mustReload
    protected boolean mustReload(Code)
    True if instance has been modified by a Transaction. This means that reading outside transaction should reload it before use. Only used for DB and CRC policies (non transacted instance)



    mustStore
    protected boolean mustStore(Code)
    True if a TX need this instance currently used outside tx When the last release is done, we must store this instance. Only used when txUpdate is false (i.e. CS policy)



    myTimerService
    protected TimerService myTimerService(Code)
    The Timer Service



    pk
    protected Object pk(Code)
    The Primary Key for this bean instance.



    readTimeout
    protected long readTimeout(Code)
    time in millisec. to keep objects in memory without rereading them (for RO policy only)



    reentrant
    protected boolean reentrant(Code)
    reentrant=true if a bean instance can be accessed concurrently in the same transaction, or outside transaction.



    remote
    protected JEntityRemote remote(Code)
    The EJBObject, or null if bean has no remote interface.



    runningtx
    protected Transaction runningtx(Code)
    transaction on which a Context has been registered. Registration may be differed at first write in case of lazyregister=true. This ref is reset to null when the transaction is completed.



    shared
    protected boolean shared(Code)
    shared=true if the bean can be modify outside this container.



    todiscard
    protected boolean todiscard(Code)
    True when context/instance has been discarded, to avoids that passivate store its state on storage.



    txUpdates
    protected boolean txUpdates(Code)
    True if a transaction is mandatory for all modifying methods. In this case, all methods outside tranction is considered as read-only. Only CS policy has txUpdates=false.



    waiters
    protected int waiters(Code)
    nb of threads waiting (synchronization)



    writingtx
    protected Transaction writingtx(Code)
    transaction that has modified an instance




    Constructor Detail
    JEntitySwitch
    public JEntitySwitch()(Code)
    empty constructor. Object is initialized via init() because it is implemented differently according to jorm mappers.




    Method Detail
    bindICtx
    public void bindICtx(Transaction tx, JEntityContext bctx)(Code)
    bind a JEntityContext for a create method.
    Parameters:
      tx - - the Transaction object
    Parameters:
      bctx - - the JEntityContext to bind



    detachPk
    protected void detachPk()(Code)
    Detach entity switch from PK list. This should trigger cleaning memory from all these objects by garbage collector.



    discardContext
    protected void discardContext(Transaction tx, boolean forgetpk, boolean pool)(Code)
    Discard instance/Context and free all objects.
    Parameters:
      tx - - the Transaction object
    Parameters:
      forgetpk - - true if remove pk from the list
    Parameters:
      pool - - true if instance can be pooled.



    endIH
    abstract public void endIH()(Code)
    Called only for CS policy, after passivateIH



    forceDiscardICtx
    public synchronized void forceDiscardICtx(Transaction tx)(Code)



    getBeanFactory
    public JFactory getBeanFactory()(Code)
    the JFactory



    getBlockingTx
    public Transaction getBlockingTx(Transaction testedtx)(Code)
    Look if the specified transaction is blocked.
    Parameters:
      testedtx - Transaction we look for The blocking transaction



    getContext4Tx
    abstract JEntityContext getContext4Tx(Transaction tx)(Code)



    getEntityTimerService
    public TimerService getEntityTimerService()(Code)
    Obtains the TimerService associated for this Entity Bean (one / pk) a JTimerService instance.



    getICtx
    public JEntityContext getICtx(Transaction tx, JEntityContext newctx)(Code)
    bind a JEntityContext for a remove method. called in case of remove(pk) or remove(handle)
    Parameters:
      tx - - the Transaction object
    Parameters:
      newctx - - the JEntityContext to bind the BeanContext



    getICtx
    public JEntityContext getICtx(Transaction tx, boolean checkr)(Code)
    Get a context/instance associated with this transaction Called at each request on the bean (including remove)
    Parameters:
      tx - - the Transaction object
    Parameters:
      checkr - - true if we must check non-reentrance. the BeanContext



    getLocal
    public JEntityLocal getLocal()(Code)
    the underlaying EJBLocalObject



    getPolicy
    public int getPolicy()(Code)
    lock policy for this bean



    getPrimaryKey
    public Object getPrimaryKey()(Code)
    the Primary Key Object for this instance.



    getRemote
    public JEntityRemote getRemote()(Code)
    the underlaying EJBObject



    getState
    abstract public int getState()(Code)
    State of this instance. State values are 0=in-tx, 1=out-tx, 2=idle,3=passive, 4=removed. we don't synchronize this method to avoidjadmin blocks



    init
    public void init(JEntityFactory bf, Object pk)(Code)
    constructor. A new object is build when a new PK is known in the container, either when a new bean is created, or when a find occurs. For create(), PK is not known yet when this object is build.
    Parameters:
      bf - The Entity Factory
    Parameters:
      pk - The Primary Key



    initpolicy
    abstract protected void initpolicy(JEntityFactory bf)(Code)



    lazyRegistering
    public boolean lazyRegistering()(Code)
    true if lazy registering enabled.



    mapICtx
    public synchronized JEntityContext mapICtx(Transaction tx, JEntityContext bctx, boolean forced, boolean holdit, boolean checkreentrance)(Code)
    Map a context and its instance.
    Parameters:
      tx - - the Transaction object
    Parameters:
      bctx - - the JEntityContext to bind if not null
    Parameters:
      forced - - force to take this context. (case of create)
    Parameters:
      holdit - - increment count to hold it, a release will be calledlater.
    Parameters:
      checkreentrance - - true if we must check non-reentrance. JEntityContext actually mapped



    notifyTimeout
    public void notifyTimeout(Timer timer)(Code)
    Notify a timeout for this bean and this Pk
    Parameters:
      timer - timer whose expiration caused this notification.



    notifyWriting
    public synchronized void notifyWriting(Transaction tx, JEntityContext bctx)(Code)
    This transaction has just modified this instance. (CMP2 only) Called only if lazyRegister is set and not RO policy.
    Parameters:
      tx - transaction



    passivateIH
    abstract public int passivateIH(boolean store, boolean passivate)(Code)

    Parameters:
      store - True if want to store instance first (CS policy)
    Parameters:
      passivate - True if we want to passivate instance result of operation: ALL_DONE, STORED, or NOT_DONE



    registerCtx
    protected void registerCtx(Transaction tx, JEntityContext bctx)(Code)
    register a Context on the transaction, as a Synchronization. this will be used later to store instance state when needed : before a finder, or at beforeCompletion, and to release instance at commit.
    Parameters:
      tx - Transaction object
    Parameters:
      bctx - The Context to be registered



    releaseICtx
    public synchronized void releaseICtx(Transaction tx, boolean discard)(Code)
    Release a context/instance at end of request.
    Parameters:
      tx - - transaction associated to this context
    Parameters:
      discard - - instance must be discarded



    removeContext4Tx
    abstract void removeContext4Tx(Transaction tx)(Code)



    setContext4Tx
    abstract void setContext4Tx(Transaction tx, JEntityContext ctx)(Code)



    terminate
    public synchronized boolean terminate(Transaction tx)(Code)
    Release completely this object, since another one will be used. this occurs in case of create, when another EntitySwitch exist already.
    Parameters:
      tx - - the Transaction object



    tryBindICtx
    public synchronized boolean tryBindICtx(Transaction tx, JEntityContext bctx, boolean simple) throws ObjectNotFoundException(Code)
    Try to bind a JEntityContext if none already bound. Called by finder methods. This is actually kind of optimization. Can be bypassed if problems: just return false.
    Parameters:
      tx - - the Transaction object
    Parameters:
      bctx - The Entity Context
    Parameters:
      simple - True if simple finder method true if context has been bound to this EntitySwitch.



    txCompleted
    public synchronized void txCompleted(Transaction tx, boolean committed)(Code)
    This transaction is now over. We can dispose of the instance for another transaction or discard it. A special implementation exists for RO policy
    Parameters:
      tx - the transaction object
    Parameters:
      committed - true if transaction was committed.



    waitmyturn
    abstract void waitmyturn(Transaction tx)(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.