Markus Karg wrote:
Hi Markus
my comments are embedded
>
> Philippe,
>
> maybe that whole thing would be easier if there would be a public interface
> to the server. At the moment, the only public, documented way to talk to
> JOnAS from outside is to use the batch scripts. Why not making a public
> document that describes how to use all that what I can do with the scripts
> in Java ways? I mean, it would be best to tell the end user that there is a
> method "stopServer" and so on (and not methods in the administration tool),
> so everyone can do what he wants, and no one has to go over the
> administration tool to talk to the server (what is some kind of strange from
> my sight; I also do not talk to Microsoft Outlook if I want to talk to my
> POP3 server). This is part one of my idea.
I think that the public interface you want already exists it is
the AdmInterface which is a Remote interface that everybody
can use to act on the server. There is one instance of this remote
object on each EJBServer, and you can access to it via a JNDI lookup
on the name XXX_Adm (XXX = the value of the property jonas.name in
jonas.properties
file with default value = jonas)
We use it through the JonasAdmin Client but every body can do the same.
So I proposed to Miroslav to added a new method in this interface
that he (or everybody) will be able to use even is the JOnASAdmin will
not use
this new method.
Have a look to org.objectweb.jonas.adm directory and code
Of course we can extend this interface if needed.
Part two would be to start JOnAS
> by method call, not by JVM call, so JOnAS needs not to call System.exit()
> since JOnAS does not know of it he has exclusive rights on the JVM. This
> means, give that task that started the JVM the control of the JVM. If
> someone wants to start a new JVM, he has to make sure (by writing some kind
> of service control thread) that this JVM is killed if JOnAS is stopped. If
> someone does not start a new JVM (e. g. he wants to have JOnAS be run in the
> same JVM as some other services) JOnAS has no problem with this since it
> does not call System.exit(). Sad but true, what we need, is what the JVM
> lacks: WindowsNT, Linux and every other "good" OS has a facility where I can
> control services (start/pause/resume/stop). The JVM was not intended to run
> services (so tools like JServ where invented). Indeed, what we need is a
> layer between the JVM and services like JOnAS, that controls that services,
> but runs them inside the same VM. Maybe we should build an interest group
> and talk to the Java Communicty Process?
>
As we have already said earlier, in the current version of JOnAS
under development, we have rebuilt the JOnAS server from a set
of services and we have added the possibility for the JOnAS server
to launch additional user services. I put in attachement the
corresponding
documentation that will be in the next release.
I hope we are going in the direction you want.
I would like to react about one of your previous mail:
> How could JOnAS users contribute to
> JOnAS development if current, public discussed problems interfere with
> non-public
> plans (every minute of our discussion is wasted time and money then)?
> And if
> it is not intended to have JOnAS users contribute, why then making it
> open
> source? Just to let them fix bugs? O suggest (as I did some months before)
> totally opening the development process and having a fine grained
> schedule
> made public in the web. Why not using sourceforge? Why not having
> something
> like "JOnAS Community" that votes what to do and what not?
there is no private plan for JonAS, we have already said that we were
currently working on a new version of JOnAS that will provide:
- the new service architecture (as previously said)
- Integration of the J2ee Connector achitecture,
- JonasAdministration via JMX and graphical tool
- a first version of integration of RMI/IIOP
we hope to improve the deploiement process.
JORM will come a little later
Most of these developments were made by external contributors
and we are currently integrating theses contributions.
Everybody can contribute to JOnAS, everybody can read the source code,
can rebuilt the product, can make prototypes, send the results of their
experimentation.
It is also true that we have received contributions we haven't integrate
in JOnAS because they were too specific or uncompletly tested.
Why not using sourceforge? it is surely a good idea, but the response
is for historical reason when we started sourceforge didn't exist.
The problem now is to know if it is worth to spend time and energy
to migrate to new processes? I don't know, for me, I prefer spend
this time to improve the JOnAS versions and add new functionalities
in the product or make it the best Opensource EJB Server in the world,
if possible!
I want to finish by telling you that I have promised to give
you a list of JOnAS that a client must seen instaed of the whole
jonas.jar,
I must admit that I have begun to work on it but I have switched
because I have had the opportunity to test the JCA integration with
a real J2ee Resource Adapter so I have stopped the previous work, this
is why you haven't
received response.
Best rgards,
--
Philippe
Philippe Coq Evidian Phone: (33) 04 76 29 78 49
Bull S.A - 1 rue de Provence - 38432 Echirolles Cedex France
Download our EJBServer at http://www.objectweb.org
Title: JOnAS Services
JOnAS Services
Target Audience and Rationale
This chapter is dedicated to advanced JOnAS users who need some "external" services to be run together with the EJB server. A service is something that may be initialized, started and stopped. JOnAS itself already defines a set of services, some of them being cornerstones of the EJB Server. The JOnAS pre-defined services are the Transaction Manager, the Security Manager, the Database Service, the JMS Service, and the Ejb Service, all of them being used by most of the EJB applications.
Some EJB application developers may need to access other services for their components. Examples of such services are a Web container, a Versant container, ... Thus, it is important that such services could be run together with the EJB server. To achieve that, you have the possibility to define it as a JOnAS service.
This chapter describes how to define a new JOnAS service, and how to specify which service should be started with the EJB server.
Introducing a new Service
The main principle for defining a new JOnAS service is to encapsulate it in a class whose interface is well known by JOnAS. More precisely, such a class allows to initialize, start and stop the service. Then you should make JOnAS aware of such a service by modifying the jonas.properties file.
Defining the Service class
A JOnAS service is represented by a class that extends the abstract
class org.objectweb.jonas.sm.AbsServiceImpl, and thus should
implement the three following abstract methods
public void doInit(Context ctx) throws ServiceException;public void doStart() throws ServiceException;public void doStop() throws ServiceException;
It should also define a public constructor with a String argument
representing the service name and which calls the constructor of
the superclass org.objectweb.jonas.sm.AbsServiceImpl.
These methods will be called by JOnAS for initializing, starting and stopping the service. Configuration parameters are provided to the initialisation method through a naming context. This naming context is built from properties defined in the jonas.properties file as explained in the section below.
The Service class should look like the following:
package a.b;
import java.naming.Context;
import java.naming.NamingException;
import org.objectweb.jonas.sm.AbsServiceImpl;
import org.objectweb.jonas.sm.ServiceException;
.....
public class MyService extends AbsServiceImpl {
.....
public MyService(String name) {
super(name);
}
public void doInit(Context ctx) throws ServiceException {
try {
String p1 = ctx.lookup("p1");
.....
} catch (NamingException e) {
throw new ServiceException("....", e);
}
.....
}
public void doStart() throws ServiceException {
.....
}
public void doStop() throws ServiceException {
.....
}
}
Modifying the jonas.properties file
In the jonas.properties file, you should define your service and
specify its initialization parameters. The first step is to choose
a name for the service (e.g. "serv1"), and then
- add this name to the jonas.services property: this property defines the set of services (comma separated) that will be started with JOnAS, in the order of this list.
- add a jonas.service.serv1.class property specifying the service class.
- add as many jonas.service.serv1.XXX properties specifying the service initialization parameters, that will be made available to the service class via the Context argument of the doInit method.
This is illustrated below:
jonas.services .......,serv1
jonas.service.serv1.class a.b.MyService
jonas.service.serv1.p1 value
Using the New Service
The new service has been given a name in jonas.properties. With this name, it is possible to get a reference on the service implementation class by using the ServiceManager interface: getService(name). Here after is an example of accessing a Service:
import org.objectweb.jonas.sm.ServiceException;
import org.objectweb.jonas.sm.ServiceManager;
MyService sv = null;
// Get a reference on MyService.
try {
sv = (MyService) ServiceManager.getInstance().getService("serv1");
} catch (ServiceException e) {
Trace.errln("Cannot find MyService:"+e);
}
Advanced Understanding
The reader may refer to the JOnAS sources for more details about the classes mentionned in this section.
JOnAS built-in services
The JOnAS existing services are the following:
| Service name | Service class |
| ejb | EJBServiceImpl |
| dbm | DataBaseServiceImpl |
| jms | JmsServiceImpl |
| jtm | TransactionServiceImpl |
| security | JonasSecurityServiceImpl |
Tracing, Naming and Orb are currently not defined as services, this will be the case in a near future. All these services except jms are mandatory for a JOnAS server. They are launched in the following order: security, jtm, dbm, jms, ejb (since dbm depends on jtm, jms depends on jtm, and ejb depends on security, jtm and jms). Thus a jonas.properties file now looks like the following:
jonas.name jonas
jonas.orb.port 0
jonas.services security,jtm,dbm,jms,ejb,serv1
jonas.service.dbm.class org.objectweb.jonas.dbm.DataBaseServiceImpl
jonas.service.dbm.datasources Oracle1
jonas.service.ejb.class org.objectweb.jonas.container.EJBServiceImpl
jonas.service.ejb.descriptors ejb-jar.xml
jonas.service.jms.class org.objectweb.jonas.jms.JmsServiceImpl
jonas.service.jms.mom org.objectweb.jonas_jms.JmsAdminForJoram
jonas.service.jms.collocated true
jonas.service.jms.url joram://localhost:16010
jonas.service.jms.threadpoolsize 10
jonas.service.jms.topics sampleTopic
jonas.service.jms.queues
jonas.service.jtm.class org.objectweb.jonas.jtm.TransactionServiceImpl
jonas.service.jtm.remote false
jonas.service.jtm.timeout 60
jonas.service.security.class org.objectweb.jonas.security.JonasSecurityServiceImpl
jonas.service.serv1.class a.b.MyService
jonas.service.serv1.p1 John
The Service interface
Each JOnAS Service class extends the
org.objectweb.jonas.sm.AbsServiceImpl class, which
implements the org.objectweb.jonas.sm.Service
interface. The Service interface is the following:
- public void init(Context ctx) throws ServiceException;
- public void start() throws ServiceException;
- public void stop() throws ServiceException;
- public boolean isStarted();
- public String getName();
The ServiceException
For the purpose of Services, the
org.objectweb.jonas.sm.ServiceException exception
is defined. Its type is java.lang.RuntimeException.
and it may encapsulate any java.lang.Throwable.
The ServiceManager
The org.objectweb.jonas.sm.ServiceManager class
is responsible for creating, initializing and launching the services.
It may also return a service from its name and list all the services.
Dynamic Services
A dynamic JOnAS Service is a service which is launched in a
new thread. Instead of extending
org.objectweb.jonas.sm.AbsServiceImpl, it should
extend org.objectweb.jonas.sm.AbsDynamicServiceImpl, and
the service start should be implemented in the run()
method instead of in the doStart() one.
So a JOnAS dynamic Service is represented by a class that extends the
abstract class
org.objectweb.jonas.sm.AbsDynamicServiceImpl, and thus
should implement the three following abstract methods
public void doInit(Context ctx) throws ServiceException;public void run() throws ServiceException;public void doStop() throws ServiceException;
