use of org.omg.CORBA.TypeCode in project ACS by ACS-Community.
the class BACIRemoteAccess method internalParentConnect.
/**
* Insert the method's description here.
* Creation date: (2.11.2000 0:35:23)
* @param baciNode si.ijs.acs.objectexplorer.engine.BACI.BACIRemoteNode
*/
private void internalParentConnect(BACIRemoteNode baciNode, boolean doSync) {
/* we are using the parent to query the object as either an IDL attribute or
Java property accessor design pattern (returns Object type, takes no parameters)
*/
// System.out.println("IPC");
String targetName = null;
TypeCode retType = null;
String id = null;
if (baciNode.getNodeType() == ATTRIBUTE) {
AttributeDescription ad = (AttributeDescription) baciNode.getUserObject();
try {
id = ad.type.id();
} catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
throw new RemoteException("IDL: BadKind thrown on type id lookup for PROPERTY child of the remote node: " + bk);
}
targetName = BACIIntrospector.attributeNameToMethodName(ad.name);
retType = ad.type;
notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Obtaining IDL attribute reference for '" + ad.name + "'.");
} else if (baciNode.getNodeType() == PROPERTY) {
OperationDescription od = (OperationDescription) baciNode.getUserObject();
try {
id = od.result.id();
} catch (org.omg.CORBA.TypeCodePackage.BadKind bk) {
throw new RemoteException("IDL: BadKind thrown on type id lookup for PROPERTY child of the remote node: " + bk);
}
targetName = od.name;
retType = od.result;
notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Obtaining reference to contained object through property accessor design pattern for '" + od.name + ".");
} else
throw new IntrospectionInconsistentException("Devices can contain objects only as IDL attributes or property accessor design patterns. Failed on '" + baciNode + "'.");
BACIRemoteNode parentNode = (BACIRemoteNode) baciNode.getParent();
if (parentNode.getCORBARef() == null) {
parentNode.connect();
if (parentNode.getCORBARef() == null)
throw new RemoteException("Child node is accessible although the parent node CORBA reference is null. Failed on '" + baciNode + ".");
}
/* begin DII stanza */
Request req = parentNode.getCORBARef()._request(targetName);
req.set_return_type(retType);
notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Invoking remote call...");
req.invoke();
Any returnValue = req.return_value();
if (returnValue.type().kind() != TCKind.tk_objref)
throw new IntrospectionInconsistentException("Return type of '" + targetName + "' is not of type object reference, expected object reference because of BACI containment specifications.");
baciNode.setCORBARef(returnValue.extract_Object());
//
baciNode.setIFDesc(getIFDesc(id));
//
if (baciNode.getCORBARef() != null)
notifier.reportDebug("BACIRemoteAccess::internalParentConnect", "Connection to contained object OK.");
else
notifier.reportError("Reference returned when resolving contained object '" + targetName + "' is null.");
/* end DII stanza */
}
use of org.omg.CORBA.TypeCode in project ACS by ACS-Community.
the class ComponentsManager method getComponentProperties.
/**
* Recursive function to get the list of all the ACS properties
* for a given IDL type. It scans the current interface, and then
* it sub-scans the inherited types
*
* @param ifdef The IDL interface defintion
* @return The list of properties for the given IDL definition, including the parents' properties
* @throws BadKind
*/
private List<String> getComponentProperties(InterfaceDef ifdef) throws BadKind {
List<String> tmp = new ArrayList<String>();
FullInterfaceDescription ifdes = ifdef.describe_interface();
for (int i = 0; i < ifdes.attributes.length; i++) {
TypeCode tc = ifdes.attributes[i].type;
if (// ojo
tc.kind() != TCKind.tk_objref)
continue;
InterfaceDef tcdef = InterfaceDefHelper.narrow(rep.lookup_id(tc.id()));
if (tc.kind() == TCKind.tk_objref && tcdef.is_a(IDL_PROPERTY))
tmp.add(ifdes.attributes[i].name);
}
// Lookup the children properties
// TODO: Loop only over CharacteristicComponent interfaces
InterfaceDef[] ifaces = ifdef.base_interfaces();
for (int i = 0; i != ifaces.length; i++) {
tmp.addAll(getComponentProperties(ifaces[i]));
}
return tmp;
}
use of org.omg.CORBA.TypeCode in project cxf by apache.
the class CorbaUtils method getTypeCode.
public static TypeCode getTypeCode(ORB orb, QName type, CorbaType obj, CorbaTypeMap typeMap, Stack<QName> seenTypes) {
if (type == null) {
throw new CorbaBindingException("corba:typemap type or elemtype information required" + (obj == null ? "" : " for " + obj) + (seenTypes.empty() ? "" : ", Enclosing type: " + seenTypes.elementAt(0)));
}
TypeCode tc = null;
// first see if it is a primitive
tc = getPrimitiveTypeCode(orb, type);
if (tc == null && type.equals(CorbaConstants.NT_CORBA_ANY)) {
// Anys are handled in a special way
tc = orb.get_primitive_tc(TCKind.from_int(TCKind._tk_any));
} else if (tc == null) {
if (typeMap == null) {
throw new CorbaBindingException("Unable to locate typemap for namespace \"" + type.getNamespaceURI() + "\"");
}
tc = typeMap.getTypeCode(type);
if (tc == null) {
if (obj == null) {
obj = typeMap.getType(type.getLocalPart());
if (obj == null) {
throw new CorbaBindingException("Unable to locate object definition");
}
}
tc = getComplexTypeCode(orb, type, obj, typeMap, seenTypes);
if (tc != null) {
typeMap.addTypeCode(type, tc);
}
}
}
if (tc == null) {
throw new CorbaBindingException("Corba type node with qname " + type + " is not supported");
}
return tc;
}
use of org.omg.CORBA.TypeCode in project wildfly by wildfly.
the class InterfaceRepository method addAttributes.
/**
* Add a set of attributes to a container (interface or value class).
*/
private void addAttributes(LocalContainer container, ContainerAnalysis ca) throws RMIIIOPViolationException, IRConstructionException {
AttributeAnalysis[] attrs = ca.getAttributes();
for (int i = 0; i < attrs.length; ++i) {
AttributeDefImpl aDef;
String aid = ca.getMemberRepositoryId(attrs[i].getJavaName());
String aName = attrs[i].getIDLName();
Class cls = attrs[i].getCls();
TypeCode typeCode = getTypeCode(cls);
aDef = new AttributeDefImpl(aid, aName, "1.0", attrs[i].getMode(), typeCode, container, impl);
container.add(aName, aDef);
}
}
use of org.omg.CORBA.TypeCode in project wildfly by wildfly.
the class InterfaceRepository method addArray.
/**
* Add an array.
*/
private ValueBoxDefImpl addArray(Class cls) throws RMIIIOPViolationException, IRConstructionException {
if (!cls.isArray())
throw IIOPLogger.ROOT_LOGGER.classIsNotArray(cls.getName());
ValueBoxDefImpl vbDef;
// Lookup: Has it already been added?
vbDef = (ValueBoxDefImpl) arrayMap.get(cls);
if (vbDef != null)
// Yes, just return it.
return vbDef;
int dimensions = 0;
Class compType = cls;
do {
compType = compType.getComponentType();
++dimensions;
} while (compType.isArray());
String typeName;
String moduleName;
TypeCode typeCode;
if (compType.isPrimitive()) {
if (compType == Boolean.TYPE) {
typeName = "boolean";
typeCode = orb.get_primitive_tc(TCKind.tk_boolean);
} else if (compType == Character.TYPE) {
typeName = "wchar";
typeCode = orb.get_primitive_tc(TCKind.tk_wchar);
} else if (compType == Byte.TYPE) {
typeName = "octet";
typeCode = orb.get_primitive_tc(TCKind.tk_octet);
} else if (compType == Short.TYPE) {
typeName = "short";
typeCode = orb.get_primitive_tc(TCKind.tk_short);
} else if (compType == Integer.TYPE) {
typeName = "long";
typeCode = orb.get_primitive_tc(TCKind.tk_long);
} else if (compType == Long.TYPE) {
typeName = "long_long";
typeCode = orb.get_primitive_tc(TCKind.tk_longlong);
} else if (compType == Float.TYPE) {
typeName = "float";
typeCode = orb.get_primitive_tc(TCKind.tk_float);
} else if (compType == Double.TYPE) {
typeName = "double";
typeCode = orb.get_primitive_tc(TCKind.tk_double);
} else {
throw IIOPLogger.ROOT_LOGGER.unknownPrimitiveType(compType.getName());
}
moduleName = "org.omg.boxedRMI";
} else {
// map the component type.
typeCode = getTypeCode(compType);
if (compType == java.lang.String.class)
typeName = getJavaLangString().name();
else if (compType == java.lang.Object.class)
typeName = getJavaLang_Object().name();
else if (compType == java.lang.Class.class)
typeName = getJavaxRmiCORBAClassDesc().name();
else if (compType == java.io.Serializable.class)
typeName = getJavaIoSerializable().name();
else if (compType == java.io.Externalizable.class)
typeName = getJavaIoExternalizable().name();
else if (compType.isInterface() && !RmiIdlUtil.isAbstractValueType(compType))
typeName = ((InterfaceDefImpl) interfaceMap.get(compType)).name();
else if (// exception type
Exception.class.isAssignableFrom(compType))
typeName = ((ExceptionDefImpl) exceptionMap.get(compType)).name();
else
// must be value type
typeName = ((ValueDefImpl) valueMap.get(compType)).name();
moduleName = "org.omg.boxedRMI." + compType.getPackage().getName();
}
// Get module to add array to.
ModuleDefImpl m = ensurePackageExists(moduleName);
// Create an array of the types for the dimensions
Class[] types = new Class[dimensions];
types[dimensions - 1] = cls;
for (int i = dimensions - 2; i >= 0; --i) types[i] = types[i + 1].getComponentType();
// Create boxed sequences for all dimensions.
for (int i = 0; i < dimensions; ++i) {
Class type = types[i];
typeCode = orb.create_sequence_tc(0, typeCode);
vbDef = (ValueBoxDefImpl) arrayMap.get(type);
if (vbDef == null) {
String id = Util.getIRIdentifierOfClass(type);
SequenceDefImpl sdi = new SequenceDefImpl(typeCode, impl);
String name = "seq" + (i + 1) + "_" + typeName;
// TypeCode boxTypeCode = new TypeCodeImpl(TCKind._tk_value_box,
// id, name, typeCode);
TypeCode boxTypeCode = orb.create_value_box_tc(id, name, typeCode);
vbDef = new ValueBoxDefImpl(id, name, "1.0", m, boxTypeCode, impl);
addTypeCode(type, vbDef.type());
m.add(name, vbDef);
impl.putSequenceImpl(id, typeCode, sdi, vbDef);
// Remember we mapped this.
arrayMap.put(type, vbDef);
typeCode = boxTypeCode;
} else
typeCode = vbDef.type();
}
// Return the box of highest dimension.
return vbDef;
}
Aggregations