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; }
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 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()); } } }
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"); } }
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 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()); } } }
@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; }
@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; }
@Override public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException { final String name = localName.toLowerCase(); if (CONFIGURATION_ALIASES.contains(name)) { push(new Configuration("", module.getProperties())); } else if (ENV_ENTRIES_ALIASES.contains(name)) { push(new EnvEntries()); } else if (BEAN_CONTEXTS_ALIASES.contains(name)) { push(new BeanContexts(null)); } else if (MODULE_ALIASES.contains(name)) { push(new ModuleContext(attributes.getValue("id"))); } else if (WEBAPP_ALIASES.contains(name)) { push(new WebAppContext(attributes.getValue("id"))); } else if (POJOS_ALIASES.contains(name)) { push(new Pojos()); } else if (RESOURCES_ALIASES.contains(name)) { push(new ResourcesConfig()); } else if (IMPORT_ALIASES.contains(name)) { importFile(attributes.getValue("path")); push(new DefaultHandler()); // just to keep the stack consistent } else { throw new IllegalStateException("Unsupported Element: " + localName); } }
@Override public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException { final String name = localName.toLowerCase(); if (CONFIGURATION_ALIASES.contains(name)) { push(new Configuration("", module.getProperties())); } else if (ENV_ENTRIES_ALIASES.contains(name)) { push(new EnvEntries()); } else if (BEAN_CONTEXTS_ALIASES.contains(name)) { push(new BeanContexts(null)); } else if (MODULE_ALIASES.contains(name)) { push(new ModuleContext(attributes.getValue("id"))); } else if (WEBAPP_ALIASES.contains(name)) { push(new WebAppContext(attributes.getValue("id"))); } else if (POJOS_ALIASES.contains(name)) { push(new Pojos()); } else if (RESOURCES_ALIASES.contains(name)) { push(new ResourcesConfig()); } else if (IMPORT_ALIASES.contains(name)) { importFile(attributes.getValue("path")); push(new DefaultHandler()); // just to keep the stack consistent } else { throw new IllegalStateException("Unsupported Element: " + localName); } }
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)); } } }
override(appModule.getProperties(), info, "hibernate"); override(appModule.getProperties(), info, "toplink"); override(appModule.getProperties(), info, "eclipselink"); override(appModule.getProperties(), info, "openjpa"); override(appModule.getProperties(), info);
override(appModule.getProperties(), info, "hibernate"); override(appModule.getProperties(), info, "toplink"); override(appModule.getProperties(), info, "eclipselink"); override(appModule.getProperties(), info, "openjpa"); override(appModule.getProperties(), info);
system.putAll(appModule.getProperties()); system.putAll(System.getProperties());
base.putAll(appModule.getProperties());
base.putAll(appModule.getProperties());
system.putAll(appModule.getProperties()); system.putAll(JavaSecurityManagers.getSystemProperties());
appModule.getProperties().put("loader.from", "tomcat");
appInfo.mbeans.addAll(appModule.getAdditionalLibMbeans()); appInfo.jaxRsProviders.addAll(appModule.getJaxRsProviders()); appInfo.properties.putAll(appModule.getProperties());
appInfo.mbeans.addAll(appModule.getAdditionalLibMbeans()); appInfo.jaxRsProviders.addAll(appModule.getJaxRsProviders()); appInfo.properties.putAll(appModule.getProperties());