Thursday Sep 26, 2013

Last chance to see the great Java EE demos presented at the Java EE 7 booth at this year's JavaOne!

Hi,
don't miss the last hours chance to review the great Java EE 7 features presented at EE7 booth at JavaOne demogrounds!

Thursday Mar 01, 2012

Metro 2.2, JAXB 2.2.5, JAX-WS 2.2.6 Released!

I'm happy to announce we released Metro 2.2, including the JAXB 2.2.5 and JAX-WS 2.2.6 releases:
Metro: http://metro.java.net/2.2/
JAX-WS: http://jax-ws.java.net/2.2.6/
JAXB: http://jaxb.java.net/2.2.5/


The Metro 2.2 is aligned and integrated with GlassFish 3.1.2 release. Some feature highlights:


  • large number of bugfixes going into all codelines

  • including better alignment with Weblogic stack in JAX-WS area

  • both JAXB and JAX-WS apt tool usage (long time deprecated in JDK) has been replaced with JSR 269 Pluggable Annotation Processing API allowing JDK8 integration and removal of com.sun.mirror implementation from JDK

  • new Modular Databinding layer has been added to JAX-WS and exposed in Metro as well, which allows users to use e.g. Moxy JAXB implementation instead of the default JAXB RI for web service invocations

  • the JAX-WS Maven plugins have been updated to allow working with latest JAX-WS releases and enhanced with lots of new capabilities

  • documentation for all 3 components has been updated to docbook format which allowed the release documentation be present also in single HTML view and PDF formats

Monday Feb 13, 2012

Slides from my Java EE Web Services talk at Java Day Russia, 2012, Sankt Petersburg

Hi, last week I gave "Java EE Web Services" talk at Java Day in Sankt Petersburg in Russia. In the audience there was about 150-200 people. I talked about both SOAP and REST, describing the styles and JavaEE offerings for each of them, specifically talking about the reference implementations covered by projects Metro and Jersey. Unfortunately even though this was my very first stay in Russia, I did not have time to do any sightseeings so maybe next time ;O). Anyway it was very nice talking to the interested crowd.
Here are the slides: Java EE Web Services (PDF).

Tuesday Oct 11, 2011

Slides from JavaOne BOF

Slides from my JavaOne BOF: "Best Practices for XML/Schema Databinding with JAXB"

[Read More]

Thursday Jun 02, 2011

JavaEE / GlassFish at JUG Ostrava

Recently I gave JavaEE6/7 & GlassFish talk and led a JavaEE workshop afterwards at Ostrava JUG event. The attendance was around 50-60 people and the discussion/workshop afterwards was very valuable and I really enjoyed talking to such an open crowd. Several pictures from the organizers (Ondrej Kvasnovsky and Jan Pfeffer) are below and more info can be found here:

http://jug-ostrava.blogspot.com/2011/05/javaee-6-glassfish-novinky-budoucnost.html



Wednesday Mar 23, 2011

This blog will be migrated

Just a short migration note ... this blog will be migrated to blogs.oracle.com in a month or two.

Wednesday Nov 19, 2008

Handling extended mixed content in JAXB

Recently an issue came up to handle extended mixed content better with JAXB.

Just to clarify in the beginning, my opinion is that when somebody is designing a schema which is supposed to be machine processed (not something for some kind of UI rendering), it is a good decision to avoid use of mixed content, especially when designing a large schema with a lot of type extensions. Mapping that kind of schema to any binding framework is usually complex and leads to complications and slowdown of development. JAXB has never been designed to handle these cases in a convenient way - it is a Java <-> XML mapping framework, and it's not possible to represent this kind of content in a hierarchy of Java objects.

