SlideShare a Scribd company logo
1 of 13
Download to read offline
@jongallimore | #TomEE
Cluster your application with
CDI and JCache
Jonathan Gallimore
@jongallimore
#TomEE
@jongallimore | #TomEE
CDI and JCache
•  What%is%CDI?%
•  What%is%JCache?%
•  Demo%1%using%Hazelcast%to%add%caching%to%a%Java%EE%
applica<on%
•  Other%approaches%
•  Q%and%A%
@jongallimore | #TomEE
CDI
•  Contexts and Dependency Injection
•  Introduced in Java EE 6 (both Web & Full Profile)
•  Integrated with other specifications in Java EE (EJB, JAX-RS, Servlets, JSF…)
•  Provides the bean lifecycle management and typesafe injection
•  Largely annotation-based
•  Uses
–  Injection (with scoping, names, qualifiers, stereotypes and alternatives)
–  Producers (factory methods)
–  Interceptors
–  Observers
•  Can be extended with portable extensions
@jongallimore | #TomEE
JCache
•  JSR-107 - https://github.com/jsr107
•  Hazelcast implements the JCache specification as of version 3.3.1 (released
October ‘14)
•  Basic concepts
–  Caching provider
–  CacheManager
–  Cache
–  Entry
CachingProvider%cachingProvider%=%Caching.getCachingProvider();%
CacheManager%cacheManager%=%cachingProvider.getCacheManager();%
Cache<Object,%Object>%cache%=%cacheManager%
% % %.getCache(%"default",%Object.class,%Object.class%);%
cache.put(%“world”,%“Hello,%world”%);%
•  Can be included in Java EE applications
•  Add javax.cache api and implementation jars in WEB-INF/lib
•  You can use Jcache in the same way a Java SE application would use it
•  JSR-107 provides standard annotations for caching, but these are not yet
implemented by containers. Hopefully this will be part of Java EE 8
•  CDI can provide dependency injection and interceptors for JCache
@jongallimore | #TomEE
JCache and Java EE
@jongallimore | #TomEE
Hazelcast as a JCache Provider
•  Hazelcast is a fully compliant implementation of Jcache
•  Very easy to add to your Java EE application
–  Add com.hazelcast:hazelcast:3.4.1 and javax.cache:cache-api:1.0.0 to your POM.xml
•  Add declarative configuration to hazelcast.xml on the application’s classpath
•  Use JCache or Hazelcast API directly
<cache%name="mycache">%
%%<key1type%class1name="java.lang.Object"%/>%
%%<value1type%class1name="java.lang.Object"%/>%
%%<sta<s<cs1enabled>true</sta<s<cs1enabled>%
%%<management1enabled>true</management1enabled>%
</cache>%
final%MutableConfigura<on<Object,%Object>%config%=%new%MutableConfigura<on<Object,%Object>()%
%%%%%%%%.setTypes(Object.class,%Object.class)%
%%%%%%%%.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Dura<on.ONE_HOUR))%
%%%%%%%%.setSta<s<csEnabled(true);%
%
cache%=%mgr.createCache("mycache",%config);%
@jongallimore | #TomEE
What is TomEE?
•  Tomcat + Java EE = TomEE
•  Pronounced “Tommy”
•  Java EE 6 Web Profile certified
•  Java EE 7 in progress
•  Built from All-Apache Components
•  What we’ve all been building ourselves
–  ... for years
@jongallimore | #TomEE
@jongallimore | #TomEE
TomEE Goals
•  Be simple
–  Avoid complexity and making users work
•  Be Tomcat
–  Should work with Tomcat tools and apps
•  Be Certified
–  Drop-in replacement for any Java EE Web Profile server
@jongallimore | #TomEE
Show me the code!
@jongallimore | #TomEE
Other approaches
•  Use Hazelcast directly as opposed to using the JCache API
–  Non-portable, but, exposes a lot more functionality in Hazelcast
–  Can still use CDI Producers and create your own interceptors
@Produces%%%
@Singleton%%%
@Hazelcast%%%
public%HazelcastInstance%createHazelcastInstance()%{%%%
%%final%String%configFile%=%"META1INF/hazelcast.xml";%%%
%
%%ClassLoader%loader%=%Thread.currentThread().getContextClassLoader();%%%
%%URL%loca<on%=%loader.getResource(configFile);%%%
%
%%final%Config%config%=%new%Config();%%%
%%config.setConfigura<onUrl(loca<on);%%%
%%config.setInstanceName("ExampleInstance");%%%
%%%%
%%return%Hazelcast.newHazelcastInstance(config);%%%
}%%
@jongallimore | #TomEE
Other approaches
•  Session replication filter
–  http://hazelcast.com/use-cases/web-session-clustering/generic-web-session-replication/
–  Native version for Tomcat / Jetty for Enterprise users
•  POC to share state for Stateful EJBs in TomEE using Hazelcast
@jongallimore | #TomEE
Thank you!

