<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Middleware Warez</title>
	<atom:link href="http://dywicki.pl/feed/" rel="self" type="application/rss+xml" />
	<link>http://dywicki.pl</link>
	<description>Do more, pay less &#124; Rób więcej, płacąc mniej</description>
	<lastBuildDate>Tue, 28 Feb 2012 00:11:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Advanced Apache Camel logging and best practices</title>
		<link>http://dywicki.pl/2012/02/advanced-apache-camel-logging-and-best-practices/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=advanced-apache-camel-logging-and-best-practices</link>
		<comments>http://dywicki.pl/2012/02/advanced-apache-camel-logging-and-best-practices/#comments</comments>
		<pubDate>Tue, 28 Feb 2012 00:09:14 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[Middleware]]></category>
		<category><![CDATA[Camel]]></category>
		<category><![CDATA[Karaf]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=756</guid>
		<description><![CDATA[Apache Camel supports a mapped diagnostic context which can be used to improve log entries, but also there is a log component which makes it easier to create log entries. Together they can be used to create foundations of activity monitoring without need to deploy another tool or database. Logging anti patterns First of all [...]]]></description>
			<content:encoded><![CDATA[<p>Apache Camel supports a <a href="http://camel.apache.org/mdc-logging.html">mapped diagnostic context</a> which can be used to improve log entries, but also there is a <a href="http://camel.apache.org/log">log component</a> which makes it easier to create log entries. Together they can be used to create foundations of activity monitoring without need to deploy another tool or database.<br />
<span id="more-756"></span></p>
<h2>Logging anti patterns</h2>
<p>First of all let&#8217;s go throught logging <a href="http://gojko.net/2006/12/09/logging-anti-patterns/">anti patterns</a> described years ago by Gojko Adzic. They are really good and shows how to avoid common problems:</p>
<ul>
<li>Single log file for all people</li>
<li>Lack of hierarchy in log categories (that&#8217;s mine idea)</li>
<li>Incomplete data in entries (covers also one information split to multiple entries)</li>
<li>Different separators in single line</li>
<li>Inconsistent log entry format (covers also inconsistent log entry format)</li>
<li>Multi-line entries</li>
<li>Populating log after the action</li>
</ul>
<p>Let describe comon mistakes we can do with Camel and how these anti patterns can look in our case. My thoughts can be really close to Gojko, but I&#8217;ll try to show you where you can meet these anti patterns on Java ground.</p>
<h3>Single log file</h3>
<p>As usual log file can be used by different people for diagnostic &#8211; eg. database administrators are not interested in all java stuff we do. Message processing, filtering and so on. They want to see query, their parameters and execution time. Nothing else. System administrators are another group which are forced to read dozen of lines to find exception with message &#8216;Too many open files&#8217;. IOExceptions are definitely category important for these people more than surrounding. We can leverage existing features from logging framework to create advanced filters to route logs.</p>
<h3>Lack of hierarchy in log categories</h3>
<p>Many libraries use a single log category or only few to do logging. That&#8217;s completly wrong idea. Let take a look for Atomikos. By default all log are produced by &#8216;atomikos&#8217; category. Even if you are interested in connection pooling tracing you are forced to see almost all events happened from begining of transaction to it&#8217;s end. In case of Apache Camel and middleware &#8211; consider:</p>
<ul>
<li>Usage of own categories, different than a framework which will reflect your mediation process logic, not technical details. Even if you are genius programmer you can be confused by log entries not connected with any process stage.</li>
<li>Be sure that all events produced by your processors, classes and context or route go to same log hierarchy &#8211; eg. org.code_house.esb.sap.finance, instead of &#8220;processor&#8221;, &#8220;org.myjavapackage&#8221; and so on. Be consistent on that.</li>
<li>Do not trust a thread name and do not use it as the category. Name of it can be changed by camel core change or component update.</li>
</ul>
<p>Camel components have a proper packages and you can easily get rid of statements unnecessary for you.</p>
<h3>Incomplete data in entries</h3>
<p>That&#8217;s I think most common mistake. The best example is Hibernate and SQL parameters logging. To get all data related to SQL query exceution and parameter binding we all are forced to use two totally different categories which are not in same hierarchy. If you are happy with setting TRACE level for org.hibernate package you can skip this example.<br />
If you have all parameters and SQL query put it together to log stream. Even if line will be insane long you will be sure that you see parameters for this SQL query, not two different.</p>
<h3>Different separators in single line</h3>
<p>I like to have a log with brackets, pipes and dots. This is so geeky. You look like guy who can see matrix and knows what is happening. Actually you do, but text processing tools are not so smart as we. Parsing is as complex as log pattern is. So don&#8217;t use too complex patterns in production and try to use singular separator. Some commercial tools require a special log format. Cook it for this tool in separate file or use different appender. Even if it is redundant. Keep main log clear and not affected by specific format which cuts 50% of diagnostic information or make it harder to read.</p>
<h3>Multi-line entries</h3>
<p>Just imagine that your SQL query have 5 lines. Not too much, isn&#8217;t? But what&#8217;s when you have a 200KB (or more) payload? Your log will grow quicker than disk size. Basically multi line entries can make parsing harder, but also makes log file longer and harder to read. If you need to keep messages don&#8217;t do that in log file. That&#8217;s not place for that. Reuse auditing features from <a href="http://servicemix.apache.org/SMX4NMR/11-audit.html">ServiceMix NMR</a> or archive <a href="http://activemq.apache.org/amq-message-store.html">ActiveMQ store</a>. You can also build your own mechanism as well if these are not sufficient using asynchronous <a href="http://camel.apache.org/wire-tap">Wire Tap pattern</a>.</p>
<h3>Populating log after the action</h3>
<p>Latest anti-pattern &#8211; remember that logs are produced by code should prelude a operation. Not other &#8211; otherwise log entry before exception will point to mediation which was fine or your will be not able to say what happened with given message. If you are against this point remember to notify people about your logging behavior. Most of them expect that log stream allows to see path before error occured (I received message with given ID), error (exception during message transofrmation) and recovery actions (message moved to dead letter).</p>
<h2>Best practices of logging with Apache Camel</h2>
<p><img src="http://dywicki.pl/wp-content/uploads/2012/02/no-name-jmx.png" alt="" title="Camel context without name set" width="299" height="571" class="alignright size-full wp-image-765" /><br />
Apache Camel uses slf4j as logging library. It&#8217;s a generic facade to many different logging libraries. You don&#8217;t have to use it in your project directly, you still can use Log4j or commons-logging, but it&#8217;s always the better to have less dependencies and clean classpath. I will not complain about ideas behind slf4j here, just point to your nous and let you nod. <img src='http://dywicki.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Name your elements</h3>
<p>If you going to live with your middleware you should know what happens when. Especially that you will have difficulty to access production environment with your lovely IDE and debugger. That&#8217;s why at least camel context should have a name. From runtime management point of view it should always have a given name. If you have a JMX console to do some administrative operations than 182-camel-10 is confusing. Just see image on right side and try to say what the following processors do. Sure, you can do that by walking whole JMX tree.</p>
<h3>Use a Mapper Diagnostic Context (MDC)</h3>
<p>MDC is an bridge from your application to logging framework. You can set some application specific variables and then re-use them to create rich log format or distinct log files by application id (yeah, it seems like missing feature in Tomcat for me too). This feature is disabled by default for Camel but it might be easily turned on. Let&#8217;s have a look on MDC variables set by Apache Camel:</p>
<ul>
<li>breadcrumbId</li>
<li>exchangeId</li>
<li>messageId</li>
<li>correlationId</li>
<li>routeId</li>
<li>camelContextId</li>
<li>transactionKey</li>
</ul>
<p>Each variable from this list can be used in combination with log format or appender. For example if you have all variables set correctly you can use this format:</p>
<pre class="brush: plain; title: ; notranslate">
log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %X{camelContextId} %X{bundle.version} | %X{routeId} %X{exchangeId} | %m%n
</pre>
<p>And you will get following line produced:</p>
<pre class="brush: plain; title: ; notranslate">23:56:12,158 | INFO  | database-batch 2.8.0.fuse-01-06 | jms-inbound-hr | ID-Code-House-local-60526-1330335502920-25-33 | Received message</pre>
<p>For me it&#8217;s still do not look like something easy to read, that&#8217;s why I introduce appender:</p>
<pre class="brush: plain; title: ; notranslate">
log4j.appender.integrationProcess=org.apache.log4j.sift.MDCSiftingAppender
log4j.appender.integrationProcess.key=camelContextId
log4j.appender.integrationProcess.default=unknown
log4j.appender.integrationProcess.appender=org.apache.log4j.RollingFileAppender
log4j.appender.integrationProcess.appender.layout=org.apache.log4j.PatternLayout
log4j.appender.integrationProcess.appender.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %X{routeId} %X{bundle.version} | %X{exchangeId} | %m%n
log4j.appender.integrationProcess.appender.file=${karaf.data}/log/mediation-$\\{camelContextId\\}.log
log4j.appender.integrationProcess.appender.append=true
log4j.appender.integrationProcess.appender.maxFileSize=1MB
log4j.appender.integrationProcess.appender.maxBackupIndex=10

log4j.category.com.mycompnany.camel_toys.hr=INFO, integrationProcess
</pre>
<p>By default, when the camelContextId is not set log entries will be appended to file data/log/mediation-unknown.log. But for these which have a context ID it will look much better (file mediation-database-batch.log):</p>
<pre class="brush: plain; title: ; notranslate">
00:38:42,386 | INFO  | jms-inbound-hr 2.8.0.fuse-01-06 | ID-Code-House-local-51055-1330383822002-4-67 | Received message with business key XYZ.
00:38:43,387 | INFO  | jms-inbound-hr 2.8.0.fuse-01-06 | ID-Code-House-local-51055-1330383822002-4-67 | Saving message in database
00:38:44,388 | INFO  | jms-inbound-hr 2.8.0.fuse-01-06 | ID-Code-House-local-51055-1330383822002-4-67 | Processing of message with business key XYZ complete.
00:38:44,389 | INFO  | jms-inbound-hr 2.8.0.fuse-01-06 | ID-Code-House-local-51055-1330383822002-4-68 | Received message with business key ZYX.
00:38:45,390 | INFO  | jms-inbound-hr 2.8.0.fuse-01-06 | ID-Code-House-local-51055-1330383822002-4-68 | Saving message in database
00:38:45,391 | ERROR | jms-inbound-hr 2.8.0.fuse-01-06 | ID-Code-House-local-51055-1330383822002-4-68 | Processing of message with business key ZYX failed.
</pre>
<p>As you see these log entries contains only a process specific informations and they are not influenced by technical details. A category is skipped because it is not relevant in this context (it still for developer logging but not here). Also you don&#8217;t have to extract a business key. You might use a breadcrumbId header or correlationId property.<br />
Before you will start using MDC be aware that the property names might be changed because issue <a href="https://issues.apache.org/jira/browse/CAMEL-5047">CAMEL-5047 Clean up MDC property names</a>. This configuration was tested with Camel up to 2.9 release. The bundle.version property is set by pax-logging, not Camel and I treat it as a mediation process version. Log4j sift appender is a wrapper so it will work also with syslog or an database appender.</p>
<h3>Embedded processors</h3>
<p>Embedded processors are something common in java DSL. If you use them your category will contain a dollar sign (my.company.RouteBuilderExt$1). Then you should not implement too complex logic in it. If you need do something more than glue strings or set header and you wish to log that &#8211; then create a separate class and remember about log category hierarchy and do not use a RouteBuilder log category. Processor logic is deeper than the route builder&#8217;s and you do some specific task. Separate it. Keep same approach for AggreagatorStrategy and org.apache.camel.spi extensions.</p>
<pre class="brush: java; title: ; notranslate">
package com.mycompnany.camel_toys.hr;
public class Route extends RouteBuilder {

    Log log = LogFactory.getLog(Route.class);

    @Override
    public void configure() throws Exception {
        from(&quot;&quot;)
            .onException(Exception.class)
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        org.apache.camel.Message out = exchange.getOut();
                        out.setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500));
                        log.error(&quot;Unexpected exception&quot;, exchange.getException());
                    }
                }
            })
            .end()
            .to(&quot;&quot;)
    }
}
</pre>
<p>It&#8217;s better to have:</p>
<pre class="brush: java; title: ; notranslate">
package com.mycompnany.camel_toys.hr; // or .processor if we have few or logic is complex
public class ExceptionProcessor implements Processor {
    // slf4j!
    private Log log = LoggerFactory.getLogger(ExceptionProcessor.class);
    @Override
    public void process(Exchange exchange) throws Exception {
        org.apache.camel.Message out = exchange.getOut();
        out.setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500));
        log.error(&quot;Unexpected exception&quot;, exchange.getException());
    }
}
</pre>
<h3>Usage of camel-log component</h3>
<p>Most of use this component in more or less proper way. For example:</p>
<pre class="brush: java; title: ; notranslate">
onException(Exception.class)
    .log(&quot;Unexpected exception ${exception}&quot;)
