alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Apache CXF example source code file (NoNamespaceAegisElementProvider.java)

This example Apache CXF source code file (NoNamespaceAegisElementProvider.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Apache CXF tags/keywords

abstracttypecreator, abstracttypecreator, aegiscontext, aegiscontext, aegiselementprovider, nonamespaceaegiselementprovider, nonamespacejava5typecreator, nonamespacetypecreator, override, reflection, type, typecreationoptions, typecreationoptions, typecreator, typecreator, util

The Apache CXF NoNamespaceAegisElementProvider.java source code

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.cxf.jaxrs.provider;

import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Set;

import org.apache.cxf.aegis.AegisContext;
import org.apache.cxf.aegis.type.AbstractTypeCreator;
import org.apache.cxf.aegis.type.DefaultTypeMapping;
import org.apache.cxf.aegis.type.TypeCreationOptions;
import org.apache.cxf.aegis.type.TypeCreator;
import org.apache.cxf.aegis.type.TypeMapping;
import org.apache.cxf.aegis.type.XMLTypeCreator;
import org.apache.cxf.aegis.type.java5.Java5TypeCreator;
import org.apache.cxf.common.util.SOAPConstants;

/**
 * Class that sets options to disable xml namespaces.
 */
class NoNamespaceAegisElementProvider<T> extends AegisElementProvider {
    /*
     * This can't use the cache in AbstractAegisProvider. It could have its own cache.
     */

    private TypeCreator createTypeCreator(TypeCreationOptions options) {
        AbstractTypeCreator xmlCreator = createRootTypeCreator(options);

        Java5TypeCreator j5Creator = new NoNamespaceJava5TypeCreator();
        j5Creator.setNextCreator(createDefaultTypeCreator(options));
        j5Creator.setConfiguration(options);
        xmlCreator.setNextCreator(j5Creator);

        return xmlCreator;
    }

    protected AbstractTypeCreator createRootTypeCreator(TypeCreationOptions options) {
        AbstractTypeCreator creator = new XMLTypeCreator();
        creator.setConfiguration(options);
        return creator;
    }

    protected AbstractTypeCreator createDefaultTypeCreator(TypeCreationOptions options) {
        AbstractTypeCreator creator = new NoNamespaceTypeCreator();
        creator.setConfiguration(options);
        return creator;
    }

    @Override
    protected AegisContext getAegisContext(Class<?> plainClass, Type genericType) {
        AegisContext context = new AegisContext();
        context.setWriteXsiTypes(writeXsiType);
        context.setReadXsiTypes(readXsiType);
        TypeCreationOptions tco = new TypeCreationOptions();
        tco.setQualifyElements(false);
        Set<java.lang.reflect.Type> rootClasses = new HashSet();
        rootClasses.add(genericType);
        context.setTypeCreationOptions(tco);
        context.setRootClasses(rootClasses);
        TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false, false);
        DefaultTypeMapping mapping = new DefaultTypeMapping(SOAPConstants.XSD, baseMapping);
        TypeCreator stockTypeCreator = createTypeCreator(tco);

        mapping.setTypeCreator(stockTypeCreator);
        context.setTypeMapping(mapping);
        context.initialize();
        return context;
    }
}

Other Apache CXF examples (source code examples)

Here is a short list of links related to this Apache CXF NoNamespaceAegisElementProvider.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.