Aha!!! So simple I was not seeing it... Thanks Antoine!!

Deven

On Mon, Jan 12, 2015 at 9:26 AM, Antoine Sabot-Durand <
[email protected]> wrote:

> Hi Deven,
>
> More a CDI user question than a Deltaspike ;)
>
> You need to provide an instance of your qualifier. As java doesn’t provide
> a way to create such an instance easily, CDI provides an AnnotationLiteral
> class to do so. As your qualifier doesn’t contain member you can create an
> anonymous class to do so :
>
> beanMgr.fireEvent(this.config, new AnnotationLiteral<AppConfig>(){});
>
> Antoine
>
>
>
>
> > Le 12 janv. 2015 à 14:45, Deven Phillips <[email protected]> a
> écrit :
> >
> > Next question... I have created a qualifier:
> >
> > import static java.lang.annotation.RetentionPolicy.*;
> > import static java.lang.annotation.ElementType.*;
> >
> > import java.lang.annotation.Retention;
> > import java.lang.annotation.Target;
> > import javax.inject.Qualifier;
> >
> > /**
> > * An annotation to allow for differentiation between
> > * differing instances of the Configuration bean
> > */
> > @Qualifier
> > @Retention(RUNTIME)
> > @Target({METHOD, FIELD, PARAMETER, TYPE})
> > public @interface AppConfig {
> > }
> >
> > And I want to use it with a fireEvent() call... Is there a good reference
> > of how to accomplish that?
> >
> > What I was thinking might work, but which does not:
> >
> > beanMgr.fireEvent(this.config, AppConfig);
> >
> > Thanks in advance!!
> >
> > Deven
> >
> > On Sun, Jan 11, 2015 at 1:46 AM, Deven Phillips <
> [email protected]>
> > wrote:
> >
> >> NVM! I figured out my problem... I forgot to add an empty "beans.xml"
> file
> >> to the META-INF directory!!!
> >>
> >> Doh!
> >>
> >> Deven
> >>
> >> On Sun, Jan 11, 2015 at 1:30 AM, Deven Phillips <
> [email protected]>
> >> wrote:
> >>
> >>> I have created a simple example to demonstrate the problem I am having:
> >>>
> >>> https://github.com/InfoSec812/deltaspike-observer-example
> >>>
> >>> Just clone the repo, and run:
> >>>
> >>>    mvn exec:java -Dexec:args="this can be anything"
> >>>
> >>> You will see some log output which shows that the "fireEvent" method
> was
> >>> called, but the event is never received.
> >>>
> >>> I hope that someone can help, as this is holding up my project.
> >>>
> >>> Thanks in advance!!
> >>>
> >>> Deven
> >>>
> >>> On Sun, Jan 11, 2015 at 12:21 AM, Deven Phillips <
> >>> [email protected]> wrote:
> >>>
> >>>> I'm trying to implement a suggestion from John Ament based this gist:
> >>>>
> >>>> https://gist.github.com/johnament/442e0aa78b7557535545
> >>>>
> >>>> My code looks something like:
> >>>>
> >>>>            // Initialize DeltaSpike Dependency Injection of JavaSE
> >>>>            // This will also cause some back-end setup to begin
> >>>>            LOG.debug("Starting CDI Container and Contexts");
> >>>>            CdiContainer cdiContainer =
> >>>> CdiContainerLoader.getCdiContainer();
> >>>>            cdiContainer.boot();
> >>>>            ContextControl ctxControl =
> cdiContainer.getContextControl();
> >>>>            ctxControl.startContexts();
> >>>>
> >>>>            // Create an ObjectFactory for the JaxRsApplication to be
> >>>> able
> >>>>            // to inject dependencies
> >>>>            CdiObjectFactory objFactory = new CdiObjectFactory();
> >>>>
> >>>>            // Send an event to DeltaSpike to load the config into
> >>>>            // the application scope
> >>>>            LOG.debug("Firing event to load configuration into
> >>>> Application scope");
> >>>>            try {
> >>>>                BeanManager bm =
> >>>> objFactory.getInstance(BeanManager.class);
> >>>>                bm.fireEvent(config);
> >>>>            } catch (InstantiateException ex) {
> >>>>                LOG.error("Error getting BeanManager from objFactory",
> >>>> ex);
> >>>>                throw new RuntimeException(ex);
> >>>>            }
> >>>>
> >>>> The problem is, the observer bean never sees the event. I can trace
> and
> >>>> step through and it never receives the event... Any thoughts on what
> I may
> >>>> be doing wrong?
> >>>>
> >>>> Thanks in advance!!
> >>>>
> >>>> Deven
> >>>>
> >>>
> >>>
> >>
>
>

Reply via email to