Refine search
final AppModule collection = new AppModule(classLoader, id, application, standaloneModule); final Map<String, Object> altDDs = collection.getAltDDs(); final AppModule module = deploymentLoader.load(jarFile, null); collection.getAdditionalLibraries().addAll(module.getAdditionalLibraries()); collection.getClientModules().addAll(module.getClientModules()); collection.getEjbModules().addAll(module.getEjbModules()); collection.addPersistenceModules(module.getPersistenceModules()); collection.getConnectorModules().addAll(module.getConnectorModules()); collection.getWebModules().addAll(module.getWebModules()); collection.getWatchedResources().addAll(module.getWatchedResources()); for (final Map.Entry<String, Object> entry : module.getAltDDs().entrySet()) { final Object existingValue = altDDs.get(entry.getKey());
@Override public void validate(final AppModule appModule) { this.appModule = appModule; module = appModule; check(appModule.getClassLoader()); for (final WebModule webModule : appModule.getWebModules()) { module = webModule; validate(webModule); } super.validate(appModule); }
private void applyOverrides(final AppModule appModule) { final String id = appModule.getModuleId() + "."; final Properties properties = SystemInstance.get().getProperties(); for (final Map.Entry<Object, Object> entry : properties.entrySet()) { final String key = entry.getKey().toString(); if (key.startsWith(id)) { final String property = key.substring(id.length()); if (appModule.getProperties().containsKey(property)) { log.debug("Overriding application " + appModule.getModuleId() + " property " + property + "=" + entry.getValue()); } else { log.debug("Adding application " + appModule.getModuleId() + " property " + property + "=" + entry.getValue()); } appModule.getProperties().put(property, entry.getValue()); } } }
private String getPersistenceModuleId(final AppModule appModule) { if (appModule.getModuleId() != null) { return appModule.getModuleId(); } for (final EjbModule ejbModule : appModule.getEjbModules()) { return ejbModule.getModuleId(); } throw new IllegalStateException("Comp must be in an ejb module, this one has none: " + appModule); }
public String uniqueHostIfExists() { final boolean hasWebApps = !getWebModules().isEmpty(); if (isWebapp() && hasWebApps) { return getWebModules().iterator().next().getHost(); } else if (hasWebApps) { String id = null; for (final WebModule web : getWebModules()) { if (id == null) { id = web.getHost(); } else if (!id.equals(web.getHost())) { return ""; // find something better as in org.apache.openejb.config.InitEjbDeployments } } return id; } return ""; }
private static void addEnvEntries(final Archive<?> archive, final String prefix, final AppModule appModule, final EjbModule ejbModule) { final Node envEntriesProperties = archive.get(prefix.concat(ENV_ENTRIES_PROPERTIES)); if (envEntriesProperties != null) { InputStream is = null; final Properties properties = new Properties(); try { is = envEntriesProperties.getAsset().openStream(); properties.load(is); ejbModule.getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties); // do it for test class too appModule.getEjbModules().iterator().next().getAltDDs().put(ENV_ENTRIES_PROPERTIES, properties); } catch (final Exception e) { LOGGER.log(Level.SEVERE, "can't read env-entries.properties", e); } finally { IO.close(is); } } }
final AppModule appModule = new AppModule(loader, archive.getName()); if (WEB_INF.equals(prefix)) { appModule.setDelegateFirst(false); appModule.setStandloneWebModule(); final WebModule webModule = new WebModule(new WebApp(), contextRoot(archive.getName()), loader, "", appModule.getModuleId()); webModule.setUrls(additionalPaths); appModule.getWebModules().add(webModule); final EjbJar ejbJar = new EjbJar(); final OpenejbJar openejbJar = new OpenejbJar(); final String ejbName = appModule.getModuleId() + "_" + javaClass.getName(); final ManagedBean bean = ejbJar.addEnterpriseBean(new ManagedBean(ejbName, javaClass.getName(), true)); bean.localBean(); final EjbModule e = new EjbModule(ejbJar, openejbJar); e.setClassLoader(tempClassLoader); appModule.getEjbModules().add(e); if (appModule.isWebapp()) { // war appModule.getWebModules().iterator().next().setFinder(ejbModule.getFinder()); appModule.getEjbModules().add(ejbModule); final Asset asset = persistenceXml.getAsset(); if (UrlAsset.class.isInstance(asset)) { appModule.getAltDDs().put(PERSISTENCE_XML, Arrays.asList(get(URL.class, "url", asset))); } else if (FileAsset.class.isInstance(asset)) { try {
@Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { final Properties overrides = new Properties(); overrides.putAll(SystemInstance.get().getProperties()); overrides.putAll(appModule.getProperties()); for (final DeploymentModule module : appModule.getDeploymentModule()) { readProperties(module); applyOverrides(overrides, module); } return appModule; }
public void setDefaultMapping(@Observes final BeforeAppInfoBuilderEvent event) { final AppModule module = event.getAppModule(); if (module == null) { return; } final List<WebModule> webModules = module.getWebModules(); final String ignore = SystemInstance.get().getProperty(DEFAULT_RS_APPLICATION_IGNORE.replace("com.tomi", ""), System.getProperty(DEFAULT_RS_APPLICATION_IGNORE, module.getProperties().getProperty(DEFAULT_RS_APPLICATION_IGNORE))); final String mapping = System.getProperty(DEFAULT_RS_APPLICATION_MAPPING, "/api/*"); if (!Boolean.parseBoolean(ignore) && !webModules.isEmpty() /*for tests mainly*/ && !isOAuth2(module)) { for (final WebModule webModule : webModules) { final WebApp webApp = webModule.getWebApp(); if (webApp == null) continue; // can't happen if (!webModule.getRestApplications().isEmpty()) continue; // already a REST application if ("tomitribe-monitor-internal".equals(webModule.getModuleId())) continue; // monitoring internal webapp if ("tomitribe-monitor-internal".equals(webApp.getId())) continue; // monitor process LOGGER.info(WadlxCodes.APPLICATION_CONFIGURER, "No REST application defined for application: {0}. Automatically adding a default JAX RS mapping for it on {1}/{2}. " + "Add a class annotated with @javax.ws.rs.ApplicationPath to the application to specify this mapping manually.", webModule.getModuleId(), webModule.getContextRoot(), mapping.replaceAll("^/+", "")); // strip off leading / characters webApp .addServlet(InternalApplication.class.getName(), null, SystemInstance.get().getProperty( DEFAULT_RS_APPLICATION_IGNORE.replace("com.tomi", ""), mapping)); } } }
appModule.getProperties().put("loader.from", "tomcat"); properties.setProperty("JdbcDriver", paramValue); } else if ("url".equals(paramName)) { properties.setProperty("JdbcUrl", paramValue); } else { properties.setProperty(paramName, paramValue); appModule.getResources().add(newResource); DeployerEjb.AUTO_DEPLOY.remove(); if (!appModule.isWebapp()) { classLoader = appModule.getClassLoader(); } else { final ClassLoader loader = standardContext.getLoader().getClassLoader(); if (loader instanceof TomEEWebappClassLoader) { final TomEEWebappClassLoader tomEEWebappClassLoader = (TomEEWebappClassLoader) loader; for (final URL url : appModule.getWebModules().iterator().next().getAddedUrls()) { tomEEWebappClassLoader.addURL(url);
@Override public AppModule deploy(final AppModule appModule) throws OpenEJBException { for (final WebModule webModule : appModule.getWebModules()) { if (webModule.getFinder() == null) { continue; } for (final EjbModule ejbModule : appModule.getEjbModules()) { // If they are the same module, they'll have the same finder if (ejbModule.getFinder() != webModule.getFinder()) { final String forceMerge = ejbModule.getProperties().getProperty("openejb.ejbmodule.MergeWebappJndiContext"); // always true is not null if (forceMerge != null) { // default resource propagation for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) { copy(webModule.getWebApp().getResourceEnvRefMap(), bean.getResourceEnvRefMap()); } } continue; } merge(ejbModule, webModule); } } return appModule; }
public void switchJaxrsOffForInternalWebApp(@Observes final BeforeAppInfoBuilderEvent event) { if (event.getAppModule().getModuleId().equals(TOMITRIBE_MONITOR_CONTEXT.substring(1))) { // / is removed from id // we handle it manually, we can desire to move to auto deployment but would need to check security etc event.getAppModule().getProperties().put("openejb.jaxrs.on", "false"); } }
if (appModule.getDeploymentModule().size() == 1 && appModule.getWebModules().size() == 1) { final WebModule webModule = appModule.getWebModules().iterator().next(); if (file.getAbsolutePath().equals(webModule.getJarLocation())) { continue; for (final WebModule webModule : appModule.getWebModules()) { webModule.setHost(standardHost.getName()); if (file.isFile() && file.getName().toLowerCase().endsWith(".ear")) { appInfo.properties.setProperty("tomcat.unpackWar", "false");
private static EjbModule addTestClassAsManagedBean(Class<?> javaClass, URLClassLoader tempClassLoader, AppModule appModule) { final EjbJar ejbJar = new EjbJar(); final OpenejbJar openejbJar = new OpenejbJar(); final String ejbName = appModule.getModuleId() + "_" + javaClass.getName(); final ManagedBean bean = ejbJar.addEnterpriseBean(new ManagedBean(ejbName, javaClass.getName(), true)); bean.localBean(); bean.setTransactionType(TransactionType.BEAN); final EjbDeployment ejbDeployment = openejbJar.addEjbDeployment(bean); ejbDeployment.setDeploymentId(ejbName); final EjbModule e = new EjbModule(ejbJar, openejbJar); e.getProperties().setProperty("openejb.cdi.activated", "false"); e.getProperties().setProperty("openejb.test.module", "true"); e.setBeans(new Beans()); e.setClassLoader(tempClassLoader); appModule.getEjbModules().add(e); return e; }
appInfo.appId = appModule.getModuleId(); appInfo.path = appModule.getJarLocation(); appInfo.standaloneModule = appModule.isStandaloneModule(); appInfo.delegateFirst = appModule.isDelegateFirst(); appInfo.watchedResources.addAll(appModule.getWatchedResources()); appInfo.mbeans.addAll(appModule.getAdditionalLibMbeans()); appInfo.jaxRsProviders.addAll(appModule.getJaxRsProviders()); appInfo.properties.putAll(appModule.getProperties()); for (final EjbModule ejbModule : appModule.getEjbModules()) { try { final EjbJarInfo ejbJarInfo = this.ejbJarInfoBuilder.buildInfo(ejbModule); if (appModule.getApplication() != null) { jndiEncInfoBuilder.build(appModule.getApplication(), appInfo.appId, null, appModule.getModuleUri(), new JndiEncInfo(), new JndiEncInfo()); for (final EjbModule ejbModule : appModule.getEjbModules()) { final List<URL> additionalLibraries = appModule.getAdditionalLibraries(); for (final URL url : additionalLibraries) { final File file = toFile(url); if (appModule.getCmpMappings() != null) { try { appInfo.cmpMappingsXml = JpaJaxbUtil.marshal(EntityMappings.class, appModule.getCmpMappings()); } catch (final JAXBException e) { throw new OpenEJBException("Unable to marshal cmp entity mappings", e);
private void readPropertiesFiles(final AppModule appModule) throws OpenEJBException { final Collection<DeploymentModule> deploymentModule = appModule.getDeploymentModule(); // We intentionally add the AppModule itself LAST so its properties trump all deploymentModule.add(appModule); for (final DeploymentModule module : deploymentModule) { final Object o = module.getAltDDs().get("application.properties"); if (o instanceof URL) { final URL url = (URL) o; try { final Properties properties = IO.readProperties(url); appModule.getProperties().putAll(properties); } catch (final IOException e) { throw new OpenEJBException("Cannot read application.properties: " + url, e); } } else if (o instanceof Properties) { appModule.getProperties().putAll((Properties) o); } else if (o != null) { throw new OpenEJBException("Unknown application.properties type: " + o.getClass().getName()); } } }
private Object configureConfiguration(final AppModule appModule, final Class<?> clazz, Object instance, final Method m) { final int modifiers = m.getModifiers(); if (!Modifier.isPublic(modifiers)) { throw new IllegalArgumentException("@Configuration should be public"); } final boolean isStatic = Modifier.isStatic(modifiers); if (!isStatic) { try { instance = clazz.newInstance(); } catch (final Exception e) { // no-op } } try { final Object result = m.invoke(isStatic ? null : instance); if (Properties.class.isInstance(result)) { appModule.getProperties().putAll(Properties.class.cast(result)); } else { throw new IllegalArgumentException(result + " not yet supported (" + m + ")"); } } catch (final IllegalAccessException | InvocationTargetException e) { throw new IllegalStateException(e); } return instance; }
public static List<ContainerInfo> getContainerInfos(final AppModule module, final ConfigurationFactory configFactory) throws OpenEJBException { final List<ContainerInfo> containerInfos = new ArrayList<ContainerInfo>(); if (module.getContainers().isEmpty()) { return containerInfos; } final String prefix = module.getModuleId() + "/"; for (final Container container : module.getContainers()) { if (container.getId() == null) { throw new IllegalStateException("a container can't get a null id: " + container.getType() + " from " + module.getModuleId()); } if (!container.getId().startsWith(prefix)) { container.setId(prefix + container.getId()); } final ContainerInfo containerInfo = configFactory.createContainerInfo(container); containerInfo.originAppName = module.getModuleId(); final Object applicationWideProperty = containerInfo.properties.remove("ApplicationWide"); if (applicationWideProperty != null) { containerInfo.applicationWide = Boolean.parseBoolean(applicationWideProperty.toString().trim()); } containerInfos.add(containerInfo); } return containerInfos; } }
final AppModule appModule = new AppModule(loader, archive.getName()); if (WEB_INF.equals(prefix)) { appModule.setDelegateFirst(false); appModule.setStandloneWebModule(); final WebModule webModule = new WebModule(createWebApp(archive), contextRoot(archive.getName()), loader, "", appModule.getModuleId()); webModule.setUrls(additionalPaths); appModule.getWebModules().add(webModule); } else if (isEar) { // mainly for CDI TCKs final FinderFactory.OpenEJBAnnotationFinder earLibFinder = new FinderFactory.OpenEJBAnnotationFinder(new SimpleWebappAggregatedArchive(tempClassLoader, scannedArchive, earMap)); appModule.setEarLibFinder(earLibFinder); final EjbModule earCdiModule = new EjbModule(appModule.getClassLoader(), DeploymentLoader.EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar()); earCdiModule.setBeans(earBeans); earCdiModule.setFinder(earLibFinder); appModule.getEjbModules().add(earCdiModule); final WebModule webModule = new WebModule(createWebApp(webArchive), contextRoot, webLoader, "", appModule.getModuleId() + "_" + contextRoot); webModule.setUrls(Collections.<URL>emptyList()); webModule.setScannableUrls(Collections.<URL>emptyList()); appModule.getEjbModules().add(ejbModule); appModule.getWebModules().add(webModule); if (appModule.isWebapp()) { // war appModule.getWebModules().iterator().next().setFinder(ejbModule.getFinder()); appModule.getEjbModules().add(ejbModule);
public AppInfo configureApplication(ClassLoader classLoader, String id, List<File> jarFiles) throws OpenEJBException { AppModule collection = new AppModule(classLoader, id); Map<String, Object> altDDs = collection.getAltDDs(); AppModule module = deploymentLoader.load(jarFile); collection.getAdditionalLibraries().addAll(module.getAdditionalLibraries()); collection.getClientModules().addAll(module.getClientModules()); collection.getEjbModules().addAll(module.getEjbModules()); collection.getPersistenceModules().addAll(module.getPersistenceModules()); collection.getResourceModules().addAll(module.getResourceModules()); collection.getWebModules().addAll(module.getWebModules()); collection.getWatchedResources().addAll(module.getWatchedResources()); for (Map.Entry<String, Object> entry : module.getAltDDs().entrySet()) { Object existingValue = altDDs.get(entry.getKey());