use of si.ijs.acs.objectexplorer.engine.DataStruct in project ACS by ACS-Community.
the class BACIIntrospector method extractTypedef.
/**
* Insert the method's description here.
* Creation date: (7.11.2000 1:00:12)
* @return java.lang.Object
* @param argument org.omg.CORBA.Any
*/
public java.lang.Object extractTypedef(TypeCode tc, Any argument) {
if (argument == null)
throw new NullPointerException("argument");
DynAny dany;
try {
dany = ra.getDynFact().create_dyn_any(argument);
} catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
e.printStackTrace();
return null;
}
DynStruct str = (DynStruct) dany;
try {
if (tc.kind() == TCKind.tk_struct) {
DataStruct ds = new DataStruct(dany.type().id());
for (int i = 0; i < str.component_count(); i++) {
ds.add(str.current_member_name(), extractAny(str.current_component().to_any()));
str.next();
}
return ds;
} else {
DataException de = new DataException(dany.type().id());
for (int i = 0; i < str.component_count(); i++) {
de.add(str.current_member_name(), extractAny(str.current_component().to_any()));
str.next();
}
return de;
}
} catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch e) {
e.printStackTrace();
return null;
} catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue e) {
e.printStackTrace();
return null;
} catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
e.printStackTrace();
return null;
}
}
use of si.ijs.acs.objectexplorer.engine.DataStruct in project ACS by ACS-Community.
the class BACIIntrospector method getStructDef.
private DataStruct getStructDef(TypeCode tc) {
if (tc.kind() != TCKind.tk_struct)
return null;
try {
DataStruct ds = new DataStruct(tc.id());
Contained ctd = ra.lookupId(tc.id());
StructDef sd = StructDefHelper.narrow(ctd);
StructMember[] mems = sd.members();
for (int i = 0; i < mems.length; i++) {
DataType dt = new BACIDataType(getClassType(mems[i].type));
dt.setElement(getDef(mems[i].type));
ds.add(mems[i].name, dt);
}
return ds;
} catch (org.omg.CORBA.TypeCodePackage.BadKind e) {
e.printStackTrace();
return null;
}
}
use of si.ijs.acs.objectexplorer.engine.DataStruct in project ACS by ACS-Community.
the class BACIRemoteAccess method internalInvokeInvocation.
/**
* Insert the method's description here.
* Creation date: (2.11.2000 18:08:47)
* @return si.ijs.acs.objectexplorer.engine.Invocation
* @param target si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
* @param op si.ijs.acs.objectexplorer.engine.Operation
*/
private Invocation internalInvokeInvocation(//TODO update secondary tree???
BACIRemote target, BACIOperation op, java.lang.Object[] params, RemoteResponseCallback cb) {
int callbackIndex = baciIntrospector.getCallbackLocation(op);
if (callbackIndex == -1)
throw new IntrospectionInconsistentException("Asynchronous operation '" + op + "' must take exactly one callback parameter.");
/* create callback */
CallbackImpl cbImpl = null;
try {
cbImpl = new CallbackImpl(op.getOperationDesc().parameters[callbackIndex].type.id(), cb);
} catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
throw new RemoteException("Error while trying to analyze typecode: " + bk);
}
org.omg.CORBA.Object cbIF = cbImpl._this_object(orb);
notifier.reportDebug("BACIRemoteAccess::internalInvokeInvocation", "Activated callback object for '" + op + "'.");
DataStruct desc = new DataStruct("IDL:alma/ACS/CBDescIn:1.0");
desc.add("normal_timeout", new Long(1000000));
desc.add("negotiable_timeout", new Long(5000000));
desc.add("id_tag", new Integer(0));
params[callbackIndex] = cbIF;
if (callbackIndex == params.length - 1) {
if (!isStrict())
notifier.reportDebug("BACIRemoteAccess::internalInvokeInvocation", "Non-strict BACI invocation signature: callback is not followed by a descriptor.");
else
throw new IntrospectionInconsistentException("Callback cannot be the last argument, because it must be followed by the descriptor.");
} else
params[callbackIndex + 1] = desc;
BACIInvocation invoc = new BACIInvocation(TRANSIENT, op.getName(), null, cb, parent.getTree(), this);
cbImpl.setInvocation(invoc);
invoc.setRemoteCall(internalInvokeTrivial(target, op, params));
synchronized (invocations) {
invocations.add(invoc);
}
notifier.reportDebug("BACIRemoteAccess::internalInvokeInvocation", "Remote call ended, constructed Invocation. Returning...");
return invoc;
}
use of si.ijs.acs.objectexplorer.engine.DataStruct in project ACS by ACS-Community.
the class BACIIntrospector method insertTypedef.
public Any insertTypedef(TypeCode tc, java.lang.Object obj) {
DynAny dany;
try {
dany = ra.getDynFact().create_dyn_any_from_type_code(tc);
} catch (org.omg.DynamicAny.DynAnyFactoryPackage.InconsistentTypeCode e) {
e.printStackTrace();
return null;
}
//Class<?> cl = getClassType(tc);
DynStruct str = (DynStruct) dany;
NameDynAnyPair[] mems = str.get_members_as_dyn_any();
try {
if (tc.kind() == TCKind.tk_struct) {
DataStruct ds = (DataStruct) obj;
for (int i = 0; i < mems.length; i++) {
mems[i].value.from_any(insertAny(mems[i].value.to_any(), ds.get(mems[i].id)));
}
} else {
DataException de = (DataException) obj;
for (int i = 0; i < mems.length; i++) {
mems[i].value.from_any(insertAny(mems[i].value.to_any(), de.get(mems[i].id)));
}
}
str.set_members_as_dyn_any(mems);
} catch (org.omg.DynamicAny.DynAnyPackage.TypeMismatch e) {
e.printStackTrace();
return null;
} catch (org.omg.DynamicAny.DynAnyPackage.InvalidValue e) {
e.printStackTrace();
return null;
}
//displayAny(dany.to_any());
return dany.to_any();
}
Aggregations