Showing posts with label my projects. Show all posts
Showing posts with label my projects. Show all posts

Monday, March 28, 2011

Maven - Hotswap Plugin

For many years I was missing the following feature of Maven: In a multi-module project, when I build a single module in a jar, I want it to be installed into the running environment (app server) seamlessly. During these years I created various scripts for this tasks, why none of them lasted too long: it's very hard to create a generic script, while nongeneric scripts need to be maintained and actually each module must have had its own script. Duh.

Thinking about it, I decided that it should be a Maven plugin, which is very simple - during the install phase, search some predefined location and hotswap the found jars. That's it. So I thought that somebody probably already thought about it and asked a question at Stackoverflow. I received few interesting answers, but not a simple plugin I needed.

So I decided to implement it myself. It took me few hours, since it was my first Maven plugin, so I had some "doing it for the first time" troubles. But finally I did it.

You are welcome to use it, and as always any feedback is appreciated.

Thursday, August 20, 2009

My Projects at Ohloh

Somebody added the Encoder Tool and tarlog-plugins to Ohloh. It wasn't me, but I've registered and became manager and the only developer for these projects.
I've also put "I use it" buttons on the project sites, so if you are using these projects, you are welcome to click the buttons. It will give me a better indication how many users these projects have.

Thursday, July 30, 2009

Encoder 0.5.1

I'd like to announce the release of Encoder 0.5.1 with the fix of Issue 24 (thanks to Anton for pointing this out)

In addition I've finally moved the build of Encoder's distribution to maven, so 0.5.1 contains both the Eclipse plugin and the standalone version.

Enjoy :)

Monday, July 20, 2009

tarlog-plugins 1.3.1

tarlog-plugins were enhanced with the support of Slf4j.

The switch between commons-logging and slf4j occurs using Preferences -> Tarlog Plugins -> Logger.
The same template "logger" is reused for both frameworks.

I needed this feature, since it was decided to use Slf4j for Wink. Hope more people will find it useful.

Tuesday, June 9, 2009

Encoder 0.5.0

It's was a long time, since the previous release of the Encoder. Actually I didn't work much on the Encoder's functionality, but I did a lot of enhancements to the Dynamic Dialogs functionality. Interesting if someone, but me, really uses it...

Anyway 0.5.0 version is ready. It requires Java 6 and Eclipse 3.4.2.
Apart of enhancement to the Dynamic Dialogs it includes the following features:
1. Hitting Ctrl+A in the text areas will perform "Select All".
2. The text areas now support different encodings when transforming from text to bytes.
3. The input text area was enhanced with "Import" functionality, which allows importing a binary file to the input text area.
4. Both input and output text areas were enhanced with the "Export" functionality that save the content of the area to a file. For text, the defined encoding will be used.

I didn't create a standalone distribution this time, but only an Eclipse plugin. If you want it as standalone, please let me know in the comments, and I'll create it for you.

Enjoy :)

Thursday, March 19, 2009

tarlog-plugins 1.3

If you are using Eclipse, you have probably needed to change font size at least once. Changing the font size in Eclipse is a somewhat cumbersome, you need to go Window -> Preferences -> General -> Appearance -> Colors and Fonts, find the relevant editor and change its font.

Personally I have suffered from this many times. Finally I decided to add the ability to change font's size quickly to tarlog-plugins, so please welcome the tarlog-plugins 1.3.

This plugin extends the 1.2.3 version with the following key bindings:
   Ctrl++ will increase font.
   Ctrl+- will decrease font.

You can change these bindings from Preferences -> General -> Keys.

Monday, November 24, 2008

Encoder's Downloads Statistics

You can call me bored, but here are some statistics of downloads of the Encoder Tool:
VersionAvailable (days)DownloadsDownloads per day
0.1.0 Plugin10161.6
0.1.0 Zip1010.1
0.2.0 Plugin20321.6
0.2.0+0.2.1 Zip20412.05
0.3.0 Plugin56440.78
0.3.0 Zip56571.02

Total: 191 downloads

Interesting how many people are continue to use it occasionally. And how many people are checking for the new versions.
Unlike the tarlog-plugins, I didn't receive any issues regarding the encoder. May be there are no bugs... Or may be nobody uses it... But there are 191 downloads.

Anyway, if you are using the encoder and you are reading this post, I will really appreciate your feedback. Any feedback.

Thanks for reading :-)

Sunday, November 23, 2008

Encoder 0.4.0

The new iteration of the Encoder was just released. Previously, I planned to release an iteration once a month, but I had almost nothing to release at the end of October and it took some more time to code new features.
And the new features are:

1. History of steps was added. So the user can restore the input and output of a specific step and start it over.
2. Enable flag was added to encoders and encoder groups. The flag can be changed from the Properties. Only the enabled encoders will appear in the UI.
3. "Escaping" encoder was added. This encoder performs the following escapings: Escape XML, Unescape XML, Escape HTML, Unescape HTML, Escape Java, Unescape Java, Escape Javascript, Unescape Javascript and Escape Sql. This encoder is based on the org.apache.commons.lang.StringEscapeUtils.

Enjoy!

Sunday, September 28, 2008

Encoder 0.3.0

A new iteration of the Encoder Tool was just released.

The major features are:

1. The standalone version was updated with the third parties jars of Eclipse 3.4.1.

2. Making validation of the input fields will be easy: "required" attribute was added to the InputField annotation. The fields marked as required will be automatically validated as not null.
In addition InputTextField annotation was enhanced with the following attributes: "validateNotEmpty", "validationPattern" and "validationMessage".
validateNotEmpty - validates that string is not empty
validationPattern - validates that string matches the pattern
validationMessage - is displayed to the user if the string doesn't match the pattern
(see Issue 9)

3. Adding jars to the encoder's classpath now supports adding multiple jars (Issue 12)

4. Paths that are saved in the plugin's classpath are now relative and not absolute (Issue 13)

5. In Preferences page, double clicking anything in tree will act as Edit, if Edit button at the right is enabled (Issue 14)

That's all. Hope you'll find these features useful.

Tuesday, September 16, 2008

Encoder 0.2.1

39 downloads to encoder-0.2.0.zip and only 40th person told me that the executable jar inside zip is broken.

Anyway, I have fixed the build script and now it should work. Download encoder-0.2.1.zip from now on.

Monday, September 8, 2008

Encoder 0.2.0

I have just released the second iteration of the Encoder.

Here are the main features:
   1. The Encoder is now customizable using the Preferences dialog. When using Eclipse, the preferences dialog appears under Windows -> Preferences. When standalone, the see File -> Preferences.
   2. The methods getName() and getGroup() should not be implemented by the encoders. Instead the encoder is defined in preferences under a group and must have a name.
   3. The input dialog now supports the ongoing validations. To use it, the encoder must implement tarlog.encoder.tool.api.fields.Validator interface. See tarlog.encoder.tool.encoders.X509CertificateEncoder if you need an example how to use it.
   4. The input fields now support arrays.

It probably has some bugs, so don't hesitate to open issues.

Tuesday, September 2, 2008

Implementing your own encoder in the Encoder Tool - Part 2

I the previous post I have explained how to create a custom encoder. The encoder that takes input and encodes it to output. But what happens, if the encoder needs an additional input to perform an encoding? E.g. the Inflate/Deflate encoders needs to know if they need to use gzip. The Digital Signatures encoders need access to the key stores with the keys and so on.
So how can the encoder receive the additional input?

Actually I tried to do it as simple as I could. To tell the Encoder Tool that your encoder needs input, you'll need to annotate the field with the InputField annotation.
So the Encoder Tool will know that prior to performing the actual encoding, it should pop-up the input dialog, get the input from user and populate the fields.

Let's take a look on the example:
package tarlog.encoder.tool.encoders;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;

import tarlog.encoder.tool.api.AbstractEncoder;
import tarlog.encoder.tool.api.fields.InputField;

public class DeflateEncoder extends AbstractEncoder {

@InputField(name = "GZIP compatible compression")
private boolean nowrap = true;

@Override
public Object encode(byte[] source) {

try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
Deflater deflater = new Deflater(Deflater.DEFLATED, nowrap);
DeflaterOutputStream deflaterStream = new DeflaterOutputStream(
bytesOut, deflater);
deflaterStream.write(source);
deflaterStream.finish();
return bytesOut.toByteArray();
} catch (IOException e) {
showException(e);
return null;
}
}
}


The field nowrap is annotated with the InputField. So when the user invokes the encoder, the following dialog will pop-up:



I guess that the idea is clear. So let's just mention what java types are supported as input fields:
  • String - can be a single line, a text box or a combo box. See TextField annotation for more details.
  • Boolean - check box
  • Integer - spinner
  • Enum - combo box
  • File - input dialog for a file or a directory. See InputFileField and InputDirectoryField annoations for more details.
  • Properties - table of properties
  • Arrays - list. See InputListField for more details.


The input dialog supports on going validations. To do so, the encoder must implement the tarlog.encoder.tool.api.fields.Validator interface. Let's take a look on the example:

