DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

The Latest Popular Topics

article thumbnail
How to Use String Data to Empower Your Similarity Search Applications
As a vector database, Milvus 2.1 supports string data types, which can vastly streamline the process of building an application with Milvus.
August 17, 2022
by xi ge
· 3,643 Views · 1 Like
article thumbnail
Lambda Functions Help AI Developers Easily Create DataFrames in Python
One of the best ways to create more versatile machine learning applications in Python is to use lambda functions to create DataFrames.
August 17, 2022
by Ryan Kh
· 7,522 Views · 2 Likes
article thumbnail
Step by Step Guide to Create Mule Custom Connector Using Java SDK
This tutorial guides you to create a custom connector for Mule 4 which includes both Source and Operation components.
Updated August 17, 2022
by Jitendra Rawat
· 4,431 Views · 2 Likes
article thumbnail
What to Know About Python and Why Its the Most Popular Today
Python is an incredibly versatile programming language that can be used for data science projects, data analysis, machine learning, and data visualization.
Updated August 16, 2022
by Aashutosh Kumar Yadav
· 8,882 Views · 4 Likes
article thumbnail
Top 10 Java Language Features
Let's explore ten Java programming features used frequently by developers in their day-to-day programming jobs.
August 15, 2022
by A N M Bazlur Rahman DZone Core CORE
· 9,375 Views · 14 Likes
article thumbnail
On Cosmetics vs. Intrinsics in Programming
Code has cosmetic and intrinsic characteristics. See examples demonstrating how to achieve the same intrinsic with different cosmetics and vice versa.
August 15, 2022
by Nicolas Fränkel
· 4,147 Views · 2 Likes
article thumbnail
How To Build a Multi-Zone Java App in Days With Vaadin, YugabyteDB, and Heroku
Welcome to my journal documenting my experience building a geo-distributed app in Java from scratch. Here, I’ll share my first results and any challenges.
August 15, 2022
by Denis Magda DZone Core CORE
· 7,401 Views · 8 Likes
article thumbnail
How to Upgrade TiDB Safely
How to use this toolkit to test your upgrade process and how it helps you upgrade your TiDB with ease and happiness.
August 15, 2022
by Canyu Zhang
· 4,867 Views · 2 Likes
article thumbnail
AI Not Living Up to the Hype? It’s a Communications Problem
The limiting factor is an inability to tell AI what to do without having to use technical details and code.
August 15, 2022
by Christian Frederiksen
· 6,324 Views · 1 Like
article thumbnail
Brewing Patterns in Java: An Informal Primer
Thoughts on pattern matching, records, and sealing.
August 14, 2022
by Manoj N Palat
· 6,496 Views · 7 Likes
article thumbnail
Neural-Symbolic Regression: Distilling Science from Data
Learn about neural-symbolic regression, how data scientists can make use of these algorithms, and what the future holds for them within deep learning.
August 14, 2022
by Kevin Vu
· 6,310 Views · 1 Like
article thumbnail
Why "Polyglot Programming" or "Do It Yourself Programming Languages" or "Language Oriented Programming" sucks?
Last year we saw the launch of a new Web programming language Dart - Structured Web Programming from Google. A very interesting approach to support web application development. Not so long after Go, Groovy, Ruby, Scala, << Name your DSL here >>; we see Dart. Is it a good thing to have at least one programming language to solve one problem? The answer is, like we already know, it depends. Stay Away From “Do it Yourself” It is your choice as to if you will try to do things yourself or allow the truly seasoned professionals to help out. Some decide that they are going to try to go it alone when they are programming something new, but this often ends up in a less than desirable place. It may even be more expensive than just hiring an expert who can help you get it programmed for you in the first place. Most people do not go it alone with the vast majority of important services in their life, so why should they ever attempt to do so when they are looking at how to create a website? It is best to avoid making this mistake, and just try to make some progress towards your goals by hiring people who truly know how to help you make the progress that you need to make. Some important backgrounds you should know about the multi-programming language paradigm are the following: 1. You can read Martin Fowler's article about language-oriented programming with language workbenches which enables you to write small programming languages easily. In this article I see everyone writing their small language, everywhere. In this concept, we see DSL (Domain Specific Language) as the future of our programming activities. Source: http://martinfowler.com/articles/languageWorkbench.html 2. Neal Ford talked about Polyglot Programming, combining multiple programming languages in application development. Later Mr. Fowler added this paradigm with Polyglot Persistence, using different types of databases within one application. Source: http://memeagora.blogspot.com/2006/12/polyglot-programming.html and http://martinfowler.com/bliki/PolyglotPersistence.html Since 2006 I already discussed and collected some experiences in multi programming language paradigm: 1. I remember a “hot” discussion in 2006 with Sebastian Meyen, chief editor of JavaMagazin Germany, also the biggest organizor of Java Conference JAX. We agreed to see the future of programming in a multi-language paradigm concept. I also said that all those languages will be based on Java VM. I also told him that one day SAP will move ABAP as a language that can be run within the Java VM, so just another language within the Java environment, with no two different personalities anymore. Today we see the beginning of this in the project called Caffeine ABAP. Source: https://cw.sdn.sap.com/cw/groups/caffeine 2. Also in 2006 I had a project in which we also used different kinds of languages and also created our own DSL: Java for the most implementation stuff UML for the design of the business objects. We generate a lot of things using the concept of MDA (Model Driven Architecture) Groovy for a lot of things, especially for writing unit tests Based on ANTLR we create our own DSL for some aspects of the application It was really exciting and we had some very good programmers in the project. The result was a very nice and flexible product, just as what we expected at the beginning of the project. Please read this article in the German language for more information: http://www.sigs.de/publications/os/2009/02/dewanto_egger_OS_02_09.pdf So after all those nice things about the multi-language paradigm, I told you, why does this suck at the end? Here are some reasons from my point of view: 1. As typical in application development the problem comes first in the maintenance phase after all the capable programmers leave the project. Did you, programming language creators ever try to teach a new programming language to a “normal”, 9 till 5 programmers? I’m not talking about 9 (am) till 9 (pm) programmers who love to learn new languages. It is definitely tough to be proficient in one programming language. This is comparable with the languages we speak every day. I’m not a native English speaker, so I’m quite sure that I made a lot of syntax and grammar errors in this article. It is possible to be able to speak three or four languages perfectly but this is an exception. 2. Did you ever try to maintain a big Struts web application with AJAX? Just try to add functionality and you will end up creating and editing a lot of files: Action and Form files, Struts XML configuration files, JavaScript files with JSON, and also HTML or JSP files. Can you imagine adding Groovy, Scala, and Dart additionally into that web app? The complexity of such a project is very high. 3. Creating a new programming language means that you also have to build the environment for it. Good IDE, good documentation, good community support, a clear roadmap, and backward compatibility are some points to be done. Groovy is a bad example of this. In the early version of this language, the editor for Eclipse was really bad. After a while, they improved the editor but they made a lot of basic changes in the language so your old groovy applications do not work anymore. You are punished if you update to the new version. This never happens to Java. You still can compile Java 1.1 applications with Java 6 compiler. 4. Before you are creating your own DSL with e.g. ANTLR ask those language Gurus first, how hard it is to maintain a programming language for the long term. Before you discuss with them don’t ever create your own DSL. Especially if you are working for SME (Small and Medium-sized Enterprise). With a small team and small budget, you will never ever maintain your own language decently. So in year 2012, six years after my support to Polyglot Programming, I hope to see following things happen: 1. One language for all aspects in one application is the best concept ever. I name this as “One for All Programming Language paradigm”. Just like we don’t use English as a technical language, German as a literate language, and Indonesian as a community language, to be able to communicate internationally with each other we just use English pragmatically for all aspects of our life. In Germany, you need to speak German in all aspects to be able to communicate with others. My best solution so far is Java + XML, that’s it, no more, no less. No mixing with Groovy, Dart, Ruby, Scala, <> in one application. Especially if you are working as a contractor, please don’t try to use all those languages just for a small Java web application. I don’t say that you should not use the other languages at all. The only thing which is important is not to mix those languages in one application. In SME you may also want to use just one programming language for all your applications. 2. Concept like GWT (Java to JavaScript compiler) or XMLC (XML compiler which compiles XML, HTML to Java classes) is great. You can work just in plain Java. Guice with all Java and no XML is also a great solution (I know that SpringFramework is also doing this with Annotations). Android is great because it uses Java as its application programming language. In conclusion, I can only hope to see more such pure and plain Java solutions in 2012!
August 13, 2022
by Lofi Dewanto
· 14,395 Views · 5 Likes
article thumbnail
Using AI To Improve Your Predictive Capabilities
Let's take a quick look at how you can use Artificial Intelligence to improve your predictive capabilities.
Updated August 13, 2022
by Adi Gaskell
· 6,085 Views · 1 Like
article thumbnail
Total Bummer: Pivotal Drops Groovy
Pivotal announced yesterday that Groovy 2.4 And Grails 3.0 will be the last major releases under Pivotal sponsorship. This is big news that has not surprisingly created a lot of buzz in the blogosphere. In this post, I describe some of the questions that others and I are wondering about and speculate on Groovy's future. Groovy’s Future is in Doubt Sadly, it appears at this time that is more likely than not that Groovy does not have a significant future ahead. It would seem that the developers of this program are going to allow it to rot away instead of taking any action steps to potentially stave off such an outcome. It seems from the statements put out by Pivotal that they are likely to nix Groovy due to a general lack of use among its customer base and the inability of the company to keep up with everything that it needs to in order to continue to offer this service to those who are still using it. We are sorry to say that it appears that Groovy is on its way out even though we don’t want it to be. Sometimes, that is just the way that these things go. After reading multiple Reddit references to this announcement, my initial thought was to see what Guillaume Laforge had to say about this. Apparently, a lot of people had the same idea because I encountered a 503 error when trying to access his page. Fortunately, I did not have to wait for Laforge's blog to be available to get more insight from him on this announcement because there were a couple of interviews with him regarding the announcement already online: Voxxed.com's Pivotal’s "Sad and Odd'' Decision to Set Groovy Adrift and InfoQ's Pivotal Pulls Groovy/Grails Funding. Since that time, Laforge's blog is available again and has a post on the subject calledThe Groovy project is looking for a new home. Another person frequently and deservedly associated with Groovy, Graeme Rocher, has also posted on the subject: The Future of Groovy and Grails Sponsorship. Laforge and Rocher were co-founders of G2One, which was acquired by SpringSource in late 2008. VMWare then acquired SpringSource about one year later (and VMWare had been owned by EMC since late 2003). EMC would later announce the spin-off of Pivotal in 2013 and Pivotal today announced the dropping of Groovy support as of 21 March 2015. Questions, Answers, and Speculations The posts referenced here in my post have collectively answered some of my questions about Groovy and at the same time presented additional questions. Why is Pivotal dropping the financial support of Groovy and Grails? Answer: Pivotal's announcement: "The decision to conclude its sponsorship of Groovy and Grails is part of Pivotal’s larger strategy to concentrate resources on accelerating both commercial and open source projects that support its growing traction in Platform-as-a-Service, Data, and Agile development. Pivotal has determined that the time is right to let further development of Groovy and Grails be led by other interested parties in the open source community who can best serve the goals of those projects." Who Might Sponsor Groovy and/or Grails Development? Speculation: Many organizations benefit from Groovy and Gravy, but many probably aren't prepared to invest as fully in their development as G2One, SpringSource, VMWare, and even Pivotal have been. An example of an organization with an obvious vested interest in Groovy's future is GradleWare. Ken Kousen has tweeted and written a blog post on the opportunity of acquiring Groovy and Grails sponsorship. What does this announcement mean for Groovy's future? Answer Mixed with Speculation: Based on Laforge's and Rocher's posts, it seems clear that the core developers plan to continue working on Groovy. However, it is understandable that if this effort is not funded (sponsored), it will have to be at a slower pace than before (I have found through personal experience that home projects take a lot longer to complete than paid projects). I believe that Groovy has strong momentum already that will continue for some time. It is vital to Gradle, is used with other open source projects and tools such as SoapUI, and could have a promising future running on Android. I primarily use Groovy for scripting and simple "glue" tools in Java applications. The language is mature and serves these purposes well and I see no reason to stop using it at this time. What does this mean for the future of the Spring Framework? Speculation: There is some concern that perhaps Spring Framework could be jettisoned next from Pivotal. This seems unlikely to me, but I didn't expect Pivotal to drop Groovy either. As much as I love Groovy and as much effect on Java and JVM development as I acknowledge it has had, I think Spring Framework has been even more pervasive in Java EE development than Groovy and Grails have been in Java SE and Java EE development. That stated, Pivotal has shown that they are willing to, as most successful businesses are, drop a product offering that is perceived as not benefiting their strategy and bottom line. I can certainly understand if this development concerns users of Spring. Is Standards-Based More Important than Being Open Source? Answer: This is a difficult question to answer that often depends on numerous contextual factors including the tools being compared, the expected length of life of the products being built, etc. Fortunately, we often don't have to choose between these as many reference implementations in the Java world are also open source. However, a point can be made that any product that is not standard (including commercial or proprietary) is subject to losing support or not being available any longer. The theory is that if standards-based products are used, one can then shift to another implementation of that standard if necessary. However, a standard is only as good as its implementations and if there is only one realistic implementation of a standard, there's not much of an advantage of transferability there. Conclusion Although I understand Pivotal's motivation for dropping Groovy, I am still sorry to hear that news. I appreciate the effort that key Groovy contributors such as Laforge and Rocher have made and I appreciate the companies that have sponsored that work. Through this sponsorship and work, we have a really nice language to use for scripting and other purposes. I hope that a sponsor can be found for Groovy, but I plan to continue to use it either way.
August 13, 2022
by Dustin Marx
· 13,106 Views · 1 Like
article thumbnail
The 5 Most Promising Frameworks of the First Half of 2016
An in-depth look at what distinguishes some newer JavaScript frameworks like Polymer, Aurelia, Meteor, Webix, and React.
Updated August 13, 2022
by Ivan Petrenko
· 42,881 Views · 37 Likes
article thumbnail
Parsing JavaScript with JavaScript
Over the weekend I started working on llamaduck- a simple tool that aims to figure out whether your code will run on the newly released node 0.6.0. Eventually, it might be able to perform other compatibility assessment tasks as well, but I’m focusing on simple stuff first. Or at least I thought it was simple. The list of API changes since 0.4.x doesn’t seem that long and it should be easy enough to digest. But as it turns out, I spent almost all of Sunday just figuring out how to turn javascript into a beautiful analyzable AST. If you don’t know what an AST is – it’s a so-called abstract syntax tree, which means it should look identical regardless of what the actual syntax is. Although it will differ for different languages. So a CoffeeScript AST should look the same as JavaScript, but Python’s will differ. JavaScript Alterations and Changes There are so many JavaScript alterations and changes that one may need to make as they work through the program that it is undoubtedly challenging for some people to keep up with precisely what they are supposed to do to take care of things like this. What is known is that JavaScript alterations and changes can make life a lot more challenging for you in the short term, but it will pay off with a better product in the long run. What I discovered was that there were a lot of changes that needed to be made to get JavaScript to line up just the way that I wanted it to. There are so many small and technical aspects of this kind of coding that need to be adhered to down to the letter, and it is certainly not easy to pull it off until one has a lot of time to sit down and figure out what they need to do. JavaScript remains the dominant language used by computer programmers to put their materials out onto the Internet, so it made a lot of sense to me to start using this as a primary tool to get my own work done as well. I have continued to rely on JavaScript for projects both large and small, and I know that the only way that I get the most possible value out of it is to use it in ways that are effective for my customers. The increased use of JavaScript for all programmers is something that has led me to believe that I must continue working on ways to make the most out of my time with this program and the skills that I know can be applied in the best ways possible to get my desired results. When running JavaScript through the actual JavaScript program, it is common for programmers to run into some common issues. There are lines of exceptions that may appear at times, and there are other situations that arise which make it obvious that a certain piece of code is just not going to work as desired. If you run into that problem, just know that this is what the process is all about. Running the JavaScript through the program first is a great way to make sure those errors and omissions are eliminated from the final product. Look over every piece of this very carefully and make sure you understand what you are looking at. You may just discover that there is a lot more that you could be doing to help out your users after all. My research came up with three options: Take a parser generator and a JavaScript grammar, and hope for the best JSLint has a parser … somewhere around line 2000 Uglify-JS supposedly has a parser too The only viable option was uglify-js. It’s a neatly packaged node.js module that does a bit more than I need, but at least it’s got an easy-to-use parser with an exposed API interface. Score! Here’s an example of a file that outputs its own AST to give you a feel for what I’m talking about: var parser = require('uglify-js').parser; var util = require('util'); (function get_ast (path, callback) { require('fs').readFile(path, 'utf-8', function (err, data) { if (err) throw err; callback(parser.parse(data)); }); })('./example.js', function (data) { console.log(util.inspect(data, true, null)); }); The file parses itself and outputs a tree encoded as a javascript array (scroll past the insanity, there’s a bit more text there): [ 'toplevel', [ [ 'var', [ [ 'parser', [ 'dot', [ 'call', [ 'name', 'require', [length]: 2 ], [ [ 'string', 'uglify-js', [length]: 2 ], [length]: 1 ], [length]: 3 ], 'parser', [length]: 3 ], [length]: 2 ], [length]: 1 ], [length]: 2 ], [ 'var', [ [ 'util', [ 'call', [ 'name', 'require', [length]: 2 ], [ [ 'string', 'util', [length]: 2 ], [length]: 1 ], [length]: 3 ], [length]: 2 ], [length]: 1 ], [length]: 2 ], [ 'stat', [ 'call', [ 'function', 'get_ast', [ 'path', 'callback', [length]: 2 ], [ [ 'stat', [ 'call', [ 'dot', [ 'call', [ 'name', 'require', [length]: 2 ], [ [ 'string', 'fs', [length]: 2 ], [length]: 1 ], [length]: 3 ], 'readFile', [length]: 3 ], [ [ 'name', 'path', [length]: 2 ], [ 'string', 'utf-8', [length]: 2 ], [ 'function', null, [ 'err', 'data', [length]: 2 ], [ [ 'if', [ 'name', 'err', [length]: 2 ], [ 'throw', [ 'name', 'err', [length]: 2 ], [length]: 2 ], undefined, [length]: 4 ], [ 'stat', [ 'call', [ 'name', 'callback', [length]: 2 ], [ [ 'call', [ 'dot', [ 'name', 'parser', [length]: 2 ], 'parse', [length]: 3 ], [ [ 'name', 'data', [length]: 2 ], [length]: 1 ], [length]: 3 ], [length]: 1 ], [length]: 3 ], [length]: 2 ], [length]: 2 ], [length]: 4 ], [length]: 3 ], [length]: 3 ], [length]: 2 ], [length]: 1 ], [length]: 4 ], [ [ 'string', './example.js', [length]: 2 ], [ 'function', null, [ 'data', [length]: 1 ], [ [ 'stat', [ 'call', [ 'dot', [ 'name', 'console', [length]: 2 ], 'log', [length]: 3 ], [ [ 'call', [ 'dot', [ 'name', 'util', [length]: 2 ], 'inspect', [length]: 3 ], [ [ 'name', 'data', [length]: 2 ], [ 'name', 'true', [length]: 2 ], [ 'name', 'null', [length]: 2 ], [length]: 3 ], [length]: 3 ], [length]: 1 ], [length]: 3 ], [length]: 2 ], [length]: 1 ], [length]: 4 ], [length]: 2 ], [length]: 3 ], [length]: 2 ], [length]: 3 ], [length]: 2 ] Conclusion Now we have a simple tree we can recursively analyze and look for incompatibilities. But before anything really practical can be done I need to figure out how to track variable scope. That’s really the hard bit because the code needs to check when variables become a critical section and then confirm that they do in fact eventually get used in a critical way. But once that nut is cracked llamaduck will be a neat little tool useful for many things. If you’ve got some coding inclination, I’d love a helping hand over at the llamaduck github repo. Related articles Lessons From A Review Of JavaScript Code (coding.smashingmagazine.com) ParserPlayground partial internals update (leuksman.com) Google Closure Introduction (googleclosure.wordpress.com) Announcing JesCov – JavaScript code coverage (olabini.com) Polyglot programming – combining functional, dynamic and imperative languages (mindscapehq.com)
August 13, 2022
by Swizec Teller
· 10,060 Views · 1 Like
article thumbnail
Openshift and AWS Lambda Deployment With Quarkus
Nowadays Quarkus is known as Supersonic Subatomic Java. It provides a lot of features to facilitate build and deployment.
Updated August 13, 2022
by Elina Valieva
· 12,407 Views · 5 Likes
article thumbnail
Migrate Serialized Java Objects with XStream and XMT
Java serialization is convenient to store the state of Java objects. However, there are some drawbacks of serialized data: It is not human-readable. It is Java-specific and is not exchangeable with other programming languages. It is not migratable if fields of the associated Java class have been changed. These drawbacks make Java serialization not a practical approach to storing object states for real-world projects. In a product developed recently, we use XStream to serialize/deserialize Java objects, which solves the first and second problems. The third problem is addressed with XMT, an open source tool developed by us to migrate XStream serialized XMLs. This article introduces this tool with some examples. Computer Languages Need to be Simplified So many of the issues that we all run into when we are working on converting computer languages into something that can be better understood by human beings is the fact that computer languages need to be simplified if possible. These languages are great for the computers that speak back and forth with one another, but they don’t necessarily work out as well when humans try to become involved with them. Many humans end up confused and unable to make much progress at all on getting these systems cleared up. Thus, it is necessary to get them cleaned up and made more usable. There are people who are actively working on this problem right now, but in the meantime, we may simply have to deal with computers that can’t do everything we would like for them to do. XStream deserialization problem when class is evolved Assume a Task class below with a prioritized field indicating whether it is a prioritized task: package example; public class Task { public boolean prioritized; } With XStream, we can serialize objects of this class to XML like below: import com.thoughtworks.xstream.XStream; public class Test { public static void main(String args[]) { Task task = new Task(); task.prioritized = true; String xml = new XStream().toXML(task); saveXMLToFileOrDatabase(xml); } private static void saveXMLToFileOrDatabase(String xml) { // save XML to file or database here } } The resulting XML will be: true And you can deserialize the XML to get back task object: import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; public class Test { public static void main(String args[]) { String xml = readXMLFromFileOrDatabase(); Task task = (Task) new XStream(new DomDriver()).fromXML(xml); } private static String readXMLFromFileOrDatabase() { // read XML from file or database here } } Everything is fine. Now we find that a prioritized flag is not enough, so we enhance the Task class to be able to distinguish between high priority, medium priority and low priority: package example; public class Task { enum Priority {HIGH, MEDIUM, LOW} public Priority priority; } However, deserialization of previously saved XML is no longer possible since the new Task class is not compatible with the previous version. How does XMT Address the Problem XMT comes to the rescue: it introduces the class VersionedDocument to version serialized XMLs and handles the migration. With XMT, serialization of task object can be written as: package example; import com.pmease.commons.xmt.VersionedDocument; public class Test { public static void main(String args[]) { Task task = new Task(); task.prioritized = true; String xml = VersionedDocument.fromBean(task).toXML(); saveXMLToFileOrDatabase(xml); } private static void saveXMLToFileOrDatabase(String xml) { // save XML to file or database here } } For task class of the old version, the resulting XML will be: true Compared with the XML generated previously with XStream, an additional attribute version is added to the root element indicating the version of the XML. The value is set to "0" unless there are migration methods defined in the class as we will introduce below. When Task class is evolved to use enum based priority field, we add a migrated method like the below: package example; import java.util.Stack; import org.dom4j.Element; import com.pmease.commons.xmt.VersionedDocument; public class Task { enum Priority {HIGH, MEDIUM, LOW} public Priority priority; @SuppressWarnings("unused") private void migrate1(VersionedDocument dom, Stack versions) { Element element = dom.getRootElement().element("prioritized"); element.setName("priority"); if (element.getText().equals("true")) element.setText("HIGH"); else element.setText("LOW"); } } Migration methods need to be declared as a private method with the name in the form of "migrateXXX", where "XXX" is a number indicating the current version of the class. Here method "migrate1" indicates that the current version of the Task class is of "1", and the method migrates the XML from version "0" to "1". The XML to be migrated is passed as a VersionedDocument object which implements the dom4j Document interface and you may use dom4j to migrate it to be compatible with the current version of the class. In this migration method, we read back the "prioritized" element of version "0", rename it as "priority", and set the value as "HIGH" if the task is originally a prioritized task; otherwise, set the value as "LOW". With this migration method defined, you can now safely deserialize the task object from XML: package example; import com.pmease.commons.xmt.VersionedDocument; public class Test { public static void main(String args[]) { String xml = readXMLFromFileOrDatabase(); Task task = (Task) VersionedDocument.fromXML(xml).toBean(); } private static String readXMLFromFileOrDatabase() { // read XML from file or database here } } The deserialization works not only for XML of the old version but also for XML of the new version. At deserialization time, XMT compares the version of the XML (recorded in the version attribute as we mentioned earlier) with the current version of the class (maximum suffix number of various migrate methods), and runs applicable migrate methods one by one. In this case, if an XML of version "0" is read, method migrate1 will be called; if an XML of version "1" is read, no migration methods will be called since it is already up to date. As the class keeps evolving, more migration methods can be added to the class by increasing the suffix number of the latest migration method. For example, let's further enhance our Task class so that the priority field is taking a numeric value ranging from "1" to "10". We add another migrate method to the Task class to embrace the change: @SuppressWarnings("unused") private void migrate2(VersionedDocument dom, Stack versions) { Element element = dom.getRootElement().element("priority"); if (element.getText().equals("HIGH")) element.setText("10"); else if (element.getText().equals("MEDIUM")) element.setText("5"); else element.setText("1"); } This method only handles the migration from version "1" to version "2", and we do not need to care about version "0" anymore, since the XML of version "0" will first be migrated to version "1" by calling the method migrate1 before running this method. With this change, you will be able to deserialize the task object from XML of the current version and any previous versions. This article demonstrates the idea of how to migrate field change of classes. XMT can handle many complicated scenarios, such as migrating data defined in multiple tiers of class hierarchy, addressing class hierarchy change, etc. For more information of XMT, please visit http://wiki.pmease.com/display/xmt/Documentation+Home
August 13, 2022
by Robin Shen
· 20,924 Views · 1 Like
article thumbnail
A Guide to Maven 3 Beta
In just over six years, Apache Maven has become one of the most coveted tools for project build and reporting management. It’s been five years since the release of Maven 2, and now the Maven committers have released the next landmark version of the software. Incredible Improvements in Little Time It didn’t take long for Maven to become one of the most respected and desired tools in computer engineering. However, the product only continues to improve as Maven 3 is now available for those needing this extra computing power. The whole system just gets more and more interesting as time goes on, and that is exactly what people are most interested in when they look through different software options that are open to them. They just want something that they know will add to the amount of work that they can get done. We took some time to speak with the visionary founder of the Maven series of products, and we got some answers directly from him about how these products work and what kind of updates we might expect in the future. Believe it or not, just sitting down with him and getting some of these answers was a big help getting us to a place where we better understand the product. There is so much buzz and excitement about Maven 3 right now, and there should be. However, we wanted to hear directly from the creator of it to see which features we should be most excited about. We are so happy that he took the time to speak with us and review his innovative product. Hear what we learned today directly from the creator. The first beta release of Maven 3, which is now complete after seven public alphas, was released this week. Maven founder and Sonatype CTO Jason van Zyl answered some questions for DZone about Maven 3 earlier this month. Below are the main new feature categories of Maven 3. Drop-in Replacement Users of Maven 1.x may remember the bumpy transition to Maven 2 because of several fundamental changes. The Maven committers remember too, and they’ve put a lot of extra work into providing backward compatibility and making Maven 3 a simple drop-in replacement for Maven 2.x in most cases. van Zyl says this was “very difficult given how much of the internals we’ve changed.” Apart from fixing problems with duplicate dependency and plugin declarations, no changes are needed for your POMs. They’ve made the command line fully compatible between 2 and 3. Polyglot Maven Polyglot Maven is not a part of Maven 3 per se, but it is a tool from van Zyl’s company, Sonatype, that can be integrated with Maven 3 via an extension point. The extension points are a new feature in Maven 3 that support tools such as Tycho, Polyglot Maven, and Maven Shell. As you’ve probably guessed from the name, Polyglot Maven supports dynamic languages and is trying to provide first-class POM-mapped DSL (Domain Specific Language) support for Groovy, Scala, Clojure, Ruby, Xtext, and YAML. Polyglot Maven currently supports YAML. This is a welcome feature for developers who find the original XML format annoying. If you don’t, no big deal. Van Zyl also says it’s important for these DSLs to have repository interoperability and tooling to leverage M2Eclipse. M2Eclipse Maven 3 has changes related to embedding that make it work a lot better inside of M2Eclipse (the first Maven integration plugin for Eclipse). Maven 3 is now capable of a 200 to 300% performance boost while running in this plugin environment built specifically for Maven and the Eclipse IDE. M2Eclipse will provide some extra XML metadata in the Maven POM, which M2Eclipse only recognizes. This is one feature that enables high build performance. M2Eclipse also downloads all sources automatically and has a single-click new project creation feature for any of your dependencies. Maven Shell The Maven Shell is another extension point. It is Maven embedded in a long-lived shell process that caches parsed POMs, avoids start-up costs when invoking Maven repeatedly, supports Maven Archetype integration, provides Nexus integration, includes a built-in help system, and on Mac OS X, provides Growl support. Van Zyl says typical cases will see a 50% reduction in build times. Version 1.0 of the Maven Shell integrates the make-like reactor mode that builds only the modified modules. Support for project workflow, Hudson, Tycho, and Polyglot Maven are also present. Other improvements Developers working in multi-module or multi-pom projects won’t have to specify the parent version in every sub-module in Maven 3. Instead, you can add version-less parent elements. Maven 3 will also be able to see which POMs supplied which artifacts. In M2Eclipse, you can then deselect a certain contribution and select others. This is made possible through Maven 3’s decoupling of execution plans and execution. Maven 3 also includes extension points (mentioned above), which allow developers to hook up to different extension points instead of subclassing a plugin to alter the plugin’s behavior. You might, for example, have an extension point to alter how web.xml is processed through the WAR plugin. The source code in Maven 3 uses Google Guice for dependency injection and Peaberry to add OSGi capabilities to Guice. The whole dependency resolution is refactored into a standalone product by Sonatype called Mercury, for which Maven 3 is a client. Believe it or not, the Maven 3 codebase ended up being 1/3rd smaller than Maven 2. Maven 3.1 Looking toward the next release, Maven 3.1 will include a security manager with the settings.xml implementation as the default. Sonatype is planning an implementation that interacts with Nexus. Maven 3.1 will also introduce POM mixins, which make the configuration more maintainable and portable. Mixins will help solve the problem in Maven 2.0, where sharing configuration could only be done via inheritance. POM mixins are a type of POM composition that allows parameterized POM fragments to be injected into the current POM with a simple reference. References: "What's New in Maven 3" - Eingestellt von Reikje, DZone interview with Jason van Zyl, and "EclipseMagazine Interview with Jason van Zyl on the Maven Ecosystem"
August 13, 2022
by Mitch Pronschinske
· 46,340 Views · 2 Likes
article thumbnail
Key Takeaways: Adrian Cockcroft's talk on Netflix, CD, and Microservices
This article was originally published on 3/19/15
August 13, 2022
by Mitch Pronschinske
· 22,210 Views · 1 Like
  • Previous
  • ...
  • 250
  • 251
  • 252
  • 253
  • 254
  • 255
  • 256
  • 257
  • 258
  • 259
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×