mine or the other guys?  Here is mine...

I have EJB like @Entity tags in a NoSQL platform....the tags for now
are @NoSqlEntity as we are using hibernate too, so you can imaging
many beans being annotated with @NoSQLEntity.  Now, since this is
noSQL, we have a grid of nodes and while triggers were bad in RDBMS,
they seem to be wonderful in noSQL environments sooooo every class
that we have a trigger to, we add a special annotation

@TriggerImpl(TriggerForAccount.class)
private class Account {
}

Then, in my platform, when scanning entities, I find these
triggers...let's pretend we have 20 triggers for now(but more get
added as developers program and we automatically invoke them as a
platform sooooo when a a trigger goes off, we get the ClassMetaData
object(just like hibernate since we stored all that on startup and
scanning for annotations).  From the ClassMetaData, we have a Class<?
extends Trigger> myTrigger variable and that is what we feed into the
provider so that we generate 20 different types of triggers in the
noSQL data grid.

make sense?  I am not sure it is the best way, but I am happy that I
have gotten through it and have something working.  I would love to
make it better if you have ideas.  In particular, I didn't like having
to give it the injector, but it seems to work.

I did see another similar blog here on similar subject....(solved a
different way by changing Guice code which I was trying to avoid)....

http://eng.wealthfront.com/2010/05/just-in-time-providers-for-guice.html

later,
Dean



On Feb 18, 1:38 pm, Bob Lee <[email protected]> wrote:
> I don't understand your problem well enough. This doesn't sound like an
> advisable approach though. Can you explain the problem at a higher level?
>
> Bob
>
> On Fri, Feb 18, 2011 at 2:00 PM, deanhiller <[email protected]>wrote:
>
> > In my Class, the client has this code
>
> > well, you can get rid of the "static"s I realized later.  and then the
> > client does this to ask for the one it needs...
>
> > @Inject
> > private ListenerProvider listenerProvider;
>
> > and the client code then is...
>
> > listenerProvider.setType(classFromSomeAnnotation);
> > OurCacheListener listener = listenerProvider.get(); //returns an
> > object of type classFromSomeAnnotation
>
> > later,
> > Dean
>
> > On Feb 18, 11:39 am, Bob Lee <[email protected]> wrote:
> > > On Fri, Feb 18, 2011 at 8:07 AM, deanhiller <[email protected]
> > >wrote:
>
> > > > Last night, I tried doing creating a CustomProvider BUT then Guice is
> > > > not injecting my CustomProvider with fields that have @Inject in my
> > > > objects that get created(I was hoping Guice intercepted them and
> > > > created them on-demand).  Is there a way to make this work....
>
> > > How do you choose which implementation to ask for? I'd probably use a
> > > binding annotation instead of setting a thread local.
>
> > > To make your code work:
>
> > > public class ListenerProvider implements Provider<OurCacheListener> {
>
> > >   private static ThreadLocal<Class<?>> clazzThreadLocal =
> > >         new ThreadLocal<Class<?>>();
>
> > >   @Inject private Injector injector;
>
> > >   @Override
> > >   public OurCacheListener get() {
> > > *     return (OurCacheListener)
> > > injector.getInstance(clazzThreadLocal.get());*
> > >   }
>
> > >   public static void setType(Class<?> clazz2) {
> > >      clazzThreadLocal.set(clazz2);
> > >   }
>
> > > }
>
> > --
> > 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.

Reply via email to