Search in sources :

Example 11 with BeanTypeInfo

use of org.apache.cxf.aegis.type.basic.BeanTypeInfo in project cxf by apache.

the class ConfigurationTest method testExtensibleDefaultTrue.

@Test
public void testExtensibleDefaultTrue() throws Exception {
    config.setDefaultExtensibleElements(true);
    config.setDefaultExtensibleAttributes(true);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertTrue(info.isExtensibleElements());
    assertTrue(info.isExtensibleAttributes());
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) AegisType(org.apache.cxf.aegis.type.AegisType) BeanType(org.apache.cxf.aegis.type.basic.BeanType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 12 with BeanTypeInfo

use of org.apache.cxf.aegis.type.basic.BeanTypeInfo in project cxf by apache.

the class CustomMappingTest method testInheritedMapping.

@Test
public void testInheritedMapping() throws Exception {
    BeanTypeInfo bti = new BeanTypeInfo(GregorianCalendar.class, "http://util.java");
    BeanType beanType = new BeanType(bti);
    beanType.setSchemaType(new QName("http://util.java{GregorianCalendar}"));
    AegisContext context = new AegisContext();
    context.initialize();
    TypeMapping mapping = context.getTypeMapping();
    // we are replacing the default mapping.
    mapping.register(beanType);
    XmlSchema schema = newXmlSchema("http://util.java");
    beanType.writeSchema(schema);
// well, test?
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) BeanType(org.apache.cxf.aegis.type.basic.BeanType) XmlSchema(org.apache.ws.commons.schema.XmlSchema) QName(javax.xml.namespace.QName) AegisContext(org.apache.cxf.aegis.AegisContext) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 13 with BeanTypeInfo

use of org.apache.cxf.aegis.type.basic.BeanTypeInfo in project cxf by apache.

the class NoDefaultConstructorBeanKeyType method readObject.

@Override
public Object readObject(MessageReader reader, Context context) throws DatabindingException {
    BeanTypeInfo inf = getTypeInfo();
    try {
        String key = null;
        // Read child elements
        while (reader.hasMoreElementReaders()) {
            MessageReader childReader = reader.getNextElementReader();
            if (childReader.isXsiNil()) {
                childReader.readToEnd();
                continue;
            }
            QName name = childReader.getName();
            AegisType defaultType = inf.getType(name);
            AegisType type = TypeUtil.getReadType(childReader.getXMLStreamReader(), context.getGlobalContext(), defaultType);
            if (type != null) {
                String value = (String) type.readObject(childReader, context);
                if ("key".equals(name.getLocalPart())) {
                    key = value;
                }
            } else {
                childReader.readToEnd();
            }
        }
        return new NoDefaultConstructorBeanKeyImpl(key);
    } catch (IllegalArgumentException e) {
        throw new DatabindingException("Illegal argument. " + e.getMessage(), e);
    }
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) DatabindingException(org.apache.cxf.aegis.DatabindingException) AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) NoDefaultConstructorBeanKeyImpl(org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanKeyImpl) MessageReader(org.apache.cxf.aegis.xml.MessageReader)

Aggregations

BeanTypeInfo (org.apache.cxf.aegis.type.basic.BeanTypeInfo)13 QName (javax.xml.namespace.QName)10 AegisType (org.apache.cxf.aegis.type.AegisType)8 BeanType (org.apache.cxf.aegis.type.basic.BeanType)8 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)7 Test (org.junit.Test)7 DatabindingException (org.apache.cxf.aegis.DatabindingException)3 AegisContext (org.apache.cxf.aegis.AegisContext)2 MessageReader (org.apache.cxf.aegis.xml.MessageReader)2 NoDefaultConstructorBeanImpl (org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanImpl)1 NoDefaultConstructorBeanKeyImpl (org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanKeyImpl)1 TypeMapping (org.apache.cxf.aegis.type.TypeMapping)1 XmlSchema (org.apache.ws.commons.schema.XmlSchema)1