Meecrowave Configuration

Meecrowave configuration is centralized in org.apache.meecrowave.Meecrowave$Builder class.

Here are the main properties:

Name Description

cdiConversation

Should CDI conversation be activated

clientAuth

HTTPS keystore client authentication

conf

Conf folder to synchronize

connectors

Custom connectors

cxfServletParams

Init parameters passed to CXF servlet

deleteBaseOnStartup

Should the directory be cleaned on startup if existing

dir

Root folder if provided otherwise a fake one is created in tmp-dir

host

Default host

http2

Activate HTTP 2

httpPort

HTTP port

httpsPort

HTTPS port

injectServletContainerInitializer

Should ServletContainerInitialize support injections.

jaxrsAutoActivateBeanValidation

Should bean validation be activated on JAX-RS endpoint if present in the classpath.

jaxrsDefaultProviders

If jaxrsProviderSetup is true the list of default providers to load (or defaulting to johnson jsonb and jsonp ones)

jaxrsLogProviders

Should JAX-RS providers be logged

jaxrsMapping

Default jaxrs mapping

jaxrsProviderSetup

Should default JAX-RS provider be configured

jaxwsSupportIfAvailable

Should @WebService CDI beans be deployed if cxf-rt-frontend-jaxws is in the classpath.

jsonbBinaryStrategy

Should JSON-B provider prettify the output

jsonbEncoding

Which encoding provider JSON-B should use

jsonbIJson

Should JSON-B provider comply to I-JSON

jsonbNamingStrategy

Should JSON-B provider prettify the output

jsonbNulls

Should JSON-B provider serialize nulls

jsonbOrderStrategy

Should JSON-B provider prettify the output

jsonbPrettify

Should JSON-B provider prettify the output

jsonpBufferStrategy

JSON-P JAX-RS provider buffer strategy (see johnzon)

jsonpMaxReadBufferLen

JSON-P JAX-RS provider read buffer limit size (see johnzon)

jsonpMaxStringLen

JSON-P JAX-RS provider max string limit size (see johnzon)

jsonpMaxWriteBufferLen

JSON-P JAX-RS provider write buffer limit size (see johnzon)

jsonpPrettify

Should JSON-P JAX-RS provider prettify the outputs (see johnzon)

jsonpSupportsComment

Should JSON-P JAX-RS provider support comments (see johnzon)

keepServerXmlAsThis

Don’t replace ports in server.xml

keyAlias

HTTPS keystore alias

keystoreFile

HTTPS keystore location

keystorePass

HTTPS keystore password

keystoreType

HTTPS keystore type

loggingGlobalSetup

Should logging be configured to use log4j2 (it is global)

loginConfig

web.xml login config

meecrowaveProperties

Loads a meecrowave properties, defaults to meecrowave.properties.

pidFile

A file path to write the process id if the server starts

properties

Passthrough properties

quickSession

Should an unsecured but fast session id generator be used

realm

realm

roles

In memory roles

scanningExcludes

A forced exclude list of jar names (comma separated values)

scanningIncludes

A forced include list of jar names (comma separated values)

scanningPackageExcludes

A forced exclude list of packages names (comma separated values)

scanningPackageIncludes

A forced include list of packages names (comma separated values)

securityConstraints

web.xml security constraint

serverXml

Provided server.xml

sharedLibraries

A folder containing shared libraries.

skipHttp

Skip HTTP connector

ssl

Use HTTPS

sslProtocol

HTTPS protocol

stopPort

Shutdown port if used or -1

tempDir

Temporary directory

tomcatAccessLogPattern

Activates and configure the access log valve. Value example: '%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'

tomcatAutoSetup

Add default servlet

tomcatFilter

A Tomcat JarScanFilter

tomcatNoJmx

(Experimental) Should Tomcat MBeans be skipped.

tomcatScanning

Should Tomcat scanning be used (@HandleTypes, @WebXXX)

tomcatWrapLoader

