Skip to content

Instantly share code, notes, and snippets.

@jeanouii
Created February 25, 2014 14:34
Show Gist options
  • Select an option

  • Save jeanouii/9209938 to your computer and use it in GitHub Desktop.

Select an option

Save jeanouii/9209938 to your computer and use it in GitHub Desktop.
public void beforeInfoTreeBuilder(@Observes final BeforeAppInfoBuilderEvent event) {
final Service wadlxGenerator = new Service(WADLX_GENERATOR_ID, null);
wadlxGenerator.setClassName(WadlGenerator.class.getName());
// for now, we just deal with one WebModule (Collapsed EAR) and of course one EjbModule
final Iterator<WebModule> iterator = event.getAppModule().getWebModules().iterator();
if (!iterator.hasNext()) return;
final WebModule webModule = iterator.next();
for (EjbModule ejbModule : event.getAppModule().getEjbModules()) {
ejbModule.getAppModule().getServices().add(wadlxGenerator);
// get the openejb-jar or create if none
OpenejbJar openejbJar = ejbModule.getOpenejbJar();
if (openejbJar == null) {
openejbJar = new OpenejbJar();
ejbModule.setOpenejbJar(openejbJar);
}
// get the PojoDeployment for the REST application or create if none
boolean found = false;
for (PojoDeployment pojo : openejbJar.getPojoDeployment()) {
if (webModule.getRestApplications().contains(pojo.getClassName())) {
LOGGER.debug("Found application for class " + pojo.getClassName());
addProviderProperty(pojo, WADLX_GENERATOR_ID);
found = true;
}
}
if (!found) {
LOGGER.debug("No application found. Creating one configuration for the default jaxrs-application.");
final PojoDeployment pojo = new PojoDeployment();
pojo.setClassName("jaxrs-application"); // default application
addProviderProperty(pojo, WADLX_GENERATOR_ID);
openejbJar.getPojoDeployment().add(pojo);
}
}
}
@rmannibucau

Copy link
Copy Markdown

public void beforeInfoTreeBuilder(@observes final BeforeAppInfoBuilderEvent event) {

    final Service wadlxGenerator = new Service(WADLX_GENERATOR_ID, null);
    wadlxGenerator.setClassName(WadlGenerator.class.getName());

for (final WebModule webModule : event.getAppModule().getWebModules()) {

    for (EjbModule ejbModule : event.getAppModule().getEjbModules()) {
        ejbModule.getAppModule().getServices().add(wadlxGenerator);

        // get the openejb-jar or create if none
        OpenejbJar openejbJar = ejbModule.getOpenejbJar();
        if (openejbJar == null) {
            openejbJar = new OpenejbJar();
            ejbModule.setOpenejbJar(openejbJar);
        }

        // get the PojoDeployment for the REST application or create if none
        boolean found = false;
        for (PojoDeployment pojo : openejbJar.getPojoDeployment()) {
            if (webModule.getRestApplications().contains(pojo.getClassName())) {
                LOGGER.debug("Found application for class " + pojo.getClassName());
                addProviderProperty(pojo, WADLX_GENERATOR_ID);
                found = true;
            }
        }

        if (!found) {
            LOGGER.debug("No application found. Creating one configuration for the default jaxrs-application.");
            final PojoDeployment pojo = new PojoDeployment();
            pojo.setClassName("jaxrs-application"); // default application
            addProviderProperty(pojo, WADLX_GENERATOR_ID);
            openejbJar.getPojoDeployment().add(pojo);
        }

}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment