Tycho Target Trouble

I lost a few hours this weekend over one line in a maven pom.xml file.  I thought I would post the issue here so that anyone else that runs into this problem might find some help.  The original setup is this:

I have a fairly large Eclipse based application that I am moving from Juno to Kepler.  I am currently using the Maven/Tycho build structure, so I decided to incorporate a Target Platform definition to make it easier for other developers to set up their target platform as they also move to a Kepler install for their IDE.  I created a project with a target platform and copied a pom.xml file from another project.  I set the packaging to “eclipse-target-definition”.  I added all of the dependencies to the target platform definition and set it as the target platform and was able to build successfully with Eclipse.

When I tried to build with maven, the build (even a clean) would fail immediately with “Could not resolve target platform specification artifact”.  After reading a few pages of google search results, I downloaded the Tycho demo project from here: http://git.eclipse.org/c/tycho/org.eclipse.tycho-demo.git

The itp04-rcp project has a target platform, and I could not see any differences between the demo pom.xml and mine.  I moved my target definition into the demo project and did not see the same error, so I determined that it was not an issue with the target definition itself.  After a few hours of tweaking, I finally figured out that you can’t have a version element in the pom.xml file for a target platform.

I removed the version element and was able to build and install my products.  Now I’m off to the races with Kepler!

Eclipse Communications Framework

A Forensic Approach

A few months ago, I started looking into using Eclipse ECF to provide a mechanism for moving some OSGi services to a remote OSGi paradigm.  The problem that I very quickly ran into is that ECF has the least amount of documentation of any Eclipse project that I have used.  Much of the documentation is also geared toward developers who want to develop new protocols, containers, discoverers, etc.  I do not want to develop ECF, I want to use it!

Of course, after my rant about lack of documentation, I found that the ECF team is working on an ECF Users Guide.

After a few days of Google exercises, I decided to go to the source and see what I could figure out for myself.  I started by cloning the ECF repository available here: ECF Git Repository and then loaded all of the projects into a new workspace.

The Tests

I checked my Run Configurations and found that there were now several JUnit Plugin tests created from launch configurations included in the test projects.

ECF Run Configurations

I launched each of the tests and found that most completed successfully.  I was a bit surprised, since I still had several compile issues in the source.  As it turns out, the compile issues were either due to missing dependencies or were bundles in an incubation directory:

  • There are a few ECF SDO plugins that depend on EMF SDO
  • The mylyn plugin had compile issues (probably because I’m running Kepler)
  • There is an ECF provider (and test) for dnsdd that has a dependency on org.xbill.dns
  • There is an ECF provider (and test) for zookeeper that has a dependency on org.apache.hadoop.zookeper
  • There is an ECF plugin with import dependencies on the Spring Framework
  • The REST capabilities have a dependency on org.json
  • There are twitter bundles that I assume have a dependency on some Twitter packages.

The tests that did not use these items seemed to run correctly.  This was important to me so that I could get a baseline of working code to use as a comparison for my learning experiences.

The Examples

The other great way to learn from the code is to check out all of the example projects that are included in the repository.  There are several example client and server bundles with run configurations that show how the different configurations are set up to connect.

For distributed OSGi, there are different configurations of the same remote connection:

  1. Declarative Services or register the service programmatically
  2. Service Discovery or static endpoint configuration
  3. If using Service Discovery, pick from SLP, Zookeeper, or Zeroconf
  4. r-OSGi or ECF Generic
  5. Synchronous or Asynchronous with callbacks

I was able to learn a great deal about how the remote OSGi can be configured by focusing on the commonality and differences between the examples:

ECF Example Projects

All in all, I was able to get my services working in a few different configurations.  I still have a good bit of work to do because I was using EMF objects as parameters of my service methods, and EMF objects are not serializable without some extra code.  But that’s a post for another day…

Fun with Google CodePro

Usually when a software tool has “Pro” in the name, it means that it is expensive. Sometimes it just means that the features are unlocked so that you can actually use the tool. In this case it means FREE.

I have used CodePro on another project, but started using it again to help analyze the Stanford Natural Language Parser (also free).  I would like to use the StanfordNLP in a side project that I have in mind.  The problem is that is has a large code base in a domain (language parsing) that I am not familiar with.