(Experimental) When deploying a classpath (current classloader), should meecrowave wrap the loader to define another loader identity but still use the same classes and resources.

useLog4j2JulLogManager

Should JUL logs be redirected to Log4j2 - only works before JUL usage.

useShutdownHook

Use shutdown hook to automatically stop the container on Ctrl+C

useTomcatDefaults

Should Tomcat default be set (session timeout, mime mapping etc…​)

users

In memory users

watcherBouncing

Activate redeployment on directories update using this bouncing.

webResourceCached

Cache web resources

webXml

Global web.xml

the class also provides some helper methods for programamtic use case like randomHttpPort() to automatically set an available port to httpPort.

You can also write a Consumer<Builder> to configure programmatically the Builder and make it active using addCustomizer(Consumer<Builder>).

Example:

new Meecrowave(new Builder() {{
        randomHttpPort();
        setTomcatScanning(false);
        setTomcatAutoSetup(false);
        setRealm(new JAASRealm());
        user("admin", "secret");
     }})
    .bake()
    .await();

Automatic configuration

The org.apache.meecrowave.Meecrowave$Builder class also provides loadFromProperties(Properties) and loadFrom(String). The last one uses the parameter to locate a propertiers file (file path or at classpath) and delegate the processing to the first one.

loadFromProperties(Propertiers) loads the configuraton from the properties. The matching is alsmot 1-1 with previous table excepted for these entries:

  • if httpPort is -1 then randomHttpPort is called

  • properties.x=y will set the property (properties entry) x with the value y

  • users.x=y will create the user x with the password y

  • roles.x=y will create the role x with the users y (comma separated if multiple users)

  • cxf.servlet.params.x=y will force the CXF servlet init parameter x to be y

  • connector.x=y will pass the property x to be y on the connector

  • connector.attributes.x=y will use the property x with value y to create the connector (set a property on the instance of ̀`org.apache.catalina.connector.Connector`)

  • realm=y will create an instance of y (qualified name of the class) as realm

  • realm.x=y will set x property to y - needs previous property to be set

  • login= will create a custom org.apache.meecrowave.Meecrowave$LoginConfigBuilder

  • login.x=y will customize previous instance with x property

  • securityConstraint= will create a custom org.apache.meecrowave.Meecrowave$SecurityConstaintBuilder

  • securityConstraint.x=y will customize previous instance with x property

  • configurationCustomizer=y will create an instance of y to customize the configuration

  • configurationCustomizer.x=y will set x to y for the customizer

out of the box, any Builder instance will read meecrowave.properties. meecrowave.properties uses CLI names (without the leading --). See CLI page for the list.

Logging

Meecrowave relies by default on Log4j2 (see http://logging.apache.org/log4j/2.x/). By default it uses an internal configuration which is overriden by standard log4j mecanism.

Passwords/Secrets

For the configuration requiring to be ciphered you can implement org.apache.meecrowave.service.ValueTransformer:

public class MyTransformer implements ValueTransformer {
    @Override
    public String name() {
        return "mine";
    }

    @Override
    public String apply(final String encodedPassword) {
        return ....;
    }
}
this code being executed before the container starts you can’t use CDI there.

To register your implementation just put the fully qualified name of your transformer in META-INF/services/org.apache.meecrowave.service.ValueTransformer.

Then to use it set the value to decode:mine:encodedvalue. General pattern is: decode:<transformer name>:<value before decryption>.

Note that by default the same ciphering algorithm than in TomEE is available (Static3DES).

This syntax is usable on the command line and in meecrowave.properties.

Programmatic customization

org.apache.meecrowave.Meecrowave$ConfigurationCustomizer can be used to customize the configuration programmatically before startup. It will take the Builder as parameter and you can change it at that moment.

org.apache.meecrowave.Meecrowave$InstanceCustomizer can be used to customize the configuration programmatically before startup. It will take the Tomcat as parameter and you can change it at that moment. This is very useful to automatically add valves and things like that.