Hi! Welcome...

I am Ashish. I am Member of Apache MINA PMC, ASF Committer and avid Code hacker. Contact me at paliwalashish at gmail dot com. I work for Terracotta [http://www.terracotta.org] as Solution Architect. I occasionally contribute to jsmpp [http://code.google.com/p/jsmpp/] .

13 October 2008 ~ 6 Comments

Updating Google Calendar with MS Project Tasks


I am back, as promised. Please read my earlier post Processing Microsoft Project File in Java using MPXJ.

In this post we shall take an mpp and update the Google Calendar with the task details. The question is why would anyone do that? 

Lets cook the story. A small team is working and the poor Project Manager share the Schedule with the team. The team is so busy coding that they forget to look at the dates, and the tasks they must be starting on. The poor Project Manager himself loose track unless he keeps MS Project Open on his desktop :-( A pretty common situation :-)  

Have faced this situation and decided to organize myself and this post is outcome of that. The driving force was "Out of sight, is out of mind". So my assumption was if the team has a visual of the task dates, the chances of task slippage shall reduce a lot. 

In this post, have built upon the my previous post to create an MPP parsing function. Have tried to keep the code in simplest form, so that it can customized later to specific needs. Have created a sample Schedule for this activity and used it for the implementation. Here is how it looks.

 

Google Calendar updater Project Schedule

Google Calendar updater Project Schedule

The schdule is simple, some date, and tasks with dependencies. The concept shall work for any number of tasks.

Following are the steps that we need to perform:

  1. Parse the mpp file
  2. Create a Calendar Service (Lets assume that the Calendar is already there, though it is possible to programmatically create the same)
  3. Get All tasks from MPP, and create Calendar Entries in Google Calendar
The Code
Google Calendar Entry Creation Code

Google Calendar Entry Creation Code

The implementation is fairly simple. We have 3 functions:

  • translateTaskToCalendarEventEntry() - Converts an Task into CalendarEventEntry, which can be added to Google Calendar
  • updateCalendar() - Takes input of all the Tasks from MPP, translates into CalendarEventEntry (using function translateTaskToCalendarEventEntry) and update the Calendar
  • updateGoogleCalendarWithMPP() - Parses the MPP using the util function from my previous post, and calls the API above to update the Calendar.

Google Calendar API usage is described in details on Google's pages, hence won't discuss here.
To use it for yourself, replace User Name and Password at line#70, with your User Credentials. Repace the URL at Line# 71 to point to your calendar.
After running the program, this is how my Calendar looked like 

Google Calendar View
Google Calendar View

A simple way to keep track of Tasks.
 

13 October 2008 ~ 19 Comments

Processing Microsoft Project File in Java using MPXJ


Many a time, I wished I had a utility that would read my projects mpp File and automatically alerted me about my tasks. Had created such a utilitly and this post desribes the process of reading MS Project Files in Java using MPXJ and Apache POI library.

MPXJ - MPXJ is the java library used for parsing MS Project files. The lib depends upon Apache POI package for providing the functionality. MPXJ supports all the three formats for MS Project. The details can be found at the Home Page for MPXJ provided in references section

Let's start implementing. The code to read the File is fairly simple.

Reading MS Project File in Java (Using MPXJ)

Reading MS Project File in Java (Using MPXJ)

 To read an MS Project file, we use projectReaderUtility class to get the instance of a ProjectReader, based on the extension. ProjectReader is the interface implemented by the classes that can read an MS Project file in mpxj library. Once we get the instance of ProjectReader, we need to invoke read API, passing the file name to be read. The API returns an instance of ProjectFile, containing all the details in the MS Project File. 

More about ProjectFile - ProjectFile is the class in mpxj, which contains all the information about an MS Project file. It has API's to access all Task details, as well other API's to extract and manipulate other metadata.

Is that it? The basic objective of reading is done. Now we can use the provided API to iterate and create applications to suite our needs. For example, to list all the tasks, use getAllTasks(), it returns a List of Tasks. Custom logic can be applied to manipulate this list as desired, like filtering the tasks based on resources or date.

What's next?

I am working on the prototype to read the MS Project File and update the Google Calendar with Task details, based on Start Date.

References

Tags: , ,

12 October 2008 ~ 6 Comments

(N)IO Frameworks in Java


In this post, I have tried to briefly capture list of available Java IO application frameworks. IO Frameworks reduces the development time by providing additional features over the bare-bone IO API's provided with Java.

Here is the definition I have used for the Framework

"An (N)IO Framework is a library, that provides easy to use API by shielding low level complexity of IO and provides rich and reusable API's to create robust and scalable Networking Applications".

A key point here is, only complexity is reduced, the power of low level API's is still available.

Have been using Apache MINA for a while, and found some similar and powerful frameworks. The idea is to share the result of searches. I don't intent to compare them on their performances or features. The text for the frameworks have been picked from the respective websites.

  • Apache MINA   - MINA (Multipurpose Infrastructure for Network Applications) is a network application framework which helps users develop high performance and high scalability network applications easily.
  • xSockets - xSocket is a lightweight java nio-based server framework to build high performance, high scalable, multithreaded servers. It supports writing synchronous and asynchronous client-side applications as well as server-side applications in a very intuitive way  
  • Grizzly - The Grizzly framework has been designed to help developers to take advantage of the Java™ NIO API. Grizzly goals is to help developers to build scalable and robust servers using NIO.
  • Netty - Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP/IP socket server
There are a few others, have picked up the popular ones. 
References

11 October 2008 ~ 1 Comment

What is Apache MINA?


Apache MINA (Multipurpose Infrastructure for Network Application) is an open source java network application framework. MINA is can be used to create Scalable, high performance Network applications. MINA provides unified API's for various transports like TCP, UDP, Serial communication, In-VM pipe. It also makes it easy to make an implementation of custom transport type. MINA provides both high-level and low-level network API's.

Application Structure

 

MINA based Application Architecture

MINA based Application Architecture

From the figure above, User application interacts with MINA API's, shielding the User application from Low level IO details. MINA internally uses IO API's to perform the actual IO functions. This makes it easy for the Users to concentrate on Application logic and leave the IO handling to Apache MINA.

Advantages (From the Apache MINA Home page)

  • Unified API's for various transports (TCP/UDP etc)
  • Provides high/low level API's
  • Customizable Thread Model
  • Easy Unit Testing using MockObjects
  • Integration with DI frameworks like Spring, Google Guice, picocontainer
  • JMX Manageability

Reference

Apache MINA

- Home Page of Apache MINA

Tags:

11 October 2008 ~ 1 Comment

Implementing SNMP4J Decoder for Apache MINA


Recently started evaluating Apache MINA. So thought about building a Trap Receiver using Apache MINA. Refer to one of my posting on What is Apache MINA?

Design
In this post we shall concentrate on just writing the ProtocolDecoder
The code snippet using SNMP4J library is
public class SNMP4JCodec extends ProtocolDecoderAdapter {

 static Logger logger = LoggerFactory.getLogger(SNMP4JCodec.class);

 public void decode(IoSession ioSession, IoBuffer ioBuffer,
                    ProtocolDecoderOutput protocolDecoderOutput) throws Exception {
     ByteBuffer pduBuffer = ioBuffer.buf();
     // Decode the bytes using SNMP4J API's
     PDU pdu = new PDU();
     try {
         BERInputStream berStream = new BERInputStream(pduBuffer);
         BER.MutableByte mutableByte = new BER.MutableByte();
         int length = BER.decodeHeader(berStream, mutableByte);
         int startPos = (int)berStream.getPosition();

         if (mutableByte.getValue() != BER.SEQUENCE) {
           String txt = "SNMPv2c PDU must start with a SEQUENCE";
           throw new IOException(txt);
         }
         Integer32 version = new Integer32();
         version.decodeBER(berStream);

         // decode community string
         OctetString securityName = new OctetString();
         securityName.decodeBER(berStream);

         // decode the remaining PDU
         pdu.decodeBER(berStream);
         logger.debug("PDU - "+pdu);
     } catch (Exception ex) {
         ex.printStackTrace();
     }
     protocolDecoderOutput.write(pdu);
 }
}

The code converts ByteBuffer into an SNMP PDU using SNMP4J  library. Similarly, we can use Adventnet or joesnmp to convert the byte stream into SNMP PDU's

NOTE: Custome Error handling need to be implemented, as per the strategy