<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Java on Brave New Geek</title><link>https://bravenewgeek.com/category/java/</link><description>Recent content in Java on Brave New Geek</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 25 Jan 2019 10:52:38 -0600</lastBuildDate><atom:link href="https://bravenewgeek.com/category/java/index.xml" rel="self" type="application/rss+xml"/><item><title>Distributed Messaging with ZeroMQ</title><link>https://bravenewgeek.com/distributed-messaging-with-zeromq/</link><pubDate>Wed, 11 Jun 2014 16:56:03 -0600</pubDate><guid>https://bravenewgeek.com/distributed-messaging-with-zeromq/</guid><description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;“A distributed system is one in which the failure of a computer you didn’t even know existed can render your own computer unusable.” -Leslie Lamport&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;With the increased prevalence and accessibility of cloud computing, distributed systems architecture has largely supplanted more monolithic constructs. The implication of using a service-oriented architecture, of course, is that you now have to deal with a myriad of difficulties that previously never existed, such as fault tolerance, availability, and horizontal scaling. Another interesting layer of complexity is providing consistency across nodes, which itself is a problem surrounded with endless research. Algorithms like &lt;a href="http://en.wikipedia.org/wiki/Paxos_(computer_science)"&gt;Paxos&lt;/a&gt; and &lt;a href="https://ramcloud.stanford.edu/wiki/download/attachments/11370504/raft.pdf"&gt;Raft&lt;/a&gt; attempt to provide solutions for managing replicated data, while other solutions offer eventual consistency.&lt;/p&gt;</description></item><item><title>Bluetooth Blues</title><link>https://bravenewgeek.com/bluetooth-blues/</link><pubDate>Tue, 19 Mar 2013 16:01:49 -0600</pubDate><guid>https://bravenewgeek.com/bluetooth-blues/</guid><description>&lt;p&gt;I spent the better part of two days working on Bluetooth connectivity for an Android app I’m developing. Going into it, I had virtually no experience working with Bluetooth, especially on Android. I quickly discovered some of the peculiarities of the platform’s Bluetooth API.&lt;/p&gt;
&lt;p&gt;In addition to connecting to Bluetooth devices, the client wanted to pair and unpair from the app. The easy way out, and probably &lt;em&gt;The Android Way&lt;/em&gt;™, would be to pass that responsibility off to the OS, à la an Intent:&lt;/p&gt;</description></item><item><title>Implementing Spring-like Classpath Scanning in Android</title><link>https://bravenewgeek.com/implementing-spring-like-classpath-scanning-in-android/</link><pubDate>Sat, 05 Jan 2013 02:53:36 -0600</pubDate><guid>https://bravenewgeek.com/implementing-spring-like-classpath-scanning-in-android/</guid><description>&lt;p&gt;One of the things that Spring 2.5 introduced back in 2007 was component scanning, a feature which removed the need for XML bean configuration and instead allowed developers to declare their beans using Java annotations. Rather than this:&lt;/p&gt;
&lt;script src="https://gist.github.com/tylertreat/7688bafe73aa1eaeaa24.js"&gt;&lt;/script&gt;
&lt;p&gt;We can do this:&lt;/p&gt;
&lt;script src="https://gist.github.com/tylertreat/937b3e36d6ecdcbc7c3b.js"&gt;&lt;/script&gt;
&lt;p&gt;It’s a pretty simple idea since Java makes it very easy to introspectively check a class’s annotations at runtime through its reflection API. Spring’s component scan feature also allows you to specify the base package(s) to scan for beans.&lt;/p&gt;</description></item><item><title>Modularizing Infinitum: A Postmortem</title><link>https://bravenewgeek.com/modularizing-infinitum-a-postmortem/</link><pubDate>Thu, 27 Dec 2012 16:04:16 -0600</pubDate><guid>https://bravenewgeek.com/modularizing-infinitum-a-postmortem/</guid><description>&lt;p&gt;In addition to getting the code migrated from &lt;a href="https://code.google.com/p/infinitum-framework/"&gt;Google Code&lt;/a&gt; to &lt;a href="https://github.com/infinitumframework"&gt;GitHub&lt;/a&gt;, one of my projects over the holidays was to modularize the Infinitum Android framework I’ve been working on for the past year.&lt;/p&gt;
&lt;p&gt;Infinitum began as a SQLite ORM and quickly grew to include a REST ORM implementation,  REST client, logging wrapper, DI framework, AOP module, and, of course, all of the framework tools needed to support these various functionalities. It evolved as I added more and more features in a semi-haphazard way. In my defense, the code was organized. It was logical. It made &lt;em&gt;sense&lt;/em&gt;. There was no method, but there also was no madness. Everything was in an appropriately named package. Everything was coded to an interface. There was no duplicated code. However, modularity — in terms of minimizing framework dependencies — wasn’t really in mind at the time, and the code was all in a single project.&lt;/p&gt;</description></item><item><title>The Importance of Being Idle</title><link>https://bravenewgeek.com/the-importance-of-being-idle/</link><pubDate>Wed, 19 Dec 2012 19:12:36 -0600</pubDate><guid>https://bravenewgeek.com/the-importance-of-being-idle/</guid><description>&lt;p&gt;&lt;em&gt;“Practice not-doing and everything will fall into place.”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;It’s good to be lazy. Sometimes, in programming, it can also be hard to be lazy. It’s this paradox that I will explore today — The Art of Being Lazy. Specifically, I’m going to dive into a design pattern known as lazy loading by discussing why it’s used, the different flavors it comes in, and how it can be implemented.&lt;/p&gt;
&lt;p&gt;Lazy loading is a pretty simple concept: don’t load something until you really need it. However, the philosophy can be generalized further: don’t do something until you need to do it. It’s this line of thinking that has helped lead to processes like &lt;a href="http://en.wikipedia.org/wiki/Kanban_(development)"&gt;Kanban&lt;/a&gt; and &lt;a href="http://en.wikipedia.org/wiki/Lean_software_development"&gt;lean software development&lt;/a&gt; (and also probably got you through high school). Notwithstanding, this tenet goes beyond the organizational level. It’s about optimizing efficiency and minimizing waste. There’s a lot to be said about optimizing efficiency in a computer program, which is why The Art of Being Lazy is an exceedingly relevant principle.&lt;/p&gt;</description></item><item><title>Dalvik Bytecode Generation</title><link>https://bravenewgeek.com/dalvik-bytecode-generation/</link><pubDate>Mon, 17 Dec 2012 20:03:57 -0600</pubDate><guid>https://bravenewgeek.com/dalvik-bytecode-generation/</guid><description>&lt;p&gt;&lt;a href="http://www.bravenewgeek.com/proxies-why-theyre-useful-and-how-theyre-implemented/" title="Proxies: Why They're Useful and How They're Implemented"&gt;Earlier&lt;/a&gt;, I discussed the use of dynamic proxies and how they can be implemented in Java. As we saw, a necessary part of proxying classes is bytecode generation. From its onset, something I wanted to include in Infinitum was lazy loading. I also wanted to provide support for AOP down the road. Consequently, it was essential to include some way to generate bytecode at runtime.&lt;/p&gt;</description></item><item><title>Proxies: Why They’re Useful and How They’re Implemented</title><link>https://bravenewgeek.com/proxies-why-theyre-useful-and-how-theyre-implemented/</link><pubDate>Mon, 17 Dec 2012 17:22:52 -0600</pubDate><guid>https://bravenewgeek.com/proxies-why-theyre-useful-and-how-theyre-implemented/</guid><description>&lt;p&gt;I wanted to write about lazy loading, but doing so requires some background on proxies. Proxies are such an interesting and useful concept that I decided it would be worthwhile to write a separate post discussing them. I’ve talked about them in the past, for instance on &lt;a href="http://stackoverflow.com/a/10239705/210070"&gt;StackOverflow&lt;/a&gt;, so this will be a bit of a rehash, but I will go into a little more depth here.&lt;/p&gt;
&lt;p&gt;What is a proxy? Fundamentally, it’s a broker, or mediator, between an object and that object’s user, which I will refer to as its client. Specifically, a proxy intercepts calls to the object, performs some logic, and then (typically) passes the call on to the object itself. I say &lt;em&gt;typically&lt;/em&gt; because the proxy could simply intercept without ever calling the object.&lt;/p&gt;</description></item><item><title>A Look at Spring’s BeanFactoryPostProcessor</title><link>https://bravenewgeek.com/a-look-at-springs-beanfactorypostprocessor/</link><pubDate>Tue, 04 Dec 2012 22:42:54 -0600</pubDate><guid>https://bravenewgeek.com/a-look-at-springs-beanfactorypostprocessor/</guid><description>&lt;p&gt;One of the issues my team faced during my time at Thomson Reuters was keeping developer build times down. Many of the groups within WestlawNext had a fairly comprehensive check-in policy in that, after your code was reviewed, you had to run a full build which included running all unit tests and endpoint tests before you could commit your changes. This is a good practice, no doubt, but the group I was with had somewhere in the ballpark of 6000 unit tests. Moreover, since we were also testing our REST endpoints, it was necessary to launch an embedded Tomcat instance and deploy the application to it before those tests could execute.&lt;/p&gt;</description></item><item><title>Solving the Referential Integrity Problem</title><link>https://bravenewgeek.com/solving-the-referential-integrity-problem/</link><pubDate>Sat, 01 Dec 2012 13:37:46 -0600</pubDate><guid>https://bravenewgeek.com/solving-the-referential-integrity-problem/</guid><description>&lt;p&gt;&lt;em&gt;“A man with a watch knows what time it is. A man with two watches is never sure.”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;I’ve been developing my open source Android framework, &lt;a href="http://code.google.com/p/infinitum-framework/"&gt;Infinitum&lt;/a&gt;, for the better part of 10 months now. It has brought about some really interesting problems that I’ve had to tackle, which is one of the many reasons I enjoy working on it so much.&lt;/p&gt;
&lt;h3 id="chicken-or-the-egg"&gt;Chicken or the Egg&lt;/h3&gt;
&lt;p&gt;Although it’s much more now, Infinitum began as an object-relational mapper which was loosely modeled after &lt;a href="http://www.hibernate.org/"&gt;Hibernate&lt;/a&gt;. One of the first major issues I faced while developing the ORM component was loading object graphs. To illustrate what I mean by this, suppose we’re developing some software for a department store. The domain model for this software might look something like this:&lt;/p&gt;</description></item></channel></rss>