Жизненный цикл Enterprise Bean'ов

Sun micosystems, “Java EE 5 Tutorial. The Life Cycles of Enterprise Beans”, public translation into Russian from English More about this translation.

Another translations: into English. Translate into another language.

Participants

krolser266 points
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next next untranslated
1 2

Java EE 5 Tutorial. The Life Cycles of Enterprise Beans

Жизненный цикл Enterprise Bean'ов

History of edits (Latest: krolser 2 years, 6 months ago) §

The Life Cycles of Enterprise Beans

Жизненный цикл Enterprise Bean'ов

History of edits (Latest: krolser 2 years, 6 months ago) §

An enterprise bean goes through various stages during its lifetime, or life cycle. Each type of enterprise bean (stateful session, stateless session, or message-driven) has a different life cycle.

The descriptions that follow refer to methods that are explained along with the code examples in the next two chapters. If you are new to enterprise beans, you should skip this section and run the code examples first.

The Life Cycle of a Stateful Session Bean

Жизненный цикл Stateful Session Bean

History of edits (Latest: krolser 2 years, 6 months ago) §

Figure 20-3 illustrates the stages that a session bean passes through during its lifetime. The client initiates the life cycle by obtaining a reference to a stateful session bean. The container performs any dependency injection and then invokes the method annotated with @PostConstruct, if any. The bean is now ready to have its business methods invoked by the client.

На рисунке рисунок 20-3 отображены состояния сессионного бина, в которых он может находится на протяжении своего жизненного цикла. The client initiates the life cycle by obtaining a reference to a stateful session bean. Контейнер внедряет все зависимости, а затем вызывает метод с аннотацией @PostConstruct, если таковой имеется. Теперь bean готов выполнять методы, вызванные клиентом.

History of edits (Latest: krolser 2 years, 6 months ago) §

Figure 20-3 Life Cycle of a Stateful Session Bean (http://java.sun.com/javaee/5/docs/tutorial/doc/figures/ejbcon-statefulSessionBeanLifeCycle.gif)

Рисунок 20-3. http://java.sun.com/javaee/5/docs/tutorial/doc/figures/ejbcon-statefulSessionBeanLifeCycle.gif

History of edits (Latest: krolser 2 years, 6 months ago) §

While in the ready stage, the EJB container may decide to deactivate, or passivate, the bean by moving it from memory to secondary storage. (Typically, the EJB container uses a least-recently-used algorithm to select a bean for passivation.) The EJB container invokes the method annotated @PrePassivate, if any, immediately before passivating it. If a client invokes a business method on the bean while it is in the passive stage, the EJB container activates the bean, calls the method annotated @PostActivate, if any, and then moves it to the ready stage.

Когда бин находится в активном состоянии, контейнер может решить его деактевировать (уничтожеть) или перевести в пассивное состояние, т.е. перенести бин из памяти в дополнительное хранилище. (Typically, the EJB container uses a least-recently-used algorithm to select a bean for passivation.) Перед тем, как перевести бин в пассивное состояние, EJB контейнер вызывает метод аннотированный @PrePassivate, если таковой имеется. Если клиент вызывает бизнес-методы компонента, находящегося в пассивном состоянии, тогда EJB контейнер активизирует бин, вызывая метод аннотированный @PostActivate, если таковой имеется, а затем переводит его в активное состояние.

History of edits (Latest: krolser 2 years, 6 months ago) §

At the end of the life cycle, the client invokes a method annotated @Remove, and the EJB container calls the method annotated @PreDestroy, if any. The bean’s instance is then ready for garbage collection.

Для того, чтобы завершить жизненный цикл бина, клиент вызывает метод аннотированный @Remove, и EJB контейнер вызывает метод аннотированный @PreDestroy, если таковой имеется. После этого бин готов к удалению сборщиком мусора.

History of edits (Latest: krolser 2 years, 6 months ago) §

Your code controls the invocation of only one life-cycle method: the method annotated @Remove. All other methods in Figure 20-3 are invoked by the EJB container. See Chapter 34, Resource Connections for more information.

Клиентский код может вызывать только один метод, который влияет на жизненный цикл бина. Это метод анотированный @Remove. Остальные методы, пердставленные на рисунке 20-3 вызываются EJB контейнером. See Chapter 34, Resource Connections for more information.

History of edits (Latest: krolser 2 years, 6 months ago) §
Pages: ← previous Ctrl next next untranslated
1 2

© http://java.sun.com/javaee/5/docs/tutorial/doc/docinfo.html.