// verifies if the server object really exists (useful if the IOR is
// valid, i.e corresponds to a good object) (e.g. old IOR)
// FIXME. To check if this call slows down performance
if (objRef._non_existent())
throw new MTPException("Bad IIOP server object reference:" + objRef.toString());
// Fill in the 'to' field of the IDL envelope
Iterator itTo = env.getAllTo();
List to = new ArrayList();
while(itTo.hasNext()) {
AID id = (AID)itTo.next();
to.add(marshalAID(id));
}
FIPA.AgentID[] IDLto = new FIPA.AgentID[to.size()];
for(int i = 0; i < to.size(); i++)
IDLto[i] = (FIPA.AgentID)to.get(i);
// Fill in the 'from' field of the IDL envelope
AID from = env.getFrom();
FIPA.AgentID[] IDLfrom = new FIPA.AgentID[] { marshalAID(from) };
// Fill in the 'intended-receiver' field of the IDL envelope
Iterator itIntendedReceiver = env.getAllIntendedReceiver();
List intendedReceiver = new ArrayList();
while(itIntendedReceiver.hasNext()) {
AID id = (AID)itIntendedReceiver.next();
intendedReceiver.add(marshalAID(id));
}
FIPA.AgentID[] IDLintendedReceiver = new FIPA.AgentID[intendedReceiver.size()];
for(int i = 0; i < intendedReceiver.size(); i++)
IDLintendedReceiver[i] = (FIPA.AgentID)intendedReceiver.get(i);
// Fill in the 'encrypted' field of the IDL envelope
//Iterator itEncrypted = env.getAllEncrypted();
//List encrypted = new ArrayList();
//while(itEncrypted.hasNext()) {
//String word = (String)itEncrypted.next();
//encrypted.add(word);
//}
String[] IDLencrypted = new String[0];
//String[] IDLencrypted = new String[encrypted.size()];
//for(int i = 0; i < encrypted.size(); i++)
//IDLencrypted[i] = (String)encrypted.get(i);
// Fill in the other fields of the IDL envelope ...
String IDLcomments = (env.getComments() != null)?env.getComments():"";
String IDLaclRepresentation = env.getAclRepresentation();
Long payloadLength = env.getPayloadLength();
int IDLpayloadLength = payloadLength.intValue();
String IDLpayloadEncoding = (env.getPayloadEncoding() != null)?env.getPayloadEncoding():"";
FIPA.DateTime[] IDLdate = new FIPA.DateTime[] { marshalDateTime(env.getDate()) };
FIPA.Property[][] IDLtransportBehaviour = new FIPA.Property[][] { };
// Fill in the 'userdefined-properties' field of the IDL envelope
Iterator itUserDefProps = env.getAllProperties();
List userDefProps = new ArrayList();
while(itUserDefProps.hasNext()) {
Property p = (Property)itUserDefProps.next();
userDefProps.add(marshalProperty(p));
}
FIPA.Property[] IDLuserDefinedProperties = new FIPA.Property[userDefProps.size()];
for(int i = 0; i < userDefProps.size(); i++)
IDLuserDefinedProperties[i] = (FIPA.Property)userDefProps.get(i);
// Fill in the list of 'received' stamps
/* FIXME: Maybe several IDL Envelopes should be generated, one for every 'received' stamp...
ReceivedObject[] received = env.getStamps();
FIPA.ReceivedObject[] IDLreceived = new FIPA.ReceivedObject[received.length];
for(int i = 0; i < received.length; i++)
IDLreceived[i] = marshalReceivedObj(received[i]);
*/
// FIXME: For now, only the current 'received' object is considered...
ReceivedObject received = env.getReceived();
FIPA.ReceivedObject[] IDLreceived;
if(received != null)
IDLreceived = new FIPA.ReceivedObject[] { marshalReceivedObj(received) };
else
IDLreceived = new FIPA.ReceivedObject[] { };
FIPA.Envelope IDLenv = new FIPA.Envelope(IDLto,
IDLfrom,
IDLcomments,
IDLaclRepresentation,
IDLpayloadLength,
IDLpayloadEncoding,
IDLdate,
IDLencrypted,
IDLintendedReceiver,
IDLreceived,
IDLtransportBehaviour,
IDLuserDefinedProperties);
FipaMessage msg = new FipaMessage(new FIPA.Envelope[] { IDLenv }, payload);
//String tmp = "\n\n"+(new java.util.Date()).toString()+" SENT IIOP MESSAGE"+ "\n" + env.toString() + "\n" + new String(payload);
//System.out.println(tmp);
//MessageTransportProtocol.log(tmp); // write in a log file for sent iiop message
objRef.message(msg);
}
catch(ClassCastException cce) {
cce.printStackTrace();
throw new MTPException("Address mismatch: this is not a valid IIOP address.");
}
catch(Exception cce2) {
cce2.printStackTrace();
throw new MTPException("Address mismatch: this is not a valid IIOP address.");
}
}