Freddy Guime

Episode 8. What’s your Aspect?

In this episode we go over Aspects (and AspectJ), what really is, and when to use them. It turns out, that there is nothing misterious about them! We also cover how to set-up Aspects for J2SE so you can start using them immediately!

Questions, feedback or comments!comments@javapubhouse.com

VM Parameter
-javaagent:dep/aspectjweaver.jar

Example Aspect

@Aspect

public class OrderAspect {

    @Before("execution(* *.*(Order))") // must qualify
    public void anyCall() {
        System.out.println("Was called from anywhere");
    }
  }

Example aop.xml file

          <aspectj>
            <aspects>
              <aspect name="OrderAspect"/>
            </aspects>
            <weaver options="-verbose -showWeaveInfo">
            </weaver>
          </aspectj>

Example Folder Structure

src
 |
 |-META-INF
    |
    |-aop.xml

References:

http://www.eclipse.org/aspectj/doc/released/adk15notebook/ataspectj-pcadvice.html

http://blog.espenberntsen.net/2010/03/20/aspectj-cheat-sheet/

http://www.eclipse.org/aspectj/doc/next/quick5.pdf

(Using aspects with annotations)
http://stackoverflow.com/questions/2011089/aspectj-pointcut-for-all-methods-of-a-class-with-specific-annotation

Episode 7. Threads, Priorities, and Swing’s Golden Rule

In this episode we talk about Threads and Threading, the difference between Daemon and User Threads, and why changing priorities is not for the weak of heart. Also we cover Swing’s golden Threading rule (with the Event Dispatching Thread). If you ever typed new Thread(), or if you heard to be careful about Swing and Threading, this episode is for you!

 

Episode 6. Observing the Observers, a talk about patterns, observer and listeners!

In this week’s podcast we talk about Design Patterns (and the Grand Dads of the Software Patterns, the Gang-of-four), and dive into our first design pattern (of many), the Observer pattern. We discussed how to implemented (within Java), and went to describe its use in Java Swing, and why anonymous inner classes for Listeners doesn’t create memory leaks (most of the time anyways). In all a great introduction to a first pattern (see what they are all about!)

 

Episode 5. Producing and Consuming, ThreadPoolExecutor, and Latency vs Throughput

In this podcast we dive into the age-old producer and consumer problem, talked about the different aspects of it (what does it really solve?), and explain the difference between throughput vs latency. Lastly we discuss the ThreadPoolExecutor and how to fine tune it for your particular project needs!

 

Episode 4: List, Set, Maps, HashCode, Equals and ConcurrentMap! Everything to know about Collections!

In this episode we describe the most used collections in the Java framework, and how can they help you out. We also talk about maps (and the importance of immutable keys), and the equals/hashcode contract (why are these anyways? :). Finally we discuss how to safely access these collections/maps from different threads (and cover the check-then-act operations in maps). If you used a map, or ever got a ConcurrentModificationException, this episode is for you!

 

Episode 3. Memory leaks, memory references and garbage collections!

This episode goes deep into memory in Java, understanding how memory leaks happen (and how to solve them!), also how to design to avoid memory leaks, weak and soft references, and how the Garbage collector works (Eden, Tenured, Perm). This podcast will help everyone that needs to take care of a memory leak!

Kudos to VisualVM and VisualGC!

 

Episode 2. Deadlock, Livelock, Escaped locks, and wait/notify oh my!

In this episode of Java pub house, we talk about Deadlocks, livelocks (and other spooky things). Most importantly we talk on how to spot them (using jstack, or visualvm), and how to program defensively against them. We also talk about escaped locks (the source of most deadlocks), and the wait/notify language construct. Finally we describe the unfairness of the lock (locks are not “fair” by default), and why is it so.

Happy Programming!

Episode 1. Volatile, and Synchronized

On this Episode, we talk about the keyword “volatile”, and what does it really mean. Even if you are a multithreading guru, this chapter goes in deep of the different things that volatile protects you from, including L2 caches and code re-ordering. We also cover the use of synchronized, and why, even though is convenient, it might create more headache than it actually solves.

Happy Programming!

“HELLO WORLD”

Welcome to Java Public House, the podcast (and blog) dedicated to the hard working Java professional! 

This blog was created to help those of us who have to work with Java day in and day out, and its mission is simple, is a podcast created by a developer for developers. You can think of it as “free” training seminars in downloadable form. We will cover Java related topics (such as multithreading, Swing, JavaFx) and gear it towards understanding these topics a little bit better, and while there are a tons of sites out there that describe good things about Java, we tried to be a little different.

This podcast talks about how to program in Java; not your tipical system.out.println(“Hello world”), but more like real issues, such as O/R setups, threading, getting certain components on the screen or troubleshooting tips and tricks in general. The format is as a podcast so that you can subscribe to it, and then take it with you and listen to it on your way to work (or on your way home), and learn a little bit more (or reinforce what you knew) from it.

Within this podcast we are open to get questions from everyone, and the most popular then gets slotted for next week’s topic (as easy as that!). So, let’s learn together, and have fun (and become better professionals!), a win win!

Why should I listen to this guy? (A little bio)

Ok, so my name is Freddy Guime, I have three kids, two cats and one wife
I Presented at JavaOne twice (and scheduled to present in 2011) on topics related to multithreading and Swing.

I work for Optionscity Software Inc, as their Director of Client Technology (don’t worry, it stills involves programming 90% of the time), and wear many hats (usability expert, performance Guru, and coffee-to-code processor. Within Optionscity I’m proud of what we create (it’s very innovate, and cutting edge), and always love the challenge of pushing Java to its limit.

Happy Programming!

Freddy