10 Primavera P6 Tools to Supercharge Your Productivity

XER cleaner and XER analyzer are type of tools and solutions which can be useful if Oracle Primavera P6 is used to create the project schedule in your …

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Implementing Java Interfaces in Clojure

As the micro-service was written in Clojure, we had the challenge to implement quartz scheduler interfaces which are primarily written in Java.

So, we decided to go with Java implementation.

Hence, we landed up against this challenge of implementing interfaces given in Java by quartz scheduler in Clojure.

Going over the internet found various techniques to implement interfaces which Clojure provides.

Firstly, let me shed some light on quartz scheduler and the interfaces it provides. Quartz has concept of Job (containing info about job i.e. which class to be executed and metadata) and Triggers (time at which it needs to be triggered i.e. firing time and job which is executed).

To execute custom actions, we need to create a class which implements Job and pass the literal to Job for executing at the firing time.

Clojure provides you with four ways to implement or extend java class which are discussed in detail.

Here is the small implementation of execute method from Job interface.

To call execute function on object:

Pros using Proxy:

Cons:

Here is the small implementation of execute method from Job interface.

One more thing, gen-class demands ahead-of-time compilation. So, you must turn on :aot feature for this namespace in your project configuration.

To call execute function on object:

The main difference which you find are type of objects which both approach create.

Pros using gen-class:

Cons:

Reify doesn’t need ahead of time compilation.

Reify and Proxy are pretty much similar in their behavior.

There are some differences such as:

proxy and reify were functionally same for us (We didn’t needed any super class method call). But, as these both approaches create anonymous class we were unable to reference. Whereas, gen-class provides us the named class objects.

Happy Clojure !!

Add a comment

Related posts:

Html to wordpress converter software free download

CMS2CMS online migration service your website HTML to WordPress migration is uncomplicated, pr. May 31, 2021 · Follow the following steps: Create a zip file. Go to WordPress and select appearance…

Understanding Neural Style Transfer

Learn the intricate working of style transfer and how the loss function are defined to get better understanding of neural style transfer.

Try Again

There is one thing we don’t give up on, and that is breathing. It might be labored or wheezy, but we keep breathing until we can’t anymore. I think that has to be, hands down, the only thing none of…