TOP

JAXB and CDATA Sections

Because I spended a few hours for that, I decided to write a small blog post about that. The challenge was to create a JAXB implementation independent solution for writing CDATA sections with a JAXB marshaller. There are a lot of solutions out there but they are not satisfying me. A lot of them reference the MOXy CDATA annotation or using the Apache XMLSerializer. They are either not implementation independent, does not work, reference deprecated code or have other pitfalls.  The following solution fixes these by using a custom implementation of javax.xml.stream.XMLStreamWriter and has not 3rd party library dependencies. Only the classes of the Java 6 JDK are used. The solution is able to create the following xml:

<test xmlns="http://www.example.org/test" msg="foo">
	<text><![CDATA[<o>]]></text>
	<text>foo</text>
</test>

(weiterlesen …)

Read More
TOP

Portlet Spring Vaadin Integration

Based on blog post from Nicolas Frankel I created the same class which works with portlets. So the method getNewApplication returns an application which is created via Spring.

import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletRequest;
 
import org.springframework.context.ApplicationContext;
import org.springframework.web.portlet.context.PortletApplicationContextUtils;
 
import com.vaadin.Application;
import com.vaadin.terminal.gwt.server.AbstractApplicationPortlet;
 
public class SpringApplicationPortlet extends AbstractApplicationPortlet
{
 
   private Class<? extends Application> clazz;
 
   @Override
   public void init(PortletConfig config) throws PortletException
   {
      super.init(config);
 
      ApplicationContext appContext = PortletApplicationContextUtils.getWebApplicationContext(config.getPortletContext());
 
      Application application = appContext.getBean("application", Application.class);
 
      clazz = application.getClass();
   }
 
   @Override
   protected Class<? extends Application> getApplicationClass() throws ClassNotFoundException
   {
      return clazz;
   }
 
   @Override
   protected Application getNewApplication(PortletRequest request) throws PortletException
   {
      ApplicationContext appContext = PortletApplicationContextUtils.getWebApplicationContext(request.getPortletSession()
            .getPortletContext());
 
      return appContext.getBean("application", Application.class);
   }
 
}
Read More
TOP

Ordered Adobe Lightroom3

Found a nice deal on mydealz.de for a full version of Lightroom 3. I want to use it not because of my big camera equipment (a Panasonic DMC-FX500), nor to start a career as photographer but for managing my photos and to remove small unbeautiful things like red eyes or a overexposure.

Read More
TOP

It is shipped!

I received a mail:

Dear Michael Ernst,

We are pleased to send you this dispatch regarding your Apple Store order W289XXXXXX.

Your Delivery Reference Number is 813XXXXXX.

We expect your order to be delivered to your shipping address on or before 27.09.2010.

So I think it will be in my hand at the end of the next week.

Read More
TOP

The plan to buy an iPhone in Strasbourg is canceled

I ordered it today on the apple website in the United Kingdom. It should be deliverd in 4 weeks. Let’s see! To handle the no address in UK problem I used borderlinx from DHL. They provide me an address in UK, so I can place my order.

Update: We estimate your order to be shipped 04 Oct, 2010.

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

The plan: buy an iPhone 4 in Strasbourg

I’m looking for a new smartphone. My old one, a 5 years old Xda from my carrier O2 is loosing the memery and all phone numbers etc. all the time I forgot to load the phone. This is very cumbersome. So I decided to buy a new one, an iPhone. I will not buy it at the local carrier t-mobile and their very expensive contracts.

Costs at t-mobile:

  • Monthly rate: 59,95 * 24 months: 1438,80 €
  • 32 GB iPhone 4: 199,95 €
  • Service charge: 24,95
  • Price per minute: 0,29 € (when not t-mobile)

So where can I buy an iPhone else? I googelt a lot and first I thought I buy it in the Glattzentrum close to Zurich. But than I thought why should I buy it in a country which is not part of the EU and to pay value added tax for it at the border again. So I decided to look for countries which are part of the EU and sell iPhones without any sim-locks and hey I could buy it in France. Next month I have an appointment 50 km away from Strasbourg so I googelt again and than I found lots of sites which describes where you can buy it in Strasbourg. I found a good link to a shop locator of apple:  http://www.apple.com/fr/buy/locator/

The page lists the following shops for Strasbourg:

  • FNAC Srasbourg
    La Maison Rouge – 22, Place Kléber
    Tel:  (+33) 03 88 52 21 21
    Tagged as an Apple shop
  • BEMAC
    14BIS, Rue de la Mesange
    Tel: (+33) 03 88 22 78 87
    Tagged as a premium reseller
  • BEMAC
    18 Quai St Nicolas
    Tel: (+33) 03 88 25 84 88

A car park is next to Place Kléber:

  • Vincie Park Services
    24 Rue du Fossé des Tanneurs
    (+33) 03 88 23 14 30

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