Petite uses annotation based configuration to make setup and configuration simple as possible. It doesn't depend on any external (XML) files; by default all configuration is done in pure Java. Nevertheless, it is easy to configure and extend Petite to match any requirements.
Installation is trivial: jodd.jar and jodd-wot.jar has to be on the classpath.
In order to use SessionScope (in some servlet container), the following listeners has to be added to the web.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-app ...> ... <listener> <listener-class>jodd.servlet.RequestContextListener</listener-class> </listener> <listener> <listener-class>jodd.servlet.HttpSessionListenerBroadcaster</listener-class> </listener> ... </web-app>
When container has session scope beans, it can't be used out of servlet container. This makes testing outside of container hard. However, Petite has one nice feature: it is possible to register scopes manually. In regular use case, it is not necessary to deal with scopes registration, since scopes will be resolved and instantiated on their first usage. Anyhow, it is possible to register specific scope instance for any scope that will be used instead of required one.
For example, it is possible to replace session scope with the singleton scope, what is usually enough for the tests:
PetiteContainer petite = new PetiteContainer(); petite.getManager().registerScope(SessionScope.class, new SingletonScope());
Now all session scope beans will be registered within singleton scope, assuming there is one and only one, big session.
Petite container has just few settings:
defaultScope - default scope for bean registration, default value: SingletonScope.class;defaultWiringMode - default wiring mode. Default value: WiringMode.STRICT. Mode can be changed during runtime (although not recommended).detectDuplicatedBeanNames - flag for detecting duplicated bean names during registration.