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