Using rest service using Helidon
Have created app using Helidon and rest services are available from Helidon.
i want to use spring jdbc template,dao Autowire features with Helidon and searched lot didn't find any article first of all is it right way ? Please suggest docs links
Spring and Helidon are alternative frameworks indented for (mostly) the same purpose. They are two different worlds that will have problems coliding.
I don't think it's impossible to combine them, but it is at least impractical and bound to bring lots of problems like bean instantiation, classloader and so on with them.
I'd recommend you choose one of the two and stick with it.
Helidon is not Spring so does not support these features. It sounds like you want to write a Spring application instead.
Related
I am implementing a REST service from scratch. I am using Spring + ibatis for the same.
Now, spring offers REST support using annotations. However, online, I find many tutorials to integrate Jersey with Spring.
My question: Why would one want to introduce extra dependencies by including another framework, that is Jersey JAX-RS, when Spring itself is good?
You assume that there's a problem with introducing "another" dependency, which, unless you're developing for some tiny embedded system, there isn't. The added memory footprint, complexity etc would generally be irrelevant.
The decision to use Spring or Jersey for RESTv implementation should be one of personal preference and suitability. Pick the one that satisfies your requirements and you're most comfortable with.
Also, using Spring for REST will require additional dependencies itself. If you're only using Spring for dependency injection, you won't require spring-web or spring-webmvc, whereas these will be required for REST.
Hope this helps
I'm analyzing on using Spring framework with Play 2.1 to support DI. Apart from DI, can i also use spring's AOP interceptors, transaction, DAO and REST support with Play 2.1? I'm not sure whether it is the right approach. If not, what is the best way to handle these things with Play? Are there any inbuilt support in Play on these areas or do i need to go with separate libraries like AspectJ, Guice, Jersey etc?
Yes you can integrate Spring with the Play Framework. I did it in a project just some weeks ago. As shown in the tutorial linked by Pere Villega this can easily be achived by extending GlobalSettings. This way also works for other DI solutions like Guice (as shown here). As far as I know, there currently is no native solution for DI in Play 2.x.
Of course you can also use other features provdided by Spring, like their DAO support or transaction management (however this may require further configuration). We even used Spring Data's MongoDB support.
Just some personal note: I really like the Play Framework for building typical Java MVC webapps, but I found it quite temperamental for building an API only. So if you are also writing your web client using Play, the provided routing and templating are great and give you a head start. For a pure REST service however I ended up using JAX-RS (on Jersey), some basic Spring components and Jetty. We then wrote the web client completely in JavaScript using Backbone, Node and Airbnb's Rendr.
Play has it's own way of managing REST, transactions (depending on the JPA library used) and interceptors.
You can integrate it with Spring, see this demo in github, but I'd first think about if you really need it.
Why are people using Spring DI vs. JSR330 DI? I see many projects still going forward at a huge speed with spring DI oblivious to the JSR330 specification. Many don't even know it exists. Was it not marketed enough and spring was?
I do see posts of Guice vs. spring, but the real argument should be JSR330 vs. spring since spring does not implement the spec yet(and hopefully one day it will). Any ideas on why such a large portion of the community seems oblivious to JSR330 and not evolving to it?
NOTE: I should make a correction here. Spring 3.0 does implement JSR330 and even has a way to override the default bindings much like guice except you have to supply an xml file instead of a Module file written in java.
I would say it is because Spring is so much more than just a simple DI container. Many teams use Spring for these other various reasons:
Transaction Management
Security
MVC
Aspects
Data Access
Batch processes
Webflow
Web Services
Many others...
They have their hands in so many things that it just makes it easy mix and match Spring technologies to do general enterprise development.
Spring 3.X supports JSR-330 out fo the box - http://blog.credera.com/topic/technology-solutions/java/springone-2gx-2011-summary/
It means that you can use the spring annotations or the JSR-330 ones.
I want to learn Restful web service using Apache CXF. Could you please suggest any resource to refer to except for the official CXF site? Where can I learn all those annotations with example uses?
One more question is “Are those annotations going to be different depending on the implementations framework like apache CXF or Jersey or any other framework?”
Are those annotations going to be different depending on the implementations framework like apache cxf or jersey or any other framework?
No. The point of the JAX-RS standard (and the rest of Java EE) is exactly to ensure the annotations work the same across implementations. Of course, there will always be bugs and differences in interpretation that result in different behavior, but in general it tends to work pretty well.
However, there may be additional, implementation-specific annotations that provide desirable functionality that is not covered by the standard (there's quite a lot of these for EJB and JPA implementations, not sure about JAX-RS). Using those would make your app depend on that particular implementation.
Check out Jersey user guide - it has a section on JAX-RS, which explains these annotations and should work with any other JAX-RS implementation: http://jersey.java.net/nonav/documentation/latest/jax-rs.html
Apache CXF documentation is very useful and it provides lots of additional resources. Consider going through it and checking the examples.
Additionally it might be useful for you to go through some JAXB tutorials and resources.
Ive been working now with the Spring Framework 3.0.5 and Spring Security 3.0.5 for several time. I know that Spring Framework uses DI and AOP. I also know that Spring Security uses DI, for example when writing custom handlers or filters. Im not sure whether Spring Security also uses AOP - so my first question is: does it?
Well, Id also like to know how Spring Security can be used for non-spring-based applications. Its written in their documentation that this is possible. Well, I wonder how - it seems like it uses DI, so how should it work in a simple java web application? I guess at least a web container which supports dependency injection is needed, correct? (Which one could that be?)
Thank you for answering :-)
[EDIT]
documentation says:
"documentation says: "Spring Security provides comprehensive security services for J2EE-based enterprise software applications. There is a particular emphasis on supporting projects built using The Spring Framework, which is the leading J2EE solution for enterprise software development. If you're not using Spring for developing enterprise applications, we warmly encourage you to take a closer look at it. Some familiarity with Spring - and in particular dependency injection principles - will help you get up to speed with Spring Security more easily.""
j2ee-based enterprise software applications......... emphasis on supporting projects using spring framework...... well this means it should be possible to work with it without Spring Framework itself!
?
AND:
Even though we use Spring to configure Spring Seurity, your application doesn't have to be Spring-based. Many people use Spring Security with web frameworks such as Struts, for example.
This is from the spring security homepage. well....
Does it use AOP ?
Yes spring-security uses AOP for its method security (you'd have to search the page to find it).
Can you use spring-security without spring ?
Generally no.
As you need to define spring beans for several spring-security elements.
But! You can use Acegi security without spring as far as I know. Which should give you close to the same functionality.
Can you secure a non-J2EE application
Definitely.
Anything that can run in a servlet container can be secured with spring-security. You just need Spring's IoC/DI.
This answer can help you on the minimal spring-security dependencies.