Package org.apache.cxf.aegis

Examples of org.apache.cxf.aegis.AegisContext


        assertXPathEquals("/b:root/@attrPlainString", "attrPlain", element);
    }
   
    @Test
    public void testAnnotatedDefaultQualifiedAttribute() throws Exception {
        AegisContext context = new AegisContext();
        TypeCreationOptions typeCreationOptions =
            new TypeCreationOptions();
        typeCreationOptions.setQualifyAttributes(true);
        context.setTypeCreationOptions(typeCreationOptions);
        context.initialize();
        TypeMapping mapping = context.getTypeMapping();
       
        Type type = mapping.getTypeCreator().createType(AttributeBean.class);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        Context messageContext = new Context(context);
View Full Code Here


        assertValid("/b:root[@pkg:attrPlainString]", element);
        assertXPathEquals("/b:root/@pkg:attrPlainString", "attrPlain", element);
    }
    @Test
    public void testXmlDefaultUnqualifiedAttribute() throws Exception {
        AegisContext context = new AegisContext();
        context.initialize();
        TypeMapping mapping = context.getTypeMapping();
       
        Type type = mapping.getTypeCreator().createType(XmlMappedAttributeBean.class);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        Context messageContext = new Context(context);
View Full Code Here

        assertXPathEquals("/b:root/@attrXmlString", "attrXml", element);
    }
   
    @Test
    public void testXmlDefaultQualifiedAttribute() throws Exception {
        AegisContext context = new AegisContext();
        TypeCreationOptions typeCreationOptions =
            new TypeCreationOptions();
        typeCreationOptions.setQualifyAttributes(true);
        context.setTypeCreationOptions(typeCreationOptions);
        context.initialize();
        TypeMapping mapping = context.getTypeMapping();
       
        Type type = mapping.getTypeCreator().createType(XmlMappedAttributeBean.class);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        Context messageContext = new Context(context);
View Full Code Here

    }

    protected AegisContext getAegisContext(Class<?> type, Type genericType) {
       
        if (resolver != null) {
            AegisContext context = resolver.getContext(type);
            // it's up to the resolver to keep its contexts in a map
            if (context != null) {
                return context;
            }
        }
View Full Code Here

        return getClassContext(type);
    }
   
    private AegisContext getClassContext(Class<?> type) {
        synchronized (classContexts) {
            AegisContext context = classContexts.get(type);
            if (context == null) {
                context = new AegisContext();
                context.setWriteXsiTypes(true); // needed, since we know no element/type maps.
                context.setReadXsiTypes(true);
                Set<Class<?>> rootClasses = new HashSet<Class<?>>();
                rootClasses.add(type);
                context.setRootClasses(rootClasses);
                context.initialize();
                classContexts.put(type, context);
            }
            return context;
        }
    }
View Full Code Here

public final class AegisElementProvider extends AbstractAegisProvider  {
   
    public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType m,
        MultivaluedMap<String, String> headers, InputStream is)
        throws IOException {
        AegisContext context = getAegisContext(type, genericType);
        AegisReader<XMLStreamReader> aegisReader = context.createXMLStreamReader();
        XMLStreamReader xmlStreamReader = StaxUtils.createXMLStreamReader(is);
        try {
            return aegisReader.read(xmlStreamReader);
        } catch (Exception e) {
            throw new WebApplicationException(e);
View Full Code Here

        MediaType m, MultivaluedMap<String, Object> headers, OutputStream os)
        throws IOException {
        if (type == null) {
            type = obj.getClass();
        }
        AegisContext context = getAegisContext(type, genericType);
        org.apache.cxf.aegis.type.Type aegisType = TypeUtil.getWriteTypeStandalone(context, obj, null);
        AegisWriter<XMLStreamWriter> aegisWriter = context.createXMLStreamWriter();
        XMLStreamWriter xmlStreamWriter = StaxUtils.createXMLStreamWriter(os);
        try {
            // use type qname as element qname?
            aegisWriter.write(obj, aegisType.getSchemaType(), false, xmlStreamWriter, aegisType);
            xmlStreamWriter.close();
View Full Code Here

        addNamespace("xsi", Constants.URI_2001_SCHEMA_XSI);
    }
   
    @Test
    public void testAnnotatedDefaultUnqualifiedAttribute() throws Exception {
        AegisContext context = new AegisContext();
        context.initialize();
        TypeMapping mapping = context.getTypeMapping();
       
        AegisType type = mapping.getTypeCreator().createType(AttributeBean.class);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        Context messageContext = new Context(context);
View Full Code Here

        assertXPathEquals("/b:root/@attrPlainString", "attrPlain", element);
    }
   
    @Test
    public void testAnnotatedDefaultQualifiedAttribute() throws Exception {
        AegisContext context = new AegisContext();
        TypeCreationOptions typeCreationOptions =
            new TypeCreationOptions();
        typeCreationOptions.setQualifyAttributes(true);
        context.setTypeCreationOptions(typeCreationOptions);
        context.initialize();
        TypeMapping mapping = context.getTypeMapping();
       
        AegisType type = mapping.getTypeCreator().createType(AttributeBean.class);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        Context messageContext = new Context(context);
View Full Code Here

        assertValid("/b:root[@pkg:attrPlainString]", element);
        assertXPathEquals("/b:root/@pkg:attrPlainString", "attrPlain", element);
    }
    @Test
    public void testXmlDefaultUnqualifiedAttribute() throws Exception {
        AegisContext context = new AegisContext();
        context.initialize();
        TypeMapping mapping = context.getTypeMapping();
       
        AegisType type = mapping.getTypeCreator().createType(XmlMappedAttributeBean.class);
        type.setSchemaType(new QName("urn:Bean", "bean"));

        Context messageContext = new Context(context);
View Full Code Here

TOP

Related Classes of org.apache.cxf.aegis.AegisContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.