Search in sources :

Example 1 with StaxSchemaValidationInInterceptor

use of org.apache.cxf.staxutils.validation.StaxSchemaValidationInInterceptor in project cxf by apache.

the class AegisDatabinding method initialize.

/**
 * {@inheritDoc} Set up the data binding for a service.
 */
public void initialize(Service s) {
    // We want to support some compatibility configuration properties.
    if (aegisContext == null) {
        aegisContext = new AegisContext();
        Object val = s.get("mtom-enabled");
        if ("true".equals(val) || Boolean.TRUE.equals(val) || mtomEnabled) {
            setMtomEnabled(true);
            aegisContext.setMtomEnabled(true);
        }
        if (mtomUseXmime) {
            aegisContext.setMtomUseXmime(true);
        }
        Map<Class<?>, String> implMap = new HashMap<>();
        // now for a really annoying case, the .implementation objects.
        for (String key : s.keySet()) {
            if (key.endsWith(".implementation")) {
                String className = key.substring(0, key.length() - ".implementation".length());
                Class<?> clazz = null;
                try {
                    clazz = ClassLoaderUtils.loadClass(className, getClass());
                } catch (ClassNotFoundException e) {
                    Message message = new Message("MAPPED_CLASS_NOT_FOUND", LOG, className, key);
                    LOG.warning(message.toString());
                    continue;
                }
                String implClassName = (String) s.get(key);
                implMap.put(clazz, implClassName);
            }
        }
        if (overrideTypes != null) {
            aegisContext.setRootClassNames(overrideTypes);
        }
        if (configuration != null) {
            aegisContext.setTypeCreationOptions(configuration);
        }
        if (!implMap.isEmpty()) {
            aegisContext.setBeanImplementationMap(implMap);
        }
    }
    aegisContext.setMappingNamespaceURI(s.getServiceInfos().get(0).getInterface().getName().getNamespaceURI());
    aegisContext.initialize();
    this.service = s;
    s.getInInterceptors().add(new StaxSchemaValidationInInterceptor());
    Set<AegisType> deps = new HashSet<>();
    for (ServiceInfo info : s.getServiceInfos()) {
        for (OperationInfo opInfo : info.getInterface().getOperations()) {
            if (opInfo.isUnwrappedCapable()) {
                initializeOperation(s, aegisContext.getTypeMapping(), opInfo.getUnwrappedOperation(), deps);
            } else {
                initializeOperation(s, aegisContext.getTypeMapping(), opInfo, deps);
            }
        }
    }
    Collection<AegisType> additional = aegisContext.getRootTypes();
    if (additional != null) {
        for (AegisType t : additional) {
            if (!deps.contains(t)) {
                deps.add(t);
            }
            addDependencies(deps, t);
        }
    }
    createSchemas(s, deps);
    for (ServiceInfo info : s.getServiceInfos()) {
        for (OperationInfo opInfo : info.getInterface().getOperations()) {
            if (opInfo.isUnwrappedCapable()) {
                initializeOperationTypes(info, opInfo.getUnwrappedOperation());
            } else {
                initializeOperationTypes(info, opInfo);
            }
        }
    }
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Message(org.apache.cxf.common.i18n.Message) HashMap(java.util.HashMap) AegisType(org.apache.cxf.aegis.type.AegisType) AegisContext(org.apache.cxf.aegis.AegisContext) StaxSchemaValidationInInterceptor(org.apache.cxf.staxutils.validation.StaxSchemaValidationInInterceptor) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) HashSet(java.util.HashSet)

Aggregations

HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 AegisContext (org.apache.cxf.aegis.AegisContext)1 AegisType (org.apache.cxf.aegis.type.AegisType)1 Message (org.apache.cxf.common.i18n.Message)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1 StaxSchemaValidationInInterceptor (org.apache.cxf.staxutils.validation.StaxSchemaValidationInInterceptor)1