Hi Raffaele

If you have a chance to build the Guice Injector yourself and
defining which Definitions should be used you can try to intercept
method calls. This could be a possibility.

Cheers Noc

Am 16.04.2012 13:32, schrieb Raffaele Castagno:
> Sorry for the half baked post.
>
> Disclaimer: I'm using a third-party framework, so I don't have
> control on the 
> application startup, I can only do the guice init on-demand inside
> the services
> I create.
>
> Also, I'm new to DI in general and Guice in particular.
>
> I have to introduce a customization mechanism in the app I'm
> working on.
> Basically, I want to be able to do something like this:
>
> public class MyServerClass implements Invokable 
> // Invokable is a third-party interface used to tell the server
> that this class contains services
> {
>   public static Object myServiceMethod () 
>   {
>     if(#MyCustomerServiceClass.myServiceMethod# is available)
>     {
>       return MyCustomerServiceClass.myServiceMethod();
>     }
>     else
>     {
>       return MyCoreServiceClass.myServiceMethod();
>     }
>   }
> }
>
> class MyCoreServerClass
> {
>   public static Object myServiceMethod () 
>   {
>     return "A";
>   }
> }
>
> class MyCustomerServiceClass extends MyCoreServerClass
> {
>   public static Object myServiceMethod () 
>   {
>     return "B";
>   }
> }
>
> My requirement is that I should be able to introduce
> MyCustomerServiceClass without
> changing nor recompile MyServerClass MyCoreServerClass.
>
> That is, I have my app with 
> MyBasicSetOfClasses.jar
> and everything works fine, than I introduce
> MyCustomerSpecificClasses.jar
> eventually touch some external configuration file, and I have the
> cusomized myServiceMethod() 
> responding to calls to "com.mycompany.MyServerClass.myServiceMethod".
>
> Is it possible to inject dependencies this way, with the new
> "configuration" inside 
> an additional JAR in the classpath or in an external configuration
> file?
>
> Thanks in advance, and sorry for the double post, and the
> convoluted and dumb request.
>
> Raffaele C.
> -- 
> You received this message because you are subscribed to the Google
> Groups "google-guice" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-guice/-/RpSNdNBPcVMJ.
> 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.

Reply via email to