<?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>Jeff Yu@IT</title>
	<atom:link href="http://jeff.familyyu.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeff.familyyu.net</link>
	<description>When you are getting older, your memory becomes worse, so you need to write down some notes from time to time, hence this place was born.</description>
	<lastBuildDate>Tue, 18 Oct 2011 02:04:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Git merge or rebase?</title>
		<link>http://jeff.familyyu.net/2011/10/18/git-merge-or-rebase/</link>
		<comments>http://jeff.familyyu.net/2011/10/18/git-merge-or-rebase/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 01:36:37 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[SCM]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://jeff.familyyu.net/?p=736</guid>
		<description><![CDATA[There are many posts about the difference on git&#8217;s rebase and merge commands, here I&#8217;d like to link two of them that I think did a great job on the explanation. 1. Rebase vs Merge in Git 2. Avoid Merge commit in Git, this one shows very detail about the difference on these two options, [...]]]></description>
			<content:encoded><![CDATA[<p>There are many posts about the difference on git&#8217;s rebase and merge commands, here I&#8217;d like to link two of them that I think did a great job on the explanation.</p>
<p>1. <a href="http://gitguru.com/2009/02/03/rebase-v-merge-in-git/">Rebase vs Merge in Git</a><br />
2. <a href="http://www.kerrybuckley.org/2008/06/18/avoiding-merge-commits-in-git/">Avoid Merge commit in Git</a>, this one shows very detail about the difference on these two options, and it is the exact problem I was facing.</p>
<p>I&#8217;d also like to quote the work pattern that is described in the above 1st link. (The result is basically put all your branch work/commits ahead of your base branch, for example master, and of course without adding those meaningless merge commits that you would have if you use the git merge.)</p>
<blockquote>
<ol>
<li>Create new branch B from existing branch A</li>
<li>Add/commit changes on branch B</li>
<li>Rebase updates from branch A</li>
<li>Merge changes from branch B onto branch A</li>
</ol>
</blockquote>
<p>I typically use the &#8216;master&#8217; branch as the base branch, which means that I only sync this branch from the remote repository, and only merge commits into this branch when I think the bug/feature is completed. Once I&#8217;ve  done the merge in master, I&#8217;ll do the commit and push, so the code in master branch&#8217;s staging repository is very short. However, I&#8217;ve done a lot of pull request from remote repository into the master branch, as I need to sync other people&#8217;s work, and then I&#8217;ll do the rebase on the topic/bugfix branch that I am working on to sync the work without adding the merge commit, and put my commit in front of others commits that are already in the repo.</p>
<p>One caution with regard to the rebase operation is: (Again quote from the 2nd link that I pointed)</p>
<blockquote><p>If you&#8217;ve shared the branch with anyone else, or are pushing it to a clone of the repository, do not rebase, but use merge instead. From the man page:</p>
<p>When you rebase a branch, you are changing its history in a way that will cause problems for anyone who already has a copy of the branch in their repository and tries to pull updates from you. You should understand the implications of using git rebase on a repository that you share.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2011/10/18/git-merge-or-rebase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git Cheat Sheet for history/difference.</title>
		<link>http://jeff.familyyu.net/2011/10/16/git-cheat-sheet-for-historydifference/</link>
		<comments>http://jeff.familyyu.net/2011/10/16/git-cheat-sheet-for-historydifference/#comments</comments>
		<pubDate>Sun, 16 Oct 2011 04:46:33 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[SCM]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://jeff.familyyu.net/?p=731</guid>
		<description><![CDATA[I knew it has some good Git Cheat Sheets on the internet. So I won&#8217;t try to create yet another Git Cheat Sheet. Instead, I&#8217;ll focus on some commands for the history and file difference, as I often use them to check what has been updated on the commits, and what files been changed in [...]]]></description>
			<content:encoded><![CDATA[<p>I knew it has some good <a href="http://help.github.com/git-cheat-sheets/">Git Cheat Sheets</a> on the internet. So I won&#8217;t try to create yet another Git Cheat Sheet. Instead, I&#8217;ll focus on some commands for the history and file difference, as I often use them to check what has been updated on the commits, and what files been changed in there etc. Usually I went to GitHub to check out the previous commits, as it did a very good job on showing the updated files, difference on each file etc. However, at some time, my home internet is very slow, so it could be painful to go to the Github to check on those commits. (It is nothing wrong in Github, it is just in my particular case at some time due to bad network).</p>
<p>Git is a DVCS, so it means that we have all histories, logs in my local machine, the remote one should be served as a backup/collaborate purpose. So it means for checking the commits/difference, it should be accomplished without connecting to internet.  Here I&#8217;ll try to enumerate some options/commands that I ran for checking those updates/commits. If you have any other good usages/commands that I left out. please feel free to make a comment.</p>
<p>1. Show all of previous commits (result only shows commit summary):</p>
<blockquote><p>git  log</p></blockquote>
<p>2. Show the latest n commits:</p>
<blockquote><p>git  log  -n</p></blockquote>
<p>3. Show the statistics (like updated file list) in previous commits:</p>
<blockquote><p>git log &#8211;stat</p></blockquote>
<p>4. Show previous commits with patches:</p>
<blockquote><p>git log -p</p></blockquote>
<p>5. Show a specific commit with commit hash id, you just need to have enough first couple letters to make it unique:<br />
Add &#8211;stats (if you want to show the statistics) and -p (if you want to show the detailed diff) options.</p>
<blockquote><p>git show 36b314c (first couple letters of id)</p></blockquote>
<p>6. Show commits/histories to a specific file (-p, -n apply here as well, but should be in front of filepath):</p>
<blockquote><p>git log &#8212; filepath</p></blockquote>
<p>7. Show a diff on a specific file with a specific commit:</p>
<blockquote><p>git show commitId (like 36b314c for example) &#8212; filepath</p></blockquote>
<p>9. Show difference between two commits:</p>
<blockquote><p>git diff firstCommitId secondCommitId</p></blockquote>
<p>10. Show difference between two commits for a specific file.</p>
<blockquote><p>git diff firstCommitId secondCommitId &#8212; filepath</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2011/10/16/git-cheat-sheet-for-historydifference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;Functional Programming for Java Developer&#8221; book review.</title>
		<link>http://jeff.familyyu.net/2011/09/17/functional-programming-for-java-developer-book-review/</link>
		<comments>http://jeff.familyyu.net/2011/09/17/functional-programming-for-java-developer-book-review/#comments</comments>
		<pubDate>Sat, 17 Sep 2011 04:32:37 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Thoughts]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[Review]]></category>

		<guid isPermaLink="false">http://jeff.familyyu.net/?p=710</guid>
		<description><![CDATA[Just finished the &#60;Functional Programming for Java Developers&#62; book that written by Dean Wampler. As Functional Programming got more buzz and more attentions lately, for Java developers (seems always busy, btw), I think this is a good and concise book for you to read on the subject, it is only 60 pages. Looks more like [...]]]></description>
			<content:encoded><![CDATA[<div style="float: left;"><a href="http://shop.oreilly.com/product/0636920021667.do"><img class="alignnone size-full wp-image-711" title="functional_programming" src="http://jeff.familyyu.net/wp-content/uploads/2011/09/functional_programming.gif" alt="" width="180" height="236" /></a></div>
<div style="margin-left: 190px;">
<p>Just finished the <a href="http://shop.oreilly.com/product/0636920021667.do">&lt;Functional Programming for Java Developers&gt;</a> book that written by <a href="http://www.deanwampler.com/">Dean Wampler</a>.</p>
<p>As Functional Programming got more buzz and more attentions lately, for Java developers (seems always busy, btw), I think this is a good and concise book for you to read on the subject, it is only 60 pages. Looks more like a long essay instead of a book, given most of IT books are having more than 200 pages. However, the 60 pages serves this book&#8217;s purpose very well, it will motivate you to enter into the Functional Programming world, at least, I am motivated!</p>
<p>The author begins with &#8220;Why Functional Programming&#8221;,  and the main reasons are: 1) Have to be good at writing concurrent program 2) Most programs are just Data Management problem 3) Functional Programming is more Modular 4) Have to work faster and faster and Functional Programming is a return to simplicity.</p>
</div>
<div style="both: clear;">
<p>I particularly like the last point of returning to simplicity, remember that how many times we need to use the IDE&#8217;s &#8216;generate getter and setter methods&#8217; function to generate those boilerplate code,  and how many times we wrote similar code to iterate a collection just because we are using another criterion. I believe, less codes means less bugs, with Java, we sometimes always bury our business logic codes into the codes that needed by language itself. Frameworks/Libraries surely offer a great help here, but wouldn&#8217;t it been even better that is supported in the language level.</p>
</div>
<div style="both: clear;">
<p>The author goes on with &#8220;What Is Functional Programming&#8221;, Some of basic principles of Functional Programming, like 1) Avoid mutable state 2) Functions as first-class values 3)Lambda and closures 4)High-order Functions 5)Side-Efffect-Free Functions 6) Recursion 7) Lazy vs Eager Evaluation 8)Declarative vs. Imperative Programming. In this chapter, I particularly impressed by Recursion and Declarative vs. Imperative Programming. In Java programming, we don&#8217;t usually see many recursion usage in our daily code, I am not sure why, vaguely remembered that it may affect the performance. With Functional Programming, it doesn&#8217;t use the loop, it uses the Recursion instead. And author list two different ways to program the factorial function. The declarative one that used the recursion seems much easier to understand for me.</p>
<p>The author continues with &#8220;Data Structure and Algorithms&#8221;, &#8220;Functional Concurrency&#8221; and &#8220;Better Object-Oriented Programming&#8221; chapter to expand a bit explanation/examples on the items that he described in the first chapter &#8220;Why Functional Programming&#8221;.</p>
<p>Last chapter is called &#8220;Where to go from here&#8221;, basically lists some good resources that for you continue to explore the wonderful world of Functional Programming.</p>
<p>Well, writing a review for a concise book should be concise as well, otherwise, why don&#8217;t you spend the time of reading my review in reading the book itself. <img src='http://jeff.familyyu.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Overall, this is a very good Functional Programming introduction book for you to read, especially for those busy Java developers.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2011/09/17/functional-programming-for-java-developer-book-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrading Hibernate 3.3.2 to Hibernate 4.0.0</title>
		<link>http://jeff.familyyu.net/2011/09/08/upgrading-hibernate-3-3-2-to-hibernate-4-0-0/</link>
		<comments>http://jeff.familyyu.net/2011/09/08/upgrading-hibernate-3-3-2-to-hibernate-4-0-0/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 09:48:48 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[RiftSaw]]></category>

		<guid isPermaLink="false">http://jeff.familyyu.net/?p=699</guid>
		<description><![CDATA[As you may know, JBoss AS 7 is incredible fast and low-memory, and it comes with Hibernate 4.0.0 by default. Since AS 7.0.1, it is easy for you to support both Hibernate 3.x  and Hibernate 4.0.0 under JBoss AS, thanks to the modular classpath here. If you want to run Hibernate 3.x under AS7 along [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know, <a href="http://www.jboss.org/jbossas">JBoss AS 7</a> is incredible fast and low-memory, and it comes with Hibernate 4.0.0 by default. Since AS 7.0.1, it is easy for you to support both Hibernate 3.x  and Hibernate 4.0.0 under JBoss AS, thanks to the modular classpath here. If you want to run Hibernate 3.x under AS7 along with Hibernate 4, you should check out <a href="http://in.relation.to/Bloggers/UsingADifferentPersistenceProviderWithAS701">this blog entry </a>and <a href="https://docs.jboss.org/author/display/AS7/JPA+Reference+Guide">this documentation</a>.</p>
<p>In <a href="https://github.com/riftsaw">RiftSaw 3</a> development, we are taking this opportunity to upgrading its JPA layer from JPA 1.0 to JPA 2.0, as JPA 2.0 is back compatible, it shouldn&#8217;t be an big issue. However, we&#8217;ve implemented the <a href="http://www.docjar.com/html/api/org/hibernate/connection/ConnectionProvider.java.html">ConnectionProvider</a> and <a href="http://www.docjar.com/html/api/org/hibernate/transaction/TransactionManagerLookup.java.html">TransactionManagerLookup</a> interfaces, since we&#8217;ve created the Datasource and TransactionManager on our own, we need to implement these two interfaces to ask Hibernate to use our own one.</p>
<p>In Hibernate 4.x, the whole package has been split into three categories, API/Impl/SPI.  So the ConnectionProvider class has been re-packaged at: <strong>org.hibernate.service.jdbc.connections.spi.ConnectionProvider</strong>, if you see the <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.hibernate/hibernate-core/4.0.0.Beta3/org/hibernate/service/jta/platform/internal/JBossAppServerJtaPlatform.java">internal implementation</a> of this, you would also notice that it also implements the <a href="http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.hibernate/hibernate-core/4.0.0.Alpha2/org/hibernate/service/spi/Configurable.java">Configurable</a> and <a href="http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.hibernate/hibernate-core/4.0.0.Alpha2/org/hibernate/service/spi/Stoppable.java?av=f">Stoppable</a>. The Configurable interface allows you to access to the Hibernate&#8217;s properties, which is kept as Map. It is much like Spring&#8217;s BeanNameAware interface, where you get to access to the BeanName. So below is the code snippet that I used for my ConnectionProvider.</p>
<pre class="brush: java; title: ; notranslate">
public class DataSourceConnectionProvider implements ConnectionProvider, Configurable, Stoppable  {

  private Properties _props;

  private boolean available = true;

  public DataSourceConnectionProvider() {
  }

  @SuppressWarnings( {&quot;unchecked&quot;})
  public void configure(Map properties) {
	 _props = new Properties();
	 _props.putAll(properties);
  }

  public Connection getConnection() throws SQLException {
	if (!available) {
		throw new HibernateException( &quot;Provider is closed!&quot; );
	}
    Connection c = HibernateUtil.getConnection(_props);
    DbIsolation.setIsolationLevel(c);
    return c;
  }

  public void closeConnection(Connection con) throws SQLException {
    con.close();
  }

  public boolean supportsAggressiveRelease() {
    return true;
  }

  public boolean isUnwrappableAs(Class unwrapType) {
		return ConnectionProvider.class.equals(unwrapType) ||
				DataSourceConnectionProvider.class.isAssignableFrom(unwrapType);
  }

  @SuppressWarnings( {&quot;unchecked&quot;})
  public  T unwrap(Class unwrapType) {
		if (ConnectionProvider.class.equals(unwrapType) ||
				DataSourceConnectionProvider.class.isAssignableFrom(unwrapType)) {
			return (T) this;
		} else {
			throw new UnknownUnwrapTypeException( unwrapType );
		}
  }

  public void stop() {
	available = false;
  }
}
</pre>
<p>For the TransactionManagerLookup interface, you would get WARN  saying this API has been deprecated ( I believe it has been deprecated before 4.x, but I didn&#8217;t get a chance to upgrade it until now), we should implement the <strong>org.hibernate.service.jta.platform.spi.JtaPlatform </strong>SPI instead, and set it to the &#8216;hibernate.transaction.jta.platform&#8217; property. Instead of having a class that implement the JtaPlatform SPI directly, I&#8217;ve subclassed it from the  <a href="http://grepcode.com/file/repo1.maven.org/maven2/org.hibernate/hibernate-core/4.0.0.Beta5/org/hibernate/service/jta/platform/internal/AbstractJtaPlatform.java#AbstractJtaPlatform">AbstractJtaPlatform</a> class, so that I&#8217;ve only needed to override two interfaces. Below is the code snippet for my custom JtaPlatform impl.</p>
<pre class="brush: java; title: ; notranslate">/**
 *
 * uses {@link HibernateUtil} to obtain the JTA {@link TransactionManager} object.
 *
 * @author Jeff Yu
 *
 */
public class OdeJtaPlatform extends AbstractJtaPlatform {

	private Properties properties = new Properties();

	public void configure(Map configValues) {
		super.configure(configValues);
		properties.putAll(configValues);
	}

	@Override
	protected TransactionManager locateTransactionManager() {
		return HibernateUtil.getTransactionManager(properties);
	}

	@Override
	protected UserTransaction locateUserTransaction() {
		throw new UnsupportedOperationException(&quot;locateUserTransaction is not supported. Use the locateTransactionManager instead.&quot;);
	}

} </pre>
<p>And then when you create your entityManagerFactory, remember to pass the following properties in.</p>
<pre class="brush: java; title: ; notranslate">props.put(Environment.CONNECTION_PROVIDER, DataSourceConnectionProvider.class.getName());
props.put(Environment.JTA_PLATFORM, OdeJtaPlatform.class.getName());</pre>
<p>Done, the custom ConnectionProvider and JtaPlatform implementation should be all set now.</p>
<p>Hope this will help you do the Hibernate upgrade at some point. Here, I&#8217;d like to thanks <a href="http://in.relation.to/Bloggers/StrongLiu">Strong Liu</a> to send the helpful links to me on this upgrading. <img src='http://jeff.familyyu.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2011/09/08/upgrading-hibernate-3-3-2-to-hibernate-4-0-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting/Using services deployed in JBoss AS 5.x</title>
		<link>http://jeff.familyyu.net/2010/09/28/gettingusing-services-deployed-in-jboss-as-5-x/</link>
		<comments>http://jeff.familyyu.net/2010/09/28/gettingusing-services-deployed-in-jboss-as-5-x/#comments</comments>
		<pubDate>Tue, 28 Sep 2010 04:03:00 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JBoss]]></category>
		<category><![CDATA[RiftSaw]]></category>

		<guid isPermaLink="false">http://jeffyuchang.wordpress.com/2010/09/28/gettingusing-services-deployed-in-jboss-as-5-x</guid>
		<description><![CDATA[JBoss AS Version 5 and above used the JBoss MicroContainer project to accomplish the service management/dependency injection. If we want to write a service that uses a JBoss Server service, like the &#8216;HAPartitionService&#8217; for example, the below shows several ways that can be done. 1. Using JBoss MC&#8217;s xml syntax This is the most common [...]]]></description>
			<content:encoded><![CDATA[<p>JBoss AS Version 5 and above used the <a href="http://jboss.org/jbossmc">JBoss MicroContainer</a> project to accomplish the service management/dependency injection. If we want to write a service that uses a JBoss Server service, like the &#8216;HAPartitionService&#8217; for example, the below shows several ways that can be done.</p>
<p><span style="text-decoration: underline;">1. Using JBoss MC&#8217;s xml syntax</span><br />
This is the most common and recommended way to do. Below is the <a href="http://www.jboss.org/riftsaw">JBoss RiftSaw</a> Clustering service that uses the &#8216;HAPartitonService&#8217; from JBoss AS Cluster.</p>
<pre class="brush: xml; title: ; notranslate">
   &lt;bean name=&quot;RiftSawClusteringService&quot; class=&quot;org.jboss.soa.bpel.clustering.JBossClusteringService&quot;&gt;
   	 &lt;property name=&quot;haPartition&quot;&gt;&lt;inject bean=&quot;HAPartition&quot; /&gt;&lt;/property&gt;
   	 &lt;property name=&quot;bpelEngineName&quot;&gt;bpel/Engine&lt;/property&gt;
   	 &lt;depends&gt;BPELEngine&lt;/depends&gt;
   &lt;/bean&gt;
</pre>
<p>See Ales&#8217; <a href="http://java.dzone.com/articles/a-look-inside-jboss-microconta-0">Advanced Dependency Injections article</a> for more about MC&#8217;s xml syntax.</p>
<p>&nbsp;</p>
<p><span style="text-decoration: underline;">2. Using JBoss MC&#8217;s service programmatically</span><br />
This way actually is the main topic for this blog entry. If you are a <a href="http://www.springframework.org">Spring framework</a> user, you would know you can use BeanFactory or ApplicationContext to get the service bean. Then in JBoss, you would wonder, whats the equivalent way to do this?</p>
<p>1) org.jboss.kernel.Kernel, this is the service that has the KernelController and ControllerContext that we need for getting the service. so firstly, you can define a service in -jboss-bean.xml that injects the Kernel service, like the following:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!--    Locate the single instance of the kernel    --&gt;
&lt;bean name=&quot;org.jboss.soa.bpel.runtime.util:service=KernelLocator&quot;
     class=&quot;org.jboss.soa.bpel.runtime.integration.KernelLocator&quot;&gt;
    &lt;property name=&quot;kernel&quot;&gt;
      &lt;inject bean=&quot;jboss.kernel:service=Kernel&quot; /&gt;
    &lt;/property&gt;
&lt;/bean&gt;
</pre>
<p>We&#8217;ve defined above class as following:</p>
<pre class="brush: java; title: ; notranslate">
package org.jboss.soa.bpel.runtime.integration;
public class KernelLocator{
  private static Kernel kernel;
  public static Kernel getKernel()  {    return KernelLocator.kernel;  }
  public void setKernel(Kernel kernel)  {    KernelLocator.kernel = kernel;  }
}
</pre>
<p>2) Use the KernelController and ControllerContext to get the service that we defined in *-jboss-bean.xml.<br />
Below is the code to actually obtain the started service out of JBoss AS.</p>
<pre class="brush: java; title: ; notranslate">
public class KernelAwareSPIFactory{
   @SuppressWarnings(&quot;unchecked&quot;)
   public &lt;T&gt; T getKernelProvidedSPI(String beanName, Class&lt;T&gt; spiArtifact)   {
      KernelController controller = KernelLocator.getKernel().getController();
      ControllerContext ctx = controller.getInstalledContext(beanName);
      return (T)ctx.getTarget();   }
}
</pre>
<p>In the end, let&#8217;s take an example from <a href="http://jboss.org/riftsaw">RiftSaw code base</a> to show how it was used.</p>
<p>&nbsp;</p>
<p>In RiftSaw, we&#8217;ve defined a ServerConfig interface.</p>
<pre class="brush: java; title: ; notranslate">
public interface ServerConfig{
  /** The default bean name */
  String BEAN_NAME = &quot;org.jboss.soa.bpel.runtime.util:service=ServerConfig&quot;;

  String getImplementationTitle();

  String getImplementationVersion();

  File getServerTempDir();

  File getServerDataDir();

  String getWebServiceHost();

  int getWebServicePort();

  .....
}
</pre>
<p>And then we&#8217;ve had the ServerConfigImpl class.</p>
<pre class="brush: java; title: ; notranslate">
public class ServerConfigImpl implements ServerConfig{  ....}
</pre>
<p>With this implementation, we&#8217;ve defined the ServerConfig service in the *-jboss-bean.xml as following.</p>
<pre class="brush: java; title: ; notranslate">
&lt;!--       ServerConfig    --&gt;
 &lt;bean name=&quot;org.jboss.soa.bpel.runtime.util:service=ServerConfig&quot;
        class=&quot;org.jboss.soa.bpel.runtime.integration.ServerConfigImpl&quot;&gt;
    &lt;property name=&quot;mbeanServer&quot;&gt;
     &lt;inject bean=&quot;JMXKernel&quot; property=&quot;mbeanServer&quot;/&gt;
    &lt;/property&gt;
    &lt;property name=&quot;webServiceHost&quot;&gt;${jboss.bind.address}&lt;/property&gt;
  &lt;/bean&gt;
</pre>
<p>Now, finally let&#8217;s see how we get this ServerConfig Service in our code.</p>
<pre class="brush: java; title: ; notranslate">
ServerConfig = new KernelAwareSPIFactory()
               .getKernelProvidedSPI(&quot;org.jboss.soa.bpel.runtime.util:service=ServerConfig&quot;, ServerConfig.class
</pre>
<p>And then, here you go, you&#8217;ve got the ServerConfig service that is in the JBoss AS.</p>
<p>&nbsp;</p>
<p>Hope this can help people who are doing integration with JBoss AS a little bit.</p>
<p>PS: Thanks <a href="http://www.jroller.com/gmazza/">Glen</a> for pointing out some grammar errors that I did earlier. As what we used to say &#8220;your patch has been applied, thanks a lot. <img src='http://jeff.familyyu.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> &#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2010/09/28/gettingusing-services-deployed-in-jboss-as-5-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Mysql and Postgres in Mac OS through MacPorts</title>
		<link>http://jeff.familyyu.net/2010/08/19/install-mysql-and-postgres-in-mac-os-through-macports/</link>
		<comments>http://jeff.familyyu.net/2010/08/19/install-mysql-and-postgres-in-mac-os-through-macports/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 01:54:00 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[Database]]></category>

		<guid isPermaLink="false">http://jeffyuchang.wordpress.com/2010/08/19/install-mysql-and-postgres-in-mac-os-through-macports</guid>
		<description><![CDATA[Here are two greats links on how to installing mysql and postgres on to your Mac OS. 1.Installing PostgreSQL on Leopard using MacPorts2.Installing MySQL on Mac OS X Leopard using MacPorts]]></description>
			<content:encoded><![CDATA[<p>Here are two greats links on how to installing mysql and postgres on to your Mac OS.</p>
<p>1.<a href="http://shifteleven.com/articles/2008/03/21/installing-postgresql-on-leopard-using-macports">Installing PostgreSQL on Leopard using MacPorts</a><br />2.<a href="http://matthewcarriere.com/2008/04/02/installing-mysql-on-mac-os-x-leopard-using-macports/">Installing MySQL on Mac OS X Leopard using MacPorts</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2010/08/19/install-mysql-and-postgres-in-mac-os-through-macports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploring ODE part V: implemenation of scheduler-simple module.</title>
		<link>http://jeff.familyyu.net/2010/07/26/exploring-ode-part-v-implemenation-of-scheduler-simple-module/</link>
		<comments>http://jeff.familyyu.net/2010/07/26/exploring-ode-part-v-implemenation-of-scheduler-simple-module/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 11:18:00 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[BPM]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ODE]]></category>
		<category><![CDATA[RiftSaw]]></category>

		<guid isPermaLink="false">http://jeffyuchang.wordpress.com/2010/07/26/exploring-ode-part-v-implemenation-of-scheduler-simple-module</guid>
		<description><![CDATA[In Ode/RiftSaw, we make the process execution as asynchronous, which means that if you running a bpel process, we are using more than one thread to accomplish this invocation. And this is what the scheduler-simple module for, it takes care of putting a task into database and pull tasks out of database and how to [...]]]></description>
			<content:encoded><![CDATA[<p>In Ode/RiftSaw, we make the process execution as asynchronous, which means that if you running a bpel process, we are using more than one thread to accomplish this invocation.</p>
<p>And this is what the scheduler-simple module for, it takes care of putting a task into database and pull tasks out of database and how to run them. Lets make a simple example here, say your bpel process has a invoke Activity to invoke an external web service. In Ode, just right before entering invoke Activity, we&#8217;ve created a job that captures this invoke activity information, and store it into the database. Because once we&#8217;ve started Ode Bpel Server, we already started a background thread that checks this ode_job table periodically, once we&#8217;ve found that there is a job needs to be executed, it will load it from database, put it into memory, and then submit it to the ExecutorService for execution.</p>
<p>In this blogpost, we will examine this module&#8217;s architecture and important APIs.</p>
<p>First is the Task API, this is the parent class for Job and SchedulerTask.</p>
<pre class="brush: java; title: ; notranslate">
class Task {
    /** Scheduled date/time. */
    public long schedDate;

    Task(long schedDate) {
        this.schedDate = schedDate;
    }
}
</pre>
<p>It is very simple, just had a scheduled date for its execution.<br />
Next, we will see the Job&#8217;s API, Job is for invoking an external service and like. we&#8217;ve put all of important information into the JobDetail object.</p>
<pre class="brush: java; title: ; notranslate">
class Job extends Task {
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss z&quot;);
    String jobId;
    boolean transacted;
    JobDetails detail;
    boolean persisted = true;

    public Job(long when, String jobId, boolean transacted, JobDetails jobDetail) {
        super(when);
        this.jobId = jobId;
        this.detail = jobDetail;
        this.transacted = transacted;
    }
....
}
</pre>
<p>Now, lets look at another type of Task, which is called SchedulerTask.</p>
<pre class="brush: java; title: ; notranslate">
private abstract class SchedulerTask extends Task implements Runnable {
    SchedulerTask(long schedDate) {
        super(schedDate);
    }
}
</pre>
<p>This is an abstract class, its subclasses are: LoadImmediateTask, UpgradeJobsTask, CheckStaleNodes.</p>
<p>&nbsp;</p>
<p>To understand these tasks, it is better that we look at what SimpleScheduler class defined. In Ode, the job design was based around three time horizons: &#8220;immediate&#8221;, &#8220;near future&#8221;, and &#8220;everything else&#8221;.<br />
Immediate jobs (i.e. jobs that are about to be up) are written to the database and kept in an in-memory priority queue. When they execute, they are removed from the database. Near future jobs are placed in the database and assigned to the current node, however they are not stored in<br />
memory. Periodically jobs are &#8220;upgraded&#8221; from near-future to immediate status, at which point they get loaded into memory. Jobs that are further out in time, are placed in the database without a node identifer; when they are ready to be &#8220;upgraded&#8221; to near-future jobs they are assigned to one<br />
of the known live nodes. recovery is straight forward, with stale node identifiers being reassigned to known good nodes.</p>
<p>In terms of time, we defined two variables, one is: _immediateInterval and _nearFutureInterval.<br />
if a job&#8217;s scheduled date is between [now, now + _immediateInterval], it belongs to the &#8220;immediate&#8221; job.<br />
while if it is in [now + _immediateInterval, now + _nearFutureInterval], it belongs to the &#8220;near future&#8221; job then.</p>
<p>You can check the SimpleScheduler.doLoadImmediate() and SimpleScheduler.doUpgrade() respectively for its logic.</p>
<p>Also, you may be aware that we&#8217;ve also had the CheckStaleNodes task, this is basically for clustering work, to<br />
check if there are any stale nodes, if it has, we will move the assigned jobs over to other node by updating nodeId.</p>
<p>So now, we&#8217;ve seen different Tasks, like Jobs and SchedulerTask. Now, we will need an interface to run these Tasks, hence TaskRunner was introduced.</p>
<pre class="brush: java; title: ; notranslate">
interface TaskRunner {
    public void runTask(Task task);
}
</pre>
<p>Here is the implementation from SimpleScheduler.TaskRunner() method.</p>
<pre class="brush: java; title: ; notranslate">
public void runTask(final Task task) {
    if (task instanceof Job) {
        Job job = (Job)task;
        if( job.detail.getDetailsExt().get(&quot;runnable&quot;) != null ) {
            runPolledRunnable(job);
        } else {
            runJob(job);
        }
    } else if (task instanceof SchedulerTask) {
        _exec.submit(new Callable() {
            public Void call() throws Exception {
                try {
                    ((SchedulerTask) task).run();
                } catch (Exception ex) {
                    __log.error(&quot;Error during SchedulerTask execution&quot;, ex);
                }
                return null;
            }
        });
    }
}
</pre>
<p>As I said before, once we&#8217;ve start BpelServer, we will start a thread running, it only gets stopped only when the BpelServer is been stopped.<br />
Thats called SchedulerThread.</p>
<p>&nbsp;</p>
<p>In this class, basically we had following members: PriorityBlockingQueue, this is queue for the immediate execution. TaskRunner, this is the<br />
container for running Task. The logic for the running is quite straight forward.</p>
<pre class="brush: java; title: ; notranslate">
/**
 * Pop items off the todo queue, and send them to the task runner for processing.
 */
public void run() {
    while (!_done) {
        _lock.lock();
        try {
            long nextjob;
            while ((nextjob = nextJobTime()) &amp;gt; 0 &amp;amp;&amp;amp; !_done)
                _activity.await(nextjob, TimeUnit.MILLISECONDS);

            if (!_done &amp;amp;&amp;amp; nextjob == 0) {
                Task task = _todo.take();
                _taskrunner.runTask(task);

            }
        } catch (InterruptedException ex) {
            ; // ignore
        } finally {
            _lock.unlock();
        }
    }
}
</pre>
<p>Now that we&#8217;ve seen all of important APIs here, we will look at how we start SimpleScheduler when ODEServer is started.<br />
excerpt from SimpleScheduler.start() method.</p>
<pre class="brush: java; title: ; notranslate">
public synchronized void start() {
    if (_running)
        return;

    if (_exec == null)
        _exec = Executors.newCachedThreadPool();

    _todo.clearTasks(UpgradeJobsTask.class);
    _todo.clearTasks(LoadImmediateTask.class);
    _todo.clearTasks(CheckStaleNodes.class);
    _processedSinceLastLoadTask.clear();
    _outstandingJobs.clear();

    _knownNodes.clear();

    try {
        execTransaction(new Callable() {

            public Void call() throws Exception {
                _knownNodes.addAll(_db.getNodeIds());
                return null;
            }

        });
    } catch (Exception ex) {
        __log.error(&quot;Error retrieving node list.&quot;, ex);
        throw new ContextException(&quot;Error retrieving node list.&quot;, ex);
    }

    long now = System.currentTimeMillis();

    // Pretend we got a heartbeat...
    for (String s : _knownNodes) _lastHeartBeat.put(s, now);

    // schedule immediate job loading for now!
    _todo.enqueue(new LoadImmediateTask(now));

    // schedule check for stale nodes, make it random so that the nodes don't overlap.
    _todo.enqueue(new CheckStaleNodes(now + randomMean(_staleInterval)));

    // do the upgrade sometime (random) in the immediate interval.
    _todo.enqueue(new UpgradeJobsTask(now + randomMean(_immediateInterval)));

    _todo.start();
    _running = true;
}
</pre>
<p>Also, please noted that we had two different types of JobProcessor, one is ordinary JobProcessor, the other one is PolledRunnableJobProcessor, which is meant for running some jobs that gets run periodically.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2010/07/26/exploring-ode-part-v-implemenation-of-scheduler-simple-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Roadmap on Mac OS X</title>
		<link>http://jeff.familyyu.net/2010/07/23/my-roadmap-on-mac-os-x/</link>
		<comments>http://jeff.familyyu.net/2010/07/23/my-roadmap-on-mac-os-x/#comments</comments>
		<pubDate>Thu, 22 Jul 2010 23:51:00 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Mac OSX]]></category>

		<guid isPermaLink="false">http://jeffyuchang.wordpress.com/2010/07/23/my-roadmap-on-mac-os-x</guid>
		<description><![CDATA[Just like what I did for my fedora roadmap, here comes my Mac OS X one. 1. Instant message: Adium, http://adium.im/ 2. video chat: skype, http://www.skype.com 3. irc client, colloquy, http://colloquy.info/ 4. chinese input, just use the built-in one directly, here is an post about the chinese input, and also can use the chinese language [...]]]></description>
			<content:encoded><![CDATA[<p>Just like what I did for <a href="http://jeff.familyyu.net/2008/05/my-fedora8-roadmap-on-t61p.html">my fedora roadmap</a>, here comes my Mac OS X one.</p>
<p>1. Instant message: Adium, <a href="http://adium.im/">http://adium.im/</a><br />
2. video chat: skype, <a href="http://www.skype.com/">http://www.skype.com</a><br />
3. irc client, colloquy, <a href="http://colloquy.info/">http://colloquy.info/</a><br />
4. chinese input, just use the built-in one directly, here is an post about the chinese input, and also can use the chinese language for the whole mac osx. <a href="http://appleclinic.wordpress.com/2008/04/16/chinese-text-input/">http://appleclinic.wordpress.com/2008/04/16/chinese-text-input/</a><br />
5. firefox, In case you still like to use the firefox in your mac box, yes, it works great. <a href="http://www.firefox.com/">http://www.firefox.com</a><br />
6. twitter client, twitterrific: <a href="http://iconfactory.com/software/twitterrific">http://iconfactory.com/software/twitterrific</a><br />
7. QQ, this one should be very china specific, <img src='http://jeff.familyyu.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , good news is that we do have a <a href="http://im.qq.com/qq/mac/download.shtml">Mac OS X QQ</a> as beta right now.<br />
8. QuickSilver, this is a new tool compared to what I had in both windows and linux, it makes people really easy to start application, you can download and install it from here. <a href="http://www.blacktree.com/">http://www.blacktree.com/</a><br />
9. Textmate, this one is a lot of rubyists choice on doing ruby on rails.. <a href="http://macromates.com/">http://macromates.com/</a>, not free though.<br />
10. Skitch, <a href="http://skitch.com/">http://skitch.com/</a>, make it easy to share screenshot etc.<br />
11. <a href="http://www.eclipse.org/">Eclipse</a>, this is still my preference for java programming.<br />
12. <a href="http://www.macports.org/install.php">Macports</a>, this is a utility more like Fedora&#8217;s Yum, Ubuntu&#8217;s apt-get.<br />
13. <a href="http://growl.info/">Growl</a>, this is a great software for the notifications.<br />
14. <a href="http://growl.info/">dropbox</a>, this is a pretty good software if you want to sync stuff between mac and iphone.</p>
<p>If you want to install JDK5 in the snow leopard, here is a good solution to this problem, <a href="http://www.scribd.com/doc/22853741/Installing-Java-5-Back-on-Snow-Leopard">http://www.scribd.com/doc/22853741/Installing-Java-5-Back-on-Snow-Leopard</a>, Here I&#8217;d like to thank <a href="http://kurtstam.blogspot.com/">Kurt</a>, strong, liweinan for making some suggestions on these softwares. <img src='http://jeff.familyyu.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>At last, this is what I had, <a href="http://skitch.com/jeffyu/dp3pm/fullscreen">http://skitch.com/jeffyu/dp3pm/fullscreen</a>. <img src='http://jeff.familyyu.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>please let me know what else you believe that I should try out.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2010/07/23/my-roadmap-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploring ODE Part IV: BpelServer API</title>
		<link>http://jeff.familyyu.net/2010/02/21/exploring-ode-part-iv-bpelserver-api/</link>
		<comments>http://jeff.familyyu.net/2010/02/21/exploring-ode-part-iv-bpelserver-api/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 15:22:00 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[BPM]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ODE]]></category>
		<category><![CDATA[RiftSaw]]></category>

		<guid isPermaLink="false">http://jeffyuchang.wordpress.com/2010/02/21/exploring-ode-part-iv-bpelserver-api</guid>
		<description><![CDATA[If you look at the ODE source code, the BpelServer API is a very important one. In this entry, we will look at the class that how we use the BpelServer, for the ODE, lets look at the ODEServer source code. __log.debug("Initializing transaction manager"); initTxMgr(); __log.debug("Creating data source."); initDataSource(); __log.debug("Starting DAO."); initDAO(); EndpointReferenceContextImpl eprContext = [...]]]></description>
			<content:encoded><![CDATA[<p>If you look at the ODE source code, the BpelServer API is a very important one. In this entry, we will look at the class that how we use the BpelServer, for the ODE, lets look at the <a href="http://svn.apache.org/repos/asf/ode/trunk/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java">ODEServer</a> source code.</p>
<pre class="brush:java"> __log.debug("Initializing transaction manager");
 initTxMgr();
__log.debug("Creating data source.");
initDataSource();
__log.debug("Starting DAO.");
initDAO();
EndpointReferenceContextImpl eprContext = new EndpointReferenceContextImpl(this);                __log.debug("Initializing BPEL process store.");
initProcessStore(eprContext);
__log.debug("Initializing BPEL server.");
initBpelServer(eprContext);
 __log.debug("Initializing HTTP connection manager");
 initHttpConnectionManager();

// Register BPEL event listeners configured in axis2.properties file.
registerEventListeners();
registerMexInterceptors();
registerContextInterceptors();        .....</pre>
<p>As above code shown:</p>
<ul>
<li>Initialized the TransactionManager, which will be used in the datasource and scheduler service.</li>
<li>Created the data source.</li>
<li>Created the DAOConnectionFactory, the extension API is BpelDAOConnectionFactory.</li>
<li>Created the EndpointReferenceContext, which takes care of resolving EndpointReference.</li>
<li>Created the Process Store, it takes care of process deploying, undeploying, list etc.</li>
<li>Initializing the BpelServer, includes following actions: setMessageExchangeContext, setDaoConnectionFactory, setBindingContext, the BindingContext and the MessageExchangeContext are the extension points for communicating with partner services.</li>
<li>Register the EventListners, MexInterceptors etc, these are all the APIs in BpelServer.</li>
</ul>
<p>You also could see how we initialize the BpelServer in the <a href="http://svn.apache.org/repos/asf/ode/trunk/engine/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java">MockBpelServer</a> class. In the <a href="http://www.jboss.org/riftsaw">Riftsaw project</a>,it is in the <a href="http://anonsvn.jboss.org/repos/riftsaw/trunk/runtime/engine/src/main/java/org/jboss/soa/bpel/runtime/engine/ode/BPELEngineImpl.java">BpelEngineImpl</a> class. In the Riftsaw project, we are adding another implementation for the ProcessStore that leverages the JBoss Application Server&#8217;s Deployer mechanism, also we adding another implementation for the BindingContext that use the JAXWS based approach, which used the JBossWS to accomplish.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2010/02/21/exploring-ode-part-iv-bpelserver-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache CXF Web Service Development book.</title>
		<link>http://jeff.familyyu.net/2010/02/20/apache-cxf-web-service-development-book/</link>
		<comments>http://jeff.familyyu.net/2010/02/20/apache-cxf-web-service-development-book/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 04:16:00 +0000</pubDate>
		<dc:creator>Jeff Yu</dc:creator>
				<category><![CDATA[SOA]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[Book]]></category>
		<category><![CDATA[CXF]]></category>
		<category><![CDATA[Review]]></category>

		<guid isPermaLink="false">http://jeffyuchang.wordpress.com/2010/02/20/apache-cxf-web-service-development-book</guid>
		<description><![CDATA[I was invited to review the new book about Apache CXF from packtpub, it is called《Apache CXF Web Service Development》by Naveen Balani and Rajeev Hathi. From the table of content, it covers both web service and restful service in CXF, also had three chapters for the CXF&#8217;s frontend, transport, interceptors, invoke etc, which are the [...]]]></description>
			<content:encoded><![CDATA[<div style="float: left;"><a href="http://www.packtpub.com/apache-cxf-web-service-development/book"><img src="http://1.bp.blogspot.com/_4KnaH_XIr1w/S39lQ7I8BxI/AAAAAAAACSk/fw76wxZFwuw/s400/cxf-ws-dev.png" border="0" alt="" /></a></div>
<div style="margin-left: 120px;">
<p>I was invited to review the new book about <a href="http://cxf.apache.org/">Apache CXF</a> from packtpub, it is called《<a href="http://www.packtpub.com/apache-cxf-web-service-development/book">Apache CXF Web Service Development</a>》by <a title="Naveen Balani" href="http://www.packtpub.com/author_view_profile/id/410">Naveen Balani</a> and                     <a title="Rajeev Hathi" href="http://www.packtpub.com/author_view_profile/id/411">Rajeev Hathi</a>.</p>
<p>From the table of content, it covers both web service and restful service in CXF, also had three chapters for the CXF&#8217;s frontend, transport, interceptors, invoke etc, which are the essential concepts of CXF&#8217;s architecture. So it definitely seems interesting to me. I will post more detailed review once I finished the book.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jeff.familyyu.net/2010/02/20/apache-cxf-web-service-development-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