More Related Content

More from Hazelcast

The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScriptThe Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScriptHazelcast
 
JCache - It's finally here
JCache -  It's finally hereJCache -  It's finally here
JCache - It's finally hereHazelcast
 
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentSpeed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentHazelcast
 
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorganShared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorganHazelcast
 
Applying Real-time SQL Changes in your Hazelcast Data Grid
Applying Real-time SQL Changes in your Hazelcast Data GridApplying Real-time SQL Changes in your Hazelcast Data Grid
Applying Real-time SQL Changes in your Hazelcast Data GridHazelcast
 
WAN Replication: Hazelcast Enterprise Lightning Talk
WAN Replication: Hazelcast Enterprise Lightning TalkWAN Replication: Hazelcast Enterprise Lightning Talk
WAN Replication: Hazelcast Enterprise Lightning TalkHazelcast
 
JAAS Security Suite: Hazelcast Enterprise Lightning Talk
JAAS Security Suite: Hazelcast Enterprise Lightning TalkJAAS Security Suite: Hazelcast Enterprise Lightning Talk
JAAS Security Suite: Hazelcast Enterprise Lightning TalkHazelcast
 
Hazelcast for Terracotta Users
Hazelcast for Terracotta UsersHazelcast for Terracotta Users
Hazelcast for Terracotta UsersHazelcast
 
Extreme Network Performance with Hazelcast on Torusware
Extreme Network Performance with Hazelcast on ToruswareExtreme Network Performance with Hazelcast on Torusware
Extreme Network Performance with Hazelcast on ToruswareHazelcast
 
Big Data, Simple and Fast: Addressing the Shortcomings of Hadoop
Big Data, Simple and Fast: Addressing the Shortcomings of HadoopBig Data, Simple and Fast: Addressing the Shortcomings of Hadoop
Big Data, Simple and Fast: Addressing the Shortcomings of HadoopHazelcast
 
JAXLondon - Squeezing Performance of IMDGs
JAXLondon - Squeezing Performance of IMDGsJAXLondon - Squeezing Performance of IMDGs
JAXLondon - Squeezing Performance of IMDGsHazelcast
 
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 OrientDB & Hazelcast: In-Memory Distributed Graph Database OrientDB & Hazelcast: In-Memory Distributed Graph Database
OrientDB & Hazelcast: In-Memory Distributed Graph DatabaseHazelcast
 
How to Use HazelcastMQ for Flexible Messaging and More
 How to Use HazelcastMQ for Flexible Messaging and More How to Use HazelcastMQ for Flexible Messaging and More
How to Use HazelcastMQ for Flexible Messaging and MoreHazelcast
 
Devoxx UK 2014 High Performance In-Memory Java with Open Source
Devoxx UK 2014   High Performance In-Memory Java with Open SourceDevoxx UK 2014   High Performance In-Memory Java with Open Source
Devoxx UK 2014 High Performance In-Memory Java with Open SourceHazelcast
 
JSR107 State of the Union JavaOne 2013
JSR107  State of the Union JavaOne 2013JSR107  State of the Union JavaOne 2013
JSR107 State of the Union JavaOne 2013Hazelcast
 
Jfokus - Hazlecast
Jfokus - HazlecastJfokus - Hazlecast
Jfokus - HazlecastHazelcast
 
In-memory No SQL- GIDS2014
In-memory No SQL- GIDS2014In-memory No SQL- GIDS2014
In-memory No SQL- GIDS2014Hazelcast
 
In-memory Data Management Trends & Techniques
In-memory Data Management Trends & TechniquesIn-memory Data Management Trends & Techniques
In-memory Data Management Trends & TechniquesHazelcast
 
How to Speed up your Database
How to Speed up your DatabaseHow to Speed up your Database
How to Speed up your DatabaseHazelcast
 
