To provide your own conversion implementation of a JAXB property, annotate the property in your JAXB class with javax.xml.bind.annotation.adapters.@XmlJavaTypeAdapter:
@XmlJavaTypeAdapter(MyAdapter.class)
public
void setFrom(LocalDate
from)
{
this.from = from;
}
Then write your Adapter marshalling your LocalDate attribute to an XML value String and unmarshalling it:
public
class MyDateAdapter
extends XmlAdapter<String,
LocalDate>
{
public
LocalDate
unmarshal(String
myString)
throws Exception
{
return LocalDate.parse(myString);
}
public
String marshal(LocalDate
myDate)
throws Exception
{
return myDate.toString();
}
}
31 August 2018
JAXB custom conversion using @XmlJavaTypeAdapter
30 August 2018
Glassfish console log timestamps
By default glassfish does not add timestamps to console logging messages and that allways leaves me wondering wether I'm looking at an old message or a new one.
To add timestamps edit $GLASSFISH_INSTALL/glassfish/domains/domain1/config/logging.properties
Replace domain1 with the domain your domainin the above, if you are not using the default domain.
change:
java.util.logging.ConsoleHandler.formatter=com.sun.enterprise.server.logging.UniformLogFormatter
to:
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
The default format is fine for me, but you can customize the format using:
java.util.logging.SimpleFormatter.format="your %format string"
The javadoc contains some format string examples.
Then (re)start the server.
23 August 2018
Java EE component versions overview (updated)
The table below lists the components in latest versions of the Java Enterprise Edition.
Many of the Java EE projects live on github.
After Java EE8, Java EE is moving to the EE4J project (Eclipse Enterprise For Java) aka Jakarta.
- I put the most important changes in red.
- Components with a [version number] between brackets are proposed for removal in a future release.
- An x indicates a technology is removed from the specification
- JSR's are shown as hyperlinked numbers.
- SE indicates that an API was moved to the standard edition
- eventually followed with the version number
- Java SE version history is in a separate post
- These API's will be removed from Java SE again with Java 11
- Web technologies are in a separate post
- EJB history is in a separate post
- I added some application servers at the bottom of the table.
Technologies | 151 J2EE 1.4 2003 |
244 Java EE5 2006 | 316 Java EE6 2009 | 342 Java EE7 4/2013 | 366 Java EE8 |
Java SE | 59 1.4 | 176 5 | 270 6 | 336 7 | 337 8 |
EJB | 153 2.1 | 220 3.0 | 318 3.1 | 345 3.2 | |
Servlet/JSP | 2.4 | 2.5 | 3.0 | 3.1 | 4.0 |
EE Management | 77 1.0 | ||||
JMS | 914 1.1 | 343 2.0 | 368 2.1 | ||
JTA 907 | 1.0 | 1.1 | 1.2 | ||
JavaMail 919 | 1.3 | 1.4 | 1.5 | 1.6 | |
Connector (JCA) | 112 1.5 | 1.5 | 322 1.6 | 1.7 | |
Java Activation Framework (JAF) 925 | 1.0 | 1.1 | SE:1.1.1 | ||
Web Services 109 | 1.1 | 1.2 | 1.3 | 1.4 | |
Web Services Metadata 181 | 2.0 | SE | SE:2.1 | ||
JAX-WS (SOAP) | 101 JAX-RPC 1.1 | 224 2.0 | SE:2.0 | SE:2.2 | |
JAX-RS (REST) | 311 1.1 | 339 2.0 | 370 2.1 | ||
JAXB 222 | 2.0 | SE:2.2 | |||
JSON-P | 353 1.0 | 3741.1 | |||
JSON-B 367 | 1.0 | ||||
JAXR (UDDI Registry) | 1.0 | [1.0] | x | ||
SOAP w attachments (SAAJ) 67 | 1.2 | 1.3 | SE | ||
StAX 173 | 1.0 | SE | |||
JMX | 1.2 | SE | SE | ||
container authorisation (JACC) 115 | 1.0 | 1.1 | 1.4 | 1.5 | |
container authentication (JASPIC) 196 | 1.0 | 1.1 | |||
Security 375 | 1.0 | ||||
Common annotations 250 | 1.0 | 1.1 | 1.2 | 1.3 | |
Java Persistence (JPA) | 1.0 | 317 2.0 | 338 2.1 | 2.2 | |
Bean Validation | 303 1.0 | 349 1.1 | 380 2.0 | ||
Managed Beans | 1.0 | ||||
Interceptors | 1.0 | 1.1 | 1.2 | ||
CDI for Java EE | 299 1.0 | 346 1.1 | 365 2.0 | ||
DI for Java 330 | 1.0 | ||||
Concurrency utilities 236 | 1.0 | ||||
State management 350 | 1.0 | ||||
Batch 352 | 1.0 | 1.1 | |||
Servers | |||||
Sun JSAS | 8 | 9.1 | |||
Glassfish | 2 | 3 (12/09) | 4 (5/13) | 5 (9/17) | |
JBoss / WildFly | 4 | 5 | 7 (7/11) | 8 (2/14) | 12 (2/18) |
IBM Websphere | 6 | 7 | 8 (6/11) | 9 (10/17) | |
Oracle Weblogic | 9 | 10 | 12.1.1 (12/11) | 12.2.1 (11/15) | |
Apache Geronimo | 1 | 2 | 3 (7/12) | - | |
Apache Tommee+ | 1.5 (9/12) | 7 (3/16) |
- J2EE 1.3(2001) introduced
- Message Driven Beans
- Local interfaces
- Profiles are a subset of the spec.
- Java EE Web profile (only profile currently defined)
- contents
- java SE
- web technologies, JTA, common annotations, JPA, validation, managed beans, interceptors, CDI, DI
- EJB Lite
- Stateless, Stateful, and Singleton session beans
- asynchronous session beans (EJB 3.2)
- only local EJB interfaces or no interfaces
- interceptors
- security
- transactions
- non persistent timer only (EJB 3.2)
- No Message Driven beans and remote invocation.
- JAX-RS (Java EE7)
- implemented by
- Resin 4
- Apache TomEE
20 August 2018
19 August 2018
Securely opening tabs to other sites from your webpage
You can use a link on your webpage to open a page from another site in another tab, using
<a ref="https://othersite/otherpage.html" target="_blank"> to other page </a>Your browser typically opens the other page in a new tab, but this page retains a relation with your webpage and can do some priviliged actions like redirecting the tab of your webpage to another URL.
To prevent this, break the opener and referer links the foreign page has to your webpage by using
<a ref="https://othersite/otherpage.html" target="_blank" rel ="noopener noreferer"> to other page </a>more...