<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Developing Software Agents Using Enterprise JavaBeans</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Dejan Mitrovi c´</string-name>
          <email>dejan@dmi.uns.ac.rs</email>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mirjana Ivanovi c´</string-name>
          <email>mira@dmi.uns.ac.rs</email>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ali Al-Dahoud</string-name>
          <email>aldahoud@zuj.edu.jo</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Milan Vidakovi c´</string-name>
          <email>minja@uns.ac.rs</email>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>BCI'12, September 16-20, 2012, Novi Sad, Serbia.</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Al-Zaytoonah University of</institution>
          ,
          <addr-line>Jordan, P.O.Box 130 Amman, 11733</addr-line>
          <country country="JO">Jordan</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Copyright c 2012 by the paper's authors. Copying permitted only for private and</institution>
          ,
          <addr-line>academic purposes. This volume is published and copyrighted by its editors., Local Proceedings also appeared in ISBN 978-86-7031-200-5</addr-line>
          ,
          <institution>Faculty of Sciences, University of Novi Sad.</institution>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Department of Mathematics</institution>
          ,
          <addr-line>and Informatics</addr-line>
          ,
          <institution>Faculty of Sciences, University of Novi Sad</institution>
          ,
          <addr-line>Novi Sad</addr-line>
          ,
          <country country="RS">Serbia</country>
        </aff>
        <aff id="aff3">
          <label>3</label>
          <institution>Faculty of Technical Sciences, University of Novi Sad</institution>
          ,
          <addr-line>Novi Sad</addr-line>
          ,
          <country country="RS">Serbia</country>
        </aff>
      </contrib-group>
      <fpage>147</fpage>
      <lpage>149</lpage>
      <abstract>
        <p>Enterprise JavaBeans (EJB s) represent one of the most widely-used server-side component architectures for developing the business logic of enterprise-scale applications. Because of their runtime properties, such as scalability, security, and transactional integrity, Enterprise JavaBeans are also an excellent tool for building software agents. This paper outlines an architecture for developing and deploying EJB -based agents. The presented approach is designed in a way that employs all the benefits of EJB s, while, at the same time, it hides the underlying complexity from agent developers.</p>
      </abstract>
      <kwd-group>
        <kwd>Software agents</kwd>
        <kwd>multi-agent systems</kwd>
        <kwd>Java EE</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Categories and Subject Descriptors</title>
      <p>I.2.11 [Computing Methodologies]: Distributed
Artificial Intelligence—Multiagent systems</p>
    </sec>
    <sec id="sec-2">
      <title>General Terms</title>
    </sec>
    <sec id="sec-3">
      <title>1. INTRODUCTION</title>
      <p>
        Extensible Java EE-based Agent Framework (XJAF ) [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] is
a FIPA-compliant [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] multi-agent system (MAS ). Its main
tasks are to provide an efficient runtime environment for
its agents, as well as to provide external clients with an
easy access to the agent technology. Being implemented in
Java EE , XJAF harnesses many benefits of enterprise-scale
applications, such as scalability and runtime load-balancing,
security, data integrity, etc.
      </p>
      <p>
        A recent improvement of XJAF , named SOA-based MAS
(SOM ) [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], brings a high level of interoperability to the
system. By offering its functionalities in form of web services,
      </p>
      <p>SOM can be easily used by a wide variety of external clients.
Because it is a specification of web services, their
functionalities and interactions, SOM can be implemented using many
modern programming languages and platforms. The default
implementation is still provided in Java EE , including the
same set of benefits as the original XJAF .</p>
      <p>
        SOM is accompanied by an agent-oriented programming
