I missed Mixins in Java today

Note to Sun: I missed being able to do mixins with Java today. Maybe it’s all this playing with Rails, but back in Java-land I had this particular problem and I thought – mixins would solve this. But no go. Not even with JDK 1.5.

I guess I’ll just put on my monkey coder hat and add decorator scaffolding and almost-identical configuration code for 50 different classes instead. Maybe I should switch back to Spring autowire (like he Rails folks say, value convention more than configuration, right?). 😛

Yes, I know that you can do it using interfaces, but it still leaves me changing more than one line in all 50 classes. I also know that you could use some fancy AOP or dynamic proxying, and go against the GrainOfTheLanguage and end up with something that “works”, but it’s a pain to run through the debugger and determine basic intent.


Using Jobs API and asyncExec

Using the Jobs API (Job and IProgressMonitor) you can implement code that will run in a thread and update the standard Eclipse progress monitoring service as you go along in your thread.

To create a job, extend from org.eclipse.core.runtime.Job and implement the run method:

protected IStatus run(IProgressMonitor monitor) {
  int steps = 100000;
  monitor.beginTask("My Task", steps);
  for ( int i=0; i

To activate the job in MyClass (say it's a page with a tableViewer which we use to set the input), you do the following:

MySampleJob myJob = new MySampleJob();
myJob .addJobChangeListener(new JobChangeAdapter() {
  public void done(IJobChangeEvent event) {
    Display.getDefault().asyncExec(new Runnable() {
      public void run() {
                        setInput(myJob .getInputForTableViewer());

Have fun!