Home of Onyx Server
DnD Networks has migrated to their own dedicated server. This could bring some instability in the system during august. please report any issues using the help desk.
DnD team is currently working on a new project: Onyx Lite. More infos soon.
Onyx is a service container. Services are contained in the service naming service and directory. Onyx implements its own JNDI.
Initial Context Class implementation: com.onyx.jndi2.ServiceInitialContext
This initial context accepts POJO and transforms them as service.
This service are exposed via REST and JMX. (XML-RPC and SOAP are in project). They can be private or public.
Tutorial:
1) Creation of the POJO:
public static class Hola {
protected int value = 0;
public Hola(){
this.value = 12;
}
public int getValue(){
return value;
}
public void setValue(int value){
this.value=value;
}
}
2) Registration of the POJO in the Onyx Context:
import com.onyx.jndi2.ServiceInitialContext;
...
ServiceInitialContext context = new ServiceInitialContext();
context.bind("hola", new Hola());
The POJO Hola is now a service registered under the name "Hola".
3) Access to the service Hola
There is several ways to access this service.
a) via JMX:
First, we need to create the service interface to the object. (you can find it in the onyx service browser at http://localhost:9900)
package com.onyx.service;
public interface Hola {
public int getValue();
public void setValue(int i);
}
Now, let s access the JNDI and get a reference on the service "Hola":
Hashtable
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.onyx.jndi2.ServiceInitialContextFactory");
//jmx url of the onyx jndi
env.put(Context.PROVIDER_URL,"jmx://localhost:9901");
// username to access the jndi (defined in the jndi.properties)
env.put(Context.SECURITY_PRINCIPAL,"username");
// password to access the jndi (defined in the jndi.properties)
env.put(Context.SECURITY_CREDENTIALS,"password");
// Creation of the Initial Context
InitialContext context = new InitialContext(env);
// we get a reference on the service Hola
com.onyx.service.Hola hola = (com.onyx.service.Hola)context.lookup("hola");
hola.setValue(100);
int val=hola.getValue();
System.out.println(val);
b) via REST:
Example:
http://localhost:9900/hola.getValue()
http://localhost:9900/hola.setValue(100)
The authentication window will popup if credentials are needed, or you can include your credentials in the URL directly.
3) Browse the current services:
If you want to know what current services are registered in the system. You can use the monitor tool or the service webpage.
- Monitor tool:
Go to bin directory and launch the monitor tool: Monitor.[bat|sh]
Go to the Mbeans repository, you will find the services under the Onyx node.