Friday April 28, 2006 Hibernate plugin in NetBeans 5.5
I've started to migrate features from hibernate plugin based on xdoclet to javax.persistence (EJB30) annotations. Working with annotations is simpler that working with xdoclet tags. It is necessary to run post processing tool for sources with xdoclet tags and to generate xml descriptors. The annotations are stored do classes. Therefore there is no need to generate xml meta data. The EJB30 is standard. It is another reason why to use them because you are not depenedend on only one implementation. You can simply move to other vendors.
I added templates for POJO with @Entity annotations. Screenshot with code completion is shown bellow.
The ui of customizer is the same like for xdoclet customizer. Only different code is generated. For example wizard for creating 1-N relation is shown bellow.
I plan also migrate the HQL wizard to EJB30 stuff. I may be add another hibernate features to NetBeans 5.5 ( Hibernate Validator and Hibernate Lucene Integration. I looked also on JBoss Seam. It is interesting technology. Has anyone experience with it?
Posted by xzajo ( Apr 28 2006, 07:03:48 PM CEST ) Permalink Comments [15]Spellchecker for Javadoc plugin
Spellchecker module was added on nbextras.org update center this week. Author is Jan Lahoda. This module provides Spellchecker API. It underlines misspelled words in the editor, provides hints with possible fixes. Currently is implemented spellchecker for javadoc.
It will be useful if someone also implements spellchecker for HTML editor. Is there any volunteer?
Posted by xzajo ( Apr 27 2006, 01:10:55 PM CEST ) Permalink Comments [5]Nbxdoclet allows to change property for many xdoclet tags at once. It is described at this page. I've implemented this feature for annotations. The feature can be for example used in order to change groups value of TestNG Test annotation property. Look at the screenshot.
Three testcases (methods) are selected in the explorer. The @Test tag is shown in the XDoclet Tags window. Properties of @Test annotations are shown in the property sheet. The <Different Values> is shown for timeOut property because the property is defined only in method2. Change of any annotation's property is applied to all selected methods.
Posted by xzajo ( Apr 21 2006, 08:30:53 PM CEST ) Permalink Comments [9]The best documentation of API - unit test
Developers don't like writing of documentation. Many tutorials and documentations are obsolete. I saw wrong javadoc comments sometimes. I claim that the best documentation of API are the unit tests.
For example I was reading javadoc of Java Language Model API (JMI). From the javadoc I didn't get knowledge how to read, create and modify annotations. Thanks to Google I found some unit tests of JMI module which uses annotations. I can use a pattern shown bellow in my code and I'm sure that it is good usage.
public void testAddAnnotation() throws java.io.IOException, FileStateInvalidException {
boolean fail = true;
Utility.beginTrans(true);
try {
Method method = (Method) clazz.getContents().get(0);
// log the annotation information
getLog().println("Method '" + method.getName() + "' has following annotations:");
for (Iterator it = method.getAnnotations().iterator(); it.hasNext(); ) {
Annotation annotation = (Annotation) it.next();
getLog().println("\tAnnotation named '" + annotation.getType().getName() + "'.");
for (Iterator it2 = annotation.getAttributeValues().iterator(); it2.hasNext(); ) {
AttributeValue attribute = (AttributeValue) it2.next();
getLog().println("\t\tAttribute value '" + attribute.getName() + "', '" + ((MetadataElement) attribute.getValue()).getSourceText() + "'.");
}
}
Annotation ann = createSimpleAnn("\"2004-06-21\"", "\"Lojza\"", "\"Unknown\"", "46");
method = (Method) clazz.getContents().get(1);
method.getAnnotations().add(ann);
fail = false;
}
finally {
Utility.endTrans(fail);
}
assertFile("File is not correctly generated.",
Utility.getFile(getDataDir(), "org/netbeans/test/codegen/AnnotationClass.java"),
getGoldenFile("testAddAnnotation_AnnotationClass.pass"),
getWorkDir()
);
}
I got a idea. Why not to add link to unit tests to javadoc html. TestNG uses annotations to specify tests groups. Why to not add annotations which package, class or method is tested. The link to test sources should be added to javadoc documentation. The test can be also indexed. Usage statistics can shown in javadoc. After that many developers, who don't write tests, will have to write tests I hope. Because the API users (developers) rather choose already tested API.
Posted by xzajo ( Apr 14 2006, 11:14:10 AM CEST ) Permalink Comments [19]NBXdoclet cooperates with Hibernate Query Tool for NetBeans
Hibernate Query Tool (hts) is amazing tool with these feature:
It so cool tool that I had to integrate it with my hibernate plugin for NetBeans 5.0. My plugin provide creating POJO object, facades and helps to setup hibernate dialects. Leon's plugin helps to create and trace queries.
I added a action to Hibernate project extension.
The action opens hts session for active project with hibernate support.
The code completion is really great. This feature will be available on my update center next week.
Project Extensions (natures) Wizard for NetBeans 5.0
Project Extensions plugin is implementation of project natures for NetBeans 5.0. Project natures extends functionality of NetBeans projects. Currently it consists of these features:
To create new project extension is very simple with Project Extension Wizard. It will be demonstrated on creating RMI project extension for J2SE project. The Java RMI (Remote Method Invocation) system allows an object running in one Java Virtual Machine (VM) to invoke methods on an object running in another Java VM. It is necessary to generate stub and skeleton classes using rmic compiler to establish connection between client and server parts. The rmic compiler must to be run on compiled class of implementation of RMI object.
At first we create simple J2SE project with modified build script. We add two new ant's tasks to main build script (build.xml in root folder of project) :
<target name = "-post-compile" depends = "rmi-post-compile"/>
<target name = "rmi-post-compile" depends = "-do-compile">
<property name = "remote.impl.filter" value = "**/*RemoteImpl.class"/>
<rmic base = "${build.classes.dir}" includes = "${remote.impl.filter}"/>
</target>
The -post-compile ant task is empty because the project extension wizard doesn't copy the standard project ant tasks to the project extension template. We can to create implementation of a RMI service and test it now. We expect that everything is alright.
Now it's time start to create a project extension using project extension wizard:
In the second Panel select the project with modified build script and clicked to Next button. After clicking to Next button Customize Project Extension Panel is shown.
The wizard automatically parses the modified build script and shows all new targets. The -post-compile is not added to table with available ant tasks because more project extensions cannot override the same target. Only dependencies between targets are stored to dependencies table.
If we assign to ant target display name the target will be represented by action in popup of project extension node in Project Extensions window. There is not necessary to change dependencies between targets. It will be usefull for example when dependencies between different Project extensions are defined. Click to next button you can specify classpath for the project extension. The libraries are got from Library manager.
RMI doesn't need extra library on the classpath. Click to Next button to show the last panel of wizard. There can be specified the name, display name, icon, post create action and customizer. The post create action is invoked after adding project extension to project. It is useful for example when it is necessary to initialize some properties. The customizer panel is shown in JDialog when is performed Properties action from project extension node.
After clicking to "Finish" button the Project extension template will be generated.
rmiext.xml - descriptor
<featuredefs>
<featuredef name = "RMICompiler"customizerClassRef = "rmiext-RmiextCustomizer.instance">
<title>RMICompiler</title>
<icon>rmiext/rmi.png</icon>
<project>
<type>org.netbeans.modules.java.j2seproject</type>
</project>
<actions>
<anttask>
<name>rmi-post-compile</name>
<title>RMI Compiler</title>
</anttask>
</actions>
<dependsOn>
<anttask>rmi-post-compile</anttask>
<featureName>org.netbeans.modules.java.j2seproject</featureName>
<anttaskInFeature>-do-compile</anttaskInFeature>
</dependsOn>
<dependsFrom>
<anttask>rmi-post-compile</anttask>
<featureName>org.netbeans.modules.java.j2seproject</featureName>
<anttaskInFeature>-post-compile</anttaskInFeature>
</dependsFrom>
<usedtargets>
<usedtarget>rmi-post-compile</usedtarget>
</usedtargets>
<velocityTemplate vmFile = "Rmiext.vm"/>
</featuredef>
</featuredefs>
rmiext.vm - velocity template
<target name="rmi-post-compile">
<property name="remote.impl.filter" value="**/*RemoteImpl.class"/>
<rmic base="${build.classes.dir}" includes="${remote.impl.filter}"/>
</target>
And references are added to layer.xml
<filesystem>
<folder name = "velocity">
<folder name = "build">
<file name = "Rmiext.xml"url = "Rmiext.xml"/>
</folder >
<folder name = "customizers">
<file name = "rmiext-RmiextCustomizer.instance"/>
</folder >
<folder name = "templates">
<file name = "Rmiext.vm" url = "Rmiext.vm"/>
</folder>
</folder>
</filesystem>
The project extension was created. No line of of code was written. So we can try to run the module. And Test the nature. The Nature can be added to project from popup in Project Extensions window.
The project extension node is shown bellow.
The RMIC compile is not run either on project building or from RMI Project extension popup.
This wizard is available in NBXdoclet Modules Development plugin. The plugin available on my update center. The NBXdoclet Modules Development plugin depends on NetBeans Module Development Environment U1.
Posted by xzajo ( Apr 11 2006, 11:09:16 AM CEST ) Permalink Comments [19]NetBeans JavaHelp Set Wizard with validation
In NetBeans Develoment Support Update 1 was introduced JavaHelp Set Wizard with validation.
It generates java help and save a lot of time. To tell you truth I started to write help for my pluging with the JavaHelp Set wizard. I was too lazy to set up the java help files manually.
Modules in NetBeans CVS uses different harness than the harness from NetBeans 5.0. It contains ant target for validation help IDs. But what to do in not netbeans CVS modules? I am too lazy to check the IDs manually that I copied the ant tasks. I've created Java Help Set Project extension.
The NetBeans Harness Extension plugin is available on my update center .
Posted by xzajo ( Apr 10 2006, 05:35:40 PM CEST ) Permalink Comments [14]Try TestNG 4.6 with NetBeans 5.0
Today I have good news for TestNG community. First testing build of TestNG Support 4.6 for NetBeans 5.0 is available on my update center. Plugin with my update center is available here. I've already wrote quick tutorial in previous record about TestNG plugin for NetBeans 5.0.
Please let me know about any problems and possible improvements on nbxdoclet's forum.
Posted by xzajo ( Apr 07 2006, 02:41:53 PM CEST ) Permalink Comments [142]Preview Version of LaTeX for NetBeans 5.0
I am proud to announce testing version of Jan Lahoda's LaTeX for NetBeans 5.0 plugin. How to install
When all modules are successfully download and installed it is necessary to do two thinks :
Please give feedback to Jan Lahoda on users@latex.netbeans.org mailing list. To subscribe send mail to users-subscribe@latex.netbeans.org address.
Posted by xzajo ( Apr 07 2006, 11:26:04 AM CEST ) Permalink Comments [18]NetBeans Module Development Environment U1 released
Good news for everyone who develops plugin and applications for NetBeans. Module Development Environment 5.0 Update 1 is available on stable update center. The most important new features and changes are listed bellow:
I have a tip. Options Panel Wizard and Matisse Form Editor is good combination:
For Example it can look in Options dialog like this :
Test NG plugin for NetBeans 5.0
I finished Test NG project extension for NetBeans 5.0 yesterday in train from Ostrava to Prague. I would like to commit it into cvs because I cannot access to CVS server on sourceforge.net. Probably ssh server is down :(. I'll try describe how to use this plugin:
Create New Test NG case from template:
Generated code of test is here :
package sd ;
import org.testng.Assert;
import org.testng.annotations.Configuration;
import org.testng.annotations.ExpectedExceptions;
import org.testng.annotations.Test;
public class NewTest {
@Configuration(afterTestClass = true)
public static void tearDownClass() {
}
@Configuration(afterTestMethod = true)
public void afterTestMethod() {
}
@Test(groups = { "My group" })
public void testMethod1() {
Assert.fail("failure");
}
The Test NG Project Extension is automatically added to project extensions. There are two action for the extension - Run Tests and Show Results. Look at the snapshot:
Results are shown in web browser:
How to install and download the plugin is here.
Posted by xzajo ( Apr 03 2006, 08:22:13 PM CEST ) Permalink Comments [196]