Overview
When designing any VisiBroker application, it is advisable to design VisiBroker components as reusable so that it can be integrated into any part of a VisiBroker application whenever needed. For example, if an application needs to support security, then a component can be designed based on VisiSecure which initializes the certificates and key. Then this component can be used to make a non-secure application into secured after attaching it to the VisiBroker applications. The ServiceLoader/VISInit feature of VisiBroker helps you to achieve this functionality.
How ServiceLoader/VISInit works
The ServiceLoader of Java and VISInit of C class facilitates loading a service/component when an ORB and/or BOA is getting initialized in an application. A service should derive from ServiceLoader/VISInit interface and implement the feature of what it is intended to, for example VisiBroker dynamic logging or security. After an application loads this component during startup and whenever a C application calls ORB_init/BOA_init API or a Java application calls ORB.init() API, the core ORB will invoke ORB_init or BOA_init (for C ) and ORB.init (for Java) functions of this service which will load the feature intended. When the application needs to uninitialize certain resources or update the database when the ORB is shutting down, it can be achieved using the ORB_shutdown/ORB_destroy APIs of VISInit for a C service or shutdown() API of ServiceLoader for a Java service.
Interfaces of Java and C
In Java, the interface name is ServiceLoader and in C , it is VISInit.
Java
The ServiceLoader interface is in com.inprise.vbroker.interceptor package.
public interface ServiceLoader {
/**
This method is called by the ORB when ORB.init() is called.
@param orb The instance of the orb for which this service is being created.
*/
void init(org.omg.CORBA.ORB orb);
/**
Called after ORB.init() is done but control hasn't been returned to
the user. Can be used to disable certain resources that were only
made available to other service inits.
*/
void init_complete(org.omg.CORBA.ORB orb);
/**
Called when the orb is being shutdown.
*/
void shutdown(org.omg.CORBA.ORB orb);
}
C
class VISInit
{
public:
VISInit();
virtual ~VISInit();
// ORB_init is called toward the beginning of CORBA::ORB_init()
virtual void ORB_init(int& /*argc*/,
char* const* /*argv*/,
CORBA_ORB* /*orb*/) {}
// ORB_initialized is called at the end of CORBA::ORB_init()
virtual void ORB_initialized(CORBA_ORB* /*orb*/) {}
// shutdown is called when CORBA::ORB::shutdown() was called
// or process shutdown is detected
virtual void ORB_shutdown() {}
// BOA is deprecated and therefore BOA_init() is considered deprecated
virtual void BOA_init(int& /*argc*/,
char* const* /*argv*/,
CORBA_BOA* /*boa*/)
{}
// called when ORB::destroy was called
virtual void ORB_destroy() {
}
};
An example of using ServiceLoader/VISInit
A non-secure C <VBROKERDIR>/examples/vbroker/basic/bank_portable example can be easily made as a secured application with loading the VisiSecure library and configuring the VisiSecure properties as below. Here, the VisiSecure library is already implementing the VISInit interface.
Server -DORBpropStorage=server.properties -Dvbroker.orb.dynamicLibs=vbsec.dll
server.properties looks like below where trustpoints folder contains the trusted certificates and identities folder contains the server identity:
vbroker.security.disable=false
vbroker.security.peerAuthenticationMode=NONE
vbroker.security.requireAuthentication=false
vbroker.security.trustpointsRepository=Directory:./trustpoints
vbroker.security.wallet.type=Directory:./identities
vbroker.security.wallet.identity=frans
vbroker.security.wallet.password=frans
When any application needs to programmatically enable security (such as configuring PKCS12 keystore) using VisiSecure APIs, then it should implement its own VISInit (for C ) or ServiceLoader (for Java) service and load it in the application using vbroker.orb.dynamicLibs property. Please refer the ServerInit.C and ClientInit.C of the <VBROKERDIR>/examples/vbroker/security/bank_ssl example on how programmatically security service can be loaded into a non-secure application.
For Java application, load the class/jar file which implements the ServiceLoader interface using the vbroker.orb.dynamicLibs property. For example:
vbj -Dvbroker.orb.dynamicLibs=DynamicLoader Server
VisiBroker examples using ServiceLoader and VISInit interfaces
The following are the VisiBroker examples which use ServiceLoader and VISInit feature:
Enabling VisiBroker debug logs dynamically
examples\\vbroker\\debug\\dynamic_logging\\dynamic_logging_cpp.html
examples\\vbroker\\debug\\dynamic_logging\\dynamic_logging_java.html
Adding VisiBroker Proprietary Interceptors to an application
examples\\vbroker\\interceptors\\active_object_lifecycle\\active_object_lifecycle_java.html
examples\\vbroker\\interceptors\\client_server\\client_server_cpp.html
examples\\vbroker\\interceptors\\client_server\\client_server_java.html
examples\\vbroker\\interceptors\\encryption\\encryption_java.html
Adding VisiBroker Portable Interceptors to an application
examples\\vbroker\\pi\\chaining\\chaining_cpp.html
examples\\vbroker\\pi\\chaining\\chaining_java.html
examples\\vbroker\\pi\\client_server\\client_server_cpp.html
Enabling VisiSecure dynamically
examples\\vbroker\\security\\bank_ssl\\bank_ssl_cpp.html
Adding Custom login mechanism dynamically
examples\\vbroker\\security\\customlogin\\customlogin_cpp.html
In addition, some of the VisiBroker components such as firewall, gatekeeper's HIOP, HIOPS, ACL also required to be loaded dynamically using the vbroker.orb.dynamicLibs property.
#ServiceLoader
#VISInit
#vbroker.orb.dynamicLibs
#VisiBroker
#Security