summaryrefslogtreecommitdiff
path: root/jurt/com
diff options
context:
space:
mode:
authorJörg Budischewski <jbu@openoffice.org>2002-06-25 06:18:12 +0000
committerJörg Budischewski <jbu@openoffice.org>2002-06-25 06:18:12 +0000
commit64dac91688d6512ed2bcb3e02cc8a0f3376a4d8c (patch)
treec918dfe70fcd534751232fcb626bab620a79550e /jurt/com
parent4c6e9514a58124d08d85dc2dd91b571e2f0559de (diff)
#99601# performance optimizations
Diffstat (limited to 'jurt/com')
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java10
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java15
-rw-r--r--jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java55
-rw-r--r--jurt/com/sun/star/lib/uno/environments/java/java_environment.java38
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java38
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java42
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java11
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/Job.java9
-rw-r--r--jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java54
-rw-r--r--jurt/com/sun/star/lib/uno/protocols/urp/urp.java43
10 files changed, 199 insertions, 116 deletions
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java
index 9907079bc2f9..35689fc3acd4 100644
--- a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionInputStream_Adapter.java
@@ -2,9 +2,9 @@
*
* $RCSfile: XConnectionInputStream_Adapter.java,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:08:59 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -99,16 +99,16 @@ class XConnectionInputStream_Adapter extends InputStream {
}
public int read(byte[] b, int off, int len) throws IOException {
- byte bytes[][] = new byte[1][];
+// byte bytes[][] = new byte[1][];
try {
- len = _xConnection.read(bytes, len - off);
+ len = _xConnection.read(_bytes, len - off);
}
catch(com.sun.star.io.IOException ioException) {
throw new IOException(ioException.toString());
}
- System.arraycopy(bytes[0], 0, b, off, len);
+ System.arraycopy(_bytes[0], 0, b, off, len);
return len == 0 ? -1 : len;
}
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java
index f65306ed76c1..c5a98f00a114 100644
--- a/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/XConnectionOutputStream_Adapter.java
@@ -2,9 +2,9 @@
*
* $RCSfile: XConnectionOutputStream_Adapter.java,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 15:27:52 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:08:59 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,9 +94,16 @@ class XConnectionOutputStream_Adapter extends OutputStream {
}
public void write(byte[] b, int off, int len) throws IOException {
- byte bytes[] = new byte[len];
+ byte bytes[] = null;
- System.arraycopy(b, off, bytes, 0, len);
+ if(off == 0 && len == b.length)
+ bytes = b;
+
+ else {
+ bytes = new byte[len];
+
+ System.arraycopy(b, off, bytes, 0, len);
+ }
try {
_xConnection.write(bytes);
diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java
index 2a6df7d84992..18d91441eef9 100644
--- a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java
+++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java
@@ -2,9 +2,9 @@
*
* $RCSfile: java_remote_bridge.java,v $
*
- * $Revision: 1.24 $
+ * $Revision: 1.25 $
*
- * last change: $Author: jbu $ $Date: 2002-03-21 16:23:31 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:08:59 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -132,7 +132,7 @@ import com.sun.star.uno.IQueryInterface;
* The protocol to used is passed by name, the bridge
* then looks for it under <code>com.sun.star.lib.uno.protocols</code>.
* <p>
- * @version $Revision: 1.24 $ $ $Date: 2002-03-21 16:23:31 $
+ * @version $Revision: 1.25 $ $ $Date: 2002-06-25 07:08:59 $
* @author Kay Ramme
* @see com.sun.star.lib.uno.environments.remote.IProtocol
* @since UDK1.0
@@ -189,40 +189,45 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid
}
// Take care of special methods release and acquire
- if(iMessage.getOperation() != null && iMessage.getOperation().equals("release")) {
- _java_environment.revokeInterface(iMessage.getOid(), new Type(iMessage.getInterface()));
- remRefHolder(new Type(iMessage.getInterface()), iMessage.getOid());
+ 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(iMessage.getOperation() != null && iMessage.getOperation().equals("acquire")) {
- String oid_o[] = new String[]{iMessage.getOid()};
- _java_environment.registerInterface(null, oid_o, new Type(iMessage.getInterface()));
+ 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(new Type(iMessage.getInterface()), iMessage.getOid());
+ addRefHolder(interfaceType, oid);
}
else {
Object object = null;
- if(iMessage.getOperation() != null) { // is it a request
- object = _java_environment.getRegisteredInterface(iMessage.getOid(), new Type(iMessage.getInterface()));
+ 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:" + iMessage.getOid());
+ xexception = new com.sun.star.uno.RuntimeException(getClass().getName() + ".dispatch - no instance provider set and unknown object:" + oid);
else {
try {
- object = _xInstanceProvider.getInstance(iMessage.getOid());
+ object = _xInstanceProvider.getInstance(oid);
- if(object == null && !iMessage.getOperation().equals("queryInterface"))
+ if(object == null && !operation.equals("queryInterface"))
xexception = new com.sun.star.uno.RuntimeException(
getClass().getName()
+ ".dispatch: instance provider returned null and operation >"
- + iMessage.getOperation()
+ + operation
+ "< not supported on null");
}
catch(com.sun.star.container.NoSuchElementException noSuchElementException) {
@@ -288,7 +293,7 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid
protected XConnection _xConnection;
protected InputStream _inputStream; // wraps the connection to be an InputStream
- protected OutputStream _outputStream; // wraps the connection to be an OutputStream
+ protected DataOutputStream _outputStream; // wraps the connection to be an OutputStream
protected XInstanceProvider _xInstanceProvider;
@@ -483,7 +488,7 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid
_xConnection = (XConnection)args[1];
_xInstanceProvider = (XInstanceProvider)args[2];
_inputStream = new XConnectionInputStream_Adapter(_xConnection);
- _outputStream = new XConnectionOutputStream_Adapter(_xConnection);
+ _outputStream = new DataOutputStream( new XConnectionOutputStream_Adapter(_xConnection) );
if(args.length > 3)
_name = (String)args[3];
@@ -837,7 +842,7 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid
synchronized(_outputStream) {
_iProtocol.writeReply(exception, threadId, result);
try {
- _iProtocol.flush(new DataOutputStream(_outputStream));
+ _iProtocol.flush(_outputStream);
_outputStream.flush();
}
catch(IOException iOException) {
@@ -868,17 +873,19 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid
boolean goThroughThreadPool = false;
+ ThreadId threadId = ThreadPoolFactory.getThreadId();
+ Object handle = null;
try {
synchronized(_outputStream) {
- _iProtocol.writeRequest((String)object, TypeDescription.getTypeDescription(type), operation, ThreadPoolFactory.getThreadId(), params, synchron, mustReply);
+ _iProtocol.writeRequest((String)object, TypeDescription.getTypeDescription(type), operation, threadId , params, synchron, mustReply);
goThroughThreadPool = synchron[0].booleanValue() && Thread.currentThread() != _messageDispatcher;
if(goThroughThreadPool) // prepare a queue for this thread in the threadpool
- _iThreadPool.attach();
+ handle = _iThreadPool.attach( threadId );
try {
- _iProtocol.flush(new DataOutputStream(_outputStream));
+ _iProtocol.flush(_outputStream);
_outputStream.flush();
}
catch(IOException iOException) {
@@ -890,12 +897,12 @@ public class java_remote_bridge implements IBridge, IReceiver, IRequester, XBrid
}
if(goThroughThreadPool)
- result = _iThreadPool.enter();
+ result = _iThreadPool.enter( handle, threadId);
}
finally {
if(goThroughThreadPool)
- _iThreadPool.detach();
+ _iThreadPool.detach( handle , threadId);
if(operation.equals("release"))
release(); // kill this bridge, if this was the last proxy
diff --git a/jurt/com/sun/star/lib/uno/environments/java/java_environment.java b/jurt/com/sun/star/lib/uno/environments/java/java_environment.java
index 1f621978353d..334badaea0b0 100644
--- a/jurt/com/sun/star/lib/uno/environments/java/java_environment.java
+++ b/jurt/com/sun/star/lib/uno/environments/java/java_environment.java
@@ -2,9 +2,9 @@
*
* $RCSfile: java_environment.java,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: jbu $ $Date: 2002-05-16 14:58:46 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:13:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,7 +91,7 @@ import com.sun.star.uno.XInterface;
* interface defined in the uno runtime.
* <p>
* <p>
- * @version $Revision: 1.7 $ $ $Date: 2002-05-16 14:58:46 $
+ * @version $Revision: 1.8 $ $ $Date: 2002-06-25 07:13:38 $
* @author Kay Ramme
* @see com.sun.star.uno.UnoRuntime
* @see com.sun.star.uno.IEnvironment
@@ -102,6 +102,7 @@ public class java_environment implements IEnvironment, Disposable {
* When set to true, enables various debugging output.
*/
static public final boolean DEBUG = false;
+ final static String _holderProxyClassName = HolderProxy.class.getName().replace('.', '/');
/*
** This is the holder proxy, which one gets while trying to get a registered object
@@ -210,14 +211,19 @@ public class java_environment implements IEnvironment, Disposable {
** This is the holder class, whichs instances are put into the hashtable
*/
class Holder {
+
int _refCount;
String _oId;
Object _object;
+ Class _class;
+ boolean _instanceOfProxy;
- Holder(String oId, Object object) {
+ Holder(String oId, Object object , Type type) {
_oId = oId;
_object = object;
_refCount = 1;
+ _class = ((TypeDescription)type.getTypeDescription()).getZClass();
+ _instanceOfProxy = (object instanceof Proxy);
}
synchronized void incRefCount() {
@@ -235,30 +241,28 @@ public class java_environment implements IEnvironment, Disposable {
_objects.remove(_oId);
}
- Object xxgetObject(Type type) {
+ Object xxgetObject(Type type)
+ {
Object result = _object;
-
- if(_object instanceof Proxy) {
+ if( _instanceOfProxy ) {
if(DEBUG) System.err.println("##### " + getClass().getName() + " - creating new Proxy Proxy");
- Class holderProxyClass = DispatcherAdapterFactory.createDispatcherAdapter(((TypeDescription)type.getTypeDescription()).getZClass(),
- HolderProxy.class.getName().replace('.', '/'));
-
+ Class holderProxyClass =
+ DispatcherAdapterFactory.createDispatcherAdapter(
+ _class,
+ _holderProxyClassName);
try {
HolderProxy holderProxy = (HolderProxy)holderProxyClass.newInstance();
holderProxy.setObject(holderProxy, _object);
holderProxy.setHolder(this);
holderProxy.setInterface(type);
-
result = holderProxy;
}
catch(Exception exception) {
System.err.println("##### " + getClass().getName() + ".xxgetObject - exception occurred:" + exception);
exception.printStackTrace();
-
result = null;
}
}
-
return result;
}
@@ -321,7 +325,7 @@ public class java_environment implements IEnvironment, Disposable {
if(oId[0] == null)
oId[0] = UnoRuntime.generateOid(object);
- String keyName = oId[0] + type;
+ String keyName = oId[0].concat( type.getTypeName());
synchronized(_objects) {
// get the holder
@@ -331,7 +335,7 @@ public class java_environment implements IEnvironment, Disposable {
System.err.println("##### " + getClass().getName() + ".registerInterface:" + object + " " + oId[0] + " " + type);
if(holder == null) {
- holder = new Holder(keyName, object);
+ holder = new Holder(keyName, object , type );
_objects.put(keyName, holder);
}
@@ -354,7 +358,7 @@ public class java_environment implements IEnvironment, Disposable {
public void revokeInterface(String oId, Type type) {
if(DEBUG) System.err.println("##### " + getClass().getName() + ".revokeInterface:" + oId + " " + type);
synchronized(_objects) {
- Holder holder = (Holder)_objects.get(oId + type);
+ Holder holder = (Holder)_objects.get(oId.concat( type.getTypeName()));
if(holder != null)
holder.decRefCount();
else
@@ -372,7 +376,7 @@ public class java_environment implements IEnvironment, Disposable {
public Object getRegisteredInterface(String oId, Type type) {
Object result = null;
- Holder holder = (Holder)_objects.get(oId + type);
+ Holder holder = (Holder)_objects.get(oId.concat( type.getTypeName()));
if(holder != null) {
result = holder.xxgetObject(type);
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java b/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java
index 3fee90ec8fe1..ad31b592d14d 100644
--- a/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java
+++ b/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java
@@ -2,9 +2,9 @@
*
* $RCSfile: IThreadPool.java,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: kr $ $Date: 2001-05-17 12:55:05 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:16:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,7 +65,7 @@ package com.sun.star.lib.uno.environments.remote;
* This interface is an abstraction of the various
* threadpool implementations.
* <p>
- * @version $Revision: 1.3 $ $ $Date: 2001-05-17 12:55:05 $
+ * @version $Revision: 1.4 $ $ $Date: 2002-06-25 07:16:52 $
* @author Joerg Budischewski
* @author Kay Ramme
* @see com.sun.star.lib.uno.environments.remote.ThreadPoolFactory
@@ -81,12 +81,33 @@ public interface IThreadPool {
public void attach();
/**
+ * As above, but hands in an already existing
+ * instance of the threadid of the current thread.
+ * Returns a handle which can be used in enter and
+ * detach calls.<p>
+ * The function exists for performance
+ * optimization reasons.
+ * @see #attach
+ */
+ public Object attach( ThreadId id );
+
+ /**
* Detaches this thread from the thread pool.
* @see #enter
*/
public void detach();
/**
+ * As above, but hands in an already existing
+ * instance of the threadid of the current thread
+ * and a handle returned by attach.
+ * The function exists for performance
+ * optimization reasons.
+ * @see #attach,#detach
+ */
+ public void detach( Object handle, ThreadId id );
+
+ /**
* Lets this thread enter the thread pool.
* This thread then executes all jobs put via
* <code>putJob</code> until a reply job arrives.
@@ -96,6 +117,17 @@ public interface IThreadPool {
public Object enter() throws Throwable;
/**
+ * as above but hands in an already existing
+ * instance of the threadid of the current thread
+ * and a handle returned by attach.
+ * This thread then executes all jobs put via
+ * <code>putJob</code> until a reply job arrives.
+ * <p>
+ * @see #putJob
+ */
+ public Object enter( Object handle, ThreadId id ) throws Throwable;
+
+ /**
* Queues a job into the jobQueue of the thread belonging
* to the jobs threadId.
* <p>
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java b/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java
index 8113687a0ad5..a27057875e53 100644
--- a/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java
+++ b/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPool.java
@@ -2,9 +2,9 @@
*
* $RCSfile: JavaThreadPool.java,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: kr $ $Date: 2001-05-17 12:55:05 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:16:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,7 +71,7 @@ import com.sun.star.uno.UnoRuntime;
/**
* This class implements a java thread pool.
* <p>
- * @version $Revision: 1.8 $ $ $Date: 2001-05-17 12:55:05 $
+ * @version $Revision: 1.9 $ $ $Date: 2002-06-25 07:16:52 $
* @author Kay Ramme
* @see com.sun.star.uno.UnoRuntime
* @see com.sun.star.lib.uno.environments.remote.ThreadPool
@@ -92,36 +92,40 @@ public class JavaThreadPool implements IThreadPool {
_javaThreadPoolFactory = javaThreadPoolFactory;
}
- public void attach() {
- ThreadId threadId = _javaThreadPoolFactory.getThreadId();
-
+ public Object attach( ThreadId threadId )
+ {
if(DEBUG) System.err.println("##### " + getClass().getName() + ".attach - id:" + threadId);
-
- // we don't have to synchronize here
- // cause the thread can attach itself
- // not concurrently
JobQueue jobQueue = _javaThreadPoolFactory.getJobQueue(threadId);
if(jobQueue == null)
jobQueue = new JobQueue(_javaThreadPoolFactory, threadId, false);
// acquiring the jobQueue registers it at the ThreadPoolFactory
jobQueue.acquire();
+ return jobQueue;
}
- public void detach() {
- ThreadId threadId = _javaThreadPoolFactory.getThreadId();
+ public void attach() {
+ attach( _javaThreadPoolFactory.getThreadId() );
+ }
- JobQueue jobQueue = _javaThreadPoolFactory.getJobQueue(threadId);
- // releasing the jobQueue deregisters it from the ThreadPoolFactory
- jobQueue.release();
+ public void detach( Object handle, ThreadId id )
+ {
+ ((JobQueue)handle).release();
}
- public Object enter() throws Throwable {
- ThreadId threadId = _javaThreadPoolFactory.getThreadId();
+ public void detach() {
+ ThreadId threadId = _javaThreadPoolFactory.getThreadId();
+ detach(_javaThreadPoolFactory.getJobQueue(threadId), threadId );
+ }
- JobQueue jobQueue = _javaThreadPoolFactory.getJobQueue(threadId);
- return jobQueue.enter(this);
+ public Object enter( ) throws Throwable {
+ ThreadId threadId = _javaThreadPoolFactory.getThreadId();
+ return enter( _javaThreadPoolFactory.getJobQueue( threadId ), threadId );
+ }
+
+ public Object enter( Object handle, ThreadId threadId ) throws Throwable {
+ return ((JobQueue)handle).enter(this);
}
public void putJob(Job job) {
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java b/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java
index 05885e0d6ef7..a9fdd21d6e72 100644
--- a/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java
+++ b/jurt/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory.java
@@ -2,9 +2,9 @@
*
* $RCSfile: JavaThreadPoolFactory.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: kr $ $Date: 2001-05-17 12:42:21 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:16:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -123,12 +123,7 @@ public class JavaThreadPoolFactory implements IThreadPoolFactory {
if(thread instanceof JobQueue.JobDispatcher)
threadId = ((JobQueue.JobDispatcher)thread).getThreadId();
else {
- try {
- threadId = new ThreadId(UnoRuntime.generateOid(thread).getBytes("UTF8"));
- }
- catch(UnsupportedEncodingException unsupportedEncodingException) {
- throw new com.sun.star.uno.RuntimeException("JavaThreadPool.getThreadId - unexpected: " + unsupportedEncodingException.toString());
- }
+ threadId = new ThreadId(UnoRuntime.generateOid(thread));
}
if(DEBUG) System.err.println("##### ThreadPool.getThreadId:" + threadId);
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/Job.java b/jurt/com/sun/star/lib/uno/environments/remote/Job.java
index 023f48c9b728..42b987c34ef3 100644
--- a/jurt/com/sun/star/lib/uno/environments/remote/Job.java
+++ b/jurt/com/sun/star/lib/uno/environments/remote/Job.java
@@ -2,9 +2,9 @@
*
* $RCSfile: Job.java,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: kr $ $Date: 2001-05-17 12:46:27 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:16:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,7 +81,7 @@ import com.sun.star.uno.UnoRuntime;
* The Job is an abstraction for tasks which have to be done
* remotely because of a method invocation.
* <p>
- * @version $Revision: 1.9 $ $ $Date: 2001-05-17 12:46:27 $
+ * @version $Revision: 1.10 $ $ $Date: 2002-06-25 07:16:52 $
* @author Kay Ramme
* @see com.sun.star.lib.uno.environments.remote.ThreadID
* @see com.sun.star.lib.uno.environments.remote.IReceiver
@@ -184,7 +184,8 @@ public class Job {
if(exception instanceof InvocationTargetException)
throwable = ((InvocationTargetException)exception).getTargetException();;
- if(DEBUG) System.err.println("##### Job.execute - exception occured:" + throwable);
+ if(DEBUG); System.err.println("##### Job.execute - exception occured:" + throwable);
+ throwable.printStackTrace();
// Here we have to be aware of non UNO exceptions, cause they may kill
// a remote side (which does not know anything about theire types)
if(!(throwable instanceof com.sun.star.uno.Exception)
diff --git a/jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java b/jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java
index 48b5c9b3004f..b7af800103b4 100644
--- a/jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java
+++ b/jurt/com/sun/star/lib/uno/environments/remote/ThreadId.java
@@ -2,9 +2,9 @@
*
* $RCSfile: ThreadId.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: kr $ $Date: 2001-05-17 12:44:32 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:16:52 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -72,7 +72,7 @@ import com.sun.star.uno.UnoRuntime;
/**
* This is the global thread id.
* <p>
- * @version $Revision: 1.1 $ $ $Date: 2001-05-17 12:44:32 $
+ * @version $Revision: 1.2 $ $ $Date: 2002-06-25 07:16:52 $
* @author Joerg Budischewski
* @see com.sun.star.lib.uno.environments.remote.ThreadPool
* @see com.sun.star.lib.uno.environments.remote.IThreadPool
@@ -91,12 +91,15 @@ public class ThreadId {
* <p>
*/
public ThreadId() {
- try {
- init(UnoRuntime.generateOid(new Object()).getBytes("UTF8"));
- }
- catch(UnsupportedEncodingException unsupportedEncodingException) {
- throw new com.sun.star.uno.RuntimeException(getClass().getName() + ".<init> - unexpected: " + unsupportedEncodingException.toString());
- }
+ init(UnoRuntime.generateOid(new Object()));
+ }
+
+ /** Use this ctor only as long as the string
+ contains only ascii characters. Otherwise,
+ use the byte [] ctor.
+ */
+ public ThreadId(String threadId ) {
+ init( threadId );
}
/**
@@ -113,17 +116,40 @@ public class ThreadId {
* <p>
* @param threadID a byte array describing a thread id
*/
- private void init(byte threadId[]) {
+ private void init(String threadId)
+ {
try {
- _threadId = threadId;
- _string = new String(threadId, "8859_1");
+ _string = threadId;
+ _threadId = _string.getBytes( "UTF8" );
}
- catch(java.io.UnsupportedEncodingException bla) {
- System.err.println(getClass().getName() + ".init - unexpected exception:" + bla);
+ catch(UnsupportedEncodingException unsupportedEncodingException) {
+ throw new com.sun.star.uno.RuntimeException(getClass().getName() + ".<init> - unexpected: " + unsupportedEncodingException.toString());
}
}
/**
+ * Initializes a thread id with a byte array
+ * <p>
+ * @param threadID a byte array describing a thread id
+ */
+ private void init(byte threadId[])
+ {
+ _threadId = threadId;
+
+ // in case the deprecated String( byte [] , byte ) ctor
+ // once vanishes, replace it with this code
+// char [] a = new char[threadId.length];
+// int nMax = threadId.length;
+// for( int i = 0 ; i < nMax ; i ++ )
+// a[i] = (char) threadId[i];
+// _string = new String( a );
+
+ // fast but deprecated
+ _string = new String(threadId, (byte) 0 );
+
+ }
+
+ /**
* Gives a hashcode.
* <p>
*/
diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java
index 48b9979e33c8..e92777ad751b 100644
--- a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java
+++ b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java
@@ -2,9 +2,9 @@
*
* $RCSfile: urp.java,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: kr $ $Date: 2001-05-17 12:46:28 $
+ * last change: $Author: jbu $ $Date: 2002-06-25 07:18:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,7 +97,7 @@ import com.sun.star.uno.Type;
* from uno. The functionality is reachable through
* the <code>IProtocol</code> interface.
* <p>
- * @version $Revision: 1.10 $ $ $Date: 2001-05-17 12:46:28 $
+ * @version $Revision: 1.11 $ $ $Date: 2002-06-25 07:18:12 $
* @author Kay Ramme
* @see com.sun.star.lib.uno.environments.remote.IProtocol
* @since UDK1.0
@@ -127,6 +127,12 @@ public class urp extends Protocol {
private Marshal _marshal;
private Unmarshal _unmarshal;
+ private String _operationContainer[] = new String[1];
+ private Object _paramsContainer[][] = new Object[1][];
+ private boolean _synchronContainer[] = new boolean[1];
+ private boolean _mustReplyContainer[] = new boolean[1];
+ private boolean _exceptionContainer[] = new boolean[1];
+
static private final byte BIG_HEADER = (byte)0x80;
// big header flags
static private final byte REQUEST = 0x40;
@@ -587,9 +593,10 @@ public class urp extends Protocol {
public IMessage readMessage(InputStream inputStream) throws IOException {
IMessage iMessage = null;
+ DataInput dataInput = new DataInputStream( inputStream );
while(iMessage == null) { // try hard to get a message
if(_unmarshal.bytesLeft() <= 0) { // the last block is empty, get a new one
- byte bytes[] = readBlock(new DataInputStream(inputStream));
+ byte bytes[] = readBlock(dataInput);
_unmarshal.reset(bytes);
}
@@ -597,15 +604,10 @@ public class urp extends Protocol {
throw new java.io.IOException("connection close message received");
else {
- String operation[] = new String[1];
- Object params[][] = new Object[1][];
- boolean synchron[] = new boolean[1];
- boolean mustReply[] = new boolean[1];
- boolean exception[] = new boolean[1];
-
- Object result = readMessage(operation, params, synchron, mustReply, exception);
+ Object result = readMessage(_operationContainer, _paramsContainer, _synchronContainer,
+ _mustReplyContainer, _exceptionContainer);
- if(operation[0] == null) { // a reply ?
+ if(_operationContainer[0] == null) { // a reply ?
iMessage = new Message(null, // oid
result, // object
null, // interface
@@ -613,20 +615,25 @@ public class urp extends Protocol {
_in_threadId,
false,
false,
- exception[0],
- params[0]);
+ _exceptionContainer[0],
+ _paramsContainer[0]);
}
else { // a request
iMessage = new Message(_in_oid,
null,
_in_interface,
- operation[0],
+ _operationContainer[0],
_in_threadId,
- synchron[0],
- mustReply[0],
+ _synchronContainer[0],
+ _mustReplyContainer[0],
false,
- params[0]);
+ _paramsContainer[0]);
}
+ _operationContainer[0] = null;
+ _paramsContainer[0] = null;
+ _synchronContainer[0] = false;
+ _exceptionContainer[0] = false;
+ _mustReplyContainer[0] = false;
}
}