Hazelcast HUGL
Hazelcast HUGLHazelcast HUGL
Hazelcast HUGLHazelcast
 

More from Hazelcast (20)

The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScriptThe Power of the JVM: Applied Polyglot Projects with Java and JavaScript
The Power of the JVM: Applied Polyglot Projects with Java and JavaScript
 
JCache - It's finally here
JCache -  It's finally hereJCache -  It's finally here
JCache - It's finally here
 
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and SpeedmentSpeed Up Your Existing Relational Databases with Hazelcast and Speedment
Speed Up Your Existing Relational Databases with Hazelcast and Speedment
 
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorganShared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
Shared Memory Performance: Beyond TCP/IP with Ben Cotton, JPMorgan
 
Applying Real-time SQL Changes in your Hazelcast Data Grid
Applying Real-time SQL Changes in your Hazelcast Data GridApplying Real-time SQL Changes in your Hazelcast Data Grid
Applying Real-time SQL Changes in your Hazelcast Data Grid
 
WAN Replication: Hazelcast Enterprise Lightning Talk
WAN Replication: Hazelcast Enterprise Lightning TalkWAN Replication: Hazelcast Enterprise Lightning Talk
WAN Replication: Hazelcast Enterprise Lightning Talk
 
JAAS Security Suite: Hazelcast Enterprise Lightning Talk
JAAS Security Suite: Hazelcast Enterprise Lightning TalkJAAS Security Suite: Hazelcast Enterprise Lightning Talk
JAAS Security Suite: Hazelcast Enterprise Lightning Talk
 
Hazelcast for Terracotta Users
Hazelcast for Terracotta UsersHazelcast for Terracotta Users
Hazelcast for Terracotta Users
 
Extreme Network Performance with Hazelcast on Torusware
Extreme Network Performance with Hazelcast on ToruswareExtreme Network Performance with Hazelcast on Torusware
Extreme Network Performance with Hazelcast on Torusware
 
Big Data, Simple and Fast: Addressing the Shortcomings of Hadoop
Big Data, Simple and Fast: Addressing the Shortcomings of HadoopBig Data, Simple and Fast: Addressing the Shortcomings of Hadoop
Big Data, Simple and Fast: Addressing the Shortcomings of Hadoop
 
JAXLondon - Squeezing Performance of IMDGs
JAXLondon - Squeezing Performance of IMDGsJAXLondon - Squeezing Performance of IMDGs
JAXLondon - Squeezing Performance of IMDGs
 
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 OrientDB & Hazelcast: In-Memory Distributed Graph Database OrientDB & Hazelcast: In-Memory Distributed Graph Database
OrientDB & Hazelcast: In-Memory Distributed Graph Database
 
How to Use HazelcastMQ for Flexible Messaging and More
 How to Use HazelcastMQ for Flexible Messaging and More How to Use HazelcastMQ for Flexible Messaging and More
How to Use HazelcastMQ for Flexible Messaging and More
 
Devoxx UK 2014 High Performance In-Memory Java with Open Source
Devoxx UK 2014   High Performance In-Memory Java with Open SourceDevoxx UK 2014   High Performance In-Memory Java with Open Source
Devoxx UK 2014 High Performance In-Memory Java with Open Source
 
JSR107 State of the Union JavaOne 2013
JSR107  State of the Union JavaOne 2013JSR107  State of the Union JavaOne 2013
JSR107 State of the Union JavaOne 2013
 
Jfokus - Hazlecast
Jfokus - HazlecastJfokus - Hazlecast
Jfokus - Hazlecast
 
In-memory No SQL- GIDS2014
In-memory No SQL- GIDS2014In-memory No SQL- GIDS2014
In-memory No SQL- GIDS2014
 
In-memory Data Management Trends & Techniques
In-memory Data Management Trends & TechniquesIn-memory Data Management Trends & Techniques
In-memory Data Management Trends & Techniques
 
How to Speed up your Database
How to Speed up your DatabaseHow to Speed up your Database
How to Speed up your Database
 
Hazelcast HUGL
Hazelcast HUGLHazelcast HUGL
Hazelcast HUGL
 

Recently uploaded

Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durbanmasabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 

Recently uploaded (20)

Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 

