Introduction

XBeans is the generation of Java Beans for the various XML Schemas which appear in the J2EE world. This allows us to use simple Java objects to work with the plethora of XML config file data used in EJB, web apps, JSP and so forth.

Currently the XBeans implementation is using BEA's XMLBeans tool to generate the code. This has the following advantages

The only downside is currently the XBeans depend on the xmlbeans-1.0.jar which is quite big. Hopefully we can fix this going forward to reduce the size of this jar.

Example

To parse some XML...

EjbJarDocument document = EjbJarDocument.Factory.parse(in);
EjbJar jar = document.getEjbJar();
SessionBeanType[] sessionBeans = jar.getEnterpriseBeans().getSessionArray();
...

To manually construct some of the XBeans for EJB...

EjbJar ejbJar = EjbJar.Factory.newInstance();
AssemblyDescriptorType assemblyDescriptor = ejbJar.addNewAssemblyDescriptor();
SecurityRole securityRole = assemblyDescriptor.addNewSecurityRole();
securityRole.setRoleName("foo");