<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://luminoussheep.net/mediawiki/index.php?action=history&amp;feed=atom&amp;title=EJB_Life_Cycle</id>
	<title>EJB Life Cycle - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://luminoussheep.net/mediawiki/index.php?action=history&amp;feed=atom&amp;title=EJB_Life_Cycle"/>
	<link rel="alternate" type="text/html" href="https://luminoussheep.net/mediawiki/index.php?title=EJB_Life_Cycle&amp;action=history"/>
	<updated>2026-04-16T19:04:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://luminoussheep.net/mediawiki/index.php?title=EJB_Life_Cycle&amp;diff=54&amp;oldid=prev</id>
		<title>Martin: Created page with &quot;= EJB 3.0 = Stateless 3 Stateful 3 == Stateless == * Can be created and destroyed with each...&quot;</title>
		<link rel="alternate" type="text/html" href="https://luminoussheep.net/mediawiki/index.php?title=EJB_Life_Cycle&amp;diff=54&amp;oldid=prev"/>
		<updated>2021-09-14T21:25:19Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= EJB 3.0 = &lt;a href=&quot;/mediawiki/index.php/File:Stateless-lifecycle-3.png&quot; title=&quot;File:Stateless-lifecycle-3.png&quot;&gt;frame|Stateless 3&lt;/a&gt; &lt;a href=&quot;/mediawiki/index.php/File:Stateful-lifecycle-3.png&quot; title=&quot;File:Stateful-lifecycle-3.png&quot;&gt;frame|Stateful 3&lt;/a&gt; == Stateless == * Can be created and destroyed with each...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= EJB 3.0 =&lt;br /&gt;
[[Image:stateless-lifecycle-3.png|frame|Stateless 3]]&lt;br /&gt;
[[Image:stateful-lifecycle-3.png|frame|Stateful 3]]&lt;br /&gt;
== Stateless ==&lt;br /&gt;
* Can be created and destroyed with each call - unlikely&lt;br /&gt;
* Only one client per running bean&lt;br /&gt;
=== Create ===&lt;br /&gt;
# Must have no arg constructor (Class.newInstance() calls this)&lt;br /&gt;
# Resources marked with annotations injected&lt;br /&gt;
# Method called annotated with @javax.annotation.PostConstruct or specified in the deployment descriptor&lt;br /&gt;
## contract: void, no args, no checked exceptions&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;post-construct&amp;gt;&lt;br /&gt;
  &amp;lt;lifecycle-callback-method&amp;gt;postCreate&amp;lt;/lifecycle-callback-method&amp;gt;&lt;br /&gt;
&amp;lt;/post-construct&amp;gt;&lt;br /&gt;
&amp;lt;pre-destroy&amp;gt;&lt;br /&gt;
  &amp;lt;lifecycle-callback-method&amp;gt;tidyUp&amp;lt;/lifecycle-callback-method&amp;gt;&lt;br /&gt;
&amp;lt;/pre-destroy&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Destroy ===&lt;br /&gt;
* methods marked with @PreDestroy&lt;br /&gt;
** must be only one void, no args, no checked exceptions&lt;br /&gt;
&lt;br /&gt;
=== Exceptions ===&lt;br /&gt;
* System exception =&amp;gt; Bean is destroyed and @PreDestroy is not called&lt;br /&gt;
** System exception is any unchecked exception (which isn&amp;#039;t annotated with @ApplicationException)&lt;br /&gt;
&lt;br /&gt;
== MDB == &lt;br /&gt;
Essentially the same as stateless&lt;br /&gt;
&lt;br /&gt;
= EJB 2.0 =&lt;br /&gt;
[[Image:stateful-lifecycle.png|frame|Stateful 2.0]]&lt;br /&gt;
= Stateless =&lt;br /&gt;
* same lifecycle as EJB 3&lt;br /&gt;
clients can call remove - this invalidates the bean for this client and returns it to the pool&lt;br /&gt;
&lt;br /&gt;
= Stateful =&lt;br /&gt;
* same lifecycle as EJB 3 different interface&lt;br /&gt;
java serialisation equivalent technology used to passivate and store bean state.&lt;br /&gt;
* represents client state - cached but not (may be passivated - stored temporarily)&lt;br /&gt;
* passivate stores state to filesystem&lt;br /&gt;
&lt;br /&gt;
== Create EJB ==&lt;br /&gt;
#newInstance()&lt;br /&gt;
#setSessionContext(sc)&lt;br /&gt;
#ejbCreate()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Start Transaction ==&lt;br /&gt;
#afterBegin()&lt;br /&gt;
&lt;br /&gt;
== Commit Transaction ==&lt;br /&gt;
#beforecompletion()&lt;br /&gt;
#afterCompletion(true)&lt;br /&gt;
&lt;br /&gt;
== Rollback Transaction ==&lt;br /&gt;
#afterCompletion(false)&lt;br /&gt;
&lt;br /&gt;
== Passivate ==&lt;br /&gt;
#ejbPassivate()&lt;br /&gt;
* Transaction state, session context etc are maintained though passivation&lt;br /&gt;
&lt;br /&gt;
== Activate ==&lt;br /&gt;
#ejbActivate()&lt;br /&gt;
* transients are undefined when reactivated - unlike serialisation&lt;br /&gt;
&lt;br /&gt;
== Client finished - calls remove() ==&lt;br /&gt;
#ejbRemove()&lt;br /&gt;
&lt;br /&gt;
== Timeout ==&lt;br /&gt;
Container may call @PreDestroy but this isn&amp;#039;t required by spec&lt;/div&gt;</summary>
		<author><name>Martin</name></author>
	</entry>
</feed>