Ehcache SimplePageCachingFilter

Add caching layer on your web application, with out modifying the code.

SimplePageCachingFilter

Ehcache has an out-of-box of solution for this ‘SimplePageCachingFilter’.
SimplePageCachingFilter is caching filter can be use full for html or any other response type
e.g JSON or xml. It uses singleton Ehcache manager to store contents. Cache keys are calculated
using the URI and query string. /exampleData?user=admin&role=admin.

There is another variant of ‘SimplePageCachingFilter’ based on headers ‘SimpleCachingHeadersPageCachingFilter’.
This filter take account headers for cache key. It take three account of headers

  • ETag
  • Last-Modified
  • Expires

Configuration

cacheName
Cache used by filter for storing content

blockingTimeoutMillis
the time, in milliseconds, to wait for the filter chain to return with a response on a cache miss. This is useful to fail fast in the event of an infrastructure failure.

varyHeader
set to true to set Vary:Accept-Encoding in the response when doing Gzip. This header is needed to support HTTP proxies however it is off by default.

Web.xml

<filter>
<filter-name>SimplePageCachingFilter</filter-name>
 <filter-class>net.sf.ehcache.constructs.web.filter.
SimplePageFragmentCachingFilter
 </filter-class>
 <init-param>
  <param-name>cacheName</param-name>
  <param-value>simplePageCache</param-value>
 </init-param>
</filter>
<filter-mapping>
<filter-name>SimplePageCachingFilter</filter-name>
 <url-pattern>/*</url-pattern>
</filter-mapping>

Ehcache configuration

<Ehcachexmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../main/config/ehcache.xsd">
<diskStorepath="java.io.tmpdir"/>
 <defaultCache
   maxEntriesLocalHeap="10"
   eternal="false"
   timeToIdleSeconds="5"
   timeToLiveSeconds="10"
   overflowToDisk="true"
   />
  <!-- Page and Page Fragment Caches -->
<cachename="simplePageCache"
  maxEntriesLocalHeap="10"
  eternal="false"
  timeToIdleSeconds="10000"
  timeToLiveSeconds="10000"
  overflowToDisk="true">
</cache>
</ehcache>

Pros

  • No code is required.
  • It allows the content compressing.
  • This can be integrated with Spring WebFramework too.

Cons

  • It do caching based on complete response.
  • It doesn’t take custom headers in account.

Apache Empire-db 2.4.0 released

The Apache Empire-db team is pleased to announce the release of Apache Empire-db version 2.4.0.
Apache Empire-db is a lightweight data access and persistence
component for relational databases based on JDBC.
http://empire-db.apache.org/

* New Empire-db JSF extensions project (empire-db-jsf2) allows simplified web development with
JFS 2.x implementations. An example project is provided.
* Various smaller improvements

Thank you for your interest in Apache Empire-db!

Get started by http://empire-db.apache.org/documentation/getting_started.htm

http://empire-db.apache.org/news.htm

ADF – Using Property Sets in JDeveloper

“Property Sets” are a new addition to ADF Business Components (ADF BC) in JDeveloper 11g. Property set is a nice declarative way to stop programming and doing same things to different attributes of  EOs and VOs.”

In this example tutorial, we will take a look of how to use Property Set to create a tool tip for two different attributes of a EO. We will be using OE schema and will be using CUSTOMERS EO created our of CUSTOMERS table in OE schema.
Right click on the package in the Model project of the Fusion Web App.
Now click new and in ADF Business Components click Property Set and then click OK.
Specify a name for new Property Set (I gave it ToolTipPropertySet). Click ok
Click on the green button and select Non – Translatable and put in Property as “TOOLTIP” and value as “This is Sample Tool Tip” like below screenshot.
Now double click on Customers EO and click on CustFirstName. In the inspector below, click on Property Set and select the property set which we created earlier (ToolTipPropertySet).

Repeat the same thing with Address attribute of Customer EO.

Save all the files and run the ADF Business component tester.
Place you cursor or click on CustFirstName. You will see the tool tip which we set in ToolTipPropertySet.
Now again place you cursor or click on Address, you will see the same tool tip. This is because we selected ToolTipPropertySet in Property Set for Address field also.
So this is the power of Property Set. We can assign a property defined in Property Set to any attribute of EO or VO. This helps in defining properties at single place and assigning them to attributes very easily.
Hope this was helpful.
Happy Learning with Techartifact !!
Rohan Walia