Work in progress

I'm slowly moving my blogs from blogger to here on wordpress, so things will be in a state of flux for a while.

If you are looking for a specific article and have been redirected here, either try the search on the right or you may be looking for ssh askpass on OSX 10.5

Kenai – is it closing or is it staying?

2010 February 6
by petermount1

Well this is a bit of a shock – first they were going to close Kenai.com so a lot of projects (including myself) started migrating away as we had a deadline of 20th April but a couple of hours ago I got an email saying everything’s changed. Now it appears that they are going to migrate java.net to the kenai architecture so all projects are going to be migrated there rather than just deleted.

Now they could have told us this in the first place and have saved a lot of us the now wasted time of migrating everything away from kenai – effectively 1 1/2 weeks wasted in ensuring nothing is lost.

It’s not all wasted effort however.

As I use a distributed scm (Mercurial) I’ve now got a working online backup of the sources over at bitbucket.org – thats working fine, so if this is true then that will stay. I have an offline backup of the repos which I automatically push to anyhow, so getting that job to push back out to bitbucket is easy. As a bonus you can even see commits on twitter.

Also the maven repositories are at sonatype – so there maven is now working better than it did at kenai (one of the only two things I had problems with on kenai).

The one big problem I had in migrating was the project. I had created two projects on javaforge.com as that appeared to have something closer to kenai (other than jira). However I soon found two major downsides to it.

  1. You must have a javaforge account to clone from mercurial – you can’t even browse source unless logged in
  2. Anyone who submits a changeset must also have a javaforge account

Now these problems are terrible. It effectively locks you in to them and removes the benefits of having a distributed scm – receive a changeset from someone and push it to there – they automatically refuse the changeset. Also why prevent someone access to the source if they are anonymous? I’ve since found references to that problem where people have given up on javaforge because you can’t to it. Not good.

So what now?

Well I’m going to plod on – I’ve got a few major issues to sort out with JAXB and XMPP to deal with, so I’m going to see what is said over the weekend after the surprise announcement. If this is true then I’m going to stay with kenai/java.net – lets hope this means keeping jira! As others have said in the forums, kenai is the best forge out there and the only one with true IDE support with NetBeans’s kenai module.

I’ll finish off (it’s 3:30 in the morning right now) with the email about this change of heart from Oracle:

Gentlepeople,

In an effort to get information out to the Kenai community quickly, while trying to manage the integration of our two companies, I think we did a poor job at communicating our plans for Kenai.com to you. I would like to remedy that now. Our strategy is simple. We don’t believe it makes sense to continue investing in multiple hosted development sites that are basically doing the same thing. Our plan is to shut down kenai.com and focus our efforts on java.net as the hosted development community. We are in the process of migrating java.net to the kenai technology. This means that any project currently hosted on kenai.com will be able to continue as you are on java.net. We are still working out the technical details, but the goal is to make this migration as seamless as possible for the current kenai.com projects. So in the meantime I suggest that you stay put on kenai.com and let us work through the details and get back to you later this month.

Thanks for your feedback and patience.

Ted Farrell
Oracle Corporation

Moving away from Kenai

2010 January 28
by petermount1

As is commonly known, Oracle have finally taken over Sun and yesterday they announced what they are intending to do with the various services provided by Sun.

Unfortunately one of those announcements was that they were withdrawing the Kenai project from public use at some point in the near future. This is a pity because the Kenai project was becoming one of the more useful forges out there.

During today there’s been a lot of forum activity on the kenai site from a lot of project owners about what to do in migrating away, including myself.

So, after a good year of being hosted on kenai I’m now faced with moving to yet another forge – but where to go and what’s going to be involved?

Well the steps needed are (in order of importance):

  1. Move the source repositories
  2. Move the maven repository
  3. Move the jira issues
  4. Change all links to the new location(s).

As an initial measure I’ve mirrored the mercurial repositories on bitbucket so at least they are mirrored elsewhere. One of mercurial’s features is being distributed so that was relatively painless.

The next two are tricky so I’m still researching them, but they all depend on what forge to use. I’ve used sourceforge in the distant past so I don’t want to go back to them, and although bitbucket does have wiki and a tracker – it’s not jira.

