Lasta Di

Japanese page here.

Lasta Di とは?

simple DI container for LastaFlute, forked from Seasar as Java8

GitHub Page

is there:

Two components

Quick component
convention registration, hot reloading (prototype)
Rich component
flexible manual registration (singleton)

How to inject

Both components can be injected by @Resource annotation.

e.g. injection definition @Java
private AbcLogic abcLogic;

Quick component

Application's business logics, are prototype e.g. Action class, Logic class...

Convention provides auto regsitration:

[your domain].app (e.g.
Class Name
e.g. app.web.AbcAction, auto regsitered as Action to Lasta Di

Class name suffixes is e.g. following:

Assist (or
AbcValidator, AbcConverter, AbcHelper, AbcService
e.g. Quick components @Directory
 |-app // application package
 |  |-logic
 |  |  |-AbcLogic
 |  |-web // web package
 |     |-AbcAction
 |     |-AbcForm

And these components can be hot-reloaded so you don't need to reboot in local development. So you can get quick trial-and-error programming with Lasta Di.

Rich component

Application's common classes, are singleton e.g. Manager class

[your domain].bizfw (e.g. com.example.bizfw) *actually free but recommended
Class Name
e.g. bizfw.AbcManager, basically you can set free name

You can register by your Di xml app.xml flexibly.

e.g. Rich components @Directory
|  |-com.example
|    |-app
|    |-bizfw *recommended package for rich components
|    |  |-AbcManager
|    |-dbflute
|    |-mylasta
   |-app.xml *your Di xml, you can regsiter here
e.g. Di xml @app.xml
    <include path="convention.xml"/>
    <component name="abcManager">...bizfw.AbcManager</component>

Lightening Boot

Simple logic in Lasta Di, speed is prior.

And following features:

Small dependencies
Javassit, JTA, Slf4j (only three)
Lazy Loading
Minimum initialization in (in hot, warm)

Application settigs for Lasta Di.

e.g. is here @Directory
|  |-com.example...
smart.deploy.mode.location (optional: cool as default)
Settings for smark deploy mode (hot, warn, cool). e.g. hot provides you quick programming in development. While, cool should be set in production.
smart.package1 (basically required)
Settings for application package treated as smark deploy.
You can set smart.package2, and 3...

Di xml

Di xml Overview

You can register your components in app.xml.

e.g. app.xml is here @Directory
|  |-com.example...

You can get rich components by setting comopnent tags with your classes.

e.g. settings for rich components @app.xml
    <!-- settings for rich components -->
    <component name="abcManager">...bizfw.AbcManager</component>
    <component name="stuManager">...bizfw.StuManager</component>
    <component name="xyzManager">...bizfw.XyzManager</component>

You can get quick components by including convention.xml.

e.g. settings for rich components @app.xml
    <include path="convention.xml"/> <!-- needs for quick components -->

    <!-- settings for rich components -->
    <component name="abcManager">...bizfw.AbcManager</component>

You can get library components provided from frameworks, e.g. LastaFlute, DBFlute, by including their xml.

e.g. Di xml @app.xml
    <include path="convention.xml"/>
    <include path="dbflute.xml"/>
    <include path="lastaflute.xml"/>

    <component name="abcManager">...bizfw.AbcManager</component>

Di xml Hierarchy

Embedded xml in Lasta Di are colored:

e.g. Di xml Hierarchy, embedded is colored @app.xml
...Reading lasta_di.xml
...Reading   redefiner.xml
...Reading   smartdeploy.xml
...Reading     smart/hotdeploy.xml
...Reading       convention.xml
...Reading         embedded_convention.xml
...Reading       creator.xml
...Reading         convention.xml (recycle)
...Reading         customizer.xml
...Reading           lastafw_customizer.xml
...Reading           embedded_customizer.xml
...Reading             tx_customizer.xml
...Reading         lastafw_creator.xml
...Reading           convention.xml (recycle)
...Reading           customizer.xml (recycle)
...Reading         embedded_creator.xml
...Reading           convention.xml (recycle)
...Reading           customizer.xml (recycle)
...Reading       customizer.xml (recycle)
...Reading app.xml
...Reading   convention.xml
...Reading     embedded_convention.xml
...Reading   dbflute.xml
...Reading     rdb.xml
...Reading       jta.xml
...Reading         jta+userTransaction.xml
...Reading         jta+transactionManager.xml
...Reading       jdbc.xml
...Reading         jta.xml (recycle)
...Reading         lastaflute_assist.xml
...Reading           lastaflute_director.xml
...Reading       tx_aop.xml
...Reading         jta.xml (recycle)
...Reading   lastaflute.xml
...Reading     lastaflute_core.xml
...Reading       lastaflute_assist.xml (recycle)
...Reading     lastaflute_db.xml
...Reading       jta.xml (recycle)
...Reading     lastaflute_web.xml
...Reading       lastaflute_core.xml (recycle)
...Reading       lastaflute_db.xml (recycle)
...Reading       convention.xml (recycle)

Di xml Expression

Using JavaScript engine 'Nashorn' as expression parser.


TODO jflute 要は S2ClassBuilder

Major Classes

has your components
manages database connections

Maven Repository

See github page.

If you use LastaFlute, you don't need Lasta Di dependency because LastaFlute depends it.

Thanks, Frameworks

Lasta Di is forked from Seasar, and inherits it, thankful wonderful functions.

And also forked from S2ClassBuilder (called Redefiner in Lasta Di), provides flexible Di xml.