<?xml version="1.0"?>
<document>

<header>
  <title>Avalon And EJB Components</title>
  <subtitle>Using Avalon Components Inside Of EJB Components</subtitle>
  <authors>
    <person name="Avalon Documentation Team" email="avalon-
[EMAIL PROTECTED]"/>
  </authors>
</header>
<body>

<s1 title="Introduction">
<p>
  Avalon is a component framework, as EJB.
  There are lot of discussion about pro and cons
  of each framework.
  The following document tries show some
  way using both frameworks, benefiting
  for their strength.
</p>
<p>
  Today there is quite some common sense about designing EJB.
  You should design EJB in a coarse grained fashion. 
  Speaking in other words EJBs are designed to implement
  use cases, or business artifact.
</p>
<p>
  In contrast Avalon components could be designed a bit
  more fine-grained. Avalon components will be the toolbox
  reused across EJB projects.
</p>
<p>
  Moreover using Avalon components will give you the chance
  to reuse Avalon components in some other J2EE container, e.g.
  Servlet Container, or in some stand alone application.
</p>
<p>
  As Avalon components are not tied to an EJB container you are
  able to do JUnit testing of the Avalon components independently 
  from the EJBs.
</p>
<p>
  Thus it might be possible to reuse the JUnit test in a JMX
  environment to provide some continuse testing.
</p>
</s1>

<s1 title="Avalon EJB Frame">
<p>
valon components should not be too visible i
would suggest to use some delegate approach. As it was 
suggested by Peter and the AvalonEJBFrame.
</p>
<p>
  As side note this approach is not new and it was already
  used in the ExaliburTestCase which ties together the
  JUnit framwork and tha Avalon framework.
</p>

</s1>

<s1 title="Configuring the Avalon EJB Delegation">
<p>
  Using the Avalon framework usually requires some
  kind of configuration.
  The following sections presents some EJB conformant
  configuration options. 
</p>
<s2 title="Using ejb-jar.xml">
<p>
You might consider defining the avalon configuration in the ejb-jar.xml.
The ejb-jar.xml describes the characteristics of an EJB.
</p>
<p>
... the ejb-jar.xml snippet ...
</p>
<source><![CDATA[
...
<env-entry>
  <env-entry-name>AvalonEJBFrame</env-entry-name>
  <env-entry-type>java.lang.String</env-entry-type>
  <env-entry-value><![CDATA[
    <configuration>
      <logger>
        <!-- use the log4j logger -->
        <log4logger/>
        <!-- use the jdk14logger
        <jdk14logger/>
        -->
        <!-- optionally you may use the logkit logger 
             see ExcaliburTestCase, and avalon.excalibur.logger
        <logkit>
          <factories>...</factories>
          <targets>...</targets>
          <categories>...</categories>
        </logkit>
        -->
      </logger>
      <components>
        <component role="A.ROLE" class="x.y.z.AImpl1"/>
      </components>
    <configuration>
    ]]&gt;
  <env-entry-value>
</env-entry>
....
]]></source>
<p>
Accessing this configuration:
</p>
<source>
Context ctx = new InitialContext();
String xconfString = ctx.lookup( "java:comp/env/AvalonEJBFrame" );
Configuration xconf = ... // build configuration from xconfString
</source>
Note: prefix java:comp/env is part of the EJB spec and should be
portable across the different application servers.
</s2>

<s2 title="JNDI Lookup of Configuration">
<p>
Lookup the avalon configuration from the JNDI stored as DOM, or plain 
xml.
Using this configuration option you must define only a place holder
in the ejb-jar.xml defining where the configuration is has to be looked 
up
in the JNDI tree.
</p>
<p>
... the ejb-jar.xml snippet ...
</p>
<source><![CDATA[
...
<env-entry>
  <env-entry-name>AvalonEJBFrame</env-entry-name>
  <env-entry-type>java.lang.String</env-entry-type>
  <env-entry-value>avalon/xconf/a/b/c/EJB1.xconf</env-entry-value>
</env-entry>
....
]]></source>

</s2>
<s2 title="JNDI Lookup of AvalonEJBFrame">
<p>
You might consider another option looking up an
AvalonEJBFrame object from the JNDI. 
</p>
<p>
... the ejb-jar.xml snippet ...
</p>
<source><![CDATA[
<env-entry>
  <env-entry-name>AvalonEJBFrame</env-entry-name>
  <env-entry-type>java.lang.String</env-entry-type>
  <env-entry-value>avalon/xconf/a/b/c/AvalonEJBFrame</env-entry-value>
</env-entry>
....
]]></source>
</s2>
</s1>

<s1 title="Using the AvalonEJBFrame">

<s2 title="Using in a StatelessSessionBean">
<p>
The AvalonEJBFrame object is shared by all StatelessSessionBean 
instances.
This means that all avalon components should be ThreadSafe.
</p>
</s2>

<s2 title="Using in a StatefulSessionBean">
<p>
Each StatefulSessionBean instance has its own AvalonEJBFrame.
</p>
</s2>

<s2 title="Using in a EntityBean">
<p>
Each EntityBean instance has its own AvalonEJBFrame.
</p>
</s2>

</s1>

</body>

</document>



Huber Bernhard, email: [EMAIL PROTECTED], homepage: 
members.a1.net/berni_huber/index.html




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to