TOP

JAX-RS, JAXB, Jersey, and CDATA

Today I had to reuse my code snippet from the JAXB and CDATA blog post to integrate it into a Jersey web application. The application produces some content which could contain some „strings“ which must be wrapped by a CDATA section. To realize this I implemented a javax.ws.rs.ext.MessageBodyReader and javax.ws.rs.ext.MessageBodyWriter by extending from the class com.sun.jersey.core.provider.jaxb.AbstractJAXBElementProvider. This implementation is registered at the Jersey Application by returning the class object in the com.bosch.im.jaxrs.ImApplication.getClasses() implementation.
(mehr …)

Read More
TOP

JavaScript Parser Generators

When validating the content of an HTML text input field it is often ineffective to trigger the remote validation for each character change. Sometimes you can use a buffer, so validation is only done after a fix time interval. For other scenarios it is a good solution to create a validator which works completely on the client side, using JavaScript. This blog post provides a quick overview and a simple tutorial for creating a JavaScript parser. (mehr …)

Read More
TOP

JPA and custom data types

I even answered a guy in the Hibernate community how to map a datatype like java.net.URL and than I asked myself why some people have problems to provide them in a JPA annotated bean. It is very easy and you don’t have to implement any special JPA provider dependent interface. The solution is so easy. Break your bean down into their properties and annotate this properties as you normally do. And than – no magic – do your mapping in your getter and setter operation. Through this, you hide the information that your bean does not hold a value of your complex type. You break the type down in a setter and recreate it in the getter operation. For performance you can hold a field of your complex type and annotate it with the javax.persistence.Transient annotation.

Read More
TOP

Xpand and tagged value interpretation

I’m currently developing a Java source generator based on UML and UML Profiles. In my profile I created a tagged value with the name „type“ and metaclass „Attribute“. After applying the stereotype to an attribute I had a lot of errors during the code generation. The error message was: „Couldn’t find operation ‚getTypeName(Common::TaggedValueType)‘ for uml::Class.Occured in: EXPAND expand:: … ::Root FOR model“ for „«getTypeName(att.type)»“. I debugged the interpreter and it seems that tagged values can override default visible attributes of the element. There should realy be a warning in the Xpand documentation.

Read More
TOP

CQTP Release 0.0.5

Fixed bugs in import conflict handling and context menu integration. The context menu entry is now also visible in the context menu of the editor.

Read More
TOP

Extend the ‚Source‘ context menu of the JDT

In this post I describe how you can contribute a context menu entry to the ‚Source‘ menu of the JDT.

  • First of all you have to create a new command. Therefore you must use the extension point org.eclipse.ui.commands. See the following example from the CQTP plugin:

    <extension
    point="org.eclipse.ui.commands">
    <command
    	id="de.dainel.cleanqualifiedtypes.command"
    	name="%action.label">
    </command>
    </extension>
  • In the next step you must add a menu contribution to integrate your command into the context menu. Use the extension point org.eclipse.ui.menus as in the following example. As you can see, it is visible when the ‚Source‘ context menu is visible and one of the registred types is selected. It is also visible within the editor of a Java file.

    <extension
    point="org.eclipse.ui.menus">
    <menuContribution
    	allPopups="true"
    	locationURI="popup:org.eclipse.jdt.ui.source.menu?after=additions">
    	<separator
    		name="cleanQualifiedTypes"
    		visible="true">
    	</separator>
    	<command
    		commandId="de.dainel.cleanqualifiedtypes.command"
    		style="push">
    		<visibleWhen>
    		<or>
    		<with variable="activeMenuSelection">
    		<iterate>
    		<or>
    		<adapt type="org.eclipse.jdt.core.IJavaProject"/>
    		<adapt type="org.eclipse.jdt.core.IPackageFragment"/>
    		<adapt type="org.eclipse.jdt.core.IPackageFragmentRoot"/>
    		<adapt type="org.eclipse.jdt.core.ICompilationUnit"/>
    		</or>
    		</iterate>
    		</with>
    		<with variable="activeEditorId">
    		<equals value="org.eclipse.jdt.ui.CompilationUnitEditor" />
    		</with>
    		</or>
    		</visibleWhen>
    	</command>
    	<separator
    		name="additions"
    		visible="false">
    	</separator>
    </menuContribution>
    </extension>
  • Last but not least you must add a handler which is responsible for the behaviour of your command. Use the extension point org.eclipse.ui.handlers and see the following example:

    <extension
    point="org.eclipse.ui.handlers">
    <handler
    	commandId="de.dainel.cleanqualifiedtypes.command"
    	class="de.dainel.cleanqualifiedtypes.handlers.
    		CleanQualifiedTypesHandler">
    </handler>
    </extension>
Read More
TOP

Release 0.0.4 von CQTP

I created a new release of CQTP. It contains a bugfix for an bug in the import grouping. The fully qualified type detector collects more possible import candidates.

Read More
TOP

Release 0.0.3 von CQTP

This release contains a bugfix to filter also imports from the same package and the root package. The Xpand integration provides a configurable sorting functionality for imports now.

Read More
TOP

Release 0.0.2 von CQTP

Heute gab es ein paar Bug-Fixes. Außerdem lässt sich das Plugin jetzt auch außerhalb der Eclipse Runtime nutzen. Aufgund der Änderungen kann ich jetzt ein zuätzliches Plugin für Xpand anbieten. Xpand ist ein Generator-Framework zur Erstellung eigener Code Generatoren.

Xpand basierte Generatoren nutzen oft keine import-Statements, da sie nur sehr komplex erzeugt werden können und sich Importkonflikte nur durch Modeling by Convention vermeiden lassen. Es wird daher oftmals gegen vollqualifizierte Klassen generiert, was den generierten Quellcode nicht schöner macht. Das Plugin lässt sich daher verwenden, um die import-Statements nachträglich zu erzeugen. Daher bietet das Plugin eine postprocessor-Komponente an, die sich in innerhalb einer Generator-Konfiguration einbinden lässt.

Hier geht es zu den Plugins.

Read More
TOP

Release 0.0.1 von CQTP

Heute veröffentliche ich mein erstes Eclipse Plugin. Es erweitert das JDT und dient dem Auflösen von vollqualifizierten Typen zu Import Statements. Hierbei manipuliert das Plugin den Abstrakt Syntax Tree von Kompilaten. Mehr Informationen findet ihr unter folgendem Link.

Read More