Announcement Announcement Module
Collapse
No announcement yet.
Fluent Application Context Wiring Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fluent Application Context Wiring

    I created an api that allows for fluent, programmatic configuration of an application context that also borrows some ideas from guice. I wanted to create configuration programmatically, but I didn't want to use annotations or use magic strings for configuring objects.

    Code:
    SpruiceModule module = new SpruiceModule() {
                public void wire(Binder binder) {
                    BeanConfig<Car> carConfig = binder.autowire("car", Car.class);
                    carConfig.startWith().start();
                    carConfig.stopWith().turnOff();
    
                    BeanConfig<Engine> engineConfig = binder.autowire("engine", Engine.class);
                    engineConfig.set().setHorsepower(200);
                    engineConfig.initWith().primeEngine();
                    engineConfig.destroyWith().destroyEngine();
                }
            };
    
            ContextBuilder builder = new ContextBuilder();
            builder.register(module);
            ModuleContext context = builder.createContext();
    
            Car car = context.get("car");
    The example shows the basic api. Proxies are used to record the configuration . The recorded information is then used to populate a generic application context. The context can be used as a parent to an xml context or annotation based context, or vice versa. It is a very thin wrapper around the Spring api's so it plays nice with existing functionality.

    The project, called Spruice, is hosted at google code. Any feedback from the Spring community would be appreciated.

    Regards,

    Mike

  • #2
    Fluent API for spring .net

    A new fluent api is available at this location:

    https://github.com/thenapoleon/Fluen...for-Spring.Net

    complete with pretty much all of what spring can do.

    Y.

    Comment

    Working...
    X