openwebbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felipe Pina <fop....@gmail.com>
Subject Re: Servlet 3.0 not injeting bean
Date Sat, 14 Jun 2014 14:33:24 GMT
Mark i used the TomEE, but i need to save memory, so when i customize the
normal tomcat with owb libs, i realized a little memory economy. I really
only need the injection.


1- My project is set with openwebbeans-tomcat7 module, but I wonder if it
is equivalent to configuration of the listener below in web.xml instead
server.xml file ? it makes no difference?

web.xml -> Can i setup this way ? This works too ?

  <!-- OpenWebbeans tomcat plugin    -->
  <listener>

<listener-class>org.apache.webbeans.web.tomcat.ContextLifecycleListener</listener-class>
  </listener>

or

setup.xml

  <Listener className="
org.apache.webbeans.web.tomcat.ContextLifecycleListener"/>

2- There is another configuration i need to do ?


2014-06-14 7:48 GMT-03:00 Mark Struberg <struberg@yahoo.de>:

> it should if you use our openwebbeans-tomcat7 module.
> Or if you use Apache TomEE which comes pre-packaged and perfectly setup
> with OpenWebBeans as CDI container. In this case you can also leverage
> multiple other cool EE features like JTA, etc. This is kind of a perfectly
> integrated setup of MyFaces and OpenWebBeans into tomcat7.
>  It comes with OpenJPA as well in case you need JPA. Of course you can
> optionally also use Hibernate and EclipseLink with TomEE as well.
>
> Might be easier for you than to setup all our internal container modules
> yourself. Of course you are welcome to do so and report back if you need
> more help.
>
> LieGrue,
> strub
>
>
>   On Saturday, 14 June 2014, 4:49, Felipe Pina <fop.net@gmail.com> wrote:
>
>
>
> Why cdi OWB injection do not works only by servlet url ?
>
>
> My java beans below.
>
>
> @WebServlet( urlPatterns = {"/tarifas"})
> public class Tarifas extends HttpServlet {
>  /**
>  *  Atributo '<code>serialVersionUID</code>' do tipo long
>  */
> private static final long serialVersionUID = 1L;
>
> @javax.inject.Inject
> private TarifaBean tarifaBean;  -> This injection do not works, when
> access by servlet url tarifas
>
> @Override
>  protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> try {
>
> tarifaBean.setSession(request.getSession());
>  request.setAttribute("valorTarifa", tarifaBean.getValorUnitario());
>  getServletContext().getRequestDispatcher("/WEB-INF/pages/tarifas.jsp").forward(request,
> response);
>  } catch (GrowUpException e) {
> throw new ServletException(e);
> // getServletContext().getRequestDispatcher("error.jsp").forward(request,
> response);
>  }
> }
>
> }
>
>
>
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> @javax.inject.Named(value="tarifaBean")
> @javax.enterprise.context.SessionScoped
> public class TarifaBean implements Serializable {
>  /**
>  *  Atributo '<code>serialVersionUID</code>' do tipo long
>  */
>  private static final long serialVersionUID = 1L;
>
> @javax.inject.Inject
>  private GrowUpFacadeAdapter facade;  -> This injection works fine, when
> access by jsf page.
>  private Double valorUnitario;
>
> public TarifaBean() {}
>
> /**
>  * @return the valorUnitario
>  * @throws GrowUpException
>  */
> public Double getValorUnitario() throws Exception {
> if (valorUnitario==null)
>  valorUnitario = buscarValorPedido();
> return valorUnitario;
> }
>
> /**
>  * @return
>  */
> private Double buscarValorPedido() throws Exception {
>  VariavelDTO var = (VariavelDTO) facade.executarComando(session,
> GCS.MAPA_VARIAVEL,
> GCS.BUSCAR_VALOR_UNITARIO);
>  if (!isCodigoValido(var))
> throw new IllegalArgumentException("Não foi possível encontrar o valor
> Unitário do pedido.");
>  return var.getValorAsDouble();
> }
>
>  }
>
>
>
>
> --
> Atenciosamente,
> Felipe Pina
>
>
>


-- 
Atenciosamente,
Felipe Pina

Mime
View raw message