<?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>Transient Technology &#187; api</title>
	<atom:link href="http://martinaharris.com/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://martinaharris.com</link>
	<description>Next time you look it might be gone</description>
	<lastBuildDate>Tue, 24 Jan 2012 18:14:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Unit Testing with a GigaSpaceFactoryBean</title>
		<link>http://martinaharris.com/2010/05/unit-testing-gigaspacefactorybean/</link>
		<comments>http://martinaharris.com/2010/05/unit-testing-gigaspacefactorybean/#comments</comments>
		<pubDate>Mon, 24 May 2010 10:29:26 +0000</pubDate>
		<dc:creator>Martin Harris</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[gigaspacefactorybean]]></category>
		<category><![CDATA[gigaspaces]]></category>
		<category><![CDATA[junit]]></category>

		<guid isPermaLink="false">http://martinaharris.com/?p=976</guid>
		<description><![CDATA[I was talking to Shay Banon (Gigaspace Software Architect) he mentioned using GigaSpaceFactoryBean for writing gigaspace unit tests. I could find no examples on their site, although I concede it may be there somewhere. This shows post shows a simple &#8230; <a href="http://martinaharris.com/2010/05/unit-testing-gigaspacefactorybean/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was talking to <span class="conn-name">Shay </span><span class="conn-name">Banon</span> (Gigaspace Software Architect) he mentioned using GigaSpaceFactoryBean for writing gigaspace unit tests.  I could find no examples on their site, although I concede it may be there somewhere.  This shows post shows a simple example.</p>
<p>He also mentioned using the admin api to do full end to end integration testing.  The admin api has huge potential as its able to control gigaspace containers, deploy into them and collect statistics.  Its a powerful api.</p>
<p>This is documented on their site: <a title="GS Admin API" href="http://www.gigaspaces.com/wiki/display/XAP7/Administration+and+Monitoring+API" target="_blank">http://www.gigaspaces.com/wiki/display/XAP7/Administration+and+Monitoring+API</a><br />
<span id="more-976"></span></p>
<h2>Example unit test using GigaSpaceFactoryBean</h2>
<p>The GigaSpaceFactoryBean does have javadoc: <a title="GIgaSpaceFactoryBean API" href="http://www.gigaspaces.com/docs/JavaDoc7.1/index.html" target="_blank">http://www.gigaspaces.com/docs/JavaDoc7.1/index.html</a>.  It can be used to provide a unit test with a gigaspace implementation for the duration of the test.</p>
<h3>Step 1 Provide a spring definition of the GigaSpaceFactoryBean</h3>
<pre class="brush: xml; gutter: false">&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:os-core="http://www.openspaces.org/schema/core"
xmlns:os-events="http://www.openspaces.org/schema/events"
xmlns:os-remoting="http://www.openspaces.org/schema/remoting"
xmlns:os-sla="http://www.openspaces.org/schema/sla"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.openspaces.org/schema/core http://www.openspaces.org/schema/core/openspaces-core.xsd
http://www.openspaces.org/schema/events http://www.openspaces.org/schema/events/openspaces-events.xsd
http://www.openspaces.org/schema/remoting http://www.openspaces.org/schema/remoting/openspaces-remoting.xsd
http://www.openspaces.org/schema/sla http://www.openspaces.org/schema/sla/openspaces-sla.xsd"&gt;

&lt;os-core:local-tx-manager id="gs.transactionManager" space="testGigaSpace" default-timeout="1000" /&gt;
&lt;os-core:space id="testGigaSpace" url="/./my-test-pu" /&gt;

&lt;bean id="gigaSpace"&gt;
&lt;property name="space" ref="testGigaSpace" /&gt;
&lt;property name="transactionManager" ref="gs.transactionManager" /&gt;
&lt;/bean&gt;</pre>
<p>Follow with other beans needed by the test.  I.e service beans and their dependencies.  Note that the space defined here will also need to be injected into services that need it.  So you will need to use the same bean id.  Careful separation of the spring files means you will be able to substitute a test space for the real one during testing.</p>
<h3>Step 2 Write a unit test</h3>
<pre class="brush: java; gutter: false; wrap-lines: false">@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/somewhere/sometest-pu.xml")
public class SomeGigaspaceTest {

    @Resource
	private ServiceUnderTest myservice;

    @Resource
    private GigaSpace gigaSpace;

    @Before
    public void setUp() {

        // Setup anything you may wish to be
        // in the space before the test starts.
        this.gigaSpace.write(stuff);

    }

    @Test
    public void testSomething() throws InterruptedException {

        ImmutableSet dataFromGS = this.myservice.getStuff();
        assertFalse(dataFromGS.isEmpty());
        assertThat(dataFromGS.size(), is(100));

    }</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F&amp;title=Unit+Testing+with+a+GigaSpaceFactoryBean" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F&amp;title=Unit+Testing+with+a+GigaSpaceFactoryBean" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F&amp;title=Unit+Testing+with+a+GigaSpaceFactoryBean" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F&amp;headline=Unit+Testing+with+a+GigaSpaceFactoryBean" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Unit+Testing+with+a+GigaSpaceFactoryBean&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Unit+Testing+with+a+GigaSpaceFactoryBean&amp;u=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Unit+Testing+with+a+GigaSpaceFactoryBean&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Unit+Testing+with+a+GigaSpaceFactoryBean&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Unit+Testing+with+a+GigaSpaceFactoryBean&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F&amp;title=Unit+Testing+with+a+GigaSpaceFactoryBean&amp;summary=&amp;source=" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F05%2Funit-testing-gigaspacefactorybean%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div><div class="dzone_button" style="float: right; margin-left: 5px;">
<script type="text/javascript">
var dzone_url = 'http://martinaharris.com/2010/05/unit-testing-gigaspacefactorybean/';
var dzone_title = 'Unit Testing with a GigaSpaceFactoryBean';
var dzone_blurb = '';
var dzone_style = '2';
</script>
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script>
</div>]]></content:encoded>
			<wfw:commentRss>http://martinaharris.com/2010/05/unit-testing-gigaspacefactorybean/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gigaspace API design &#8211; the GigaSpace write method</title>
		<link>http://martinaharris.com/2010/01/gigaspace-api-design-the-gigaspace-write-method/</link>
		<comments>http://martinaharris.com/2010/01/gigaspace-api-design-the-gigaspace-write-method/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 05:00:00 +0000</pubDate>
		<dc:creator>Martin Harris</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[gigaspaces]]></category>

		<guid isPermaLink="false">http://martinaharris.com/?p=609</guid>
		<description><![CDATA[Gigaspaces is an excellent product.  Supplying a flexible cache, the ability to run processes, underpinned with spring, good desktop space management tools and some well thought out configurable and scalable architectures.  The documentation and programmers api design could do with some effort though.  Lets take a look at the GigaSpace interface and the design of the write method as a small example where improvement is much needed. <a href="http://martinaharris.com/2010/01/gigaspace-api-design-the-gigaspace-write-method/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Now don&#8217;t get me wrong, I like gigaspaces and I am not into bashing someones API for the sake of it.  Take a look at the GigaSpace interface documented in javadoc: <a title="Gigaspace JavaDoc" href="http://www.gigaspaces.com/docs/JavaDoc7.1/org/openspaces/core/GigaSpace.html" target="_blank">http://www.gigaspaces.com/docs/JavaDoc7.1/org/openspaces/core/GigaSpace.html</a> Its time the API was cleaned up.  Take the write method for instance:</p>
<pre>&lt;T&gt; <a title="interface in com.j_spaces.core" href="http://www.gigaspaces.com/docs/JavaDoc7.1/com/j_spaces/core/LeaseContext.html" target="_blank">LeaseContext</a>&lt;T&gt; <strong>write</strong>(T entry,
                          long lease,
                          long timeout,
                          int modifiers)
                      throws <a title="class or interface in org.springframework.dao" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/dao/DataAccessException.html" target="_blank">DataAccessException</a></pre>
<p>These are the things I dislike about it:<br />
<span id="more-609"></span></p>
<ul>
<li>The long timeout and lease don&#8217;t have units declared.  See my previous blog where <a title="How to supply a duration to an api" href="/2010/01/timeunit-its-brill/" target="_blank">I show a good way to supply durations</a>.</li>
<li>The documentation is terrible, it does not mention what units the timeout are in, I had to navigate to LeaseContext to understand the lease, and find  Lease.FOREVER.  As I write this I still do not know how to set a maximum or minimum timeout.  Perhaps 0, null?  Not sure.  What happens if you set a minus value?</li>
<li>The method has a mode in the form of modifiers.  Modifiers is a bad name but I would rather delete it than change the name.  The mode is not a great way to communicate what your method does, but this one is particularly bad because it can effect what might be returned and possibly the types of exception that might get thrown.</li>
<p style="padding-left: 60px;"><a href="http://www.gigaspaces.com/docs/JavaDoc7.1/com/j_spaces/core/client/UpdateModifiers.html#UPDATE_OR_WRITE"><code>UpdateModifiers.UPDATE_OR_WRITE</code></a> .  If your very lucky you might get a lease back.  If you have successfully written (a new object or object with no id.) you get null.  If you update the lease contains the previous value.  But hang on there is a flag!  I hate flags.  The NoWriteLease if set causes the method to return null in all situations.  I wonder how you set that, the documentation has no link.</p>
<p style="padding-left: 60px;"><a href="http://www.gigaspaces.com/docs/JavaDoc7.1/com/j_spaces/core/client/UpdateModifiers.html#WRITE_ONLY"><code>UpdateModifiers.WRITE_ONLY<br />
</code></a> Could throw EntryAlreadyInSpaceException for objects that have an id and your writing a duplicate.</p>
<p style="padding-left: 60px;">So as you can see, if I call this method changing the mode might mean I have to change the post execution traps, null handling etc.  Very easy to introduce a bug inadvertently.</p>
<p>If anyone from GigaSpace or OpenSpace is reading, sorry but its been a long day and I had to walk 4 miles through the snow to get home!  While you amending the API onto an otherwise excellent product, could you update your more general documentaiton.  Its very use case based.  This is great when my use case matches your documentation, but most of the time this is not the case.  So it becomes a nightmare picking pieces from here and there hoping its all going to work.  I drive everything from tests but it gets a bit tedious when my tests fail because my assumptions are wrong.</p>
<li>UpdateModifiers is also not an enum but a constants class.  As such the evil modifier is not even type or boundary safe.</li>
</ul>
<p>Anyway before this blog turns into a rant.  It may already be too late, sorry.  <img src='http://martinaharris.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<h2>For discussion &#8211; Suggestion for a new API</h2>
<pre class="brush: java; gutter: false; wrap-lines: false">write(T entry
    , long lease, TimeUnit leaseUnit
    , long timeout, TimeUnit timeoutUnit)

writeOrUpdate(T entry
    , long lease, TimeUnit leaseUnit
    , long timeout, TimeUnit timeoutUnit)

update(T entry
    , long lease, TimeUnit leaseUnit
    , long timeout, TimeUnit timeoutUnit)

partialUpdate(T entry
    , long lease, TimeUnit leaseUnit
    , long timeout, TimeUnit timeoutUnit)</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F&amp;title=Gigaspace+API+design+-+the+GigaSpace+write+method" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F&amp;title=Gigaspace+API+design+-+the+GigaSpace+write+method" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F&amp;title=Gigaspace+API+design+-+the+GigaSpace+write+method" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F&amp;headline=Gigaspace+API+design+-+the+GigaSpace+write+method" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Gigaspace+API+design+-+the+GigaSpace+write+method&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Gigaspace+API+design+-+the+GigaSpace+write+method&amp;u=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Gigaspace+API+design+-+the+GigaSpace+write+method&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Gigaspace+API+design+-+the+GigaSpace+write+method&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Gigaspace+API+design+-+the+GigaSpace+write+method&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F&amp;title=Gigaspace+API+design+-+the+GigaSpace+write+method&amp;summary=&amp;source=" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Fgigaspace-api-design-the-gigaspace-write-method%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div><div class="dzone_button" style="float: right; margin-left: 5px;">
<script type="text/javascript">
var dzone_url = 'http://martinaharris.com/2010/01/gigaspace-api-design-the-gigaspace-write-method/';
var dzone_title = 'Gigaspace API design &#8211; the GigaSpace write method';
var dzone_blurb = '';
var dzone_style = '2';
</script>
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script>
</div>]]></content:encoded>
			<wfw:commentRss>http://martinaharris.com/2010/01/gigaspace-api-design-the-gigaspace-write-method/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>TimeUnit use it more of the Time please!</title>
		<link>http://martinaharris.com/2010/01/timeunit-its-brill/</link>
		<comments>http://martinaharris.com/2010/01/timeunit-its-brill/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 20:45:49 +0000</pubDate>
		<dc:creator>Martin Harris</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[software quality]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[setter]]></category>
		<category><![CDATA[TimeUnit]]></category>

		<guid isPermaLink="false">http://martinaharris.com/?p=600</guid>
		<description><![CDATA[Time for my first blog of the year. Yea! Mind you its a bit small, but then perhaps that is a good thing. Look at these two setters. Setter methods like the first example are very common. Take a look &#8230; <a href="http://martinaharris.com/2010/01/timeunit-its-brill/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Time for my first blog of the year.  Yea!  Mind you its a bit small, but then perhaps that is a good thing.</p>
<p>Look at these two setters.  Setter methods like the first example are very common.  Take a look at the second its so much better.  With the second the responsibility to convert is neatly delegated to another class instead of forcing the user of the api to work it out.  In addition the programmer can supply hours, minutes or any other that TimeUnit supports.</p>
<pre class="brush: java; light: true">
public void setDuration(long durationInMs) {
    this.duration = durationInMs;
}

public void setDuration(long duration, TimeUnit timeUnit) {
    this.duration = timeUnit.toMillis(duration);
}﻿
</pre>
<p>TimeUnit was brought to you by: java.util.concurrent.TimeUnit!  Its handy, so use it!  <img src='http://martinaharris.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F&amp;title=TimeUnit+use+it+more+of+the+Time+please%21" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F&amp;title=TimeUnit+use+it+more+of+the+Time+please%21" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F&amp;title=TimeUnit+use+it+more+of+the+Time+please%21" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F&amp;headline=TimeUnit+use+it+more+of+the+Time+please%21" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=TimeUnit+use+it+more+of+the+Time+please%21&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=TimeUnit+use+it+more+of+the+Time+please%21&amp;u=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=TimeUnit+use+it+more+of+the+Time+please%21&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=TimeUnit+use+it+more+of+the+Time+please%21&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=TimeUnit+use+it+more+of+the+Time+please%21&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F&amp;title=TimeUnit+use+it+more+of+the+Time+please%21&amp;summary=&amp;source=" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fmartinaharris.com%2F2010%2F01%2Ftimeunit-its-brill%2F" target="_blank"><img class="lightsocial_img" src="http://martinaharris.com/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div><div class="dzone_button" style="float: right; margin-left: 5px;">
<script type="text/javascript">
var dzone_url = 'http://martinaharris.com/2010/01/timeunit-its-brill/';
var dzone_title = 'TimeUnit use it more of the Time please!';
var dzone_blurb = '';
var dzone_style = '2';
</script>
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script>
</div>]]></content:encoded>
			<wfw:commentRss>http://martinaharris.com/2010/01/timeunit-its-brill/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