public class X509CertificateEncoder extends AbstractEncoder implements
Validator {

private X509Certificate cert;

@InputField(name = "Certificate File", order = -300)
private File file;

@InputField(name = "Algorithm", readonly = true)
private SignatureAlgorithms algorithm = SignatureAlgorithms.SHA1withDSA;

@InputField(name = "Signature")
@InputTextField(multiline = true)
private String signature;

public String isValid() {
if (file == null || file.equals("")) {
return "Certificate File cannot be empty";
}
if (signature == null || signature.equals("")) {
return "Signature cannot be empty";
}
return null;
}

...


The method isValid() will be invoked each time the user changes input.

Sunday, August 31, 2008

Implementing your own encoder in the Encoder Tool

As I already mentioned in the Encoder's introduction post, the main feature of the Encoder Tool is an extensibility. Meaning that you can implement your own encoders and plug them to the Encoder Tool.

In this guide, I'll explain how to create a custom encoder and plug it into the Encoder Tool. This guide applies to the current Encoder's version (0.2.0).

Create Java Project


Download the distribution of the Encoder (zip file) and create a java project. Add an encoder's jar and third-parties jars from the lib folder to the project's classpath.

Create an Encoder's Class


Create a new class that extends tarlog.encoder.tool.api.AbstractEncoder.

Implement encode() Method


This is the most important method to implement, the method that is responsible to the encoder's logic. First, you'll need to pay attention that there are two encode methods that you can override:
* Object encode(String source)
and
* Object encode(byte[] source)
You must override at least one of these methods, but usually you will override only one.

So what is the difference?
Object encode(String source) is invoked when the input is a text.
Object encode(byte[] source) is invoked when the input is a byte array.
Simple, isn't it?

The default implementation of these methods is to call each other, which leads to endless recursion if you don't implement one of the methods. The Encoder Tool asserts that you implement one of the methods and will throw an exception if you don't.

The result of the encode method should be either a String or a byte array. If other object is returned, its toString() method will be invoked. If null is returned, the output will remain unchanged.

Example


package tarlog.encoder.tool.encoders;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import tarlog.encoder.tool.api.AbstractEncoder;

public class MyUrlEncoder extends AbstractEncoder {

@Override
public Object encode(String source) {
try {
return URLEncoder.encode(source, "UTF-8");
} catch (UnsupportedEncodingException e) {
showException(e);
return null;
}
}
}


Plug in a Customer Encoder to the Encoder Tool


To plugin in a custom encoder to the Encoder Tool do the following:
1. Open preferences page and add a new encoder. You can add it either to the existing group or you can create a new group.
2. When you add the encoder, you should provide a name, a class name and a classpath.
3. Define classpath of the encoder, it may contain class folders or jars.
4. Press OK and start using your encoder.

Conclusion


In this post I have described how to create custom encoders to the Encoder Tool. As you could see, it's very very simple. However, you may say, what happens if the custom encoder needs an additional input? Just like the "Digital Signatures" encoders. So there is solution for this, but it will have to wait for the next post.

Friday, August 29, 2008

Encoder 0.1.0

And here just another neat tool I have developed for my personal needs and decided to make it public. Meet the Encoder!

So what is it used for?


It is used to encode things from one format to another. The input can be either text or bytes and the same about output. The tool is easily extendable: if you need to perform some special encoding you can implement encoder yourself and plug it into the tool. I'll expand about this functionality in the later post.

Built-in Encoders


Currently the build-in encoders are:
  • To/From Base64
  • Url Encoder/Decoder
  • Inflate/Deflate (optionally uses gzip)
  • Create signature using a private key
  • Verify signature using a public key
  • Verify signature using a certificate


Running the tool


The tool can be run either as an eclipse plugin or as a standalone application. UI is implemented in SWT, which makes it cross-platform. To run the Encoder standalone, download the distribution zip and execute "javaw -jar encoder-0.1.0.jar". You'll need at least Java 5.

I guess that all for now. I'll be happy to get any feedback about the Encoder and see people using it.

Enjoy!

Tuesday, August 26, 2008

tarlog-plugins 1.2.2

Only 48 hours since 1.2.1 was released, I'm releasing another fix to the tarlog-plugins.

It fixes the redundant cmd process that is left in memory after the cmd is closed. See Issue 3 for more details.

Monday, August 25, 2008

tarlog-plugins 1.2.1

18 downloads in about a month and one opened defect. I think it's pretty nice for the plugin I wrote for my personal needs and advertised only in this blog.

So now I'm releasing version 1.2.1 of the tarlog-plugins.
It contains the fix to the only defect I got from the outside world and a fix to the defect I opened myself.

Just to remind you the features of the plugin:

  • Open in Command Prompt - opens command prompt from the current file or folder in the Eclipse's Package Explorer/Navigator.

  • Open in Windows Explorer - opens windows explorer with the selection on the current file or folder in the Eclipse's Package Explorer/Navigator.

  • Templates for apache-commons-logging.


I'm working with Eclipse 3.4 and I use this plugin only there. So I'm not quite sure if it will work with the previous versions of Eclipse.

Sunday, July 20, 2008

Open Command Prompt or Windows Explorer in Eclipse

One of the features I miss in Eclipse is an ability to open Windows Explorer and Command Prompt (like CMD Here) on the current file or folder.
So I decided to implement it myself and here it is.
I gave it a huge name, since I hope to add there some more plugins that I miss, but currently it contains only the above features.

Enjoy!

Update: Since this post was written back in 2008, the plugin had some updates. See tarlog-plugins tagged posts.


Recommended Reading

1. Eclipse Rich Client Platform (2nd Edition)
2. Swt/Jface in Action: GUI Design with Eclipse 3.0
3. EMF: Eclipse Modeling Framework (2nd Edition)
4. Effective Java