I’s been a while since I have written my last blog post. Mostly because I have been busy with Zero2Hero which I have co-founded in fall last year. Zero2Hero is offering the coolest trainings on hot technologies. You can checkout the current offerings at http://www.zero2hero.at.
At the moment we are preparing some Git workshops – we have been able to engage Tim Berglund, a well known GitHubber. Registration has already started.
In the past months we started a series of workhops around Groovy technologies. So we had started out with Groovy (with Dierk König, Canoo), did Gradle (with Peter Niederwieser, Gradleware). In Fall this year we should finalize this series with a Grails training.
Using the Amazon Console create a S3 bucket. Use your domain name (e.g. www.domain.tld) to name the bucket.
Open the properties panel, switch to the Website tab, enable hosting of static web sites. Next go back to the permissions tab and click Edit bucket policy
Yesterday I had to move a few files from a Git repository A to repository B while working on a client’s project. Today I had to do it again on another project. Again I had to think about the sequence of commands I had used. For this reason I’m posting this here.
Prepare repository A (the source)
git clone --no-hardlinks /path/to/sourcerepository repositoryA
# remove remote origin just so we can't break anything in the source repository
git remote rm origin
# filter for desired files
git filter-branch --subdirectory-filter directory HEAD
# move around files, etc.
# then commit
git add .
git commit -m"isolated files"
In line #1 we clone the source repository so we can’t break the original one, we also remove the remote in line #4 so no links back to the source repository exist. Next using the filter-branch command we filter out everything but the directory we want to keep.
Pull files to new repository
For the past 18 months I have been utilizing hades for implementing JPA based repositories/DAOs. Hades has now been moved into the Spring Data JPA project. Starting with their 1.0.1 release I tried migrating one of my projects to this release. Following I document the steps that were necessary to achieve this.
Their project page starts off with showing the Maven repositories and dependency descriptors (in case you are using Maven). Obviously the first thing is to replace the hades artifact by the spring-data-jpa artifact.
The project’s domain classes implement the org.synyx.hades.domain.Persistable interface which has to be replaced by org.springframework.data.domain.Persistable (takes a single generics parameter for the id type).
DAO interfaces extending org.synyx.hades.dao.GenericDao have to be modified to extend org.springframework.data.repository.CrudRepository. With this modification you will face a couple of compile problems. read*-methods have been renamed to find*-methods. Also you are loosing the paging and sorting capable find* – methods (which I didn’t use). If those are required then extend the org.springframework.data.repository.PagingAndSortingRepository interface.
find* – methods now return iterables rather than list types requiring minor adjustments to existing codebase. To get around this, the interface can also extend from JpaRepository. Using this base interface hands you a pretty powerful DAO that goes far beyond a simple CRUD repository.
When I started off with hades many month ago I used an explicit XML-based configuration of DAO components.
With these changes in place all tests were showing the green bar again. However, today I would recommend using repository namespace http://www.springframework.org/schema/data/jpa which significantly reduces the amount of configuration needed by utilizing class path scanning to detect repository components.
Certainly you might encounter more steps during migration depending on the features you have used from the old hades code base. In my case I only had used named JPA queries which just continued to work like before.
What a shame I haven’t published anything for a long time. To make up for this long pause, I’m going to discuss how Spring can support with analyzing class metadata. These days everybody is crazy about using annotations in their frameworks. Occasionally you need to know what classes/methods are annotated. A good example might be to build a list of class names for all JPA entities (those classes annotated with javax.persistence.Entity and the like).
A simple use-case showing how to detect classes annotated as components
This use-case is using a few Spring APIs and some home grown code that controls resource matching (ClassResourceResolver and AnnotationMetadataMatcher).
Under the hood Spring is using the ASM bytecode library for looking into the class files. Not that no class examined by the code above is actually loading any of the class objects so it is fairly lightweight and not filling up your perm gen space. Still you need to make up useful search paths so you don’t end up scanning through you full classpath.
Subversion, das wohl immer noch am weitesten verbreitete SCM im Java-Bereich, muss sich in letzter Zeit einige Kritik gefallen lassen.
Tatsächlich häufen sich die Anzeichen, dass die Konkurrenten aus dem Lager der verteilten Systeme immer mehr an Popularität gewinnen. So wechseln immer mehr Projekte auf das verteilte Versionsmanagementsystem (DVCS) Git.Ist das nur ein temporärer Hype oder eine technologische ®Evolution?
Am 4.Mai 2011 gibt es erstmals in Österreich einen Git Workshop mit Matthew McCullough (offizieller GitHub Trainer) und somit eine einmalige Gelegenheit zu erfahren was denn hinter dem Erfolg von Git steckt.
Anmeldung per EMail (mit Name und Adresse des anzumeldenden Teilnehmers) an email@example.com. Zum Workshop in Englisch werden maximal 20 Teilnehmer zugelassen, ein eigener Laptop ist mitzunehmen.
Anmeldung von Gruppen ab 3 Personen zu ermäßigtem Preis auf Anfrage. Im Preis enthalten sind Getränke sowie ein Brötchenbuffet zu Mittag! Ermäßigtes Parken in der Hoteltiefgarage ist möglich.
Matthew McCullough’s Bio
Matthew McCullough is an energetic 15 year veteran of enterprise software development, world-traveling open source educator, and co-founder of Ambient Ideas, LLC, a US consultancy. Matthew currently is a trainer for GitHub.com, author of the Git Master Class series for O’Reilly, speaker on the No Fluff Just Stuff tour, author of three of the top 10 DZone RefCards, including the Git RefCard, and President of the Denver Open Source Users Group.
His current topics of research center around project automation: build tools (Maven, Leiningen, Gradle), distributed version control (Git), Continuous Integration (Hudson) and Quality Metrics (Sonar).
We all have learned that it is not wise to overuse static methods as these are kind of hard to test and deal with. So in general I strive to get out of their way. Sometimes I’m facing the situation that the use of a framework or that some technical infrastructure requires me to implement static methods.
So for testing I found PowerMock which nicely integrates with EasyMock and Mockito.