nuun-io / kernel

Nuun Kernel is an IOC component for creation of powerfull enterprise stack.
Other
8 stars 5 forks source link

Fix 59 root packages #63

Closed pith closed 8 years ago

pith commented 8 years ago

Currently I find difficult to know what are the configuration options for the kernel. Some of them are accessible via KernelConfiguration, some of them are accessible through kernel params and it's also difficult to find all the kernel params.

So I propose an option system à la XNIO (javadoc).

Add a typed option:

public class KernelOption<T>
{
    private String name;
    private T value;
}

Group all the options in a class KernelOptions:

public class KernelOptions
{
    public static final KernelOption<List<String>> ROOT_PACKAGES = new KernelOption<List<String>>("root.packages");
    public static final KernelOption<Boolean> PRINT_SCAN_WARN = new KernelOption<Boolean>("scan.warn.disable");
    ...
}

Add an option method on KernelConfiguration:

<T> KernelConfiguration option(KernelOption<T> option, T value)

Then use it as follows:

NuunCore.newKernelConfiguration()
                .option(KernelOptions.SCAN_PLUGIN, false)
                .option(KernelOptions.ROOT_PACKAGES, Lists.newArrayList("it.fixture.scan"))

As a bonus this PR also add a fixture to factorize the kernel creation in the tests.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.2%) to 80.387% when pulling d78e0199c766527c40c0c776b0d89fef3284b65b on fix-59-rootPackages into 0494c47f20eb0e4ad4eaf775199f5ac2c924cd58 on master.

pith commented 8 years ago

Fix #59