<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace Site Server v5.9.2 (http://www.squarespace.com/) on Thu, 11 Mar 2010 03:10:58 GMT--><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rss="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:cc="http://web.resource.org/cc/"><rss:channel rdf:about="http://www.mgroh.net/journal/"><rss:title>Journal</rss:title><rss:link>http://www.mgroh.net/journal/</rss:link><rss:description></rss:description><dc:language>en-US</dc:language><dc:date>2010-03-11T03:10:58Z</dc:date><admin:generatorAgent rdf:resource="http://www.squarespace.com/">Squarespace Site Server v5.9.2 (http://www.squarespace.com/)</admin:generatorAgent><rss:items><rdf:Seq><rdf:li rdf:resource="http://www.mgroh.net/journal/2010/1/28/next-generation-daumenkino.html"/><rdf:li rdf:resource="http://www.mgroh.net/journal/2010/1/1/happy-new-year.html"/><rdf:li rdf:resource="http://www.mgroh.net/journal/2009/12/24/merry-christmas.html"/><rdf:li rdf:resource="http://www.mgroh.net/journal/2009/12/9/mailadressen-validieren-mit-ruby.html"/><rdf:li rdf:resource="http://www.mgroh.net/journal/2009/11/27/json-and-rest-with-spring-30.html"/><rdf:li rdf:resource="http://www.mgroh.net/journal/2009/11/24/hello-internet-iii.html"/></rdf:Seq></rss:items></rss:channel><rss:item rdf:about="http://www.mgroh.net/journal/2010/1/28/next-generation-daumenkino.html"><rss:title>Next Generation Daumenkino</rss:title><rss:link>http://www.mgroh.net/journal/2010/1/28/next-generation-daumenkino.html</rss:link><dc:creator>mgroh</dc:creator><dc:date>2010-01-28T13:13:51Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p><object width="400" height="320"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=7050373&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=7050373&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="320"></embed></object></p>
<p><a href="http://vimeo.com/7050373">videogioco-loop experiment</a> from <a href="http://vimeo.com/user2426155">donato sansone</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>&nbsp;</p>
<p>(Danke Marion)</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.mgroh.net/journal/2010/1/1/happy-new-year.html"><rss:title>Happy New Year</rss:title><rss:link>http://www.mgroh.net/journal/2010/1/1/happy-new-year.html</rss:link><dc:creator>mgroh</dc:creator><dc:date>2010-01-01T02:10:51Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p><span class="full-image-block ssNonEditable"><span><img src="http://www.mgroh.net/storage/19034_1276097014980_1006605953_30867885_7758557_n.jpg?__SQUARESPACE_CACHEVERSION=1262311891586" alt="" /></span></span></p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.mgroh.net/journal/2009/12/24/merry-christmas.html"><rss:title>merry christmas</rss:title><rss:link>http://www.mgroh.net/journal/2009/12/24/merry-christmas.html</rss:link><dc:creator>mgroh</dc:creator><dc:date>2009-12-24T16:07:44Z</dc:date><dc:subject>Pop christmas music ratm</dc:subject><content:encoded><![CDATA[<p><span class="full-image-block ssNonEditable"><span><img src="http://www.mgroh.net/storage/Rage-Against-The-Machine-Killing-In-The-Na-34369.jpg?__SQUARESPACE_CACHEVERSION=1261696160682" alt="" /></span></span></p>
<p>The christmas number one 2009 in England, covered by&nbsp;<em>Mambo Kurt</em>.</p>
<p><a href="http://en.wikipedia.org/wiki/Killing_in_the_Name#2009_Christmas_Number_One_campaign">Killing in the name</a></p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/VjQM1szeoGY&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/VjQM1szeoGY&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>And here is the original version by Rage Against the Machine. Still pretty fresh, even though it's 17 years old.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/34Y6Bwc046E&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/34Y6Bwc046E&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>But Hitler is a Joe McElderry and&nbsp;X-Factor fan.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/MO0Auo50A1A&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/MO0Auo50A1A&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>&nbsp;</p>]]></content:encoded></rss:item><rss:item rdf:about="http://www.mgroh.net/journal/2009/12/9/mailadressen-validieren-mit-ruby.html"><rss:title>Mailadressen validieren mit ruby</rss:title><rss:link>http://www.mgroh.net/journal/2009/12/9/mailadressen-validieren-mit-ruby.html</rss:link><dc:creator>mgroh</dc:creator><dc:date>2009-12-09T22:27:40Z</dc:date><dc:subject>Code dns mail ruby script validation</dc:subject><content:encoded><![CDATA[<p>In meinem Twitterstream ist heute eine Frage nach automatisierter <a href="http://twitter.com/muesli/status/6507341420">Email-Validation</a> aufgetaucht. Ich hab vor längerem ein kleines, sehr einfaches ruby-Script geschrieben, dass eine Liste von Mailadressen überprüft, indem es den <a href="http://en.wikipedia.org/wiki/MX_record">MX-Record</a> des hostteils (der Teil hinter dem @) auflöst und dann versucht, sich an den ersten rausgefundenen Mailserver auf dem <span class="caps"><span class="caps">SMTP</span></span> Port zu verbinden. Eine Adresse gilt als valid, wenn beides funktioniert. Nun ist das natürlich ein sehr oberflächlicher Test, weil ja nur der hostteil der Adresse überprüft wird, und das Script spricht auch kein smtp mit dem Server, sondern schaut nur, ob man sich an Port 25 verbinden kann. Trotzdem kann man damit einen Grossteil von Adressen, die zwar der Form entsprechen, aber invalid sind, rausfiltern. Ich bin auch nicht sicher, ob kommerzielle Email-Validation-Software da gross etwas anderes macht(?).</p>

<p>Jedenfalls, falls wieder einmal jemand so etwas braucht: Hier ist das Script (Bis ich das File rausgesucht hatte war der Fragesteller schon manuell durch... :/). Man kann das natürlich sehr leicht so erweitern, dass die Mailadressen aus einem File gelesen werden.</p>

<pre><code>require 'rubygems'
require 'net/dns/resolver'
require 'socket'
include Socket::Constants

def is_valid?(address)
  return false if address.count(&quot;@&quot;) != 1
  packet = Net::DNS::Resolver.start(address.split(&quot;@&quot;).last, Net::DNS::MX)
  mx = packet.answer.first
  return false if mx.nil?
  sock = TCPSocket.new(mx.exchange[0..-2], 25)
  if (sock) then
    sock.close
    return true
  end
  return false
end

#only the first is valid
addresses = [&quot;spam@mgroh.net&quot;, &quot;foo@bla.blub&quot;, &quot;nomail@example.com&quot;]

valid_addresses = addresses.map{|a| a if is_valid?(a)}.compact
puts valid_addresses</code></pre>
]]></content:encoded></rss:item><rss:item rdf:about="http://www.mgroh.net/journal/2009/11/27/json-and-rest-with-spring-30.html"><rss:title>JSON and REST with Spring 3.0</rss:title><rss:link>http://www.mgroh.net/journal/2009/11/27/json-and-rest-with-spring-30.html</rss:link><dc:creator>mgroh</dc:creator><dc:date>2009-11-26T23:28:05Z</dc:date><dc:subject>Code JSON Java REST Spring</dc:subject><content:encoded><![CDATA[<p>The version 3 of the <strong>Spring</strong> framework, which is available as ReleaseCandidate2 now, brings some nice new features for developers who want to add <span class="caps">REST</span>ful web services to a Java web project. I feel it offers a real alternative to the different <span class="caps">JAX</span>-RS implementations, because you need less code and less (but still a bit, it's spring after all :)) configuration of xml files, especially if you use spring anyway. </p>

