Sun River
Topics about Java SE, Servlet/JSP, JDBC, MultiThread, UML, Design Pattern, CSS, JavaScript, Maven, JBoss, Tomcat, ... |
Packages | |
javax.naming | Provides the classes and interfaces for accessing naming services. |
javax.naming.directory | Extends the javax.naming package to provide functionality for accessing directory services. |
javax.naming.event | Provides support for event notification when accessing naming and directory services. |
javax.naming.ldap | Provides support for LDAPv3 extended operations and controls. |
javax.naming.spi | Provides the means for dynamically plugging in support for accessing naming and directory services through the javax.naming and related packages.(Service Provider Interface) |
?????????????????????Atom / Consistency / Isolation / Durability
?????????????????????????????????????????
?????????????????????4 Isolation?Levels: Read uncommitted / Read Committed / Repeatable Read / Serializable?????????
??
Step1: Definition of Remote Interface
????????????? public interface Count extends EJBObject{
????????????????????????public int count() throws RomoteException;
????????????????????? }
Step2: Definition of Home Interface
???????????????public interface CountHome extends EJBHome {
????????????????????????Count create(int val) throws RemoteException, CreateException;
????????????????????? }
Step3: Definition of?Bean Class
???????????????Public class CountBean implements SessionBeam {
??????????????????????????public int val;
???????????????????????????public int count() {
??????????????????????????????System.out.println("count()");
????????????????????????????? return ++val;
??????????????????????????????}
?????????????? public void ejbCreate(int val) throws CreateException {
????????????????????????????this.val=val;
??????????????????????????? System.out.println("ejbCreate()");
???????????????????????? }
???????????????? public void ejbRemove(){};
???????????????? public void ejbActivate(){};
???????????????? public void ejbPassivate(){};
???????????????? public void setSessionContext(SessionContext ctx){};
????????? }
Step4: Definition of ejb-jar.xml
?????????????????? <ejb-jar>
????????????????????? <enterprise-beans>
??????????????????????? <session>
?????????????????????????? <ejb-name>Count</ejb-name>
??????????????????????????? <home>CountHome</home>
??????????????????????????? <remote>Count</remote>
??????????????????????????? <ejb-class>CountBean</ejb-class>
??????????????????????????? <session-type>Stateful</session-type>
??????????????????????????? <transaction-type>Container</transaction-type>
??????????????????????? </session>
????????????????????? </enterprise-beans>
????????????????????</ejb-jar>????????????????????
????????
摘要: 閱讀全文The following figure shows the life cycle of a stateful session bean. It has the following states:
The various state transitions as well as the methods available during the various states are discussed below.
--) Life Cycle of an Entity Bean
When developing an entity bean you can take advantage of the bean's relationship with the container to execute logic and optimizations outside the context of the bean's core logic. As the container creates and pools an instance, assigns data to it, executes bean methods, and eventually removes the instance, the container provides opportunities for your code to execute. This topic provides an overview of an entity bean's life cycle, pointing out some of these opportunities.
The following figure shows the life cycle of an entity bean. An entity bean has the following three states:
The various state transitions as well as the methods available during the various states are discussed below.
--) Dirty Read??
Dirty reads occur when transactions are allowed to see uncommitted changes to the data. In other words, changes made inside a transaction are visible outside the transactionbefore it is committed. If the changes are rolled back instead of being committed, it is possible for other transactions to have done work based on incorrect, transient data.
--) Nonrepeatable reads occur when:
?a) Transaction A reads a row
?b)Transaction B changes the row
?c)Transaction A reads the same row a second time and gets different results
--) Phantom reads occur when:??
a)Transaction A reads all rows that satisfy a WHERE condition???
b)Transaction B inserts an additional row that satisfies the same condition???
c)Transaction A reevaluates the WHERE condition and picks up the additional phantom row
--) READ_UNCOMMITTED?
By setting the isolation level to you are saying that you won't have a problem with reading data that might get rolled back. If this is unacceptable, use a more restrictive isolation level.
--) What is the default transaction isolation level ?
A. READ_UNCOMMITTED
B. READ_COMMITTED
C. REPEATABLE_READ
D. SERIALIZABLE
E. None of Above
Note:The Isolation level depends on the database in use.