Hi all guys,
thanks a lot for your replies, very appreciated :) So, I'll try to
show my intentions to better explain why I tried the ASM way: I'm
maintaining a Guice extension called Rocoto[1] (already mentioned in
the 3rd parties extensions on the Guice Wiki) that allows user binding
configuration files and that's able to resolve placeholder in the
Apache Ant style.
The way Rocoto resolves the variables[2] is the one Fred was
suggesting, I mean using the Injector reference into the providers for
values that contain placeholder; for example, given the property
JDBC.url=jdbc:mysql://${JDBC.host|localhost}:${JDBC.port}/${JDBC.schema}
it will be translated to
bind(Key.get(String.class,
Names.named("JDBC.url"))).toProvider(new
PropertiesResolverProvider("jdbc:mysql://${JDBC.host|localhost}:${JDBC.port}/${JDBC.schema}"));
and the ${JDBC.host}, ${JDBC.port} and ${JDBC.schema} placeholder will
be resolved via the Injector instance, and the resolution happens when
the PropertiesResolverProvider#get method is invoked.
So, the way to improve the performances, I thought it is a good idea
resolving and injecting directly all the dynamic dependencies during
the injection time and not request the instance invoking
injector.getInstance(Key.get(String.class, Names.named("${JDBC.host}")));
injector.getInstance(Key.get(String.class, Names.named("${JDBC.port}")));
injector.getInstance(Key.get(String.class, Names.named("${JDBC.schema}")));
Do you have any suggestion do achieve this objective? Moreover in the
feature I'd like to add the feature Guice resolves directly
@Named("jdbc:mysql://${JDBC.host|localhost}:${JDBC.port}/${JDBC.schema}"),
but that's another history...
Many thanks in advance, have a nice day!!!
Simo
[1] https://github.com/99soft/Rocoto
[2]
https://github.com/99soft/Rocoto/tree/master/src/main/java/org/nnsoft/guice/rocoto/configuration/resolver/
http://people.apache.org/~simonetripodi/
http://www.99soft.org/
On Tue, Nov 30, 2010 at 6:54 PM, Sam Berlin <[email protected]> wrote:
> I don't think anything relating to dependencies or injection points is going
> to solve your problem. Ultimately what you need is for the requirement in
> LineNumbersCache to be relaxed, so that code Guice is injecting doesn't
> require having line numbers available.
> FWIW, you can take a look at the patch at
> http://code.google.com/p/google-guice/issues/detail?id=366 . That exposes
> some new API methods around InjectiongPoint/Dependency. i doubt it will
> resolve your problem -- but if it does, it's another point in favor of the
> API changes.
>
> sam
>
> On Tue, Nov 30, 2010 at 12:02 PM, Simone Tripodi <[email protected]>
> wrote:
>>
>> Hi all guys,
>> after tried creating classes with ASM that require dependency
>> injection by Guice, without success, due to Issue 574[1], I' d like to
>> know if is there a way to simulate injection points for components
>> defined at runtime.
>>
>> I started taking a look to
>> `com.google.inject.spi.ProviderWithDependencies` that requires
>> `Set<com.google.inject.spi.Dependency<?>> getDependencies()` method be
>> implemented, and the Set can be obtained by invoking
>>
>> `com.google.inject.spi.Dependency.forInjectionPoints(Set<com.google.inject.spi.InjectionPoint>
>> injectionPoints)`.
>>
>> My trouble is that `com.google.inject.spi.InjectionPoint` instances
>> can be build only via `com.google.inject.spi.InjectionPoint` static
>> methods, that look for Guice's annotations. Moreover
>> `com.google.inject.spi.InjectionPoint` is final so I can't extend it
>> to cheat Guice invoking my custom methods. That's the point I'm
>> blocked :P
>>
>> Any thought/suggestion? Many thanks in advance!
>> Simo
>>
>> [1] http://code.google.com/p/google-guice/issues/detail?id=574
>>
>> http://people.apache.org/~simonetripodi/
>> http://www.99soft.org/
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "google-guice" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-guice?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.