rkuhn / BootStrap

Lightweight application initialization helper

Home Page:http://www.rkuhn.info/BootStrap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BootStrap
=========

This started out as a lightweight replacement for those large DI frameworks
when all you need is to wire up a few objects. Features:

- no transitive dependencies apart from scala-library
- can instantiate any POJO (constructor args or bean setters)
- provides Configuration trait for enhancing user experience if desired
- configuration file format extremely easy to read and write

Example configuration file syntax:

================================================================================
configure SomeThing bob
  with SomeProperty 42
  with OtherProperty "hello world!"
end

configure OtherThing constructorDemo
  construct arg1
  construct reference bob
  with Property configure Helper with Name Alice end
  call start
end
================================================================================

Whitespace is arbitrary except within double-quoted strings. Names are given as
second argument to "configure" and may be referenced only after their
corresponding "end" token (no passing around unfinished objects). The list of
constructors is scanned to find one which is compatible with the arguments
given, where literals are tried to parse using java.lang.Integer.valueOf() and
friends. "with Prop" tries calling a single-argument method named "setProp"
which is compatible with the given argument type. After all is set and done,
parameterless methods may be called by specifying "call".

Most of the above is skipped for classes implementing the Configurable
interface, which may enable setter invocations by overriding useBeanSetters()
to return "true". Constructor arguments are not legal, as are method calls. All
arguments not successfully passed into bean setters are wrapped up and passed
into the configure() method. The finished object must be returned wrapped in a
Success. This scheme allows direct configuration as well as factories.

See COPYING for licensing information.

Have Fun!

(c) 2011, Roland Kuhn

About

Lightweight application initialization helper

http://www.rkuhn.info/BootStrap

License:GNU Lesser General Public License v2.1


Languages

Language:Scala 66.6%Language:Python 33.4%