Hi,

Today I commited some changes to appache-extras:

InjectingSerializer redesigned to get rid of dependency on InjectorListener and 
InjectorEventDispatcher.
Implemented Injector annotation:  Injector marks another annotation types as 
dependency injection markers. Fields marked with such DI markers are injected 
by instances obtained by specified bean factory type. This can be used for 
example also for logger injection:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@Injector(beanFactory=LoggerFactory.class)
public @interface InjectLogger {}

public class BeanWithLogger {
        @InjectLogger
        protected java.util.logging.Logger  l;
        
        public void sayHello() {
                l.info("Hello");
        }
}

See more in pivot_contrib.di\test\pivot_contrib\di\logInjector.

Regards K.

-----Original Message-----
From: Sandro Martini (JIRA) [mailto:j...@apache.org] 
Sent: Tuesday, February 26, 2013 2:32 PM
To: dev@pivot.apache.org
Subject: [jira] [Commented] (PIVOT-885) Add support for dependecy injection and 
RMI


    [ 
https://issues.apache.org/jira/browse/PIVOT-885?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13587114#comment-13587114
 ] 

Sandro Martini commented on PIVOT-885:
--------------------------------------

Hi Karel, your proposal looks very interesting, even the "field injected 
events" stuff ... so my priority here is to better understand if core Pivot 
need some change to enable usage of Spring or other DI frameworks (even in a 
basic way), and maybe provide a sample of this (for example in apache-extras).
Then improve existing classes with more annotation/other stuff, but again I 
think it would be better to keep in core Pivot only generic interfaces/classes, 
and provide any specific implementation in apache-extras, to have a more 
modular structure.
For example for 2.1 I'd like a simple DI way for injecting a logger inside 
Applications, and even a Cache implementation.

I started to look at your prototype in attach here and it seems very 
interesting (and don't get me wrong, but of course not all need/want to use 
RMI, DI, and related stuff). But before thinking to integrate it in core Pivot 
my approach would be to add it as an extension (put in a dedicated subproject 
under one of our subprojects at apache-extras), and then see how/what to do, 
base on users feedback, etc ... anyway you could help us to do this first step.

What do you think ?

                
> Add support for dependecy injection and RMI
> -------------------------------------------
>
>                 Key: PIVOT-885
>                 URL: https://issues.apache.org/jira/browse/PIVOT-885
>             Project: Pivot
>          Issue Type: New Feature
>            Reporter: Karel Hübl
>            Assignee: Sandro Martini
>             Fix For: 2.1
>
>         Attachments: extensions-sample.zip, pivot-extensions.zip
>
>
> As pivot application devoloper, I would like to have support for dependency 
> injection in Pivot. My requirements are:
> - support for field injection (at least)
> - support for @PostConstruct methods
> - support for @RuntimeScoped classes - only one instance may be constructed 
> during Runtime. Usefull when one needs share injected instances.
> - in relevant cases, inject dependencies also into namespace.
> I implemented prototype of this functionality, source codes including unit 
> tests and sample application are included. The dependency injection is 
> implemented in proposed org.apache.pivot.beans.injection package.
> Please consider adding this functionality in future Pivot release.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators 
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to