<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Ruslan's blog</title>
	<atom:link href="http://xruslan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://xruslan.wordpress.com</link>
	<description></description>
	<lastBuildDate>Thu, 12 Mar 2009 15:46:18 +0000</lastBuildDate>
	<language>uk</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='xruslan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Ruslan's blog</title>
		<link>http://xruslan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://xruslan.wordpress.com/osd.xml" title="Ruslan&#039;s blog" />
	<atom:link rel='hub' href='http://xruslan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Presentations and articles about scalable software architecture</title>
		<link>http://xruslan.wordpress.com/2009/03/04/presentations-and-articles-about-scalable-software-architecture/</link>
		<comments>http://xruslan.wordpress.com/2009/03/04/presentations-and-articles-about-scalable-software-architecture/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 19:37:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Scalable]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2009/03/04/presentations-and-articles-about-scalable-software-architecture/</guid>
		<description><![CDATA[Last week was searching for interesting articles and presentations with samples of scalable and failure tolerant architecture. As result, my bookmarks increased with a number of new links to articles and videos. Articles: Scalability Principles SEDA Large codebase organization with Spring Building Scalability and Achieving Performance: A Virtual Panel Scalability Worst Practices Shard Lessons Asynchronous [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=45&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Last week was searching for interesting articles and presentations with samples of scalable and failure tolerant architecture. As result, my bookmarks increased with a number of new links to articles and videos.</p>
<p>Articles:</p>
<ol>
<li><a href="http://www.infoq.com/articles/scalability-principles">Scalability Principles</a></li>
<li><a href="http://www.eecs.harvard.edu/~mdw/papers/seda-sosp01.pdf">SEDA</a></li>
<li><a href="http://mikenereson.blogspot.com/2007/06/spring-on-code-organization-for-large.html">Large codebase organization with Spring</a></li>
<li><a href="http://www.infoq.com/articles/scalability-panel">Building Scalability and Achieving Performance: A Virtual Panel</a></li>
<li><a href="http://www.infoq.com/articles/scalability-worst-practices">Scalability Worst Practices</a></li>
<li><a href="http://www.addsimplicity.com/adding_simplicity_an_engi/2008/08/shard-lessons.html">Shard Lessons</a></li>
<li><a href="http://www.webperformancematters.com/journal/2007/8/21/asynchronous-architectures-4.html">Asynchronous Architectures [4]</a></li>
<li><a href="http://esammer.blogspot.com/2009/02/principles-of-architecture-reduce-and.html">Thoughts on Development</a></li>
<li><a href="http://davidvancouvering.blogspot.com/2009/02/hitting-scalability-wall-amdahls-law.html">Hitting the scalability wall &#8211; Amdahl&#8217;s Law</a></li>
<li><a href="http://www.caffeinatedcoder.com/10-lessons-in-scalability-from-myspace/">10 Lessons in Scalability from MySpace</a></li>
<li><a href="http://natishalom.typepad.com/nati_shaloms_blog/2008/05/twitter-as-an-e.html">Twitter as a scalability case study</a></li>
</ol>
<p>Videos &amp; presentations:</p>
<ol>
<li><a href="http://www.infoq.com/presentations/shoup-ebay-architectural-principles">Randy Shoup on eBay&#8217;s Architectural Principles</a></li>
<li><a href="http://www.infoq.com/presentations/architecture-evaluation">Architecture Evaluation in Practice</a></li>
<li><a href="http://www.infoq.com/presentations/availability-consistency">Availability &amp; Consistency</a></li>
<li><a href="http://www.infoq.com/presentations/Architecting-Latency-Dan-Pritchett">Architecting for Latency</a></li>
<li><a href="http://www.infoq.com/presentations/design-and-architecture-of-infoq">The Design and Architecture of InfoQ</a></li>
<li><a href="http://www.infoq.com/presentations/operational-manageability">Architecture Quality: Operational Manageability</a></li>
<li><a href="http://www.slideshare.net/Georgio_1999/how-to-scale-your-web-app">How to scale your web app</a></li>
<li><a href="http://www.infoq.com/presentations/MySpace-Dan-Farino">Behind the Scenes at MySpace.com</a></li>
<li><a href="http://www.slideshare.net/Blaine/scaling-twitter">Scaling Twitter</a></li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=45&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2009/03/04/presentations-and-articles-about-scalable-software-architecture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>Cловники в предметній області</title>
		<link>http://xruslan.wordpress.com/2009/03/04/c%d0%bb%d0%be%d0%b2%d0%bd%d0%b8%d0%ba%d0%b8-%d0%b2-%d0%bf%d1%80%d0%b5%d0%b4%d0%bc%d0%b5%d1%82%d0%bd%d1%96%d0%b9-%d0%be%d0%b1%d0%bb%d0%b0%d1%81%d1%82%d1%96/</link>
		<comments>http://xruslan.wordpress.com/2009/03/04/c%d0%bb%d0%be%d0%b2%d0%bd%d0%b8%d0%ba%d0%b8-%d0%b2-%d0%bf%d1%80%d0%b5%d0%b4%d0%bc%d0%b5%d1%82%d0%bd%d1%96%d0%b9-%d0%be%d0%b1%d0%bb%d0%b0%d1%81%d1%82%d1%96/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 19:04:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Architecture]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2009/03/04/c%d0%bb%d0%be%d0%b2%d0%bd%d0%b8%d0%ba%d0%b8-%d0%b2-%d0%bf%d1%80%d0%b5%d0%b4%d0%bc%d0%b5%d1%82%d0%bd%d1%96%d0%b9-%d0%be%d0%b1%d0%bb%d0%b0%d1%81%d1%82%d1%96/</guid>
		<description><![CDATA[Словники предметної області займають вельми важливе місце при проектуванні та розробці програмного забезпечення. Не менш частіше використовуються словники в предметній області. В даному випадку, словниками можуть виступати невеликі набори даних в стилі ключ-значення, або більш складні, де кожному ключу відповідає набір значень. Прикладів таких словників є безліч, наприклад, словник країн, словник типів кредитних карточок, словник [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=44&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Словники предметної області займають вельми важливе місце при проектуванні та розробці  програмного забезпечення. Не менш частіше використовуються словники в предметній області. В даному випадку, словниками можуть виступати невеликі набори даних в стилі ключ-значення, або більш складні, де кожному ключу відповідає набір значень. Прикладів таких словників є безліч, наприклад, словник країн, словник типів кредитних карточок, словник пріоритетів задач, і більш складніші словники матеріалів та продукції (за окремими вийнятками) тощо.</p>
<p>Ця стаття розповідає про моє бачення такого &#8220;патерна&#8221; як <i>Словник</i>. Важливо визначитися, що саме слід вважати словником в предметній області. </p>
<p>Словник – це набір термінів пов’язаних між собою певною областю використання, які проте рідко змінюються. Частіше всього, словники використовуються, для того, щоб надати користувачам вибір значень з певної множити, наприклад, країну проживання, стать, посаду тощо. </p>
<p>Словники складаються з записів, які собою являють пару ключ-значення. В залежності від значення словники бувають простими та складними. Простий словник, це коли певному ключу відповідає одне значення, а складний словник – ключу відповідає набір значення. Наприклад, якщо коду країни відповідає тільки назва цієї країни, то цей словник є простим, де ключем виступає код країни. Прикладом складного словника є словник матеріалів, де коду товару відповідає його назва, вартість, країна виробник, маса тощо.</p>
<p>Складні словники можуть бути складеними. Складеним словником називається такий, в якого одне із значень є елементом іншого словниками. Наприклад, дано складний словник країн, в якому певному коду відповідають назва та код типу країни (республіка, федерація, королівство тощо). Код типу країни вказує на словник типів країн, таким чином словник країни можна вважати складеним та залежним від словника типів країн.</p>
<p> <img><br /> Рис 1 – Різні типи словників.</p>
<p>Словники часто використовують при розробці програмного забезпечення, адже дають можливість групувати набори даних в окремі групи, використовувати їх в групах та асоціювати певне значення з групою. В предметної області певний набір даних може бути словником, якщо він не виступає центральним в даній предметній області. Словники повинні залишатися максимально спрощеним та піддававтися мінімальним змінам в процесі використання, в той час як центральні сутності предметної можуть бути дуже складними та змінювати часто.</p>
<p>Чим складніший словник, тим більше програмний продукт залежить від нього. Словники можуть з часом переростати на повноцінні набори даних. При цьому збільшується або їх складності або кількість даних.</p>
<p>Зі словників часто починається проектування та кодування програм, вони є об’єктом перевикористання. Якщо використовувати необхідні словники спроектовані та закодовані на попередніх проектах, то можна скоротити час на написання нових проектів. Розроблений словник може виступати незалежним компонентом, але подібні компоненти буває тяжко спроектувати, адже вони вимагають гнучкості в роботі, а також тісної залежності від них іншого коду.</p>
<p>Існує кілька способів зберігання даних словників: набори констант, енумерації, файли, база даних тощо. Використання констант та енумерації для зберігання елементів словника пожуть значно покращити процес кодувати та збільшити читабельність коду, але при цьому частіше всього ми втрачаємо можливість швидкої зміни «захардкодженого» набору даних. Звичайно, словник статей, може бути спокійно закодований у вигляді енумерації, але словник країн ні. Те, що словники змінюються рідко не значить, що вони ніколи не міняються. В окремих випадках є необхідність добавити нові елементи або виконати корестування існуючих, і в залежності від типу програми, найкращими будуть тут зберігання словників у файлах та базах даних. </p>
<p>Ще однією хорошою практикою є змістовні ключі словників. Простіше працювати та підтримувати в роботі словники, що містять ключі, які легко зрозуміти та отримати інформацію про сам елемент словника. Цього тяжко досягнути якщо використовувати числові ідентифікатори. Наприклад, для словника типів кредитних карточок ключі VISA, MSTR, AMEX тощо зручніше використовувати, ніж, наприклад, 1, 2, 3. У випадку використання бази даних для зберігання словників також простіше писати запити.<br />Оскільки словники містять невеликі набори даних і в основному рідко змінюються, то вони частіше легко піддаються кешуванню. Але тут слід не забувати, що словники теж можуть міняти, тому програма повинна підтримувати або можливість обновити дані в кеші або виконати інвалідацію кеша або ж увімкнути підтримку дати закінчення терміни дії кешу, після якого нові дані будуть знов закешовані.</p>
<p>Для зберігання та використання словників можна також використовувати і інші способи. Наприклад, якщо використовується MySQL, то для роботи із таблицями з словниками можна використвувати MyISAM engine, адже він найкраще підходить для даних, що рідко змінуюються, але частіше зчитуються. Таблиці із словниками частіше піддаються повному кешуванню СУБД, а використання сладених індексів на всі колонки БД може взагалі позбавити необхідность у фізичному вводі-виводі. Збереження словників у базі даних та використання зовнішніх ключів покращує цілісність даних, і знову ж таки, не сильно впливає на ресурси для виконання запитів.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=44&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2009/03/04/c%d0%bb%d0%be%d0%b2%d0%bd%d0%b8%d0%ba%d0%b8-%d0%b2-%d0%bf%d1%80%d0%b5%d0%b4%d0%bc%d0%b5%d1%82%d0%bd%d1%96%d0%b9-%d0%be%d0%b1%d0%bb%d0%b0%d1%81%d1%82%d1%96/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>Spring MVC and RESTful web service.</title>
		<link>http://xruslan.wordpress.com/2009/02/11/spring-mvc-and-restful-web-service/</link>
		<comments>http://xruslan.wordpress.com/2009/02/11/spring-mvc-and-restful-web-service/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 23:08:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2009/02/11/spring-mvc-and-restful-web-service/</guid>
		<description><![CDATA[This article is a result of my experience on building small RESTful web service using SpringMVC 2.5. Web service is simple, it supports only few operations, most of them just retrieves data and sends back it in XML. Well, the task is simple enough: build secured web service for mostly getting and sometimes posting data; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=43&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This article is a result of my experience on building small RESTful web service using <a href="http://springframework.org">SpringMVC 2.5</a>. Web service is simple, it supports only few operations, most of them just retrieves data and sends back it in XML.</p>
<p>Well, the task is simple enough:</p>
<ol>
<li>build secured web service for mostly getting and sometimes posting data;</li>
<li><a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> interface is required
<ul>
<li> but SOAP could be added later (I think that if you build SOAP web service you should wait that you&#8217;ll need to provide REST API  for this web service too and vise versa).</li>
</ul>
</li>
</ol>
<p>As web service is build with REST philosophy, than we need to support processing of GET, POST (well, for me it&#8217;s enough) requests and return data as XML or JSON. Spring MVC as well others REST web service frameworks and API help with this too. So, what&#8217;s next?</p>
<p>As application is build with Spring 2.5, it was the best to have some framework for building REST web service easily and easily to integrate it with Spring. Not a secret, that Spring MVC integrates with Spring better that any other web framework or REST web service framework (hm, maybe it&#8217;s because it is build on Spring). Well, this is cons for using Spring MVC and it is good, but truly &#8211; this not enough yet.</p>
<p>Yet one requirement: SOAP web service could be added later. And if it could be added than (in most cases) it will be added. This is important, very important, because we want to build easy-to-extend software. And in case of SOAP WS I prefer to use Spring WS, that is well integrated with Spring MVC. Need also to take into consideration that some REST web service frameworks hardly integrates with Spring MVC or wanted to process all requests. That is a great pros for using Spring MVC.</p>
<p>You may understand what I&#8217;m implying. Yes, Spring MVC will be used to build RESTful web service.</p>
<h4>Architecture</h4>
<p>The main goals of architecture are:</p>
<ul>
<li> be scalable (not to much, but enough to process thousands of requests per hour)</li>
<li> be extendable (SOAP must be easy to add)</li>
<li> do what is required and nothing more</li>
</ul>
<p>Next decisions were made:</p>
<ul>
<li> request should be stateless</li>
<li> each request should be processed as quick as possible</li>
<li> there will be 2 levels of caching: one cache for entities and queries (used by web service backend service), and another cache for rendered XML response (used by web service endpoint).</li>
<li> everything that could be changed is configured through simple XML configuration (i.e. cache configuration, security configuration, business logic configuration etc.)</li>
</ul>
<p>The main result of made decisions &amp; rules is request processing lifecycle, that consists of next few phases:</p>
<ol>
<li> Authentification &amp; Authorization (security filter)</li>
<li> Getting request parameters. Web service endpoint (in our case it is SpringMVC controller) parses request parameters and validates them.</li>
<li> If everything is okay than it tries to get XML response from cache and sends it as response to the client. This step is optional and is processed only if cache is enabled and client does not specify request as such that ignores cache.</li>
<li> Endpoint determines the appropriate WebService backend service and run it and get results.</li>
<li> Endpoint converts results into XML, prepare response and stores it at cache (if cache is enabled). After the XML response is send back to client.</li>
</ol>
<p><img alt="" /></p>
<p>So, if the request response is cached in 2nd or 1st cache levels, than response will be generated without hitting database. In my development environment caching helps to increase performance up to 1500%. In production this number is less &#8211; just 300-500%. Still these is very well.</p>
<p>This lifecycle helps to build a scheme of responsibilities and modules. Later each responsibility could be processed by own server or a set of servers.</p>
<p><img alt="" /></p>
<h4>Simple implemenation</h4>
<p>Spring 2.5 gave us possibility to use annotations as for declaring services as for declaring SpringMVC controllers. Spring&#8217;s annotations <code>Controller, RequestMapping, RequestParam</code> and flexible politic on request handle method parameters gives us brilliant instrument for building web service endpoint.<br />
Ofcourse, hardcoding of URLs in annotations looks as not the best way for building flexible and configurable application. But, this is quite pardonable, because we will use <a href="http://tuckey.org/urlrewrite/">UrlRewriteFilter</a>. UrlRewriteFilter is very useful tool, as it will helps to rewrite URLs, get parameters from URL and do other interesting things. But for our the most important are next 2 features:</p>
<ol>
<li>flexibility while mapping external URLs (used by users) to internal URLS (processed by endpoint controllers)</li>
<li>possibility to catch parameters from URL, e.g. http://example.com/book/edit/12 -&gt;<br />
http://exampl.com/book/edit?boodId=12 etc.</li>
</ol>
<p>Lets look how we could use this features:<br />
Let we have RESTful web service that returns XML with information with specified by id book. Web service clients could get this information by requesting url<br />
http://ourservice.com/ws/rest/book/{bookId} (e.g. http://ourservice.com/ws/rest/book/12). Our application should handle this call and the information about book wit specified id.</p>
<p>Here is our web service controller:</p>
<pre class="java">@Controllerpublic class WebServiceEndpoint {

     @Autowired     private BookService bookService;

     @RequestMapping(value = "webservice/book", methods = RequestMethod.GET)
     public ModelAndView getBook(@RequestParam(name="bookID", required=true)int bookId, Map&lt;String, Object&gt; model) {
           model.put("book", bookService.getBookById(bookId));         return new ModelAndView("template/ws/bookInfo", model);
     }
}</pre>
<p>Code is very simple, but it&#8217;s good as for sample.</p>
<p>So, we have controller that processes all GET requests for <code>'webservice/book'</code> resource, that should have request parameter of type integer with name &#8216;bookID&#8217;. Endpoint just call backend service, gets information about book, put it to model map and return the <code>ModelAndView</code> instance with simple template that will be rendered and returned to client.</p>
<p>This endpoint controller can&#8217;t be default process web service request. To redirect web service client request to our endpoint we will use UrlRewriteFilter</p>
<pre class="xml">     &lt;rule&gt;
       &lt;from&gt;^/ws/rest/book/[0-9]+$&lt;/from&gt;
       &lt;to&gt;/webservice/book?bookID=$1&lt;/to&gt;
     &lt;/rule&gt;</pre>
<p>so request for resource <code>http://ourservice.com/ws/rest/book/12</code> will be rewrited by filter to <code>http://ourservice.com/webservice/book?bookID=12</code>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=43&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2009/02/11/spring-mvc-and-restful-web-service/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple LRU cache implementation.</title>
		<link>http://xruslan.wordpress.com/2009/01/17/simple-lru-cache-implementation/</link>
		<comments>http://xruslan.wordpress.com/2009/01/17/simple-lru-cache-implementation/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 21:17:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2009/01/17/simple-lru-cache-implementation/</guid>
		<description><![CDATA[By this url can be found post about using LinkedHashMap as LRU cache. Also, I&#8217;ve found such code with a direct link as comment in Apache Roller source code.LinkedHashMap can be used as LRU cache because it supports ordering it&#8217;s elements not only by insert order, but also by access-order. Also there is protected method [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=42&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>By this <a href="http://www.davidflanagan.com/blog/000014.html">url</a> can be found post about using <code>LinkedHashMap</code> as LRU cache. Also, I&#8217;ve found such code with a direct link as comment in <a href="http://roller.apache.com">Apache Roller</a> source code.<br /><code>LinkedHashMap</code> can be used as LRU cache because it supports ordering it&#8217;s elements not only by insert order, but also by access-order. Also there is protected method <code>removeEldestEntry</code> in the <code>LinkedHashMap</code> that runs in the <code>put()</code> and <code>putAll()</code> methods. If that method returns true, than least recently inserted/accessed element will be removed.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=42&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2009/01/17/simple-lru-cache-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>You and your&#8217;s sofware expansibility.</title>
		<link>http://xruslan.wordpress.com/2009/01/14/you-and-yours-sofware-expansibility/</link>
		<comments>http://xruslan.wordpress.com/2009/01/14/you-and-yours-sofware-expansibility/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 08:49:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2009/01/14/you-and-yours-sofware-expansibility/</guid>
		<description><![CDATA[For a long time one of the scores of software I&#8217;m writing is expansibility. That&#8217;s mean how fast, with minimum of changes, I can add new features or extend existed one. I&#8217;ve made few notes and use them as often as possible. Here are they: &#8211; Never or almost never requirements you are working on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=41&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For a long time one of the scores of software I&#8217;m writing is <i>expansibility</i>. That&#8217;s mean how fast, with minimum of changes, I can add new features or extend existed one. <br />I&#8217;ve made few notes and use them as often as possible. Here are they:<br /> &#8211; <i>Never</i> or almost never <i>requirements</i> you are working on <i>are complete</i>. Even if customer told you that this is finish step and we stop work on it &#8211; that mean only &#8211; we stop the work for now and we may continue it after some time. And of course, that time may vary from few weeks to few month, so you may and you will forget the code. That&#8217;s why always <u>write comments to the code even if it is not yours!</u><br /> &#8211; <u>If you can extend the code you&#8217;ve write before &#8211; do it!</u> If you need to get the list of some entities &#8211; use search engine if it exists. If search engine is not enough &#8211; extend it and use it. <u>Be DRY principal follower!</u><br /> &#8211; Write your code with one think: <u>I will use it tomorrow too!</u> That&#8217;s mean that you should <i>write quality code, well commented code and code that make everything you have now and a little bit more.</i> Sure, this <i>&#8220;a little bit more&#8221;</i> should be result of your experience. If you don&#8217;t have enough experience &#8211; use this too! Why? You&#8217;ll get need experience much faster!<br /> &#8211; <u>Do code review! Often.</u> Why? Because it increases the quality of your code and as result of software. And also you&#8217;ll find your and yours colleagues weak and that is 50% of new experience. I like <a href="http://atlassian.com">Atlassian</a> experience with code reviewing for many tasks they do.</p>
<p>Simple, but important.<br />var dzone_url = &#8216;http://java-ua.blogspot.com/2009/01/for-long-time-one-of-scores-of-software.html&#8217;;<br />var dzone_title = &#8216;You and your&#8217;s sofware expansibility.&#8217;;<br />var dzone_style = &#8217;1&#8242;;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=41&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2009/01/14/you-and-yours-sofware-expansibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>Spring MVC + FreeMarker + Tiles 2</title>
		<link>http://xruslan.wordpress.com/2009/01/08/spring-mvc-freemarker-tiles-2-2/</link>
		<comments>http://xruslan.wordpress.com/2009/01/08/spring-mvc-freemarker-tiles-2-2/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 21:41:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Freemarker]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Tiles 2]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2009/01/08/spring-mvc-freemarker-tiles-2-2/</guid>
		<description><![CDATA[This is extended and translated into English version of my post Spring MVC + FreeMarker + Tiles 2. I&#8217;ve found that many are interested about the joint work of those frameworks. Well, this article shows how to configure the Spring MVC application with Tiles 2 and FreeMarker. You may don&#8217;t use the SpringMVC framework, and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=40&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is extended and translated into English version of my post <a href="http://java-ua.blogspot.com/2008/10/spring-mvc-freemarker-tiles-2.html">Spring MVC  + FreeMarker + Tiles 2</a>. I&#8217;ve found that many are interested about the joint work of those frameworks. <br />Well, this article shows how to configure the Spring MVC application with <a href="http://tiles.apache.org">Tiles 2</a> and <a href="http://freemarker.org">FreeMarker</a>. You may don&#8217;t use the <a href="http://springframework.org">SpringMVC</a> framework, and in this case you need to make by your hands all the configuration work that Spring MVC does for you.<br />As you may know, Freemarker is popular template engine write on Java and used by mostly by Java applications. Tiles 2 is also Java frameworks used to prepare document using one or more &#8220;tiles&#8221; &#8211; the parts that are defined separately but used to be generated at one document. For example, using tiles you can define site header/footer, news or post blocks at your site etc.<br />So, how did I get it working?<br />Simple!</p>
<p>In file <code>web.xml</code> add the freemarker configuration.
<pre class="xml">&lt;servlet&gt;        &lt;servlet-name&gt;pages&lt;/servlet-name&gt;        &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;&lt;/servlet&gt;

 &lt;servlet-mapping&gt;        &lt;servlet-name&gt;pages&lt;/servlet-name&gt;        &lt;url-pattern&gt;*.page&lt;/url-pattern&gt; &lt;/servlet-mapping&gt;

&lt;servlet&gt;        &lt;servlet-name&gt;freemarker&lt;/servlet-name&gt;        &lt;servlet-class&gt;freemarker.ext.servlet.FreemarkerServlet&lt;/servlet-class&gt;

        &lt;init-param&gt;            &lt;param-name&gt;TemplatePath&lt;/param-name&gt;            &lt;param-value&gt;/&lt;/param-value&gt;        &lt;/init-param&gt;        &lt;init-param&gt;            &lt;param-name&gt;NoCache&lt;/param-name&gt;            &lt;param-value&gt;true&lt;/param-value&gt;        &lt;/init-param&gt;        &lt;init-paramv            &lt;param-name&gt;ContentType&lt;/param-name&gt;            &lt;param-value&gt;text/html&lt;/param-value&gt;        &lt;/init-param&gt;

        ....

        &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;&lt;/servlet&gt;

&lt;servlet-mapping&gt;        &lt;servlet-name&gt;freemarker&lt;/servlet-name&gt;        &lt;url-pattern&gt;*.ftl&lt;/url-pattern&gt;&lt;/servlet-mapping&gt;</pre>
<p>And here is the important part *-servlet.xml configuration:
<pre class="xml">&lt;!-- Tiles 2 configuration--&gt;&lt;bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"&gt;        &lt;property name="definitions"&gt;            &lt;list&gt;                &lt;!-- the tiles configuration files are declared here --&gt;                 &lt;value&gt;/WEB-INF/defs/general.xml&lt;/value&gt;                &lt;value&gt;/WEB-INF/defs/secure.xml&lt;/value&gt;            &lt;/list&gt;        &lt;/property&gt;&lt;/bean&gt;

&lt;bean id="tilesViewResolver" class="com.javaua.spring.integration.ext.ExtUrlBasedViewResolver"&gt;    &lt;property name="viewClass" value="com.javaua.spring.integration.ext.ExtTilesView"/&gt;    &lt;property name="exposeSpringMacroModel" value="true"/&gt;&lt;/bean&gt;

&lt;bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"&gt;    &lt;property name="cache" value="true"/&gt;    &lt;property name="prefix" value=""/&gt;    &lt;property name="suffix" value=".ftl"/&gt;    &lt;!-- if you want to use the Spring FreeMarker macros, set this property to true --&gt;    &lt;property name="exposeSpringMacroHelpers" value="true"/&gt;&lt;/bean&gt;

&lt;!-- Controller that returns view = /layout/header --&gt;&lt;bean name="/layout/header.page" class="au.com.at2.web.spring.HeaderController"/&gt;</pre>
<p>Also show here the part of general.xml file where Tiles definitions are set up.:
<pre class="xml">&lt;definition name="home" extends="default"&gt;        &lt;put-attribute name="title" value="Home Page"/&gt;        &lt;put-attribute name="body" value="/templates/home.ftl"/&gt;&lt;/definition&gt;&lt;definition name="default" template="/templates/main.ftl"&gt;        &lt;put-attribute name="header" value="/layout/header.page"/&gt;        &lt;put-attribute name="footer" value="/templates/layout/footer.ftl"/&gt;&lt;/definition&gt;&lt;definition name="/layout/header" template="/templates/layout/header.ftl"/&gt;</pre>
<p>Source code of <code>com.javaua.spring.integration.ext.ExtUrlBasedViewResolver</code> class:
<pre class="java">import org.springframework.core.Ordered;import org.springframework.web.servlet.View;import org.springframework.web.servlet.view.AbstractUrlBasedView;import org.springframework.web.servlet.view.UrlBasedViewResolver;

public class ExtUrlBasedViewResolver extends UrlBasedViewResolver implements Ordered {

    private boolean exposeSpringMacroModel = false;

    public void setExposeSpringMacroModel(boolean exposeSpringMacroModel) {        this.exposeSpringMacroModel = exposeSpringMacroModel;    }

    protected View loadView(String viewName, Locale locale) throws Exception {        AbstractUrlBasedView view = buildView(viewName);        View viewObj = (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);

        if (viewObj instanceof ExtTilesView) {            ExtTilesView tilesView = (ExtTilesView) viewObj;            tilesView.setExposeSpringMacroModel(exposeSpringMacroModel);        }

        return viewObj;    }
</pre>
<p>Source code of <code>com.javaua.spring.integration.ext.ExtTilesView</code> class:
<pre class="java">import org.springframework.web.servlet.view.tiles2.TilesView;import org.springframework.web.servlet.view.AbstractTemplateView;import org.springframework.web.servlet.support.RequestContext;

import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpServletRequest;import javax.servlet.ServletException;import java.util.Map;

public class ExtTilesView extends TilesView {

    private boolean exposeSpringMacroModel = false;

    public void setExposeSpringMacroModel(boolean exposeSpringMacroModel) {        this.exposeSpringMacroModel = exposeSpringMacroModel;    }

    @SuppressWarnings("unchecked")    protected final void renderMergedOutputModel(Map model, HttpServletRequest request,                                                 HttpServletResponse response) throws Exception {

        if (exposeSpringMacroModel) {            if (model.containsKey(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE)) {                throw new ServletException(                        "Cannot expose bind macro helper '" +                        AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE +                        "' because of an existing model object of the same name");            }            model.put(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE,                    new RequestContext(request, getServletContext(), model));        }

        super.renderMergedOutputModel(model, request, response);    }}</pre>
<p>Why we need those two classes? Simple enough. Class <code>ExtTilesView</code> exposes Spring macro model which is required when using standard macros used to support work with Freemarker and Velocity typelate frameworks. And the class <code>ExtUrlBasedViewResolver</code> helps us to prevent view-not-found-error. Because, standard <code>UrlBasedViewResolver</code> is used for getting tiles view, it will throw an error when view with specified name is not found. In my case, I have two view resolvers and each will throw an error if view can&#8217;t be found. <br />And <code>FreeMarkerViewResolver</code> will request for the file, while tiles requests just for XML definition. That&#8217;s why I&#8217;ve ran the tiles view resolver as first one.<br />var dzone_url = &#8216;http://java-ua.blogspot.com/2009/01/spring-mvc-freemarker-tiles-2.html&#8217;;<br />var dzone_title = &#8216;Spring MVC + FreeMarker + Tiles 2&#8242;;<br />var dzone_style = &#8217;1&#8242;;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/40/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/40/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/40/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=40&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2009/01/08/spring-mvc-freemarker-tiles-2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>GC and performance</title>
		<link>http://xruslan.wordpress.com/2009/01/08/gc-and-performance/</link>
		<comments>http://xruslan.wordpress.com/2009/01/08/gc-and-performance/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 21:08:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Intellij Idea]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2009/01/08/gc-and-performance/</guid>
		<description><![CDATA[Мабуть, нікому не секрет, що GC є дуже важливою річчю в JVM, і що вона займається звільненням памяті, що вже не використовуються. Також багатьом відомо, що є кілька різних політик виконання очистки пам&#8217;яті. Конфігурація не виглядає надто складною, є всього кілька можливих варіантів вибору політики GC: SerialGC &#8211; встановлена по дефолту, працює найкраще якщо на [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=39&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Мабуть, нікому не секрет, що GC є дуже важливою річчю в JVM, і що вона займається звільненням памяті, що вже не використовуються. Також багатьом відомо, що є кілька різних політик виконання очистки пам&#8217;яті. Конфігурація не виглядає надто складною, є всього кілька можливих варіантів вибору політики GC:</p>
<p>
<ul>
<li>SerialGC &#8211; встановлена по дефолту, працює найкраще якщо на машині тільки один процесор, коли виконуєть збір сміття, то програма тормозить, адже в даний момент вона не відповідає.</li>
<p>
<li>ParallelGC &#8211; використовується можливість виконувати мінорний (minor) збір сміття в паралельних потоках. Програма здатна відповідати на запити клієнта в момент збору сміття</li>
<p>
<li>ParallelOldGC &#8211; виконує мажорний (major) збір сміття в паралельних потоках</li>
<p>
<li>ConcMarkSweepGC &#8211; В даному випадку постійно відбувається збір сміття, програма не тормозить при зборах сміття, як це можна замітити в 3 попередніх випадках.</li>
<p></ul>
<p>Таким чином, я вирішив переконфігурувати для прикладу <a href="http://jetbrains.com/idea">IntellijIdea</a>, що я використовую. <br /><code><br />-Xms256m<br />-Xmx512m<br /><b>-XX:MaxPermSize=120m</b><br />-XX:+UseConcMarkSweepGC<br />-ea<br />-Dawt.useSystemAAFontSettings=lcd<br /></code></p>
<p>Для покращення швидкодії роботи, можна також установити значення ms = mx, так щоб<br /><code><br /><b>-Xms512m</b><br />-Xmx512m<br />-XX:MaxPermSize=120m<br />-XX:+UseConcMarkSweepGC<br />-ea<br />-Dawt.useSystemAAFontSettings=lcd<br /></code></p>
<h4>Ресурси</h4>
<p>
<ul>
<li><a href="http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html">Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning</a> &#8211; із серії must-read</li>
<p>
<li><a href="http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp">Java HotSpot VM Options</a> &#8211; якось давно шукав подібну документацію, тепер повезло більше &#8211; знашов.</li>
<p>
<li><a href="http://www.petefreitag.com/articles/gctuning/">Tuning Garbage Collection Outline</a> &#8211; цікава підбірка фактів про GC</li>
<p></ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=39&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2009/01/08/gc-and-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Enums та перевизначення методів</title>
		<link>http://xruslan.wordpress.com/2008/12/25/java-enums-%d1%82%d0%b0-%d0%bf%d0%b5%d1%80%d0%b5%d0%b2%d0%b8%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%bd%d1%8f-%d0%bc%d0%b5%d1%82%d0%be%d0%b4%d1%96%d0%b2/</link>
		<comments>http://xruslan.wordpress.com/2008/12/25/java-enums-%d1%82%d0%b0-%d0%bf%d0%b5%d1%80%d0%b5%d0%b2%d0%b8%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%bd%d1%8f-%d0%bc%d0%b5%d1%82%d0%be%d0%b4%d1%96%d0%b2/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 15:32:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2008/12/25/java-enums-%d1%82%d0%b0-%d0%bf%d0%b5%d1%80%d0%b5%d0%b2%d0%b8%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%bd%d1%8f-%d0%bc%d0%b5%d1%82%d0%be%d0%b4%d1%96%d0%b2/</guid>
		<description><![CDATA[Читаючи книгу Programming Groovy, я дізнався про можливість перевизначати методи в enums. Про це навіть не здогадувався раніше, і це мене справді здивувало.І справді, нехай у нас є enum в якому вказані дні в тижні: enum DAYS { MON, TUE, WED, THU, FRI, SAT, SUN; public String is() { return "working"; }} Що ж, MON.is().equals("working") [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=38&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Читаючи книгу <a href="http://www.pragprog.com/titles/vslg/programming-groovy">Programming Groovy</a>, я дізнався про можливість перевизначати методи в enums. Про це навіть не здогадувався раніше, і це мене справді здивувало.<br />І справді, нехай у нас є <code>enum</code> в якому вказані дні в тижні:
<pre class="java">enum DAYS {  MON, TUE,  WED, THU,   FRI, SAT,   SUN;

  public String is() {     return "working";  }}</pre>
<p>Що ж, <code>MON.is().equals("working")</code> має бути істинним; але подібне тяжко сказати, наприклад, для <code>SUN.is().equals("working")</code>. <br />Звичайно тепер ми можемо визначити <code>enum</code> наступним чином:
<pre class="java">enum DAYS {  MON, TUE,  WED, THU,   FRI,   SAT {     public String is() {        return "week-end, day 1";     }  },  SUN {     public String is() {        return "week-end, day 2";     }  };

  public String is() {     return "working";  }}</pre>
<p>І все, тепер <code>SUN.is().equals("week-end, day 2") == true</code>.<br />Проблема вирішена, при чому, без збереження зайвого поля &#8211; вказівника на рядок.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=38&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2008/12/25/java-enums-%d1%82%d0%b0-%d0%bf%d0%b5%d1%80%d0%b5%d0%b2%d0%b8%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%bd%d1%8f-%d0%bc%d0%b5%d1%82%d0%be%d0%b4%d1%96%d0%b2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>Mac OS X</title>
		<link>http://xruslan.wordpress.com/2008/12/15/mac-os-x/</link>
		<comments>http://xruslan.wordpress.com/2008/12/15/mac-os-x/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 01:18:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2008/12/15/mac-os-x/</guid>
		<description><![CDATA[Yesterday I have been fully moved to the Mac OS X. Spent all day for finding and installing software. I little bit sad, because can&#8217;t find java 1.6 and 32 bit version. I was thinking about changing used OS from Windows to Mac OS X or to Linux (Ubuntu) a very long time already. But [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=37&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday I have been fully moved to the Mac OS X. Spent all day for finding and installing software. I little bit sad, because can&#8217;t find java 1.6 and 32 bit version.</p>
<p>I was thinking about changing used OS from Windows to Mac OS X or to Linux (Ubuntu) a very long time already. But just now found free day to move. <br />Still, If I&#8217;ll not find the solution with java update and sound bad work then I&#8217;ll become Linux (Ubuntu) user.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=37&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2008/12/15/mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
		<item>
		<title>Google App Engine &amp; Java</title>
		<link>http://xruslan.wordpress.com/2008/10/27/google-app-engine-java/</link>
		<comments>http://xruslan.wordpress.com/2008/10/27/google-app-engine-java/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 21:27:00 +0000</pubDate>
		<dc:creator>Ruslan</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://xruslan.wordpress.com/2008/10/27/google-app-engine-java/</guid>
		<description><![CDATA[Google нарешті таки вирішив, що наступна версія App Engine буде підтримувати Java. З самого початку пора. А ще би було добре позбутися декотрих дивних обмежень, як от, тривалість запиту, маскимальний розмір файлу тощо.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=35&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Google нарешті таки вирішив, що наступна версія App Engine буде підтримувати Java. З самого початку пора. А ще би було добре позбутися декотрих дивних обмежень, як от, тривалість запиту, маскимальний розмір файлу тощо.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/xruslan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/xruslan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/xruslan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/xruslan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/xruslan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/xruslan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/xruslan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/xruslan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/xruslan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/xruslan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/xruslan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/xruslan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/xruslan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/xruslan.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=xruslan.wordpress.com&amp;blog=4036290&amp;post=35&amp;subd=xruslan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://xruslan.wordpress.com/2008/10/27/google-app-engine-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/693e55b0ea5ee193f430979a5438b598?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ruslan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