I will have to split this into multiple posts, but you can read about the metrics report below.

Continue reading

Eclipse Console Window

Here’s a quick code snippet for using the Console view that is included with the standard Eclipse views when using RCP.  In the example, I am using the output from Log4J and streaming it to the Console.

The Console import declarations are:

import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsole;

The code that you will need to create the Console and direct the Logging output to the console is:

// Connect the Logging output to the console view.
ConsolePlugin plugin = ConsolePlugin.getDefault();
IConsoleManager consoleManager = plugin.getConsoleManager();
MessageConsole console = new MessageConsole("Console", null);
consoleManager.addConsoles(new IConsole[] { console });

logger = Logger.getLogger("default");
logger.addAppender(new WriterAppender(new SimpleLayout(), console.newMessageStream()));

And that is basically it. All output to the logger is now streaming to the Console window in the application.

Overlay Icon

I had a good bit of trouble in Eclipse with taking an Icon and adding another Icon as an overlay. This was needed for creating an ILabelDecorator for the Common Navigator. I found a few posts on different forums that used a class called OverlayIcon from a package in Eclipse. The problem was that I didn’t seem to have that package installed, or just didn’t have access to the class.

It took forever, but I finally found a class that works. It was posted in a user folder from LSU of all places. It is from the package org.eclipse.team.internal.ui, which was available for import with my plugin.xml file. The problem is that it does not contain the OverlayIcon class. So I would up using the source from the link below and putting it in my own package.

Here’s a link to where I found this code: Link to OverlayIcon

Also, here is a copy of the code (with package removed) in case the link above is ever broken:

Continue reading

The Wumpus Hunter

The design uses a knowledge base to store known information about each location. A rule set is then used to determine what actions the agent should take based upon the information known. The knowledge base uses a forward chaining concept on its tell(percepts) function to add new information to its array of locations. It then uses a backward chaining concept on the ask(location) function to find all possible information about a particular location.

While the knowledge base is somewhat stable, the functionality of the agent can be changed quite drastically by manipulating the rule set. For now, I have the agent programmed to choose its next action based on a random function that is run on a weighted set of possibilities. For example, if the agent’s first choice of move location would be a location that has not been visited that is in the same direction currently being traveled.

The wumpus world program also included a player view of the wumpus world, so that the user can play the part of the agent. The program still has some buggy behavior, but the agent consistently finds the gold in the case that it is not forced to choose between two unknown locations.


Naive Bayes Classifier

This page contains information that I have gathered for a semester project for my Machine Learning class at FIT. The project consists of implementing an application that can filter newsgroups for spam “off content postings” by using the Naive Bayes algorithm to differentiate normal newsgroup posts from off content posts.

To start off, I decided to create a program that could analyze a newsgroup post and tell which newsgroup the post belongs too. The newsgroups that I’m currently working with are:

  • alt.guitar
  • alt.guitar.tab
  • alt.rec.camping
  • alt.rec.hiking
  • comp.ai.philosophy
  • comp.games.development.programming.algorithms
  • comp.lang.c++
  • comp.lang.lisp
  • comp.programming
  • comp.programming.threads
  • comp.unix.programmer
  • microsoft.public.win32.programmer.directx.managed

I created a data set of newsgroup postings by downloading all posts in each newsgroup over a period of a few weeks. I used the Thunderbird e-mail application to subscribe to and download each newsgroup. The Classifier application then reads the files saved by Thunderbird to load the newsgroups. The same process was used to obtain postings from the same newsgroups at a later time that were not included in the original set of postings. This second set of newsgroups contains 10 postings in each newsgroup to be used as test data. The time necessary to read each posting in the original set of data and manually classify it as “off-topic” was too great to accomplish for this project. Therefore, I decided to simply attempt to classify each posting in the test data to predict which newsgroup the posting belonged to.

The Naive Bayes theorem is applied to the problem as follows:
P(N|W) = [ P(W|N) * P(N) ] / P(W) where N = Newsgroups, W = Words.
A newsgroup posting is made up of a list of words. According to the formula above, the probability that a posting is in newsgroup N is equal to the probability that the words will appear in the newsgroup, multiplied by the probability that a posting will appear in the newsgroup, divided by the probability that the words will appear at all. The probability is calculated for each word in the posting, and then multiplied together to obtain the overall probability of the posting in the newsgroup.

