blob: 6e046e03b856c9488ff57753d656ab84ce313aa7 [file] [log] [blame]
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.internal.sessions.factories;
import org.eclipse.persistence.descriptors.ClassDescriptor;
import org.eclipse.persistence.internal.sessions.factories.NamespaceResolvableProject;
import org.eclipse.persistence.internal.sessions.factories.NamespaceResolverWithPrefixes;
import org.eclipse.persistence.oxm.XMLDescriptor;
import org.eclipse.persistence.oxm.mappings.XMLBinaryDataCollectionMapping;
import org.eclipse.persistence.oxm.mappings.XMLBinaryDataMapping;
import org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping;
import org.eclipse.persistence.oxm.mappings.XMLDirectMapping;
/**
* INTERNAL:
* <p><b>Purpose</b>: Defines descriptors for any EclipseLink OXM objects that may
* have separate classpath dependencies from the rest of TopLink.</p>
* @author mmacivor
* @since 10.1.3
*/
public class OXMObjectPersistenceRuntimeXMLProject extends NamespaceResolvableProject {
public OXMObjectPersistenceRuntimeXMLProject() {
super();
}
public OXMObjectPersistenceRuntimeXMLProject(NamespaceResolverWithPrefixes namespaceResolverWithPrefixes) {
super(namespaceResolverWithPrefixes);
}
@Override
protected void buildDescriptors() {
addDescriptor(buildXMLBinaryDataMappingDescriptor());
addDescriptor(buildXMLBinaryDataCollectionMappingDescriptor());
}
public ClassDescriptor buildXMLBinaryDataMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(XMLBinaryDataMapping.class);
descriptor.getInheritancePolicy().setParentClass(XMLDirectMapping.class);
XMLDirectMapping swaRefMapping = new XMLDirectMapping();
swaRefMapping.setAttributeName("isSwaRef");
swaRefMapping.setXPath(getPrimaryNamespaceXPath() + "is-swa-ref/text()");
descriptor.addMapping(swaRefMapping);
XMLDirectMapping mimeTypeMapping = new XMLDirectMapping();
mimeTypeMapping.setAttributeName("mimeTypePolicy");
mimeTypeMapping.setGetMethodName("getMimeType");
mimeTypeMapping.setSetMethodName("setMimeType");
mimeTypeMapping.setXPath(getPrimaryNamespaceXPath() + "mime-type/text()");
descriptor.addMapping(mimeTypeMapping);
XMLDirectMapping shouldInlineMapping = new XMLDirectMapping();
shouldInlineMapping.setAttributeName("shouldInlineBinaryData");
shouldInlineMapping.setXPath(getPrimaryNamespaceXPath() + "should-inline-data");
descriptor.addMapping(shouldInlineMapping);
return descriptor;
}
public ClassDescriptor buildXMLBinaryDataCollectionMappingDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(XMLBinaryDataCollectionMapping.class);
descriptor.getInheritancePolicy().setParentClass(XMLCompositeDirectCollectionMapping.class);
XMLDirectMapping swaRefMapping = new XMLDirectMapping();
swaRefMapping.setAttributeName("isSwaRef");
swaRefMapping.setXPath(getPrimaryNamespaceXPath() + "is-swa-ref/text()");
descriptor.addMapping(swaRefMapping);
XMLDirectMapping mimeTypeMapping = new XMLDirectMapping();
mimeTypeMapping.setAttributeName("mimeTypePolicy");
mimeTypeMapping.setGetMethodName("getMimeType");
mimeTypeMapping.setSetMethodName("setMimeType");
mimeTypeMapping.setXPath(getPrimaryNamespaceXPath() + "mime-type/text()");
descriptor.addMapping(mimeTypeMapping);
XMLDirectMapping shouldInlineMapping = new XMLDirectMapping();
shouldInlineMapping.setAttributeName("shouldInlineBinaryData");
shouldInlineMapping.setXPath(getPrimaryNamespaceXPath() + "should-inline-data");
descriptor.addMapping(shouldInlineMapping);
return descriptor;
}
}