Search in sources :

Example 1 with BeanTypeInfo

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

the class DefaultTypeCreator method createDefaultType.

@Override
public AegisType createDefaultType(TypeClassInfo info) {
    BeanType type = new BeanType();
    /*
         * As of this point, we refuse to do this for generics in general.
         * This might be revisited ... it might turn out to 'just work'.
         */
    Class<?> typeClass = TypeUtil.getTypeClass(info.getType(), false);
    if (typeClass == null) {
        throw new DatabindingException("Unable to map generic type " + info.getType());
    }
    type.setSchemaType(createQName(typeClass));
    type.setTypeClass(typeClass);
    type.setTypeMapping(getTypeMapping());
    BeanTypeInfo typeInfo = type.getTypeInfo();
    typeInfo.setDefaultMinOccurs(getConfiguration().getDefaultMinOccurs());
    typeInfo.setExtensibleAttributes(getConfiguration().isDefaultExtensibleAttributes());
    typeInfo.setExtensibleElements(getConfiguration().isDefaultExtensibleElements());
    return type;
}
Also used : DatabindingException(org.apache.cxf.aegis.DatabindingException) BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) BeanType(org.apache.cxf.aegis.type.basic.BeanType)

Example 2 with BeanTypeInfo

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

the class ArrayTypeInfoTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    addNamespace("b", "urn:Bean");
    addNamespace("a", "urn:anotherns");
    addNamespace("xsi", Constants.URI_2001_SCHEMA_XSI);
    AegisContext context = new AegisContext();
    context.initialize();
    mapping = context.getTypeMapping();
    // address type
    BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
    addressInfo.setTypeMapping(mapping);
    addressType = new StructType(addressInfo);
    addressType.setTypeClass(Address.class);
    addressType.setSchemaType(new QName("urn:Bean", "addr"));
    mapping.register(addressType);
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) QName(javax.xml.namespace.QName) AegisContext(org.apache.cxf.aegis.AegisContext)

Example 3 with BeanTypeInfo

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

the class StructTypeTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    // address type
    BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
    addressInfo.setTypeMapping(mapping);
    addressType = new StructType(addressInfo);
    addressType.setTypeClass(Address.class);
    addressType.setSchemaType(new QName("urn:Bean", "address"));
    mapping.register(addressType);
    // purchase order type
    BeanTypeInfo poInfo = new BeanTypeInfo(PurchaseOrder.class, "urn:Bean");
    poInfo.setTypeMapping(mapping);
    purchaseOrderType = new StructType(poInfo);
    purchaseOrderType.setTypeClass(PurchaseOrder.class);
    purchaseOrderType.setTypeMapping(mapping);
    purchaseOrderType.setSchemaType(new QName("urn:Bean", "po"));
    mapping.register(purchaseOrderType);
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) QName(javax.xml.namespace.QName)

Example 4 with BeanTypeInfo

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

the class ConfigurationTest method testExtensibleDefaultFalse.

@Test
public void testExtensibleDefaultFalse() throws Exception {
    config.setDefaultExtensibleElements(false);
    config.setDefaultExtensibleAttributes(false);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertFalse(info.isExtensibleElements());
    assertFalse(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 5 with BeanTypeInfo

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

the class ConfigurationTest method testMinOccursDefault0.

@Test
public void testMinOccursDefault0() throws Exception {
    config.setDefaultMinOccurs(0);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "bogusProperty")), 0);
}
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) QName(javax.xml.namespace.QName) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

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