use of org.apache.openejb.assembler.classic.WebAppInfo in project tomee by apache.
the class Deploy method print.
private static void print(final AppInfo appInfo) {
System.out.println("App(id=" + appInfo.path + ")");
for (final EjbJarInfo info : appInfo.ejbJars) {
System.out.println(" EjbJar(id=" + info.moduleName + ", path=" + info.path + ")");
for (final EnterpriseBeanInfo beanInfo : info.enterpriseBeans) {
System.out.println(" Ejb(ejb-name=" + beanInfo.ejbName + ", id=" + beanInfo.ejbDeploymentId + ")");
for (final String name : beanInfo.jndiNames) {
System.out.println(" Jndi(name=" + name + ")");
}
System.out.println("");
}
for (final InterceptorInfo interceptorInfo : info.interceptors) {
System.out.println(" Interceptor(class=" + interceptorInfo.clazz + ")");
}
System.out.println("");
}
for (final ClientInfo clientInfo : appInfo.clients) {
System.out.println(" Client(main-class=" + clientInfo.mainClass + ", id=" + clientInfo.moduleId + ", path=" + clientInfo.path + ")");
System.out.println("");
}
for (final ConnectorInfo connectorInfo : appInfo.connectors) {
System.out.println(" Connector(id=" + connectorInfo.moduleId + ", path=" + connectorInfo.path + ")");
System.out.println("");
}
for (final WebAppInfo webAppInfo : appInfo.webApps) {
System.out.println(" WebApp(context-root=" + webAppInfo.contextRoot + ", id=" + webAppInfo.moduleId + ", path=" + webAppInfo.path + ")");
System.out.println("");
}
for (final PersistenceUnitInfo persistenceUnitInfo : appInfo.persistenceUnits) {
System.out.println(" PersistenceUnit(name=" + persistenceUnitInfo.name + ", provider=" + persistenceUnitInfo.provider + ")");
System.out.println("");
}
}
use of org.apache.openejb.assembler.classic.WebAppInfo in project tomee by apache.
the class AppInfoBuilder method buildWebModules.
private void buildWebModules(final AppModule appModule, final JndiEncInfoBuilder jndiEncInfoBuilder, final AppInfo appInfo) throws OpenEJBException {
for (final WebModule webModule : appModule.getWebModules()) {
final WebApp webApp = webModule.getWebApp();
final WebAppInfo webAppInfo = new WebAppInfo();
webAppInfo.description = webApp.getDescription();
webAppInfo.displayName = webApp.getDisplayName();
webAppInfo.path = webModule.getJarLocation();
webAppInfo.moduleId = webModule.getModuleId();
webAppInfo.watchedResources.addAll(webModule.getWatchedResources());
webAppInfo.validationInfo = ValidatorBuilder.getInfo(webModule.getValidationConfig());
webAppInfo.uniqueId = webModule.getUniqueId();
webAppInfo.restApplications.addAll(webModule.getRestApplications());
webAppInfo.restClass.addAll(webModule.getRestClasses());
webAppInfo.ejbWebServices.addAll(webModule.getEjbWebServices());
webAppInfo.ejbRestServices.addAll(webModule.getEjbRestServices());
webAppInfo.jaxRsProviders.addAll(webModule.getJaxrsProviders());
for (final Map.Entry<String, Set<String>> entry : webModule.getWebAnnotatedClasses().entrySet()) {
final ClassListInfo info = new ClassListInfo();
info.name = entry.getKey();
info.list.addAll(entry.getValue());
webAppInfo.webAnnotatedClasses.add(info);
}
for (final Map.Entry<String, Set<String>> entry : webModule.getJsfAnnotatedClasses().entrySet()) {
final ClassListInfo info = new ClassListInfo();
info.name = entry.getKey();
info.list.addAll(entry.getValue());
webAppInfo.jsfAnnotatedClasses.add(info);
}
webAppInfo.host = webModule.getHost();
if (!webModule.isStandaloneModule() && USE_EAR_AS_CONTEXT_ROOT_BASE) {
webAppInfo.contextRoot = appModule.getModuleId() + "/" + webModule.getContextRoot();
} else {
webAppInfo.contextRoot = webModule.getContextRoot();
}
webAppInfo.sessionTimeout = 30;
if (webModule.getWebApp() != null && webModule.getWebApp().getSessionConfig() != null) {
for (final SessionConfig sessionConfig : webModule.getWebApp().getSessionConfig()) {
if (sessionConfig.getSessionTimeout() != null) {
webAppInfo.sessionTimeout = sessionConfig.getSessionTimeout();
break;
}
}
}
jndiEncInfoBuilder.build(webApp, webModule.getJarLocation(), webAppInfo.moduleId, webModule.getModuleUri(), webAppInfo.jndiEnc, webAppInfo.jndiEnc);
webAppInfo.portInfos.addAll(this.configureWebservices(webModule.getWebservices()));
for (final Servlet servlet : webModule.getWebApp().getServlet()) {
final ServletInfo servletInfo = new ServletInfo();
servletInfo.servletName = servlet.getServletName();
servletInfo.servletClass = servlet.getServletClass();
servletInfo.mappings = webModule.getWebApp().getServletMappings(servletInfo.servletName);
for (final ParamValue pv : servlet.getInitParam()) {
final ParamValueInfo pvi = new ParamValueInfo();
pvi.name = pv.getParamName();
pvi.value = pv.getParamValue();
servletInfo.initParams.add(pvi);
}
webAppInfo.servlets.add(servletInfo);
}
for (final Listener listener : webModule.getWebApp().getListener()) {
final ListenerInfo listenerInfo = new ListenerInfo();
listenerInfo.classname = listener.getListenerClass();
webAppInfo.listeners.add(listenerInfo);
}
for (final Filter filter : webModule.getWebApp().getFilter()) {
final FilterInfo filterInfo = new FilterInfo();
filterInfo.name = filter.getFilterName();
filterInfo.classname = filter.getFilterClass();
filterInfo.mappings = webModule.getWebApp().getFilterMappings(filter.getFilterName());
for (final ParamValue pv : filter.getInitParam()) {
filterInfo.initParams.put(pv.getParamName(), pv.getParamValue());
}
webAppInfo.filters.add(filterInfo);
}
appInfo.webApps.add(webAppInfo);
}
}
use of org.apache.openejb.assembler.classic.WebAppInfo in project tomee by apache.
the class RESTService method getRestEjbs.
protected Map<String, EJBRestServiceInfo> getRestEjbs(final AppInfo appInfo, final String webapp) {
final Map<String, BeanContext> beanContexts = new HashMap<>();
for (final EjbJarInfo ejbJar : appInfo.ejbJars) {
if (ejbJar.webapp && webapp != null && !ejbJar.moduleId.equals(webapp)) {
continue;
}
for (final EnterpriseBeanInfo bean : ejbJar.enterpriseBeans) {
if (bean.restService) {
final BeanContext beanContext = containerSystem.getBeanContext(bean.ejbDeploymentId);
if (beanContext == null) {
continue;
}
beanContexts.put(bean.ejbClass, beanContext);
}
}
}
final Map<String, EJBRestServiceInfo> restEjbs = new HashMap<>();
for (final WebAppInfo webApp : appInfo.webApps) {
for (final String ejb : webApp.ejbRestServices) {
if (beanContexts.containsKey(ejb)) {
restEjbs.put(ejb, new EJBRestServiceInfo(webApp.contextRoot, beanContexts.get(ejb)));
}
// else ear probably
}
}
for (final Map.Entry<String, BeanContext> ejbs : beanContexts.entrySet()) {
final String clazz = ejbs.getKey();
if (!restEjbs.containsKey(clazz)) {
// null is important, it means there is no webroot path in standalone
String context = null;
if (!OLD_WEBSERVICE_DEPLOYMENT) {
if (appInfo.appId != null && !appInfo.appId.isEmpty()) {
context = appInfo.appId;
} else {
context = ejbs.getValue().getModuleName();
}
}
restEjbs.put(clazz, new EJBRestServiceInfo(context, beanContexts.get(clazz)));
}
}
beanContexts.clear();
return restEjbs;
}
use of org.apache.openejb.assembler.classic.WebAppInfo 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.WebAppInfo in project tomee by apache.
the class OpenEJBContextConfig method processAnnotationsWebResource.
@Override
protected void processAnnotationsWebResource(final WebResource webResource, final WebXml fragment, final boolean handlesTypesOnly, final Map<String, JavaClassCacheEntry> javaClassCache) {
final WebAppInfo webAppInfo = info.get();
if (webAppInfo != null && FileResource.class.isInstance(webResource)) {
final File file = new File(FileResource.class.cast(webResource).getCanonicalPath());
for (final ClassListInfo info : webAppInfo.webAnnotatedClasses) {
if (webInfClassesAnnotationsProcessed.contains(info.name)) {
continue;
}
try {
boolean doProcess = isIncludedIn(info.name, file);
if (!doProcess) {
// for sym links we can need to check each file for an exact matching
for (final String path : info.list) {
if (isIncludedIn(path, file)) {
doProcess = true;
break;
}
}
}
if (doProcess) {
webInfClassesAnnotationsProcessed.add(info.name);
internalProcessAnnotationsStream(info.list, fragment, false);
}
} catch (final MalformedURLException e) {
logger.warning(e.getMessage(), e);
}
}
} else {
super.processAnnotationsWebResource(webResource, fragment, handlesTypesOnly, javaClassCache);
}
}
Aggregations