Throwable throwable = null;
try {
do {
// Use the protocol to read a job.
IMessage iMessage = _iProtocol.readMessage(_inputStream);
if(iMessage.getThreadId().equals(_threadId)) {
continue;
}
// Take care of special methods release and acquire
String operation = iMessage.getOperation();
String oid = iMessage.getOid();
if(operation != null && operation.equals("release")) {
Type interfaceType = new Type(iMessage.getInterface());
_java_environment.revokeInterface(oid, interfaceType );
remRefHolder(interfaceType, oid);
if(iMessage.mustReply())
sendReply(false, iMessage.getThreadId(), null);
}
else if(operation != null && operation.equals("acquire")) {
Type interfaceType = new Type(iMessage.getInterface());
String oid_o[] = new String[]{oid};
_java_environment.registerInterface(null, oid_o, interfaceType );
addRefHolder(null, interfaceType, oid);
}
else {
Object object = null;
if(operation != null) { // is it a request
Type interfaceType = new Type(iMessage.getInterface());
object = _java_environment.getRegisteredInterface(oid, interfaceType);
Object xexception = null;
if(object == null) { // this is an unknown oid, so we may have to ask the XInstanceProvider
if(_xInstanceProvider == null) // we have neither an object nor an instance provider -> exception
xexception = new com.sun.star.uno.RuntimeException(getClass().getName() + ".dispatch - no instance provider set and unknown object:" + oid);
else {
try {
object = _xInstanceProvider.getInstance(oid);
if(object == null && !operation.equals("queryInterface"))
xexception = new com.sun.star.uno.RuntimeException(
getClass().getName()
+ ".dispatch: instance provider returned null and operation >"
+ operation
+ "< not supported on null");
}
catch(com.sun.star.container.NoSuchElementException noSuchElementException) {
xexception = new com.sun.star.uno.RuntimeException(getClass().getName() + ".dispatch - wrapped exception:" + noSuchElementException);
}
catch(com.sun.star.uno.RuntimeException runtimeException) {
xexception = runtimeException;
}
}
}
if(xexception != null) {
// an exception occurred while trying to get an instance.
// propagate it.
sendReply(true, iMessage.getThreadId(), xexception);
iMessage = null;
}
}
if(iMessage != null) {