JSF 2.0 & Cassandra - How to get started - jsf

Here come a few newbie questions on using Cassandra with JSF 2.0. I'm in the start of a web application and want to use Cassandra as a backend. My app should be deployed in different regions and hence the same data should be available/replicated in/to all regions.
I would like to have general information about best practices.
I have the following setup:
Maven2
JSF 2.0 (currently using Managed Beans and JPA)
Glassfish 3.2.1
Which driver would you recommend?
cassandra-jdbc driver implemented with datastax community edition?
Or Hector, which seems to be the most advanced client?
If Hector how would I use Hector properly within a JSF project?
Hector JPA integration (could not find any information on how to use)?
Using Hector directly from Managed Beans without JPA?
How would I use the driver best in a JSF 2.0 web application?
Managed Beans?
Singleton Bean?
POJOs?
(I'm not very familiar with Java EE yet, but in the process of building up knowledge)
How would I structure the classes/beans so that connections can be pooled?
Is there maybe an open source example that is using JSF/Java EE or JSF/POJO to see how such as setup is used in best practice?
What are your opinions on how to start such a project from scratch?
I'm thankful for all hints you can give me. I'm struggling since a month to find enough information to get started on this project.

Which driver would you recommend?
* cassandra-jdbc driver implemented with datastax community edition?
* Or Hector, which seems to be the most advanced client?
I would probably suggest hector as this project status is active. There are many q&a, articles and manuals that can be found online and that help greatly when you starting to learn this new technology. But that does not means cassandra-jdbc driver is lack of materials that can be found online. This is my personal preference development using hector library from version 0.8 to the current latest version.
If Hector how would I use Hector properly within a JSF project?
* Hector JPA integration (could not find any information on how to use)?
* Using Hector directly from Managed Beans without JPA?
How would I use the driver best in a JSF 2.0 web application?
* Managed Beans?
* Singleton Bean?
* POJOs?
(I'm not very familiar with Java EE yet, but in the process of
building up knowledge)
How would I structure the classes/beans so that connections can be
pooled?
Is there maybe an open source example that is using JSF/Java EE or
JSF/POJO to see how such as setup is used in best practice?
You should really read and study into these repository.
cassandra-queue-spring
hector object mapper
I don't have experience in JPA so I can't comment further but it seem that hector has the JPA classes that you will be interested in. Be sure to check out this Hector Object Mapper introduction.
What are your opinions on how to start such a project from scratch?
It's probably difficult to start everything from scratch if you are new JavaEE but this link should provide you assistance when you start your own project.

Related

datastax driver vs spring-data-cassandra

Hey I am new to Cassandra and I am friendly with Spring jdbc-template.
Can anyone please explain difference between both of them? Also can you suggest which one is good to use ?
thanks.
spring-data-cassandra uses datastax's java-driver, so the decision to be made is really whether or not you need the functionality of spring-data.
Some features from spring data that may be useful for you (documented here):
spring xml configuration for configuring your Cluster instance (especially useful if you are already using spring).
object mapping component.
The java-driver also has a mapping component as well that is worth exploring.
In my opinion if you are already using spring, it is worth looking into spring-data-cassandra. Otherwise, it would be good to start off with just the datastax java-driver.

Does Hazelcast follow JSR-107

Read about JSR-107 and JCache recently.
Would like to know whether Hazelcast or Ehcache follow this JSR?
JSR107 (JCache) made good progress and we already notified the spec committee that Hazelcast will implement the JCache spec. Having JCache part of Java EE 8 will be significant achievement so Hazelcast is now committed to JCache.
-talip (hazelcast founder)
As far as Hazelcast goes, here is a response from Talip Ozturk:
> 1. Does hazelcast have any plans to support JSR107? If so, any release date?
It shouldn't be hard to support JSR107 but it is a 10 years old JSR
that is never been finalized. We don't want to spend time on it until
we see an official release of the spec.
Found on this page.
As far as Ehcache goes, here is a possible implementation that may work: https://github.com/jsr107/ehcache-jcache
Hazelcast 3.3.1 passed the JSR107 final TCK and was accepted by the JCP as compatible. Makes sense since the JCache spec co-author is the CEO of Hazelcast
You can download it at http://hazelcast.org/download
If you need an implementation of JCache, the only one that I'm aware of being available today is Oracle Coherence; see: http://docs.oracle.com/middleware/1213/coherence/develop-applications/jcache_part.htm
For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.
Hazelcast is now fully complied with Jsr107 or Jcache. This is announced in the official Blog
On the opening day of JavaOne and Oracle Open World, Hazelcast, the leading In-Memory Data Grid provider is announcing the release of Hazelcast 3.3.1 JCache, the JCache compatible version of Hazelcast.
And acording to this
Hazelcast JCache implementation is 100% TCK (Technology Compatibility Kit) compliant and therefore passes all specification requirements.
The samples in hazel cast makes it somewhat easy to learn jcache as there is really poor JavaDocs and other resources

About Java Cassandra Client, which one is better? How about CQL? [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
I am trying to develop application using Hive as the Database, and then I also find noSQL solutions as an alternative to it.
Now decided to develop using Cassandra, my next problem is about what client should I use? which one is better, Hector -- a pure java solutions, or Kundera with JPA like development?
I prefer Hector, but I am curious about Kundera. Is there anyone using Kundera? Which is better?
I'm curious about CQL (Cassandra Query Language). Can it integrate with Hector?
Hector is slowly moving towards CQL integration. The first steps have been made, but because of the experience of an unstable API, the developers seem to have postponed a new release. The CQL API is rather new, as it should be nearly equivalent to a SQL syntax. I made some basic steps with CRUD operations to verify that data could be written and read via CQL.
Nevertheless, the CQL JAR is not usable out of the box like a standard JDBC driver as of now, and misses some important feature aspects. Having a look at the more or less difficult to understand thrift API and the not really much simpler hector API, I am convinced that CQL will be established as the state-of-the-art access API for Cassandra in version 0.8.1 and 1.0, where thrift will remain the native, raw access for some time.
The competition between both APIs has nothing to do with the decision of Hector. Hector itself provides additional services like failure and connection handling in the cluster. These are features being addressed by neither thrift nor CQL.
I don't really believe in all other O/R mappers, or even those claiming to provide a full-fledged JPA. I cannot imagine how this should work.
Answering your question about clients - Hector essentially provides access to the Cassandra native API (columns, column families, rows etc) whereas Kundera aims to hide these details and provide object-database mapping.
Kundera therefore probably makes it easier to quickly persist a range of Java objects into Cassandra - but may not provide an efficient mapping, perhaps losing some of the performance that noSQL approaches provide.
Hector expects you to adapt to the Cassandra data model - this will be harder work, but is likely to deliver more performance.
There is now a new client, Astyanax, released by Netflix in January 2012.
"Astyanax is a Java Cassandra client. It borrows many concepts from
Hector but diverges in the connection pool implementation as well as
the client API. One of the main design considerations was to provide a
clean abstraction between the connection pool and Cassandra API so
that each may be customized and improved separately. Astyanax provides
a fluent style API which guides the caller to narrow the query from
key to column as well as providing queries for more complex use cases
that we have encountered. The operational benefits of Astyanax over
Hector include lower latency, reduced latency variance, and better
error handling."
The source code for Astyanax is hosted at Github: https://github.com/Netflix/astyanax
For details about using CQL with Cassandra and Hector, see:
https://github.com/rantav/hector/wiki/Using-CQL
The following mail list thread is a good discussion on where we will be going with CQL as an API:
http://groups.google.com/group/hector-users/browse_thread/thread/540dc9c3908fbb44/f5ee488f2178e2f4
For the sake of completeness I think the Pelops library should be mentioned too. Hector seems to be the most used, but Pelops has a simpler API. Pelops does not support CQL.
Coming from Ruby I find both to be extremely verbose and imperative, though.
Kundera no more relies on Solandra for indexing approach. It enables you now to use secondary indexing support provided by Cassandra and as well as it gives you a way to run jpa queries over OPP (like range queries etc). We are working to enable native CQL support.
Take a look at:
http://mevivs.wordpress.com/2012/02/13/how-to-crud-and-jpa-association-handling-using-kundera/
for more details.
-Vivek
There is no java client in the same level with hector, hector is the best and there is work in progress in hector side to support cql. I saw cql commits for hector in github this month, but doesn't know it's final state. You can ask it to hector users group http://groups.google.com/group/hector-users
Also there is a very simple object mapper in hector
https://github.com/rantav/hector/wiki/Hector-Object-Mapper-%28HOM%29
My Best,
Serdar Irmak
Kundera 2.0.4 released:
Major Changes in this release:
Cross-datastore persistence( Easy to migerate existing mysql app over nosql)
support for relational databases (e.g Mysql etc)
replace solandra with lucene based indexing.
Support added for bi-directinal associations.
Performance improvement fixes.
We tested and 1 million inserts with proper indexing happened in 6 minutes.
Vivek
I am yet to try Hector, but am involved in latest Kundera 2.0.1 release. I suggest you give it a try. It has gone a major change since its inception and you can see a lot of new features getting added and bugs being fixed. Currently it supports JPA 1.0 and Cassandra 0.7.6 but we are planning to add support for Cassandra 0.8 and JPA 2.0 very soon. There is a pretty good example here: https://github.com/impetus-opensource/Kundera/wiki/Getting-started that may help you get started.
Astyanax api produces human-readable code and does include connection pooling.
CQL support over cassandra has been integrated in kundera 2.0.6(yet to be released). It allows to execute CQL as nativequery now.
-Vivek

Scala web application security

What are good framework choices for web security in a Scala web application. We would like to try out Scala web development, but couldn't yet find good Scala web app security frameworks.
From the Java side I know at least Spring Security and Apache Shiro.
Do you have experience with Scala web app security frameworks or with Spring Security / Apache Shiro in a Scala context?
Lift has security baked in as described here by David Pollak, the author of Lift.
I used Spring Security in small Scala web application. I created it as I started to learn Scala and I tried to use complete Java stack: Spring MVC + Spring + Spring Security + Hibernate + BlazeDS (I also used Flex in this project for the frontend). Now I can tell that it was really nice and positive experience. Generally the question is how good scala integrates with Spring and Hibernate. I had to use #BeanProperty or #BeanInfo and java collections in entities.
But I have not faced any real issues from the spring security side. It was working as expected. I can remember only one minor issue with Spring AOP: service classes were publishing their methods through BlazeDS to the flex application. I also secured them with Spring Security's object ACLs (with <security:intercept-methods /> and <security:protect />). All this stuff, of course, is possible because of AOP magic. So I noticed this wired Spring AOP's behavior - if your class implements some interfaces, then it will use JDK's proxies to implement them and delegate all calls to target, but if class does not implementing any interfaces, then it will use cglib to extend your class and delegate each method call. The problem is that my public service classes does not implement any interfaces, but AOP was not working properly. The reason is ScalaObject interface that is implemented by all scala classes. So I created new traits for all public services in order to solve this problem (I have not found any way to configure Spring AOP - seems that this behavior is hardcoded).
So as you can see it's not a problem to use Spring Security with Scala. I believe that it should be even easier to use Apache Shiro because it claims to be completely container or environment independent (I heard that it's possible to use Spring Security outside Spring, but I also heard that it's pretty painful). Generally in Scala you can archive everything you can in Java. The question is how pretty/idiomatic/pure/side-effect-free resulting code would be.
By the way, there is a new project that integrates Lift with Apache Shiro: lift-shiro. Here you can also find small blog post about it.
Hope this helps.

Spring/Spring Security 3.0.x execution flow

I'm currently in the process of migrating an application from Spring 2.5.6 to Spring 3.0.4 and Spring Security 3.0.2 and I was wondering if there was some kind of execution flow for both of these framework so that developpers could know what is being called before what.
For those of you who are doing this kind of migration, I can tell you that it's not a simple task that's why I was wondering if some experts, out there, in the wild, would have some references about these flow.
Thanks
You should start here:
http://static.springsource.org/spring-security/site/docs/3.0.x/reference/springsecurity.html
This is a detailed overview of how spring works and will get you up to speed on the changes. Additionally I highly recommend the book by Peter Mularien - Spring Security 3.
With these two references you'll be on your way in no time.
Grant

Resources