Skip to content

Commit

Permalink
MOXy SchemaGenerator WSDL Namespace order switch (#2135)
Browse files Browse the repository at this point in the history
This switch allows users use previous unordered behaviour before PR #365.

Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
  • Loading branch information
rfelcman authored May 9, 2024
1 parent c75d2be commit ce6a459
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024 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
Expand Down Expand Up @@ -78,6 +78,14 @@ public final class MOXySystemProperties {
*/
public static final String MOXY_LOG_PAYLOAD = "eclipselink.logging.payload.moxy";

/**
* Property to control disable/enable sorting of generated XML Schemas by MOXy SchemaGenerator.
*
* Usage: set to {@link Boolean#TRUE} to enable sorting by XML Namespace URI or {@link Boolean#FALSE} to disable it.
* By default it is enabled {@link Boolean#TRUE}.
*
*/
public static final String MOXY_SCHEMA_GENERATOR_SORT = "org.eclipse.persistence.moxy.schema.generator.sort";

public static final Boolean xmlIdExtension = getBoolean(XML_ID_EXTENSION);

Expand All @@ -91,6 +99,8 @@ public final class MOXySystemProperties {

public static final Boolean moxyLogPayload = PrivilegedAccessHelper.getSystemPropertyBoolean(MOXY_LOG_PAYLOAD, false);

public static final Boolean moxySchemaGeneratorSort = PrivilegedAccessHelper.getSystemPropertyBoolean(MOXY_SCHEMA_GENERATOR_SORT, true);

/**
* Returns value of system property.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 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
Expand Down Expand Up @@ -33,6 +33,7 @@
import org.eclipse.persistence.internal.oxm.schema.SchemaModelProject;
import org.eclipse.persistence.internal.oxm.schema.model.Schema;
import org.eclipse.persistence.internal.oxm.schema.model.SchemaCompareByNamespace;
import org.eclipse.persistence.jaxb.MOXySystemProperties;
import org.eclipse.persistence.jaxb.TypeMappingInfo;
import org.eclipse.persistence.jaxb.javamodel.Helper;
import org.eclipse.persistence.jaxb.javamodel.JavaClass;
Expand Down Expand Up @@ -234,7 +235,7 @@ public Map<String, SchemaTypeInfo> generateSchemaFiles(SchemaOutputResolver outp

java.util.Collection<Schema> schemas = schemaGenerator.getAllSchemas();
// make sure that schemas will be passed to the output in specified order
if (schemas instanceof List) {
if (schemas instanceof List && MOXySystemProperties.moxySchemaGeneratorSort) {
((List)schemas).sort(new SchemaCompareByNamespace());
}
for(Schema schema : schemas) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2024 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
Expand Down Expand Up @@ -63,6 +63,7 @@
import org.eclipse.persistence.internal.oxm.schema.model.SimpleType;
import org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticle;
import org.eclipse.persistence.internal.oxm.schema.model.TypeDefParticleOwner;
import org.eclipse.persistence.jaxb.MOXySystemProperties;
import org.eclipse.persistence.jaxb.compiler.builder.TransformerPropertyBuilder;
import org.eclipse.persistence.jaxb.compiler.facets.DecimalMaxFacet;
import org.eclipse.persistence.jaxb.compiler.facets.DecimalMinFacet;
Expand Down Expand Up @@ -154,7 +155,9 @@ public void generateSchema(List<JavaClass> typeInfoClasses, Map<String, TypeInfo
this.arrayClassesToGeneratedClasses = arrayClassesToGeneratedClasses;

//sort input classes before schema name (like schema1.xsd, schema2.xsd....) is generated and assigned
typeInfoClasses.sort(new JavaClassCompareByNamespace(typeInfo));
if (MOXySystemProperties.moxySchemaGeneratorSort) {
typeInfoClasses.sort(new JavaClassCompareByNamespace(typeInfo));
}
for (JavaClass javaClass : typeInfoClasses) {
addSchemaComponents(javaClass);
}
Expand Down

0 comments on commit ce6a459

Please sign in to comment.