|
From: <jbo...@li...> - 2006-06-14 03:06:46
|
Author: mic...@jb...
Date: 2006-06-13 23:06:31 -0400 (Tue, 13 Jun 2006)
New Revision: 4758
Modified:
labs/trailblazers/trunk/EJB3/EEE.iws
labs/trailblazers/trunk/EJB3/docs/services/interceptor/index.html
labs/trailblazers/trunk/EJB3/lib/jboss-annotations-ejb3.jar
labs/trailblazers/trunk/EJB3/lib/jboss-ejb3.jar
labs/trailblazers/trunk/EJB3/lib/jboss-ejb3x.jar
labs/trailblazers/trunk/EJB3/src/trail/injection/CalculatorMDB.java
labs/trailblazers/trunk/EJB3/src/trail/interceptor/Tracer.java
Log:
Upgrade to RC7
Modified: labs/trailblazers/trunk/EJB3/EEE.iws
===================================================================
--- labs/trailblazers/trunk/EJB3/EEE.iws 2006-06-13 21:41:51 UTC (rev 4757)
+++ labs/trailblazers/trunk/EJB3/EEE.iws 2006-06-14 03:06:31 UTC (rev 4758)
@@ -134,93 +134,93 @@
</component>
<component name="FileEditorManager">
<leaf>
- <file leaf-file-name="index.html" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/docs/services/interceptor/index.html">
+ <file leaf-file-name="CalculatorBean.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/mdb/CalculatorBean.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="239" column="7" selection-start="7734" selection-end="7734" vertical-scroll-proportion="0.6621622">
+ <state line="14" column="54" selection-start="374" selection-end="400" vertical-scroll-proportion="0.025525525">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="Tracer.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/trail/interceptor/Tracer.java">
+ <file leaf-file-name="CalculationRecord.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/CalculationRecord.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="3" column="26" selection-start="74" selection-end="74" vertical-scroll-proportion="0.076576576">
- <folding>
- <element signature="imports" expanded="true" />
- </folding>
+ <state line="4" column="13" selection-start="67" selection-end="67" vertical-scroll-proportion="0.09985316">
+ <folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="CalculatorMBean.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/trail/jmx/CalculatorMBean.java">
+ <file leaf-file-name="CalculatorMDB.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/CalculatorMDB.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="7" column="13" selection-start="198" selection-end="198" vertical-scroll-proportion="0.15315315">
- <folding />
+ <state line="3" column="19" selection-start="65" selection-end="65" vertical-scroll-proportion="0.076576576">
+ <folding>
+ <element signature="imports" expanded="true" />
+ </folding>
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="CalculationRecord.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/trail/mdb/CalculationRecord.java">
+ <file leaf-file-name="InjectionRec.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/InjectionRec.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="4" column="13" selection-start="61" selection-end="61" vertical-scroll-proportion="0.1021021">
+ <state line="7" column="13" selection-start="135" selection-end="135" vertical-scroll-proportion="0.14977974">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="CalculatorBean.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/trail/mdb/CalculatorBean.java">
+ <file leaf-file-name="RecordManager.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/RecordManager.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="14" column="13" selection-start="359" selection-end="359" vertical-scroll-proportion="0.2807808">
+ <state line="2" column="17" selection-start="43" selection-end="43" vertical-scroll-proportion="0.04992658">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="RecordManager.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/trail/mdb/RecordManager.java">
+ <file leaf-file-name="RecordManagerBean.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/RecordManagerBean.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="13" selection-start="89" selection-end="89" vertical-scroll-proportion="0.1021021">
+ <state line="26" column="26" selection-start="645" selection-end="645" vertical-scroll-proportion="0.4743025">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="CalculationRecord.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/CalculationRecord.java">
+ <file leaf-file-name="Calculator.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/interceptor/Calculator.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="4" column="13" selection-start="64" selection-end="64" vertical-scroll-proportion="0.1021021">
+ <state line="4" column="17" selection-start="74" selection-end="74" vertical-scroll-proportion="0.1021021">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="Calculator.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/Calculator.java">
+ <file leaf-file-name="InterceptorCalculator.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/interceptor/InterceptorCalculator.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="17" selection-start="93" selection-end="93" vertical-scroll-proportion="0.12481645">
+ <state line="11" column="4" selection-start="205" selection-end="205" vertical-scroll-proportion="0.2042042">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="MdpojoCalculator.java" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/MdpojoCalculator.java">
+ <file leaf-file-name="Tracer.java" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/src/trail/interceptor/Tracer.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="14" column="13" selection-start="349" selection-end="349" vertical-scroll-proportion="0.2807808">
+ <state line="14" column="36" selection-start="379" selection-end="379" vertical-scroll-proportion="0.33183184">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="RecordManager.java" pinned="false" current="true" current-in-tab="true">
- <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/RecordManager.java">
+ <file leaf-file-name="index.html" pinned="false" current="true" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/docs/services/interceptor/index.html">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="13" selection-start="92" selection-end="92" vertical-scroll-proportion="0.1021021">
+ <state line="224" column="35" selection-start="7348" selection-end="7348" vertical-scroll-proportion="5.7177176">
<folding />
</state>
</provider>
@@ -516,6 +516,32 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
+ <option name="myItemId" value="PsiDirectory:$PROJECT_DIR$/src/trail/injection" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="EEE.ipr" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="EEE" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewModuleNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="PsiDirectory:$PROJECT_DIR$" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="PsiDirectory:$PROJECT_DIR$/src" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="PsiDirectory:$PROJECT_DIR$/src/trail" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
<option name="myItemId" value="PsiDirectory:$PROJECT_DIR$/src/trail/apptrans" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
@@ -674,15 +700,6 @@
<option name="HOST" value="localhost" />
<option name="PORT" value="5005" />
</configuration>
- <configuration selected="false" default="true" type="Application" factoryName="Application">
- <option name="MAIN_CLASS_NAME" />
- <option name="VM_PARAMETERS" />
- <option name="PROGRAM_PARAMETERS" />
- <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
- <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
- <option name="ALTERNATIVE_JRE_PATH" />
- <module name="" />
- </configuration>
<configuration selected="false" default="true" type="JUnit" factoryName="JUnit">
<module name="" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
@@ -711,6 +728,15 @@
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" />
</configuration>
+ <configuration selected="false" default="true" type="Application" factoryName="Application">
+ <option name="MAIN_CLASS_NAME" />
+ <option name="VM_PARAMETERS" />
+ <option name="PROGRAM_PARAMETERS" />
+ <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
+ <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
+ <option name="ALTERNATIVE_JRE_PATH" />
+ <module name="" />
+ </configuration>
</component>
<component name="SelectInManager" />
<component name="StarteamConfiguration">
@@ -755,12 +781,12 @@
</todo-panel>
</component>
<component name="ToolWindowManager">
- <frame x="33" y="23" width="1099" height="828" extended-state="0" />
+ <frame x="105" y="24" width="1099" height="828" extended-state="0" />
<editor active="true" />
<layout>
<window_info id="CVS" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33006993" order="7" />
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.25594673" order="0" />
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.26165557" order="0" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.32968536" order="1" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="8" />
@@ -846,111 +872,109 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
- <entry file="file://$PROJECT_DIR$/dd2/web/web.xml">
+ <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/CalculationRecord.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
+ <state line="4" column="13" selection-start="64" selection-end="64" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/dd/web/jboss-web.xml">
+ <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/Calculator.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
+ <state line="5" column="17" selection-start="93" selection-end="93" vertical-scroll-proportion="0.12481645">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/lifecycle/SessionRecord.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/MdpojoCalculator.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="2" column="13" selection-start="39" selection-end="39" vertical-scroll-proportion="0.04992658">
+ <state line="14" column="13" selection-start="349" selection-end="349" vertical-scroll-proportion="0.2807808">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/apptrans/ApptransCalculator.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/RecordManager.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="46" column="62" selection-start="1234" selection-end="1234" vertical-scroll-proportion="0.37237236">
+ <state line="5" column="13" selection-start="92" selection-end="92" vertical-scroll-proportion="0.08858859">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/interceptor/InterceptorCalculator.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/mdb/CalculationRecord.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="3" column="26" selection-start="74" selection-end="74" vertical-scroll-proportion="0.076576576">
- <folding>
- <element signature="imports" expanded="true" />
- </folding>
+ <state line="4" column="13" selection-start="61" selection-end="61" vertical-scroll-proportion="0.1021021">
+ <folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/docs/services/interceptor/index.html">
+ <entry file="file://$PROJECT_DIR$/src/trail/mdb/CalculatorBean.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="239" column="7" selection-start="7734" selection-end="7734" vertical-scroll-proportion="0.6621622">
+ <state line="14" column="54" selection-start="374" selection-end="400" vertical-scroll-proportion="0.025525525">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/interceptor/Tracer.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/CalculationRecord.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="3" column="26" selection-start="74" selection-end="74" vertical-scroll-proportion="0.076576576">
- <folding>
- <element signature="imports" expanded="true" />
- </folding>
+ <state line="4" column="13" selection-start="67" selection-end="67" vertical-scroll-proportion="0.09985316">
+ <folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/jmx/CalculatorMBean.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/CalculatorMDB.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="7" column="13" selection-start="198" selection-end="198" vertical-scroll-proportion="0.15315315">
- <folding />
+ <state line="3" column="19" selection-start="65" selection-end="65" vertical-scroll-proportion="0.076576576">
+ <folding>
+ <element signature="imports" expanded="true" />
+ </folding>
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/mdb/CalculationRecord.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/InjectionRec.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="4" column="13" selection-start="61" selection-end="61" vertical-scroll-proportion="0.1021021">
+ <state line="7" column="13" selection-start="135" selection-end="135" vertical-scroll-proportion="0.14977974">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/mdb/CalculatorBean.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/RecordManager.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="14" column="13" selection-start="359" selection-end="359" vertical-scroll-proportion="0.2807808">
+ <state line="2" column="17" selection-start="43" selection-end="43" vertical-scroll-proportion="0.04992658">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/mdb/RecordManager.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/injection/RecordManagerBean.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="13" selection-start="89" selection-end="89" vertical-scroll-proportion="0.1021021">
+ <state line="26" column="26" selection-start="645" selection-end="645" vertical-scroll-proportion="0.4743025">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/CalculationRecord.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/interceptor/Calculator.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="4" column="13" selection-start="64" selection-end="64" vertical-scroll-proportion="0.1021021">
+ <state line="4" column="17" selection-start="74" selection-end="74" vertical-scroll-proportion="0.1021021">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/Calculator.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/interceptor/InterceptorCalculator.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="17" selection-start="93" selection-end="93" vertical-scroll-proportion="0.12481645">
+ <state line="11" column="4" selection-start="205" selection-end="205" vertical-scroll-proportion="0.2042042">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/MdpojoCalculator.java">
+ <entry file="file://$PROJECT_DIR$/src/trail/interceptor/Tracer.java">
<provider selected="true" editor-type-id="text-editor">
- <state line="14" column="13" selection-start="349" selection-end="349" vertical-scroll-proportion="0.2807808">
+ <state line="14" column="36" selection-start="379" selection-end="379" vertical-scroll-proportion="0.33183184">
<folding />
</state>
</provider>
</entry>
- <entry file="file://$PROJECT_DIR$/src/trail/mdpojo/RecordManager.java">
+ <entry file="file://$PROJECT_DIR$/docs/services/interceptor/index.html">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="13" selection-start="92" selection-end="92" vertical-scroll-proportion="0.1021021">
+ <state line="224" column="35" selection-start="7348" selection-end="7348" vertical-scroll-proportion="5.7177176">
<folding />
</state>
</provider>
Modified: labs/trailblazers/trunk/EJB3/docs/services/interceptor/index.html
===================================================================
--- labs/trailblazers/trunk/EJB3/docs/services/interceptor/index.html 2006-06-13 21:41:51 UTC (rev 4757)
+++ labs/trailblazers/trunk/EJB3/docs/services/interceptor/index.html 2006-06-14 03:06:31 UTC (rev 4758)
@@ -66,9 +66,9 @@
<font size="2">
<p>The runtime services, such as transaction and security services, are applied to the bean objects at the method invocation time. Under the hood, those services are often implemented as interceptor methods managed by the container, which run before and after the target method invocation to check for service actions (e.g., to commit a transaction or throw a security exception).</p>
-
-<p>EJB 3.0 allows developers to write custom interceptors for EJB methods. That essentially gives you an extensible container. You can develop, reuse and ship your own services. Or, you can even re-implement the transaction and security services to override the container's default services offering. In this trail, we will discuss how EJB 3.0 interceptor works.</p>
+<p>EJB 3.0 allows developers to write custom interceptors for EJB methods. That essentially gives you an extensible container. You can develop, reuse and ship your own services. Or, you can even re-implement the transaction and security services to override the container's default services offering. In this trail, we will discuss how EJB 3.0 interceptor works.</p>
+
</font>
</td>
</tr>
@@ -92,11 +92,11 @@
</tr>
<tr>
<td><img width="37" border="0" src="../../images/transparent.gif"></td>
-<td class="description" width="500">
-<font size="2">
-
-<p>The sample application in this trail showcases two custom interceptors I developed for the session-based investment calculator. One interceptor limits the number of historic records to four. That is, if you click on the "calculate" button multiple times, you will only see up to 4 most recent calculation records below the calculator form. The other interceptor provides the trace and execution time for each bean method involved in the calculation. The trace is displayed at the bottom of the page.</p>
+<td class="description" width="500">
+<font size="2">
+<p>The sample application in this trail showcases two custom interceptors I developed for the session-based investment calculator. One interceptor limits the number of historic records to four. That is, if you click on the "calculate" button multiple times, you will only see up to 4 most recent calculation records below the calculator form. The other interceptor provides the trace and execution time for each bean method involved in the calculation. The trace is displayed at the bottom of the page.</p>
+
<p><center>
<FORM>
<INPUT type="button" value="Try the calculator" onClick="window.open('calculator.jsp','calculator','width=400,height=500')">
@@ -129,30 +129,30 @@
<td class="description" width="500">
<font size="2">
-<p>You can place a custom interceptor method inside the bean class. The method must be annotated with the <code>@AroundInvoke</code> tag and it is called by the container before any other business method in the bean object is invoked. The container passes the current invocation context to the interceptor method as the <code>ctx</code> object. From the invocation context, you can figure out the current bean object and the target method intercepted by this interceptor. In the following example, the interceptor method inspects whether there are more than 4 cached records in this session. If so, it erases the earliest record to make room for the new calculation record. The <code>ctx.proceed()</code> statement at the end of the method recursively instructs the runtime to move on to the next interceptor. If there is no more interceptors, the target method is executed.</p>
-
-<pre><code>
-@Stateful
-public class InterceptorCalculator implements Calculator, Serializable {
-
- // ... ...
-
- @AroundInvoke
- public Object limitStateSize (InvocationContext ctx)
- throws Exception {
-
- // Remove the earliest entry when the history
- // list gets too long
- if (starts.size() > 4) {
- starts.remove (0);
- ends.remove (0);
- growthrates.remove (0);
- savings.remove (0);
- results.remove (0);
- }
- return ctx.proceed();
- }
-}
+<p>You can place a custom interceptor method inside the bean class. The method must be annotated with the <code>@AroundInvoke</code> tag and it is called by the container before any other business method in the bean object is invoked. The container passes the current invocation context to the interceptor method as the <code>ctx</code> object. From the invocation context, you can figure out the current bean object and the target method intercepted by this interceptor. In the following example, the interceptor method inspects whether there are more than 4 cached records in this session. If so, it erases the earliest record to make room for the new calculation record. The <code>ctx.proceed()</code> statement at the end of the method recursively instructs the runtime to move on to the next interceptor. If there is no more interceptors, the target method is executed.</p>
+
+<pre><code>
+@Stateful
+public class InterceptorCalculator implements Calculator, Serializable {
+
+ // ... ...
+
+ @AroundInvoke
+ public Object limitStateSize (InvocationContext ctx)
+ throws Exception {
+
+ // Remove the earliest entry when the history
+ // list gets too long
+ if (starts.size() > 4) {
+ starts.remove (0);
+ ends.remove (0);
+ growthrates.remove (0);
+ savings.remove (0);
+ results.remove (0);
+ }
+ return ctx.proceed();
+ }
+}
</code></pre>
</font>
@@ -181,48 +181,48 @@
<td class="description" width="500">
<font size="2">
-<p>Another way to define interceptors is to put the interceptor method in a separate class and then annotate the target bean class with the <code>@Interceptor</code> tag. Here is an interceptor class that logs the call trace and execution time of all the method invocation in its target bean object. Recall that the <code>ctx.proceed()</code> call in the interceptor recursively invokes the next interceptor and the target method. Hence, the code in the <code>finally</code> is called after the target and downstream interceptors are all returned.</p>
-
-<pre><code>
-public class Tracer {
-
- @AroundInvoke
- public Object log (InvocationContext ctx)
- throws Exception {
-
- String className = ctx.getBean().getClass().getName();
- String methodName = ctx.getMethod().getName();
- String target = className + "." + methodName + "()";
-
- long start = System.currentTimeMillis();
- System.out.println ("Invoking " + target);
- try {
- return ctx.proceed();
- } catch(Exception e) {
- throw e;
- } finally {
- System.out.println("Exiting " + target);
- cal.setTrace(cal.getTrace() + "<br/>" +
- "Exiting " + target);
- long time = System.currentTimeMillis() - start;
- System.out.println("This method takes " +
- time + "ms to execute");
- }
- }
-}
-</code></pre>
-
-<p>Here is the <code>@Interceptor</code> annotation on the bean class.</p>
-
-<pre><code>
-@Stateful
-@Interceptors (Tracer.class)
-public class InterceptorCalculator implements Calculator, Serializable {
-
- // ... ...
-}
-</code></pre>
-
+<p>Another way to define interceptors is to put the interceptor method in a separate class and then annotate the target bean class with the <code>@Interceptor</code> tag. Here is an interceptor class that logs the call trace and execution time of all the method invocation in its target bean object. Recall that the <code>ctx.proceed()</code> call in the interceptor recursively invokes the next interceptor and the target method. Hence, the code in the <code>finally</code> is called after the target and downstream interceptors are all returned.</p>
+
+<pre><code>
+public class Tracer {
+
+ @AroundInvoke
+ public Object log (InvocationContext ctx)
+ throws Exception {
+
+ String className = ctx.getTarget().getClass().getName();
+ String methodName = ctx.getMethod().getName();
+ String target = className + "." + methodName + "()";
+
+ long start = System.currentTimeMillis();
+ System.out.println ("Invoking " + target);
+ try {
+ return ctx.proceed();
+ } catch(Exception e) {
+ throw e;
+ } finally {
+ System.out.println("Exiting " + target);
+ cal.setTrace(cal.getTrace() + "<br/>" +
+ "Exiting " + target);
+ long time = System.currentTimeMillis() - start;
+ System.out.println("This method takes " +
+ time + "ms to execute");
+ }
+ }
+}
+</code></pre>
+
+<p>Here is the <code>@Interceptor</code> annotation on the bean class.</p>
+
+<pre><code>
+@Stateful
+@Interceptors (Tracer.class)
+public class InterceptorCalculator implements Calculator, Serializable {
+
+ // ... ...
+}
+</code></pre>
+
<p> You can also use the <code>@Interceptors</code> annotation to specify multiple interceptor classes for the bean. Those interceptors are invoked in the order they appear on the annotation's attribute array. The interceptor method inside the bean class is invoked the last.</p>
</font>
@@ -248,22 +248,22 @@
</tr>
<tr>
<td><img width="37" border="0" src="../../images/transparent.gif"></td>
-<td class="description" width="500">
-<font size="2">
+<td class="description" width="500">
+<font size="2">
-<p>Server</p>
-
-<ul>
- <li><a href="code/Calculator.java.html">Calculator.java</a>: The session bean interface</li>
- <li><a href="code/InterceptorCalculator.java.html">InterceptorCalculatorBean.java</a>: The session bean with the history cache size limit interceptor method</li>
- <li><a href="code/Tracer.java.html">Tracer.java</a>: The interceptor class for the logging and tracing interceptor</li>
-</ul>
-
+<p>Server</p>
+
+<ul>
+ <li><a href="code/Calculator.java.html">Calculator.java</a>: The session bean interface</li>
+ <li><a href="code/InterceptorCalculator.java.html">InterceptorCalculatorBean.java</a>: The session bean with the history cache size limit interceptor method</li>
+ <li><a href="code/Tracer.java.html">Tracer.java</a>: The interceptor class for the logging and tracing interceptor</li>
+</ul>
+
<p>Client</p>
-
-<ul>
- <li><a href="code/calculator.jsp.html">calculator.jsp</a>: The JSP user interface</li>
-</ul>
+
+<ul>
+ <li><a href="code/calculator.jsp.html">calculator.jsp</a>: The JSP user interface</li>
+</ul>
</font>
</td>
</tr>
Modified: labs/trailblazers/trunk/EJB3/lib/jboss-annotations-ejb3.jar
===================================================================
(Binary files differ)
Modified: labs/trailblazers/trunk/EJB3/lib/jboss-ejb3.jar
===================================================================
(Binary files differ)
Modified: labs/trailblazers/trunk/EJB3/lib/jboss-ejb3x.jar
===================================================================
(Binary files differ)
Modified: labs/trailblazers/trunk/EJB3/src/trail/injection/CalculatorMDB.java
===================================================================
--- labs/trailblazers/trunk/EJB3/src/trail/injection/CalculatorMDB.java 2006-06-13 21:41:51 UTC (rev 4757)
+++ labs/trailblazers/trunk/EJB3/src/trail/injection/CalculatorMDB.java 2006-06-14 03:06:31 UTC (rev 4758)
@@ -2,7 +2,6 @@
import javax.ejb.*;
import javax.jms.*;
-import javax.annotation.*;
import java.util.StringTokenizer;
import trail.slsb.*;
Modified: labs/trailblazers/trunk/EJB3/src/trail/interceptor/Tracer.java
===================================================================
--- labs/trailblazers/trunk/EJB3/src/trail/interceptor/Tracer.java 2006-06-13 21:41:51 UTC (rev 4757)
+++ labs/trailblazers/trunk/EJB3/src/trail/interceptor/Tracer.java 2006-06-14 03:06:31 UTC (rev 4758)
@@ -10,8 +10,8 @@
public Object log (InvocationContext ctx)
throws Exception {
- InterceptorCalculator cal = (InterceptorCalculator) ctx.getBean();
- String className = ctx.getBean().getClass().getName();
+ InterceptorCalculator cal = (InterceptorCalculator) ctx.getTarget();
+ String className = ctx.getTarget().getClass().getName();
String methodName = ctx.getMethod().getName();
String target = className + "." + methodName + "()";
|