General recommendation for JAXB, if you come up to a corner case is to use customizations. If none of the many customizations help, you shall use the DOM customization (https://jaxb.dev.java.net/guide/Avoid_strong_databinding.html#Mapping_to_DOM) which is able to handle 100% schema structures, like this:


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0">
<xs:element>
<xs:complexType>
<xs:sequence>
<xs:any maxOccurs="unbounded" processContents="skip">
<xs:annotation><xs:appinfo>
<jaxb:dom/>
</xs:appinfo></xs:annotation>
</xs:any>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

With this customization, the underlying contents are stored in DOM tree, and thus you get unlimited capabilities to modify/access the tree structure. You loose the convenient JAXB mapping approach of course.

As I mentioned in the beginning, one corner case is handling multiple extensions with mixed content.

Usual way how JAXB handles this, is to generate 'content' property as List where ? is the common denominator of the potential content. Then, using @XmlElementRefs and @XmlElementRef annotations, it specifies which elements are expected in the tree.


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MyBaseType", propOrder = {
"content"
})
@XmlSeeAlso({
MyExtendedType.class
})
public class MyBaseType {

@XmlElementRefs({
@XmlElementRef(name = "element2", type = JAXBElement.class),
@XmlElementRef(name = "element1", type = JAXBElement.class)
})
@XmlMixed
protected List content;

public List getContent() {
if (content == null) {
content = new ArrayList();
}
return this.content;
}
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MyExtendedType")
public class MyExtendedType extends MyBaseType {
}

Since we are talking about mixed content, 'String' is one of the elements, so in the end you end up either with List<Object>, List<Serializable> or List<String>. Not very convenient, but still you can work with it in usual JAXB way.

However, the bigger problem comes when you do need to use a schema like this:


<xs:complexType name="BaseTypeWithElementsExtended" mixed="true">
<xs:sequence>
<xs:element name="element1" type="xs:string" />
<xs:element name="element2" type="xs:string" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="ExtendedTypeWithElements" mixed="true">
<xs:complexContent mixed="true">
<xs:extension base="BaseTypeWithElementsExtended">
<xs:sequence>
<xs:element name="element3" type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="ExtendedType2" mixed="true">
<xs:complexContent mixed="true">
<xs:extension base="ExtendedTypeWithElements">
<xs:sequence>
<xs:element name="element4" type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<xs:element name="MultiExtendedTypeWithElements" type="ExtendedType2"/>

The main difference is that there are multiple extensions (all of them mixed of course). The usual JAXB approach doesn't work here, because JAXB generates this kind of content:


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ExtendedType2")
public class ExtendedType2 extends ExtendedTypeWithElements {
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ExtendedTypeWithElements")
@XmlSeeAlso({
RestrictedType2 .class,
ExtendedType2 .class
})
public class ExtendedTypeWithElements extends BaseTypeWithElementsExtended {
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BaseTypeWithElementsExtended", propOrder = {
"content"
})
@XmlSeeAlso({
RestrictedTypeWithElements.class,
ExtendedTypeWithElements.class
})
public class BaseTypeWithElementsExtended {
@XmlElementRefs({
@XmlElementRef(name = "element1", type = JAXBElement.class),
@XmlElementRef(name = "element2", type = JAXBElement.class)
})
@XmlMixed
protected List content;

public List getContent() {
if (content == null) {
content = new ArrayList();
}
return this.content;
}
}

Hmm, now how do you represent element3 or element4?

You've got the "content" property, which is supposed to hold the mixed content, but at the same time, you've got extensions which introduce another type of content. With Java, you can't put another "content" variable with another set of annotations to the subclasses. So, I decided to add one more global customization for those who cannot modify their schemas and need to handle this case directly through jaxb. The customization goes like this:


<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
xmlns:xjc= "http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc">
<jaxb:globalBindings generateMixedExtensions="true"/>
</jaxb:bindings>

When this customization is present (either inline or externally), the behaviour of JAXB changes slightly, and the code it generates for schema above looks like this:


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ExtendedType2")
public class ExtendedType2 extends ExtendedTypeWithElements {

@XmlElementRefs({
@XmlElementRef(name = "element1", type = JAXBElement.class),
@XmlElementRef(name = "element2", type = JAXBElement.class),
@XmlElementRef(name = "element3", type = JAXBElement.class),
@XmlElementRef(name = "element4", type = JAXBElement.class)
})
@XmlMixed
@OverrideAnnotationOf
protected List contentOverrideForExtendedType2;
}

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ExtendedTypeWithElements")
@XmlSeeAlso({
RestrictedType2 .class,
ExtendedType2 .class
})
public class ExtendedTypeWithElements extends BaseTypeWithElementsExtended {

@XmlElementRefs({
@XmlElementRef(name = "element1", type = JAXBElement.class),
@XmlElementRef(name = "element2", type = JAXBElement.class),
@XmlElementRef(name = "element3", type = JAXBElement.class)
})
@XmlMixed
@OverrideAnnotationOf
protected List contentOverrideForExtendedTypeWithElements;
}

public class BaseTypeWithElementsExtended {
@XmlElementRefs({
@XmlElementRef(name = "element1", type = JAXBElement.class),
@XmlElementRef(name = "element2", type = JAXBElement.class)
})
@XmlMixed
protected List content;

public List getContent() {
if (content == null) {
content = new ArrayList();
}
return this.content;
}
}

There's a proprietary annotation to allow overriding the content property with a different content. When JAXB runtime finds the dummy content property, it modifies it's internal representation of the original 'content' property to allow a larger set of elements, as defined in the annotations.

The code is in current JAXB nightly builds, so give it a try and we can improve/modify it before next release based on your comments. Either send them to JAXB forums, or directly to me.

Tuesday Jul 15, 2008

Grails and web service development with Metro - little update

I've seen several comments where people had issues using the Metro plugin for Grails framework. I fixed the problems and updated installation instructions a bit, so if you use the latest plugin release (1.0.1), you shall be fine. I also updated the plugin to comply with Grails 1.0.3. Check it out at:
https://jax-ws-commons.dev.java.net/grails/

Tuesday Jun 24, 2008

parse-nb equivalent to parse-ipr and parse-dot-classpath

While working on some parts of JAXB, and using NetBeans myself for development, I came across the two projects parse-ipr and parse-dot-classpath, which are useful when you need to invoke your project files from command line without an IDE. I developed a NetBeans equivalent of those: parse-nb. What it does?

Basically, it allows you to parse your NetBeans Java project files (nbproject/project.xml, project.properties) and give you a java classpath-way formatted string as an output.

So if you run it on JAXB2.1 project (which I just updated from freeform to regular NB J2SE project), you get a scary output like this:

I believe you would never want to write or maintain this by hand, and it is still useful to have it to be able to run e.g. an individual tests manually from command line, so this way you can write your own scripts to set whatever classpath you wish to set. Read more at parse-nb website, and download from the project's download area.

I do run it as a part of bash setup, so that I can then always start debugging tests like this:

java $DBG $JB21 TestCaseRunner .

And here's a usage info:

It of course lacks in many areas, so improvements are always welcome! I'd also appreciate if the NetBeans library system gets much simpler, as it's very hard to work with currently.

Thursday Jun 19, 2008

Mr. Groovy at Prague Sun site

Yesterday (Wed18th), thanks to the ServerSide symposium happening in Prague, we had a chance to chat with Guillaume Laforge, the Groovy guy.

Guillaume visited the Prague's Sun site, where he gave a presentation on Groovy success stories, to describe where and how the Groovy is used and how it helps in development/production environments, then we had a chance to chat and ask some questions.






Technorati Profile

Wednesday Jun 18, 2008

Grails and web service development with Metro

I searched through my blog entries, and realized that I somehow forgot to blog about the Metro Plugin for Grails framework I introduced in the beginning of this year. So, this is an attempt to do a (late) little advertising.

If you use Grails, you are certainly aware of it's plugin system. I decided to wrote a little Metro plugin which enables you to expose your Groovy/Grails classes as Metro web services in a simple and easy way using natural Grails commands, such as

grails create-service

and natural Metro annotations, such as @WebService, like this:

import javax.jws.\*
@WebService(targetNamespace="http://com.calculator")
class CalculatorService {
@WebMethod
def int add(int i, int j) {
return i+j;
}
@WebMethod
def multiply(int i, int j) {
return i\*j;
}
}

Those are the only things you need to do to develop web services with Grails after installing the plugin. You can find exact installation/how to use instructions at plugin website. Currently I host the plugin as a subproject of JAX-WS Commons project, but am working on making sure it is hosted at Grails plugin site as well.

Btw, I recently found also these instructions on how to use the Metro Grails plugin to develop contract-first (WSDL first) web services, which gives exactly the areas where I planned to improve the plugin in. So in future, the instructions might get even more simple.

Monday Jun 16, 2008

Firefox download day tomorrow!

I just received following email:

The show starts tomorrow! I'm already running Firefox RC3, and really curious how will the download day go ;O) There's only ~5000 pledges from Czech Republic which is a bit dissapointing for me. I believe the real download numbers will be much higher.

Thursday Jun 12, 2008

Metro features with NetBeans

With Geertjan's help, my article about Metro use in NetBeans has been published to NetBeans Zone. Enjoy! And vote for it if you like it ;O)

Wednesday Jun 04, 2008

New features in Metro 1.3 with NetBeans 6.1

Couple of people asked about availability of the new features I described earlier. The bits there point to NetBeans 6.5 builds. Question is whether you can use the same bits for NetBeans 6.1?
Unfortunately the answer so far is no, it is not possible. However, come here for updates.

I've tried to keep the bits the same, but there has been a change in classpath apis which didn't allow me to produce the same artefacts for both 6.5 and 6.1 builds. There's also a WS server api redesign planned for 6.5. So, I'll try to provide the build, but we'll see.

JAXB

Well, you might have already read Kohsuke's blog about JAXB 2.2 maintenance release. Hudson is his baby now, and he's moving away from JAXB duties.
The reason I mention it on my blog is that I'm going to take over the JAXB work going forward.
I'll leave it with that note for now, maybe I'll write more later on.


About

The views expressed on this [blog; Web site] are my own and do not necessarily reflect the views of Oracle.

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today
Bookmarks