Java JAXB Pros/Cons and Documentation [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
It's been a while since I used Java in anger so please forgive me if this is silly.
I have just got started on a Java project where we are using JAXB to de-serializing an incoming XML string (from Jetty Server). The project is only using JAXB for this situation.
What are the alternatives to JAXB?
What are pros/cons of JAXB to these alternatives
I have done some googling and found lots of reference material, but is there a definitive source that is the goto place for JAXB questions or do people just see what people are doing and interpret from there.
Thanks.

I've found JAX-B pretty useful and actually like it better than many of the alternatives, especially if I'm starting from scratch and generating a schema from Java objects rather than Java objects from a schema.
In my experience, for whatever reason, I've found good documentation hard to come by from just Google searches. The best electronic documentation is provided in the JAX-B download where you'll also find numerous examples. "SOA Using Java Web Services" also has a good overview.
As for alternatives, there is:
XStream
Castor
and probably several more.

XML Bean comes to mind (http://xmlbeans.apache.org/)
One of the PROS about JAXB is that it now comes bundle in with JDK6. The generate output is really tight and efficient. We are currently converting all our XML Bean implementation to use JAXB 2. The big CONS that we have seen is the lack of XSD related operations.

I have been using JAXB for a few projects. I think the best thing about it is it's integration with newer technologies like JAX-WS and JAX-RS (JSR 311, Restful spec).
If you are handling incoming XML as a String with Jetty, I would seriously consider looking into the JAX-RS. It handles all of the JAXB binding stuff for you and you just work with an object.
I've been pretty happy with JAXB through CXF for both REST style and SOAP web services.

I have tried many of the listed suggestions and prefer Simple to them all. It is relatively new in the overall sense yet mature and stable, and seems to have taken a lot of the complaints from other XML frameworks into account. I highly suggest reading the front page and if possible giving it a quick proof of concept prototype in your project.
http://simple.sourceforge.net/

Look here: http://jcp.org/en/jsr/all for JSR-222.
This Java Specification Request specifies the standard (non-free).

For alternatives to JAXB you might want to check out XFire (http://xfire.codehaus.org/) or Axis2 (http://ws.apache.org/axis2/). Those seem to be 2 popular alternatives, and I believe both are now JAX-WS complaint.

XStream is really good if you have an object model for the xml you are trying to parse.

Other alternatives could be Castor, JibX, XMLBeans, or JDOM.

Actually I had used Castor. It is better than JAXB in case of xml binding. It provides functionality to map your existing java beans.

One big drawback of JAXB (if using annotations in transfer objects) is that Android does not support JAXB annotations (classes unknown) and you cannot add them manually.
Also see Using JAXB with Google Android

Related

XML Parsing Mechanism with spring boot JAXB vs Staxs vs Hand Crafted parser [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
We are building Microservices using spring boot, however we have part of our project will be responsible for connecting with ESB through MQ and our contract is XSDs.
Our design team have 3 options:
Go for generation with JAXB "Generating POGO, building the marshaling and unmarshaling, and generating XML request and Response"
Using Staxs as a XML parsing library "However we didn't have any stream of data to be parsed"
Handcrafted Parser
Design team rejects JAXB as a solution for this concerns:
Custom validation cannot be handled in JAXB with spring boot
JAXB marshaling and unmarshaling will cause performance issue
ESB returned response will not comply with UI "however our services is stateless and ESB responses must not serve UI or being tightly coupled"
So Please i need to know what is the best approach that we can follow, Dev team see's the handcrafted approach is very time consuming.
and accuracy of written model and classes will no be the most accurate for that case.
Thanks,
Hamed
Is there any evidence from the design team for these claims?
You can patch many custom validations on top of jaxb. There might be some frameworks that don't work well together with jaxb, but a general "cannot be handled" requires some evidence or specifics.
Depends on the actual requests. Ask to see performed benchmarks.
I dont really see how the approach to xml parsing would change that.
Anyway, there are a lot of xml parsing options. Without specifics/requirements it is hard to specifiy "the best" for that case. The actual requirements are usually so low and all common libraries are so good, that it doesnt really matter.

ServiceStack.net equivalent for Java (or something that could interwork with ServiceStack)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I read about ServiceStack.NET and really liked it a lot (especially the fact that it is based on a messaging paradigm and implements the Data Transfer Objects pattern).
I would like to know if there is any framework for Java that comes close to what ServiceStack provides for .NET? Alternatively, do you know of any Java framework that can interwork with ServiceStack?
I am especially interested in the below features that ServiceStack.Net provides:
Metadata pages for all registered formats With links to WSDLs, XSDs
Support for JSON/JSONP, XML, JSV, CSV and SOAP on all end-points
And although I am looking for a framework that provides the above features on the JVM, I would also be interested in one of these platforms because I suspect that they could be used as intermediaries for interworking with the JVM world (i.e. the Facade pattern).
Python
Ruby
node.js
Disclaimer: I'm not familiar with http://www.servicestack.net/, however it seems to be a Web Application Framework built around Enterprise Integration Patterns (EIPs).
Apache Camel integrates with a lot of the services you mentioned and is also built around EIPs. A great place to start is #Claus Isben's Camel In Action book.
In case you just want to build a web application, try:
Many Java web applications are built with Spring to great success. It has a lot of the features you're looking for, and I'm sure there is a lot of documentation for the integrations you're looking for.
It seems like you're looking for a fully featured integration framework, but just in case you are looking for a much more lightweight approach, try Jersey, the JAX-RS Reference Implementation. It has WADL support out of the box with the sample application.
You can achive this by using Apache CXF and Camel transport for cxf. http://camel.apache.org/camel-transport-for-cxf.html

tools available for generating wsdl from java interface(java2wsdl) in webservice [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
Generating java files(stubs and skeletons) from wsdl(wsdl2java) is quite easy but I felt that generating wsdl from java(java2wsdl) is not as easy as wsdl2java.
I am starting with a webservice from scratch, I have written the java interface which contains all the web service API.
I want to generate wsdl from my java interface, I have come across about apache axis.
It is good but I want to know that what are the other tools available to generate wsdl from java interface, which are friendly to implement and what are advantages and disadvantages of them.
Suggestions and opinions are welcomed. Thanks in advance.
In addition to Apache Axis (v1.x and v2.x), I have used the IBM JAX-RPC implementation, some JAX-WS stuff and Spring-WS v2. My best experience thus far has been with the Spring framework. It advocates a contract-first development approach to web services; that is, create your XML Schema document first and then generate Java POJOs from that. Using Spring-WS you don't need to worry about creating a WSDL because (if you instruct it to) it will generate the WSDL based on your XML Schema document(s) and your configuration.
This allowed me to keep my web service interface packages nice and tidy: simple annotations hooked my Java classes into my Spring configuration, and the Spring-WS framework handled everything else. Spring-WS was the least invasive framework I've used for this, and also the easiest to get up and running with.
Using the Web Service plugin for eclipse IDE: Press 'Ctrl+N ', and go to Web Service/Web Service. For the service implementation written, wsdl will get generated in the same project directory.
This is an easy way of generating wsdl and vice versa(client stubs).
java2wsdl cmd available in apache cxf(For the cxf 2.1 versions, use java2ws instead) can do what exactly you want

Proper tool for simple XML interfaces [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I need to expose some services of the web application to remote clients via XML interfaces over http.
A number of provided services is limited (3-7), both request and response should be kept simple and do not require any special data types or cross-entity relations.
My goal is to keep the code clean and clear and have robust and performant application.
I would really appreciate your advices regarding the proper XML binding\processing tool to be used for that task.
UPD: My bad, haven't mentioned that restlet is required for implementation, however, as far as I am concerned, it does not impose any restrictions on the xml tool to be used.
Thanks in advance.
The JAX-RS specification (JSR-311) provides a standard means of creating RESTful services over HTTP. There are several JAX-RS implementations: Jersey, RESTEasy, Wink. JAXB (JSR-222) is the standard binding layer (objects to/from XML) for JAX-RS, and there are several implementations: MOXy, Metro, JaxMe, etc.
These implementations are also come pre-bundled with Java EE application servers (i.e. GlassFish and WebLogic contain Jersey).
Here is an example I put together using Jersey & MOXy in GlassFish:
Part 1 - The Database
Part 2 - Mapping the Database to JPA Entities
Part 3 - Mapping JPA entities to XML (using JAXB)
Part 4 - The RESTful Service
Part 5 - The Client
We've done some work recently using Apache CXF, and found its JAX-RS support to be simple and allow us to write very DRY friendly code.
There is a reasonable amount of flexibility, e.g. several different data binding layers to choose from.
How about XStream? http://x-stream.github.io/
XStream is a simple library to serialize objects to XML and back again.
I like http://www.restlet.org/
My advice would be to not use a binding tool at all. Just deal with the fact that what you are sending over the wire is in fact XML. The Spring Web Services reference manual describes the rationale behind this, which is called 'contract first', right here
I understand that what you are looking to write is not a SOAP service, but a REST service. That doesn't matter for the point I am making against using a binding tool, the principle of 'contract first' still applies.
Good luck!

Java plugin framework choice [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
We're trying to determine how to implement a simple plugin framework for a service we are implementing that allows different types of calculators to be "plugged-in".
After reading a number of posts about Java plugin frameworks, it seems like the most common options are:
OSGI
"Rolling your own" plugin framework
The Java Plugin Framework (JPF)
The Java Simple Plugin Framework (JSPF)
OSGI seems to be more than we need.
"Rolling your own" is ok but it would be nice to reuse a common library.
So we're down to the JPF and JSPF. JPF doesn't seem to be in active development anymore.
JSPF seems very simple and really all we need. However I haven't heard much about it. I've only seen one post on StackOverflow about it. Does anyone else have any experience with JSPF? Or any other comments on this design choice?
Update: There isn't necessarily a correct answer to this.. however we're going to go with Pavol's idea as we need just a really, really simple solution. Thanks EoH for the nice guide.
(Disclaimer: I am the author of JSPF, so better take my comment with a grain of salt ;-)
The main reason I started with the JSPF was because I had the same problem as you have now: I was looking for a simple solution to make my thesis-project 1) extensible and 2) give it a more or less clear code structure.
The reason why I haven't decided to use an existing framework was because most of them were so heavyweight to start with, that I got lost in reading documentation and was almost forgetting my original task. So, according to your statement
We're trying to determine how to
implement a simple plugin framework
for a service we are implementing that
allows different types of calculators
to be "plugged-in".
I'd think that you could give JSPF a shot and see how far you come within one or two hours.
However, the final decision also depends a bit on what exactly you want to achieve, and the specific circumstances.
I have heard positive results from a number of individuals who have been using it to structure their projects or load plugins in their projects. On the other hand, I also know of one person in our department who discarded it again because he didn't feel it was mixing well with his programming style.
So, to answer your question briefly (and surely in a biased way), I would use
OSGi for projects and teams
which are large and have many people working on it
that justify the overhead of setting up the infrastructure
in need of the specific services offered
JPF for projects and teams
of medium size (?, honestly I am not sure about the project / team size they are targeting)
which are in need of more structured facilities to organize their code, like XML configurations, detailed plugin lifecycle management, extensible plugins ...
JSPF for projects and teams
of small size, following an agile paradigm
that just need something that works out of the box, without the need of configurations or setup
willing to sacrifice some features for simplicity
I hope you find the plugin framework most suitable for your scenario. And, no matter what you try, I would be happy to hear about your results.
If you are planning to have just one (or only a few) not very complex 'extension points' than perhaps a well-defined SPI and a piece of configuration might be sufficient. No need to use a plugin framework.
By piece of configuration I mean some mechanism to find your plugins. For example something like META-INF/services/ or simply listing your plugins in a configuration file.
More details (upon request):
SPI = Service Provider Interface, an "implementer-side equivalent of an API". To learn more try searching for a difference between API and SPI. However in this context it is just a fancy term for an interface to be implemented by your plugins (i.e. defines the contract for your plugins).
A nice, short article "Creating a Service Provider Interface" by Ethan Nicholas describes how to create your own SPI in similar way as it is done in several part of the Java Platform itself.
META-INF/services/ can be seen as a more generalized approach to creating SPIs. More information can be found in the respective section of the JAR File Specification.
If you need a really simple solution, try jin-plugin. It is a minimalistic plugin framework for Java and PHP.

Categories

Resources