<p>Interesting enough, Springsource (the company behind spring) decided to add this feature to the spring-mvc project, not spring-ws. The reason behind this is that <cite>"There were a number of technical issues [...] most importantly the approach felt 'clunky' and unnatural for a developer who was already used to Spring <span class="caps">MVC</span> 2.5."</cite> (as stated <a href="http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/">here</a>, which is a nice introduction to the new <span class="caps">REST </span>features in spring 3 btw).</p>

<p>Version 3.0 of spring-mvs adds, among other things, a view to render <span class="caps">JSON </span>representations of your data objects: the <code>JacksonJsonView</code>. Regarding the growing number of rich javascript frontends built with jQuery et al, this of particular interest. As the name suggests, this view relies on the <a href="http://jackson.codehaus.org/">Codehaus Jackson</a> <span class="caps">JSON </span>processor, a parser and generator which is especially known to be really fast. While there were some third-party solutions to add <span class="caps">JSON </span>support to spring based webapps before (<a href="http://spring-json.sourceforge.net">http://spring-json.sourceforge.net</a> for example, to name just one of them), it is nice to have this feature in the framework itself.</p>

<p>To use the <code>JacksonJsonView</code>, you need the current spring-mvc and spring-aop artifacts (3.0.0.RC2 by the time of this writing), and the jackson mapper 1.3.0. The maven dependencies are:</p>

<pre><code>&lt;dependencies&gt;
  &lt;dependency&gt;
  	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
  	&lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
  	&lt;version&gt;3.0.0.RC2&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
  	&lt;groupId&gt;org.springframework&lt;/groupId&gt;
  	&lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
  	&lt;version&gt;3.0.0.RC2&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
  	&lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
  	&lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
  	&lt;version&gt;1.3.0&lt;/version&gt;
  &lt;/dependency&gt;
&lt;/dependencies&gt;</code></pre>

<p>As spring 3 has not yet been released, (the current version is <span class="caps">RC2</span>), you need to add the spring maven repo to your pom file as well:</p>

<pre><code>&lt;repositories&gt;
	&lt;repository&gt;
		&lt;id&gt;springsource maven repo&lt;/id&gt;
		&lt;url&gt;http://maven.springframework.org/milestone&lt;/url&gt;
	&lt;/repository&gt;
&lt;/repositories&gt;</code></pre>

<p>Spring 3 adds the possibility to use content negotiation by <span class="caps">URI </span>and <code>Accept</code> <span class="caps">HTTP </span>header to determine which representation to return via the <code>ContentNegotiatingViewResolver</code>, which is a elegant way to support multiple data representations(JSON, <span class="caps">XML, RSS,</span> Atom...). But to keep things simple I assume we only want to render <span class="caps">JSON </span>and are using the <code>XmlViewResolver</code>. (You can find more on views and view resolving in spring mvc <a href="http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch16s05.html">in the spring documenation</a>).</p>

<p>This means your servlet application context might look like this:</p>

<pre><code>&lt;beans&gt;
&lt;!!-- Search for annotated controllers in the package net.mgroh.www.foo.ctrl --&gt;
&lt;context:annotation-config /&gt;
&lt;context:component-scan base-package=&quot;net.mgroh.www.foo.ctrl&quot; /&gt;

&lt;!!-- Map handler methods on HTTP paths with RequestMapping etc --&gt;
&lt;bean class=&quot;org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter&quot; /&gt;

&lt;!!-- Use the XmlViewResolver --&gt;
&lt;bean name=&quot;viewResolver&quot; class=&quot;org.springframework.web.servlet.view.XmlViewResolver&quot;/&gt;
&lt;/beans&gt;</code></pre>

<p>And you have the following in a file named <code>views.xml</code>:</p>

<pre><code>&lt;beans&gt;
&lt;bean name=&quot;jsonView&quot; class=&quot;org.springframework.web.servlet.view.json.MappingJacksonJsonView&quot; /&gt;
&lt;/beans&gt;</code></pre>

<p>You can then implement a Controller serving a <span class="caps">JSON </span>representation of an object Foo like this:</p>

<pre><code>@Controller
public class FooController {

	@RequestMapping(value = &quot;/foo/{fooid}&quot;, method = RequestMethod.GET)
	public ModelAndView findFoo(@PathVariable String fooid) {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName(&quot;jsonView&quot;);
		modelAndView.addObject(new Foo());
		return modelAndView;
}</code></pre>

<p>And that's all what you need to implement a <span class="caps">REST</span>ful Web Service with Spring <acronym title="omitting a few lines in &lt;textile#1&gt; to configure the &lt;textile#2&gt;, and the details of &lt;textile#3&gt; of course">MVC</acronym>. </p>

<p>In Spring 3 there is a lot more which makes it a easy to use (if you know spring, obviously) and (relatively) lightweight framework for implementing <span class="caps">REST</span>ful Web Services in the Java world. A good starting point is <a href="http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/">this article</a> I mentioned  before and the <a href="http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/">Spring documentation</a> of course.</p>
]]></content:encoded></rss:item><rss:item rdf:about="http://www.mgroh.net/journal/2009/11/24/hello-internet-iii.html"><rss:title>Hello internet, III</rss:title><rss:link>http://www.mgroh.net/journal/2009/11/24/hello-internet-iii.html</rss:link><dc:creator>mgroh</dc:creator><dc:date>2009-11-24T20:47:14Z</dc:date><dc:subject></dc:subject><content:encoded><![CDATA[<p>The third incarnation of mgroh.net is finally online. yay.</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/zSDj7bjAv2s&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/zSDj7bjAv2s&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p><a href="http://www.youtube.com/watch?v=zSDj7bjAv2s">directMEH</a><br /></p>]]></content:encoded></rss:item></rdf:RDF>