use of org.apache.cxf.binding.corba.wsdl.Alias 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.apache.cxf.binding.corba.wsdl.Alias 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.apache.cxf.binding.corba.wsdl.Alias in project cxf by apache.
the class DeclaratorVisitor method visitNewTypes.
private void visitNewTypes(Scope newScope) {
CorbaType nextCorbaType = null;
XmlSchemaType nextSchemaType = null;
CorbaType oldCorbaType = getCorbaType();
QName newQname = new QName(getCorbaType().getQName().getNamespaceURI(), newScope.toString());
if (oldCorbaType instanceof Alias) {
// Alias
//
Alias oldAlias = (Alias) oldCorbaType;
Alias alias = new Alias();
alias.setQName(newQname);
alias.setBasetype(oldAlias.getBasetype());
alias.setType(oldAlias.getType());
alias.setRepositoryID(newScope.toIDLRepositoryID());
nextCorbaType = alias;
} else if (oldCorbaType instanceof Sequence) {
// Sequence
//
nextSchemaType = duplicateXmlSchemaComplexType(newScope);
Sequence oldSequence = (Sequence) oldCorbaType;
Sequence newSequence = new Sequence();
newSequence.setQName(newQname);
newSequence.setType(nextSchemaType.getQName());
newSequence.setElemtype(oldSequence.getElemtype());
newSequence.setElemname(oldSequence.getElemname());
newSequence.setBound(oldSequence.getBound());
newSequence.setRepositoryID(newScope.toIDLRepositoryID());
nextCorbaType = newSequence;
} else if (oldCorbaType instanceof Fixed) {
// Fixed
//
nextSchemaType = duplicateXmlSchemaSimpleType(newScope);
Fixed oldFixed = (Fixed) getCorbaType();
Fixed newFixed = new Fixed();
newFixed.setQName(newQname);
newFixed.setDigits(oldFixed.getDigits());
newFixed.setScale(oldFixed.getScale());
newFixed.setType(oldFixed.getType());
newFixed.setRepositoryID(newScope.toIDLRepositoryID());
nextCorbaType = newFixed;
} else {
System.err.println("[DeclaratorVisitor: Unexpected CORBA type error!]");
System.exit(1);
}
if (nextCorbaType != null) {
typeMap.getStructOrExceptionOrUnion().add(nextCorbaType);
}
}
use of org.apache.cxf.binding.corba.wsdl.Alias in project cxf by apache.
the class ScopedNameVisitor method populateAliasSchemaType.
protected static void populateAliasSchemaType(CorbaType corbaType, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
holder.setCorbaType(corbaType);
Alias alias = (Alias) corbaType;
// loop through alias base types, till you get a non-alias corba type
CorbaType type = findCorbaType(typeMap, alias.getBasetype());
while ((type != null) && (type instanceof Alias)) {
alias = (Alias) type;
type = findCorbaType(typeMap, alias.getBasetype());
}
QName tname;
if (type == null) {
// it must be a primitive type
tname = xmlSchemaPrimitiveMap.get(alias.getBasetype());
} else {
tname = type.getType();
}
XmlSchemaType stype = schemas.getTypeByQName(tname);
if (stype == null) {
XmlSchema xmlSchema = wsdlVisitor.getManager().getXmlSchema(tname.getNamespaceURI());
if (xmlSchema != null) {
stype = xmlSchema.getTypeByName(tname);
} else {
stype = wsdlVisitor.getSchema().getTypeByName(tname);
}
}
holder.setSchemaType(stype);
}
use of org.apache.cxf.binding.corba.wsdl.Alias in project cxf by apache.
the class ScopedNameVisitor method findNonSchemaType.
protected static boolean findNonSchemaType(String name, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
boolean result = false;
TypeMappingType typeMap = wsdlVisitor.getTypeMap();
XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
QName qname = new QName(typeMap.getTargetNamespace(), name);
CorbaType corbaType = findCorbaType(typeMap, qname);
if (corbaType != null) {
if (corbaType instanceof Alias) {
result = true;
if (holder != null) {
populateAliasSchemaType(corbaType, wsdlVisitor, holder);
}
} else if (((corbaType instanceof Sequence) || (corbaType instanceof Anonsequence)) && ((corbaType.getType().equals(Constants.XSD_BASE64)))) {
// special case of sequence of octets
result = true;
if (holder != null) {
holder.setCorbaType(corbaType);
holder.setSchemaType(schemas.getTypeByQName(corbaType.getType()));
}
}
}
return result;
}
Aggregations