use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class UnDeployMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
final Deployer deployer = (Deployer) lookup("openejb/DeployerBusinessRemote");
try {
final Collection<AppInfo> apps = deployer.getDeployedApps();
final Collection<String> paths = new ArrayList<String>(apps.size());
for (final AppInfo info : apps) {
paths.add(info.path);
}
if (paths.contains(path)) {
// exact matching
deployer.undeploy(path);
} else {
for (final String proposed : paths) {
// exact matching + extension
if (path.equals(proposed + ".war") || path.equals(proposed + ".ear") || path.equals(proposed + ".jar")) {
deployer.undeploy(proposed);
return;
}
}
for (final String proposed : paths) {
// just the app/folder name
if (proposed.endsWith("/" + path) || proposed.endsWith("\\" + path)) {
deployer.undeploy(proposed);
return;
}
}
}
} catch (final OpenEJBException e) {
throw new TomEEException(e.getMessage(), e);
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class RESTService method afterApplicationCreated.
public void afterApplicationCreated(@Observes final AssemblerAfterApplicationCreated event) {
if (!enabled)
return;
final AppInfo appInfo = event.getApp();
if ("false".equalsIgnoreCase(appInfo.properties.getProperty("openejb.jaxrs.on", "true"))) {
return;
}
quickCheckIfOldDeploymentShouldBeUsedFromEjbConfig(appInfo);
if (deployedApplications.add(appInfo)) {
if (appInfo.webApps.size() == 0) {
final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
final ClassLoader appClassLoader = getClassLoader(containerSystem.getAppContext(appInfo.appId).getClassLoader());
Thread.currentThread().setContextClassLoader(appClassLoader);
try {
final Map<String, EJBRestServiceInfo> restEjbs = getRestEjbs(appInfo, null);
if (restEjbs.isEmpty()) {
return;
}
final Collection<Object> providers;
if (useDiscoveredProviders(appInfo)) {
providers = appProviders(appInfo.jaxRsProviders, appClassLoader);
} else {
providers = new ArrayList<>();
}
if ("true".equalsIgnoreCase(appInfo.properties.getProperty(OPENEJB_USE_APPLICATION_PROPERTY, APPLICATION_DEPLOYMENT))) {
final Application application = new InternalApplication(null);
addEjbToApplication(application, restEjbs);
// merge configurations at app level since a single deployment is available
final List<IdPropertiesInfo> pojoConfigurations = new ArrayList<>();
BeanContext comp = null;
for (final EjbJarInfo ejbJar : appInfo.ejbJars) {
for (final EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
if (comp != null) {
break;
}
if (bean.ejbClass.equals(BeanContext.Comp.class.getName())) {
comp = containerSystem.getBeanContext(bean.ejbDeploymentId);
break;
}
}
if (ejbJar.pojoConfigurations != null) {
pojoConfigurations.addAll(ejbJar.pojoConfigurations);
}
}
if (appInfo.pojoConfigurations != null) {
pojoConfigurations.addAll(appInfo.pojoConfigurations);
}
final Map.Entry<String, EJBRestServiceInfo> next = restEjbs.entrySet().iterator().next();
if (comp == null) {
comp = next.getValue().context;
}
deployApplication(appInfo, next.getValue().path, restEjbs, comp.getClassLoader(), comp.getInjections(), containerSystem.getAppContext(appInfo.appId).getWebBeansContext(), comp.getJndiContext(), providers, pojoConfigurations, application, wildcard);
} else {
for (final Map.Entry<String, EJBRestServiceInfo> ejb : restEjbs.entrySet()) {
final BeanContext ctx = ejb.getValue().context;
if (BeanType.MANAGED.equals(ctx.getComponentType())) {
deployPojo(appInfo.appId, "", ejb.getValue().path, ctx.getBeanClass(), null, ctx.getClassLoader(), ctx.getInjections(), ctx.getJndiContext(), containerSystem.getAppContext(appInfo.appId).getWebBeansContext(), providers, new ServiceConfiguration(ctx.getProperties(), appInfo.services));
} else {
deployEJB(appInfo.appId, "", ejb.getValue().path, ctx, providers, appInfo.services);
}
}
}
} finally {
Thread.currentThread().setContextClassLoader(oldLoader);
}
} else {
for (final WebAppInfo webApp : appInfo.webApps) {
afterApplicationCreated(appInfo, webApp);
}
}
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class WsService method start.
@Override
public void start() throws ServiceException {
wsRegistry = SystemInstance.get().getComponent(WsRegistry.class);
if (wsRegistry == null && SystemInstance.get().getComponent(HttpListenerRegistry.class) != null) {
wsRegistry = new OpenEJBHttpWsRegistry();
}
if (portAddressRegistry == null) {
portAddressRegistry = new PortAddressRegistryImpl();
SystemInstance.get().setComponent(PortAddressRegistry.class, portAddressRegistry);
}
containerSystem = (CoreContainerSystem) SystemInstance.get().getComponent(ContainerSystem.class);
portAddressRegistry = SystemInstance.get().getComponent(PortAddressRegistry.class);
assembler = SystemInstance.get().getComponent(Assembler.class);
SystemInstance.get().setComponent(WsService.class, this);
if (assembler != null) {
SystemInstance.get().addObserver(this);
for (final AppInfo appInfo : assembler.getDeployedApplications()) {
final AppContext appContext = containerSystem.getAppContext(appInfo.appId);
deploy(new AssemblerAfterApplicationCreated(appInfo, appContext, null));
}
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class WsService method stop.
@Override
public void stop() throws ServiceException {
if (assembler != null) {
SystemInstance.get().removeObserver(this);
for (final AppInfo appInfo : new ArrayList<AppInfo>(deployedApplications.keySet())) {
undeploy(new AssemblerBeforeApplicationDestroyed(appInfo, null));
}
assembler = null;
if (SystemInstance.get().getComponent(WsService.class) == this) {
SystemInstance.get().removeComponent(WsService.class);
}
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class WsService method newEjbToDeploy.
// handle webapp ejbs of ears - called before afterApplicationCreated for ear so dont add app to deployedApplications here
public void newEjbToDeploy(@Observes final NewEjbAvailableAfterApplicationCreated event) {
final AppInfo app = event.getApp();
if (!deployedApplications.containsKey(app)) {
deployedApplications.putIfAbsent(app, new LinkedList<BeanContext>());
}
deployApp(app, event.getBeanContexts());
}
Aggregations