> (that's
> why hot reloading is a good bad idea and can break after a restart
> even if "F5" tests were green ;)).
Oh yeah, I've got obscure errors after hot reloading hundreds of times.
Most of them were JNDI-related, by the way ;)
> Hmm, maybe not. JSP support injections and are generated at runtime
> so
> it needs some glue code but reusing the same principle would work and
> this API even if internal is more stable (see InstanceManager of
> tomcat).
That's it - JSPs came to my mind even before the idea of generating
annotated classes. Needless to say I did some testing...
=============================== 8< ===================================
<%@page import="javax.enterprise.inject.spi.BeanManager"%>
<%@page import="javax.inject.Inject"%>
<%@page import="java.util.logging.Logger"%>
<%@page import="javax.transaction.UserTransaction"%>
<%@page import="javax.annotation.Resource"%>
<%@page import="javax.annotation.PostConstruct"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%!
@Resource
private UserTransaction tx;
@Inject
private BeanManager bm;
private final static Logger LOG = Logger.getLogger("foo.jsp");
@PostConstruct
public void post() {
LOG.info("foo.jsp::post()");
LOG.info("tx = " + tx);
LOG.info("bm = " + bm);
}
%>
<%
request.setAttribute("tx", tx);
request.setAttribute("bm", bm);
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
tx = ${requestScope.tx}<br>
bm = ${requestScope.bm}<br>
</body>
</html>
=============================== 8< ===================================
The results were, errr, a bit disappointing.
TomEE 7.0.0-M3
==============
tx = null
bm = org.apache.webbeans.container.InjectableBeanManager@b4ecb2
@PostConstruct: invoked
WildFly 10.0.0
==============
tx = null
bm = null
@PostConstruct: not invoked
GlassFish/Payara 4.1.1
======================
bm = (had to remove BeanManager since JSP didn't compile)
tx = null
@PostConstruct: not invoked
Is it another blind-spot in the spec? or is it a bug? or am I doing it
totally wrong?
Dimitri