Supported styling.
https://github.com/rwz/SyntaxHighlighter/blob/master/demos/autoloader.html
I'm dedicated agile security architect/system architect/developer with specialty of open source framework.
In my previous blog about Java EE 6 Maven Dependency a wrote about the crippled javaee-api maven dependency in maven central.
That is finally fixed in EE 7.
<dependency>
<groupid>javax</groupid>
<artifactid>javaee-api</artifactid>
<version>7.0</version>
<scope>provided</scope>
</dependency>
See also Essential Maven POM For JavaEE 7
The EE 6 classes are available in maven central.
<dependency>
<groupid>javax</groupid>
<artifactid>javaee-api</artifactid>
<version>6.0</version>
<scope>provided</scope>
</dependency>
But when running unit test against them you receive the below error. Thats because they do not contain implementation classes, only api class.
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/persistence/LockModeType
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
So in practice, the dependecy is in real life unusable. Instead you must use api classes from specific vendors like JBoss.
<dependency>
<groupid>org.jboss.spec</groupid>
<artifactid>jboss-javaee-6.0</artifactid>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
Interceptor was in EE 5 introduced in EJB 3.0, see EJB3 Interceptors javax.ejb.AroundInvoke. In EE 6 that was taken out and made generic into Interceptors (JSR318), package javax.interceptor.*.
You can call Interceptor in EE 6 in two way:
Your custom Interceptor.
package se.magnuskkarlsson.example.interceptor;
import java.io.Serializable;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
import org.apache.log4j.Logger;
@Audit
@Interceptor
public class AuditInterceptor implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(AuditInterceptor.class);
@AroundInvoke
public Object intercept(InvocationContext ctx) throws Exception {
log.info("### Entering method: " + ctx.getMethod().getName()
+ " in class " + ctx.getMethod().getDeclaringClass().getName());
return ctx.proceed();
}
}
Interception in a POJO.
package se.magnuskkarlsson.example.interceptor;
import javax.interceptor.Interceptors;
public class DemoPOJO {
@Interceptors(AuditInterceptor.class)
public String sayHello() {
return "Hello POJO";
}
}
Interception in a Stateless Session Bean.
package se.magnuskkarlsson.example.interceptor;
import javax.ejb.Stateless;
import javax.interceptor.Interceptors;
@Stateless
public class DemoSLSB {
@Interceptors(AuditInterceptor.class)
public String sayHello() {
return "Hello SLSB";
}
}
beans.xml located for war in WEB-INF/.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
</beans>
To use the Interceptor you must let weld create the intercepted class, otherwise will weld never knew about the interceptor and hence will the interceptor never work.
Example usage from a Servlet.
package se.magnuskkarlsson.example.interceptor;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/audit")
public class DemoServlet extends javax.servlet.http.HttpServlet {
private static final long serialVersionUID = 1L;
@Inject
private DemoPOJO pojo;
@EJB
private DemoSLSB slsb;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
resp.setCharacterEncoding("UTF-8");
resp.setContentType("text/html; charset=UTF-8");
PrintWriter out = null;
try {
out = resp.getWriter();
out.println("<html><body>");
out.println("<h1>" + pojo.sayHello() + "</h1>");
out.println("<h1>" + slsb.sayHello() + "</h1>");
out.println("</html></html>");
} finally {
if (out != null) {
out.close();
}
}
}
}
You cannot use Interceptor directly in servlets, see https://java.net/projects/servlet-spec/lists/jsr340-experts/archive/2012-02/message/0.
To list all JNDI entries with JBoss CLI.
First start JBoss CLI.
$ ./jboss-cli.sh --connect
Then execute.
[standalone@localhost:9999 /] /subsystem=naming:jndi-view
When deploying a snapshot release or if you by some other reason want to generate sources or javadoc jar, you could always configure maven-source-plugin and maven-javadoc-plugin and hook them in maven life cycle.
But that is not necessary in maven uber pom is that already defined for release. You can reuse that by adding -DperformRelease=true
mvn -DperformRelease=true [goals]
Different example of usage:
Local build with sources and javadoc jar generation
mvn -DperformRelease=true clean install
Deploy target. Use only with snapshot version. Then deploy means snapshot publishing to defined snapshot repository.
mvn -DperformRelease=true clean install deploy
The capabilities and what is supported out of the box in EE, is increasing from next version to next version. The drive behind the new feature are:
EE 4 - JBoss AS 4.X, JBoss EAP 4 *
EE 5 - JBoss AS 5.1, JBoss EAP 5 *
EE 6 - JBoss AS 7.1, JBoss EAP 6 *
EE 7 - Wildfly 8.x, JBoss EAP 7 * (release date Q2-Q3? 2015)
*) The EAP is forked from AS/Wildfly version left to it, but with much more quality (tested, patched, security compliance testing, security patched), documentation and with support.