[Oxen Software Studio] OxenIoC: IoC container for Objective C.Part 2

9 views
Skip to first unread message

Facundo

unread,
May 7, 2011, 10:48:38 AM5/7/11
to oxen-softw...@googlegroups.com
We have improved our OxenIoC container. We have fixed one bug, the only one that we detected, and we have added some new features that help to write less code to define objects into container and their dependencies.

The main idea is use a mechanism like java annotations or c# attributes. We developed some preprocessors macros for this.

The preprocessors macros defined are:
  • IoCName(name): Defines a name for the object. If you don't use this "annotation" so the object will be named like the class name.
  • IoCLazy: Defines if it is Lazy.
  • IoCSingleton: Defines if the object is Singleton.
  • IoCInject(property, objectName): Inject the object whose name is "objectName" into the property named "property".
Example:
#import "ServiceExecutorImpl3.h"
#import "IoCContainer.h"

@implementation ServiceExecutorImpl3
@synthesize service;

IoCName(ServiceExecutor3)
IoCLazy
IoCSingleton
IoCInject(service, theService)

- (void) executeService {
[service execute];
}
@end
This example, defines an object named ServiceExecutor3, lazy, singleton and injects into property "service" the object named "theService".

For getting the instance of this class we just call the getObject method
 id executor = [container getObject:@"ServiceExecutor3"];
So, this is a third way to defines objects into container. The others two are by instancing a ObjectDefinition object and by xml.

To get the code click here

Part1 of this post click here




--
Posted By Facundo to Oxen Software Studio at 2/15/2011 11:14:00 AM

Facundo

unread,
May 7, 2011, 10:52:37 AM5/7/11
to oxen-softw...@googlegroups.com
We have improved our OxenIoC container. We have fixed one bug, the only one that we detected, and we have added some new features that help to write less code to define objects into container and their dependencies.

The main idea is to use a mechanism like java annotations or c# attributes. We developed some preprocessors macros for this.


The preprocessors macros defined are:
  • IoCName(name): Defines a name for the object. If you don't use this "annotation" then the object will be named like the class name.
  • IoCLazy: Defines if it is Lazy.
  • IoCSingleton: Defines if the object is Singleton.
  • IoCInject(property, objectName): Inject the object whose name is "objectName" into the property named "property".
    Example:
    #import "ServiceExecutorImpl3.h"
    #import "IoCContainer.h"

    @implementation ServiceExecutorImpl3
    @synthesize service;

    IoCName(ServiceExecutor3)
    IoCLazy
    IoCSingleton
    IoCInject(service, theService)

    - (void) executeService {
    [service execute];
    }
    @end
    This example defines an object named ServiceExecutor3, lazy, singleton and injects into property "service" the object named "theService".
    Reply all
    Reply to author
    Forward
    0 new messages