Anyhow here’s the new repo information for the bitbucket mirrors:

  • https://username@bitbucket.org/petermount/reteptools/
  • https://username@bitbucket.org/petermount/retepmicrokernel/
  • https://username@bitbucket.org/petermount/retepxmpp/
  • https://username@bitbucket.org/petermount/retepjavadoc/

As soon as I’ll have more information I’ll make another post here, on twitter and on identi.ca

    Binding custom objects to attributes in JAXB

    2010 January 4
    by petermount1

    When generating Java sources from an XML Schema with JAXB, the type of field used to represent an attribute is determined by it’s type in the schema.

    For example, a snippet from jabber-client.xsd:

       <xs:element name="message">
         <xs:complextype>
            <xs:attribute name="from" type="xs:string" use="optional">
            <xs:attribute name="to" type="xs:string" use="optional">
         </xs:complextype>
       </xs:sequence>
       </xs:element>

    By default, JAXB would create the object (Message in this case) with two String properties. To change this to another object (say JID) we would add a simple binding changing these to use JID and define two static methods who’s job it is to convert between a String and a JID.

    So the bindings would be something like:

       <bindings schemalocation="jabber-client.xsd">
         <bindings node="/xsd:schema/xsd:element[@name='message']/xsd:complexType">
           <bindings node="xsd:attribute[@name='from']">
             <property>
               <baseType>
                 <javaType name="uk.org.retep.xmpp.JID"
                   parseMethod="uk.org.retep.xmpp.jaxb.adaptor.XMPPDatatypeConverter.parseJID"
                   printMethod="uk.org.retep.xmpp.jaxb.adaptor.XMPPDatatypeConverter.printJID"
                 />
               </baseType>
             </property>
           </bindings>
         </bindings>
       </bindings>

    Now for mose usecases this is fine and works pretty well. The problem is when you have a large number of custom bindings.

    What JAXB does for each binding is that it generates an anonymous Adapter class. In that adaper class are two methods which call the two methods declared in the binding – in the case of binding to a Double you would get the following:

    public class Adapter1
        extends XmlAdapter<String, Double>
    {
    
        public Double unmarshal(String value) {
            return (javax.xml.bind.DatatypeConverter.parseDouble(value));
        }
    
        public String marshal(Double value) {
            if (value == null) {
                return null;
            }
            return (javax.xml.bind.DatatypeConverter.printDouble(value));
        }
    
    }
    

    The problem here is that JAXB generates one of these for every instance, so you can end up having multiple Adapter classes present, all doing the same thing. In one instance I had a single schema contain 16 duplicates of the above code. In retepXMPP I had almost 60 spread over multiple schemas just for handling JID. This is a lot of wasted, duplicated code and if you use a large number of schemas then this is going to cause both your jar sizes and permgen use to increase for no real reason.

    So it would be nice to reduce this down to a single adapter.

    Fortunately there is a way when using the JAXB RI. There is an alternate javaType binding which takes the full class name of an adapter class instead – using this causes JAXB to use that single class instead of generating these duplicate classes. The main difference is replacing the parseMethod and printMethod attributes with a single adapter attribute, and qualifying the javaType with the http://java.sun.com/xml/ns/jaxb/xjc namespace.

    So the bindings would be something like:

    <bindings
        xmlns="http://java.sun.com/xml/ns/jaxb"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
        xmlns:retep="http://retep.org/xml/ns/retepTools"
        version="2.0">
       <bindings schemalocation="jabber-client.xsd">
         <bindings node="/xsd:schema/xsd:element[@name='message']/xsd:complexType">
           <bindings node="xsd:attribute[@name='from']">
             <property>
               <baseType>
                 <xjc:javaType adapter="uk.org.retep.xmpp.jaxb.adaptor.JIDAdapter" name="uk.org.retep.xmpp.JID" />
               </baseType>
             </property>
           </bindings>
         </bindings>
       </bindings>
    </bindings>

    Then just create a single adapter implementation. in retepXMPP thats some 60 classes reduced to one, if you generate any javadocs based on the generated sources there’s no more “Adapter” spam – large numbers of apparently duplicated classes in the javadocs etc.

    Tip: Just make sure you keep an eye on that namespace – miss it out and XJC will spurt out some unusual error messages.