final ValueTransformers transformers = getExtension(ValueTransformers.class); for (final String key : config.stringPropertyNames()) { final String val = config.getProperty(key); } else if (field.getType() == int.class) { if ("httpPort".equals(name) && "-1".equals(val)) { // special case in case of random port randomHttpPort(); toSet = null; } else { property(prop.substring("properties.".length()), config.getProperty(prop)); } else if (prop.startsWith("users.")) { user(prop.substring("users.".length()), config.getProperty(prop)); } else if (prop.startsWith("roles.")) { role(prop.substring("roles.".length()), config.getProperty(prop)); } else if (prop.startsWith("cxf.servlet.params.")) { cxfServletParam(prop.substring("cxf.servlet.params.".length()), config.getProperty(prop)); } else if (prop.startsWith("connector.")) { // created in container property(prop, config.getProperty(prop)); } else if (prop.equals("realm")) { final ObjectRecipe recipe = newRecipe(config.getProperty(prop)); addCustomizer(Consumer.class.cast(recipe.create()));
@Override public void beforeAll(final ExtensionContext context) { final Meecrowave.Builder builder = new Meecrowave.Builder(); final Optional<MeecrowaveConfig> meecrowaveConfig = context.getElement().map(e -> e.getAnnotation(MeecrowaveConfig.class)); final String ctx; if (builder.getHttpPort() < 0) { builder.randomHttpPort();
final Map<String, String> props = new HashMap<>(); if (config != null) { ofNullable(config.getProperties()).ifPresent(p -> p.stringPropertyNames().stream() .filter(k -> k.startsWith("jpa.property.")) .forEach(k -> props.put(k.substring("jpa.property.".length()), p.getProperty(k))));
if (configuration.getMeecrowaveProperties() != null && !"meecrowave.properties".equals(configuration.getMeecrowaveProperties())) { configuration.loadFrom(configuration.getMeecrowaveProperties()); if (configuration.isUseLog4j2JulLogManager() && Log4j2s.IS_PRESENT) { // /!\ don't move this line or add anything before without checking log setup System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager"); setupJmx(configuration.isTomcatNoJmx()); if (configuration.getTempDir() == null || configuration.getTempDir().length() == 0) { tempDir = createDirectory(base, "temp"); } else { tempDir = new File(configuration.getTempDir()); if (!tempDir.exists()) { tempDir.mkdirs(); ofNullable(configuration.getSharedLibraries()).map(File::new).filter(File::isDirectory).ifPresent(libRoot -> { final Collection<URL> libs = new ArrayList<>(); try { ofNullable(configuration.getTomcatAccessLogPattern()) .ifPresent(pattern -> tomcat.getHost().getPipeline().addValve(new LoggingAccessLogPattern(pattern))); final List<Valve> valves = buildValves(); httpsConnector.setProperty("SSLEnabled", "true"); if (configuration.sslProtocol != null) { configuration.property("connector.sslhostconfig.sslProtocol", configuration.sslProtocol); configuration.property("connector.sslhostconfig.certificateKeystoreFile", configuration.keystoreFile);
if (configuration.getMeecrowaveProperties() != null && !"meecrowave.properties".equals(configuration.getMeecrowaveProperties())) { configuration.loadFrom(configuration.getMeecrowaveProperties()); if (configuration.isUseLog4j2JulLogManager() && Log4j2s.IS_PRESENT) { // /!\ don't move this line or add anything before without checking log setup System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager"); setupJmx(configuration.isTomcatNoJmx()); if (configuration.getTempDir() == null || configuration.getTempDir().length() == 0) { tempDir = createDirectory(base, "temp"); } else { tempDir = new File(configuration.getTempDir()); if (!tempDir.exists()) { tempDir.mkdirs(); ofNullable(configuration.getSharedLibraries()).map(File::new).filter(File::isDirectory).ifPresent(libRoot -> { final Collection<URL> libs = new ArrayList<>(); try { ofNullable(configuration.getTomcatAccessLogPattern()) .ifPresent(pattern -> tomcat.getHost().getPipeline().addValve(new LoggingAccessLogPattern(pattern))); final List<Valve> valves = buildValves(); httpsConnector.setProperty("SSLEnabled", "true"); if (configuration.sslProtocol != null) { configuration.property("connector.sslhostconfig.sslProtocol", configuration.sslProtocol); configuration.property("connector.sslhostconfig.certificateKeystoreFile", configuration.keystoreFile);
deployWebapp("/meecrowave", destination); }}) { System.out.println("Started on http://localhost:" + container.getConfiguration().getHttpPort() + "/meecrowave");
configuration = builder.getExtension(OAuth2Options.class); securityProperties = ofNullable(builder.getProperties()).map(Properties::stringPropertyNames).orElse(emptySet()).stream() .filter(s -> s.startsWith("oauth2.cxf.rs.security.")) .collect(toMap(s -> s.substring("oauth2.cxf.".length()), s -> builder.getProperties().getProperty(s)));
Meecrowave.Builder toMeecrowaveConfiguration() { final Meecrowave.Builder builder = new Meecrowave.Builder(); for (final Field field : MeecrowaveConfiguration.class.getDeclaredFields()) { final String name = field.getName(); builder.randomHttpPort(); builder.setUsers(properties.stringPropertyNames().stream().collect(toMap(identity(), properties::getProperty))); builder.setRoles(properties.stringPropertyNames().stream().collect(toMap(identity(), properties::getProperty))); builder.setCxfServletParams(properties.stringPropertyNames().stream().collect(toMap(identity(), properties::getProperty))); int end = realm.indexOf(':'); if (end < 0) { builder.setRealm(Realm.class.cast(loader.loadClass(realm).newInstance())); } else { final ObjectRecipe recipe = new ObjectRecipe(realm.substring(0, end)); .map(v -> v.split("=")) .forEach(v -> recipe.setProperty(v[0], v[1])); builder.setRealm(Realm.class.cast(recipe.create(loader))); builder.setSecurityConstraints(Stream.of(securityConstraints.split("|")) .map(item -> { try { .map(v -> v.split("=")) .forEach(v -> recipe.setProperty(v[0], v[1])); builder.setLoginConfig(Meecrowave.LoginConfigBuilder.class.cast(recipe.create(loader)));
private static void doSetup(final ServletContext servletContext) { final Meecrowave.Builder config = Meecrowave.Builder.class.cast(servletContext.getAttribute("meecrowave.configuration")); final HawtioConfiguration configuration = config.getExtension(HawtioConfiguration.class); final JolokiaInitializer.JolokiaConfiguration jolokia = config.getExtension(JolokiaInitializer.JolokiaConfiguration.class); if (!configuration.isActive()) { return;
Meecrowave.Builder toMeecrowaveConfiguration() { final Meecrowave.Builder builder = new Meecrowave.Builder(); for (final Field field : MeecrowaveConfiguration.class.getDeclaredFields()) { final String name = field.getName(); builder.randomHttpPort(); builder.setUsers(properties.stringPropertyNames().stream().collect(toMap(identity(), properties::getProperty))); builder.setRoles(properties.stringPropertyNames().stream().collect(toMap(identity(), properties::getProperty))); builder.setCxfServletParams(properties.stringPropertyNames().stream().collect(toMap(identity(), properties::getProperty))); int end = realm.indexOf(':'); if (end < 0) { builder.setRealm(Realm.class.cast(loader.loadClass(realm).newInstance())); } else { final ObjectRecipe recipe = new ObjectRecipe(realm.substring(0, end)); .map(v -> v.split("=")) .forEach(v -> recipe.setProperty(v[0], v[1])); builder.setRealm(Realm.class.cast(recipe.create(loader))); builder.setSecurityConstraints(Stream.of(securityConstraints.split("|")) .map(item -> { try { .map(v -> v.split("=")) .forEach(v -> recipe.setProperty(v[0], v[1])); builder.setLoginConfig(Meecrowave.LoginConfigBuilder.class.cast(recipe.create(loader)));
final ValueTransformers transformers = getExtension(ValueTransformers.class); for (final String key : config.stringPropertyNames()) { final String val = config.getProperty(key); } else if (field.getType() == int.class) { if ("httpPort".equals(name) && "-1".equals(val)) { // special case in case of random port randomHttpPort(); toSet = null; } else { property(prop.substring("properties.".length()), config.getProperty(prop)); } else if (prop.startsWith("users.")) { user(prop.substring("users.".length()), config.getProperty(prop)); } else if (prop.startsWith("roles.")) { role(prop.substring("roles.".length()), config.getProperty(prop)); } else if (prop.startsWith("cxf.servlet.params.")) { cxfServletParam(prop.substring("cxf.servlet.params.".length()), config.getProperty(prop)); } else if (prop.startsWith("connector.")) { // created in container property(prop, config.getProperty(prop)); } else if (prop.equals("realm")) { final ObjectRecipe recipe = newRecipe(config.getProperty(prop)); addCustomizer(Consumer.class.cast(recipe.create()));
.forEach(i -> optionValues[i] = builder.getExtension(Meecrowave.ValueTransformers.class).apply(optionValues[i]));
.forEach(i -> optionValues[i] = builder.getExtension(Meecrowave.ValueTransformers.class).apply(optionValues[i]));
public Meecrowave.Builder doBoot() { final Meecrowave.Builder configuration = new Meecrowave.Builder().randomHttpPort().noShutdownHook(/*the rule does*/); boolean unlocked = false; ClassLoaderLock.LOCK.lock();
public Meecrowave.Builder doBoot() { final Meecrowave.Builder configuration = new Meecrowave.Builder().randomHttpPort().noShutdownHook(/*the rule does*/); boolean unlocked = false; ClassLoaderLock.LOCK.lock();
@Override public void beforeAll(final ExtensionContext context) { final Meecrowave.Builder builder = new Meecrowave.Builder(); final Optional<MeecrowaveConfig> meecrowaveConfig = context.getElement().map(e -> e.getAnnotation(MeecrowaveConfig.class)); final String ctx; if (builder.getHttpPort() < 0) { builder.randomHttpPort();
public <T> T bind(final T instance) { final ValueTransformers transformers = getExtension(ValueTransformers.class); Class<? extends Object> type = instance.getClass(); do {
public <T> T bind(final T instance) { final ValueTransformers transformers = getExtension(ValueTransformers.class); Class<? extends Object> type = instance.getClass(); do {
map.putAll(asMap(builder.getProperties())); ofNullable(builder.getExtension(Cli.class).getConfiguration()).ifPresent(configuration -> { final File file = new File(configuration); if (file.exists()) {
map.putAll(asMap(builder.getProperties())); ofNullable(builder.getExtension(Cli.class).getConfiguration()).ifPresent(configuration -> { final File file = new File(configuration); if (file.exists()) {