Proper tool for simple XML interfaces [closed] - java

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!

Related

I am looking for java web framework [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 don't know if I should continue the other post of mine because this is a different question. But the questions are related.
I am looking for web java framework that:
1. will be MVC framework.
2. will be well documented.
3. will allow me use javascript of my own without using the framework modules.
4. will support feature like masterpage in asp.net.
5. will have the ability to create predefined components and use them wherever I need.
Is there something like this?
I appriciate very much examples for those features.
Judging by the tags you chose, it all points to:
Spring Web MVC framework
In my opinion it also satisfies your 5 requirements.
I would recommend using Spring Roo to generate your first project. Roo projects use the technologies that Ralph recommends:
JSPX, with some preconfigured tagx files
Tiles as templating framework
Roo will also setup Hibernate with Mysql, which are the technologies you mentioned in your other post
I can't speak to #4, because I don't know masterpage, but Spring MVC satisfies the other four requirements. I'd recommend it highly.
Be warned that Spring has an MVC framework, but it's much, much more. It's a three-legged stool:
Dependency injection and IoC
Aspect oriented programming AOP
Modules like MVC, persistence with JDBC and ORM, messaging, remoting, security, etc.
I would recommend this setup:
Spring (Spring Core and Spring MVC),
Tiles,
JSPX (the X markes the spot)
Tiles for "support feature like masterpage in asp.net."
JSPX, because you can easyly write Tagx files to define your predefined components.

Are there any examples/tutorials of using Spring 3.0 with Cassandra as a backend? [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
As I had written in title, I am trying to learn Spring 3.0 (I already know Django, Pylons and few simpler MVC frameworks) and try to use Cassandra as a backend for my web application.
Are there any real world examples of doing this? Or maybe some tutorials? I know about the existence of documentation of both technologies, yet I am looking for something "faster" to read and get me rolling.
I'm the author of Hector https://github.com/rantav/hector, the leading java client for cassandra so I would encourage you to have a look at what it has to offer.
While I personally have not been using hector with spring, we did get a few contributions which added spring support. See for example https://github.com/rantav/hector/blob/master/core/src/test/resources/cassandra-context-test-v2.xml and https://github.com/rantav/hector/blob/master/core/src/test/resources/cassandra-context-test-v2-new.xml
If you are already familiar with MVC frameworks then you should be aware that which database/datastore you use in the backend shouldn't impact your MVC application as a whole, or how you structure things - it should only affect your data layer and how it retrieves data.
With Spring MVC, the accepted practice is that you represent your data model as a series of "domain model / classes", which are typically just POJOs to hold your data. "Domain" here means that it is related to your problem domain; so if you have an application which deals with customers ordering things you'd want to have a Customer class, an Order class, etc.
Each of the three layers of your MVC application - the controllers, the service/business logic layer, and the DAO layer interacts with these domain model classes. Since the DAO layer is responsible for retrieving or updating this data in the backend, this means it is the DAO layer which needs to know how to fetch your Customer or Order class from Cassandra, how to update certain Customer fields, etc.
So there is nothing special about how you would build your Spring MVC application itself when using Cassandra or any other "NoSQL" database. You'll just need to provide different implementations of your DAO classes which can communicate with Cassandra.
If you are asking if there are any pre-built Spring utilities that can access Cassandra (or Thrift) then the answer is no, at least as far as what's in Spring 3.0. But this should be pretty simple to write once you have the DAO interface set and all other layers of your application in place.
AFAIK there is no "public" tutorial or example covering Spring (3.0) in conjunction with Cassandra.
So maybe you could look into it :)
I would recommend to start looking at the "template" terminology in Spring (e.g JDBCTemplate and HibernateTemplate) and create something like a "CassandraTemplate".
I don't think there is any cassandra-spring library available. However, you could use Spring to instantiate and configure the bean that talks to Cassandra, and inject that into any other bean you have that requires persistence. That way you can let it benefit from Inversion Of Control and all the facilities the Spring ApplicationContext offers.
That way you can separate the code that is aware of the cassandra datastore from your business logic and use spring.
So, your component that talks to Cassandra will be of the [#Repository][1] stereotype, e.g. it is a Repository, just like a repository that talks, for instance to a JDBC datasource.
I am involved with a project using Spring with Cassandra called Easy Cassandra. A sample is provided here:
https://weblogs.java.net/blog/otaviojava/archive/2013/08/25/run-cassandra-spring-data

Java and J2EE code examples for 3-tier apps [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
Do you know a site that offers a tutorial with sample source code for a 3-tier application (the usual data access layer, business layer and UI layer)?
The simple, readable and intuitive the source code. Best practices that are applied to the code are welcome as well.
Take a look at Appfuse , it's a quick-starter for java web application, provided with different frameworks : Tapestry , Spring MVC / Struts2 /JSF + Hibernate / Hibatis. It's based on a Maven build, all basic configurations done for you...
One of the few 'realistic' sample that come to my mind...
Another one is the Petstore application from sun, and looking for 'petstore download' on Google, you can find stuff that seems interesting (to me anyway, i didn't give it a look :-), like this spring petstore, "an Ajax based application with DWR, Spring and Hibernate"...
Yes, have a look at the Spring MVC step by step example. It's very clear.
The sample application I'm aware of are the following:
The famous Java Pet Store from Sun. In the version I've downloaded, it used a wide range of Java EE technologies, but it didn't use any modern MVC framework.
From the Spring project you have several applications: JPetStore, Pet Clinic and more. All come with the spring download.
The Seam framework has an Hotel Booking application
You can also have a look at the 3 tier open source applications such as Liferay, but bare in mind that they may by very large. I'm not familiar with any that I can recommend, so please google for CRM/ERP/Protals etc. (sourceforge and freshmeat.net might be good sources as well)
Although it is backed by a CMS and not database, Artifactory may also serve as a good example.
Hope these help.

Java JAXB Pros/Cons and Documentation [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 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

JAX-RS Frameworks [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've been doing some work with the JAX-RS reference implementation (Jersey).
I know of at least two other frameworks (Restlet & Apache CXF).
My question is: Has anyone done some comparison between those frameworks and if so, which framework would you recommend and why?
FWIW we're using Jersey as its packed full of features (e.g. WADL, implicit views, XML/JSON/Atom support) has a large and vibrant developer community behind it and has great spring integration.
If you use JBoss/SEAM you might find RESTeasy integrates a little better - but if you use Spring for Dependency Injection then Jersey seems the easiest, most popular, active and functional implementation.
Restlet has an extensive list of extensions for Spring, WADL, XML, JSON as well and many more, including an extension for JAX-RS API.
It is also the sole framework available in six consistent editions:
Java SE
Java EE
Google Web Toolkit
Google AppEngine
Android
OSGi environments
Its main benefits are:
fully symmetric client and server API when JAX-RS was designed for server-side processing
connectors for other protocols than HTTP (mapping to HTTP semantics) when JAX-RS is HTTP only
much broader feature scope including full URI routing control via the Restlet API (but can integrate with Servlet if needed)
full provision for NIO support
The JAX-RS API can be a good choice if you are restricted to JCP approved APIs (then don't use Spring or any extension of the JAX-RS projects like Jersey and RESTeasy!), but otherwise Restlet is the most mature framework (initially released in 2005) and will give you, in its 2.0 version, all the benefits of annotations combined with a powerful and extensible class-oriented framework.
For a longer list of features, please check this page.
Best regards,
Jerome Louvel
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
My team and I use Restlet extensively, but not its JAX-RS features. I can tell you that I've been very impressed with the Restlet developers and community; they're very active, engaged, responsive, and committed to a stable, efficient, reliable, and effective framework. I'm sorry I can't directly address your primary interest but I thought you might find my experience with Restlet valuable.
My colleague mentions why we are using RESTeasy for our current project in RESTful web services in Java EE with RESTeasy (JAX-RS):
Its reference implementation, Jersey, was not chosen because we had trouble integrating it well with EJB3 and Seam 2.0.
We are using the RESTeasy implementation of JAX-RS, because we had no trouble integrating it with our EJBs and Seam. It also has sufficient documentation.
There is another implementation from Apache, but I haven’t tried it because it uses an older version of JAX-RS.
Finally there is yet another framework for RESTful web services for Java called Restlet but we did not favour it because at the time of this writing, it is using a custom architecture, even though proper JAX-RS support is in the works.
It seems like there are 4 decent JAX-RS implementations, so you are probably ok with any of them.
For what it's worth, I have found Jersey (1.0.2) really nice so far. My needs are quite modest, simple back-end service, take care of plumbing and so on. And that Jersey does quite nicely.
Found out that Apache Wink is very easy to work with, supports JAX-RS and has many features beyond the standard.
I would use no framework. Just the one that comes with your applications server. If you use specifics of one framwork you'll lose portability and you'll be in the hell of what if the vendor of the app server includes a different version of your favourite framework. I'll stick to jax-ws.

Categories

Resources