本文整理汇总了Java中java.rmi.server.ObjID.read方法的典型用法代码示例。如果您正苦于以下问题:Java ObjID.read方法的具体用法?Java ObjID.read怎么用?Java ObjID.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.rmi.server.ObjID
的用法示例。
在下文中一共展示了ObjID.read方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readExternal
import java.rmi.server.ObjID; //导入方法依赖的package包/类
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException
{
manager = UnicastConnectionManager.read(in);
objid = ObjID.read(in);
byte ack = in.readByte();
// This byte is somewhat confusing when interoperating with JDK
if (ack != RETURN_ACK && ack != 0/* jdk ack value */)
{
throw new IOException("no ack found");
}
// Notify the DGC of the remote side that we hold the reference to the
// received object. Do not notify if the client and server are on the
// same virtual machine.
if (manager.serverobj == null)
LeaseRenewingTask.scheduleLeases(this);
}
示例2: readCommon
import java.rmi.server.ObjID; //导入方法依赖的package包/类
/**
* Reads everything left except Endpoint info from the given stream and
* detects if DGC ack is needed.
*
* @param in the stream to read data from
*
* @throws IOException if any I/O error occurred
* @throws ClassNotFoundException if class could not be loaded by current
* class loader
*/
protected void readCommon(ObjectInput in)
throws IOException, ClassNotFoundException {
objId = ObjID.read(in);
boolean needAck = in.readBoolean();
if (in instanceof RMIObjectInputStream) {
RMIObjectInputStream oin = (RMIObjectInputStream) in;
if (oin.isRemoteCallStream()) {
oin.needDGCAck(needAck);
}
}
RMIObjectInfo info = ExportManager.getInfo(objId);
if ((info == null) || !info.sref.remoteEquals(this)) {
/*
* This remote object created in another VM so
* register it in ClientDGC.
*/
ClientDGC.registerForRenew(this);
}
}
示例3: read
import java.rmi.server.ObjID; //导入方法依赖的package包/类
public static LiveRef read(ObjectInput in, boolean useNewFormat)
throws IOException, ClassNotFoundException
{
Endpoint ep;
ObjID id;
// Now read in the endpoint, id, and result flag
// (need to choose whether or not to read old JDK1.1 endpoint format)
if (useNewFormat) {
ep = TCPEndpoint.read(in);
} else {
ep = TCPEndpoint.readHostPortFormat(in);
}
id = ObjID.read(in);
boolean isResultStream = in.readBoolean();
LiveRef ref = new LiveRef(id, ep, false);
if (in instanceof ConnectionInputStream) {
ConnectionInputStream stream = (ConnectionInputStream)in;
// save ref to send "dirty" call after all args/returns
// have been unmarshaled.
stream.saveRef(ref);
if (isResultStream) {
// set flag in stream indicating that remote objects were
// unmarshaled. A DGC ack should be sent by the transport.
stream.setAckNeeded();
}
} else {
DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
}
return ref;
}
示例4: doCall
import java.rmi.server.ObjID; //导入方法依赖的package包/类
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
ObjectInputStream ois = new ObjectInputStream(in) {
@Override
protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
return ObjID[].class;
} else if ("java.rmi.server.ObjID".equals(desc.getName())) {
return ObjID.class;
} else if ( "java.rmi.server.UID".equals(desc.getName())) {
return UID.class;
}
throw new IOException("Not allowed to read object");
}
};
ObjID read;
try {
read = ObjID.read(ois);
}
catch ( java.io.IOException e ) {
throw new MarshalException("unable to read objID", e);
}
if ( read.hashCode() == 2 ) {
ois.readInt(); // method
ois.readLong(); // hash
System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
}
System.err.println("Sending return with payload for obj " + read);
out.writeByte(TransportConstants.Return);// transport op
ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);
oos.writeByte(TransportConstants.ExceptionalReturn);
new UID().write(oos);
BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
Reflections.setFieldValue(ex, "val", payload);
oos.writeObject(ex);
oos.flush();
out.flush();
this.hadConnection = true;
synchronized ( this.waitLock ) {
this.waitLock.notifyAll();
}
}
示例5: doCall
import java.rmi.server.ObjID; //导入方法依赖的package包/类
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
ObjectInputStream ois = new ObjectInputStream(in) {
@Override
protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
return ObjID[].class;
} else if ("java.rmi.server.ObjID".equals(desc.getName())) {
return ObjID.class;
} else if ( "java.rmi.server.UID".equals(desc.getName())) {
return UID.class;
}
throw new IOException("Not allowed to read object");
}
};
ObjID read;
try {
read = ObjID.read(ois);
}
catch ( java.io.IOException e ) {
throw new MarshalException("unable to read objID", e);
}
if ( read.hashCode() == 2 ) {
ois.readInt(); // method
ois.readLong(); // hash
System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
}
System.err.println("Sending return with payload for obj " + read);
out.writeByte(TransportConstants.Return);// transport op
ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);
oos.writeByte(TransportConstants.ExceptionalReturn);
new UID().write(oos);
BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
Reflections.setFieldValue(ex, "val", payload);
oos.writeObject(ex);
oos.flush();
out.flush();
this.hadConnection = true;
synchronized ( this.waitLock ) {
this.waitLock.notifyAll();
}
}
示例6: doCall
import java.rmi.server.ObjID; //导入方法依赖的package包/类
private void doCall ( DataInputStream in, DataOutputStream out ) throws Exception {
ObjectInputStream ois = new ObjectInputStream(in) {
@Override
protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName()) ) {
return ObjID[].class;
}
else if ( "java.rmi.server.ObjID".equals(desc.getName()) ) {
return ObjID.class;
}
else if ( "java.rmi.server.UID".equals(desc.getName()) ) {
return UID.class;
}
else if ( "java.lang.String".equals(desc.getName()) ) {
return String.class;
}
throw new IOException("Not allowed to read object");
}
};
ObjID read;
try {
read = ObjID.read(ois);
}
catch ( java.io.IOException e ) {
throw new MarshalException("unable to read objID", e);
}
if ( read.hashCode() == 2 ) {
// DGC
handleDGC(ois);
}
else if ( read.hashCode() == 0 ) {
if ( handleRMI(ois, out) ) {
this.hadConnection = true;
synchronized ( this.waitLock ) {
this.waitLock.notifyAll();
}
return;
}
}
}
示例7: testAnonymousRegistry
import java.rmi.server.ObjID; //导入方法依赖的package包/类
public void testAnonymousRegistry() throws Exception {
// Make the registry
Registry reg = LocateRegistry.createRegistry(0);
// Convert it to a stub
Remote stub = RemoteObject.toStub(reg);
// Analyze the serial form of the stub
SObject sstub = (SObject) SerialScan.examine(stub); // (SObject) ss.readObject();
System.out.println(sstub);
// The interesting data is in the "annotations", i.e. the data
// written by the writeObject method as documented.
List<SEntity> annots = sstub.getAnnotations();
assertEquals(1, annots.size());
SBlockData sdata = (SBlockData) annots.get(0);
DataInputStream din = sdata.getDataInputStream();
// Read the UnicastRef encoding
// Type string
String unicastref = din.readUTF();
assertEquals("UnicastRef", unicastref);
// Host address
String host = din.readUTF();
// Test that this is indeed a local address by creating a ServerSocket.
// That will fail if this is not a valid address or if it is remote.
InetAddress addr = InetAddress.getByName(host);
ServerSocket socket = new ServerSocket(0, 0, addr);
socket.close();
// Port (this is what we would be after if we were using this to
// discover the port number assigned by the kernel).
int port = din.readInt();
assertTrue(port != 0);
System.out.println("The port is " + port);
// ObjID, should be the registry id.
ObjectInput idin = new DataObjectInput(din);
ObjID objID = ObjID.read(idin);
assertEquals(new ObjID(ObjID.REGISTRY_ID), objID);
// Boolean value false
boolean b = din.readBoolean();
assertFalse(b);
// Check we've exhausted the data
assertEquals(-1, din.read());
}