Recently I volunteered myself to do some of the Spring integration for Hazelcast, for one main reason actually.. I had always wondered how to actually do that. It is something you don't get to do often in a corporate working environment. As with most things Spring related it actually turned out to be very simple.
First thing I needed to do was define a schema for the Hazelcast xml config. If you want to add your custom XML configuration into Springs', it will require that you have a schema for the specific XML.
So what is the quickest way to get started on a schema? Altova XML Spy, it generates a basic XSD form a sample XML which takes care of about 40% of the actual work. Then it's all about the details, min / max constraints, enumerations, defaults, attributes and documentation. I believe XSDs should be verbose, so the version below is not 100% complete but it is a good starting point.
I am not going to add the XSD to this post as is quite long and doesn't add much with regards to the actual Spring integration. If interested, it is available here...
On the Spring side you need the following:
1. An implementation of: NamespaceHandlerSupport, this basically tells Spring when it finds "hazelcast" use the "HazelcastBeanDefinitionParser".
2. An implementation of: AbstractSimpleBeanDefinitionParser. This implementation actually processes the XML from the Spring application config. You need to override
getBeanClass and doParse methods, to specify what type of object and how to create it respectively.
3. 2 files in the META-INF
3.1. A spring.handlers file containing the namespace and the NamespaceHandlerSupport implementation (in my case):
http\://www.hazelcast.com/schema/config=com.hazelcast.spring.HazelcastNamespaceHandler
3.2. A spring.schemas file containing the location of the schema:
http\://www.hazelcast.com/schema/config/hazelcast-basic.xsd=hazelcast-basic.xsd
and that is it...
The XML you described in your XSD is now available to be used within your the Spring config.
The example below is a Hazelcast map cache config, which can then be injected where required as ref="config".
The source and tests for this are available in the Hazelcast code project here.
Subscribe to:
Post Comments (Atom)
Popular Posts
-
I have recently been slacking on content on my blog, between long stressful hours at work and to the wonderful toy that is an iPhone, I have...
-
I make no claim to be a "computer scientist" or a software "engineer", those titles alone can spark some debate, I regar...
-
I saw an article (well more of a rant) the other day, by Rob Williams Brain Drain in enterprise Dev . I have to say, I do agree with some o...
-
This series of posts will be about me getting to grips with JBoss Drools . The reasoning behind it is: SAP bought out my company's curre...
-
Update: Check out my updated re-certification on the new 2019 exam... here Let me start by saying, for this certification I studied and...
Is the schema location correct?
ReplyDeletehttp://www.hazelcast.com/schema/config/hazelcast-basic.xsd
Hi,
ReplyDeleteNope, they never did publish it to that URL. This was just an example and the initial version I did for them and unfortunately I haven't had any time to dedicate much more to Hazelcast.
This is cool. Thanks, Brian. Even though I am reading it much later than when you published it, the information is very valuable.
ReplyDeleteHello sir, I got you by Google search.
ReplyDeleteIt is really helpful article about the topic of briandupreez.net.It is very helpful in using social media sites. I so much interest about your article. I know it is not any simple information. This is very nice post! I will bookmark this blog as I have Greater Eviction Service Solutions provides fast, efficient, and professional eviction services for property owners in Austin, Florida. Demand an eviction these days.
Thanks for the great post.
It's nice that there are such blogs.
ReplyDeleteNice blog with excellent information. Thank you, keep sharing.
ReplyDeleteBest Paper Products Manufacturer Company | Thoran Paper Products
Liên hệ Aivivu, đặt vé máy bay tham khảo
ReplyDeletevé máy bay đi Mỹ giá rẻ 2021
chuyen bay tu my ve vietnam
lich bay tu duc ve viet nam
vé máy bay từ nhật bản về việt nam
Các chuyến bay từ Incheon về Hà Nội hôm nay
vé máy bay từ canada về việt nam
chuyen bay chuyen gia trung quoc