Acceptor Exception Event Plugin
This plugin is implemented by org.jacorb.orb.listener.AcceptorExceptionListener.
package org.jacorb.orb.listener;
public interface AcceptorExceptionListener extends EventListener
void exceptionCaught(AcceptorExceptionEvent ae);
The configuration property is
jacorb.acceptor_exception_listener
If the server listener thread receives an exception while doing the ServerSocket.accept() it will construct a org.jacorb.orb.listener.AcceptorExceptionEvent and notify the configured implementation. The Event allows the following to be retrieved:
public ORB getORB()
public Throwable getException()
The default implementation, org.jacorb.orb.listener.DefaultAcceptorExceptionListener, will simply shutdown the ORB on all Errors and for SSLExceptions that are thrown before any socket connections have been made. If the developer wishes they may plugin their own for more fine grained control.
In order to detect whether the exception has been thrown on the first attempt or any attempt after that the developer may use the following function within their listener implementation.
public void exceptionCaught(AcceptorExceptionEvent ae) {
...
if (((org.jacorb.orb.iiop.IIOPListener.Acceptor)
ae.getSource()).getAcceptorSocketLoop()) {
...
getAcceptorSocketLoop returns false if the event has been thrown on the initial loop, or true on any loop after that.
Note that if the default implementation is used it is possible that due to e.g. an SSLException the listener will fail to accept on the server socket after the root POA is resolved which means that the ORB will be shutdown. Therefore future calls on that POA will fail with a ’POA destroyed’ message.
3.3.1 JacORB Implname and CORBA Objects
A JacORB object key consists of <impl name>/<poa name>/<object oid>. The lifespan of CORBA objects are defined by the POA policy LifespanPolicyValue.
Transient objects are those whose lifespans are bounded by the process in which they were created. Once a transient object has been destroyed any clients still holding references to those objects should receive a OBJECT NOT EXIST. This applies even if the transient object is recreated as it is a new object reference. To achieve this JacORB replaces the implname portion of the key with transient data.
Persistent objects are those that may live beyond the lifetime of the process that created them. The implname property should be configured in this case. It should be set to a unique name to to form part of the object identity. If it is not set, an exception will be thrown. This property may be configured in the jacorb.properties (where an example shows it set to StandardImplName) or in the code of the server e.g.
/* create and set properties */
java.util.Properties props = new java.util.Properties();
props.setProperty("jacorb.use_imr","on");
props.setProperty("jacorb.implname","MyName");
/* init ORB */
orb = org.omg.CORBA.ORB.init(args, props);
The implname property allows a program to run with a different implementation name so that it will not accept references created by another persistent POA with the same POA name. A common problem is where the developer has two persistent servers running with the same implname and POA names when one tries to contact the other. Rather than calling server x, server y performs local call. This is because there is no way of distinguishing the two servers; the developer should have used different implnames (e.g. UUIDs).
Corbaloc with JacORB Implname and CORBA Objects
Normally corbaloc is used to provide a shortcut to refer to CORBA objects. However the stringified key portion corresponds to the octet sequence in the object key member of a GIOP Request or LocateRequest header as defined in section 15.4 of CORBA 2.3. Further the key string uses the escape conventions described in RFC 2396 to map away from octet values that cannot directly be part of a URL. This means the key string might look like:
corbaloc:iiop:10.1.0.4:18000/FooBar/ServiceName/V_3%f1%1c%9b%11%db%b7%e9
%bdsnQ%ea%85qV_3%f0%1c%9b%11%db%b7%e9%bdsnQ%ea%85TA5%f0%1c%9b%11
%db%b7%e9%bdsnQ%ea%85
With JacORB, for persistent objects, the developer may configure the implname, poa name and object key. This should mean that the corbaloc sequence should be more readable:
corbaloc:iiop:10.1.0.4:42811/imr_demo/ImRDemoServerPOA/imr_demo
With a transient object the key may look like:
corbaloc:iiop:10.1.0.4:42818/2649480905/%14%3e45%0d%0b!%10%3e
As it is not possible to construct a transient object with a readable key some developers may find it useful to use the objectKeyMap facility within JacORB to refer to their transient objects. Note the objectKey functionality may also be used with persistent objects.
This property provides more readable corbaloc URLs by mapping the actual object key to an arbitrary string. The mapping below would permit clients of a name service to access it using corbaloc::ipaddress:portnum/NameService. The property also accepts the following mappings:
- IOR, resource, jndi, URL (e.g. file, http)
Note that jacorb.orb.objectKeyMap.name is configurable both through the jacorb.properties file and through the proprietary function
ORB::addObjectKey(String name, String)
Example usage
jacorb.orb.objectKeyMap.NameService=file:///home/rnc/NameSingleton.ior
This then allows the corbaloc key portion to simply be ’NameService’.
3.3.2 JacORB Network Event Logging
An enhancement has been added to JacORB that allows a developer to monitor TCP and SSL connections.
Note that for both of these implementations full information may only retrieved with a successful connection; e.g. if the connection could not be established there will be no certificates.
TCP Monitoring
To monitor TCP connections a developer should implement the following interface
package org.jacorb.orb.listener;
public interface TCPConnectionListener extends EventListener
void connectionOpened(TCPConnectionEvent e);
void connectionClosed(TCPConnectionEvent e);
The classname should then be specified in the property
jacorb.net.tcp_listener
The standard java event interface is followed; the developer’s code will receive the TCPConnection-Event which allows the following information to be retrieved:
public String getLocalIP()
public int getLocalPort()
public String getRemoteIP()
public int getRemotePort()
Note that the TCPConnectionEvent extends java.util.EventObject and the EventObject.getSource operation will return the IIOPConnection of the TCP connection.
SSL Monitoring
To monitor SSL sessions a developer should implement the following interface
package org.jacorb.orb.listener;
public interface SSLSessionListener extends EventListener
void sessionCreated(SSLSessionEvent e);
void handshakeException(SSLSessionEvent e);
void keyException(SSLSessionEvent e);
void peerUnverifiedException(SSLSessionEvent e);
void protocolException(SSLSessionEvent e);
void sslException(SSLSessionEvent e);
The classname should then be specified in the property
jacorb.security.ssl.ssl_listener
The standard java event interface is followed; the developer’s code will receive the SSLSessionEvent which allows the following information to be retrieved:
public String getLocalIP()
public int getLocalPort()
public String getRemoteIP()
public int getRemotePort()
public String getRemoteDN()
public X509Certificate[] getPeerCertificateChain()
Note that getRemoteDN will simply return a concatenated string of the certificates. For that reason it is deprecated; getPeerCertificateChain should be used instead as that allows a developer to extract specific information from the certificate. In order to detect a succesful handshake the implementation delegates to the JSSE javax.net.ssl.HandShakeCompletedListener. When using JDK1.3 JSSE the JSSE may not throw for instance a handshakeException but a sslException. Similar to above, SSLSessionEvent extends java.util.EventObject. The EventObject.getSource operation will return the source of the HandshakeCompletedEvent.
3.3.3 JacORB IORMutator
An enhancement has been added to JacORB that allows a developer to alter incoming and outgoing objects at a very low level within the ORB. While the majority of the users would not require this ability, it is useful within scenarios where for instance, a user is running with legacy network elements which have multiple, identical IP addresses. This allows them to mutate the IORs as shown below.
This is a very powerful ability that must be used with caution. As it operates at the CDRStream level it is easy to break the ORB and cause unpredictable behaviour
Adding a Mutator
The developer should firstly extend the following abstract class.
package org.jacorb.orb.IORMutator;
public abstract class IORMutator
protected org.omg.ETF.Connection connection;
public abstract IOR mutateIncoming (IOR object);
public abstract IOR mutateOutgoing (IOR object);
The classname should then be specified in the property
jacorb.iormutator
The IORMutator class also has a org.omg.ETF.Connection connection variable. This variable will be updated with the current transport information for the respective streams. Note, altering the information within the transport is undefined. The mutateIncoming operation will be called for CDRInputStream operations and the mutateOutgoing for CDROuputStream operations.