use of org.apache.openejb.AppContext 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.AppContext 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));
}
}
}
use of org.apache.openejb.AppContext in project tomee by apache.
the class DeploymentIndexTest method setUp.
@Before
public void setUp() throws SystemException {
method = Method.class.getMethods()[0];
beanContext = new BeanContext("aDeploymentId", null, new ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null, null, null, false), null, null), DeploymentIndexTest.class, null, null, null, null, null, null, null, null, null, null, false, false);
deploymentIndex = new DeploymentIndex(new BeanContext[] { beanContext, beanContext });
}
use of org.apache.openejb.AppContext in project tomee by apache.
the class BasicClusterableRequestHandlerTest method setUp.
@Override
protected void setUp() throws Exception {
requestHandler = new BasicClusterableRequestHandler();
request = (ClusterableRequest) mock(ClusterableRequest.class);
response = (ClusterableResponse) mock(ClusterableResponse.class);
clusteredContainer = (ClusteredRPCContainer) mock(ClusteredRPCContainer.class);
beanContext = new BeanContext("aDeploymentId", null, new ModuleContext("", null, "", new AppContext("", SystemInstance.get(), null, null, null, false), null, null), BasicClusterableRequestHandlerTest.class, null, null, null, null, null, null, null, null, null, null, false, false);
}
use of org.apache.openejb.AppContext in project tomee by apache.
the class ContextualJndiReference method findPrefix.
private String findPrefix() {
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
for (final AppContext appContext : containerSystem.getAppContexts()) {
if (appContext.getClassLoader().equals(loader)) {
return appContext.getId();
}
for (final WebContext web : appContext.getWebContexts()) {
if (web.getClassLoader().equals(loader)) {
return appContext.getId();
}
}
}
if (1 == containerSystem.getAppContexts().size()) {
return containerSystem.getAppContexts().iterator().next().getId();
}
return null;
}
Aggregations