
org.openrdf.util.rmirouting.Job Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2004 OntoText Lab, Sirma AI OOD
*
* Address:
* Europe 135 Tsarigradsko Shose, Sofia 1784, Bulgaria
* (IT Center Office Express, 3rd floor)
*
* North America 438 Isabey Str, Suite 103, Montreal, Canada H4T 1V3
*
* Phone: (+359 2) 9768 310
* Fax: (+359 2) 9768 311
*
*
* E-mail: [email protected]
* Web: http://www.ontotext.com
* Sirma Group International Corp. http://www.sirma.com
* Sirma AI Ltd. http://www.sirma.bg
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.openrdf.util.rmirouting;
import java.io.Serializable;
/**
* Title: RMI routing
* Description: The Job class represent a single invocation of a method
* returning 'void' that has been invoked only with native and seralizable
* arguments. This si very usefull way to batch several invocation of a such
* king into a single RMI call so to reduce the net trafic.
* Copyright: Copyright (c) 2004
* Company: Ontotext Lab. Sirma AI
* @author Damyan Ognyanoff
* @version 1.0
*/
class Job implements Serializable {
/**
* The description of the method being invoked. Actually, it is a char array
* which begins with the name of the method followed by the names of the
* classes of its arguments. All these substrings are separated by '|'
* character. The description is parsed on the other side of the channel
* and it is used to locate and invoke that method on the reflected instance
* there.
*/
char[] methodDescription;
/**
* the actual arguments used within the method call. They should be either
* instances imeplemnting java.io.Serializable
or be some of the java native
* types e.g. byte, char, etc.
*/
byte[] serializedArgs;
/**
* constructor
* @param methodDescription of the method to be batched
* @param args used for the method call
*/
public Job(char[] methodDescription, Object[] args) {
this.methodDescription = methodDescription;
java.io.ByteArrayOutputStream buf = new java.io.ByteArrayOutputStream(2048);
try {
java.io.ObjectOutputStream oo = new java.io.ObjectOutputStream(buf);
oo.writeObject(args);
} catch (java.io.IOException e) {
e.printStackTrace();
// should throw some exception here
}
this.serializedArgs = buf.toByteArray();
}
/**
* second constructor that receive a method description as String
* @param m the description of the method invoked
* @param args used for the the method call
*/
public Job(String m, Object[] args) {
this(m.toCharArray(), args);
}
} //Job
© 2015 - 2025 Weber Informatics LLC | Privacy Policy