Thursday Jul 05, 2012

Project OpenPTK Release 2.1 Available

The OpenPTK owners are pleased to announce that release 2.1 is available.  It has been "tagged" in the svn repository. See the download page for details.  

This release is an update to version 2.0.  This release contains bug fixes, enhancements to existing capabilities, and new features.  The most notable change in this release is the use of maven, instead of ant, for the build process.  The adoption of maven has made the project more modular, reduced its download size (less bundled jar files) and will enable the future support of Project OpenPTK in a maven repository.

For full details, see the OpenPTK version 2.1 Release Notes

Monday Nov 12, 2007

Source Code Posted

Last Friday the Project OpenPTK team (Derrick, Terry and I) did an initial check-in of the source code. You can download the pre-built samples and browse the source code. Details related to the source code can be found on http://www.ohloh.net. Our initial check-in was about 120 files and included over 15,000 lines of code (that's minus blank lines and comments). The Javadocs for the Java API are available on http://www.openptk.org.

Friday Oct 12, 2007

Announcing Project Open Provisioning ToolKit (OpenPTK)

Derrick Harcey, Terry Sigle and I (Systems Engineers in Sun's Software Practice) publically announced Project OpenPTK at Sun's Customer Engineering Conference (CEC) 2007 in Las Vegas, Nevada.

In addition to my co-founders (Derrick and Terry), i'd like to thank lots of other people that helped make this project possible. The three of us put in a lot of evenings and weekends.

  • My wife: I spent a few weekends and evenings writing code and having conference calls. I woke her up sometimes while dicsussing issues during 1:00 AM conference calls.
  • My two boys: while they were either at swimming lessons or at Tae Kwon Do classes, I would occasionally bring my laptop to write code or read technology books for research.
  • My management supported this project since day one. Thanks for supporting our vision.
  • Sun's engineering, marketing, open source and legal teams.

Being a member of Project OpenPTK has allowed he to see, first hand, that Sun believes in and supports open source projects.

Wednesday Jun 14, 2006

I discovered the Future (and FutureTask)

I'm working on updating a Java program that has to call a Web Service. The application is a Corporate phonebook (white pages) that uses the Sun LDAP Directory server. One option in the program calls a Web Service to get external (non-LDAP) data about a person. The application would wait if the Web Service was either slow or not available, eventually timing out. The timeout was too long for the end-user.

The requirement was to have the application call the Web Service with the option of setting a specific timeout.

I reviewed my Java books on threading, searched the web and tried to write a test Java app that would create a Thread, have the new Thread call the Web Service and stop if the Thread took too long. I tried using various combinations of

wait(millseconds)

and

notify()

to make something happen. No luck. I asked a friend "What am I doing wrong"?

His anwser was

java.util.concurrent.FutureTask

Thanks again to Brian Doherty for the advise.

The java.util.concurrent.\* package is new in the Java SE 5.0 release. I found a great example of using FutureTask in Core Java 2 Volume II - Advanced Features, Seventh Edition Chapter 1. Multithreading. The get(timeout_value,timeout_unit) method was exactly what I needed. It was soooooo much easier to implement a test program with the java.util.concurrrent package then by manually trying to make wait()/notify() work. Here's my test program which has a timeout value set to expire before the work (sleeping) is complete:

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class testFutureTask
{
   Perform perform = null;
   FutureTask task = null;
   Thread thd = null;
   
   public testFutureTask()
   {
   }
   
   public static void main(String[] args)
   {
      testFutureTask test = new testFutureTask();
      test.begin();
   }
   
   private void begin()
   {
      String answer = null;
      perform = new Perform("what is the question");
      task = new FutureTask(perform);
      thd = new Thread(task);
      thd.start();
      System.out.println("\\nPerforming the Task, (please wait) ... \\n");
      try
      {
//         answer = task.get();  // run until complete
         answer = task.get(5000,TimeUnit.MILLISECONDS); // timeout in 5 seconds
      }
      catch (ExecutionException e)
      {
         e.printStackTrace();
      }
      catch (InterruptedException e)
      {
         answer = "got interrupted.";
      }
      catch (TimeoutException e)
      {
         answer = "tired of waiting, timed-out.";
      }
      System.out.println(answer);
      return;
   }
}

class Perform implements Callable
{
   private String input = null;
   private String output = null;
   
   public Perform(String input)
   {
      this.input = input;
   }
   
   public String call() throws Exception
   {
      output = "The response to '" + input + "' is 42";
      try
      {
         Thread.sleep(10000);
      }
      catch (InterruptedException e)
      {
         System.out.println("Perform::call(), sleep interrupted.");
      }
      return output;
   }
}
About

Scott Fehrman

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News

No bookmarks in folder

Projects

No bookmarks in folder

Ref. Material

No bookmarks in folder