.end()
</pre>
<p>By default your logging category will be set to route id (eg route4, route5 etc) which will obviously not help in detecting the issues. Also log level is not present so it&#8217;s set by default to INFO. A proper usage is:</p>
<pre class="brush: java; title: ; notranslate">
onException(Exception.class)
    // see, I have here a same category as route builder because it's on same level
    .log(LoggingLevel.ERROR, &quot;com.mycompnany.camel_toys.hr&quot;, &quot;Unexpected exception ${exception}&quot;)
.end()
</pre>
<h2>Quick summary</h2>
<p>It&#8217;s too late to continue this blog entry, but I hope it will be useful for all of you. Remember &#8211; be a reasonable. Use short log entries for business activity monitoring and keep them far from technical details. A statement &#8220;Rejecting message because validation error&#8221; is sufficient for 95% of people. The remaining 5% is involved in development but for these you have a separate log. <img src='http://dywicki.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I hope you like the idea of best practices and you would like to see more similar entries. If you feel yourself more experienced than I or you simply prefer a different approach and would like share your ideas &#8211; do that. It will be pleasure to discuss here or link to your reply on other blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2012/02/advanced-apache-camel-logging-and-best-practices/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache Aries under Apache Tomcat</title>
		<link>http://dywicki.pl/2012/01/apache-aries-under-apache-tomcat/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apache-aries-under-apache-tomcat</link>
		<comments>http://dywicki.pl/2012/01/apache-aries-under-apache-tomcat/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 20:51:40 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=754</guid>
		<description><![CDATA[Few months ago I&#8217;ve read an article written by my friend Jacek Laskowski &#8211; Enterprise OSGi runtime setup with Apache Aries Blueprint. In his article Jacek describes which bundles should be installed to get the blueprint working. As IBM employee Jacek can always promote IBM WebSphere in version X or Y which started (or will [...]]]></description>
			<content:encoded><![CDATA[<p>Few months ago I&#8217;ve read an article written by my friend <a href="http://jlaskowski.blogspot.com">Jacek Laskowski</a> &#8211; <a href="http://www.jaceklaskowski.pl/wiki/Enterprise_OSGi_runtime_setup_with_Apache_Aries_Blueprint" title="Enterprise OSGi runtime setup with Apache Aries Blueprint">Enterprise OSGi runtime setup with Apache Aries Blueprint</a>. In his article Jacek describes which bundles should be installed to get the blueprint working. As IBM employee Jacek can always promote IBM WebSphere in version X or Y which started (or will start) supporting blueprint as dependency injection mechanism. That&#8217;s not fine for these who do not run IBM producs and want something light. As you know, Aries and OSGi Blueprint is an alternative for old-fashion Spring approach.<span id="more-754"></span></p>
<h2>Why I would use Aries Blueprint instead of Spring?</h2>
<p>That&#8217;s good question. Let me answer. First of all Aries runs fine with OSGi. With OSGi you have full modularity and extensive life cycle for your deployment units. Spring Framework is cool and offer you only life cycle for your beans. Just imagine that you don&#8217;t have to assembly whole webapp every time when your DAO implementation is changed. Also Spring have some issues with custom namespaces and supports only one way of hadling it &#8211; fail fast. If you are interested in details you can finds some answers on <a href="http://gnodet.blogspot.com">Guillaume Nodet</a> blog in <a href="http://gnodet.blogspot.com/2010/03/spring-dm-aries-blueprint-and-custom.html">post about custom namespace handlers</a>.<br />
Of course you can still run Spring-DM under OSGi or select some Spring Source product. For me, blueprint fits OSGi much better.</p>
<h2>How to run OSGi under Tomcat</h2>
<p>As you (may) know OSGi is an module layer. Tomcat is an servlet container. If you wish run something under Tomcat that must be an WAR. So to start using OSGi under Tomcat I&#8217;ll simply embed it inside an war. Because I would expose a servlets registered under OSGi to be accessible throught tomcat connector I&#8217;ll also use additional proxy service. So there are two different solutions one is Equinox Servlet Bridge and Felix Http Bridge. Both works fine. For this post I&#8217;ve selected Felix artifacts.</p>
<p>Starting Framework is really simple, you just need an instance of ServletContextListener which will start the framework.</p>
<pre class="brush: java; title: ; notranslate">public class StartupListener implements ServletContextListener {

    private Logger logger = LoggerFactory.getLogger(StartupListener.class);

    private FrameworkService service;

    public void contextInitialized(ServletContextEvent event) {
        logger.info(&quot;Starting felix framework&quot;);

        this.service = new FrameworkService(event.getServletContext());
        this.service.start();
    }

    public void contextDestroyed(ServletContextEvent event) {
        logger.info(&quot;Framework shutdown&quot;);

        this.service.stop();
    }
}</pre>
<p>I could finish my post here, but I&#8217;ve meet multiple problems. I will describe them here to not lost them in future. <img src='http://dywicki.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>FrameworkService and ProvisioningActivator</h3>
<p>First of all, I would like to install some bundles after framework startup. Starting only Felix is not fun at all. We need modules! To get this part done we need to use an specific Felix configuration option called <strong>felix.systembundle.activators</strong>. It allows to pass BundleActivator instances using different classloader/different context than OSGi framework execution. By this way we can simply access resources embeded in WAR. I know it is not really nice solution, but I wanted to keep my demo simple. Just see the ProvisioningActivator code below. We use our servlet context during bundle activation!</p>
<pre class="brush: java; title: ; notranslate">public class ProvisionActivator implements BundleActivator {

    private final ServletContext servletContext;

    private static transient Logger logger = Logger.getLogger(ProvisionActivator.class.getName());

    public ProvisionActivator(ServletContext servletContext) {
        this.servletContext = servletContext;
    }

    public void start(BundleContext context) throws Exception {
        servletContext.setAttribute(BundleContext.class.getName(), context);

        ArrayList&lt;Bundle&gt; installed = new ArrayList&lt;Bundle&gt;();
        for (URL url : findBundles()) {
            Bundle bundle = context.installBundle(url.getFile(), url.openStream());
            installed.add(bundle);
        }

        for (Bundle bundle : installed) {
            try {
                bundle.start();
            } catch (Exception e) {
                logger.warning(&quot;Unable to start bundle &quot; + bundle.getSymbolicName() + &quot;. &quot; + e);
            }
        }
    }

    public void stop(BundleContext context) throws Exception {
    }

    private List&lt;URL&gt; findBundles() throws Exception {
        List&lt;URL&gt; list = new ArrayList&lt;URL&gt;();

        Set paths = this.servletContext.getResourcePaths(&quot;/WEB-INF/bundles/&quot;);
        logger.info(&quot;List of entries in /WEB-INF/bundles/ &quot; + paths);
        for (Object o : paths) {
            String name = (String)o;
            if (name.endsWith(&quot;.jar&quot;)) {
                URL url = this.servletContext.getResource(name);
                if (url != null) {
                    list.add(url);
                }
            }
        }

        return list;
    }
}</pre>
<p>Now we need proxy servlet and proxy startup listener. First receives calls from browser and forward its to OSGi servlets, second delivers some servlet events from war to OSGi. The setup is really simple:</p>
<pre class="brush: xml; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;
&lt;web-app xmlns=&quot;http://java.sun.com/xml/ns/j2ee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xsi:schemaLocation=&quot;

http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;

    version=&quot;2.5&quot;&gt;

    &lt;display-name&gt;Aries WebApp&lt;/display-name&gt;

    &lt;listener&gt;
        &lt;listener-class&gt;org.code_house.workshop.aries.war.StartupListener&lt;/listener-class&gt;&lt;!-- This part starts the Framework --&gt;
    &lt;/listener&gt;

    &lt;listener&gt;
        &lt;listener-class&gt;org.apache.felix.http.proxy.ProxyListener&lt;/listener-class&gt;
    &lt;/listener&gt;

    &lt;servlet&gt;
        &lt;servlet-name&gt;proxy&lt;/servlet-name&gt;
        &lt;servlet-class&gt;org.apache.felix.http.proxy.ProxyServlet&lt;/servlet-class&gt;
        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;

    &lt;servlet-mapping&gt;
        &lt;servlet-name&gt;proxy&lt;/servlet-name&gt;
        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;

&lt;/web-app&gt;</pre>
<p>Ok, having the framework running is great, but now we would like to use Felix WebConsole to inspect environment we run. For that we need another important improvement. If you have done some webapps you know that servlet api should not be included in WARs. We need respect same rule in this case. We can not install servlet api as OSGi bundle because ProxyServlet uses WAR classloader, it is not part of any bundle. Because of that we need configure framework to load javax.servlet and javax.servlet.http packages from parent classloader. Just remember to add them in <strong>org.osgi.framework.system.packages</strong> configuration property.<br />
From OSGi point of view we need an bridge which registers HttpService. Bot OSGi part and proxy part are linked. To get everything running you need both of them.</p>
<p>Now we are close to run everything. What we need to remember? Well under OSGi we have to handle dependencies just like under Tomcat, so I&#8217;ll install following artifacts:</p>
<ul>
<li>org.apache.aries.blueprint &#8211; blueprint-api, blueprint-core, to support declarative services</li>
<li>org.apache.aries.proxy &#8211; proxy-api, proxy-impl, these two are blueprint dependencies</li>
<li>org.apache.felix &#8211; http bridge, to link OSGi servlets with Proxy Servlet</li>
<li>org.ops4j.pax.logging &#8211; pax-logging-api, pax-logging-service, just to see what happens</li>
<li>org.apache.felix &#8211; webconsole, to track environment</li>
</ul>
<p>The basic setup can be really tiny. One thing I did not solve is proper logging. Because pax-logging-service uses log4j and some containers also do there is small conflict between those two. I did not investigate this realy deeply, but I suppose that there is need to put them into system packages list.</p>
<h2>Summary</h2>
<p>Running OSGi under Tomcat is not hard part. Actually many of providers do that, for example Atlassian have own extension system build on top of OSGi. If your product need an extreme extensibility, then this post is for you. If you will build it correctly then updates will work right after the update without need to restart whole web application.</p>
<p>I hope you enjoyed this part. If you are looking for source code &#8211; visit <a href="https://github.com/splatch/example-aries-tomcat">github</a>. The code contains few modules. After build you can drop a war/target/webapp-1.0.0.SNAPSHOT.war into tomcat webapps directory. You can run <strong>mvn jetty:run-war</strong> to see same effect. After that you will be able to access Felix WebConsole at http://localhost:8080/webapp-1.0.0.SNAPSHOT/system/console. The default user and password is admin. Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2012/01/apache-aries-under-apache-tomcat/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Running aspects under OSGi 4.2 with Karaf</title>
		<link>http://dywicki.pl/2011/11/running-aspects-under-osgi-4-2-with-karaf/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=running-aspects-under-osgi-4-2-with-karaf</link>
		<comments>http://dywicki.pl/2011/11/running-aspects-under-osgi-4-2-with-karaf/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 19:23:46 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[OSGi]]></category>
		<category><![CDATA[AspectJ]]></category>
		<category><![CDATA[Karaf]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=707</guid>
		<description><![CDATA[One of bigest benefits of Java is byte code manipulation. You can change everything you want in your application without touching source code. That&#8217;s usefull for many cases, starting from legacy code, where we can&#8217;t simply modify and recompile library up to modern applications where aspects can be used to handle runtime exceptions. The most [...]]]></description>
			<content:encoded><![CDATA[<p>One of bigest benefits of Java is byte code manipulation. You can change everything you want in your application without touching source code. That&#8217;s usefull for many cases, starting from legacy code, where we can&#8217;t simply modify and recompile library up to modern applications where aspects can be used to handle runtime exceptions. The most popular project is <a href="http://eclipse.org/aspectj/">AspectJ</a> which is part of <a href="http://eclipse.org">Eclipse</a> ecosystem, in this post I going to show you how to use AspectJ with Karaf.<br />
<span id="more-707"></span></p>
<h2>Enabling AspectJ</h2>
<p>Byte code manipulation requires access to class resource (.class file). It can be obtained from class loader which was used to load the class. Under Tomcat it&#8217;s easy. Anywhere you are, you can use MyClass.class.getClassLoader() and you will access web application class loader. But how to handle it under OSGi, where every bundle have own class loader? Equinox supports technic called hooks. It allows us, the developers, to extend framework in more declarative way. Hooks became very useful and since OSGi 4.3 release all certified frameworks will support few:</p>
<ul style="font-weight: bold">
<li>Resolver Hook</li>
<li>Bundle Hook</li>
<li>Service Hook</li>
<li><span style="font-weight: normal">and finally</span> Weaving Hook</li>
</ul>
<p><a href="http://dywicki.pl/wp-content/uploads/2011/11/equinox-vim.png" rel="lightbox"><img src="http://dywicki.pl/wp-content/uploads/2011/11/equinox-vim-300x172.png" alt="Setting equinox as default framework in Karaf" title="Setting equinox as default framework in Karaf" width="300" height="172" class="alignright size-medium wp-image-710" /></a><br />
The core difference between hooks in Equinox and in OSGi 4.3 is how they are registered. OSGi 4.3 allows to register hooks as typical services. In older Equinox they&#8217;re loaded from framework configuration or they are discovered by classpath scanning (they must be attached to Eqinox bundle as fragments). So whole trick is to start framework with hooks JARs. Also, to make aspects works, in older version, AspectJ must be loaded before any woven class, but that&#8217;s logical. You can&#8217;t weave classes when they already loaded and cached by JVM.</p>
<h2>Enabling in Karaf</h2>
<p>Because actual version of Karaf (2.2.4) still works with OSGi 4.2 we&#8217;ll use older way to enable aspects. First of all, before launch we&#8217;ll change default framework. By default Karaf distribution uses Felix as OSGi framework. Open the <strong>etc/config.properties</strong> and change the <strong>karaf.framework</strong> property to <strong>equinox</strong>.</p>
<pre class="brush: java; title: ; notranslate">
karaf.framework=equinox
</pre>
<p>If you are interested in different versions of same framework, you can simply hack this file because the karaf.framework is used to look up another property. Few lines below in configuration file you can see:</p>
<pre class="brush: plain; title: ; notranslate">
karaf.framework.equinox=${karaf.default.repository}/org/eclipse/osgi/3.6.2.R36x_v20110210/osgi-3.6.2.R36x_v20110210.jar
karaf.framework.felix=${karaf.default.repository}/org/apache/felix/org.apache.felix.framework/3.0.9/org.apache.felix.framework-3.0.9.jar
</pre>
<p>Framework JAR is located by expression <strong>karaf.framework.${karaf.framework}</strong>. But that&#8217;s only a note for curious people. <img src='http://dywicki.pl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><a href="http://dywicki.pl/wp-content/uploads/2011/11/dir-struct.png" rel="lightbox"><img src="http://dywicki.pl/wp-content/uploads/2011/11/dir-struct-300x204.png" alt="Files in Karaf home and lib" title="Files in Karaf home and lib" width="300" height="204" class="alignleft size-medium wp-image-722" /></a>Once we switched to Equinox we have only few steps left. First of all we need to install aspectj and weaving hook. Last part is example aspects. I had problem to locate fresh version of Weaving hook because project was moved from Equinox Incubator to Equinox Bundles. We need download whole <a href="http://download.eclipse.org/equinox/">Equinox SDK</a> to grab following artifacts from plugins directory:</p>
<ul>
<li>org.eclipse.equinox.weaving.aspectj_1.0.1.v20110502.jar</li>
<li>org.eclipse.equinox.weaving.caching_1.0.100.v20110502.jar</li>
<li>org.eclipse.equinox.weaving.hook_1.0.100.v20110502.jar</li>
</ul>
<p>I copied these artifacts to karaf home directory except <strong>org.eclipse.equinox.weaving.hook</strong>. It goes to lib directory, otherwise hook won&#8217;t be discovered. That&#8217;s because hook discovery is done by property file lookup. The lookup uses framework class loader and in Karaf case it is URLClassLoader with lib/ entries and framework archive.</p>
<p>In addition we&#8217;ll need also AspectJ runtime. We&#8217;ll install it from <a href="http://servicemix.apache.org">ServiceMix</a> bundles <a href="http://repo1.maven.org/maven2/org/apache/servicemix/bundles/">repository</a> but it will be installed directly from maven. No additional download steep need. After that we can launch bin/karaf and start installing artifacts:</p>
<pre class="listing">
<span class="command">~/tools/apache-karaf-2.2.4-switch$ ./bin/karaf</span>
<span class="startup">
        __ __                  ____
       / //_/____ __________ _/ __/
      / ,<  / __ `/ ___/ __ `/ /_
     / /| |/ /_/ / /  / /_/ / __/
    /_/ |_|\__,_/_/   \__,_/_/         

</span><span class="bold">
  Apache Karaf</span> (2.2.4)

Hit '<span class="bold">&lt;tab&gt;</span>' for a list of available commands
and '<span class="bold">[cmd] --help</span>' for help on a specific command.
<span class="bold">karaf</span>@root&gt; <span class="command">install file:lib/org.eclipse.equinox.weaving.hook_1.0.100.v20110502.jar</span>
Bundle ID: 49
<span class="bold">karaf</span>@root&gt; <span class="command">install file:org.eclipse.equinox.weaving.aspectj_1.0.1.v20110502.jar</span>
Bundle ID: 50
<span class="bold">karaf</span>@root&gt; <span class="command">install file:org.eclipse.equinox.weaving.caching_1.0.100.v20110502.jar</span>
Bundle ID: 51
<span class="bold">karaf</span>@root&gt; <span class="command">install mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.aspectj/1.6.8._2</span>
Bundle ID: 52
<span class="bold">karaf</span>@root&gt; <span class="command">list</span>
[  49] [Resolved   ] [            ] [   60] Aspect Weaving Hooks Plug-in (Incubation) (1.0.100.v20110502)
                                       Hosts: 0
[  50] [Active     ] [            ] [   60] WeavingService Plug-in (Incubation) (1.0.1.v20110502)
[  51] [Active     ] [            ] [   60] Standard Caching Service for Equinox Aspects (Incubation) (1.0.100.v20110502)
[  52] [Active     ] [            ] [   60] Apache ServiceMix :: Bundles :: aspectj (1.6.8.2)
</pre>
<p>To resolve correctly fragment bundle and connect it with equinox system bundle an restart may be needed. I recommend to restart, because it is the best way to connect everything together. Optionally you may set start level to be lower than default &#8211; 60. But for test purposes it may be leaved as is.</p>
<h2>Running aspects</h2>
<p>After installing all stuff it would be nice to run some aspects, isn&#8217;t? <img src='http://dywicki.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  If we have environment ready to handle byte code manipulation it would be nice to use it. As an example Aspect I will use char counter. After writing to PrintStream instance it will write information how many characters was writen and to which stream. I don&#8217;t know AspectJ syntax so it might not be optimal &#8211; feedback is welcome.</p>
<pre class="brush: java; title: ; notranslate">
package org.code_house.workshop.karaf.aspect.aspectj;

import java.io.PrintStream;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;;

public aspect HelloAspect {

	after(String msg, PrintStream stream) : // after call
		call(void PrintStream.println(String)) // println
		&amp;&amp; !within(HelloAspect)  // not from Aspect
		&amp;&amp; args(msg)  // with String attribute
		&amp;&amp; target(stream) { // and PrintStream as a target
		stream.println(&quot;You just wrote &quot; + msg.length() + &quot; chars to &quot; + stream); // display message
	}
}
</pre>
<p>Because we going to weave classes during load time we need <strong>META-INF/aop.xml</strong> file to let discover our aspects. Contents of file are really simple and points to aspect class name. Also it worth to notify to be careful with AspectJ version. I&#8217;ve got an error:</p>
<pre class="brush: plain; title: ; notranslate">BCException: Unable to continue, this version of AspectJ supports classes built with weaver version 6.0 but the class org.code_house.workshop.karaf.aspect.aspectj.HelloAspect is version 7.0</pre>
<p>The root cause is version mismatch between runtime and compile time. I used version 1.6.11 to compiler and 1.6.8 to run. After aligning versions to 1.6.8 it started working again.<br />
Second, important thing is a specific manifest entry <strong>Eclipse-SupplementBundle</strong>. It says which bundle is enhanced by aspects contained inside declaring bundle. I&#8217;ve put <strong>org.code-house.workshop.karaf.aspect.bundle</strong> because I going only to instrument one bundle. But value of this header might be an wildcard. Second option is to add <strong>Require-Bundle</strong> header pointing to org.aspectj.runtime. </p>
<p>So the last step is to install our artifacts and check if they&#8217;re runnign correctly. Let&#8217;s do that.</p>
<pre class="listing">
<span class="bold">karaf</span>@root&gt; <span class="command">install mvn:org.code-house.workshop.karaf.aspect/aspectj/1.0.0.SNAPSHOT</span>
Bundle ID: 53
<span class="bold">karaf</span>@root&gt; <span class="command">install mvn:org.code-house.workshop.karaf.aspect/bundle/1.0.0.SNAPSHOT</span>
Bundle ID: 54
<span class="bold">karaf</span>@root&gt; <span class="command"> list</span>
[  53] [Active     ] [            ] [   60] Code-House :: Workshop :: Karaf :: Aspect :: AspectJ (1.0.0.SNAPSHOT)
[  54] [Active     ] [            ] [   60] Code-House :: Workshop :: Karaf :: Aspect :: Bundle (1.0.0.SNAPSHOT)

<span class="bold">karaf</span>@root&gt; <span class="command">start 53 54</span>
Starting org.code-house.workshop.karaf.aspect.bundle
You just wrote 52 chars to org.apache.felix.gogo.runtime.threadio.ThreadPrintStream@327800e9
</pre>
<p><a href="http://dywicki.pl/wp-content/uploads/2011/11/karaf-output.png" rel="lightbox"><img src="http://dywicki.pl/wp-content/uploads/2011/11/karaf-output-150x150.png" alt="Aspect output in console" title="Aspect output in console" width="150" height="150" class="alignright size-thumbnail wp-image-724" /></a></p>
<h2>Summary</h2>
<p>Whole code used to write this post is <a href="https://github.com/splatch/example-karaf-aspectj">publically available</a> on <a href="http://github.com">GitHub</a>. Remember to use Aspects carefully, because they might change behaviour on whole environment, especially when you use centralized load time weaving. It&#8217;s worth to add excludes in your aop.xml file to don&#8217;t w enhance packages different than we really wish to instrument.<br />
If you are interested in AspectJ usage with OSGi 4.3, you can follow <a href="http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg06822.html">this topic</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2011/11/running-aspects-under-osgi-4-2-with-karaf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preserving message order in ActiveMQ</title>
		<link>http://dywicki.pl/2011/11/preserving-message-order/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=preserving-message-order</link>
		<comments>http://dywicki.pl/2011/11/preserving-message-order/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 10:36:52 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[Middleware]]></category>
		<category><![CDATA[ActiveMQ]]></category>
		<category><![CDATA[JMS]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=699</guid>
		<description><![CDATA[Few hours ago I&#8217;ve found an usefull post about preserving message order with ActiveMQ written by Marcelo Jabali from FUSE Source. In his example Marcelo used broker feature called Exclusive Consumers. It lets send messages only to one consumer and if it fails then second consumer gets all messages. I think it is not the [...]]]></description>
			<content:encoded><![CDATA[<p>Few hours ago I&#8217;ve found an usefull <a href="http://marcelojabali.blogspot.com/2011/11/preserving-message-order-with-apache.html">post</a> about preserving message order with <a href="http://activemq.apache.org">ActiveMQ</a> written by <a href="http://marcelojabali.blogspot.com/">Marcelo Jabali</a> from <a href="http://www.fusesource.com/">FUSE Source</a>. </p>
<p>In his example Marcelo used broker feature called <a href="http://activemq.apache.org/exclusive-consumer.html">Exclusive Consumers</a>. It lets send messages only to one consumer and if it fails then second consumer gets all messages. I think it is not the best idea if we have many messages to process. Why we wouldn&#8217;t use few consumers with preserved message order? Well, I was sure it is not possible, but during last training I&#8217;ve found solution.<br />
<span id="more-699"></span></p>
<h2>Broker configuration</h2>
<p><stroke><br />
So how to force ActiveMQ to preserve message order? It&#8217;s really simple, we just need to change dispatch policy for destination. We can do this for all queues or only for selected.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
    xmlns:amq=&quot;http://activemq.apache.org/schema/core&quot;&gt;

    &lt;broker xmlns=&quot;http://activemq.apache.org/schema/core&quot;&gt;
        &lt;destinationPolicy&gt;
            &lt;policyMap&gt;
                &lt;policyEntries&gt;
                    &lt;policyEntry queue=&quot;&gt;&quot;&gt;&lt;!-- Please refer 2nd part of this post --&gt;
                        &lt;dispatchPolicy&gt;
                            &lt;strictOrderDispatchPolicy /&gt;
                        &lt;/dispatchPolicy&gt;
                    &lt;/policyEntry&gt;
                &lt;/policyEntries&gt;
            &lt;/policyMap&gt;
        &lt;/destinationPolicy&gt;
    &lt;/broker&gt;
&lt;/beans&gt;
</pre>
<p></stroke></p>
<p>After this consumers should receive messages in same order like they were sent from producer. You can find example code on github: <a href="https://github.com/splatch/example-activemq-ordered">example-activemq-ordered</a>. You can run all from maven:</p>
<pre class="brush: bash; title: ; notranslate">
cd broker1; mvn activemq:run
cd broker2; mvn activemq:run
cd consumer; mvn camel:run
cd consumer; mvn camel:run
cd producer; mvn camel:run
</pre>
<h2>Upgrade</h2>
<p>After posting update about this blog post to Twitter <a href="http://www.nighttale.net/">Dejan Bosanac</a> send me <a href="https://twitter.com/dejanb/status/137485620292493312">few</a><a href="https://twitter.com/#!/dejanb/status/137498395358142464">updates</a>. He is co-author of <a href="http://www.manning.com/snyder/">ActiveMQ in Action</a> so his knowledge is much more deeper than mine. <img src='http://dywicki.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
First of all I mixed XML syntax. <strong>strictOrderDispatchPolicy</strong> is handled by topics, not queues. For second destination type strict order is turned on by <strong>strictOrderDispatch</strong> attribute set to true for <strong>policyEntry</strong> element. This preserves order but, as Dejan wrote, it will broke round robin and all messages will go to only one consumer, as in previous example given by Marcelo.</p>
<p>Also, Marcelo published <a href="http://marcelojabali.blogspot.com/2011/11/load-balanced-ordered-message.html">second post</a> about Message Groups which allows to preserve order and have multiple concurrent consumers on queue.</p>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2011/11/preserving-message-order/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introduction to Karaf WebConsole</title>
		<link>http://dywicki.pl/2011/11/introduction-to-karaf-webconsole/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=introduction-to-karaf-webconsole</link>
		<comments>http://dywicki.pl/2011/11/introduction-to-karaf-webconsole/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 23:02:22 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=682</guid>
		<description><![CDATA[Management of OSGi &#8211; let&#8217;s face it &#8211; is not very hard. The OSGi environment is clearly defined and that gives programmers many mechanisms to create administrative tools. The problem begins when we would like to use only one tool to manage few projects or artifacts of different types. I know this from personal experience [...]]]></description>
			<content:encoded><![CDATA[<p>Management of OSGi &#8211; let&#8217;s face it &#8211; is not very hard. The OSGi environment is clearly defined and that gives programmers many mechanisms to create administrative tools. The problem begins when we would like to use only one tool to manage few projects or artifacts of different types. I know this from personal experience because when I run Camel, ActiveMQ and CXF every from them provides own administration console. Every of them requires own security configuration, looks differently, have own dependencies and so on.<br />
<span id="more-682"></span><br />
This stands a little bit in contradiction with the OSGi specification idea, which tries to unify management of different things, not only dependencies (Core) but aspects like configuration (ConfigAdmin), deployment (DeploymentAdmin), meta data (MetaType), preferences (PreferencesService), users (UserAdmin) or permissions (PermissionAdmin). Naturally, creation of standard for management tools is too hard to be closed in any specification, even so good like OSGi.</p>
<h2>Felix WebConsole</h2>
<p>As response for problems with lack of common tool, available from browser a project <a href="http://felix.apache.org/site/apache-felix-web-console.html">Felix WebConsole</a> was created. This is a subproject of <a href="http://felix.apache.org">Felix&#8217;a</a>. In its assumptions Felix WebConsole should let easily extend itself through the use of mechanisms known from the core OSGi &#8211; that is, services. It should also let change look and feel and localize the tool. All these assumptions was covered, but number of extensions for Felix WebConsole do not grow like mushrooms after the rain.<br />
The question is, why? Now, in its simplicity Felix WebConsole make difficult creation of more complex extensions such as JMX. The problem is that our extension is only a servlet. From one hand it&#8217;s too much to put a link in list of bundles, on the other hand it is too little to make a few pages. If we&#8217;ll try we&#8217;ll begin to implement the second Struts framework based on servlets.<br />
Project team do not make things easier because it puts on the &#8220;lightness&#8221; console. It is expected to deploy console on mobile devices too.</p>
<h2>Karaf WebConsol as alternative</h2>
<p>Apache Karaf WebConsole is brand new project, which was made few months ago. After dynamic incubation phase, which maybe was too short, it was moved to sub-project of Karaf. Similar as precursor it points to lightness but also points to collaboration with other web frameworks, in this case it is another ASF project &#8211; the Apache Wicket. Through its use we obtained far-reaching component model. It means that you may add link to menu and style it with fragment CSS (without fragment bundle). You may add new tab with content or simply put another widget to dashboard. All these things you may see right after logging into console.<br />
All these extension won&#8217;t be possible without Wicket and Pax-Wicket. Thanks to huge amount of work made by <a href="http://github.com/anpieber">Andreas Pieber</a> on second project. Everything is stable and works as fast as Felix WebConsole.</p>
<h2>Architecture of Karaf WebConsole</h2>
<p>As I meintoned before, WebConsole uses Pax-Wicket and Wicket as presentation layer (we don&#8217;t count Java Script libraries). Most of extensions uses also blueprint to register services. There is no problem, similary like in case of Felix WebConsole, to use Spring DM or declarative services. Everything works with Pax-Web, but it should be possible to run it with any HttpService.<br />
Whats&#8217;s more, an experimental branch of pax-wicket which I worked on previously named <a href="https://github.com/splatch/pax-wicket-jsr330">jsr330</a> let to use same components in a traditional container like is Tomcat. This means that the administrative tool went beyond the OSGi framework and will allow creation of multi-modular consoles, also in a traditional environment.</p>
<h2>Extensions</h2>
<p>New elements who are added to Karaf WebConsole are  typically Wicket components or they are converted to them. Let see how to add new element to navigation:</p>
<pre class="brush: java; title: ; notranslate">
package org.apache.karaf.webconsole.blueprint.internal.navigation;

import java.util.ArrayList;
import java.util.List;

import org.apache.karaf.webconsole.blueprint.internal.BlueprintPage;
import org.apache.karaf.webconsole.core.navigation.NavigationProvider;
import org.apache.wicket.Page;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;

public class BlueprintNavigationProvider implements NavigationProvider {

    public List&lt;Link&lt;Page&gt;&gt; getItems(String componentId, String labelId) {
        List&lt;Link&lt;Page&gt;&gt; items = new ArrayList&lt;Link&lt;Page&gt;&gt;();

        Link&lt;Page&gt; link = new BookmarkablePageLink&lt;Page&gt;(componentId, BlueprintPage.class);
        link.add(new Label(labelId, &quot;Blueprint&quot;));
        items.add(link);

        return items;
    }

}
</pre>
<p><img src="http://dywicki.pl/wp-content/uploads/2011/11/menu-entry.png" alt="" title="menu entry" width="199" height="90" class="alignright size-full wp-image-677" /><br />
Interface <strong>org.apache.karaf.webconsole.core.navigation.NavigationProvider</strong> is universal supplier of navigation elements. In web application it&#8217;s mostly about links. Now, when we have implementation we need to submit it into registry to let use it. In this particular example we going to use blueprint, but it might be a standard activator or any other declarative way as well.</p>
<pre class="brush: xml; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;blueprint xmlns=&quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot;&gt;

    &lt;service ref=&quot;provider&quot; interface=&quot;org.apache.karaf.webconsole.core.navigation.NavigationProvider&quot;&gt;
        &lt;service-properties&gt;
            &lt;entry key=&quot;extends&quot; value=&quot;osgi&quot; /&gt;
        &lt;/service-properties&gt;

    &lt;/service&gt;

    &lt;bean id=&quot;provider&quot; class=&quot;org.apache.karaf.webconsole.blueprint.internal.navigation.BlueprintNavigationProvider&quot; /&gt;

&lt;/blueprint&gt;
</pre>
<p>Fragment above will cause addition of <strong>BlueprintPage</strong> as child of OSGi menu, because we set extends property. Result of execution you may see on attached picture.</p>
<p>Navigation is only example, remember &#8211; you have much more possibilities:</p>
<ul>
<li>org.apache.karaf.webconsole.core.brand.BrandProvider &#8211; lets to change design (without fragment bundles)</li>
<li>org.apache.karaf.webconsole.core.navigation.ConsoleTabProvider &#8211; causes addition of new tab in navigation</li>
<li>org.apache.karaf.webconsole.core.navigation.SidebarProvider &#8211; adds new elements on left side</li>
<li>org.apache.karaf.webconsole.core.widget.WidgetProvider &#8211; lets to publish new panels with content</li>
<li>org.apache.karaf.webconsole.osgi.bundle.IActionProvider &#8211; adds specific link to bundle list</li>
<li>org.apache.karaf.webconsole.osgi.bundle.IColumnProvider &#8211; adds column to bundle list</li>
<li>org.apache.karaf.webconsole.osgi.bundle.IDecorationProvider &#8211; adds icon bundle list</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2011/11/introduction-to-karaf-webconsole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Karaf WebConsole &#8211; wprowadzenie</title>
		<link>http://dywicki.pl/2011/11/karaf-webconsole-wprowadzenie/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=karaf-webconsole-wprowadzenie</link>
		<comments>http://dywicki.pl/2011/11/karaf-webconsole-wprowadzenie/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 22:15:09 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=673</guid>
		<description><![CDATA[Zarządzanie tym, co się dzieje z OSGi &#8211; powiedzmy sobie szczerze &#8211; nie jest bardzo trudne. Idee tego środowiska są zdefiniowane jasno co daje programistom do dyspozycji wiele mechanizmów do tworzenia narzędzi administracyjnych. Problem zaczyna się gdy chcemy użyć jednego narzędzia do zarządzania kilkoma projektami bądź artefaktami kilku typów. Znam to z autopsji, ponieważ gdy uruchamiam Camela, ActiveMQ i [...]]]></description>
			<content:encoded><![CDATA[<p>Zarządzanie tym, co się dzieje z OSGi &#8211; powiedzmy sobie szczerze &#8211; nie jest bardzo trudne. Idee tego środowiska są zdefiniowane jasno co daje programistom do dyspozycji wiele mechanizmów do tworzenia narzędzi administracyjnych. Problem zaczyna się gdy chcemy użyć jednego narzędzia do zarządzania kilkoma projektami bądź artefaktami kilku typów. Znam to z autopsji, ponieważ gdy uruchamiam Camela, ActiveMQ i CXF to każde z nich dostarcza własną konsolę administracyjną. Każda z nich wymaga oddzielnej konfiguracji bezpieczeństwa, inaczej wygląda, ma swoje zależności i tak dalej.<br />
<span id="more-673"></span><br />
Stoi to trochę w sprzeczności z ideą specyfikacji OSGi, która stara się unifikować zarządzanie nie tylko zależnościami (Core) ale aspektami takimi jak konfiguracja (ConfigAdmin), deployment (DeploymentAdmin), metadane (MetaType), preferencje (PreferencesService), użytkownicy (UserAdmin) czy uprawnienia (PermissionAdmin) i tak dalej. Naturalnie, stworzenie standardu dla konsoli administracyjnej nastręcza zbyt wielu problemów by udało się to zamknąć w jakiejkolwiek specyfikacji, nawet tak dobrze przygotowanej jak OSGi.</p>
<h2>Felix WebConsole</h2>
<p>W odpowiedzi na problemy z brakiem tego typu narzędzia, dostępnego z poziomu przeglądarki powstał projekt <a href="http://felix.apache.org/site/apache-felix-web-console.html">Felix WebConsole</a>. Jest to podprojekt dobrze znanego w światku <a href="http://felix.apache.org">Felix&#8217;a</a>. W swych założeniach Felix WebConsole ma pozwalać na łatwe rozszerzanie poprzez użycie mechanizmów znanych z core osgi &#8211; czyli usług. Ma również pozwalać na łatwą zmianę wyglądu oraz internacjonalizację. Wszystkie te założenia zostały spełnione, jednak ilość rozszerzeń do Felix WebConsole nie rośnie niczym grzyby po deszczu.<br />
Nasuwa się pytanie, dlaczego? Otóż, w swej prostocie Felix WebConsole utrudnia tworzenie bardziej złożonych rozszerzeń takich jak np. JMX. Problem polega na tym, że nasze rozszerzenie to tylko i aż servlet. Jest to z jednej strony zbyt dużo by dorzucić link np. do listy wiązek a z drugiej strony zbyt mało by zrobić kilka podstron, ponieważ zaczniemy implementować drugiego strutsa.<br />
Sprawy nie ułatwia sam zespół projektu, który stawia na &#8220;lekkość&#8221; konsoli, co ma pozwalać na jej uruchomienie również na urządzeniach mobilnych.</p>
<h2>Karaf WebConsole jako alternatywa</h2>
<p>Apache Karaf WebConsole to nowy projekt, który powstał kilka miesięcy temu. Po bardzo dynamicznej fazie inkubacji, która trwała być może zbyt krótko, został powołany do życia jako pod-projekt Karafa. Karaf WebConsole tak jak i poprzednik stawia na lekkość, ale zakłada współpracę z frameworkami webowymi, w tym przypadku jest to kolejny projekt ASF &#8211; Apache Wicket. Dzięki jego użyciu uzyskaliśmy daleko idącą komponentowość. To znaczy, że możesz dodać link do menu oraz określić jego wygląd przy pomocy CSS. Możesz dodać nową zakładkę ze stałą treścią bądź po prostu &#8220;widget&#8221; do ekranu powitalnego, który zobaczysz tuż po zalogowaniu korzystając z usług OSGi.<br />
Wszystkie te rozszerzenia nie były by możliwe gdyby nie Wicket oraz Pax-Wicket. Dzięki ogromowi pracy, który <a href="http://github.com/anpieber">Andreas Pieber</a> włożył w rozwój tego drugiego projektu całość działa stabilnie oraz równie szybko, co Felix WebConsole.</p>
<h2>Architektura Karaf WebConsole</h2>
<p>Tak jak już wspomiałem WebConsola wykorzystuje Pax-Wicket oraz Wicket do prezentacji (nie licząc bibliotek Java Script). Większość rozszerzeń wykorzystuje również blueprint do tego by się rejestrować. Nie ma jednak problemu, podobnie jak w przypadku Felix WebConsole, aby użyć Spring DM lub declarative services. Całość działa z Pax-Web, ale powinno być możliwe użycie dowolnego HttpService.<br />
Co więcej eksperymentalny branch pax-wicket nad którym pracowałem wcześniej nazwany <a href="https://github.com/splatch/pax-wicket-jsr330">jsr330</a> umożliwi używanie tych samych komponentów również w tradycyjnym kontenerze jakim jest Tomcat. To znaczy, że narzędzie administracyjne wykraczało by poza ramy OSGi umożliwiając tworzenie wielo-modułowych konsoli również w tradycyjnym środowisku.</p>
<h2>Rozszerzenia</h2>
<p>Nowe elementy, które są dodawane do Karaf WebConsole są zazwyczaj komponentami Wicketa bądź są przekształcane na nie. Przyjrzyjmy się w jaki sposób dodać nowy element do nawigacji:</p>
<pre class="brush: java; title: ; notranslate">
package org.apache.karaf.webconsole.blueprint.internal.navigation;

import java.util.ArrayList;
import java.util.List;

import org.apache.karaf.webconsole.blueprint.internal.BlueprintPage;
import org.apache.karaf.webconsole.core.navigation.NavigationProvider;
import org.apache.wicket.Page;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;

public class BlueprintNavigationProvider implements NavigationProvider {

    public List&lt;Link&lt;Page&gt;&gt; getItems(String componentId, String labelId) {
        List&lt;Link&lt;Page&gt;&gt; items = new ArrayList&lt;Link&lt;Page&gt;&gt;();

        Link&lt;Page&gt; link = new BookmarkablePageLink&lt;Page&gt;(componentId, BlueprintPage.class);
        link.add(new Label(labelId, &quot;Blueprint&quot;));
        items.add(link);

        return items;
    }

}
</pre>
<p><img src="http://dywicki.pl/wp-content/uploads/2011/11/menu-entry.png" alt="" title="menu entry" width="199" height="90" class="alignright size-full wp-image-677" /><br />
Interfejs <strong>org.apache.karaf.webconsole.core.navigation.NavigationProvider</strong> jest uniwersalnym dostawcą elementów nawigacyjnych. W aplikacji webowej sprowadza się to do linków. Teraz, gdy mamy implementację należy zgłosić usługę do rejestru tak by została ona użyta. W tym celu użyjemy blueprint, ale równie dobrze może to być standardowy aktywator bądź inny mechanizm declarative services.</p>
<pre class="brush: xml; title: ; notranslate">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;blueprint xmlns=&quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot;&gt;

    &lt;service ref=&quot;provider&quot; interface=&quot;org.apache.karaf.webconsole.core.navigation.NavigationProvider&quot;&gt;
        &lt;service-properties&gt;
            &lt;entry key=&quot;extends&quot; value=&quot;osgi&quot; /&gt;
        &lt;/service-properties&gt;

    &lt;/service&gt;

    &lt;bean id=&quot;provider&quot; class=&quot;org.apache.karaf.webconsole.blueprint.internal.navigation.BlueprintNavigationProvider&quot; /&gt;

&lt;/blueprint&gt;
</pre>
<p>Powyższy kawałek spowoduje dodanie linku do <strong>BlueprintPage</strong> jako element menu OSGi, ponieważ podaliśmy wartość extends. Wynik działania powyżej.</p>
<p>Nawigacja to tylko przykład, pamiętaj - możliwości jest znacznie więcej:</p>
<ul>
<li>org.apache.karaf.webconsole.core.brand.BrandProvider &#8211; pozwala na zmianę wyglądu</li>
<li>org.apache.karaf.webconsole.core.navigation.ConsoleTabProvider &#8211; dodaje nową zakładkę do konsoli</li>
<li>org.apache.karaf.webconsole.core.navigation.SidebarProvider &#8211; dodaje elementy po lewej stronie ekranu</li>
<li>org.apache.karaf.webconsole.core.widget.WidgetProvider &#8211; pozwala na dodawanie nowych paneli z treścią</li>
<li>org.apache.karaf.webconsole.osgi.bundle.IActionProvider &#8211; dodaje link do listy wiązek</li>
<li>org.apache.karaf.webconsole.osgi.bundle.IColumnProvider &#8211; dodaje kolumnę do listy wiązek</li>
<li>org.apache.karaf.webconsole.osgi.bundle.IDecorationProvider &#8211; dodaje ikony do listy wiązek</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2011/11/karaf-webconsole-wprowadzenie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building sample middleware &#8211; producer</title>
		<link>http://dywicki.pl/2011/06/building-sample-middleware-producer-jms-json/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-sample-middleware-producer-jms-json</link>
		<comments>http://dywicki.pl/2011/06/building-sample-middleware-producer-jms-json/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 12:40:30 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[Middleware]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=633</guid>
		<description><![CDATA[Last two days I&#8217;ve spent hacking Swing code. I decided to run standalone producer application to show real interaction with broker. You may treat this Swing app like entry point for people to our middleware system. Users simply do &#8220;transfers&#8221; from this application and don&#8217;t know anything about technical details. I added text area to [...]]]></description>
			<content:encoded><![CDATA[<p>Last two days I&#8217;ve spent hacking Swing code. I decided to run standalone producer application to show real interaction with broker. You may treat this Swing app like entry point for people to our middleware system. Users simply do &#8220;transfers&#8221; from this application and don&#8217;t know anything about technical details. I added text area to main window to show structure of message sent to broker.<br />
<span id="more-633"></span></p>
<h2>Producing messages with JMS</h2>
<p>Most of communication systems, whanever you will go have two different kinds of values, first &#8211; main and mainly used is body, second is typical metadata named headers or properties or parameters. JMS is not different, you can create different kinds of messages and set headers to them (in JMS world they&#8217;re named property, but I preffer header).<br />
Let check messaging code we have:</p>
<pre class="brush: java; highlight: [20,22,24,28,29,30,31]; title: ; notranslate">
// import declarations ...
public class JmsMessageSender implements MessageSender, InitializingBean {

	private ConnectionFactory connectionFactory;
	private Session session;
	private final String destination;
	private MessageProducer producer;

	public JmsMessageSender(String destination) {
		this.destination = destination;
	}

	public void sendMessage(String message, Map&lt;String, Object&gt; headers)
		throws Exception {

		if (session == null || producer == null) {
			afterPropertiesSet();
		}

		TextMessage jmsMsg = session.createTextMessage(message);
		for (String header : headers.keySet()) {
			jmsMsg.setObjectProperty(header, headers.get(header));
		}
		producer.send(jmsMsg);
	}

	public void afterPropertiesSet() throws Exception {
		Connection connection = connectionFactory.createConnection();
		session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
		Queue queue = session.createQueue(destination);
		producer = session.createProducer(queue);
	}

	// not important
}
</pre>
<p>First of all we inject connectionFactory using Spring configuration file. In line 20 we create text message, because we sending messages with String as content. Line 22 sets headers for message and finally sends it in line 24 using message producer created in lines 28-31. If we&#8217;ll look closer these lines we&#8217;ll see standard initalization code automatically called during bean creation by Spring. In line 29 we create session without transaction support and create producer to send messages. Connection factory is configured in XML with properties file to extract informations like broker url username and password.</p>
<pre class="brush: xml; title: ; notranslate">
&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.xsd&quot;&gt;

    &lt;bean id=&quot;view&quot; class=&quot;org.code_house.mom.producer.ProducerWindow&quot;&gt;
        &lt;property name=&quot;title&quot; value=&quot;Bank Agent APP&quot; /&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;controller&quot; class=&quot;org.code_house.mom.producer.ProducerController&quot;&gt;
        &lt;constructor-arg ref=&quot;view&quot; /&gt;
        &lt;property name=&quot;messageSender&quot;&gt;
            &lt;bean class=&quot;org.code_house.mom.producer.JmsMessageSender&quot;&gt;
                &lt;constructor-arg value=&quot;MOM.Incoming&quot; /&gt;
                &lt;property name=&quot;connectionFactory&quot; ref=&quot;connectionFactory&quot; /&gt;
            &lt;/bean&gt;
        &lt;/property&gt;
        &lt;property name=&quot;mapper&quot; ref=&quot;mapper&quot; /&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;connectionFactory&quot; class=&quot;org.apache.activemq.ActiveMQConnectionFactory&quot;&gt;
        &lt;property name=&quot;brokerURL&quot; value=&quot;${url}&quot; /&gt;
        &lt;property name=&quot;userName&quot; value=&quot;${user}&quot; /&gt;
        &lt;property name=&quot;password&quot; value=&quot;${pass}&quot; /&gt;
    &lt;/bean&gt;

    &lt;bean class=&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;&gt;
        &lt;property name=&quot;location&quot; value=&quot;classpath:activemq.properties&quot; /&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;mapper&quot; class=&quot;org.codehaus.jackson.map.ObjectMapper&quot; /&gt;

&lt;/beans&gt;
</pre>
<p>I decided to use JSON over XML. Regarding last post about data structures it is not the best choice but it is very simple. So don&#8217;t treat it as reference implementation. I just wish to don&#8217;t use JAXB annotations. <img src='http://dywicki.pl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Headers</h3>
<p>Headers are common thing for routing. This is main reason why I allow to provide headers as parameter to sendMessage method. In many cases it is better to use headers or even extract headers from body of message in one endpoint to reduce number of content reads. Example how to use headers for routing we&#8217;ll see in next part about <a href="http://camel.apache.org">Apache Camel</a>.</p>
<p>Just as a note types of headers supported by JMS spec:<br />
<a href="http://dywicki.pl/wp-content/uploads/2011/06/mom_producer.png"><img src="http://dywicki.pl/wp-content/uploads/2011/06/mom_producer-300x300.png" alt="" title="mom_producer" width="300" height="300" class="alignright size-thumbnail wp-image-645" /></a></p>
<ul>
<li>Boolean</li>
<li>Byte</li>
<li>Short</li>
<li>Int</li>
<li>Long</li>
<li>Float</li>
<li>Double</li>
<li>String</li>
<li>Object</li>
</ul>
<p>We can get or set headers using get<strong>Type</strong>Property(String name) or set<strong>Type</strong>Property(String name, Type value). Remember that headers of type &#8220;object&#8221; set by setObjectProperty must be serializable, otherwise they will be dropped before sending.</p>
<h2>Producer application</h2>
<p>As I said at begining of the post I spent two days on Swing hacks. <img src='http://dywicki.pl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I injected two additional depentencies to this module &#8211; <a href="www.miglayout.com">mig layout</a> and <a href="http://betterbeansbinding.kenai.com/">better beans binding</a>. First is responsible for frame layout, second for interactions between model and Swing controls. Whole application is simple form. All informations are displayed in status bar at bottom of the window, rest is taken by message area and combo boxes.</p>
<p>I have say, that binding framework is cool and reduced number of code lines I had to write without it.  If you are interested in exact code structure, please go to <a href="https://github.com/splatch/mom-sample/tree/master/producer">producer module</a> in <a href="https://github.com/splatch/mom-sample">mom-sample github repository</a>. Because it is not in area of this post I will not write more about desktop implementation details.</p>
<p>For these who wish run sample (I belive you would do that) &#8211; after executing</p>
<pre class="brush: bash; title: ; notranslate">mvn clean install</pre>
<p>You can simply execute target/producer.jar by doulbe click. This is fat-jar with all dependencies needed by producer application. </p>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2011/06/building-sample-middleware-producer-jms-json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Building sample middleware]]></series:name>
	</item>
		<item>
		<title>XML Schema Design Patterns</title>
		<link>http://dywicki.pl/2011/06/xml-schema-design-patterns/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=xml-schema-design-patterns</link>
		<comments>http://dywicki.pl/2011/06/xml-schema-design-patterns/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 14:22:54 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.dywicki.pl/?p=230</guid>
		<description><![CDATA[XML Schema jest bodajże najlepszym sposobem walidacji dokumentów XML. Model zastosowany w przypadku tego meta-języka pozwala na tworzenie złożonych konstrukcji. W oparciu o niego można budować własne rozszerzenia czy też zagnieżdżać w sekcjach xsd:appinfo dodatkowe metadane. Dzisiaj jednak nie o tym, a o wzorcach projektowych. Sam się zdziwiłem gdy trafiłem na artykuł Introducing Design Patterns [...]]]></description>
			<content:encoded><![CDATA[<p>XML Schema jest bodajże najlepszym sposobem walidacji dokumentów XML. Model zastosowany w przypadku tego meta-języka pozwala na tworzenie złożonych konstrukcji. W oparciu o niego można budować własne rozszerzenia czy też zagnieżdżać w sekcjach xsd:appinfo dodatkowe metadane. Dzisiaj jednak nie o tym, a o wzorcach projektowych. Sam się zdziwiłem gdy trafiłem na artykuł <a href="http://developers.sun.com/jsenterprise/archive/nb_enterprise_pack/reference/techart/design_patterns.html">Introducing Design Patterns in XML Schemas</a>. W życiu się nie zastanawiałem czy to co piszę w XSD ma coś wspólnego z wzorcami czy nie. Sun wyprzedził w tym momencie chyba wszystkich. <img src='http://dywicki.pl/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
<span id="more-230"></span><br />
Wzorce, które zostały wymienione we wspomnianym artykule odnoszą się do powiązania definiowanych typów z definiowanymi elementami. Ciężko mi się zgodzić z tym, że wybór wzorca jest krytyczny przy projektowaniu schematu, ponieważ schemat zazwyczaj ma przeznaczenie już w chwili pisania i zazwyczaj nie możemy powiedzieć, zrobimy to wzorcem X, ponieważ sam nasuwa się wzorzec Y. Ale to tak tylko moim zdaniem.</p>
<p>Tabelka poniżej prezentuje zawartość przeniesioną ze strony Suna. Zawiera ona 4 najpopularniejsze wzorce. Dwa najczęściej spotykane w internecie to Venetian Blind oraz Garden of Eden ze względu na to, że są bardzo podatne na ponowne użycie.</p>
<table>
<tr>
<th>Wzorzec</th>
<th>Charakterystyka</th>
</tr>
<tr>
<td><strong>Russian Doll</strong>, <a href="#Russian_Doll_Sample">przykład</a></td>
<td>Zawiera jeden element globalny, pozostałe są lokalne.</td>
</tr>
<tr>
<td>
<ul class="pros">
<li>Jest tylko jeden poprawny element.</li>
<li>Może uprościć przestrzeń nazw poprzez zastosowanie atrybutu elementFormDefault dla elementu xsd:schema.</li>
</ul>
</td>
<td>
<ul class="cons">
<li>Nadaje się tylko dla pojedynczych schematów.</li>
<li>Pozwala na ponowne użycie tylko całej gałęzi, a nie każdego typu z osobna.</li>
</ul>
</td>
</tr>
<tr>
<td><strong>Salami Slice</strong>, <a href="#Salami_Slice_Sample">przykład</a></td>
<td>Wszystkie elementy są globalne, stąd każdy może być użyty w charakterze root node&#8217;a.</td>
</tr>
<tr>
<td>
<ul class="pros">
<li>Wszystkie elementy można ponownie użyć.</li>
<li>Łatwe wiązanie schematów pomiędzy plikami.</li>
</ul>
</td>
<td>
<ul class="cons">
<li>Powoduje większą złożoność w przestrzeni nazw.</li>
<li>Trudny do określenia root.</li>
</ul>
</td>
</tr>
<tr>
<td><strong>Venetian Blind</strong>, <a href="#Venetian_Blind_Sample">przykład</a></td>
<td>Pochodna Russian Doll, zawiera jeden element globalny, pozostałe są lokalne</td>
</tr>
<tr>
<td>
<ul class="pros">
<li>Zawiera tylko jeden element nadrzędny.</li>
<li>Pozwala na ponowne użycie wszystkich typów oraz elementu nadrzędnego.</li>
<li>Łatwa praca z wieloma plikami.</li>
</ul>
</td>
<td>
<ul class="cons">
<li>Ograniczona enkapsulacja poprzez ekspozycję wszystkich typów.</li>
</ul>
</td>
</tr>
<tr>
<td><strong>Garden of Eden</strong>, <a href="#Garden_of_Eden_Sample">przykład</a></td>
<td>Połączenie Venetian Blind oraz Salami Slice. Wiele elementów globalnych, wiele typów publicznych. Wiele kandydatów na root node.</td>
</tr>
<tr>
<td>
<ul class="pros">
<li>Pozwala ponownie użyć elementy oraz typy.</li>
<li>Łatwa praca z wieloma plikami.</li>
</ul>
</td>
<td>
<ul class="cons">
<li>Zawiera wiele potencjalnych elementów nadrzędnych.</li>
<li>Ograniczona enkapsulacja.</li>
<li>Trudna do czytania i zrozumienia.</li>
</ul>
</td>
</tr>
<tr>
<td colspan="2" align="right"><em>Źródło: Sun Developers Network</em></td>
</tr>
</table>
<h2>Przykłady</h2>
<h3><a name="Russian_Doll_Sample">Russian Doll</a></h3>
<pre class="brush: xml; title: ; notranslate">&lt;xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
    targetNamespace=&quot;http://schemas.sun.com/point/russiandoll&quot;
    xmlns:tns=&quot;http://schemas.sun.com/point/russiandoll&quot;
    elementFormDefault=&quot;qualified&quot;&gt;

    &lt;xsd:element name=&quot;Line&quot;&gt;
	&lt;xsd:complexType&gt;
	    &lt;xsd:sequence&gt;
		&lt;xsd:element name=&quot;PointA&quot;&gt;
		    &lt;xsd:complexType&gt;
			&lt;xsd:attribute name=&quot;x&quot; type=&quot;xsd:integer&quot;/&gt;
			&lt;xsd:attribute name=&quot;y&quot; type=&quot;xsd:integer&quot;/&gt;
		    &lt;/xsd:complexType&gt;
		&lt;/xsd:element&gt;
		&lt;xsd:element name=&quot;PointB&quot;&gt;
		    &lt;xsd:complexType&gt;
			&lt;xsd:attribute name=&quot;x&quot; type=&quot;xsd:integer&quot;/&gt;
			&lt;xsd:attribute name=&quot;y&quot; type=&quot;xsd:integer&quot;/&gt;
		    &lt;/xsd:complexType&gt;
		&lt;/xsd:element&gt;
	    &lt;/xsd:sequence&gt;
	&lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;
&lt;/xsd:schema&gt;</pre>
<h3><a name="Salami_Slice_Sample">Salami Slice</a></h3>
<pre class="brush: xml; title: ; notranslate">&lt;xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
    targetNamespace=&quot;http://schemas.sun.com/point/salami&quot;
    xmlns:tns=&quot;http://schemas.sun.com/point/salami&quot;
    xmlns=&quot;http://schemas.sun.com/point/salami&quot;
    elementFormDefault=&quot;qualified&quot;&gt;

    &lt;xsd:element name=&quot;PointA&quot;&gt;
	&lt;xsd:complexType&gt;
	    &lt;xsd:attribute name=&quot;x&quot; type=&quot;xsd:integer&quot;/&gt;
	    &lt;xsd:attribute name=&quot;y&quot; type=&quot;xsd:integer&quot;/&gt;
    	&lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;

    &lt;xsd:element name=&quot;PointB&quot;&gt;
	&lt;xsd:complexType&gt;
	    &lt;xsd:attribute name=&quot;x&quot; type=&quot;xsd:integer&quot;/&gt;
	    &lt;xsd:attribute name=&quot;y&quot; type=&quot;xsd:integer&quot;/&gt;
	&lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;

    &lt;xsd:element name=&quot;Line&quot;&gt;
    	&lt;xsd:complexType&gt;
	    &lt;xsd:sequence&gt;
		&lt;xsd:element ref=&quot;PointA&quot;/&gt;
		&lt;xsd:element ref=&quot;PointB&quot;/&gt;
	    &lt;/xsd:sequence&gt;
	&lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;
&lt;/xsd:schema&gt;</pre>
<h3><a name="Venetian_Blind_Sample">Venetian Blind</a></h3>
<pre class="brush: xml; title: ; notranslate">&lt;xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
    targetNamespace=&quot;http://schemas.sun.com/point/venetianblind&quot;
    xmlns:tns=&quot;http://schemas.sun.com/point/venetianblind&quot;
    xmlns=&quot;http://schemas.sun.com/point/venetianblind&quot;
    elementFormDefault=&quot;qualified&quot;&gt;

    &lt;xsd:complexType name=&quot;PointType&quot;&gt;
	&lt;xsd:attribute name=&quot;x&quot; type=&quot;xsd:integer&quot;/&gt;
	&lt;xsd:attribute name=&quot;y&quot; type=&quot;xsd:integer&quot;/&gt;
    &lt;/xsd:complexType&gt;

    &lt;xsd:element name=&quot;Line&quot;&gt;
	&lt;xsd:complexType&gt;
	    &lt;xsd:sequence&gt;
		&lt;xsd:element name=&quot;PointA&quot; type=&quot;PointType&quot;/&gt;
		&lt;xsd:element name=&quot;PointB&quot; type=&quot;PointType&quot;/&gt;
	    &lt;/xsd:sequence&gt;
	&lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;
&lt;/xsd:schema&gt;
</pre>
<h3><a name="Garden_of_Eden_Sample">Garden of Eden</a></h3>
<pre class="brush: xml; title: ; notranslate">&lt;xsd:schema xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
    targetNamespace=&quot;http://schemas.sun.com/point/gardenofeden&quot;
    xmlns=&quot;http://schemas.sun.com/point/gardenofeden&quot;
    elementFormDefault=&quot;qualified&quot;&gt;

    &lt;xsd:complexType name=&quot;PointType&quot;&gt;
	&lt;xsd:attribute name=&quot;x&quot; type=&quot;xsd:integer&quot;/&gt;
	&lt;xsd:attribute name=&quot;y&quot; type=&quot;xsd:integer&quot;/&gt;
    &lt;/xsd:complexType&gt;

    &lt;xsd:complexType name=&quot;LineType&quot;&gt;
	&lt;xsd:sequence&gt;
	    &lt;xsd:element ref=&quot;PointA&quot;/&gt;
	    &lt;xsd:element ref=&quot;PointB&quot;/&gt;
	&lt;/xsd:sequence&gt;
    &lt;/xsd:complexType&gt;

    &lt;xsd:element name=&quot;PointA&quot; type=&quot;PointType&quot;/&gt;

    &lt;xsd:element name=&quot;PointB&quot; type=&quot;PointType&quot;/&gt;

    &lt;xsd:element name=&quot;Line&quot; type=&quot;LineType&quot;/&gt;
&lt;/xsd:schema&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2011/06/xml-schema-design-patterns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building sample middleware – data structures</title>
		<link>http://dywicki.pl/2011/06/building-sample-middleware-data-structures/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-sample-middleware-data-structures</link>
		<comments>http://dywicki.pl/2011/06/building-sample-middleware-data-structures/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 12:54:18 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[Middleware]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=590</guid>
		<description><![CDATA[Data with middleware The data structures are very important in middleware world. Because we often connect multiple systems we need to define an &#8220;domain model&#8221; for integration. The domain model means that objects we share between all systems are well known, well defined, well understand in multiple teams often provided by multiple vendors. Let see [...]]]></description>
			<content:encoded><![CDATA[<h2>Data with middleware</h2>
<p>The data structures are very important in middleware world. Because we often connect multiple systems we need to define an &#8220;domain model&#8221; for integration. The domain model means that objects we share between all systems are <strong>well known</strong>, <strong>well defined</strong>, <strong>well understand</strong> in multiple teams often provided by multiple vendors. Let see what does it means in practice.<br />
<span id="more-590"></span></p>
<h4>Well known</h4>
<p>If you talk with business guys you have to use same terms with programmers. You might be mediator but not the translator. As integration team member mediate correct shape of solution but don&#8217;t became a translator between business divisions and developers (unless you are business analitic). All people should use same terms to minimalise problems with number of definitions. That&#8217;s first step of multiple projects, not only integration. If you look for deeper knowledge of domain definitions check a &#8220;<a href="http://domaindrivendesign.org/books/evans_2003">Domain Driven Design</a>&#8221; book written by <a href="http://domaindrivendesign.org/about#eric">Eric Evans</a> and published in 2003. Ok, maybe business is not always part of integration project, but you communicate systems used by people, isn&#8217;t?</p>
<h4>Well defined</h4>
<p>You have names and scopes for your classes and objects. Probably you have 90% of fields that will be defined in them. Remember to don&#8217;t put too much informations from one system to domain model. Domain model is not list of entities from one system. Make sure that you don&#8217;t share database identifier from one system to second. Identifier should be business, for example most of clients might be identified by personal document, most of companies can be identified by tax id, not by database sequence. For future reasons try to extract atomic values, like for databases. With atomic values you will have less text processing to extract specific data and less code to maintain.</p>
<h4>Well understand</h4>
<p>That&#8217;s case for distributed teams. Usually every team have own parts of software to do and every team plays different game. Someone else produces messages, someone consumes them, this is place when you&#8217;ll have small wars. Make sure that data structures you all have to share match common needs, that defined identifiers are fine for different systems too. I met multiple situations when system analytics from two companies spent lots of hours on phone defining field constraints. Don&#8217;t follow this path.</p>
<p>Whole integration project is about to fail in 95% cases &#8211; if you will not have data structures. Ok, we know that proper structure is key for integration. Second important point in data is representation. I don&#8217;t going to talk about REST at all, but rather about format of serialization. We have number of options here, just look table below</p>
<table style="border: 1px solid #eee">
<tr>
<th>Serialization Format</th>
<th>Pros</th>
<th>Cons</th>
</tr>
<tr>
<th>Java Object Serialization</th>
<td>
<ul class="pros">
<li>Very easy to maintain</li>
<li>Easy to use with JMS / ActiveMQ &#8211; ObjectMessages</li>
<li>Built in Java</li>
</ul>
</td>
<td>
<ul class="cons">
<li>Available only for systems written in Java</li>
<li>Both sides must use same classes and versions (if we use serialization id)</li>
<li>As every binary format &#8211; it is hard to process</li>
</ul>
</td>
</tr>
<tr>
<th>XML (with XML Schema)</th>
<td>
<ul class="pros">
<li>Easy to read and write, both for computer and people (I don&#8217;t belive YAML)</li>
<li>Easy to use with JMS / ActiveMQ &#8211; TextMessages</li>
<li>Very easy validation, with XML Schema</li>
<li>Well supported in many languages (including validation with XML Schema), DOM api provides complex operations</li>
</ul>
</td>
<td>
<ul class="cons">
<li>Requires additional libraries, some languages don&#8217;t have any binding from XML to Objects and vice versa</li>
<li>Synchronisation between Java and XML Schema (code generation)</li>
<li>Without proper XML Schema might be too lax</li>
<li>Not the best for big portions of data because overflow</li>
</ul>
</td>
</tr>
<tr>
<th>JSON</th>
<td>
<ul class="pros">
<li>Easy to read and write, both for computer and people, even easier than XML</li>
<li>Easy to use with JMS / ActiveMQ &#8211; TextMessages</li>
<li>Smaller than XML, easier to parse, even without any API</li>
<li>Supported in number of languages</li>
</ul>
</td>
<td>
<ul class="cons">
<li>Lack of well supported official structure control tool (like XML Schema)</li>
<li>Lack of official API for handling JSON</li>
<li>Requires additional libraries, some languages don&#8217;t have any binding from JSON to Objects and vice versa</li>
</ul>
</td>
</tr>
</table>
<p><a href="http://dywicki.pl/wp-content/uploads/2011/06/mom_domain.png"><img src="http://dywicki.pl/wp-content/uploads/2011/06/mom_domain.png" alt="" title="Domain structure" width="365" height="594" class="alignright size-full wp-image-592" /></a></p>
<p>There is number of different wire formats not listed here &#8211; for example <a href="http://code.google.com/p/protobuf/">Protobuf</a>, <a href="http://en.wikipedia.org/wiki/Electronic_Data_Interchange">EDI</a> which match this scenario too. I don&#8217;t count them (even if I should) because first is not well supported in many languages, second is rather legacy format not well for new systems.</p>
<h2>Structures used in MOM</h2>
<p>Like in most cases, also with middleware we have some data structures. Because we going to process simple cash transactions we&#8217;ll have following classes:</p>
<ul>
<li>org.code_house.mom.domain.Transaction</li>
<li>org.code_house.mom.domain.Client</li>
<li>org.code_house.mom.domain.Money</li>
<li>org.code_house.mom.domain.Money.Currency</li>
</ul>
<h3>Transaction</h3>
<p>Every transaction will have unique identifier generated by <a href="http://download.oracle.com/javase/1,5.0/docs/api/java/util/UUID.html">UUID</a>. Transaction will point to some Client and have assigned <a href="http://martinfowler.com/eaaCatalog/money.html">Money</a> object.</p>
<h3>Client</h3>
<p>In our case client is very simple POJO which contains fields ID and name. For middleware purposes we going to use only ID. Name might be usefull for user interface operations.</p>
<h3>Money</h3>
<p>Because we going to transfer some money to client account from producer we have to use proper data structure for a &#8220;cash&#8221;. Few years ago <a href="http://martinfowler.com/">Martin Fowler</a> in his book &#8220;<a href="http://martinfowler.com/books.html#eaa">Patterns of Enterprise Application Architecture</a>&#8221; defined a <a href="http://martinfowler.com/eaaCatalog/money.html">Money</a> pattern which is suitable to handle money values. We have to remember that client account might be handled in different currency and we cannot send only amount information. We need a currency too.</p>
<p>That&#8217;s all for data structures. It was more about philosophy than about code, but don&#8217;t worry &#8211; in next part we going to write more. All needed classes you&#8217;ll find in <a href="https://github.com/splatch/mom-sample">git repository</a>. You may download <a href="https://github.com/splatch/mom-sample/zipball/master">zip archive</a>|<a href="https://github.com/splatch/mom-sample/tarball/master">tar archive</a> if you don&#8217;t have git client.</p>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2011/06/building-sample-middleware-data-structures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Building sample middleware]]></series:name>
	</item>
		<item>
		<title>Building sample middleware &#8211; broker</title>
		<link>http://dywicki.pl/2011/06/building-sample-middleware-broker/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=building-sample-middleware-broker</link>
		<comments>http://dywicki.pl/2011/06/building-sample-middleware-broker/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 16:45:30 +0000</pubDate>
		<dc:creator>splatch</dc:creator>
				<category><![CDATA[Middleware]]></category>

		<guid isPermaLink="false">http://dywicki.pl/?p=560</guid>
		<description><![CDATA[At end of the May I had great time in United Kingdom providing consulting. After this I started thinking about sharing an idea of middleware application based on ActiveMQ and Camel features. I&#8217;ve spent few days to create sufficient example. What middleware is? Middleware is a general term, about some software which is some kind [...]]]></description>
			<content:encoded><![CDATA[<p>At end of the May I had great time in United Kingdom providing consulting. After this I started thinking about sharing an idea of middleware application based on ActiveMQ and Camel features. I&#8217;ve spent few days to create sufficient example.</p>
<h1>What middleware is?</h1>
<p>Middleware is a general term, about some software which is some kind of proxy between other systems. What for? &#8211; you could ask. Generally because communication from point to point is not the best to build bigger applications, and some components in middle of communication allows us to inject new logic without changing source systems. Could you imagine situation where you have a number of system producing messages and an number of consumers of these messages written in different languages? That&#8217;s typical case where middleware is going to be usefull.<br />
There is number of middleware tools from various categories, in this post we&#8217;ll learn how to use ActiveMQ to build message oriented middleware. What does the MOM means? Generally that we have asynchronous communication without direct method invocations. Producer don&#8217;t know anything about consumer and vice versa. If you are interested in MOM &#8211; pick up &#8220;<a href="http://manning.com/snyder/">ActiveMQ in Action</a>&#8221; book (written by commiters of ActiveMQ) from <a href="http://manning.com">Manning Publications Co.</a> where this term is described in greater detail.<br />
<span id="more-560"></span></p>
<h2>The scenario</h2>
<p>In our scenario we we&#8217;ll use number of queues, every client will have own queue and will consume messages only from this queue. The producer will send messages with header which will be used to determine client queue. In the middle we have <a href="http://camel.apache.org">Apache Camel</a> which will process incoming messages and dispatch them to concrete client queues. Camel will also copy messages to log queue for  audit processor (not listed on image).<br />
<a href="http://dywicki.pl/wp-content/uploads/2011/06/mom_architecture.png"><img src="http://dywicki.pl/wp-content/uploads/2011/06/mom_architecture.png" alt="" title="MOM System Architecture" width="536" height="268" class="aligncenter size-full wp-image-562" /></a><br />
As alternative I going to show you how to extract client ID from message body instead of forcing producer to use headers. </p>
<h2>Setting up ActiveMQ</h2>
<p>If you are Linux or MacOS user you could use <a href="https://github.com/mxcl/homebrew">brew</a> package manager to install activemq using following command:</p>
<pre class="brush: bash; title: ; notranslate">brew install activemq</pre>
<p>Other users can download ActiveMQ package from <a href="http://activemq.apache.org/">project site</a>.</p>
<p>Ok, we have ActiveMQ installed, in next steep we going to create an test instance of activemq where we&#8217;ll hack configuration. To do this execute following command:</p>
<pre class="brush: bash; title: ; notranslate">activemq-admin create mom</pre>
<p>After execution of command you should get following directory structure<br />
<a href="http://dywicki.pl/wp-content/uploads/2011/06/mom_broker.png"><img src="http://dywicki.pl/wp-content/uploads/2011/06/mom_broker.png" alt="" title="mom_broker" width="836" height="284" class="aligncenter size-full wp-image-570" /></a></p>
<p>We don&#8217;t going to use all of these files, so in my set up I going to remove next configuration files:</p>
<ul>
<li>Because we don&#8217;t going to use SSL yet:
<ul>
<li>broker.ks</li>
<li>broker.ts</li>
</ul>
</li>
<li>Because we don&#8217;t use security yet:
<ul>
<li>credentials.properties</li>
</ul>
</li>
<li>Because we don&#8217;t going to use ActiveMQ webconsole:
<ul>
<li>jetty-realm.properties</li>
<li>jetty.xml</li>
</ul>
</li>
</ul>
<p>These files are unecessary at this moment in our setup.</p>
<h2>Configuring ActiveMQ</h2>
<p>Becase activemq-admin script creates dummy broker configuration we have to modify it a bit. <strong>Remember to put elements in XML file with alphabetic order. Since ActiveMQ 5.4 release all elements are ordered.</strong>. First of all we going to modify destinationPolicy element:</p>
<pre class="brush: xml; highlight: [4,5]; title: ; notranslate">
        &lt;destinationPolicy&gt;
            &lt;policyMap&gt;
                &lt;policyEntries&gt;
                    &lt;policyEntry queue=&quot;&gt;&quot; optimizedDispatch=&quot;true&quot; lazyDispatch=&quot;false&quot; producerFlowControl=&quot;false&quot; memoryLimit=&quot;12 mb&quot; /&gt;
                    &lt;policyEntry queue=&quot;MOM.Client.&gt;&quot; advisoryForDelivery=&quot;true&quot; advisoryForConsumed=&quot;true&quot; /&gt;
                &lt;/policyEntries&gt;
            &lt;/policyMap&gt;
        &lt;/destinationPolicy&gt;
</pre>
<p>First policyEntry element disables producerFlowControl. In other words ActiveMQ will accept all messages sent by producer, even when the memory limit was exceeded. Messages that are not able to be put in memory will be persisted in store. By default ActiveMQ have producerFlowControl set to true, and broker will notify producer to wait untill there will be place in memory, eg. messages from queue will be consumed. Second entry turn on advisory messages for message delivery and consumption for MOM.Client.* queues. These advisory messages are sent when message was received from producer and was succesfully processed by consumer. ActiveMQ offers number of <a href="http://activemq.apache.org/advisory-message.html">advisory topics and messages</a>. Some of them are disabled, some other are enabled by default.</p>
<p>Second change in configuration file is predefined destinations. </p>
<pre class="brush: xml; title: ; notranslate">
        &lt;destinations&gt;
            &lt;queue physicalName=&quot;MOM.Incoming&quot; /&gt;
            &lt;queue physicalName=&quot;MOM.Audit&quot; /&gt;
        &lt;/destinations&gt;
</pre>
<p>These destinations will be created when broker starts, even if there is no consumers or producers. After these changes we can start our broker with following command:</p>
<pre class="brush: bash; title: ; notranslate">$ACTIVEMQ_HOME/bin/mom console</pre>
<p>With VisualVM we can check which destinations are created by default. When you start monitoring tool simply select local process with org.apache.activemq.console.Main which should be displayer after execution of command listed above.<br />
<a href="http://dywicki.pl/wp-content/uploads/2011/06/mom_jmx.png"><img src="http://dywicki.pl/wp-content/uploads/2011/06/mom_jmx.png" alt="" title="mom_jmx" width="408" height="230" class="size-full wp-image-575" /></a></p>
<p>That&#8217;s all for ActiveMQ set up. If you have troubes with configuration changes, you can pick up all changes directly from <a href="https://github.com/splatch/mom-sample">git repository</a> or download <a href="https://github.com/splatch/mom-sample/zipball/master">zip archive</a>|<a href="https://github.com/splatch/mom-sample/tarball/master">tar archive</a> if you don&#8217;t have git client.</p>
]]></content:encoded>
			<wfw:commentRss>http://dywicki.pl/2011/06/building-sample-middleware-broker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Building sample middleware]]></series:name>
	</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: _ @ 2012-05-20 02:45:11 -->
