use of org.omg.CORBA.TypeCode in project cxf by apache.
the class CorbaAnyEventProducer method getAnyContainedType.
private CorbaObjectHandler getAnyContainedType(Any a) {
CorbaObjectHandler result = null;
TypeCode tc = a.type();
QName containedName = new QName("AnyContainedType");
QName idlType = null;
if (CorbaUtils.isPrimitiveTypeCode(tc)) {
idlType = CorbaAnyHelper.getPrimitiveIdlTypeFromTypeCode(tc);
result = new CorbaPrimitiveHandler(containedName, idlType, tc, null);
} else if (tc.kind().value() == TCKind._tk_any) {
idlType = CorbaConstants.NT_CORBA_ANY;
result = new CorbaAnyHandler(containedName, idlType, tc, null);
((CorbaAnyHandler) result).setTypeMap(handler.getTypeMap());
} else {
idlType = handler.getTypeMap().getIdlType(tc);
result = CorbaHandlerUtils.initializeObjectHandler(orb, containedName, idlType, handler.getTypeMap(), serviceInfo);
}
InputStream is = a.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(is);
reader.read(result);
return result;
}
use of org.omg.CORBA.TypeCode in project cxf by apache.
the class CorbaHandlerUtils method getTypeListener.
public static CorbaTypeListener getTypeListener(QName name, QName idlType, CorbaTypeMap typeMap, ORB orb, ServiceInfo serviceInfo) throws CorbaBindingException {
CorbaObjectHandler handler = null;
TypeCode tc = CorbaUtils.getTypeCode(orb, idlType, typeMap);
try {
while (tc.kind().value() == TCKind._tk_alias) {
Alias alias = (Alias) CorbaUtils.getCorbaType(idlType, typeMap);
if (alias == null) {
throw new CorbaBindingException("Couldn't find corba alias type: " + idlType);
}
tc = tc.content_type();
idlType = alias.getBasetype();
}
} catch (Throwable ex) {
throw new CorbaBindingException(ex);
}
CorbaTypeListener result = null;
if (CorbaUtils.isPrimitiveIdlType(idlType)) {
handler = new CorbaPrimitiveHandler(name, idlType, tc, null);
result = new CorbaPrimitiveListener(handler);
} else {
CorbaType type = CorbaUtils.getCorbaType(idlType, typeMap);
switch(tc.kind().value()) {
case TCKind._tk_any:
handler = new CorbaAnyHandler(name, idlType, tc, type);
((CorbaAnyHandler) handler).setTypeMap(typeMap);
result = new CorbaAnyListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_array:
handler = new CorbaArrayHandler(name, idlType, tc, type);
result = new CorbaArrayListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_enum:
handler = new CorbaEnumHandler(name, idlType, tc, type);
result = new CorbaEnumListener(handler);
break;
case TCKind._tk_except:
handler = new CorbaExceptionHandler(name, idlType, tc, type);
result = new CorbaExceptionListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_fixed:
handler = new CorbaFixedHandler(name, idlType, tc, type);
result = new CorbaFixedListener(handler);
break;
case TCKind._tk_sequence:
if (isOctets(type)) {
handler = new CorbaOctetSequenceHandler(name, idlType, tc, type);
result = new CorbaOctetSequenceListener(handler);
} else {
handler = new CorbaSequenceHandler(name, idlType, tc, type);
result = new CorbaSequenceListener(handler, typeMap, orb, serviceInfo);
}
break;
case TCKind._tk_string:
case TCKind._tk_wstring:
// These can be handled just like regular strings
handler = new CorbaPrimitiveHandler(name, idlType, tc, type);
result = new CorbaPrimitiveListener(handler);
break;
case TCKind._tk_struct:
handler = new CorbaStructHandler(name, idlType, tc, type);
result = new CorbaStructListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_union:
handler = new CorbaUnionHandler(name, idlType, tc, type);
result = new CorbaUnionListener(handler, typeMap, orb, serviceInfo);
break;
case TCKind._tk_objref:
handler = new CorbaObjectReferenceHandler(name, idlType, tc, type);
result = new CorbaObjectReferenceListener(handler, orb);
break;
default:
throw new CorbaBindingException("Unsupported complex type " + idlType);
}
}
return result;
}
use of org.omg.CORBA.TypeCode in project cxf by apache.
the class CorbaHandlerUtils method getTypeEventProducer.
public static CorbaTypeEventProducer getTypeEventProducer(CorbaObjectHandler handler, ServiceInfo serviceInfo, ORB orb) throws CorbaBindingException {
QName idlType = handler.getIdlType();
TypeCode tc = handler.getTypeCode();
CorbaTypeEventProducer result = null;
if (CorbaUtils.isPrimitiveIdlType(idlType)) {
result = new CorbaPrimitiveTypeEventProducer(handler);
} else {
switch(tc.kind().value()) {
case TCKind._tk_any:
result = new CorbaAnyEventProducer(handler, serviceInfo, orb);
break;
case TCKind._tk_array:
result = new CorbaArrayEventProducer(handler, serviceInfo, orb);
break;
case TCKind._tk_enum:
result = new CorbaEnumEventProducer(handler);
break;
case TCKind._tk_except:
result = new CorbaExceptionEventProducer(handler, serviceInfo, orb);
break;
case TCKind._tk_fixed:
result = new CorbaFixedEventProducer(handler);
break;
case TCKind._tk_sequence:
if (isOctets(handler.getType())) {
result = new CorbaOctetSequenceEventProducer(handler);
} else {
result = new CorbaSequenceEventProducer(handler, serviceInfo, orb);
}
break;
case TCKind._tk_string:
case TCKind._tk_wstring:
// These can be handled just like regular strings
result = new CorbaPrimitiveTypeEventProducer(handler);
break;
case TCKind._tk_struct:
if (handler.isAnonymousType()) {
result = new CorbaAnonStructEventProducer(handler, serviceInfo, orb);
} else {
result = new CorbaStructEventProducer(handler, serviceInfo, orb);
}
break;
case TCKind._tk_union:
result = new CorbaUnionEventProducer(handler, serviceInfo, orb);
break;
case TCKind._tk_objref:
result = new CorbaObjectReferenceEventProducer(handler, serviceInfo, orb);
break;
default:
throw new CorbaBindingException("Unsupported complex type " + idlType);
}
}
return result;
}
use of org.omg.CORBA.TypeCode in project cxf by apache.
the class CorbaHandlerUtils method createTypeHandler.
public static CorbaObjectHandler createTypeHandler(ORB orb, QName name, QName idlType, CorbaTypeMap typeMap) {
CorbaObjectHandler handler = null;
TypeCode tc = CorbaUtils.getTypeCode(orb, idlType, typeMap);
try {
while (tc.kind().value() == TCKind._tk_alias) {
Alias alias = (Alias) CorbaUtils.getCorbaType(idlType, typeMap);
if (alias == null) {
throw new CorbaBindingException("Couldn't find corba alias type: " + idlType);
}
tc = tc.content_type();
idlType = alias.getBasetype();
}
} catch (Throwable ex) {
throw new CorbaBindingException(ex);
}
if (CorbaUtils.isPrimitiveIdlType(idlType)) {
handler = new CorbaPrimitiveHandler(name, idlType, tc, null);
} else if (tc.kind().value() == TCKind._tk_any) {
// Any is a special kind of primitive so it gets its own handler
handler = new CorbaAnyHandler(name, idlType, tc, null);
((CorbaAnyHandler) handler).setTypeMap(typeMap);
} else {
CorbaType type = CorbaUtils.getCorbaType(idlType, typeMap);
switch(tc.kind().value()) {
case TCKind._tk_array:
handler = new CorbaArrayHandler(name, idlType, tc, type);
break;
case TCKind._tk_enum:
handler = new CorbaEnumHandler(name, idlType, tc, type);
break;
case TCKind._tk_except:
handler = new CorbaExceptionHandler(name, idlType, tc, type);
break;
case TCKind._tk_fixed:
handler = new CorbaFixedHandler(name, idlType, tc, type);
break;
case TCKind._tk_sequence:
if (isOctets(type)) {
handler = new CorbaOctetSequenceHandler(name, idlType, tc, type);
} else {
handler = new CorbaSequenceHandler(name, idlType, tc, type);
}
break;
case TCKind._tk_struct:
handler = new CorbaStructHandler(name, idlType, tc, type);
break;
case TCKind._tk_union:
handler = new CorbaUnionHandler(name, idlType, tc, type);
break;
case TCKind._tk_string:
case TCKind._tk_wstring:
// These need to be here to catch the anonymous string types.
handler = new CorbaPrimitiveHandler(name, idlType, tc, type);
break;
case TCKind._tk_objref:
handler = new CorbaObjectReferenceHandler(name, idlType, tc, type);
break;
default:
handler = new CorbaObjectHandler(name, idlType, tc, type);
}
}
return handler;
}
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;
}
Aggregations