Thanks, I've kludged something together with that info. I found that
Errai's startup happens after all my Seam components are
initialized/injected, because the Errai servlet loads after
SeamListener. So I'm just stuffing the MessageBus into a static field
for now. Ugly, I know, but getting started with Errai is taking about a
week longer than I'd hoped (for various reasons).
On 02/02/10 03:04, Heiko Braun wrote:
When running on JBossAS you can use
the org.jboss.util.naming.NonSerializableFactory
to bind the bus to JNDI:
private void rebind() throws NamingException {
InitialContext rootCtx = new InitialContext();
Name fullName = <Jndi Name>;
NonSerializableFactory.rebind(fullName, <ErraiBus>, true);
}
IIRC you use a Seam @Factory declaration [1] that's doing the lookup,
or use the seam components.xml to declare it externally.
[1]
http://docs.jboss.org/seam/2.1.2/reference/en-US/html/concepts.html#d0e4345
/Heiko
On Feb 1, 2010, at 5:36 PM, Mike Brock wrote:
> Well, we were always intending to support Seam as a container.
>
> We have an interface called ErraiConfigExtension which exposes the
> bootstrap process. You can use it to grab access to an ErraiBus
> instance and, in turn, bootstrap another container:
>
> /**
> * Create a config extension class so we can do things like setup the
> default tables
> * when the application is deployed, etc.
> */
> @ExtensionComponent
> public class AppConfigurator implements ErraiConfigExtension {
>
> private MessageBus bus;
>
> @Inject
> public AppConfigurator(MessageBus bus) {
> this.bus = bus;
> }
>
> public void configure(Map<Class, Provider> bindings, Map<String,
> Provider> resourceProviders) {
> // provide extension points here
> }
> }
>
> The configure() method is called when the component is auto-discovered
> in the class path. So you could, in theory, simply expose the Errai
> container to Seam or JNDI, etc.
>
> Mike.
>
> On 2010-02-01, at 3:19 AM, Sean Flanigan wrote:
>
>>
>> How can I obtain a reference to the MessageBus inside my Seam web
>> application on the server side?
>>
>> I see that the ServerMessageBusImpl is being injected by Guice in
>> AbstractErraiServlet, but the injector instance seems to be private. So
>> even if I use Guice myself, it will be a different injector, and hence a
>> different singleton scope, right?
>>
>> It looks like all the ErraiBus examples have server classes annotated
>> with @Service, and constructors which @Inject the MessageBus. I'm not
>> sure if I can do exactly that. For the moment, I would like to
>> construct the objects myself. If I could obtain the right Guice
>> injector, I could call Injector.injectMembers on the objects which need
>> the MessageBus.
>>
>> Hmm. I'm not going to have to re-architect everything, am I? (BTW,
>> unlike the examples, I'm not implementing MessageCallback on the server,
>> I just want to send messages on the same bus that my clients are
>> polling.)
>>
>> So is there some way I can obtain a reference to the Injector or the
>> ErraiService from "outside"? Or will I have to annotate a class with
>> @Service? It looks to me as if ErraiServiceConfiguratorImpl wants to
>> construct the object itself (via Guice), which probably won't work for
>> Seam components...
>>
>> Am I going about this all wrong, or what?
>>
>> Thanks
>>
>> Sean.
>>
>> --
>> Sean Flanigan
>>
>> Senior Software Engineer
>> Engineering - Internationalisation
>> Red Hat
>>
>> _______________________________________________
>> errai-users mailing list
>> errai-users(a)lists.jboss.org <mailto:errai-users@lists.jboss.org>
>>
https://lists.jboss.org/mailman/listinfo/errai-users
>
> _______________________________________________
> errai-users mailing list
> errai-users(a)lists.jboss.org <mailto:errai-users@lists.jboss.org>
>
https://lists.jboss.org/mailman/listinfo/errai-users
--
Sean Flanigan
Senior Software Engineer
Engineering - Internationalisation
Red Hat