language named Agent Language for SOM (ALAS ) [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The
two main goals of ALAS are to provide developers with
programming constructs that hide the complexity of agent
development, and to support truly heterogeneous agent
mobility [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ]. During the migration process, the ALAS source
code of a mobile agent is recompiled, on-the-fly, into the
executable code of the target platform. Currently supported
platforms include SOM , JADE, and PySOM, a Python-based
implementation of SOM .
      </p>
      <p>This paper presents recent improvement of the ALAS
compiler that enables the full utilization of Enterprise JavaBeans
(EJB ). SOM agents are now defined as stateless session
EJB s, and then passed on to the enterprise application server.
In this way, many advanced EJB functionalities, such as
scalability and object pooling, can be exploited with a
minimum programming effort. At the same time, the ALAS
programming language hides this complexity from the agent
developer.</p>
      <p>The rest of the paper is organized as follows. Section 2
provides an overview of the EJB technology. Recent
performance improvements of SOM and its agents are described in
Section 3. Finally, general conclusions and future research
directions are given in Section 4.
2.</p>
    </sec>
    <sec id="sec-4">
      <title>EJB TECHNOLOGY OVERVIEW</title>
      <p>
        Enterprise JavaBeans (EJB ) represent one of the most
important Java EE technologies for developing server-side
components. EJB s incorporate the business logic of
“distributed, transactional, secure and portable” [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] enterprise
applications based on Java EE . And yet, they are relatively
simple to develop and use.
      </p>
      <p>
        In general, there are two categories of EJB s (or, simply,
beans): message-driven, and session beans. Message-driven
beans are used in the context of Java Message Service JMS
[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], a Java EE technology for asynchronous messaging. In
XJAF and SOM , the agent communication infrastructure
is based heavily on exactly message-driven beans and JMS.
      </p>
      <p>Session beans can further be categorized into singleton,
stateless, and stateful. As its name suggests, there is a
single instance of a singleton bean per Java EE application.
Concurrent access is managed by the EJB container and
can be fine-tuned by the developer. Stateless beans
maintain no conversational state between distinct invocations.
They are well-suited for operations that can be executed in
a single method call. A stateful bean, on the other hand, is
used when the conversational state between different method
calls needs to be preserved.</p>
      <p>When it comes to the runtime efficiency of Java EE
applications, stateless session beans offer the best performance.
This is because modern enterprise application servers offer
the EJB pooling technique. The server maintains a pool
of pre-initialized stateless beans. Once a client request is
made, the server selects an instance from the pool, executes
the method, and then returns the bean instance back to the
pool. Therefore, an instance is recycled from the pool for
each new request, rather than having to be (re)allocated,
used, and then deallocated. The pool size is also
automatically adjusted to fit the number of concurrent requests. In
this way, only a small number of stateless EJB s can be used
to serve a large number of external clients.</p>
      <p>To achieve the best performance, and utilize the object
pooling technique, SOM agents are based on stateless
session EJB s.</p>
    </sec>
    <sec id="sec-5">
      <title>3. SOM AGENTS</title>
      <p>
        Originally, SOM (and its predecessor XJAF ) featured a
single stateless session EJB class named AgentHolder [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
When a request for a task execution is made, the system
first finds an agent that can solve the required task. Then,
it looks-up an instance of AgentHolder, passing it the
reference to the created agent object (a Plain Old Java Object
POJO ). The agent life-cycle is then managed by the
enterprise application server.
      </p>
      <p>This approach was convenient from the point of view of
agent developers. They were able to develop agents as POJO s,
without any knowledge or understanding of EJB s and the
whole enterprise application architecture. An obvious
disadvantage, however, is the extra allocation/deallocation of
the agent object – the exact step EJB pooling avoids.</p>
      <p>With the recent development of ALAS , this disadvantage
can be alleviated. The language compiler has now been
modified to output an EJB directly, and thus avoid the process
of “packing” a POJO inside of the AgentHolder bean.</p>
      <p>As an example, Listing 1 shows the source code of a simple
PingAgent written in ALAS . The agent exposes a single
service named ping which outputs the received parameter.</p>
      <p>Listing 1: ALAS source code of PingAgent
package ex amp les ;
agent PingAgent {
s e rv i ce void p i n g ( S t r i n g msg ) {</p>
      <p>l o g ( msg ) ; } } // o u t p u t s t h e m essage
From the given source code, the ALAS compiler produces
a stateless session EJB shown in Listing 2. The bean, also
marked as local-only features a single handler for all
incoming messages.</p>
      <p>Listing 2: Auto-generated EJB for PingAgent
@ S t a t e l e s s @LocalBean
public c l a s s PingAgent implements Agent {
public void onMessage ( ACLMessage msg ) {
i f ( msg . getCommand ( ) . e q u a l s ( ”Ping ” ) ) {
// unm arshal t h e a c t u a l c o n t e n t
Ping t a s k = XMLMapper . u n m a r s h a l l P i n g (
message . g e t C o n t e n t ( ) ) ;
S t r i n g param = t a s k . getMsg ( ) ;
a l a s . s t d l i b . j a v a . common . Log . w r i t e (</p>
      <p>param ) ;
return ; } } }</p>
      <p>This simple example demonstrates how ALAS represents
a solution that achieves the best runtime performance, while
hiding the complexity of enterprise applications from agent
developers.
4.</p>
    </sec>
    <sec id="sec-6">
      <title>CONCLUSIONS AND FUTURE WORK</title>
      <p>Enterprise JavaBeans represent one of the most
widelyused technologies for developing the server-side business logic
of large-scale applications. A category of EJB s, known as
stateless session EJB s, provide the best runtime performance
due to advanced object pooling and load-balancing
techniques offered by modern enterprise application servers. This
paper presents a solution for developing and deploying
software agents that are based exactly on stateless session EJB s.
At the same time, the ALAS agent-oriented programming
language hides the complexity of enterprise applications from
agent developers, allowing them to focus on problem-solving
tasks.</p>
      <p>Further improvements of the system will be focused on
efficient approaches and algorithms for preserving the agent
state between distinct running sessions. Additionally, the
existing JMS -based system will be replaced by a new and
recommended technique of asynchronous bean invocation.
The goal is to continuously improve the system’s
performance, while following the modern standards and
technologies.
5.</p>
    </sec>
    <sec id="sec-7">
      <title>ACKNOWLEDGMENTS</title>
      <p>This work is partially supported by Ministry of Education
and Science of the Republic of Serbia, through project no.
OI174023: “Intelligent techniques and their integration into
wide-spectrum decision support.”
6.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <article-title>[1] Enterprise JavaBeans technology homepage</article-title>
          . http://www.oracle.com/technetwork/java/javaee/ ejb/index.html.
          <source>Retrieved on July 15</source>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <article-title>[2] FIPA homepage</article-title>
          . http://www.fipa.org/.
          <source>Retrieved on July 15</source>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M.</given-names>
            <surname>Hapner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Burridge</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Sharma</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Fialli</surname>
          </string-name>
          , and
          <string-name>
            <given-names>K.</given-names>
            <surname>Stout. Java Message</surname>
          </string-name>
          <article-title>Service (JMS) specification</article-title>
          . http://www.oracle.com/technetwork/java/jms/ index.html,
          <year>April 2002</year>
          .
          <source>Retrieved on July 15</source>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>M.</given-names>
            <surname>Ivanovi</surname>
          </string-name>
          ´c, M. Vidakovi´c, D. Mitrovi´c, and
          <string-name>
            <given-names>Z.</given-names>
            <surname>Budimac</surname>
          </string-name>
          .
          <article-title>Evolution of Extensible Java EE-Based Agent Framework</article-title>
          . In G. Jezic,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kusek</surname>
          </string-name>
          , N.-T. Nguyen,
          <string-name>
            <given-names>R.</given-names>
            <surname>Howlett</surname>
          </string-name>
          , and L. Jain, editors,
          <source>Agent and Multi-Agent Systems. Technologies and Applications</source>
          , volume
          <volume>7327</volume>
          of Lecture Notes in Computer Science, pages
          <fpage>444</fpage>
          -
          <lpage>453</lpage>
          . Springer Berlin / Heidelberg,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>D.</given-names>
            <surname>Mitrovi</surname>
          </string-name>
          ´c, M. Ivanovi´c, and
          <string-name>
            <surname>M. Vidakovi</surname>
          </string-name>
          <article-title>´c. Introducing ALAS: a novel agent-oriented programming language</article-title>
          . In T. E. Simos, editor,
          <source>Proceedings of Symposium on Computer Languages</source>
          , Implementations, and
          <string-name>
            <surname>Tools</surname>
          </string-name>
          (SCLIT
          <year>2011</year>
          )
          <article-title>held within</article-title>
          <source>International Conference on Numerical Analysis and Applied Mathematics (ICNAAM</source>
          <year>2011</year>
          ),
          <source>AIP Conf. Proc. 1389</source>
          , pages
          <fpage>861</fpage>
          -
          <lpage>864</lpage>
          ,
          <year>September 2011</year>
          .
          <source>ISBN 978-0-7354-0956-9.</source>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>B. J.</given-names>
            <surname>Overeinder</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D. R. A. D.</given-names>
            <surname>Groot</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N. J. E.</given-names>
            <surname>Wijngaards</surname>
          </string-name>
          , and
          <string-name>
            <given-names>F. M. T.</given-names>
            <surname>Brazier</surname>
          </string-name>
          .
          <article-title>Generative mobile agent migration in heterogeneous environments</article-title>
          .
          <source>Scalable computing: practice and experience</source>
          ,
          <volume>7</volume>
          (
          <issue>4</issue>
          ):
          <fpage>89</fpage>
          -
          <lpage>99</lpage>
          ,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Vidakovi</surname>
          </string-name>
          <article-title>´c, B</article-title>
          . Milosavljevi´c, Z. Konjovi´c, and G. Sladi´c.
          <article-title>EXtensible Java EE-based agent framework and its application on distributed library catalogues</article-title>
          .
          <source>Computer science and information systems, ComSIS</source>
          ,
          <volume>6</volume>
          (
          <issue>2</issue>
          ):
          <fpage>1</fpage>
          -
          <lpage>16</lpage>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>