0

I newbie in java i don't know of all possibilites. I want to know can i implement something like this:

class DIConfig {
   // create at start of application (integration with javaee container)
   // load configurable files and stores all configuration
}

class Foo {
    // use DIConfig to inject value stored in DIConfig to String url
    @Config("general.url")
    String url;

    public void bar() {
        // same thing with local variable
        @Config("export.maxRows")
        int maxRows;
    }
}

It's available? How can i do it? My trouble - i don't understand how to using annotation execute some code and stores result in annotaed variable.


Seems it not possible. All DI frameworks use something like binder - i've many classes that using configuration property and create all of this classes via binder or something like this - impossible. I search mechanism that don't use any binders. Somethinh like interceptors (AOP) but initialize variable instead wrap method invoke.

Torsten
  • 21,726
  • 5
  • 24
  • 31
  • 1
    Probably what you want can be reached using [Spring][1] or [Guice][2]. [1]: http://stackoverflow.com/questions/317687/how-can-i-inject-a-property-value-into-a-spring-bean-which-was-configured-using [2]: http://stackoverflow.com/questions/9772557/using-google-guice-to-to-inject-java-properties – aim Aug 03 '13 at 11:17
  • Thanks, seems it's not possible by my requirements. – Torsten Aug 03 '13 at 15:56

0 Answers0