28
czerwca
2010
My goal was to create a simple, extensible Enum converter that would work with iBatis. This seems like a trivial problem, but took me a while to find a proper solution.
There were some additional preconditions:
The example Enum for this problem looks like this one (copy&paste from jaxb generated source):
@XmlType(name ="ServiceType")
@XmlEnum
public enum ServiceType {
@XmlEnumValue("stationary")
STATIONARY("stationary"),
@XmlEnumValue("mobile")
MOBILE("mobile");
private final String value;
ServiceType(String v) {
value = v;
}
public String value() {
return value;
}
public static ServiceType fromValue(String v) {
for (ServiceType c: ServiceType.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
"No big deal", you say. I beg to differ. What I wanted to achieve was a simple construction which would look like this when used for another Enum (CommonEnumTypeHandler is the name of my generic converter):
public class ServiceTypeHandler extends CommonEnumTypeHandler{ }
Unfortunately due to the fact, that Java does not have reified generics, which is described in multiple places, I had to stick with passing through a Class type of my enum. So it looks like this:
public class ServiceTypeHandler extends CommonEnumTypeHandler{ public ServiceTypeHandler() { super(ServiceType.class); } }
My final class has to look like this one below:
import java.sql.SQLException; import com.ibatis.sqlmap.client.extensions.ParameterSetter; import com.ibatis.sqlmap.client.extensions.ResultGetter; import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback; public abstract class CommonEnumTypeHandlerimplements TypeHandlerCallback { Class enumClass; public CommonEnumTypeHandler(Class clazz) { this.enumClass = clazz; } public void setParameter(ParameterSetter ps, Object o) throws SQLException { if (o.getClass().isAssignableFrom(enumClass)) { ps.setString(((T) o).name().toUpperCase()); } else throw new SQLException("Excpected " + enumClass + " object than: " + o); } public Object getResult(ResultGetter rs) throws SQLException { Object o = valueOf(rs.getString()); if (o == null) throw new SQLException("Unknown parameter type: " + rs.getString()); return o; } public Object valueOf(String s) { return Enum.valueOf(enumClass, s.toUpperCase()); } }
28
czerwca
2010
Już dziś możecie skorzystać z "umilacza" czytania artykułów. Od zawsze denerwowało mnie rozpraszające badziewie na stronach z artykułami. Teraz z tym koniec. Odkąd odkryłem Readability -- strona bookmarkletu,.
Wszelkie instrukcje na temat korzystania są dostępne na stronie projektu, tak więc warto sprawdzić.
27
czerwca
2010
This year's Javarsovia conference took place on 26th june. It was held at Centrum Konferencyjno-Kongresowe, Bobrowiecka Street, Warsaw.
First of all - the organization was very nice. Everything seemed smooth, maybe with the exception of conference registration, it was simply overcrowded. The agenda was split into four tracks, each hour 4 different presentations were given in different halls. So you just had to choose which one to attend. My path through the conference is described below, together with my views on each of the presentations I attended.
The introductory speech conducted by Mateusz Zięba and some other guy from WarJUG, that I can't seem remember. The speech was very entertaining. Guys did really good job with creating the appropriate atmosphere for the rest of the conference.
Jakub Nabrdalik (TouK) with his "How not to bio-degrade your code" was like the biggest event of the conference - held on the biggest hall of the building, with lots and lots of people attending. The audience was vivid and responded to Jakub's ideas with applause. He played us all very well.
"From request to response" by Jarosław Błąd bored me to death. It wasn't interesting at all to listen about technical details of request handling by all layers of the JEE stack. - like http server, communication with Java app server, kinds of threads in the latter and the likes. What this presentation should have been about were personal views and opinions on other technologies, frameworks - Jarek started to tackle in Q&A section of his speech - that was the real meat!
"Code refactoring" by Piotr Jagielski - overally good, but due to lots of agile, TDD, etc stuff present in the agenda - I kind of lost interest in that particular one.
Fortunately dinner came to aid. With my vital forces rejuvenated by means of lasagne my mind's comprehension skills were back to normal.
That allowed me to enjoy Wiktor Gworek's presentation about Google's style of Java coding. It was worth attending. Thou seamed mainly like a Google Guava introduction - it gave a really fast presentation of Java concepts, how you can beautify your code and give you joy from what you write and create in your normal work day.
"Routes of camel riding" by Maciek Próchniak - a solid does of technical knowledge by another colleague from TouK. Good one - thou didn't get much attention from the public. In fact the topic might have been a little misleading, but still the presentation went out well.
What Jarek Pałka did with his NoSQL talk wasn't ground breaking, but funny enough and entertaining for the finishing act of this conference. For me some moments of his speech were rather enlightening - NoSQL dbs are actually used in some serious real world scenarios! Nice. This presentation gave an insight into one of such DBs - Neo4j, a graph handling DB. Left me with a sense of incompleteness - there was no comparison with other NoSQL products, but this is only an encouragement for me to delve deeper into this subject.
All in all, the conference was a big success, with lots of good talks, meeting friends, talking, listening. Around 650 people were on site, I hope the next one will be even bigger! Please bear in mind that the talks presented by me were only the fourth part of all the talks! AFAIK all of them will be available in video form some time after the conference - perhaps some video editing has to be done, it's not always youtube you are targeting ;-)
Oh, and I didn't win any small laptops, ipods, books, vouchers - crap. Maybe next year ;-)
10
czerwca
2010
Kilka dni temu na portalu OSNews pojawiła się notatka o skromym tytule: What Are You Working On?. Takie proste pytanie spowodowało lawinę komentarzy. Mnóstwo projektów, których ludzie się "dopuszczają" w czasie wolnym. Wszystkie można przeczytać tutaj: komentarze. Jest tam wiele do przeczytania, ale jeden komentarz naprawdę "zrobił mój dzień" :)
Come on people, you can do better than that. - trying to improve a tube theremin I built last year to get more linear response. - putting a webcam in the eye of a HAL9000 replica finished a while ago so it can stream fisheye video ;) - part of a team which put a 4m high black monolith in the pedestrian area of my home town :-D - working on a hardware/software solution so my iTunes can display the current track on the cheap LED display i got off eBay - organizing a visit from Tesla Coil Orchestra to play on their tesla coils ...and all that wile running a museum of old computers. I think I may be overstretching myself a bit, but it feels good.
21 kwietnia 2010, 18:01:59 | Reaktywacja o-filmoramy? |
Mam nadzieję, że wreszcie jednak ruszę z blogiem filmowym, po raz kolejny należy mu się reaktywacja.
http://o-filmorama.blogspot.com