Cluster your Application using CDI and JCache

  • 1. @jongallimore | #TomEE Cluster your application with CDI and JCache Jonathan Gallimore @jongallimore #TomEE
  • 2. @jongallimore | #TomEE CDI and JCache •  What%is%CDI?% •  What%is%JCache?% •  Demo%1%using%Hazelcast%to%add%caching%to%a%Java%EE% applica<on% •  Other%approaches% •  Q%and%A%
  • 3. @jongallimore | #TomEE CDI •  Contexts and Dependency Injection •  Introduced in Java EE 6 (both Web & Full Profile) •  Integrated with other specifications in Java EE (EJB, JAX-RS, Servlets, JSF…) •  Provides the bean lifecycle management and typesafe injection •  Largely annotation-based •  Uses –  Injection (with scoping, names, qualifiers, stereotypes and alternatives) –  Producers (factory methods) –  Interceptors –  Observers •  Can be extended with portable extensions
  • 4. @jongallimore | #TomEE JCache •  JSR-107 - https://github.com/jsr107 •  Hazelcast implements the JCache specification as of version 3.3.1 (released October ‘14) •  Basic concepts –  Caching provider –  CacheManager –  Cache –  Entry CachingProvider%cachingProvider%=%Caching.getCachingProvider();% CacheManager%cacheManager%=%cachingProvider.getCacheManager();% Cache<Object,%Object>%cache%=%cacheManager% % % %.getCache(%"default",%Object.class,%Object.class%);% cache.put(%“world”,%“Hello,%world”%);%
  • 5. •  Can be included in Java EE applications •  Add javax.cache api and implementation jars in WEB-INF/lib •  You can use Jcache in the same way a Java SE application would use it •  JSR-107 provides standard annotations for caching, but these are not yet implemented by containers. Hopefully this will be part of Java EE 8 •  CDI can provide dependency injection and interceptors for JCache @jongallimore | #TomEE JCache and Java EE
  • 6. @jongallimore | #TomEE Hazelcast as a JCache Provider •  Hazelcast is a fully compliant implementation of Jcache •  Very easy to add to your Java EE application –  Add com.hazelcast:hazelcast:3.4.1 and javax.cache:cache-api:1.0.0 to your POM.xml •  Add declarative configuration to hazelcast.xml on the application’s classpath •  Use JCache or Hazelcast API directly <cache%name="mycache">% %%<key1type%class1name="java.lang.Object"%/>% %%<value1type%class1name="java.lang.Object"%/>% %%<sta<s<cs1enabled>true</sta<s<cs1enabled>% %%<management1enabled>true</management1enabled>% </cache>% final%MutableConfigura<on<Object,%Object>%config%=%new%MutableConfigura<on<Object,%Object>()% %%%%%%%%.setTypes(Object.class,%Object.class)% %%%%%%%%.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Dura<on.ONE_HOUR))% %%%%%%%%.setSta<s<csEnabled(true);% % cache%=%mgr.createCache("mycache",%config);%
  • 7. @jongallimore | #TomEE What is TomEE? •  Tomcat + Java EE = TomEE •  Pronounced “Tommy” •  Java EE 6 Web Profile certified •  Java EE 7 in progress •  Built from All-Apache Components •  What we’ve all been building ourselves –  ... for years
  • 9. @jongallimore | #TomEE TomEE Goals •  Be simple –  Avoid complexity and making users work •  Be Tomcat –  Should work with Tomcat tools and apps •  Be Certified –  Drop-in replacement for any Java EE Web Profile server
  • 11. @jongallimore | #TomEE Other approaches •  Use Hazelcast directly as opposed to using the JCache API –  Non-portable, but, exposes a lot more functionality in Hazelcast –  Can still use CDI Producers and create your own interceptors @Produces%%% @Singleton%%% @Hazelcast%%% public%HazelcastInstance%createHazelcastInstance()%{%%% %%final%String%configFile%=%"META1INF/hazelcast.xml";%%% % %%ClassLoader%loader%=%Thread.currentThread().getContextClassLoader();%%% %%URL%loca<on%=%loader.getResource(configFile);%%% % %%final%Config%config%=%new%Config();%%% %%config.setConfigura<onUrl(loca<on);%%% %%config.setInstanceName("ExampleInstance");%%% %%%% %%return%Hazelcast.newHazelcastInstance(config);%%% }%%
  • 12. @jongallimore | #TomEE Other approaches •  Session replication filter –  http://hazelcast.com/use-cases/web-session-clustering/generic-web-session-replication/ –  Native version for Tomcat / Jetty for Enterprise users •  POC to share state for Stateful EJBs in TomEE using Hazelcast