As we discussed in the previous post, CXF is the combination of two projects: Celtix developed by IONA and XFire developed by Codehaus working together at the Apache Software Foundation.
Thoughts on Software Development Trends, Enterprise Architecture, Design, Big Data, and Cloud Computing.
As we discussed in the previous post, CXF is the combination of two projects: Celtix developed by IONA and XFire developed by Codehaus working together at the Apache Software Foundation.
Apache CXF is an open source services framework which is a result of the merge between the XFire and Celtix projects. CXF helps us build and develop services using JAX-WS. These services can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA and work over a variety of transports such as HTTP, JMS or JBI.
In this series we will go through two common approaches to create a web service.
A Hibernate Session is a transaction-level cache of persistent data. We can configure a cluster or JVM-level (SessionFactory-level) cache on a class-by-class and collection-by-collection basis. We can also plug in a clustered cache into Hibernate. At the time of providing cache we need to understand that when we are updating the persistence DB it will not automatically reflect on Cache.
Configuring CACHE in Hibernate
We need to tell Hibernate that which caching implementation we need to use. This we can accomplish by specifying the name of a class that implements org.hibernate.cache.CacheProvider using the property hibernate.cache.provider_class. Hibernate comes bundled with a number of built-in integrations with open-source cache providers; additionally, we could implement your own and plug it in as outlined above. Prior to 3.2 Hibernate is defaulted to use EhCache as the default cache provider.
To find the CACHE PROVIDERS please check this post <Click Here>
The <cache> element of a class or collection mapping has the following form:
<cache
usage="transactional|read-write|nonstrict-read-write|read-only" (1)
region="RegionName" (2)
include="all|non-lazy" (3)
/>
(1)
usage (required) specifies the caching strategy: transactional, read-write, nonstrict-read-write or read-only
(2)
region (optional, defaults to the class or collection role name) specifies the name of the second level cache region
(3)
include (optional, defaults to all) non-lazy specifies that properties of the entity mapped with lazy="true" may not be cached when attribute-level lazy fetching is enabled
If application needs to read but never modify instances of a persistent class, a read-only cache may be used. This is the simplest and best performing strategy. It’s even perfectly safe for use in a cluster.
<class name="eg.Immutable" mutable="false">
<cache usage="read-only"/>
....
</class>
If the application needs to update data, a read-write cache might be appropriate. This cache strategy should never be used if serializable transaction isolation level is required. If the cache is used in a JTA environment, you must specify the property hibernate.transaction.manager_lookup_class, naming a strategy for obtaining the JTA TransactionManager. In other environments, you should ensure that the transaction is completed when Session.close() or Session.disconnect() is called. If you wish to use this strategy in a cluster, you should ensure that the underlying cache implementation supports locking. The built-in cache providers do not.
<class name="eg.Cat" .... >
<cache usage="read-write"/>
....
<set name="kittens" ... >
<cache usage="read-write"/>
....
</set>
</class>
If the application only occasionally needs to update data (ie. if it is extremely unlikely that two transactions would try to update the same item simultaneously) and strict transaction isolation is not required, a nonstrict-read-write cache might be appropriate. If the cache is used in a JTA environment, you must specify hibernate.transaction.manager_lookup_class. In other environments, you should ensure that the transaction is completed when Session.close() or Session.disconnect() is called.
The transactional cache strategy provides support for fully transactional cache providers such as JBoss TreeCache. Such a cache may only be used in a JTA environment and you must specify hibernate.transaction.manager_lookup_class.
Here in this port you can find the list of Cache providers and their Concurrency support details. (Exerted from Official Hibernate Tutorial)
Cache providers.
|
Cache |
Provider class |
Type |
Cluster Safe |
Query Cache Supported |
|
Hashtable (not intended for production use) |
|
memory |
yes | |
|
EHCache |
|
memory, disk |
yes | |
| OSCache |
|
memory, disk |
yes | |
|
SwarmCache |
|
clustered (ip multicast) |
yes (clustered invalidation) |
yes (clock sync req.) |
|
JBoss Cache 1.x |
|
clustered (ip multicast), transactional |
yes (replication) |
yes (clock sync req.) |
|
JBoss Cache 2 |
|
clustered (ip multicast), transactional |
yes (replication or invalidation) |
yes (clock sync req.) |
Cache Concurrency Strategy Support
|
read-only |
nonstrict-read-write |
read-write |
transactional |
|
|
Hashtable (not intended for production use) |
yes |
yes |
yes |
|
|
EHCache |
yes |
yes |
yes |
|
|
OSCache |
yes |
yes |
yes |
|
|
SwarmCache |
yes |
yes |
||
|
JBoss Cache 1.x |
yes |
yes |
||
|
JBoss Cache 2 |
yes |
yes |