LightObjectBOX IoC container — example

I usually like less xml configuration, i have a tiny project… IDEAStickyPlugin which is running as IntelliJ IDEA Plugin.

recently i got interest to support IDEASticky as a desktop standalone application, at least for my Ubuntu based pc, (i am not satisfy with Sticky notes and Tomboy).
these days i am working on this stuff. so i felt a tiny light weight IoC container,(though PicoContainer is better) no XML level configuration will be a good addition…

so yesterday evening i made the first test case and implemented the tiny container, here is few example code snaps:

@LightObjectName( name = “a” )
public class A {
……
@LightObjectKey( key = “b” )
public void setB(B b) {
this.b = b;
}
……
}

@LightObjectName( name = “b” )
public class B {
…..
@LightObjectKey( key = “a” )
public void setA(A a) {
this.a = a;
}
…..
}

here @LightObjectName annotation is used to define an object name, this name will be used to store in container.
@LightObjectKey annotation is used to define dependent object. it will be set through the setter on container initialization time.
also cyclic dependency has no problem.

sample usages:

mContainer = LightObjectBox.createBox();
mContainer.add( A.class );
mContainer.add( B.class );
mContainer.init();

here i have created an instance of LightObjectBox though createBox() and ..
add(
Class ) is used to register a component into container scope. later init(); invocation initialize all classes + dependencies …

so i can recall my object instance by “A a = mContainer.getObject( “a” );”
i will publish whole source code after completing my IDEASticky Standalone :) keep reading my blog :)

Advertisement

One response to “LightObjectBOX IoC container — example

  1. Bhai jaan,
    I can’t able to understand everyting … :(
    Becouse i have no knowledge about JAVA Language. But i’ll … learn it…

    But i know you are well in JAVA. :)

    Go ahead Hasan bhai…

    Aawaj

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

my tweets

 

October 2006
S S M T W T F
« Sep   Nov »
 123456
78910111213
14151617181920
21222324252627
28293031  

Flickr Photos



@kamalapur over bridge

@kamalapur station

cox's bazaar trip oct 09

cox's bazaar trip oct 09

More Photos
Follow

Get every new post delivered to your Inbox.