<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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/"
	>

<channel>
	<title>blog.tjmoretto.com</title>
	<link>http://blog.tjmoretto.com</link>
	<description></description>
	<pubDate>Fri, 18 Jul 2008 19:02:14 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Spring Transaction Management using Aspects</title>
		<link>http://blog.tjmoretto.com/2008/07/18/spring-transaction-management-using-aspects/</link>
		<comments>http://blog.tjmoretto.com/2008/07/18/spring-transaction-management-using-aspects/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 19:00:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.tjmoretto.com/2008/07/18/spring-transaction-management-using-aspects/</guid>
		<description><![CDATA[For the sake of doing dependency injection into some Hibernate loaded domain classes (see previous post), I was forced to change an application to use AspectJ for it&#8217;s aspect weaving.  When I did this, it broke my existing usage of the Spring @Transaction annotation.
Here&#8217;s what I had to do to fix it.
1. Define my [...]]]></description>
			<content:encoded><![CDATA[<p>For the sake of doing dependency injection into some Hibernate loaded domain classes (see <a href="http://blog.tjmoretto.com/2008/07/18/domain-model-dependency-injection/">previous post</a>), I was forced to change an application to use AspectJ for it&#8217;s aspect weaving.  When I did this, it broke my existing usage of the Spring @Transaction annotation.</p>
<p>Here&#8217;s what I had to do to fix it.</p>
<p>1. Define my transaction as annotation driven in the application context file.</p>
<p><code>&lt;tx:annotation-driven transaction-manager="transactionManager" mode="aspectj"/&gt;</code></p>
<p>2. Manually set the transactionManager on the AnnotationTransactionAspect class. Supposedly, this is a <a href="http://jira.springframework.org/browse/SPR-3817">bug</a> in Spring pre 2.5.x, but I was still encountering it even in 2.5.5.</p>
<p><code>&lt;bean class="org.springframework.transaction.aspectj.AnnotationTransactionAspect" factory-method="aspectOf" dependency-check="none"&gt;<br />
&lt;property name="transactionManager" ref="transactionManager"/&gt;<br />
&lt;/bean&gt;</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tjmoretto.com/2008/07/18/spring-transaction-management-using-aspects/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Domain Model Dependency Injection</title>
		<link>http://blog.tjmoretto.com/2008/07/18/domain-model-dependency-injection/</link>
		<comments>http://blog.tjmoretto.com/2008/07/18/domain-model-dependency-injection/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 18:52:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[architecture]]></category>

		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.tjmoretto.com/2008/07/18/domain-model-dependency-injection/</guid>
		<description><![CDATA[I recently had the need to add some rich features to an existing domain model.  The application is built with Spring 2.5.x and Hibernate.  When I started on this endeavor, I had no idea how many issues I would encounter.  So, here&#8217;s what I ultimately had to do to get DI in [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had the need to add some rich features to an existing domain model.  The application is built with Spring 2.5.x and Hibernate.  When I started on this endeavor, I had no idea how many issues I would encounter.  So, here&#8217;s what I ultimately had to do to get DI in my Hibernate loaded domain classes.</p>
<p>1. Use the <a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/beans/factory/annotation/Configurable.html" target="_blank">@Configurable</a> annotation on your domain class that you want to do DI with.<br />
2. Use the @Autowired annotation on the member variable that needs DI.</p>
<p><code>@Configurable<br />
@Entity<br />
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)<br />
@DiscriminatorColumn(name="material_type", discriminatorType=DiscriminatorType.STRING)<br />
@org.hibernate.annotations.ForceDiscriminator<br />
@Table(<br />
name = "materials",<br />
uniqueConstraints = {@UniqueConstraint(columnNames={"material_id"})}<br />
)<br />
public abstract class MaterialContent {<br />
@Autowired<br />
@Transient<br />
protected ProtectedFileUrlDao protectedFileUrlDao;<br />
}</code></p>
<p>3. Define the Autowired member variable as a bean in your application context file (there&#8217;s of course other ways to do this).</p>
<p><code>&lt;bean id="protectedFileURLDao" class="com.sample.impl.ProtectedFileURLDaoImpl"&gt;<br />
&lt;property name="sessionFactory" ref="sessionFactory"/&gt;<br />
&lt;/bean&gt;<br />
</code><br />
4. Setup the standard application context settings to allow for Annotation DI.  By default, spring will use compile-time weaving (fine by me).</p>
<p><code>&lt;context:component-scan base-package="com.sample"/&gt;<br />
&lt;context:spring-configured/&gt;<br />
&lt;context:annotation-config/&gt;</code></p>
<p>5. Setup your maven pom to compile the code with the AspecJ weaver.</p>
<p><code>&lt;plugin&gt;<br />
&lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;<br />
&lt;artifactId&gt;aspectj-maven-plugin&lt;/artifactId&gt;<br />
&lt;version&gt;1.0&lt;/version&gt;<br />
&lt;configuration&gt;<br />
&lt;source&gt;1.5&lt;/source&gt;<br />
&lt;verbose&gt;true&lt;/verbose&gt;<br />
&lt;complianceLevel&gt;1.5&lt;/complianceLevel&gt;<br />
&lt;showWeaveInfo&gt;true&lt;/showWeaveInfo&gt;<br />
&lt;aspectLibraries&gt;<br />
&lt;aspectLibrary&gt;<br />
&lt;groupId&gt;org.springframework&lt;/groupId&gt;<br />
&lt;artifactId&gt;spring-aspects&lt;/artifactId&gt;<br />
&lt;/aspectLibrary&gt;<br />
&lt;/aspectLibraries&gt;<br />
&lt;/configuration&gt;<br />
&lt;executions&gt;<br />
&lt;execution&gt;<br />
&lt;goals&gt;<br />
&lt;goal&gt;compile&lt;/goal&gt;<br />
&lt;/goals&gt;<br />
&lt;/execution&gt;<br />
&lt;/executions&gt;<br />
&lt;dependencies&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.aspectj&lt;/groupId&gt;<br />
&lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;<br />
&lt;version&gt;1.6.1&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;dependency&gt;<br />
&lt;groupId&gt;org.aspectj&lt;/groupId&gt;<br />
&lt;artifactId&gt;aspectjtools&lt;/artifactId&gt;<br />
&lt;version&gt;1.6.1&lt;/version&gt;<br />
&lt;/dependency&gt;<br />
&lt;/dependencies&gt;<br />
&lt;/plugin&gt;</code></p>
<p>Here&#8217;s some of the references that I used while setting this up:</p>
<p><a href="http://chris-richardson.blog-city.com/migrating_to_spring_2_part_3__injecting_dependencies_into_en.htm">Chris Richardson - enterprise POJOs</a><br />
<a href="http://blog.springsource.com/main/2008/01/23/new-improvements-in-domain-object-dependnecy-injection-feature/"> New Improvements in Domain Object Dependency Injection Feature</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.tjmoretto.com/2008/07/18/domain-model-dependency-injection/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting Typo 5 running on Dreamhost</title>
		<link>http://blog.tjmoretto.com/2008/02/13/getting-typo-5-running-on-dreamhost/</link>
		<comments>http://blog.tjmoretto.com/2008/02/13/getting-typo-5-running-on-dreamhost/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 16:19:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[dreamhost]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[typo]]></category>

		<guid isPermaLink="false">http://blog.tjmoretto.com/?p=3</guid>
		<description><![CDATA[I decided to attempt to install Typo 5.0.2 on my Dreamhost account in an effort to learn something about Rails 2. Didn&#8217;t go so well, but here&#8217;s what I had to do to get it working:

I had previously setup my Dreamhost account to leverage my own gems, ruby, etc. The best info for this is [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to attempt to install <a href="http://typosphere.org/" target="_blank">Typo</a> 5.0.2 on my <a href="http://dreamhost.com/" target="_blank">Dreamhost</a> account in an effort to learn something about Rails 2. Didn&#8217;t go so well, but here&#8217;s what I had to do to get it working:</p>
<ol>
<li>I had previously setup my Dreamhost account to leverage my own gems, ruby, etc. The best info for this is from <a href="http://nateclark.com/articles/2006/10/20/dreamhost-your-own-packages-and-gems" target="_blank">Nate Clark</a>.</li>
<li>Install the typo gem. This was time consuming, because Dreamhost kept killing my *gem install* processes. In the end, I had to download each of the required gems independently and install them one by one. I just placed them in my home directory and then ran <em>gem install gem_name</em>.</li>
<li>Install typo to a specific path by running <em>typo install $HOME/blog.tjmoretto.com/</em>. Typo has the <a href="http://typosphere.org/articles/2007/08/26/install-typo" target="_blank">actual instructions</a> if you need.</li>
<li>Configure the web directory of my subdomain to point to the $HOME/blog.tjmoretto.com/public directory of the typo install.</li>
<li>Create a mysql database using the Dreamhost admin tool. I ended up using mysql, because when I first tried to write a blog entry with the default sqlite setup, I was getting an <em>Invalid state</em> error. Could not find any useful info on the typo mailing list for fixing this.</li>
<li>Update the database.yml file to use the mysql database (default is sqlite).</li>
<li>Create the database tables by running <em>rake db:migrate RAILS_ENV=production</em> from the root of the typo install.</li>
<li>Update the dispatch.fcgi file to use my own gems by replacing the existing shebang line at the top of the file with <em>#!/home/&lt;user&gt;/.packages/bin/ruby</em></li>
<li>Test out the dispatch.fcgi process by running it from the command line. This can be done by going to the <em>$HOME/blog.tjmoretto.com/public</em> directory and running <em>./dispatch.fcgi</em>. You should see the html output to the console if it is working correctly.</li>
<li>Done!</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.tjmoretto.com/2008/02/13/getting-typo-5-running-on-dreamhost/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
