use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class Container method deploy.
public AppContext deploy(final String name, final File file, final boolean overrideName) throws OpenEJBException, IOException, NamingException {
final AppContext context;
final AppInfo appInfo;
if (WebAppDeployer.Helper.isWebApp(file)) {
String contextRoot = file.getName();
if (overrideName) {
contextRoot = name;
}
appInfo = SystemInstance.get().getComponent(WebAppDeployer.class).deploy(null, contextRoot, file);
if (appInfo != null) {
context = SystemInstance.get().getComponent(ContainerSystem.class).getAppContext(appInfo.appId);
} else {
context = null;
}
} else {
appInfo = configurationFactory.configureApplication(file);
if (overrideName) {
appInfo.appId = name;
for (final EjbJarInfo ejbJar : appInfo.ejbJars) {
if (file.getName().equals(ejbJar.moduleName)) {
ejbJar.moduleName = name;
ejbJar.moduleId = name;
}
for (final EnterpriseBeanInfo ejb : ejbJar.enterpriseBeans) {
if (BeanContext.Comp.openejbCompName(file.getName()).equals(ejb.ejbName)) {
ejb.ejbName = BeanContext.Comp.openejbCompName(name);
}
}
}
for (final WebAppInfo webApp : appInfo.webApps) {
if (sameApplication(file, webApp)) {
webApp.moduleId = name;
webApp.contextRoot = lastPart(name, webApp.contextRoot);
if ("ROOT".equals(webApp.contextRoot)) {
webApp.contextRoot = "";
}
}
}
}
context = assembler.createApplication(appInfo);
}
moduleIds.put(name, null != appInfo ? appInfo.path : null);
infos.put(name, appInfo);
appContexts.put(name, context);
return context;
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class HttpRequestImpl method getSession.
public HttpSession getSession(boolean create) {
if (session == null && create) {
// default is infinite *here* only
long timeout = -1;
if (contextPath != null) {
// TODO: webapp should be contextual, would need to normalize jaxws, jaxrs, servlet, jsf...before but would be better
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
if (assembler != null) {
for (final AppInfo info : assembler.getDeployedApplications()) {
for (final WebAppInfo webApp : info.webApps) {
if (webApp.contextRoot.replace("/", "").equals(contextPath.replace("/", ""))) {
timeout = webApp.sessionTimeout;
}
}
}
}
}
final HttpSessionImpl impl = new HttpSessionImpl(contextPath, timeout) {
@Override
public void invalidate() {
super.invalidate();
HttpRequestImpl.this.session = null;
}
};
session = impl;
if (begin != null) {
begin.sessionCreated(new HttpSessionEvent(session));
session = new SessionInvalidateListener(session, begin);
}
// can call req.getSession() so do it after affectation + do it after cdi init
impl.callListeners();
final SessionManager sessionManager = SystemInstance.get().getComponent(SessionManager.class);
final SessionManager.SessionWrapper previous = sessionManager.newSession(begin, end, session, application);
if (previous != null) {
session = previous.session;
}
}
return session;
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class WsService method undeploy.
public void undeploy(@Observes final AssemblerBeforeApplicationDestroyed event) {
final AppInfo appInfo = event.getApp();
if (deployedApplications.remove(appInfo) != null) {
for (final EjbJarInfo ejbJar : appInfo.ejbJars) {
final Map<String, PortInfo> ports = new TreeMap<String, PortInfo>();
for (final PortInfo port : ejbJar.portInfos) {
ports.put(port.serviceLink, port);
}
for (final EnterpriseBeanInfo enterpriseBean : ejbJar.enterpriseBeans) {
if (enterpriseBean instanceof StatelessBeanInfo || enterpriseBean instanceof SingletonBeanInfo) {
final PortInfo portInfo = ports.get(enterpriseBean.ejbName);
if (portInfo == null) {
continue;
}
final BeanContext beanContext = containerSystem.getBeanContext(enterpriseBean.ejbDeploymentId);
if (beanContext == null) {
continue;
}
// remove wsdl addresses from global registry
final String address = ejbAddresses.remove(enterpriseBean.ejbDeploymentId);
addressesForApp(appInfo.appId).remove(new EndpointInfo(address, portInfo.wsdlPort, beanContext.getBeanClass().getName()));
if (address != null) {
portAddressRegistry.removePort(portInfo.serviceId, portInfo.wsdlService, portInfo.portId, portInfo.seiInterfaceName);
}
// remove container from web server
final String location = ejbLocations.get(enterpriseBean.ejbDeploymentId);
if (this.wsRegistry != null && location != null) {
this.wsRegistry.removeWsContainer(location, ejbJar.moduleId);
}
// destroy webservice container
destroyEjbWsContainer(enterpriseBean.ejbDeploymentId);
ejbLocations.remove(enterpriseBean.ejbDeploymentId);
}
}
}
for (final WebAppInfo webApp : appInfo.webApps) {
deployedWebApps.remove(webApp);
final Map<String, PortInfo> ports = new TreeMap<String, PortInfo>();
for (final PortInfo port : webApp.portInfos) {
ports.put(port.serviceLink, port);
}
for (final ServletInfo servlet : webApp.servlets) {
if (servlet.servletClass == null) {
continue;
}
PortInfo portInfo = ports.remove(servlet.servletClass);
if (portInfo == null) {
portInfo = ports.remove(servlet.servletName);
if (portInfo == null) {
continue;
}
}
// remove wsdl addresses from global registry
final String address = servletAddresses.remove(webApp.moduleId + "." + servlet.servletName);
if (address != null) {
portAddressRegistry.removePort(portInfo.serviceId, portInfo.wsdlService, portInfo.portId, portInfo.seiInterfaceName);
}
// clear servlet's reference to the webservice container
if (this.wsRegistry != null) {
try {
this.wsRegistry.clearWsContainer(webApp.contextRoot, host(webApp), servlet, webApp.moduleId);
} catch (final IllegalArgumentException ignored) {
// no-op
}
}
// destroy webservice container
destroyPojoWsContainer(portInfo.serviceLink);
}
addressesByApplication.remove(webApp.moduleId);
}
addressesByApplication.remove(appInfo.appId);
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class RESTService method undeploy.
public void undeploy(@Observes final AssemblerBeforeApplicationDestroyed event) {
final AppInfo app = event.getApp();
final boolean removed = deployedApplications.remove(app);
if (removed) {
for (final WebAppInfo webApp : app.webApps) {
final List<DeployedService> toRemove = new ArrayList<>();
for (final DeployedService service : services) {
if (service.isInWebApp(app.appId, webApp)) {
undeployRestObject(app.appId, service.address);
toRemove.add(service);
}
}
services.removeAll(toRemove);
deployedWebApps.remove(webApp);
}
}
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class RESTService method start.
@Override
public void start() throws ServiceException {
SystemInstance.get().setComponent(RESTService.class, this);
beforeStart();
containerSystem = (CoreContainerSystem) SystemInstance.get().getComponent(ContainerSystem.class);
assembler = SystemInstance.get().getComponent(Assembler.class);
if (assembler != null) {
SystemInstance.get().addObserver(this);
for (final AppInfo appInfo : assembler.getDeployedApplications()) {
final AppContext appContext = containerSystem.getAppContext(appInfo.appId);
afterApplicationCreated(new AssemblerAfterApplicationCreated(appInfo, appContext, null));
}
}
}
Aggregations