Object planValue = plan.getValue();
if (Application.class.isInstance(planValue)) {
Application application = (Application) planValue;
// set dependency
Environment env = application.getEnvironment();
if (env == null) {
env = new Environment();
application.setEnvironment(env);
}
setDependency(env);
// add the gbean into plan
JAXBElement<Gbean> gbeanElement = objectFactory.createGbean(gbean);
application.getService().add(gbeanElement);
} else if (WebApp.class.isInstance(planValue)) {
WebApp webapp = (WebApp) planValue;
// set dependency
Environment env = webapp.getEnvironment();
if (env == null) {
env = new Environment();
webapp.setEnvironment(env);
}
setDependency(env);
// add the gbean into plan
JAXBElement<Gbean> gbeanElement = objectFactory.createGbean(gbean);
webapp.getServiceOrPersistence().add(gbeanElement);
} else if (OpenejbJar.class.isInstance(planValue)) {
OpenejbJar openejbJar = (OpenejbJar) planValue;
// set dependency
Environment env = openejbJar.getEnvironment();
if (env == null) {
env = new Environment();
openejbJar.setEnvironment(env);
}
setDependency(env);
// add the gbean into plan