prem chander jonnala
prem chander jonnala

Reputation: 29

externalize namespace JAXB generated package-info.java

How to externalize the namespace value in package-info.java

@javax.xml.bind.annotation.XmlSchema(namespace = "http://loclahost:9093/Request", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

in the above code how should externalize the "http://loclahost:9093/Request".

Any help is greatly appreciated

Upvotes: 2

Views: 1332

Answers (2)

bdoughan
bdoughan

Reputation: 149037

The namespace specified on the the @XmlSchema annotation isn't meant to correlate to the physical location of the XML schema. It is used to qualify the element, so that your address element is different from another organizations use of an address element. This is similar to package names in Java. As with package names, people generally use domain names for this purpose. I can't think of a good reason to have the namespace look like: http://loclahost:9093/Request.

Upvotes: 2

Ian Roberts
Ian Roberts

Reputation: 122394

Annotation attribute values have to be compile time constants so the best you can do is to declare a public static final String NAMESPACE = "http://example.com" in another class and then say namespace = MyClass.NAMESPACE in the annotation. But you'd still have to re-compile package-info.java when MyClass changes.

Upvotes: 2

Related Questions