Title: OpenWebBeans FAQ Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at . https://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. # OpenWebBeans Configuration Internal configuration of OpenWebBeans can be done via: src/main/resources/META-INF/openwebbeans/openwebbeans.properties All those files contain at single property ``configuration.ordinal`` which defines their 'importance'. Any setting from a property file with a higher configuration.ordinal will overwrite settings from one with a lower configuration.ordinal. The internally used configuration.ordinal values range from 1 to 100. The default value is 100. This trick allows us to split OpenWebBeans in different modules which automatically change the container configuration if you put that jar on the classpath. For overriding the default configuration with own settings simply put a ``META-INF/openwebbeans/openwebbeans.properties`` file into your projects classpath (e.g. into a jar) and either use a ``configuration.ordinal`` higher than 100 or leave it empty to get the default value of 100. If you use OpenWebBeans as part of another project then you can assume that most of the values got tweaked by the integration regarding to the specific needs. ## Configure SPI implementations OpenWebBeans provide a set of Service Provider Interfaces and multiple different implementations a user can choose from. You can choose the implementations you like to use for your situation by configuring them in ``META-INF/openwebbeans/openwebbeans.properties``. Read more about our SPIs in [OpenWebBeans SPI](openwebbeans-spi.html) ## Other Configurable Values The following configuration values can get tweaked to get tailor OWB to your specific needs. Boolean values can either be true, or TRUE, or false, or FALSE. ## Proxy Mapping OpenWebBeans enables the user to define the NormalScope handlers for specific scopes. NormalScope handlers are used by OpenWebBeans' proxies to resolve the 'Contextual Instance'. E.g. for a ``@SessionScoped User`` injected into some other class, this is exactly the piece of code which goes into the current Http Session and gets the User instance from there. This class must extend ``org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler`` and overwrite the ``Object getContextualInstance()`` method. This allows for more aggressive caching than with the generic ``NormalScopedBeanInterceptorHandler`` which is the default. The default NormalScope handler will look up the Contextual Instance in the respective Context for each and every method invocation on the proxy. But sometimes we can much more aggressively cache the instances. E.g. for ``@ApplicationScoped`` beans we can keep the contextual instance inside the proxy, making it as fast as a pure Java instance - but still gaining all the benefits of CDI! For ``@RequestScoped`` and ``@SessionScoped`` we can use a NormalScope handler which caches the Contextual Instance in a ThreadLocal. By default the following NormalScope handlers get used:
org.apache.webbeans.proxy.mapping.javax.enterprise.context.ApplicationScoped
    =org.apache.webbeans.intercept.ApplicationScopedBeanInterceptorHandler
org.apache.webbeans.proxy.mapping.javax.enterprise.context.RequestScoped
    =org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler
org.apache.webbeans.proxy.mapping.javax.enterprise.context.SessionScoped
    =org.apache.webbeans.intercept.SessionScopedBeanInterceptorHandler
As you can see we use a prefix ``org.apache.webbeans.proxy.mapping.`` followed by the fully qualified scope name as key. The value represents the fully qualified name of the handler class. If you have a custom scope which spans a Request or longer then you can simply reuse the ``RequestScopedBeanInterceptorHandler`` as shown in the following example:
org.apache.webbeans.proxy.mapping.org.apache.deltaspike.core.api.scope.ViewAccessScoped
    =org.apache.webbeans.intercept.RequestScopedBeanInterceptorHandler
##Enable FailOver / Session Replication support #### Since OpenWebBeans-1.5.0 OWB-1.5.x and later does *not* need any special module or filter to enable clustering. All that works out of the box as we now directly utilize the Servlet Session. #### OpenWebBeans-1.2.x Add the clustering module to your project: org.apache.openwebbeans openwebbeans-clustering Register the FailOverFilter in your web.xml: OWB FailOverFilter org.apache.webbeans.web.failover.FailOverFilter OWB FailOverFilter Faces Servlet #### OpenWebBeans-1.0.x and 1.1.x Add the following properties in your openwebbeans.properties: configuration.ordinal=100 org.apache.webbeans.web.failover.issupportfailover=true org.apache.webbeans.web.failover.issupportpassivation=true Register the FailOverFilter in your web.xml: OWB FailOverFilter org.apache.webbeans.web.failover.FailOverFilter OWB FailOverFilter Faces Servlet