The overview of Apelon Server
The Apelon Server is an application server which provides various communication protocol such as TCP/IP, JDBC and so on to any application. The Apelon Server hides all the detailed implementation of message transfer from the application. It also supports heterogeneous databases flexibly. The Apelon Server currently supports ORACLE and DB2.
The Apelon Server provides an application class
called a {@link com.apelon.apelonserver.server.QueryServer
QueryServer} that is loaded dynamically into the Apelon Server framework when
the server starts up. Client api calls result in xml streams that are parsed by
the server and the appropriate methods are called in the application
class.
Client API
An application which sends a message to the Apelon Server needs to create one of connections. For example,
{@link com.apelon.apelonserver.client.ServerConnection ServerConnection} srvr_conn = new ServerConnectionSocket(host,port);
Once a socket connection is created, a client needs to extend {@link com.apelon.apelonserver.client.BasicQuery BasicQuery}. Since {@link com.apelon.apelonserver.client.BasicQuery BasicQuery} is an abstract class, the class which extends needs to implement getServerConnection() to return the socket connection. If the class which extends BasicQuery is SearchServer, then the client can send the message to the Apelon Server by calling overridden SearchServer.exeuteQuery().
{@link
com.apelon.apelonserver.client.ServerConnection ServerConnection} srvr_conn =
new {@link com.apelon.apelonserver.client.ServerConnectionSocket
ServerConnectionSocket}(host,port);
//save the socket connection to SearchServer which extends BasicQuery
SearchServer searchServer = new
SearchServer(srvr_conn);
// Since BasicQuery.executeQuery() is the protected method, sendQuery() actually calls BasicQuery.executeQuery()
searchServer.sendQuery(message);
Since the Apelon Server can maintain multiple QueryServer, the client should know which query the message is sent to. The Apelon Server maintains a header for each QueryServer. When the Apelon Server receives the query from a client, it extracts the header.
To set a header before sending a message to the Apelon Server, the client should call {@link com.apelon.apelonserver.client.BasicQuery BasicQuery}.setVersion().
If a client wants to send a message to the QueryServer whose header is “DTS:001”, then a client should call setVersion() with the header.
{@link
com.apelon.apelonserver.client.ServerConnection ServerConnection} srvr_conn =
new {@link com.apelon.apelonserver.client.ServerConnectionSocket
ServerConnectionSocket}(host,port);
//save the socket connection to SearchServer which extends BasicQuery
SearchServer searchServer = new
SearchServer(srvr_conn);
// set the header to send the message to QueryServer in Apelon Server whose header is “DTS:001”
searchServer.setVersion(“DTS:001”);
// Since BasicQuery.executeQuery()
is the protected method, sendQuery() actually calls BasicQuery.executeQuery()
searchServer.sendQuery(message);
{@link com.apelon.apelonserver.server.RemoteServer
RemoteServer} rs = new {@link com.apelon.apelonserver.server.RemoteServerJDBC
RemoteServerJDBC}(user, pass, host);
ServerConnection srvr_conn = new ServerConnectionJDBC(rs);
Once a JDBC connection is created, a client needs a class which extends {@link com.apelon.apelonserver.client.BasicQuery BasicQuery}. Since BasicQuery is an abstract class, the class which extends needs to implement getServerConnection() to return the socket connection. If the class which extends BasicQuery is SearchServer, then the client can send the message to databases by calling overridden SearchServer.exeuteQuery().
{@link com.apelon.apelonserver.server.RemoteServer RemoteServer}
rs = new RemoteServerJDBC(user, pass, host);
srvr_conn = new ServerConnectionJDBC(rs);
//save the JDBC connection to SearchServer which extends BasicQuery
SearchServer searchServer = new
SearchServer(srvr_conn);
// Since BasicQuery.executeQuery() is the protected method, sendQuery() actually calls BasicQuery.executeQuery()
SearchServer.sendQuery(message);
In JDBC connection, a client side and server side resides in a same machine.
For multiple JDBC connection, a caller should map {@link com.apelon.apelonserver.server.QueryServer QueryServer} and header by calling {@link com.apelon.apelonserver.server.RemoteServer RemoteServer}.setQueryServer() method. Since QueryServer in the server side means a database connection, if each query server is instantiated with a different JDBC connection parameter, the multiple JDBC connection can be programmed as follows.
{@link
com.apelon.apelonserver.server.RemoteServer RemoteServer} rs = new
RemoteServerJDBC(user, pass, host);
{@link
com.apelon.apelonserver.client.ServerConnection ServerConnection} srvr_conn =
new {@link com.apelon.apleonserver.client. ServerConnectionJDBC
ServerConnectionJDBC}(rs);
//save the socket connection to SearchServer which extends BasicQuery
SearchServer searchServer = new
SearchServer(srvr_conn);
//create matching rule between the client’s QueryServer class and the header
rs.setQueryServer(com.apelon.dts.server.QueryServer.class,
com.apelon.common.ApelonHeader.DTS1_HEADER);
// set the header to send the message to QueryServer in Apelon Server whose header is “DTS:001”
SearchServer.setVersion(“DTS:001”);
// Since BasicQuery.executeQuery() is the protected method, sendQuery() actually calls BasicQuery.executeQuery()
SearchServer.sendQuery(message);
RemoteServer rs2 = new
RemoteServerJDBC(user, pass, host);
ServerConnection sc = new
ServerConnectionJDBC(rs);
LinkServer fLinkServer =
NavServer.createInstance(sc);
//com.apelon.dts.server.LinkServer extends com.apelon.apelonserver.server.QueryServer
//create matching rule between the client’s QueryServer class and the header
rs2.setQueryServer(com.apelon.dts.server.LinkServer.class,
“DTS:002”);
fLinkServer.setVersion(“DTS:002”);
Server API
As mentioned above, the Apelon Server loads an application class called a {@link com.apelon.apelonserver.server.QueryServer QueryServer}. QueryServer basically has JDBC connections and passes the connections to an application class which extends QueryServer class by calling the following methods.
· {@link com.apelon.apelonserver.server.QueryServer QueryServer}.setConnection(Connection conn); //for single connection
· {@link com.apelon.apelonserver.server.QueryServer QueryServer}.setConnections(List conns); //for multiple connections
List conns consists of com.apelon.common.sql.ConnectionParams objects.
QueryServer extracts the method name from the query from a client and using reflection method, the method of the application class which extends QueryServer is executed. During the execution, the method can access the data through JDBC connections passed from QueryServer.
The configuration information is loaded from XML-based property file.