This post describes a very simple library versioning scheme using a class loader and jar file identified by its URL.
Versioning is a common challenge in commercial software development. The most common technique to support multiple versions of a library, executable or framework, in Java or Scala relies on the class loader.
A library can be easily versioned by creating multiple jar files, one for each version.
Versioning is a common challenge in commercial software development. The most common technique to support multiple versions of a library, executable or framework, in Java or Scala relies on the class loader.
A library can be easily versioned by creating multiple jar files, one for each version.
Simple implementation
Let's select a simple case for each a library is self-contained in a jar file with two versions
The first step consists of loading the two versions of the library through their URL by converting each jar file names to a URL. This feat is accomplished by instantiating the class loaders: In this particular case, the class loader is undefined by its URL with the type URLClassLoader (line 5 & 9). The jar files are loaded within the current thread (line 7 & 11): A more efficient approach would consists of creating a future to load the classes asynchronously.
The class to be used in this case depends on the variable version (line 15). Once the appropriate class is loaded, its instance and method are ready available to the client be invoked.
- ArrayIndex1.jar
- ArrayIndex2.jar
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import java.net.{URL, URLClassLoader} import java.io.File import java.lang.reflect.Method val cl1 = new URLClassLoader( Array[URL](new File("ArrayIndex1.jar").toURL), Thread.currentThread().getContextClassLoader() ) val cl2 = new URLClassLoader( Array[URL](new File("ArrayIndex2.jar").toURL), Thread.currentThread().getContextClassLoader() ) val compatibleClass: Class[_] = if( version > 0.9) cl1.loadClass("ArrayIndex") else cl2.loadClass("ArrayIndex") val obj = compatibleClass.newInstance val methods = compatibleClass.getMethods println(s"${methods.map( _.getName).mkString(",")}") |
The first step consists of loading the two versions of the library through their URL by converting each jar file names to a URL. This feat is accomplished by instantiating the class loaders: In this particular case, the class loader is undefined by its URL with the type URLClassLoader (line 5 & 9). The jar files are loaded within the current thread (line 7 & 11): A more efficient approach would consists of creating a future to load the classes asynchronously.
The class to be used in this case depends on the variable version (line 15). Once the appropriate class is loaded, its instance and method are ready available to the client be invoked.
Excellent post!!! Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities.Java Course in Chennai | Best JAVA Training in Chennai
ReplyDeleteTo learn shorter programs when compared to Java then it is the right time to choose python training. There is increasing market demand for professionals who have completed python training.
ReplyDeletepython training in chennai | python training institutes in chennai
Nice post Thanks for the Sharing this information Big Data Hadoop Training | PHP Training in Noida
ReplyDeleteSas Training Institute in Noida-Webtrackker is the best sas training institute in noida. SAS has taken the lead role for a long time, where most companies have standard software. While you have this certification under your belt, give big rewards to the IT industry, it can also serve as an important payer on the business side of the economy. SAS can read data files created by other statistical packages. Therefore, for experienced users of these statistical packages, SAS does not threaten to create data files created by these packages in a SAS file format.
ReplyDeleteSap Training Institute in Noida
PHP Training Institute in Noida
Hadoop Training Institute in Noida
Oracle Training Institute in Noida
Linux Training Institute in Noida
Dot net Training Institute in Noida
Salesforce training institute in noida
Java training institute in noida
Hadoop Training Institute in Noida- Webtrackker is the best Hadoop training institute in noida. If you want take the training in a Hadoop than Webtrackker is the best option for you. Since then Hadoop has continued with the development of the YARN cluster manager, releasing the project from its first distribution of HadoopMap Reduce. HadoopMap Reduce is still available in Hadoop to perform static batch processes for which Map Reduce is suitable. Other data processing activities can be assigned to different processing engines (including Spark), where YARN manages the management and allocation of cluster resources.
ReplyDeleteProjects like Apache Mesas provide a powerful and growing range of distributed cluster management capabilities. Most Spark implementations still use Apache Hadoop and its associated projects to meet these requirements.
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
ReplyDeletehttps://www.besanttechnologies.com/training-courses/java-training
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.
ReplyDeletehttps://www.besanttechnologies.com/training-courses/java-training
Webtrackker Indirapuram offers an inclusive software testing training in Indirapuram. The extensive practical training provided by the Software Testing training institute in Indirapuram, equips live projects and simulations. Such a detailed course in Software Testing has helped our students to obtain work in several multinationals. The Webtrackker trainers are subject to specialized corporate professionals who offer an in-depth study in the Software Testing course in Indirapuram.
ReplyDeletesoftware testing institute in Indirapuram
Aws online training in india
ReplyDeleteSalesforce online training in india
SAS training institute in noida
ReplyDeletephp training institute in noida
linux training institute in noida
cloud Computing Training in Noida
hadoop training institute in noida
SAS training institute in noida
ReplyDeletephp training institute in noida
linux training institute in noida
cloud Computing Training in Noida
hadoop training institute in noida
Python R Training Institute in Noida
Oracle DBA online training in India
ReplyDeleteNEW YEAR OFFERS 2018
ReplyDeleteFlipkart New Year Offers on Mobile Phones
Ebay New Year Offers On Mobile Phones
SEO Company In Cape Town
ReplyDeleteSEO company in Durban
SEO Company in india
SEO company in Johannesburg
Seo company in zimbabwe
ReplyDeleteSeo company in washington
Seo company in wakefield
Seo company in virginia
Seo company in usa
Sirkus System Bangalore Reviews- Sirkus System IT Services Pvt Ltd a logo name specialized in product improvement & answers for mobile environment and other platforms Sirkus device Bangalore critiques- Quality development, dedicated work approach and professional attitude are some of the traits which outline Sirkus Systems IT Services Pvt Ltd.
ReplyDeleteSirkus system
sirkus system
Sirkus Systems
sirkus system review
Sirkus System
Sirkus System Reviews
Sirkus System
Sirkus System Review
Java training in indirapuram- There are multiple structures and streams for developing a product or utility. When we talk of technology and programming languages, Java is the maximum desired platform. It is used to expand a whole lot of programs for the systems and embedded devices like cellular telephones, drugs, laptops, and many others.
ReplyDeleteJava training in indirapuram
Hadoop training in indirapuram
sas training in indirapuram
sap training in indirapuram
linux training in indirapuram
sap fico training in indirapuram
web design training in indirapuram
php training in indirapuram
Best Hadoop Training Institutes In Noida
ReplyDeletebest sas training institutes in noida
best sap training institutes in noida
best linux training institutes in noida
best salesforce training institutes in noida
best software testing training institutes in noida
best python training institutes in noida
ReplyDeletebest oracle training institutes in noida
best android training institutes in noida
best php training institutes in noida
best web design training institutes in noida
best java training institutes in noida
best sap mm training institutes in noida
best sap sd training institutes in noida
best sap hr training institutes in noida
ReplyDeletebest tableau training institutes in noida
best automation anywhere training institutes in noida
best rpa training institutes in noida
best blue prism training institutes in noida
best digital marketing training institutes in noida
best angularjs 5 training institutes in noida
ReplyDeletebest net training institutes in noida
best aws training institutes in noida
best cloud computing training institutes in noida
Vermeer
ReplyDeleteAutocAD
ReplyDeleteBest Autocad training in delhi
AutoCAD Summer Training in Uttam Nager
AutoCAD Summer Training in Delhi
I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
ReplyDeleteIBM BPM Online Training in Chennai
IBM BPM Online Training
aws training institute in noida
ReplyDeletebest data science training institute in delhi
python Training Institute in noida
sas Training Institute in noida
linux Training Institute in noida
Salesforce Training Institute in Noida
ReplyDeleteSalesforce Training in noida
Best Salesforce Training Institutes in Noida
Best Aws Training Institutes in Noida
best aws training in noida
I red this blog and i like the way of you expressing the ideas.please update such kind of informations in future.
ReplyDeleteweb designing course in chennai
SEO Training in Chennai
Big Data Training in Chennai
Hadoop Training in Chennai
Android Training in Chennai
Selenium Training in Chennai
Digital Marketing Course in Chennai
JAVA Training in Chennai
best german classes in chennai
german classes in chennai
German classes in OMR
best php training institute in noida
ReplyDeletephp training in noida
android training institute in noida
android apps training institute in noida
best android training institute in noida
android training in noida
Dot net training institute in noida
best Dot net training institute in noida
Dot net training in noida
web design training institute in noida
best web design training institute in noida
web design training in noida
Best sap training institute in Noida
ReplyDeletesap training in Noida
Java Training Institute in Noida
best Java Training Institute in Noida
Java Training in Noida
Digital Marketing Training Institute in Noida
Best Digital Marketing Training Institute in Noida
Digital Marketing Training in Noida
Software Testing Training institute in Noida
Best Software Testing Training institute in Noida
Software Testing Training in Noida
Salesforce training institute in noida
Best Salesforce training institute in noida
Salesforce training in noida
php training institute in noida
Cloud Computing Training Institute in Noida
ReplyDeleteBest Cloud Computing Training Institute in Noida
Cloud Computing Training in Noida
Oracle dba training institute in Noida
Oracle training institute in Noida
Best oracle training institute in Noida
sap training institute in Noida
python training institute in noida
ReplyDeletesolidworks training institute in noida
sap fico training institute in noida
linux training institute in noida
Hadoop training institute in noida
aws training institute in noida
Autocad training institute in noida
ReplyDelete6 weeks industrial training in noida
Data Science With python training Institute in Noida
sas training institute in noida
machine learning training Institute in Noida