MqMsgque PACKAGE - the package-main is a single piece of code evaluated only once at application startup … More...
Functions | |
void | MqMain (void *code) |
Main entrypoint - start the application | |
MqMsgque PACKAGE - the package-main is a single piece of code evaluated only once at application startup …
Example from MyServer.java
→ The package-main configure the factory and start the server.
package example; import jvmkkernel.*; import jvmqmsgque.*; // package-item final class MyServer extends MqContextC implements MqServerSetupIF { // Factory Constructor public MyServer(MqContextC tmpl) { super(tmpl); } // service to serve all incoming requests for token "HLWO" class MyFirstCallback implements MqServiceIF { public void Callback(MqContextC ctx) { SendSTART(); SendSTR(ReadSTR() + " World"); SendRETURN(); } } // define a service as link between the token "HLWO" and the class "MyFirstService" public void ServerSetup() { ServiceCreate("HLWO", new MyFirstCallback()); } // ------------------------------------------------------------- // package-main public static void main(String[] argv) { // create the "MyServer" factory… and return the initial (top) object MqContextC srv = MqFactoryC.Add(MyServer.class).New(); try { srv.LinkCreate(argv); srv.ProcessEvent(MqWaitOnEventE.FOREVER); } catch (Throwable e) { srv.ErrorCatch(e); } srv.Exit(); } }
void MqMain | ( | void * | code | ) |
Main entrypoint - start the application
Tcl has a special requirement, for every new server-thread a new interpreter is created and
this interpreter source the toplevel file for initialization. This file is set on library startup and
can be changed with MqInitResetArg0. The problem is the server startup code from the toplevel. For internal
purpose this code should only be executed on application-startup (like the C main function)
and not for every thread again.