Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.lang.reflect.Proxy;
import java.util.*;
import java.util.logging.Logger;
import java.security.AccessController;

/**
* Finds request/response wrapper and exception bean memebers.
Expand Down Expand Up @@ -212,6 +213,19 @@ public List<A> collectResponseBeanMembers(M method) {
return responseMembers;
}

// When an element is of an array type, the software
// currently sets nillable to true regardless of the value of the
// related annotation. A customer has complained that nillable="false"
// should be allowed for such a type.
//
// Since the current behavior was specifically placed in the code,
// there may be a good reason for it, and we do not want to break
// compatibility.
// Therefore, we are adding a new system property
// -Djaxb.allowNonNillableArray=true
// to implement the behavior requested by the customer.
static final boolean JAXB_ALLOWNONNILLABLEARRAY = getBooleanSystemProperty("jaxb.allowNonNillableArray").booleanValue();

private void processXmlElement(List<Annotation> jaxb, String elemName, String elemNS, T type) {
XmlElement elemAnn = null;
for (Annotation a : jaxb) {
Expand All @@ -227,7 +241,7 @@ private void processXmlElement(List<Annotation> jaxb, String elemName, String el
String ns = (elemAnn != null && !elemAnn.namespace().equals("##default"))
? elemAnn.namespace() : elemNS;

boolean nillable = nav.isArray(type)
boolean nillable = (nav.isArray(type) && !JAXB_ALLOWNONNILLABLEARRAY)
|| (elemAnn != null && elemAnn.nillable());

boolean required = elemAnn != null && elemAnn.required();
Expand Down Expand Up @@ -450,4 +464,15 @@ private static String getPropertyName(String name) {
reservedWords.put("enum", "_enum");
}

// This method is copied from RuntimeModeler.java in the same directory.
private static Boolean getBooleanSystemProperty(final String prop) {
return AccessController.doPrivileged(
new java.security.PrivilegedAction<Boolean>() {
public Boolean run() {
String value = System.getProperty(prop);
return value != null ? Boolean.valueOf(value) : Boolean.FALSE;
}
}
);
}
}