本文整理汇总了Java中org.omg.CORBA.Any.insert_Object方法的典型用法代码示例。如果您正苦于以下问题:Java Any.insert_Object方法的具体用法?Java Any.insert_Object怎么用?Java Any.insert_Object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.omg.CORBA.Any
的用法示例。
在下文中一共展示了Any.insert_Object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeAny
import org.omg.CORBA.Any; //导入方法依赖的package包/类
/**
* Writes any java.lang.Object as a CORBA any.
* @param out the stream in which to write the any.
* @param obj the object to write as an any.
*/
public void writeAny( org.omg.CORBA.portable.OutputStream out,
java.lang.Object obj)
{
org.omg.CORBA.ORB orb = out.orb();
// Create Any
Any any = orb.create_any();
// Make sure we have a connected object...
java.lang.Object newObj = Utility.autoConnect(obj,orb,false);
if (newObj instanceof org.omg.CORBA.Object) {
any.insert_Object((org.omg.CORBA.Object)newObj);
} else {
if (newObj == null) {
// Handle the null case, including backwards
// compatibility issues
any.insert_Value(null, createTypeCodeForNull(orb));
} else {
if (newObj instanceof Serializable) {
// If they're our Any and ORB implementations,
// we may want to do type code related versioning.
TypeCode tc = createTypeCode((Serializable)newObj, any, orb);
if (tc == null)
any.insert_Value((Serializable)newObj);
else
any.insert_Value((Serializable)newObj, tc);
} else if (newObj instanceof Remote) {
ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
} else {
ORBUtility.throwNotSerializableForCorba(newObj.getClass().getName());
}
}
}
out.write_any(any);
}