WebAppDescriptor API proposal
rbattenfeld May 12, 2011 5:24 PMHi Andrew and all others
I created a new discussion about the WebAppDescriptor API. The titel is more accurated.
I am stepping into this task of creating an API for the webAppDescriptor. I first analyzed a little bit the schema files and as well the current API implementation. I think, the API design should follow how the specification is designed. This helps to make the API consistend with the spec.
What do you think about the following package names:
org.jboss.shrinkwrap.descriptor.api.javaee6 // javaee_6.xsd
org.jboss.shrinkwrap.descriptor.api.webapp30 // web-app_3_0.xsd
org.jboss.shrinkwrap.descriptor.api.webcommon30 // web-common_3_0.xsd
org.jboss.shrinkwrap.descriptor.api.jsp22 // jsp_2_2.xsd
....
In the packages are the interfaces placed as defined in the corresponding schema, meaning the complex types. For example, the WebAppDescriptor.java is in the webapp30 package and so on. This allows to implement all other xsd schemas having dependencies for example on the web-common schema.
I prototyped a little bit and have implemented the child interface as you have suggested. Cool. Here is a code snippet:
final String webApp = Descriptors.create(WebAppDescriptor.class)
.absoluteOrdering().name("name1").name("name2").up()
.securityConstraint().displayName("displayName").authConstraint().description("description").roleName("manager").up().up()
.filter().filterName("myfilter").filterClass("com.acme.test.filter").asyncSupported(false).up()
.exportAsString();
Note the double step back from auth-contraint to security-contraint to web-app.
This would create the following web.xml file:
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<absolute-ordering>
<name>name1</name>
<name>name2</name>
</absolute-ordering>
<security-constraint>
<auth-constraint>
<description>description</description>
<role-name>manager</role-name>
</auth-constraint>
</security-constraint>
<filter>
<filter-name>MyFilter</filter-name>
<filter-class>com.acme.test.filter</filter-class>
<async-supported>false</async-supported>
</filter>
</web-app>
Does the proposal reflect your idea of the API design? Let me know what you think and I will change it.
Thanks
Ralf