<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Olaf&#039;s blog &#187; System architecture</title>
	<atom:link href="http://olafsblog.sysbsb.de/category/system-architecture/feed/" rel="self" type="application/rss+xml" />
	<link>http://olafsblog.sysbsb.de</link>
	<description>Olaf&#039;s blog on software development and life</description>
	<lastBuildDate>Sat, 14 Aug 2010 20:39:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using RPC-style, encoded Axis 1 webservices with spring-remoting</title>
		<link>http://olafsblog.sysbsb.de/using-rpc-style-encoded-axis-1-webservices-with-spring-remoting/</link>
		<comments>http://olafsblog.sysbsb.de/using-rpc-style-encoded-axis-1-webservices-with-spring-remoting/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 20:16:55 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[Axis 1]]></category>
		<category><![CDATA[Jax-ws]]></category>
		<category><![CDATA[Spring-Remoting]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=76</guid>
		<description><![CDATA[Preamble
When working with enterprise integration you will quite often deal with legacy systems integration.
I recently had the case where integration of webservices was requested, and much to my surprise there are huge issues when attempting to integrate old webservices (as in pre axis2 and pre jax-ws).
These webservices use outdated or unsupported methods, such as rpc-style/encoded [...]]]></description>
			<content:encoded><![CDATA[<h2>Preamble</h2>
<p>When working with enterprise integration you will quite often deal with legacy systems integration.</p>
<p>I recently had the case where integration of webservices was requested, and much to my surprise there are huge issues when attempting to integrate old webservices (as in pre axis2 and pre jax-ws).</p>
<p>These webservices use outdated or unsupported methods, such as <a href="http://ws.apache.org/axis2/1_2/Axis2-rpc-support.html">rpc-style/encoded</a> communication, or even worce, outdated elements in the XML messages, for instance &lt;multiref&gt;&#8217;s. Having to integrate such services does of course imply that you cannot change anything on the server side, and thus such an outdated format must still be consumed.<br />
This is a huge problem, since current WS implementations, such as the popular axis2 framework, do simply not support these formats.</p>
<p>What surprised me the most about this is that webservices are designed to make systems independent by defining a common communication and data format, which is the exact opposite of what is going on here &#8211; and these formats are not that old, we are probably talking 4-5 years.</p>
<p>Developers facing these problems are taking rather desperate measures to work around these problems, such as <a href="http://www.jroller.com/0xcafebabe/entry/migrating_smoothly_from_rpc_encoded">using on-the-fly XSLT transformation to convert incoming and outgoing WS messages</a>. However, this binds your application even stronger to the outdated format and specific service data.</p>
<p>In my case I wanted to use <a href="http://static.springsource.org/spring/docs/2.5.x/reference/remoting.html">Spring-remoting</a>. Since the service was RPC-style, I wanted to use the <a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/remoting/jaxrpc/JaxRpcPortProxyFactoryBean.html">JaxRpcPortProxyFactoryBean</a> to create an on-the-fly proxy implementing the service interface. What I did not want to do is having to write any additional code to consume the service. Furthermore, I wanted the complex objects transferred by the services to be represented by standard JAVA beans, and not be generated using the wsdl2java axis1 tools. Here is how I got this to work.<br />
<span id="more-76"></span></p>
<h2>Using Spring-remoting&#8217;s jax-rpc support with axis 1</h2>
<h3>Required maven dependencies</h3>
<p>First, I was willing to make the compromise of having axis1 on my classpath. This might not be the way to go for everyone, unless you are using an OSGI framework, which was not an option in my case. Using jax-rpc with axis1 from spring requires the following dependencies (I am using <a href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">maven&#8217;s dependency management</a> for the sake of simplicity):</p>
<pre class="brush: xml;">
&lt;dependency&gt;
  &lt;groupId&gt;commons-io&lt;/groupId&gt;
  &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;commons-discovery&lt;/groupId&gt;
  &lt;artifactId&gt;commons-discovery&lt;/artifactId&gt;
  &lt;version&gt;0.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
  &lt;artifactId&gt;axis-jaxrpc&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
  &lt;artifactId&gt;axis&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
  &lt;artifactId&gt;axis-saaj&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;wsdl4j&lt;/groupId&gt;
  &lt;artifactId&gt;wsdl4j&lt;/artifactId&gt;
  &lt;version&gt;1.6.2&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;2.5.6&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
  &lt;version&gt;2.5.6&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;cglib&lt;/groupId&gt;
  &lt;artifactId&gt;cglib-nodep&lt;/artifactId&gt;
  &lt;version&gt;2.2&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>Note that this setup is for JDK 1.5. JDK 1.6 ships with quite a lot of jax-ws libraries, so you might want to check whether all of these dependencies are still required when using 1.6, but I fear they might.</p>
<h3>Configuring the service using the port proxy factory bean</h3>
<p>First, I downloaded the WSDL&#8217;s from the services and placed them within my src/main/resources folder to use them offline. This is not required, but I do recommend it. Next step was to set up the factory beans for jax-rpc to generate implementations of my service interfaces:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;&gt;

  &lt;bean id=&quot;myWebService&quot; class=&quot;org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean&quot;&gt;
    &lt;property name=&quot;serviceInterface&quot; value=&quot;my.package.MYServiceInterface&quot; /&gt;
    &lt;property name=&quot;wsdlDocumentUrl&quot; value=&quot;classpath:path/to/my/wsdl.swdl&quot; /&gt;
    &lt;property name=&quot;namespaceUri&quot; value=&quot;namespace/as/defined/in/wsdl&quot; /&gt;
    &lt;property name=&quot;serviceName&quot; value=&quot;ServiceNameFromWsdl&quot; /&gt;
    &lt;property name=&quot;portName&quot; value=&quot;PortNameFromWsdl&quot; /&gt;
    &lt;property name=&quot;servicePostProcessors&quot;&gt;
      &lt;list&gt;
        &lt;!--
          This is for mapping your POJO's to the complex service objects (if you are using any).
          You can use an arbitrary number of mapping &lt;bean&gt; configurations for every model
          namespace of your WSDL.
        --&gt;
        &lt;bean
          class=&quot;org.springframework.remoting.jaxrpc.support.AxisBeanMappingServicePostProcessor&quot;&gt;
	  &lt;!-- encoding style as in WSDL, in my case the outdated soap/encoding --&gt;
          &lt;property name=&quot;encodingStyleUri&quot; value=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; /&gt;
          &lt;property name=&quot;typeNamespaceUri&quot; value=&quot;namespace/for/models/as/defined/in/wsdl&quot; /&gt;
          &lt;property name=&quot;beanMappings&quot;&gt;
            &lt;props&gt;
              &lt;prop key=&quot;my.package.MyPojo&quot;&gt;ModelNameInWsdl&lt;/prop&gt;
            &lt;/props&gt;
          &lt;/property&gt;
        &lt;/bean&gt;
      &lt;/list&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
&lt;/beans&gt;
</pre>
<p>If the service specifies an operation such as <code>ComplexResponseVO getResults(ComplexRequestVO)</code>, you would thus define an interface like so:</p>
<pre class="brush: java;">
public interface MyService {
     MyResponsePojo getResults(MyRequestPojo);
}
</pre>
<p>And map the <code>MyResponsePojo</code> and <code>MyRequestPojo</code> using the AxisBeanMappingServicePostProcessor in the above spring configuration. Spring will serialize and deserialize the pojos using standard getter and setter methods to obtain the values, thus you do not have to care for serialization or marshalling. In fact, your pojos do not even have to be Serializable.</p>
<p>Once you have this stuff up and running, you can inject the <code>MyService</code> implementation into any other spring bean and use it like any other bean. Spring will convert the usually annoying and unrecoverable RemoteExceptions into unchecked remote exceptions, thus if you want to handle these, catching <a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/remoting/RemoteAccessException.html">remote access exceptions</a> is recommended.</p>
<p>Using an interface as the service representation has the additional advantage that it is pretty easy to <a href="http://www.martinfowler.com/bliki/SelfInitializingFake.html">fake or mock the service for integration testing</a>.</p>
<h3>Handling uppercase data type attributes</h3>
<p>Now it&#8217;s getting really ugly: Legacy services sometimes violate the JAVA standards of good coding and specify uppercase attribute names for their data types. This is like writing</p>
<pre class="brush: java;">
public class MyService {
     private SomeType MyFieldName;
     ...
}
</pre>
<p>And thus pretty ugly. When using spring&#8217;s <code>JaxRpcPortProxyFactoryBean</code> things are getting a lot worce: the <code>BeanDeserializer</code> will look for a getter/setter pair (property) starting with an uppercase letter &#8211; and will never find it, since they must start with a lowercase letter. <a href="http://issues.apache.org/jira/browse/AXIS-1761">This is a known issue in Axis 1.x</a>, and there is no fix released for it (and most likely there will never be one). </p>
<p>I solved the problem by providing a subclass of the <code>org.apache.axis.encoding.ser.BeanDeserializer</code> to the <code>JaxRpcPortProxyFactoryBean</code> using a subclassed <code>AxisBeanMappingServicePostProcessor</code> and a customized <code>BeanDeserializerFactory</code>:</p>
<pre class="brush: xml;">
&lt;bean id=&quot;myWebService&quot; class=&quot;org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean&quot;&gt;
...
  &lt;property name=&quot;servicePostProcessors&quot;&gt;
    &lt;list&gt;
      &lt;bean class=&quot;my.package.MyServicePostProcessor&quot;&gt;
      ....
</pre>
<p>Here is the sourcecode for this post processor, the deserializer factory and deserializer:</p>
<h4>The post processor:</h4>
<pre class="brush: java;">
package my.package;

import javax.xml.namespace.QName;
import javax.xml.rpc.encoding.TypeMapping;

import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.springframework.remoting.jaxrpc.support.AxisBeanMappingServicePostProcessor;

/**
 * This {@link AxisBeanMappingServicePostProcessor} registers a
 * {@link MyBeanDeserializerFactory} during
 * {@link #registerBeanMapping(TypeMapping, Class, QName) mapping registration}.
 *
 * @author Olaf Otto
 */
public class MyServicePostProcessor extends AxisBeanMappingServicePostProcessor {

  /**
   * Registers the {@link MyBeanDeserializer} for the given mapping.
   */
  @Override
  @SuppressWarnings(&quot;unchecked&quot;)
  protected void registerBeanMapping(TypeMapping mapping, Class javaType, QName wsdlType) {
    mapping.register(javaType, wsdlType, new BeanSerializerFactory(javaType, wsdlType), new MyBeanDeserializerFactory(javaType, wsdlType));
  }
}
</pre>
<h4>The deserializer factory:</h4>
<pre class="brush: java;">
package my.package;

import javax.xml.namespace.QName;

import org.apache.axis.encoding.Deserializer;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.EnumDeserializer;

/**
 * This {@link BeanDeserializerFactory} provides a {@link #getGeneralPurpose(String) general-purpose}
 * deserializer {@link MyBeanDeserializer capable of handling local names not conforming to the java beans spec}.
 *
 * @author Olaf Otto
 */
public class MyBeanDeserializerFactory extends BeanDeserializerFactory {
  private static final long serialVersionUID = -8880103201020594221L;

  @SuppressWarnings(&quot;unchecked&quot;)
  public MyBeanDeserializerFactory(Class javaType, QName xmlType) {
    super(javaType, xmlType);
  }

  /**
   * Returns either:
   * &amp;lt;ol&amp;gt;
   *       &amp;lt;li&amp;gt;
   *           The super types general-purpose deserializer if the target type or
   *           the XML type is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; or the pre-defined deserializer class
   *           is an {@link EnumDeserializer}
   *      &amp;lt;/li&amp;gt;

   *      &amp;lt;li&amp;gt;A {@link MyBeanDeserializer} otherwise (standard case)&amp;lt;/li&amp;gt;
   * &amp;lt;/ol&amp;gt;
   *
   *  @return never &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;, rather throws a {@link RuntimeException}.
   */
  @Override
  protected Deserializer getGeneralPurpose(String mechanismType) {
    Deserializer deserializer;
    if (javaType == null || xmlType == null || deserClass == org.apache.axis.encoding.ser.EnumDeserializer.class) {
      deserializer = super.getGeneralPurpose(mechanismType);
    } else {
      deserializer = new MyBeanDeserializer(javaType, xmlType, typeDesc, propertyMap);
    }
    return deserializer;
  }
}
</pre>
<h4>The deserializer:</h4>
<pre class="brush: java;">
package my.package;

import static org.springframework.util.Assert.hasText;

import java.util.Map;

import javax.xml.namespace.QName;

import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.ser.BeanDeserializer;
import org.apache.axis.message.SOAPHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

/**
 * This {@link BeanDeserializer} takes care of non-normal local names,
 * i.e. local names starting with an uppercase character.&amp;lt;br /&amp;gt;
 * Such a local name, usually derived from a WSDL description, will
 * lead to a property lookup for a getter/setter pair on the target bean of the deserialization
 * with an uppercase name start. However, all property names start with a lowercase character
 * according to the java beans spec, thus a property with an upper case name start
 * is never found, causing the deserialization to fail.&amp;lt;br /&amp;gt;
 *
 * @author Olaf Otto
 */
public class MyBeanDeserializer extends BeanDeserializer {
  private static final long serialVersionUID = 1183255594948119370L;

  @SuppressWarnings(&quot;unchecked&quot;)
  public MyBeanDeserializer(Class javaType, QName xmlType, TypeDesc typeDesc, Map propertyMap) {
    super(javaType, xmlType, typeDesc, propertyMap);
  }

  @SuppressWarnings(&quot;unchecked&quot;)
  public MyBeanDeserializer(Class javaType, QName xmlType, TypeDesc typeDesc) {
    super(javaType, xmlType, typeDesc);
  }

  @SuppressWarnings(&quot;unchecked&quot;)
  public MyBeanDeserializer(Class javaType, QName xmlType) {
    super(javaType, xmlType);
  }

  /**
   * {@link #normalizeLocalName(String) normalizes} the localName and invokes
   * {@link BeanDeserializer#onStartChild(String, String, String, Attributes, DeserializationContext)}.
   */
  @Override
  public SOAPHandler onStartChild(String namespace, String localName, String prefix, Attributes attributes1, DeserializationContext deserializationcontext) throws SAXException {
    String normalizedLocalName = normalizeLocalName(localName);
    return super.onStartChild(namespace, normalizedLocalName, prefix, attributes1, deserializationcontext);
  }

  /**
   * Converts the first character of the local name to
   * {@link Character#toLowerCase(char) lower case}, if it is
   * {@link Character#isUpperCase(char) upper case}.
   *
   * @param localName must not be &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; and not empty.
   * @return The normalized local name, never &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.
   */
  public String normalizeLocalName(String localName) {
    hasText(localName, &quot;The local name must not be null or empty.&quot;);
    char localNameStart  = localName.charAt(0);
    String normalizedLocalName = localName;
    if (Character.isUpperCase(localNameStart)) {
      StringBuilder builder = new StringBuilder(32)
                    .append(Character.toLowerCase(localNameStart))
                    .append(localName.substring(1));
      normalizedLocalName = builder.toString();
    }
    return normalizedLocalName;
  }
}
</pre>
<p>You might also write you own Serializer if you have the problem &#8220;in the opposite direction&#8221; which, luckily, I didn&#8217;t.</p>
<p>Let&#8217;s hope the current WS standards are not deprecated this fast&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/using-rpc-style-encoded-axis-1-webservices-with-spring-remoting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Modular development with OSGI about to be very, very popular &#8211; finally.</title>
		<link>http://olafsblog.sysbsb.de/modular-development-with-osgi-about-to-be-very-very-popular-finally/</link>
		<comments>http://olafsblog.sysbsb.de/modular-development-with-osgi-about-to-be-very-very-popular-finally/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 11:40:32 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[OSGI]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[eclipselink]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=72</guid>
		<description><![CDATA[It&#8217;s quite exciting to see the tremendous progress in development tools, patterns, frameworks and libraries since the release of JAVA 1.0 in 1996.
Within just thirteen years, development improved from the first applets, from the dark ages of the first EJB standardization attempts and a lack of suitable development processes into an age where aspect oriented [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s quite exciting to see the tremendous progress in development tools, patterns, frameworks and libraries since the release of JAVA 1.0 in 1996.<br />
Within just thirteen years, development improved from the first applets, from the dark ages of the first EJB standardization attempts and a lack of suitable development processes into an age where aspect oriented programming, dependency injection and a freely available range of lightweight yet extremely powerful frameworks, libraries and API&#8217;s finally permitted the humble programmer to do what he always wanted to do &#8211; analyze problems, and elegantly write them down without spending all of his precious time on the syntax.</p>
<p>I would even go as far as saying that there was no object orientation before programming crosscutting concerns and using dependency injection became established mechanisms.<br />
Think about it: The original goal of OO is not to use inheritance, encapsulation, identity and polymorphism, but to express the <em>real world of things</em> &#8211; our reality &#8211; using an <em>abstract world of things</em>, while preserving most of the properties and relationships we observe in reality. </p>
<p>Before AOP, before being able to separate the description of things from creating, configurating and connecting concrete instances through dependency injection frameworks, this goal was hard to achieve.</p>
<h3>Modules larger than classes with OSGI</h3>
<p>Now however, we are about to reach a new stage in development of object orientation in JAVA: Developing modules that are <em>larger than classes</em>, modules which can, once properly identified, be developed independently using all the wonderful technology described beforehand. The technology used to achieve this has a name: <a href="http://en.wikipedia.org/wiki/OSGi">OSGI</a>. This technology has quite a long history of development, but a certain lack of elegance and light-weightiness barred this component model from becoming a real hit in the worldwide development community. This is about to change.<br />
<span id="more-72"></span></p>
<h3>Impact of OSGI on the development process</h3>
<p>Let me stress out here how important it is to be able to develop, manage and deploy such modules. The larger your system, the more developers your project involves, the longer you maintain it &#8211; you will always face the same problem: Developers concurrently working with party of the system that are directly or transitively connected will run into conflicts. You will have different parts of your system requiring different versions of the same library on the same class path. Changing one part of the system will always affect other parts of the system, most of the times in an unplanned fashion. </p>
<p>Test driven developments helps a lot along the way, but you still have a responsibility problem if there&#8217;s one team changing something and this causes a problem in a different part of the system, and dependency issues can be a real mess.</p>
<p>This is where OSGI can play out it&#8217;s strengths. Not only does it offer you complete, classloader-based module isolation. I believe the greatest benefit lies in the development process: Concurrent development is a lot easier with OSGI bundles than with a huge pile of tightly interconnected classes. You can have a lot of changes in the bundle, while exposing a relatively stable interface through which other components access your bundle&#8217;s services. Separation into OSGI bundles can bring the power of the SOA-Idea into &#8220;stand-alone&#8221; applications, without the massive overhead of connecting systems or components through, for example web services.</p>
<p>Of course, this concept has quite an impact on your way of thinking, since you will start to add a new level of decomposition: Which classes form tightly coupled components that could be isolated from other components and used as a service through a well-defined, slim and easy-to-use interface? </p>
<h3>OSGI about to &#8220;break through&#8221;</h3>
<p>Now, why am i so convinced that OSGI is about to finally become as common as using AOP or dependency injection? Because all the popular technologies are just about to embrace OSGI:</p>
<ul>
<li>
    <a href="http://www.jroller.com/habuma/entry/modular_java">Craig walls (Spring framework) has just finished his book an modular JAVA with the spring framework, featuring OSGI and Spring</a>, a very powerful combination.
 </li>
<li>
    <a href="http://it-republik.de/jaxenter/jax/sessions/jax/speaker/#3271">Doug Clarke</a> and <a href="http://it-republik.de/jaxenter/jax/sessions/jax/speaker/#2213">Shaun Smith</a> will hold a presentation on persistence and OSGI with eclipselink (the reference implementation of the JAVA persistence API (JPA))</a>, thus suitable persistence mechanisms for this level of modularization are likely to be close at hand.
 </li>
</ul>
<p>And if you <a href="http://it-republik.de/jaxenter/jax/sessions/?tid=1053">look at the schedule for the JAX, Europe&#8217;s most important software &#038; development conference, there have never been more OSGI topics featured</a> &#8211; at least I would doubt that.</p>
<p>In other words: OSGI will soon be so smoothly integrated with you favorite frameworks, IDE&#8217;s and API&#8217;s that using it will be a breeze &#8211; and a must, if you want to take the quality of your development process and software to the next level.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/modular-development-with-osgi-about-to-be-very-very-popular-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facts on open source projects for decision-makers</title>
		<link>http://olafsblog.sysbsb.de/more-facts-on-open-source-projects-for-decision-makers/</link>
		<comments>http://olafsblog.sysbsb.de/more-facts-on-open-source-projects-for-decision-makers/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 14:16:41 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[QA]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[ohloh.net]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=64</guid>
		<description><![CDATA[Summary
Finding useful information about open source software projects can be tedious &#8211; especially when trying to find facts that your customers understand.
ohloh.net provides excellent, comparable meta information for open source projects and should be on every decision-makers favorites list.
Why this software and not another?
I often find the need to justify the use of a specific [...]]]></description>
			<content:encoded><![CDATA[<h3>Summary</h3>
<p>Finding useful information about open source software projects can be tedious &#8211; especially when trying to find facts that your customers understand.<br />
<a href="http://www.ohloh.net/projects/search">ohloh.net provides excellent, comparable meta information for open source projects</a> and should be on every decision-makers favorites list.</p>
<h3>Why this software and not another?</h3>
<p>I often find the need to justify the use of a specific open source software. Why is is better than another, competing open source software? How much better is the community support? How many supporters does it have? How active is the project and how much effort was spend on it&#8217;s development? How about metrics for the code, and how do you compare software in general?<br />
Those are about the most important questions i have to answer.<br />
<span id="more-64"></span></p>
<h3>Obtaining information about open source projects</h3>
<p>Most of the above questions are not so easy to answer. When it comes to usage statistics and community support, one might be lucky to find the number of committers and the number of downloads, the number of mailings on the project mailing list or a more or less qualified article in a software mag. All of this information can usually be googled up or located on the projects site.<br />
Unfortunately, many of the above facts are only loosely related to a project&#8217;s code quality.<br />
To compare code, i am usually downloading the software and run QA tools on it, such as <a href="http://findbugs.sourceforge.net/">findbugs</a> and <a href="http://www.kclee.de/clemens/java/javancss/">JAVANCSS</a>. But code metrics are something that developers understand, but customers usually do not. They want to know how many happy users a software has and whether or not community support might last long enough to justify investments.</p>
<h3>Best practice: ohloh.net</h3>
<div  style="float:right;margin:0 0 1em 1em;width:303px;height:270px;"><img id="image65" src="http://olafsblog.sysbsb.de/wp-content/uploads/2008/10/hibernate-investment-costs.jpg" alt="Ohloh.net: Investment costs for hibernate so far" /><br /><span style="font-size:80%;">ohloh.net: Money spend on developing hibernate, calculation based on the COCOMO model.</span></div>
<p>Looking for such Information, i found <a href="http://www.ohloh.net/projects/hibernate">ohloh.net&#8217;s project information site for hibernate</a>.<br />
To my surprise, it had most of the things i was looking for. Code metrics. Information on who is involved in the projects development. Usage statistics. Ratings. Reviews. Journal links. An executive summary and statements on the code quality and project state, based on facts.  </p>
<p>
To sum it up i wish that more projects would publish information to the same extend ohloh does. ohloh.net&#8217;s project meta-information should be an example and a blue print for other big open source sites. Sourceforge, for example, is already publishing some useful project information (see for example <a href="http://sourceforge.net/projects/findbugs/">findbugs sf project page</a>) but does not deliver the same amount and quality of information that ohloh has to offer.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/more-facts-on-open-source-projects-for-decision-makers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Howto use acegi-security and the @Secured annotation for method interception</title>
		<link>http://olafsblog.sysbsb.de/howto-use-acegi-security-and-the-secured-annotation-for-method-interception/</link>
		<comments>http://olafsblog.sysbsb.de/howto-use-acegi-security-and-the-secured-annotation-for-method-interception/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 10:19:51 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[acegi]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=52</guid>
		<description><![CDATA[Acegi-security (now spring-security) provides a @Secured (org.acegisecurity.annotation.Secured) annotation.
Classes using this annotation can be processed by a suitable BeanPostProcessor, which will proxy the class so that calls to @Secured methods are intercepted and the required authentication is validated against the acegi security context. Note that the following is a configuration for acegi-security, things might be different [...]]]></description>
			<content:encoded><![CDATA[<p>Acegi-security (now spring-security) provides a @Secured (<code>org.acegisecurity.annotation.Secured</code>) annotation.<br />
Classes using this annotation can be processed by a suitable BeanPostProcessor, which will proxy the class so that calls to @Secured methods are intercepted and the required authentication is validated against the acegi security context. Note that the following is a configuration for acegi-security, things might be different with spring-security.</p>
<p><em>2008-07-12: Comment:<a href="http://www.jroller.com/habuma/entry/method_level_security_in_spring"> It is indeed a lot simpler using spring-security, as Craig Walls demonstrates in this posting in his blog &#8220;Spring-Loaded&#8221;</a></em>).</p>
<p>In order to activate the post processing for the @Secured annotations, a spring configuration such as the following is required:<br />
<span id="more-52"></span></p>
<pre class="brush: xml;">
    &lt;!-- Bean post-processor for activating any advisors --&gt;
    &lt;bean class=&quot;org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator&quot;/&gt;

    &lt;!-- The advisor that creates secured proxies for beans using security annotations such as @Secured --&gt;
    &lt;bean class=&quot;org.acegisecurity.intercept.method.aopalliance.MethodDefinitionSourceAdvisor&quot;&gt;
        &lt;constructor-arg&gt;
            &lt;ref bean=&quot;myMethodInterceptor&quot;/&gt;
        &lt;/constructor-arg&gt;
    &lt;/bean&gt;
</pre>
<p>Where <code>myMethodInterceptor</code> is a <a href="http://acegisecurity.org/acegi-security/apidocs/org/acegisecurity/intercept/method/aopalliance/MethodSecurityInterceptor.html">MethodSecurityInterceptor</a>, which may be configured like this:</p>
<pre class="brush: xml;">
    &lt;bean id=&quot;myMethodInterceptor&quot; class=&quot;org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor&quot;&gt;
        &lt;property name=&quot;validateConfigAttributes&quot; value=&quot;false&quot;/&gt;
        &lt;property name=&quot;authenticationManager&quot; ref=&quot;authenticationManager&quot;/&gt;
        &lt;property name=&quot;accessDecisionManager&quot; ref=&quot;accessDecisionManager&quot;/&gt;
        &lt;property name=&quot;objectDefinitionSource&quot; ref=&quot;objectDefinitionSource&quot;/&gt;
    &lt;/bean&gt;
</pre>
<p>With a suitable <a href="http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/AuthenticationManager.html">AuthenticationManager</a>,  <a href="http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/AccessDecisionManager.html">AccessDescisionManager</a> and and <code>objectDefinitionSource</code> of type <a href="http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/intercept/method/MethodDefinitionSource.html">MethodDefinitionSource</a>.</p>
<p>Often it is the case that annotated bean classes must be proxied directly, rather than proxying some implemented interface. </p>
<p>If you get an exception such as<br />
<code><br />
 Failed to convert property value of type [$Proxy70] to required type ...<br />
 no matching editors or conversion strategy found<br />
</code></p>
<p>Your solution might be to force the proxying of the target class itself using:</p>
<pre class="brush: xml;">
    &lt;!-- Bean post-processor for auto-activating all advisors --&gt;
    &lt;bean class=&quot;org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator&quot;&gt;
        &lt;property name=&quot;proxyTargetClass&quot; value=&quot;true&quot; /&gt;
    &lt;/bean&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/howto-use-acegi-security-and-the-secured-annotation-for-method-interception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why it&#8217;s better to integrate XML schema files into the classpath</title>
		<link>http://olafsblog.sysbsb.de/why-its-better-to-integrate-xml-schema-files-into-the-classpath/</link>
		<comments>http://olafsblog.sysbsb.de/why-its-better-to-integrate-xml-schema-files-into-the-classpath/#comments</comments>
		<pubDate>Sat, 10 May 2008 12:50:54 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=48</guid>
		<description><![CDATA[When using schema files in your XML configuration, it&#8217;s might happen that your XML parser will attempt to actually download the schema file using the configured schema URI.
This is the case when there is no mechanism for resolving the schema URI to a local schema file (as, for example the bean handler registration in spring) [...]]]></description>
			<content:encoded><![CDATA[<p>When using schema files in your XML configuration, it&#8217;s might happen that your XML parser will attempt to actually download the schema file using the configured schema URI.<br />
This is the case when there is no mechanism for resolving the schema URI to a local schema file (as, for example the <a href="http://static.springframework.org/spring/docs/2.5.x/reference/extensible-xml.html">bean handler registration in spring</a>) or when such a mechanism fails.<br />
<span id="more-48"></span><br />
Unfortunately, the XSD URI may either not be retrieved (since not all server configurations permit HTTP connections from an application) or the XSD URI may just be an alias intended to be resolved by a mechanism such as the previously mentioned spring handlers.<br />
In that case, it is very likely that the XML validation by the parser will fail without providing a hint to the missing XSD file that caused the failure, very likely with an error message like this:</p>
<p><code><br />
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ...<br />
</code></p>
<p>Thus, it is recommended to provide the XSD&#8217;s through the applications class path and reference it accordingly in the XML file.<br />
I did this for an <a href="http://activemq.apache.org/">activemq</a> configuration as follows:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
       xmlns:amq=&quot;http://activemq.org/config/1.0&quot;
       xmlns:jms=&quot;http://www.springframework.org/schema/jms&quot;
       xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

           http://activemq.org/config/1.0 activemq-core-5.0.0.xsd
           http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.xsd&quot;&gt;
 ...
</pre>
<p>In this example, the XML file <strong>activemq-core-5.0.0.xsd</strong> will be retreived from the classpath (residing in the default package). Putting the XSD into a subpackage on the classpath or using a <strong>classpath://</strong> URI has not worked for me in <a href="http://www.springframework.org/">spring 2.5.2</a> (and other systems). There appear to be a couple of parsers with only very basic classpath resource retreival capabilities.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/why-its-better-to-integrate-xml-schema-files-into-the-classpath/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why @Configurable and @Transactional don&#8217;t belong to into the same class</title>
		<link>http://olafsblog.sysbsb.de/why-configurable-and-transactional-dont-belong-to-into-the-same-class/</link>
		<comments>http://olafsblog.sysbsb.de/why-configurable-and-transactional-dont-belong-to-into-the-same-class/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 18:57:10 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=35</guid>
		<description><![CDATA[When using the Spring framework, one can still benefit from dependency injection etc. even if a bean is not obtained from a bean factory by using the @Configurable annotation, f.e.:


@Configurable(value = &#34;myBean&#34;)
public class MyBean {
   ...
}

Where myBean is the bean id in the spring context.
This approach can be somewhat problematic, though, when used [...]]]></description>
			<content:encoded><![CDATA[<p>When using the <a href="http://www.springframework.org">Spring framework</a>, one can still benefit from dependency injection etc. even if a bean is not obtained from a <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/beans/factory/BeanFactory.html">bean factory</a> by using the <code>@Configurable</code> annotation, f.e.:<br />
<span id="more-35"></span></p>
<pre class="brush: java;">
@Configurable(value = &quot;myBean&quot;)
public class MyBean {
   ...
}
</pre>
<p>Where myBean is the bean id in the spring context.</p>
<p>This approach can be somewhat problematic, though, when used in conjunction with aspect-oriented features.<br />
Say, for example, you also want to use <a href="http://java.sun.com/developer/technicalArticles/J2EE/jpa/">JPA</a> and require a transactional behavior.</p>
<p>You would usually do the following:</p>
<pre class="brush: java;">
@Configurable(value = &quot;myBean&quot;)
public class MyBean {
   @Transactional
    public void foo() {
    ...
    }
}
</pre>
<p>This will not work, but lead to an exception like this:</p>
<p><code><br />
java.lang.IllegalStateException: Post-processor tried to replace bean instance of type [my.package.MyBean] with (proxy) object of type [my.package.MyBean$$EnhancerByCGLIB$$c029ddbf] - not supported for aspect-configured classes!<br />
</code></p>
<p>The reason is that @Configurable will ask spring to configure the current bean during constructor invokation. During configuration, a number of bean post processors will be invoked on the bean, and one of them, namely the <a href="http://www.jdocs.com/spring/2.5.2/org/springframework/aop/framework/autoproxy/InfrastructureAdvisorAutoProxyCreator.html">InfrastructureAdvisorAutoProxyCreator</a> will find the <code>@Transactional</code> annotation &#8211; which <em>advices</em> the post processor to proxy the bean in order to manage the required transaction&#8217;s context.</p>
<p>But you cannot override the expected outcome of a class instanciation with <code>new</code> with a proxy object &#8211; since it is not of the same type as the expected object!</p>
<p>Thus, <code>@Configurable</code> and <code>@Transactional</code> &#8211; together with any other advice that leads to a proxy object &#8211;  cannot coexist in your class.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/why-configurable-and-transactional-dont-belong-to-into-the-same-class/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ClassCastException, PersistentCollection, Hibernate &amp; JPA</title>
		<link>http://olafsblog.sysbsb.de/jpa-hibernate-cannot-be-cast-to-orghibernatecollectionpersistentcollection/</link>
		<comments>http://olafsblog.sysbsb.de/jpa-hibernate-cannot-be-cast-to-orghibernatecollectionpersistentcollection/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 22:06:20 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=33</guid>
		<description><![CDATA[Verwendet man Hibernate (und JPA) kann es mitunter zu recht exotischen Fehlern kommen.
Ein Beispiel, zu dem ich bei google heute nicht einen einzigen Treffer gefunden habe ist folgende Exception:

...
Caused by: javax.persistence.RollbackException: Error while commiting the transaction
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(
  [...]]]></description>
			<content:encoded><![CDATA[<p>Verwendet man Hibernate (und JPA) kann es mitunter zu recht exotischen Fehlern kommen.<br />
Ein Beispiel, zu dem ich bei google heute <em>nicht einen einzigen Treffer gefunden</em> habe ist folgende Exception:</p>
<p><code><br />
...<br />
Caused by: javax.persistence.RollbackException: Error while commiting the transaction<br />
        at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)<br />
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(<br />
        JpaTransactionManager.java:438)<br />
        ... 55 more<br />
Caused by: <strong>java.lang.ClassCastException: java.util.HashSet<br />
        cannot be cast to org.hibernate.collection.PersistentCollection</strong><br />
        at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:34)<br />
...<br />
</code><br />
<span id="more-33"></span><br />
Das tritt dann auf, wenn man wohlmeinend die Exposition der internen Repräsentation vermeiden wollte und beispielsweise so etwas hier auf einer persistenten Collection macht:</p>
<pre class="brush: java;">
 @Entity
 public  class foo {
       private Set&lt;AnotherEntity&gt; _relatedEntites = new HashSet&lt;AnotherEntity&gt;();

     @OneToMany(cascade = {CascadeType.ALL }, fetch = FetchType.LAZY)
     @Column(name = &quot;RELATED_ENTITIES&quot;)
      public Set&lt;AnotherEntity&gt; getRelatedEntities() {
            return new HashSet&lt;AnotherEntity&gt;(_relatedEntites)
     }
 }
</pre>
<p>Das: <strong>new HashSet<AnotherEntity>(</strong>&#8230;<strong>)</strong> ist ein Fehler, da es aus der vorher erzeugten persistenten Collection wieder eine HashMap macht, die nicht persistiertbar ist.</p>
<p>Um die Manipulierbarkeit der Klasse zu vermeiden kann man stattdessen die <em>@Immutable</em>-Annotation verwenden:</p>
<pre class="brush: java;">
 @Entity
 public  class foo {
       private Set&lt;AnotherEntity&gt; _relatedEntites = new HashSet&lt;AnotherEntity&gt;();

     @OneToMany(cascade = {CascadeType.ALL }, fetch = FetchType.LAZY)
     @Column(name = &quot;RELATED_ENTITIES&quot;)
     @Immutable
      public Set&lt;AnotherEntity&gt; getRelatedEntities() {
            return _relatedEntites;
     }
 }
</pre>
<p>Dann klappt&#8217;s auch mit Hibernate.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/jpa-hibernate-cannot-be-cast-to-orghibernatecollectionpersistentcollection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Typparameter einer generischen java-Klasse zur Laufzeit bestimmen</title>
		<link>http://olafsblog.sysbsb.de/typparameter-einer-generischen-java-klasse-zur-laufzeit-bestimmen/</link>
		<comments>http://olafsblog.sysbsb.de/typparameter-einer-generischen-java-klasse-zur-laufzeit-bestimmen/#comments</comments>
		<pubDate>Tue, 25 Mar 2008 15:04:03 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[System architecture]]></category>
		<category><![CDATA[generics]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=30</guid>
		<description><![CDATA[Einer der etwas komplizierten Teile von Java generics ist der Umgang mit Typparametern zur Laufzeit.
Oftmals wird behauptet, dass es nicht möglich sei, den konkreten Typ eines Typ-Parameters zur Laufzeit zu erhalten. Das stimmt so aber nicht.

Nehmen wir folgende Klassen, wobei Entity und EntityImpl unwichtiger Beispielcode sind:


/**
 * Demonstrates the retrieval of a generic type parameters [...]]]></description>
			<content:encoded><![CDATA[<p>Einer der etwas komplizierten Teile von Java generics ist der Umgang mit Typparametern zur Laufzeit.<br />
Oftmals wird behauptet, dass es nicht möglich sei, den konkreten Typ eines Typ-Parameters zur Laufzeit zu erhalten. Das stimmt so aber nicht.<br />
<span id="more-30"></span><br />
Nehmen wir folgende Klassen, wobei Entity und EntityImpl unwichtiger Beispielcode sind:</p>
<pre class="brush: java;">

/**
 * Demonstrates the retrieval of a generic type parameters actual Class at runtime.
 *
 * @author Olaf Otto
 *
 * @param &lt;T&gt; the generic type.
 */
public abstract class AbstractDao&lt;T extends Entity&gt; {
    @SuppressWarnings(&quot;unchecked&quot;)
    public void foo() {
        Class&lt;T&gt; clazz = null;
        // Since we are targeting this class, we know it is a ParameterizedType.
        // We use getGenericSuperclass in this example since this class is abstract and the method will be invoked
        // on a directly derived class instance.
        ParameterizedType pt = (ParameterizedType) getClass().getGenericSuperclass();
        Type[] typeArguments = pt.getActualTypeArguments();
        // Since we know the maximum number of type arguments (1), this check is sufficient.
        if (typeArguments != null &amp;&amp; typeArguments.length &gt; 0) {
            Type arg = typeArguments[0];
            if (arg instanceof Class) {
                clazz = (Class&lt;T&gt;) arg;
            }
        }
        System.out.println(&quot;Resolved generic type parameter to &quot; + clazz + &quot;.&quot;);
    }
}

/**
 * Dummy class for demonstration purposes.
*/
public class Entity {
}

/**
 *  Dummy class for demonstration purposes.
*/
public class SomeEntity extends Entity {

}
</pre>
<p>Ruft man jetzt innerhalb einer main-Methode oder eines Unit-Tests die Methode <code>foo()</code> auf einer <code>SomeEntity</code>-Instanz auf, so erhält man folgendes Ergebnis:<br />
<code><br />
Resolved generic type parameter to class my.package.name.SomeEntity.<br />
</code></p>
<p>Womit der Typparameter korrekt aufgelöst ist.</p>
<p>Zum Ausprobieren: die verwendete Main-Klasse.</p>
<pre class="brush: java;">
/**
 * A main method provider for demonstration purposes.
*/
public class Main {
    public static void main(String[] args) {
        SomeEntityDao dao = new SomeEntityDao();
        dao.foo();
    }
}
</pre>
<h3>Pro und contra</h3>
<p><a href="http://www.artima.com/weblogs/viewpost.jsp?thread=208860">In einem Ähnlichen Posting zeigt Ian Robertson</a>, wie man diese Systematik unabhängig von der Vererbungshierarchie verwenden kann.<br />
In den <a href="http://www.artima.com/forums/flat.jsp?forum=106&#038;thread=208860">Kommentaren zu seinem Posting</a> wird diskutiert, warum man überhaupt so viel komplizierten utility-Code schreiben sollte, wenn man ebensogut einfach und sicher die Klasse des Typ-Parameters in der ableitenden Klasse bekannt machen kann &#8211; was letztendlich davon abhängt, an wie vielen unterschiedlichen Stellen im Code man die Typinformationen der Parameter benötigt.</p>
<h3>API Dokumentationen zum Posting:</h3>
<p><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/ParameterizedType.html">Die ParameterizedType API-Dokumentation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/typparameter-einer-generischen-java-klasse-zur-laufzeit-bestimmen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring-loaded</title>
		<link>http://olafsblog.sysbsb.de/spring-loaded/</link>
		<comments>http://olafsblog.sysbsb.de/spring-loaded/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 22:42:29 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=29</guid>
		<description><![CDATA[Craig Walls, einer der Autoren des famosen &#8220;Spring in action&#8221; Buches, schreibt in seinem Weblog vieles extrem Lesenswertes rund um Spring. Dank der zahlreichen Codebeispiele eine gute Quelle für best practice Spring &#8211; und natürlich sehr aktuell!
]]></description>
			<content:encoded><![CDATA[<p>Craig Walls, einer der Autoren des famosen &#8220;<a href="http://www.manning.com/walls2/">Spring in action</a>&#8221; Buches, <a href="http://www.jroller.com/habuma/">schreibt in seinem Weblog vieles extrem Lesenswertes rund um Spring</a>. Dank der zahlreichen Codebeispiele eine gute Quelle für best practice Spring &#8211; und natürlich sehr aktuell!</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/spring-loaded/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring context, überall &#8211; auch mit openAMF</title>
		<link>http://olafsblog.sysbsb.de/spring-context-uberall-auch-mit-openamf/</link>
		<comments>http://olafsblog.sysbsb.de/spring-context-uberall-auch-mit-openamf/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 12:45:22 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=27</guid>
		<description><![CDATA[Benutzt man zur Anbindung eines Flash-Frontends openAMF oder macht man irgend etwas Ähnliches, was am DispatcherServlet vorbei geht, muss man nicht auf die AOP basierten scopes verzichten. In diesem Fall stellt ein einfacher Filter in der web.xml die entsprechenden Scopes ur Verfügung: 

    &#60;filter&#62;
        &#60;filter-name&#62;springContextFilter&#60;/filter-name&#62;
 [...]]]></description>
			<content:encoded><![CDATA[<p>Benutzt man zur Anbindung eines Flash-Frontends <a href="http://www.openamf.com/cms/">openAMF</a> oder macht man irgend etwas Ähnliches, was am <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/web/servlet/DispatcherServlet.html">DispatcherServlet</a> vorbei geht, muss man nicht auf die <a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop-api.html">AOP basierten scopes</a> verzichten. In diesem Fall stellt ein einfacher Filter in der web.xml die entsprechenden Scopes ur Verfügung: </p>
<pre class="brush: xml;">
    &lt;filter&gt;
        &lt;filter-name&gt;springContextFilter&lt;/filter-name&gt;
        &lt;filter-class&gt;org.springframework.web.filter.RequestContextFilter&lt;/filter-class&gt;
    &lt;/filter&gt;

    &lt;filter-mapping&gt;
        &lt;filter-name&gt;springContextFilter&lt;/filter-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
</pre>
<p>Mehr dazu gibt&#8217;s natürlich in der <a href="http://static.springframework.org/spring/docs/2.0.x/api/org/springframework/web/filter/RequestContextFilter.html">spring-doku</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/spring-context-uberall-auch-mit-openamf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
