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

<channel>
	<title>Avantia Team Blog</title>
	<atom:link href="http://blog.avantia-inc.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.avantia-inc.com</link>
	<description></description>
	<lastBuildDate>Mon, 12 Sep 2011 02:32:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Using Hazelcast In-memory Data Grid</title>
		<link>http://blog.avantia-inc.com/2011/09/11/using-hazelcast-in-memory-data-grid/</link>
		<comments>http://blog.avantia-inc.com/2011/09/11/using-hazelcast-in-memory-data-grid/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 02:28:00 +0000</pubDate>
		<dc:creator>Brian Jimerson</dc:creator>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[distributed systems]]></category>
		<category><![CDATA[Jahia]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=308</guid>
		<description><![CDATA[In a previous post, we explored a new class of products called in-memory data grids, that provide scalability and performance for data access in today&#8217;s cloud applications.  In this post, we&#8217;ll walk through using one these products, Hazelcast, as an in-memory data grid backed by a relational database as a persistent store. It should be <a href='http://blog.avantia-inc.com/2011/09/11/using-hazelcast-in-memory-data-grid/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>In a <a title="previous" href="http://blog.avantia-inc.com/2011/08/31/cloud-scale-data-access-with-in-memory-data-grids/">previous</a> post, we explored a new class of products called in-memory data grids, that provide scalability and performance for data access in today&#8217;s cloud applications.  In this post, we&#8217;ll walk through using one these products, <a title="Hazelcast" href="http://blog.avantia-inc.com/2011/08/31/cloud-scale-data-access-with-in-memory-data-grids/">Hazelcast</a>, as an in-memory data grid backed by a relational database as a persistent store.</p>
<p>It should be noted that this is not an endorsement for Hazelcast.  Hazelcast is a very good open-source product in this space, but there are other products, both commercial and open-source, that offer the same features or more.  We chose Hazelcast for this post because its a lightweight, open-source solution with an easy to understand API.</p>
<p>Two best of breed commercial products in this space are <a href="http://www.vmware.com/products/vfabric-gemfire/overview.html">VMware vFabric Gem Fire</a> and <a href="http://www.oracle.com/us/products/middleware/coherence/index.html">Oracle Coherence</a>.  Give both of these products a look (or let me know and I&#8217;ll help you) if you&#8217;re interested in enterprise-grade in-memory data grids.  Our example uses Hazelcast, but the concepts are applicable to other in-memory data grids.</p>
<h3>Prerequisites</h3>
<p>There are a few assumptions and prerequisites for this example.  For this example, we&#8217;re going to create a Java main class that starts the Hazelcast datagrid.  The project is created in <a href="http://www.springsource.com/developer/sts">Spring Source Tool Suite</a>, uses <a href="http://maven.apache.org">Maven 2</a> for build and dependency management, and uses <a href="http://www.springsource.com/developer/spring">Spring</a> 3.x for dependency injection, and <a href="http://www.mysql.com">MySQL</a> for persistence.  If you&#8217;re not comfortable with any of these technologies, it&#8217;s probably worthwhile to become familiar with them.</p>
<h3>Maven Configuration</h3>
<p>The first step is to add the dependencies for Hazelcast, Spring Framework, and MySQL to your Maven POM.  Of course, adjust the versions and Spring and MySQL dependencies accordingly:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;dependencies&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;com.hazelcast&lt;/groupId&gt;
    &lt;artifactId&gt;hazelcast&lt;/artifactId&gt;
    &lt;version&gt;1.9.3.3&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
    &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;org.springframework&lt;/groupId&gt;
    &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
    &lt;version&gt;3.0.5.RELEASE&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;commons-dbcp&lt;/groupId&gt;
    &lt;artifactId&gt;commons-dbcp&lt;/artifactId&gt;
    &lt;version&gt;1.4&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
    &lt;groupId&gt;mysql&lt;/groupId&gt;
    &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
    &lt;version&gt;5.1.16&lt;/version&gt;
  &lt;/dependency&gt;
&lt;/dependencies&gt;
</pre>
<h3>Domain and DAO Classes</h3>
<p>The next step is to create the domain and data access classes for accessing our database and back the Hazelcast cache.  For this example, we&#8217;re going to use a music artist whose information is already stored in the database.  The domain model is simple, but can be easily extended.  We&#8217;re also using Spring&#8217;s JDBC template for data access; any data access technology can be used, including JPA and JDO.  There&#8217;s nothing very interesting about these classes.</p>
<p>The domain class is:</p>
<pre class="brush: java; title: ; notranslate">
package net.avantia.datagrid.domain;

/**
 * Domain object for artist.
 * @author Brian Jimerson
 *
 */
public class Artist {

	private Integer id;
	private String name;
	private String url;

	/**
	 * @return the id
	 */
	public Integer getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}
	/**
	 * @param url the url to set
	 */
	public void setUrl(String url) {
		this.url = url;
	}
}
</pre>
<p>And the DAO is:</p>
<pre class="brush: java; title: ; notranslate">

package net.avantia.datagrid.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import javax.sql.DataSource;

import net.avantia.datagrid.domain.Artist;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;

/**
 * JDBC Template DAO for artists.
 *
 * @author Brian Jimerson
 *
 */
public class ArtistJdbcDao {

	private JdbcTemplate jdbcTemplate;

	/**
	 * Constructs a new ArtistJdbcDao with the specified data source.
	 * @param dataSource The data source to use.
	 */
	public ArtistJdbcDao(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}

	/**
	 * Gets all artists.
	 * @return All artists
	 */
	public List&lt;Artist&gt; getAllArtists() {
		List&lt;Artist&gt; allArtists = this.jdbcTemplate.query(
				&quot;select * from artist&quot;, new ArtistMapper());
		return allArtists;
	}

	/**
	 * Finds an artist by id.
	 * @param id The id of the artist to find.
	 * @return The artist if found.
	 */
	public Artist findArtistById(Integer id) {
		Artist artist = this.jdbcTemplate.queryForObject(
				&quot;select * from artist a where a.id = ?&quot;, new Object[]{id}, new ArtistMapper());
		return artist;
	}

	/**
	 * Artist mapper implementation of RowMapper
	 * @author Brian Jimerson
	 *
	 */
	final class ArtistMapper implements RowMapper&lt;Artist&gt; {

		/**
		 * Maps a result set row to an Artist object.
		 */
		public Artist mapRow(ResultSet rs, int rowNum) throws SQLException {
			Artist artist = new Artist();
			artist.setId(rs.getInt(&quot;id&quot;));
			artist.setUrl(rs.getString(&quot;url&quot;));
			return artist;
		}
	}
}
</pre>
<h3>Map Loader</h3>
<p>Our implementation of MapLoader is what tells Hazelcast how to back it&#8217;s Map cache entries with our database entries.  Our example only needs read access to data (not write access to the database) so we only have to implement a MapLoader.  The code for our MapLoader is:</p>
<pre class="brush: java; title: ; notranslate">

package net.avantia.datagrid.util;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import net.avantia.datagrid.dao.ArtistJdbcDao;
import net.avantia.datagrid.domain.Artist;

import com.hazelcast.core.MapLoader;

/**
 * MapLoader implementation for load artists into Hazelcast.
 *
 * @author Brian Jimerson
 *
 */
public class ArtistMapLoader implements MapLoader&lt;String, String&gt; {

	private ArtistJdbcDao dao;

	/**
	 * Default constructor for ArtistMapLoader
	 */
	public ArtistMapLoader() {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(&quot;avantia-data-grid-context.xml&quot;);
		dao = ctx.getBean(&quot;artistJdbcDao&quot;, ArtistJdbcDao.class);
	}

	public String load(String id) {
		Integer intId = Integer.parseInt(id);
		Artist a = dao.findArtistById(intId);
		if (a != null) {
			return a.getName();
		} else {
			StringBuilder sb = new StringBuilder();
			sb.append(&quot;Artist for id [&quot;);
			sb.append(id);
			sb.append(&quot; not found.&quot;);
			return sb.toString();
		}
	}

	public Map&lt;String, String&gt; loadAll(Collection&lt;String&gt; ids) {
		Map&lt;String, String&gt; artistMap = new HashMap&lt;String, String&gt;();
		List&lt;Artist&gt; artists = dao.getAllArtists();
		for (Artist a : artists) {
			artistMap.put(a.getId().toString(), a.getName());
		}
		return artistMap;
	}

	public Set&lt;String&gt; loadAllKeys() {
		Set&lt;String&gt; allArtistIds = new HashSet&lt;String&gt;();
		List&lt;Artist&gt; artists = dao.getAllArtists();
		for (Artist a : artists) {
			allArtistIds.add(a.getId().toString());
		}
		return allArtistIds;
	}

}
</pre>
<p>This MapLoader returns a Map to be cached; the key of the Map entry is the artist id, and the value is the artist name.  You could easily make the the value of the entry be an Artist bean with all of the attributes of the artist by changing the implementation and method signatures.</p>
<h3>Configuration</h3>
<p>The next step (almost done!) is to configure Hazelcast and our Spring beans.  The only thing special for our Hazelcast configuration is the class name for our map called 'artists'.  Everything else is the standard Hazelcast configuration:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;!-- Regular Hazelcast configuration omitted --&gt;

&lt;map name=&quot;artists&quot;&gt;
  &lt;map-store enabled=&quot;true&quot;&gt;
   &lt;class-name&gt;net.avantia.datagrid.util.ArtistMapLoader&lt;/class-name&gt;
   &lt;write-delay-seconds&gt;0&lt;/write-delay-seconds&gt;
  &lt;/map-store&gt;
&lt;/map&gt;
</pre>
<p>And our Spring configuration is standard too; it just configures our data source and DAO:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;bean id=&quot;dataSource&quot; destroy-method=&quot;close&quot;&gt;
 &lt;property name=&quot;url&quot; value=&quot;jdbc:mysql://localhost:3306/artists&quot; /&gt;
 &lt;property name=&quot;username&quot; value=&quot;root&quot; /&gt;
 &lt;property name=&quot;password&quot; value=&quot;password&quot; /&gt;
 &lt;property name=&quot;driverClassName&quot; value=&quot;org.hibernate.dialect.MySQLDialect&quot; /&gt;
&lt;/bean&gt;

&lt;bean id=&quot;artistJdbcDao&quot;&gt;
 &lt;constructor-arg ref=&quot;dataSource&quot;/&gt;
&lt;/bean&gt;

&lt;context:component-scan base-package=&quot;net.avantia&quot; /&gt;
</pre>
<h3>Main Class</h3>
<p>The final class for the data grid server is the Java main to start Hazelcast. This could also be a Servlet in an application server or other ways of starting a listener.</p>
<p>Our Main class is:</p>
<pre class="brush: java; title: ; notranslate">
package net.avantia.datagrid;

import com.hazelcast.config.ClasspathXmlConfig;
import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;

/**
 * Starts the cache server.
 * @author Brian Jimerson
 *
 */
public class DataGridServer {

	private HazelcastInstance instance;

	/**
	 * Main entry point for the memory data grid server.
	 * @param args
	 */
	public static void main(String[] args) {
		Config cfg = new ClasspathXmlConfig(&quot;hazelcast.xml&quot;);
		HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg);
		DataGridServer server = new DataGridServer(instance);
		int status = server.run();
	}

	/**
	 * Creates a new CacheServer instance.
	 * @param instance The underlying HazelcastInstance
	 */
	private DataGridServer(HazelcastInstance instance) {
		this.instance = instance;
	}

	/**
	 * Runs the server.
	 *
	 * @return 0 if run completes successfully; a negative number if there was an error.
	 */
	private int run() {
		System.out.println(&quot;Started data grid server with instance [&quot; + instance.getName() + &quot;].&quot;);
		return 0;
	}

}
</pre>
<h3>Data Grid Client</h3>
<p>Once you start the data grid server, there are a number of ways to access the data grid.  Hazelcast provides Java, memcached (yes, memcached client access, but it doesn&#8217;t seem to support named maps), and REST clients out of the box, and these should cover most of your needs.</p>
<p>For Java client access, you can either wire up a Spring bean like this:</p>
<pre class="brush: xml; title: ; notranslate">
	&lt;bean id=&quot;hazelcastClient&quot;
		class=&quot;com.hazelcast.client.HazelcastClient&quot;
		factory-method=&quot;newHazelcastClient&quot;&gt;
		&lt;constructor-arg value=&quot;artist&quot;/&gt;
		&lt;constructor-arg value=&quot;artist&quot;/&gt;
		&lt;constructor-arg value=&quot;localhost&quot;/&gt;
	&lt;/bean&gt;
</pre>
<p>or in Java like this:</p>
<pre class="brush: java; title: ; notranslate">
  HazelcastClient hazelcastClient = HazelcastClient.newHazelcastClient(&quot;artist&quot;, &quot;artist&quot;, &quot;localhost&quot;);
</pre>
<p>And once you have a client instance you can get all of the grid&#8217;s artists like this:</p>
<pre class="brush: java; title: ; notranslate">
  Map&lt;String, String&gt; allArtists = hazelcastClient.getMap(&quot;artist&quot;);
  System.out.println(&quot;All artists = &quot; + allArtists);
</pre>
<h3>Conclusion</h3>
<p>In this post, we&#8217;ve walked through the process of using Hazelcast as an in-memory data grid, providing a map cache backed by a persistent store.  This cache is read-only, but could easily support massive reads with little latency in a cloud-based infrastructure.</p>
<p>There are many other use cases for in-memory data grids in the cloud: writing to persistence-backed caches, name-value entries, and map-reduce strategies.  This is just one use case that shows how to leverage a traditional database to support large-scale data access for persistent data.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/09/11/using-hazelcast-in-memory-data-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scalabution: Don&#8217;t let design patterns distract you from the business process</title>
		<link>http://blog.avantia-inc.com/2011/09/07/scalabution-dont-let-design-patterns-distract-you-from-the-business-process/</link>
		<comments>http://blog.avantia-inc.com/2011/09/07/scalabution-dont-let-design-patterns-distract-you-from-the-business-process/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 15:18:44 +0000</pubDate>
		<dc:creator>Jeremiah Shapera</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[design patterns]]></category>
		<category><![CDATA[distributed systems]]></category>
		<category><![CDATA[scalability]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=226</guid>
		<description><![CDATA[Scalability is really about distribution. Once a system exhausts all available resources on a single server, it is time to scale out &#8211; distribute the workload over more than one server. If a system can perform its function identically on an arbitrary number of servers as on one server then the system is scalable. The <a href='http://blog.avantia-inc.com/2011/09/07/scalabution-dont-let-design-patterns-distract-you-from-the-business-process/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Scalability is really about distribution. Once a system exhausts all available resources on a single server, it is time to scale out &#8211; distribute the workload over more than one server. If a system can perform its function identically on an arbitrary number of servers as on one server then the system is scalable. The most common approach to distributing a system is tier-based; divide system features into independent components or services that can each run on separate servers. Another approach is resource-based distribution; divide system load across as many servers as is necessary. These two approaches are quite similar but diverge significantly in one important aspect; congruence with the business process.</p>
<p>Tier-Based distribution is similar to SOA, albeit superficially. The cornerstone of SOA is cohesive services with clearly defined boundaries. In an SOA system boundaries are drawn along vertical lines delineating areas of responsibility. N-tier design uses boundaries to define units of scalability rather than areas of responsibility. Boundaries between tiers are drawn along fault lines in the resource landscape &#8211; hand-off points between components. A business process that might fall under a single service in SOA might live in multiple tiers to allow optimization of resource usage at critical points in the process. Loosely coupled units of related functionality may scale independently in an n-tier system. This flexibility comes at the cost of artificial boundaries injected into an otherwise cohesive process with forced integration to allow the process to flow across those boundaries.</p>
<p>An example of such artificial boundaries is found in nearly every design pattern in common use. MVC allows each part to vary (and scale) independently by separating models, views, and controllers into independent tiers. Whether deployed separately or together these independent tiers operate in a mutually dependent integration as defined by a business process. Physical separation and logical independence do not break the links between steps in a process. Even a distributable process remains a cohesive unit when viewed as a process as opposed to a pattern.</p>
<p>Resource-Based distribution relies on process-oriented cohesion, creating a more natural separation of functionality along process boundaries. As with SOA, boundaries delineate areas of responsibility. Scalability is achieved not through artificial separation of functionality, but organically through process improvement. Separation of concerns is aligned with business needs rather than the organization imposed by programing constructs.</p>
<p>Organic growth tightly coupled to a business process is here assumed a desirable outcome. Tier- and resource-based distribution are conceptually similar in their ability to scale. Both may allocate computational resources to any subprocess as needed. Tier-based distribution errs toward flexibility and scalability in its interpretation of a business process. When the business process changes, the focus on scalability results in divergence with the process. Resource-based distribution errs toward adherence to the business process. Changes in the process do not result in a loss of scalability. Incongruence with the business means that the system does not fulfill its intended purpose and can result in loss of information. Shouldn&#8217;t a system focus on the business process and scale naturally as the business grows?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/09/07/scalabution-dont-let-design-patterns-distract-you-from-the-business-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cloud Scale Data Access with In-memory Data Grids</title>
		<link>http://blog.avantia-inc.com/2011/08/31/cloud-scale-data-access-with-in-memory-data-grids/</link>
		<comments>http://blog.avantia-inc.com/2011/08/31/cloud-scale-data-access-with-in-memory-data-grids/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 03:37:07 +0000</pubDate>
		<dc:creator>Brian Jimerson</dc:creator>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[hazelcast]]></category>
		<category><![CDATA[vfabric]]></category>
		<category><![CDATA[weblogic]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=285</guid>
		<description><![CDATA[Cloud applications require a new way of thinking about design and function.  One new paradigm is data access.  There are a number of options for data access, persistence, and storage in cloud applications: relational databases, document databases, key/value databases, and so on.  All of these options offer advantages and disadvantages in cloud applications, and current <a href='http://blog.avantia-inc.com/2011/08/31/cloud-scale-data-access-with-in-memory-data-grids/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Cloud applications require a new way of thinking about design and function.  One new paradigm is data access.  There are a number of options for data access, persistence, and storage in cloud applications: relational databases, document databases, key/value databases, and so on.  All of these options offer advantages and disadvantages in cloud applications, and current architecture and design principles for cloud applications prefer using a combination of these data stores to solve the task at hand.</p>
<p>Most of these data storage solutions require persisting data to an underlying disk or other permanent store medium.  They differ in their data structures and query mechanisms, but still must eventually store the data somewhere semi-permanent, so that the data can persist across restarts, failures, and backup/restore processes.  The downside to this is well known; disk and network access is slow.  Cloud applications are usually designed to support massive scale, such as tens of thousands of users or millions of queries per day.  Reading and writing data from disk or network doesn&#8217;t lend itself to this kind of scale.</p>
<p>A different type of data solution that can support this kind of scale is a distributed in-memory data grid.  A distributed in-memory data grid stores data in memory, as the name says, which performs notoriously well.  Most traditional caching mechanisms use memory access to provide performance.  Even though traditional cache solutions provide fast in-memory data access, they are designed to perform a different function than in-memory data grids, and there&#8217;s a couple of things that they usually lack for cloud applications:</p>
<ol>
<li>Since they were designed to do things like cache database query results or HTTP sessions, their data structures are usually limited to key/value pairs.</li>
<li>As traditional cache solutions were designed to be &#8216;embedded&#8217; in applications, its hard to scale traditional cache solutions in a grid format.  Most traditional cache solutions support horizontal scaling through cluster communications and replication, but they don&#8217;t support vertical scaling of data segments through techniques like sharding and <a title="MapReduce" href="http://labs.google.com/papers/mapreduce.html" target="_blank">MapReduce</a>.</li>
</ol>
<p>So wouldn&#8217;t it be nice to use a data access solution that gave you:</p>
<ul>
<li>The performance of in-memory data access</li>
<li>The reliability of data persistence</li>
<li>The scalability of cloud-like grid clusters</li>
<li>The flexibility of multiple data structures and programming models</li>
</ul>
<p>That&#8217;s where distributed in-memory data grids come in.  These products give you the performance of memory access, like traditional cache systems.  However, they also give you the benefits of traditional database systems, like persistence and data structures, and they also add grid scale.  The idea is that with enough nodes in the data grid cluster, and the right replication scheme, storing data in-memory doesn&#8217;t mean the data is volatile.</p>
<p>With traditional data center architectures, in-memory data is never considered sufficient, because the restart of a server, failure of a server, bad hardware, or even an operating system update would cause a loss of data.  But if  you have a 100-node cluster, and if your data is sharded and replicated across the 100 nodes properly, you should be able to have access to all of the data even if you lose 5 or 10 nodes to any of these downtime scenarios.  What are the chances of enough nodes being down (say 50-60 out of 100) to lose any in-memory data?</p>
<p>If the probability of data loss can be reduced to a negligible factor, then <em>not</em> storing data in-memory becomes a hard argument.  In-memory data storage provides a lot of benefit to scale and performance, with very little risk.  Two things that are required are a large grid cluster (PaaS), like <a href="http://www.cloudfoundry.com/" target="_blank">VMware Cloud Foundry</a> or <a href="http://aws.amazon.com/ec2/" target="_blank">Amazon EC2</a>, and an in-memory data grid solution designed for this application.</p>
<p>Hopefully I&#8217;ve convinced you that there is a strong case for looking at distributed in-memory data grids for large scale, public and private cloud applications.  Some of the in-memory data grids designed for this scenario are:</p>
<ul>
<li><a title="VMware vFabric GemFire" href="http://www.vmware.com/products/vfabric-gemfire/overview.html" target="_blank">VMware vFabric GemFire</a> &#8212; GemFire is a best-of-breed solution for commercial applications.  Features like continuous queries are first class.</li>
<li><a title="Oracle Coherence" href="http://www.oracle.com/us/products/middleware/coherence/index.html" target="_blank">Oracle Coherence</a> &#8212; Coherence is another best-of-breed in-memory data grid.  If you&#8217;re using WebLogic Server 11g, you already have Coherence.</li>
<li><a title="Hazelcast" href="http://www.hazelcast.com/" target="_blank">Hazelcast</a> &#8212; Hazelcast is an open-source, Java-based in-memory data grid.  It supports many of the features discussed, and some other standard features of in-memory data grids (like continuous queries) are planned.</li>
</ul>
<p>In the next post, I&#8217;ll show you how to use Hazelcast to provide an in-memory data store, backed by a relational database, and how to query from a REST client.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/08/31/cloud-scale-data-access-with-in-memory-data-grids/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying Jahia 6.1 on Oracle WebLogic</title>
		<link>http://blog.avantia-inc.com/2011/07/27/deploying-jahia-6-1-on-oracle-weblogic/</link>
		<comments>http://blog.avantia-inc.com/2011/07/27/deploying-jahia-6-1-on-oracle-weblogic/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 02:57:58 +0000</pubDate>
		<dc:creator>Brian Jimerson</dc:creator>
				<category><![CDATA[Jahia]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[WebLogic]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=231</guid>
		<description><![CDATA[Most people deploy Jahia WCM on Apache Tomcat, which is the default application server. But Jahia is fully compliant with the Java Servlet specification, and as such can be deployed to any compliant Servlet container such as IBM WebSphere Application Server, JBoss, and Oracle WebLogic Server. In this post, we&#8217;ll cover how to deploy Jahia <a href='http://blog.avantia-inc.com/2011/07/27/deploying-jahia-6-1-on-oracle-weblogic/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Most people deploy <a href="http://www.jahia.com" target="_blank">Jahia WCM</a> on <a href="http://tomcat.apache.org" target="_blank">Apache Tomcat</a>, which is the default application server.  But Jahia is fully compliant with the Java Servlet specification, and as such can be deployed to any compliant Servlet container such as <a href="http://www-01.ibm.com/software/webservers/appserv/was/" target="_blank">IBM WebSphere Application Server</a>, <a href="http://www.jboss.org/jbossas/" target="_blank">JBoss</a>, and <a href="http://www.oracle.com/technetwork/middleware/weblogic/index.html" target="_blank">Oracle WebLogic Server</a>.  In this post, we&#8217;ll cover how to deploy Jahia EE 6.1 to Oracle WebLogic Server 11g using Oracle Database 11g as the database for Jahia.</p>
<h2>Deployment Model Differences</h2>
<p>Jahia is deployed as a standard WAR file, and, with the exception of classpath resources, template sets for sites are deployed as a directory in the WAR file&#8217;s templates folder.  For example, if my template set is called &#8216;my-template-set&#8217;, the template set would be deployed to the Jahia WAR file&#8217;s templates/my-template-set directory.  This deployment model is convenient, as it keeps the Jahia application, and custom templates, self-contained in a single deployable unit.  When deploying templates to Jahia on Tomcat, this is as simple as copying template resources to the webapps/ROOT/templates directory in Tomcat.  Tomcat treats folders in it&#8217;s webapps directory that match the exploded WAR format as contexts; the ROOT context (unless you&#8217;ve changed it) in Tomcat is the Jahia WAR file and is automatically served up as the / URL context.</p>
<p>WebLogic, like many full Java EE containers, do not have this kind of simple deployment model for a number of reasons.  WebLogic assumes that there will be multiple servers, Admin or managed, in domains.  It also supports clustered nodes and distributed deployments.  Because of these features, deploying applications to WebLogic requires an application to be distributed through the Admin Server and node managers, and not just simply served up from the filesystem.  What this means to Jahia administrators and developers is that updated template sets, which are the main artifact for Jahia development, can&#8217;t be copied to the Jahia WAR directory to deploy changes.  When template sets are updated, the entire Jahia WAR file must be redeployed and redistributed through WebLogic Admin Servers and node managers, and as such eliminates the ability to do &#8216;hot deployment&#8217; of template resources.</p>
<h2>Jahia Config Wizard</h2>
<p>The first step in deploying Jahia to WebLogic is to run the Jahia Config Wizard while its deployed to a temporary Tomcat server:</p>
<ol>
<li>Download Jahia EE 6.1 tar file.</li>
<li>Extract Jahia to a temporary location.</li>
<li>Create a new user/schema for Jahia in Oracle DB.</li>
<li>Start Jahia by running &lt;jahia-dir&gt;/bin/startup.sh|.bat.</li>
<li>Open a browser and go to http://localhost:8080/config</li>
<li>Go through the Config Wizard; the key here is to set up the Oracle database properly instead of the default Hypersonic database.</li>
<li>Shutdown Jahia: &lt;jahia-dir&gt;/bin/shutdown.sh|.bat</li>
</ol>
<h2>Creating the Jahia EAR Structure</h2>
<p>Since WebLogic is a full Java EE container, it expects EAR resources instead of WAR files.  You can deploy WAR files directly to WebLogic, but behind the scenes is creates an EAR file for the WAR, and there are some application-level configuration settings necessary for Jahia on WebLogic, so you need to create an exploded EAR structure for Jahia:</p>
<ol>
<li>Create a new WebLogic domain with an Admin Server and a managed server.  We&#8217;ll call our domain jahia_domain and our managed server jahia_server1.</li>
<li>Copy the following files from the temporary Tomcat/Jahia server to the domain&#8217;s lib directory (&lt;middleware-home&gt;/user_projects/domains/jahia_domain/lib):<br />
<code>&lt;tomcat-dir&gt;/lib/activation-1.1.jar<br />
&lt;tomcat-dir&gt;/lib/castor-1.1.1.jar<br />
&lt;tomcat-dir&gt;/lib/ccpp-1.0.jar<br />
&lt;tomcat-dir&gt;/lib/commons-logging-1.1.1.jar<br />
&lt;tomcat-dir&gt;/lib/jaxb-impl-2.1.7.jar<br />
&lt;tomcat-dir&gt;/lib/log4j-1.2.15.jar<br />
&lt;tomcat-dir&gt;/lib/pluto-container-2.0.0-RI.jar<br />
&lt;tomcat-dir&gt;/lib/pluto-descriptor-api-2.0.0-RI.jar<br />
&lt;tomcat-dir&gt;/lib/pluto-descriptor-impl-2.0.0-RI.jar<br />
&lt;tomcat-dir&gt;/lib/pluto-taglib-2.0.0-RI.jar<br />
&lt;tomcat-dir&gt;/lib/portlet-api-2.0.jar<br />
&lt;tomcat-dir&gt;/lib/stax-1.2.0.jar<br />
&lt;tomcat-dir&gt;/lib/stax-api-1.0.1.jar<br />
&lt;tomcat-dir&gt;/lib/xercesImpl-2.9.1.jar<br />
&lt;tomcat-dir&gt;/lib/xmlParserAPIs-2.9.1.jar<br />
&lt;tomcat-dir&gt;/endorsed/jaxb-api-2.1.jar</code></li>
<li>Create a new directory in your domain home called jahia-deploy</li>
<li>In jahia-deploy, create the following directories and file:</li>
<ol>
<li>jahia-ear</li>
<li>jahia-ear/META-INF</li>
<li>jahia-ear/META-INF/application.xml</li>
<li>jahia-ear/META-INF/weblogic-application.xml</li>
<li>jahia-ear/jahia</li>
</ol>
<li>Edit jahia-ear/META-INF/application.xml and add this content:
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE application PUBLIC &quot;-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN&quot; &quot;http://java.sun.com/dtd/application_1_3.dtd&quot;&gt;
&lt;application&gt;
  &lt;display-name&gt;Jahia&lt;/display-name&gt;
  &lt;description&gt;Jahia&lt;/description&gt;
  &lt;module&gt;
    &lt;web&gt;
      &lt;web-uri&gt;jahia&lt;/web-uri&gt;
      &lt;context-root&gt;/&lt;/context-root&gt;
    &lt;/web&gt;
   &lt;/module&gt;
&lt;/application&gt;
</pre>
</li>
<li>Edit jahia-ear/META-INF/weblogic-application.xml and add this content:
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;weblogic-application xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns=&quot;http://www.bea.com/ns/weblogic/90&quot; xsi:schemaLocation=&quot;http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-application.xsd http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/j2ee_1_4.xsd &quot;&gt;
&lt;xml&gt;
  &lt;parser-factory&gt;
    &lt;saxparser-factory&gt;org.apache.xerces.jaxp.SAXParserFactoryImpl&lt;/saxparser-factory&gt;
    &lt;document-builder-factory&gt;org.apache.xerces.jaxp.DocumentBuilderFactoryImpl&lt;/document-builder-factory&gt;
    &lt;transformer-factory&gt;org.apache.xalan.processor.TransformerFactoryImpl&lt;/transformer-factory&gt;
  &lt;/parser-factory&gt;
&lt;/xml&gt;
&lt;prefer-application-packages&gt;
  &lt;package-name&gt;antlr.*&lt;/package-name&gt;
&lt;/prefer-application-packages&gt;
&lt;/weblogic-application&gt;
</pre>
</li>
<li>Copy the contents of &lt;tomcat-dir&gt;/webapps/ROOT to jahia-deploy/jahia-ear/jahia</li>
<li>Move the following jars from jahia-deploy/jahia-ear/jahia/WEB-INF/lib to jahia-deploy/jahia-ear<br />
<code><br />
jms-1.1.jar<br />
jta-1.0.1B.jar<br />
mail-1.4.jar<br />
xalan-2.7.0.jar</code></li>
<li>Comment out these two sections in jahia-deploy/jahia-ear/jahia/WEB-INF/web.xml:
<pre class="brush: xml; title: ; notranslate">
&lt;servlet&gt;
  &lt;servlet-name&gt;Test&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.jahia.bin.TestServlet&lt;/servlet-class&gt;
  &lt;load-on-startup&gt;99&lt;/load-on-startup&gt;
&lt;/servlet&gt;
...
&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Test&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/test/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
</pre>
</li>
</ol>
<h2>Creating File System Directories</h2>
<p>Jahia, by default, stores a number of items in directories inside the WAR directory, like search indexes and BLOB files.  Since Jahia as a whole gets redeployed when templates get redeployed, you&#8217;ll want to change these directories to something external to the Jahia WAR:</p>
<ol>
<li>Assuming that the base directory for these files is /var/jahia, create the following directories:
<ol>
<li>/var/jahia/content</li>
<li>/var/jahia/content/bigtext</li>
<li>/var/jahia/content/tmp</li>
<li>/var/jahia/content/slide</li>
<li>/var/jahia/content/filemanager</li>
<li>/var/jahia/search_indexes</li>
<li>/var/jahia/workspaces</li>
</ol>
</li>
<li>Give your WebLogic user full read and write access to these directories.</li>
<li>Edit jahia-deploy/jahia-ear/jahia/WEB-INF/etc/config/jahia.properties, and change the following properties:
<ol>
<li>jahiaFilesBigTextDiskPath = /var/jahia/content/bigtext</li>
<li>tmpContentDiskPath = /var/jahia/content/tmp</li>
<li>slideContentDiskPath = /var/jahia/content/slide</li>
<li>jahiaFileRepositoryDiskPath = /var/jahia/content/filemanager</li>
</ol>
</li>
<li>Edit jahia-deploy/jahia-ear/jahia/WEB-INF/etc/repository/jackrabbit/repository.xml, and change the Workspaces element to this:
<pre class="brush: xml; title: ; notranslate">
&lt;Workspaces rootPath=&quot;/var/jahia/workspaces&quot; defaultWorkspace=&quot;default&quot;/&gt;
</pre>
</li>
</ol>
<h2>Deploying Jahia</h2>
<p>Now that all of the initial configuration is complete, you can deploy Jahia to your WebLogic Server.  Follow these steps for the initial deployment, and whenever you want to redeploy templates or the Jahia application proper:</p>
<ol>
<li>Copy your template set web resources to jahia-deploy/jahia-ear/jahia/templates</li>
<li>Copy any compiled custom classes or resources to jahia-deploy/jahia-ear/jahia/WEB-INF/classes</li>
<li>Log in to the WebLogic Administration Console (i.e. http://localhost:7001/console)</li>
<li>If this is the first time you&#8217;ve deployed Jahia on the server:
<ol>
<li>Create a new datasource with a JNDI name of &#8216;jdbc/jahia&#8217; that points to the Oracle DB set up previously</li>
<li>Deploy the jahia-deploy/jahia-ear directory as an exploded EAR application in the Deployments section</li>
</ol>
</li>
<li>If you&#8217;re redeploying Jahia for template or other changes, then simply update the existing jahia application in the Deployments section, using the jahia-deploy/jahia-ear directory as an exploded EAR application.</li>
</ol>
<h2>Conclusion</h2>
<p>Although the initial set up of Jahia for WebLogic may seem a bit daunting, running and deploying Jahia on WebLogic is just as seamless as lightweight servers such as Tomcat.  WebLogic is a very good enterprise application server, and is certainly a wise choice for many organizations.  And thanks to Jahia&#8217;s standards compliance, open nature, and flexibility, Jahia can be run on WebLogic with minimal configuration just like any other Java application server.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/07/27/deploying-jahia-6-1-on-oracle-weblogic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Value of Quality: It&#8217;s Everyone&#8217;s Responsibility</title>
		<link>http://blog.avantia-inc.com/2011/06/20/the-value-of-quality-its-everyones-responsibility/</link>
		<comments>http://blog.avantia-inc.com/2011/06/20/the-value-of-quality-its-everyones-responsibility/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 12:30:19 +0000</pubDate>
		<dc:creator>Mike Hammontree</dc:creator>
				<category><![CDATA[Quality Assurance]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[quality]]></category>
		<category><![CDATA[quality assurance]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[value]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=108</guid>
		<description><![CDATA[What is the value of quality and why is it everyone&#8217;s responsibility? Have you ever really stopped and asked yourself this? Or, do you just assume that quality is a built-in, natural phenomenon and not something you have to be concerned about? While this seems like a straight-forward question that should be easy to answer, <a href='http://blog.avantia-inc.com/2011/06/20/the-value-of-quality-its-everyones-responsibility/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>What is<em> </em>the value of quality and why is it everyone&#8217;s responsibility? Have you ever really stopped and asked yourself this? Or, do you just assume that quality is a built-in, natural phenomenon and not something you have to be concerned about?</p>
<p>While this seems like a straight-forward question that should be easy to answer, it is actually a commonly misunderstood part of many software development efforts. With a clear understanding of quality, and by implementing concepts to assure quality within your project, you will be taking a great step towards improving your final product and increasing the return on your investment.</p>
<p><strong>What is quality?</strong></p>
<p>Merriam-Webster provides several definitions for quality. For the purposes of software development, there are two in particular that fit well: <em>a degree of excellence</em> and <em>superiority in kind.</em></p>
<p>Don&#8217;t you want your end result to have a high degree of excellence and be a superior product? It won&#8217;t happen accidentally. Quality is deliberate, intentional, and should always be planned. Think of it as a guiding principle of your project that should be highlighted on day one. Regardless of what you&#8217;re building, quality should be one of your objectives.</p>
<p><strong>What is quality assurance (QA)?</strong></p>
<p>Quality assurance is the process of ensuring your deliverables meet a defined, minimum standard with the least amount of defects possible. Quality assurance requires dedication, planning, consistent attention and time.</p>
<p>The standards for quality assurance within your project are set during the requirements phase. These may include functional requirements, non-functional requirements, standards required for integration into other platforms, usability needs or company-specific best practices. As the foundation for your deliverables, having clear, specific requirements plays a critical role in quality assurance.</p>
<p><strong>Value &amp; Responsibility: </strong></p>
<p>Quite simply, quality adds value by improving your end result. Implementing the practice of quality assurance in all phases of the project lifecycle and with all members of the project team is how to get it.</p>
<p>Every resource has the potential to add quality while working within their respective roles on the project. Everyone inherits this responsibility as part of the project team. Even with a resource filling the role of tester, it does not let others off the hook for maintaining quality while working on the project.</p>
<p>In much the same way a player on a sports team contributes to its overall success, each member of a project team is able to provide the same contribution to quality within a project. Working together as a team towards improving quality produces better results. Whether your business sponsor steps forward to clarify vagueness in a requirement, your project manager catches an error in estimates, or your developer corrects a defect prior to system testing, each person has contributed to improving the quality of the final result.</p>
<p>As a matter of fact, errors corrected earlier in the project lifecycle, whether they be in planning or defects in actual code, result in less overall expense to the project as a whole since they were not carried downstream. The further downstream errors and defects go, the more costly they become to correct in hours burned, resource engagement and budget consumption.</p>
<p>In the case of a production defect, while you can go back and correct one that&#8217;s been exposed to your users after release, you may have a hard time, or possibly never, overcome negative perceptions and opinions formed as the end user encountered the issue. The risk and potential impact to your business is significantly reduced by having quality assurance processes in place to minimize this situation from occurring to begin with.</p>
<p>Dedication to quality assurance will involve commitments to time, budget and resources around quality tools and practices used in the project. Include expenses for resource(s) to fill the role of tester in your project budget. Plan time for unit, integration, system, regression and user acceptance testing, both manually and automated if possible, prior to release. Provide the needed tools and environments for testing resources to verify and validate project requirements. And finally, use a system to log defects and track tasks for the project as a way to manage work and minimize risk prior to release.</p>
<p>Once you have the people and tools in place, commit to following through on addressing issues that impact quality. If you are doing the work to identify these issues in your product or processes, you must also follow through with getting the effort required to correct them into your project workflow to realize the value of your investment in quality.</p>
<p><strong>Misconceptions surrounding quality, quality assurance and testing:</strong></p>
<p>Misconceptions about quality, quality assurance and testing can easily work their way into technical groups and project teams. Be aware of the differences in some of these common misconceptions surrounding quality to keep your team and project focused on delivering high quality results.</p>
<p><em>- Quality, quality assurance, and testing are all the same thing. </em></p>
<p>While they are all related to one another, they are different. Quality is the goal, quality assurance is the process, and testing is one of the primary tools used within quality assurance to increase quality. It&#8217;s easy to lump them all together as one, and place that responsibility on one person only. By doing so, you narrow the potential for improving quality by limiting resources who can otherwise have a positive impact on your end result.</p>
<p><em>- Quality assurance guarantees perfect results.</em></p>
<p>While quality assurance processes can greatly improve the overall end result of a project, it is not a system designed to create perfection. When instituting a culture of quality amongst your project team, it is important to note that while perfection itself may be unattainable, it is not an excuse to disregard processes intended to improve quality. Higher quality typically results in higher end user satisfaction with a product.</p>
<p><em>- If everyone is focused on quality, then I don&#8217;t need a tester.</em></p>
<p>Even with everyone focused on quality, the role of a tester in software development is still one which we highly recommend be included in your project team. Acute testers have the ability to not only put themselves in the shoes of the end user, but also provide valuable details on where defects are happening and how to recreate them. This is the key to turning reported defects into implemented fixes quickly and accurately. Developers are often too familiar with the code to see some issues while end users are often not familiar enough to know if something is working as designed. Having the tester in the middle helps bridge the gap, and will help bring a higher level of confidence to your deliverables.</p>
<p><em>- With a tester on my project team, my developers will be able to work quicker since they won&#8217;t need to test. </em></p>
<p>Unit testing by developers is one of the easiest ways quality can add value to a project. When a developer finds an issue as a result of testing done as they develop, they have the ability to implement a fix much quicker than at any other time in the project. This conserves time, resources, budget and potential impact on other areas of code once integrated. Testing resources will once again verify this code as part of the whole, either directly or indirectly, during system and integration testing downstream. Unit testing will not uncover all defects in software, which is why system and regression testing is necessary as well. Unit, system and regression tests are intended to complement each other. Quality will suffer and project resources will be wasted unnecessarily if any one type of testing is used as a replacement for another.</p>
<p>As you get the wheels turning while contemplating the next project on the horizon, take a close look at your processes and the dynamics of your project team. Is quality a goal? Is everyone taking responsibility for quality? Will you get more value from this effort with people and processes that are more quality-centric as you work?  Odds are, you will.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/06/20/the-value-of-quality-its-everyones-responsibility/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jahia 6.5 xCM Released</title>
		<link>http://blog.avantia-inc.com/2011/06/14/jahia-6-5-xcm-released/</link>
		<comments>http://blog.avantia-inc.com/2011/06/14/jahia-6-5-xcm-released/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 03:52:30 +0000</pubDate>
		<dc:creator>Brian Jimerson</dc:creator>
				<category><![CDATA[Jahia]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Web Content Management]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=175</guid>
		<description><![CDATA[Jahia 6.5 xCM was just released, and for those of you who haven&#8217;t seen or heard of Jahia 6.5, it&#8217;s a very exciting release.  Jahia 6.5, despite it&#8217;s version number, is a major release of Jahia, and introduces many new features that really makes it stand out as a platform for a myriad of web <a href='http://blog.avantia-inc.com/2011/06/14/jahia-6-5-xcm-released/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.jahia.com">Jahia 6.5 xCM</a> was just released, and for those of you who haven&#8217;t seen or heard of Jahia 6.5, it&#8217;s a very exciting release.  Jahia 6.5, despite it&#8217;s version number, is a major release of Jahia, and introduces many new features that really makes it stand out as a platform for a myriad of web content management needs.  As a Gold Partner, we&#8217;ve had the opportunity to work with Jahia 6.5 during its development and beta program, and we wanted to point out some of the major new features.</p>
<h3>New Content Management Roles</h3>
<p>In past Jahia versions, there were a few standard roles involved in editing, consuming and publishing content:</p>
<ul>
<li><strong>Content reader -</strong> anonymous users or standard logged in users who can consume content or documents</li>
<li><strong>Content editor -</strong> someone who is authorized to contribute, edit, or delete content</li>
<li><strong>Content approver -</strong> someone who is authorized to publish content to the &#8216;live&#8217; site</li>
</ul>
<p>Jahia 6.5 introduces a couple new content management roles to the web content lifecycle.  The idea is that companies have end users with varying degrees of responsibility for site design and content contribution; these new roles support this variation by getting new tools for web content contribution (these tools are discussed later).  The new roles that have been introduced include:</p>
<ul>
<li><strong>Casual content editor -</strong> this would be someone who contributes content to a site, but doesn&#8217;t necessarily &#8216;build out&#8217; the entire site.  For example, take an online magazine site.  A site like this has a lot of article authors who don&#8217;t necessarily care about page structures, home page banners, etc.  They need to create an article quickly and easily.</li>
<li><strong>Business site designer -</strong> this role would be someone who isn&#8217;t a developer, but needs to build sites quickly from sets of pre-defined layouts, themes, and content components.  For example, let&#8217;s say a marketing department wants to launch a microsite for a campaign.  Instead of funding an IT project to build the microsite, the marketing department has the ability to use a web-based, drag-and-drop development environment to quickly build the microsite internally, and deploy that site.</li>
</ul>
<p>These new roles enable business units to be more agile in their web presence, and also open content management to a larger audience.  One interesting consequence of these new roles is that in many cases the traditional Jahia developer/administrator idiom could be much different; developers could be responsible for building and deploying components to be consumed by site designers instead of building templates.  Of course, companies can still choose to follow the traditional model of creating templates that provide strong structure for content editors.</p>
<h3>Jahia Studio</h3>
<p>Jahia Studio is a new view of content management that allows non-developers to quickly build sites in Jahia from sets of predefined components, structures, and styles.  Jahia Studio is a web-based environment for users to build sites and pages from palettes of content and social components, layouts, pages, and other content items.  If you&#8217;re familiar with graphical IDEs like Visual Studio or Eclipse with web plugins, think drag-and-drop of components from your palette to your page, only these are content components instead of user interface controls.</p>
<div id="attachment_193" class="wp-caption alignnone" style="width: 705px"><a href="http://blog.avantia-inc.com/wp-content/uploads/2011/06/JahiaStudio1.png"><img class="size-large wp-image-193" title="Jahia Studio" src="http://blog.avantia-inc.com/wp-content/uploads/2011/06/JahiaStudio1-1024x575.png" alt="" width="695" height="390" /></a><p class="wp-caption-text">Jahia Studio</p></div>
<p>The introduction of Jahia Studio means that business units no longer need to engage the development team to create a site; instead the business is empowered to create sites with little training.  The development team creates an &#8216;inventory&#8217; of components, layouts, themes, and the like, deploys them to Jahia, and the business can then design and create sites by consuming this inventory.  This can enable organizations to be truly agile in their web presence, by significantly reducing the time to market and reducing the inevitable gap between vision and implementation.</p>
<h3>Casual Contribution</h3>
<p>Casual contribution mode is a new way for content editors to contribute content, without having to use the traditional popup editors that past versions of Jahia used extensively.  Although inline editing was introduced in Jahia 6, inline editing wasn&#8217;t very useful beyond quick fixes of text content.  The value in casual contribution is that it introduces a new kind of content editor; someone who needs to contribute rich content, but doesn&#8217;t need to leverage the power tools that the full blown Jahia editor tools provide.  Building on the previous example of article authors, these authors don&#8217;t need the ability to create full site map layouts, manage access control lists, or import/export content.  Rather, they need to be able to quickly author new articles with robust editor controls in an intuitive manner.  This kind of content editing is enabled through casual contribution.</p>
<p>In a nutshell, casual contribution builds upon inline editing; it allows casual contributors to enter content in context of the page or content at hand.  Although traditional content editing in Jahia is very intuitive through &#8216;in-context&#8217; editing, casual contribution improves the editor&#8217;s user experience and extends the audience that can contribute content.</p>
<p><a href="http://blog.avantia-inc.com/wp-content/uploads/2011/06/CasualContribution1.png"><img class="alignnone size-large wp-image-178" title="Casual Contribution " src="http://blog.avantia-inc.com/wp-content/uploads/2011/06/CasualContribution1-1024x577.png" alt="" width="695" height="391" /></a></p>
<div id="attachment_179" class="wp-caption alignnone" style="width: 705px"><a href="http://blog.avantia-inc.com/wp-content/uploads/2011/06/CasualContribution2.png"><img class="size-large wp-image-179" title="Casual Contribution 2" src="http://blog.avantia-inc.com/wp-content/uploads/2011/06/CasualContribution2-1024x574.png" alt="" width="695" height="389" /></a><p class="wp-caption-text">Casual Contribution</p></div>
<p>Underneath the hood, Jahia 6.5 has augmented and/or replaced the usage of GWT with JQuery throughout the user interface.  The experience of casual contribution is just one example of how adding JQuery to the mix has greatly enhanced Jahia&#8217;s UI.</p>
<h3>Conclusion</h3>
<p>New content management roles, Jahia Studio, and casual contribution are just a few of the exciting new features in Jahia 6.5 xCM.  There are a plethora of other improvements and additions that we couldn&#8217;t cover here, but we hope to cover in future posts:</p>
<ul>
<li>Component development API</li>
<li>JCR access throughout the full content model</li>
<li>REST APIs for reading and manipulating content</li>
<li>Improved Maven support for Jahia artifacts, like components and templates</li>
<li>Ability to use multiple template sets for a single virtual site</li>
<li>Improved UI and browser compatibility with JQuery</li>
<li>Linking between Studio components, like linking a Rating component to an Article component</li>
</ul>
<p>Jahia 6.5 xCM is an exciting step towards providing a true unified platform for web content delivery.  This version truly enables a much broader audience to manage web content; no longer is the management of web content limited to trained power business users and web developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/06/14/jahia-6-5-xcm-released/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using Enterprise Integration Patterns as a Web Content Platform</title>
		<link>http://blog.avantia-inc.com/2011/06/06/using-enterprise-integration-patterns-as-a-web-content-platform/</link>
		<comments>http://blog.avantia-inc.com/2011/06/06/using-enterprise-integration-patterns-as-a-web-content-platform/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 03:25:30 +0000</pubDate>
		<dc:creator>Brian Jimerson</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[SOA / EAI]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=114</guid>
		<description><![CDATA[Organizations with SOA and service-based infrastructures often need to present data from multiple services in a unified, aggregated interface.  Historically, this has been the domain of portals.  One of the tenets of a portal composite pattern is aggregated content; in other words taking content from multiple, disparate sources and presenting the content in a standard <a href='http://blog.avantia-inc.com/2011/06/06/using-enterprise-integration-patterns-as-a-web-content-platform/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Organizations with SOA and service-based infrastructures often need to present data from multiple services in a unified, aggregated interface.  Historically, this has been the domain of portals.  One of the tenets of a portal composite pattern is aggregated content; in other words taking content from multiple, disparate sources and presenting the content in a standard look and feel.  However, portals typically have a &#8216;portal&#8217; feel; they usually use frames, fieldsets, or boxes to present content from a particular source (think Portlet, mashup, or Web Part).</p>
<p>Recently, one of our clients had a requirement to present data and content from multiple services, but didn&#8217;t want the portal look and feel.  After some more analysis, it became evident that the website needed to invoke multiple services, take the response messages from those services, and create an HTML output that incorporated the response messages as well as &#8216;static&#8217; HTML, CSS, and JavaScript.  This requirement is very similar in function to a BPEL composite or a platform that implements <a href="http://www.eaipatterns.com/">Enterprise Integration Patterns (EIP)</a>.   In other words, service invocation is orchestrated, messages are passed and collected, and an output is created that is the composition of the messages and other data.  The biggest difference between BPEL/EIP and this requirement is that the output is HTML, not a data protocol like XML.</p>
<p>Given the similarities, we designed and built a web content delivery platform that leveraged EIP messaging styles but generated an HTML response.  This particular solution used <a href="http://www.springsource.org/spring-integration">Spring Integration</a> for the messaging integration.  Other platforms that implement the same patterns could just as easily be used, such as BPEL, <a href="http://www.oracle.com/technetwork/middleware/service-bus/overview/index.html">Oracle Service Bus</a>, or <a href="http://www.mulesoft.org/">Mule ESB</a>, to name a few.</p>
<p>The basic sequence for generating web pages in our system is as follows:</p>
<div id="attachment_124" class="wp-caption alignnone" style="width: 705px"><a href="http://blog.avantia-inc.com/wp-content/uploads/2011/06/SpringIntegrationBlogSequence.png"><img class="size-large wp-image-124" title="Sequence Diagram" src="http://blog.avantia-inc.com/wp-content/uploads/2011/06/SpringIntegrationBlogSequence-1024x564.png" alt="Sequence Diagram" width="695" height="382" /></a><p class="wp-caption-text">Sequence Diagram of Content Integration</p></div>
<p>One of the key actors in this sequence is the page configuration; there needs to be some sort of storage of page and site configuration.  This storage needs to be able to tell the integration platform and supporting code things like:</p>
<ul>
<li>What services/channels do I need for content?</li>
<li>What XSLT do I use for output transformation?</li>
<li>What security or authentication mechanisms are required for this page?</li>
</ul>
<p>For this particular project, we used <a href="http://www.oracle.com/technetwork/middleware/content-management/index-094708.html">Oracle Universal Content Management (UCM)</a> to provide the configuration storage, as well as storing the XSLTs used to create the output.  The client had UCM installed already, and UCM has robust SOAP APIs, so it was a good fit.  In practice, any sort of persistent storage could be used, such as a relational database, Spring context configuration, and so on.  It would be helpful to use something that doesn&#8217;t require redeployment of the application (like Spring context configurations usually do), as the idea is to allow the development of sites independently of the content delivery platform.</p>
<p>Once the composition of the page request is determined, the integration platform is used to collect, aggregate, transform, and assemble the resultant output.  The first step is to process the request.</p>
<p>Using Spring Integration, a Servlet was created to handle requests for these &#8216;virtual&#8217; pages.  The Java code for the doPost method looks like this:</p>
<pre class="brush: java; title: ; notranslate">
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
ServiceGateway serviceGateway = (ServiceGateway) context.getBean(&quot;serviceGateway&quot;);
result = serviceGateway.getPage(requestInfo);
response.getWriter().write(result);
</pre>
<p>In the preceding code, the requestInfo variable is just a Java bean that stores a the requested page&#8217;s configuration.  The most important part of this is the page name.  In our case, the requested page is the third part of the request path; the first two are the Servlet and site respectively.  So, for a request of /serviceBus/mySite/home, the Servlet path is serviceBus, the site name is mySite, and the page is home.</p>
<p>The Spring context configuration for the serviceGateway bean is:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;si:gateway
  service-interface=&quot;net.avantia.bus.integration.ServiceGateway&quot;
  id=&quot;serviceGateway&quot;/&gt;
</pre>
<p>And the ServiceGateway interface is a simple interface:</p>
<pre class="brush: java; title: ; notranslate">
public interface ServiceGateway {
 @Gateway(requestChannel=&quot;page-request&quot;, replyChannel=&quot;html&quot;)
    public String getPage(RequestInfo message)
     throws MissingContentResourceException, Exception;
}
</pre>
<p>The request channel page-request is defined simply in the context configuration as:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;si:channel id=&quot;page-request&quot;/&gt;
</pre>
<p>None of this is very interesting though.  The real key is the Message Enricher defined for the page-request channel:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;si:service-activator
  ref=&quot;bootstrapMessageEnricher&quot;
  method=&quot;enrichMessage&quot;
  input-channel=&quot;page-request&quot;
  output-channel=&quot;full-request-content&quot;/&gt;
</pre>
<p>This bean tells Spring Integration to enrich the inbound message on the page-request channel by invoking the enrichMessage method on the bootstrapMessageEnricher bean with the supplied inbound message.  The enrichMessage method of the bootstrapMessageEnricher gets the configuration of the requested page from our configuration store (UCM in this case), and sets a number of headers in the message.  The bootstrapMessageEnricher bean&#8217;s enrichMessage method looks like this:</p>
<pre class="brush: java; title: ; notranslate">

public Message&lt;String&gt; enrichMessage(Message&lt;RequestInfo&gt; message)  throws Exception {
  RequestInfo reqInfo = message.getPayload();
  String requestedPage = reqInfo.getRequestedPage();
  String site = reqInfo.getSiteName();
  Map queryMap = reqInfo.getQueryParams();
  String siteXmlFileName = site + &quot;_SITE_XML&quot;;
  String siteXsltFileName = site + &quot;_SITE_XSL&quot;;
  String siteXml = ucmContentUtil.getUcmFile(siteXmlFileName, ucmUid, ucmPwd);
  String convertedPath = convertSitePath(requestedPage);
  XPathUtil xpathUtil = new XPathUtil(siteXml);
  String pageNode = xpathUtil.getXmlFragment(convertedPath);
  if (null == pageNode) {
     throw new MissingContentResourceException(&quot;No page node found for path: '&quot; + convertedPath + &quot;'&quot;);
  }
  String siteXslt = ucmContentUtil.getUcmFile(siteXsltFileName, ucmUid, ucmPwd);
  String queryParamXml = wsbUtil.convertQueryParams(queryMap);
  Message&lt;String&gt; outMessage = MessageBuilder.withPayload(pageNode).
   setHeader(&quot;siteXml&quot;, siteXml).
   setHeader(&quot;queryParams&quot;, queryParamXml).
   setHeader(&quot;siteName&quot;, ((RequestInfo) message.getPayload()).getSiteName()).
   setHeader(&quot;requestedPage&quot;, requestedPage).setHeader(&quot;siteXslt&quot;, siteXslt).
   setHeader(&quot;servletRequest&quot;, reqInfo.getServletRequest()).
   setHeader(&quot;contextParameters&quot;, ((RequestInfo) message.getPayload()).getContextParameters().toXml()).
   build();
  return outMessage;
}
</pre>
<p>The Message Enricher takes care of figuring out the requested site, required authentication, and so on by parsing the request, finding the configuration for the requested page, and setting message headers for the requested information.  The next step is to configure a Header Value Router that routes the messages to specific beans based on the message headers set by the Message Enricher:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;si:header-value-router input-channel=&quot;split-request-content&quot; header-name=&quot;contentSrcType&quot;&gt;
  &lt;si:mapping value=&quot;soap&quot; channel=&quot;soap-service-request&quot; /&gt;
  &lt;si:mapping value=&quot;httpGet&quot; channel=&quot;http-get-service-request&quot; /&gt;
  &lt;si:mapping value=&quot;ucmGetFile&quot; channel=&quot;ucmGetFile-request&quot; /&gt;
  &lt;si:mapping value=&quot;param&quot; channel=&quot;param-request&quot; /&gt;
  &lt;si:mapping value=&quot;static&quot; channel=&quot;aggregator-input&quot; /&gt;
  &lt;si:mapping value=&quot;http&quot; channel=&quot;aggregator-input&quot; /&gt;
&lt;/si:header-value-router&gt;
</pre>
<p>The Header Value Router takes care of routing the message to various beans defined based on the header values set by the Message Enricher.  The beans defined include channels that invoke services, as well as transformers that apply XSL transformations to the messages.  The XSLTs, in this solution, generate valid HTML.</p>
<p>Once the routing is completed, Spring Integration sends the final message back to the serviceGateway bean, which is configured to send the message to the http reply channel.  The proxy servlet then responds to the client with the message that sits on the http reply channel.</p>
<p>There are a couple of design considerations that came up as part of this solution, and should certainly be evaluated before heading down this path:</p>
<ol>
<li><strong>The solution requires content to be managed by XSLT and XML:</strong> This is not a solution for non-technical end users to manage content, like a true content management system would be.  This is a pattern for aggregating content in a SOA or cloud based environment, where your web designers are savvy in XML and XSLT and need to develop a UI for service-driven content.</li>
<li><strong>Form-driven content is not considered &#8216;first class&#8217;: </strong> HTML forms didn&#8217;t drive this design.  The architecture could certainly be modified to accomodate form driven interaction, but it was not a requirement for this solution.</li>
<li><strong>Invoking multiple external services for each request impacts performance: </strong> The solution has aspect-oriented caching built into it, so that invocation results can be cached on a per-service basis.  This is a subject for subsequent posts.</li>
<li><strong>Standard Java EE security is hard to apply to &#8216;virtual&#8217; page URLs: </strong> Spring Security helps when applying custom login pages, security contexts and the like.  Spring Security was leveraged as much as possible for this solution.</li>
</ol>
<p>In practice, this approach is better suited for delivering HTML snippets or JSON rather than full web pages.  But it is a good example of how to leverage integration techniques for more than just data message results; it gives you a way to generate user interface markup, AJAX responses, and other content markup directly from your ESB or integration platform.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/06/06/using-enterprise-integration-patterns-as-a-web-content-platform/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Extension Methods Make Life Easier</title>
		<link>http://blog.avantia-inc.com/2011/05/26/extension-methods-make-life-easier/</link>
		<comments>http://blog.avantia-inc.com/2011/05/26/extension-methods-make-life-easier/#comments</comments>
		<pubDate>Fri, 27 May 2011 00:15:37 +0000</pubDate>
		<dc:creator>Kevin Grigsby</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Extension Methods]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=73</guid>
		<description><![CDATA[Extension Methods are one of the more kewl features added to the .Net language in recent years (with .Net 3.0) that once realized, can be both fun and powerful. There are a few guidelines I will mention later when creating your extensions. But for now, right to the where, why and how to use extension <a href='http://blog.avantia-inc.com/2011/05/26/extension-methods-make-life-easier/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Extension Methods are one of the more kewl features added to the .Net language in recent years (with .Net 3.0) that once realized, can be both fun and powerful.  There are a few guidelines I will mention later when creating your extensions.  But for now, right to the where, why and how to use extension methods.</p>
<p><span id="more-73"></span></p>
<h3>Why?</h3>
<p>How many times have you created a utility method that perhaps formats a set of numbers, let’s say a phone number, into a formatted number with parenthesis, spaces and dashes?  Perhaps a zip code into a zip+four format?  Not a difficult task and probably only one line of code, something like the following:</p>
<pre class="brush: csharp; title: ; notranslate">
public string FormatPhone(long PhoneNumber) {
	return string.Format(&quot;{0:(000) 000-0000}&quot;, PhoneNumber);
}
</pre>
<p>Then when you want to access it, you have code similar to the following:</p>
<pre class="brush: csharp; title: ; notranslate">
long PhoneNumber = 3302164400;
string Result = Utilities.FormatPhone(PhoneNumber);
</pre>
<p>It does the trick and there is nothing wrong with it.  However, once you get into multiple developers working on the same project, you need to let each of them know of your great new method.  Not to mention, where do you put it?  Meaning, what namespace is it in?  Is it generic enough to simply create a new project that is just a bunch of helpful methods like this and we reference it?  If you reference it but do not add a using statement, we will still not be able to use it.  This latter issue is still true with extension methods, but I am getting ahead of myself.  Let’s make this same utility method into an extension method like so:</p>
<pre class="brush: csharp; title: ; notranslate">
public static string Formatted(this long Source) {
	return string.Format(&quot;{0:000-000-0000}&quot;, Source.Number);
}
</pre>
<p>Programmatically this is nearly the exact same code.  The only real difference is the method signature.  Note that it is a static method and the addition of the “this” keyword.  That last requirement to making extension methods would be that it needs to be part of a static class.  That all seems logical to me since we do not want to create an instance of the class, we just want to run our extension method.  So now that we have our new extension method, let’s see it in use:</p>
<pre class="brush: csharp; title: ; notranslate">
long PhoneNumber = 3302164400;
string Result = PhoneNumber.Formatted();
</pre>
<p>One of the best things about extension methods is that they now are considered top-level/first class methods that were originally on the object.  This means that the method will show up in intellisence when you hit the period as shown below.</p>
<p><img style="float: none; padding: 10px 0px 10px 10px;" src="http://www.ScreamingMonks.com/Blog/images/2011/ExtensionMethodsIntellisence.png" alt="Intellisense on Extension Methods" /></p>
<p>Please note that in the image above, it was extending a PhoneNumber object instead of just the long, but the logic was exactly the same.</p>
<p>Here is another extension method that can come in quite handy and is far easier to understand (and find) than some helper method.  The original code to translate a string into the current language via Sitecore is as follows:</p>
<pre class="brush: csharp; title: ; notranslate">
string Result = Sitecore.Globalization.Translate.Text(&quot;Some text to translate&quot;);
</pre>
<p>Not difficult to understand at all, however, quite a lot of typing each time you need to translate something.  So the following extension method can help.</p>
<pre class="brush: csharp; title: ; notranslate">
public static string Translate(this string Input) {
	return Sitecore.Globalization.Translate.Text(Input);
}
</pre>
<p>Now the code to run it would be similar to the following:</p>
<pre class="brush: csharp; title: ; notranslate">
string Result = &quot;Some text to translate&quot;.Translate();
</pre>
<h3>Overload</h3>
<p>You can even overload extension methods.  The following example overloads the Translate method to make it similar to the string.Format method:</p>
<pre class="brush: csharp; title: ; notranslate">
public static string Translate(this string Input, params object[] Parameters) {
	List NewValues = new List();

	foreach (object Parameter in Parameters) {
		if (Parameter is string)
			NewValues.Add(((string)Parameter).Translate());
		else
			NewValues.Add(Parameter.ToString().Translate());
	} // foreach of the parameters

	return string.Format(Input.Translate(), NewValues.ToArray()).ToString();
}
</pre>
<p>This would allow you to have code like the following:</p>
<pre class="brush: csharp; title: ; notranslate">&quot;Translate both {0} and {1}&quot;.Translate(&quot;this here&quot;, Constants.Season.SPRING);</pre>
<p>As you can see, you can pass any valid set of strings into the parameters of the Translate extension.</p>
<p>Along those same lines, one of my first extension methods I ever wrote and consistently use is one that extends the StringBuilder class.  A fair amount of times I am writing many lines of strings to my StringBuilder object.  However, I want to format the text and have each string be on its own line.  There is no existing method that both creates a new line (AppendLine) and takes formatting values (AppendFormat.)  Sure, I could put an “\n” at the beginning of each line but then I have to remember that for each line and I am not a fan of having formatting code when a method can do it for me consistently.  So I created the following extension method:</p>
<pre class="brush: csharp; title: ; notranslate">
public static StringBuilder AppendLineFormatted(this StringBuilder Input, string Format, params object[] Parameters) {
	return Input.AppendFormat(&quot;\n&quot; + Format, Parameters);
}
</pre>
<p>That then allows me to do the following in code:</p>
<pre class="brush: csharp; title: ; notranslate">
StringBuilder Results = new StringBuilder();

Results.AppendLineFormatted(&quot;&lt;h2&gt;{0}&lt;/h2&gt;&quot;, ms.Season);
Results.AppendLineFormatted(&quot;&lt;dl&gt;&quot;);

Results.AppendLineFormatted(&quot;&lt;dt&gt;{0}&lt;/dt&gt;&quot;, s.Day.Value);
Results.AppendLineFormatted(&quot;&lt;dd&gt;{0:h:mm tt}&lt;/dd&gt;&quot;, s.Time);
Results.AppendLineFormatted(&quot;&lt;dd&gt;{0}&lt;/dd&gt;&quot;, s.Notes);
Results.AppendLineFormatted(&quot;&lt;/dl&gt;&quot;);

return Results.ToString();
</pre>
<p>As you can see this is building HTML code.  There are two foreach loops in the actual code that have been removed for clarity, but the above should give you an idea of what I was shooting for.</p>
<h3>Say My Name</h3>
<p>This brings me to another point I want to get across.  I was extending the StringBuilder class that currently has Append, AppendLine and AppendFormat methods.  At one point I thought about overloading the AppendLine method that takes the same formatting parameters.  I tested it and it worked just as it should.  However, it was doing a disservice to the extension method itself.  It was not obvious that the extension method existed so it could be missed and can also make it confusing.  I have read a few articles that suggest to not overload an existing method with an extension method.  It makes sense and I have stuck too that.  I am glad I came up with that solution on my own as well.</p>
<h3>Is That It?</h3>
<p>Now let’s get more complex.  Currently each of the extension methods here has only been a few lines of code.  There is nothing wrong with that and chances are, most of yours will be simple as well.  These methods are just ways to help us save some duplicate code and typing as well as a more logical grouping and thus understanding of what is available to make our coding lives easier.</p>
<p>Here is an extension method that takes an Enumerable set of some generic objects that either are or inherit from a specific class.  In particular, specific to a Sitecore CMS project I was working on.  We had data in a separate database that the customer did not want to manage via Sitecore.  We needed a way to link the mass amount of data they had with the minimal amount we needed on the Sitecore side.  Using LINQ (which can have a blog post of its own, so stay tuned!) and the Entity Framework we would get back the exact set of objects we were looking for.  However, we needed to now get the Sitecore data (its Link and GUID) and didn’t want to have to write similar code for each of our objects to basically do the same thing of connecting to Sitecore, find the object, match it up and grab what we need to grab.  The following code shows this final method showing only two different classes, however, there were multiple we were handling.</p>
<pre class="brush: csharp; title: ; notranslate">
public static void SitecoreFill(this IEnumerable Items) where T : SitecoreLink {
	Items.ToList().ForEach(item =&gt; {
		string ADDID = &quot;&quot;;
		string ContainerID = &quot;&quot;;
		string FieldName = &quot;&quot;;

		switch (item.GetType().Name) {
			case &quot;Parish&quot;:
				ContainerID = Constants.Sitecore.Containers.PARISH;
				FieldName = Constants.Sitecore.ADDIDFields.PARISH;
				ADDID = (item as Parish).ID.ToString();
				break;

			case &quot;School&quot;:
				ContainerID = Constants.Sitecore.Containers.SCHOOL;
				FieldName = Constants.Sitecore.ADDIDFields.SCHOOL;
				ADDID = (item as School).ID.ToString();
				break;
		} // switch on the Type of object

		Item scItem = Sitecore.Context.Database.Items.GetItem(ContainerID);

		if (scItem.HasChildren) {
			Item Found = scItem.Children.Where(c =&gt; c.Fields[FieldName].Value == ADDID).FirstOrDefault();

			if (Found != null) {
				item.GUID = Found.ID.Guid;
				item.Link = Sitecore.Links.LinkManager.GetItemUrl(Found);
			} // if we found the one we are looking for
		} // if there is at least one child item
	}); // foreach of the items in the given list
}
</pre>
<p>The SitecoreLink class has two simple properties on it, the GUID and the Link properties.  Now they get filled in within this extension method.</p>
<p>That then allows me to use LINQ to get the set of items I needed and then run this extension method similar to the following:</p>
<pre class="brush: csharp; title: ; notranslate">
var Items = (from p in AdministrationQueries.GetParishes()
	where p.Name.ToLower().Contains(Criteria) ||
	p.Addresses.Any(a =&gt; a.ZipCode.Zip == Criteria ||
	a.City.ToLower().Contains(Criteria))
	select p).ToList();

Items.SitecoreFill();
</pre>
<p>Now Items has the GUID and Link properties set and it only took one line of code.</p>
<p>One final extension method I will pass along here is one that makes the following code a bit more readable:</p>
<pre class="brush: csharp; title: ; notranslate">
string day = &quot;Friday&quot;;
DayOfWeek dayOfWeek = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), day);
</pre>
<p>That is somewhat duplicating things in my mind.  Here is the extension method:</p>
<pre class="brush: csharp; title: ; notranslate">
public static T ToEnum(this string value) {
	return (T)Enum.Parse(typeof(T), value);
}
</pre>
<p>Finally, here is what that would give us the ability to do:</p>
<pre class="brush: csharp; title: ; notranslate">
string day = &quot;Friday&quot;;
DayOfWeek dayOfWeek = day.ToEnum();
</pre>
<p>Or even like this:</p>
<pre class="brush: csharp; title: ; notranslate">
DayOfWeek dayOfWeek = &quot;Friday&quot;.ToEnum();
</pre>
<p>As you can see, that makes it quite a bit more obvious what we were actually doing (taking a word and converting that to a given enumeration.)  This extension method flirts with a suggested rule that your extension methods shouldn’t be so generic that everything extends the string class and now there are too many to scroll through or even remember or group logically.</p>
<h3>Trickery</h3>
<p>One trick I have used thanks to extension methods is that sure, I have a class that holds values and does stuff.  Chances are, you are going to want some sort of collection of that class.  This of course could be a List or any of the other collection classes.  If I wanted to write a method that dealt with a List I would have to write a new class that inherited from IList and that seems like a bit of a pain.  However, with having just the single item of MyClass and then writing an extension similar to the following, I get all of the goodness of the List collection and I can extend it:</p>
<pre class="brush: csharp; title: ; notranslate">
public static string DoSomething(this List Items) {
	…
}
</pre>
<h3>Keep In Mind</h3>
<p>It is important to note that just because you can write an extension method doesn’t mean you should.  An example of this where extension methods may be getting abused would be one off of the string class called IsValidEmail.  Sure it works, sure it is useful.  However, not all strings are going to be email addresses.  That should be more of a utility or helper method in some static class where you pass in the email string.  In the example above with the enumeration, I say it flirts with this rule, true.  However, all enumerations could be strings or at least we have all used the Enum.Parse method to convert a string to some enumeration.  It always seemed like double code to tell it I am using this enumeration and then have to cast it to that enumeration.  Extension Methods and how far down the rabbit hole they go may become one of those religious debates like C# vs VB or Tabs vs Spaces or Coke vs Pepsi.  Time will tell.</p>
<p>In conclusion, I think extension methods are incredibly powerful and this may be the code geek inside me, but I think they are really quite fun.  One last thing I will mention is that if you create your own objects, you can put normal methods and/or properties on them to your heart’s content.  However, there may be some issues with properties and methods when you have data contracts going over the wire.  Perhaps you are connecting with a third party and you do not want them to see all of your coding goodness, you only want them to see the properties.  Thus putting your extension methods into a separate namespace and class breaks them out logically and allows your data contracts to flow without bounds nor worry.  Also, we do not have the source code for .Net nor most third party .dll’s you may reference.  However, we can still extend them as if we did have the source code, thanks to the wonderful world of extension methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/05/26/extension-methods-make-life-easier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event-driven Architecture with Distributed Data Management Systems</title>
		<link>http://blog.avantia-inc.com/2011/05/11/event-driven-architecture-with-distributed-data-management-systems/</link>
		<comments>http://blog.avantia-inc.com/2011/05/11/event-driven-architecture-with-distributed-data-management-systems/#comments</comments>
		<pubDate>Thu, 12 May 2011 03:22:59 +0000</pubDate>
		<dc:creator>Brian Jimerson</dc:creator>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[eda]]></category>
		<category><![CDATA[vfabric]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=36</guid>
		<description><![CDATA[Event-driven architecture (EDA) is an architectural pattern for building systems that respond to events (significant changes in state) in the system, rather than responding to external requests or messages.  In other words, systems utilizing EDA provide proactive notifications to users or clients based on internal changes.  Take Twitter&#8216;s site for example; if you&#8217;re on Twitter&#8216;s <a href='http://blog.avantia-inc.com/2011/05/11/event-driven-architecture-with-distributed-data-management-systems/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Event-driven architecture (EDA) is an architectural pattern for building systems that respond to events (significant changes in state) in the system, rather than responding to external requests or messages.  In other words, systems utilizing EDA provide proactive notifications to users or clients based on internal changes.  Take <a href="http://twitter.com">Twitter</a>&#8216;s site for example; if you&#8217;re on <a href="http://twitter.com">Twitter</a>&#8216;s site, and someone you are following tweets, your page is refreshed with the tweet without you having to request an update of the page.  Your list of tweets is refreshed because an event (new tweet) triggers it.</p>
<p>EDA is an appropriate pattern in many types of web applications; it provides a rich user experience by telling the user what is happening, instead of the user having to request updated information.  This can be applied across many use cases:</p>
<ul>
<li>Portal dashboards &#8211; instead of refreshing a page to get updated dashboard information, the dashboard refreshes itself (real-time reporting).</li>
<li>Social / discussion / blog &#8211; as community members contribute, followers are automatically up to date</li>
<li>Business applications &#8211; business events are constantly sent to users, instead of them having to request updates.  Think of someone like a travel agent or a retailer&#8217;s customer service agent who relies on real-time data; instead of them requesting updates, the updates are sent to them as they happen.</li>
</ul>
<p>This list goes on, but the underlying theme to modern EDA-driven applications is that they usually rely on near real-time data, are highly transactional, and are web based.  Traditional web based applications are stateless, which means they can&#8217;t respond to events on a server.  This is a departure from user experiences with thick client and client-server applications.  Technically, thick client and client-server applications are based on EDA (the user interface is built upon event handlers, not request/response models), and web based applications depart from EDA.  But the current trend is to apply EDA to web, SOA, and cloud applications, which is the point of discussion.</p>
<p>There are a number of ways to design EDA applications for the web, SOA, and cloud, but there&#8217;s a very compelling approach that a <a href="http://www.springsource.com/products/cloud-application-platform">VMware vFabric</a> engineer brought to my attention today using distributed data management systems designed for cloud-based applications.  Traditionally, EDA systems rely on messaging systems to raise events; there are a number of reasons for this, but one of the most significant is performance.  Remember, events are significant changes in state, which is really a change in the data for a system.</p>
<p>So, if a system were to react to an event, it has to be able to detect changes in its state (the application&#8217;s data).  In traditional applications, detecting changes in state (data) means constantly querying a relational database.  For high transaction systems, this means querying databases every few seconds at a minimum to detect changes, and since state is usually tied to a user, these database queries are per user.  Querying databases at this frequency just to detect changes in state (events) would crush most traditional applications, no matter how well they&#8217;re engineered.  This is why most web based EDA applications employ techniques like callbacks, asynchronous event messages, and AJAX polling from web pages.</p>
<p>Now, consider an application that uses a distributed data management system like <a href="http://www.springsource.com/products/data-management">vFabric GemFire</a>.  <a href="http://www.springsource.com/products/data-management">GemFire</a> is a lot of things, but for the sake of this discussion, it is an in-memory data layer that provides persistence, performance, and high availability.  In other words, you can query it at will without concern for performance, just like you would with in-memory objects, but still be confident that the data is persistent, as you would be with a relational database.</p>
<p>With <a href="http://www.springsource.com/products/data-management">GemFire</a>, providing event notifications can be as simple as starting a thread that polls for updated data (you don&#8217;t need to worry much about the performance of constant queries); the thread, which can be resident to the application, can invoke whatever event handler is registered.  This is very similar to event handlers in thick client applications.</p>
<p>Taking this approach gives applications the ability to implement event polling, instead of reacting to event notifications.  If applications aggregate or integrate external systems, this is a good thing.  Instead of having to decide whether or not to respond to events, and how to respond to them, they can control which events to respond to, and what to do.</p>
<p>This may seem like a minute twist, but let&#8217;s extend our <a href="http://twitter.com">Twitter</a> example to a fictitious Zapper application that provides similar functionality.  Let&#8217;s say that there are 10,000 users online.  If the Zapper backend responded to events (zaps) sent, and 1000 zaps were sent per minute, then Zapper&#8217;s servers would have to figure out which of the 10,000 users should receive updates for each zap.  That&#8217;s 10,000 evaluations per zap, or 10,000,000 evaluations per minute, that Zapper&#8217;s servers would have to process.</p>
<p>If Zapper was designed so that each user session polled for events (using something like <a href="http://www.springsource.com/products/data-management">GemFire</a> in their infrastructure), then the Zapper servers have a much different profile.  Each Zapper session would poll for updated zaps frequently, let&#8217;s say every 30 seconds.  Every Zapper session would poll for updates 2 times in a minute; that&#8217;s 20,000 polls per minute (2 polls per minute x 10,000 users) compared to 10,000,000 evaluations per minute for the previous scenario.  And the polls are ultimately against an in-memory data layer, instead of sending a message to the clients that they need to re-query the relational database.</p>
<p>This scenario is based on a system that is highly transactional; the data is updated much more than it is read.  But systems that are built upon EDA imply that there are frequent and significant changes to the application&#8217;s data.   It is but one example of ways to design systems that rely on cloud architectures, high performance and scalability, and frequently changing data.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/05/11/event-driven-architecture-with-distributed-data-management-systems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to Avantia&#8217;s New Blog</title>
		<link>http://blog.avantia-inc.com/2011/05/03/welcome-to-avantias-new-blog/</link>
		<comments>http://blog.avantia-inc.com/2011/05/03/welcome-to-avantias-new-blog/#comments</comments>
		<pubDate>Wed, 04 May 2011 02:45:27 +0000</pubDate>
		<dc:creator>Brian Jimerson</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://blog.avantia-inc.com/?p=16</guid>
		<description><![CDATA[Welcome to Avantia&#8217;s new blog.  We are excited about having another avenue for discussing things that are fun and exciting to us. We will be discussing a lot of the technologies, processes, and techniques that we use every day in developing software, as well as subjects and industry trends that we are interested and involved <a href='http://blog.avantia-inc.com/2011/05/03/welcome-to-avantias-new-blog/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Welcome to Avantia&#8217;s new blog.  We are excited about having another avenue for discussing things that are fun and exciting to us.</p>
<p>We will be discussing a lot of the technologies, processes, and techniques that we use every day in developing software, as well as subjects and industry trends that we are interested and involved in.  Our team is involved in a staggering amount of technology, industries, and other software development goodness, and our new blog provides a place to bring this wealth of information together.</p>
<p>So be sure to check back often; we have a number of subjects planned for posts in the coming weeks and months.  Some of things that we&#8217;ve been working on and will be writing about include:</p>
<ul>
<li>Enterprise cloud computing</li>
<li>Enterprise and application security labs</li>
<li>New ways of building applications, like NoSQL and JavaScript servers</li>
<li>Agile business process strategies</li>
<li>How to build successful teams</li>
<li>And much more&#8230;</li>
</ul>
<p>Welcome, and please let us know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.avantia-inc.com/2011/05/03/welcome-to-avantias-new-blog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

