First of all: here is my code: https://github.com/s1ddok/todosapp
I'm learning java technologies. I forked a demo project on github and for now my goal is to add login (user specific todos) and hibernate mysql stuff. I successfully done it for -spring version. Now I want to do the same stuff for java ee.
How do I migrate annotation based hibernate code (Entities and config) to java ee? Is it possible to simply reuse them? I heard that you have to use xml config with Java EE, is it true?
My requirement is to use same front-end (backbone) and same database for both -spring and -javaee. This is my goal. I have to implement same-functionality REST service with spring and javaee.
I'm completely stuck with that.
With JavaEE you do not have to use much XML configs (in comparison with the old J2EE), but you can do most things with annotations.
Regarding database access you can still use Hibernate (JPA), since JPA is part of the JavaEE spec. The Json annotations like com.fasterxml.jackson.annotation.JsonIdentityInfo are not part of JavaEE spec (yet), so you might have to use JAXB instead.
Regarding REST you want to have a look at JAX-RS. The annotations are different in comparison to Spring (#ApplicationPath, #Path, #GET, ...), but you should be able to achieve the same result for you application.
For security (login) you have to look at application server specific options, since this be will standarized only in JavaEE 8 (JSR 375).
Related
I have been working on an infrastructure project that has a myriad of pages that used in numerous flow based scenarios. I eager to use a standard framework for facilitating this flows. I have a glance on spring web flow and I realize it is difficult to deal with all of the XML stuff like flow files. Could you please tell me is there an annotation base version instead of these XML files? Or Is there any other frameworks that use annotation based approach for this purpose. Moreover, I saw Seam framework, but like Spring Web Flow it has an XML based feature. Additionally, I read some articles about Netui Page Flows. Even though it has annotation based flows, as you know it is a very old framework and discontinued now.
I use this links:
spring web flow support in intellij idea 12
Spring Web Flow Ref Book
spring web flow
As I need this xml based file for create a web flow for my JSP pages into my enterprise application, after month looking for best solutions and frameworks, finally I find Spring Statemachine for my porpuse. I put that here for someone in future that looks for object-oreinted state machine that can be used in her/his page flow.
Thank you Spring :)
Java configuration was introduced in version 1.2.0 of Spring Data, but I can't figure out how the java configuration for <jpa:auditing> should look like. I couldn't find any examples in the docs, neither did I figure it out by looking at the Spring Data JPA Source.
I'm suspecting it's not possible to translate <jpa:auditing> into java configuration, but as I couldn't find a Jira for the possibly missing feature, I'm unsure. Does anyone know if I still have to use XML configuration if I use Spring Data JPA with auditing?
EDIT: This feature is available as of version 1.5 M1 of Spring Data. See the ticket created by Alex Blomskøld for details.
Activating auditing is currently not supported by the JavaConfig means we introduced in 1.2.0. As we're planning to generally overhaul the auditing infrastructure anyway, would you mind filing a ticket against Spring Data JPA to capture that aspect of the story?
I have developed a Spring/JPA application: the service, repository and domain layers are nearing completion.
The only layer that is missing is the web layer. I am considering using Playframework 2.0 for the web layer but I am not sure whether I can inject/use spring beans in my Playframework 2.0 classes.
Is this possible? If so how?
You can. Updated for Play 2.5.x:
https://github.com/remithieblin/play-spring-loader
Alex.p is right there is support for spring in PlayFramework
Have a look here :
http://typesafe.com/blog/announcing-play-framework-21-the-high-velocit
and on example here :
https://github.com/guillaumebort/play20-spring-demo
Cheers
I just tested it on my project it works but on playframework 2.1 in 2.0 it didn't work.
Here is a another way of injecting beans using Spring. Standard annotations are used. No plugin is required.
https://github.com/huntc/play-spring
There's already support for the Spring IoC container in Play. It's just a matter of editing the application.conf file as mentioned in the linked to article.
Ignore the above see comment: it seems that this was dropped in playframework 2.0.
We are using Spring 2.5 and spring-json for JSON support. We have the below configuration in views.xml
<bean name="jsonView" class="org.springframework.web.servlet.view.json.JsonView"/>
Now, we have learnt that Spring 3.x uses JackSon API internally for JSON support. My question is how can we override the default implementation of Spring 2.5 to use JackSon - The way Spring 3.x begins.
Note: We don't want to migrate my Spring version, but, want Spring 2.5 to use this JackSon API instead of Spring-Json
Is it possible to replace Spring's JSON support without breaking it ?
Unfortunately, Spring's own documentation states that Spring-json is "deeply" a component of the existing Spring 2.5 framework.
See : http://spring-json.sourceforge.net/
That said - removing the dependencies on spring-json, adding your own JSON parser, and rebuilding spring can be done. I assume this will require a lot of work given that spring-json is a major component of the whole Spring MVC suite.
An alternative : Building a Facade
In addition, I don't know of any Java EE specification for Json libraries which implies that there is a good chance that all internal Spring json dependencies are specific to the APIs defined by Spring-json [compare this, for example, with JPA, which is generically defined by Java EE, so that it is easy to replace many a DAO framework].
Generally, you can package any sort of JSon library as a Spring component that will be available in the application context. Now - if you reimplement the necessary interfaces using the facade pattern, using Jackson under the hood, your version of Spring 2.5 should work the same. Alternatively, you could intercept Json related calls of interest using Spring's aspect oriented injection libraries, and reroute them as necessary.
Again, however, these are all advanced tasks - they would be excellent learning projects but I'm not sure that the time investment would really pay off if this is a production application.
http://www.javaworld.com/javaworld/jw-02-2008/jw-02-springcomponents.html
For instance, I am using JSF + custom framework developed in our company. Now I want to use a third party validation framework that can be used as an plug-in and it should not create any dependency what ever may be the technical stack.
So my question is does spring provide any framework of that sort or if it's available how can I use that?
I am expecting a validation framework something like, which is configurable through XML.
Spring does have a validation framework, but if you want minimal dependencies, then I'd suggest that you go with a Bean validation provider. It's a new(ish) official validation standard, defined in JSR-303.
There are several implementations at the moment. I'd give Hibernate Validator a look.
I disagree. Hibernate Validator is an awful piece of software (at least the versions that were current about a year ago). Spring Validation is a nice piece of software, that goes together well with the BeanWrapper interface.
But it's true: Spring Hibernate resides inside the Spring Context jar, which is unnecessary overhead. Hopefully there will be a separate version sometime.