One of the biggest problems with the Naive Bayes algorithm occurs when one of the probabilities is equal to 0. A probability of 0 occurs when a word in the posting is not found in the existing list of words from the newsgroup. Since all of the probabilities are multiplied, the resulting probability is also 0, regardless of the probabilities of the rest of the words in the posting. To correct this problem, I replace any probability of 0 with the probability that the word will be found in the English language. For a 4 letter word, the probability is 1 in 233,378.

The classifier seems to work very well, with around an 85% success rate for most test runs. The classifier is configurable to filter out words less than 4, 5, or 6 characters; and will return different results based on which selection is made. I would assume that the classifier is more accurate when filtering the words less than 6 characters, but I don’t have enough data to prove that to be the case.

  1. Here’s the application
  2. Here’s the Newsgroups
  3. Here’s the Test Data

OpenGL in C#

LangleyGL is a program that resulted when I ported my OpenGL code to C#. I had to learn C# in a hurry for a project at work, and thought this would be a good test. Of course, all of this was made possible by the csgl project. The basic purpose of the project to begin with was to load mesh files from a *.3ds format.Many thanks to the Wotsit file format page for the great info on the 3ds format.

Another reason for writing the program was to attempt to apply object oriented programming techniques in the realm of OpenGL. This turned out to be much more complicated than I had originally expected. Most computer scientists would point out that the 3D world is composed of many very obvious “objects” – Lights, meshes, cameras, etc. This is nice and all until you combine it with some type of state machine – Lights On/Off, Modelview/Projection, what’s my current texture, etc. I finally realized that I had to be aware of (almost) every function and parameter made available to me from the OpenGL API. The best resource I can recommend is the OpenGL Redbook. Read it cover to cover (even if some chapters don’t apply).

As it turned out, this program may be useful to basic computer graphics instructors. The parameters of the view matrix can be modified and the changes viewed in real time. It also includes limited lighting parameters and some material creation methods.

I’ve uploaded the auto-generated code comment report from Visual Studio.

Oh yeah, here’s the code.

Learning DirectX

Not much to say yet about this one. I just finished it on Friday, and I haven’t added any comments or anything else to explain what the code does. Just a cheesy game, but not bad for learning Direct3D in a week.

The point of the game is to collect as many CTIA logos as possible while dodging the snowballs. The more CTIA logos that are collected, the faster the snowballs roll. There is only one level, no high scores table, and tank doesn’t fire. Strangely enough – it was still entertaining enough to get me through a week of C# training.

Here’s a screen shot:

Screenshot of game.
 Here’s the code.

Multilingual Software Reuse


Software can be designed in a way that enhances
its ability to be reused. This paper examines several concepts or
rules to follow when designing reusable software components. The
paper then gives examples of how to implement designs in both Java
and C#, as well as some problems that occur when using both languages.

The concept of software reuse has been discussed for decades,
yet software developers fight the same battles over software reuse
that have been fought time and time again. One of the sources used
for this paper, The Mythical Man Month, is actually the 20th
anniversary edition of the original material. Even though the
technology involved in the book (IBM System/360) is obsolete, its
discussion of reuse is still relevant (Brooks 222). Consider that
a Google search for software reuse on 7/20/04 returned 1,640,000
results. With so much material available on the topic of software
reuse, is there anything left to discuss?

This paper was born from two experiences working with software reuse
at Lockheed Martin for the Common Training Instrumentation
Architecture program. The first experience was the porting of the
OpenMap application from Java to C#. The other ongoing experience
is viewing the design of a common component library to be implemented
simultaneously in C# and Java. Using multiple languages to implement
the same design provided an interesting view of software reuse. There
are design methodologies, which, if followed, will enhance the ability
of a particular software design to be reused.

In today’s world of object-oriented languages, a software component’s
design can be reused as opposed to its code. There are books on design
patterns, refactoring, and even a Unified Modeling Language (UML) for
expressing a software design in a standard format. Tools can be found
for generating source code from UML diagrams in a number of languages,
leaving the developer to write much less code to implement the design.
Language vendors may also provide translators that will translate
software from one programming language to another.