[weld-dev] How to use Weld servlet Env with Grizzly?

Martin Kouba mkouba at redhat.com
Mon May 21 08:23:30 EDT 2018


Hi Alex,

do you have some publicly available project so that we can discuss a 
real code?

In general, if you want to integrate Weld servlet with a custom servlet 
container:

1. Implement org.jboss.weld.environment.servlet.Container, e.g. 
GrizzlyContainer
   - Container#touch() should return true if a specific container is 
detected
  - Container#initialize() and Container#destroy() can be used to 
init/cleanup the container
  - note that ContainerContext#getManager() returns a BeanManager which 
could be used later, e.g. for dependency injection; you can also obtain 
a BeanManager from the servlet context - see for example [1]

2. Implement a container specific "injection support"
- each servlet container should provide its own SPI - you should 
implement this SPI so that injection into servlets, listeners and 
filters is supported; see for example [2] how undertow support is 
implemented

3. There is no need to "connect" EnhancedListener in any way. It should 
be registeded automatically. However, if you're trying to run an 
embedded servlet container you will need to register 
org.jboss.weld.environment.servlet.Listener manually.

Martin


[1]
https://github.com/weld/core/blob/master/environments/servlet/core/src/main/java/org/jboss/weld/environment/undertow/WeldInstanceFactory.java#L56

[2]
https://github.com/weld/core/blob/master/environments/servlet/core/src/main/java/org/jboss/weld/environment/undertow/WeldServletExtension.java

Dne 18.5.2018 v 19:52 Alex Sviridov napsal(a):
> Hi all
> 
> Could anyone explain how to connect WebappContext that implements 
> ServletContext, to
> Weld servlet env? I've read the code, but still can't understand how to 
> connect SomeContainer,
> that implements servlet.Container, EnhancedListener and Grizzly 
> WebappContext? Could anyone
> describe main principles how to do it? I would be very thankful.
> 
> -- 
> Best regards, Alex Sviridov
> 
> 
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
> 

-- 
Martin Kouba
Senior Software Engineer
Red Hat, Czech Republic


More information about the weld-dev mailing list