<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1559840812483088227</id><updated>2024-09-28T19:32:22.751-07:00</updated><category term="Java"/><category term="clojure"/><category term="Android"/><category term="CISSP"/><category term="OpenSSL"/><category term="Programming"/><category term="Spring"/><category term="Algorithm"/><category term="Functional Programming"/><category term="SSL"/><category term="TLS"/><category term="Access Controls"/><category term="Asymmetric"/><category term="Encryption"/><category term="Handshaking"/><category term="Layout"/><category term="RHCSA"/><category term="Symmetric"/><category term="TCP"/><category term="UDP"/><category term="authentication"/><category term="ACK"/><category term="ARP"/><category term="Administrative"/><category term="Ant"/><category term="BASH"/><category term="Biometrics"/><category term="Block Cipher"/><category term="Browser"/><category term="C language"/><category term="Cipher"/><category term="Citrix"/><category term="Concurrency"/><category term="Confidentiality"/><category term="Cookies"/><category term="DCCP"/><category term="DSA"/><category term="DTLS"/><category term="Design Patterns"/><category term="GCC"/><category term="Gradle"/><category term="Groovy"/><category term="Hard Drives"/><category term="Http Only"/><category term="Hypervisor"/><category term="ICMP"/><category term="IKE"/><category term="IPsec"/><category term="IPv4"/><category term="IPv6"/><category term="Integrity"/><category term="JAX-B"/><category term="JConsole"/><category term="JMX"/><category term="Jersey"/><category term="KVM"/><category term="LPIC"/><category term="LinearLayout"/><category term="MBean"/><category term="MXBean"/><category term="Make"/><category term="NAT"/><category term="Notifications"/><category term="OSI"/><category term="Packets"/><category term="Physical"/><category term="Process"/><category term="Public Key Cryptography"/><category term="RSA"/><category term="Risk"/><category term="SAN"/><category term="SATA"/><category term="SCSI"/><category term="SIP"/><category term="SYN"/><category term="SYN-ACK"/><category term="Security"/><category term="Service"/><category term="Session"/><category term="Stream Cipher"/><category term="TCP/IP"/><category term="Technical"/><category term="Threat"/><category term="Three-way handshake"/><category term="Tunneling"/><category term="UI"/><category term="VM"/><category term="VPN"/><category term="View"/><category term="ViewGroup"/><category term="Virtualisation"/><category term="Vulnerabilities"/><category term="X.509"/><category term="XJC"/><category term="XML"/><category term="Xen"/><category term="Zombie"/><category term="atom"/><category term="css"/><category term="defence-in-depth"/><category term="expand"/><category term="ffmpeg"/><category term="find"/><category term="passwords"/><category term="something you are"/><category term="something you have"/><category term="something you know"/><category term="tokens"/><category term="web-design"/><title type='text'>snippets of tech</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-2030359933436897085</id><published>2012-11-14T01:20:00.001-08:00</published><updated>2012-11-14T01:21:19.505-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ant"/><category scheme="http://www.blogger.com/atom/ns#" term="Gradle"/><category scheme="http://www.blogger.com/atom/ns#" term="Groovy"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="JAX-B"/><category scheme="http://www.blogger.com/atom/ns#" term="XJC"/><title type='text'>JAXB generation using gradle</title><content type='html'>&lt;h2&gt;Gradle XJC Ant Task&lt;/h2&gt;
&lt;p&gt;I had a problem yesterday with the gradle war task not picking up all our jaxb classes.&lt;br /&gt;
The build phase was correctly creating all the correct java files but wasn&#39;t including them all in the final war which was causing errors on our testing environments but not locally.&lt;br /&gt;
The reason they worked locally was because eclipse compiles its own classes rather than using your build tools copies.&lt;/p&gt;
&lt;script src=&quot;https://gist.github.com/4071113.js?file=build.gradle&quot;&gt;&lt;/script&gt;
&lt;h2&gt;The solution&lt;/h2&gt;
&lt;p&gt;Actually, i&#39;ll start with what the problem actually was. It turns out that gradle or one of its plugins is a bit too clever. We haven&#39;t added the generated sources to the source sets so really speaking we shouldn&#39;t have any compiled jaxb classes. However since we have a direct dependency on some of these classes it has included them for us.&lt;br /&gt;
&lt;br /&gt;
The solution regardless is to add the generated-sources to the sourceSets.&lt;/p&gt;
&lt;script src=&quot;https://gist.github.com/4071154.js?file=build.gradle&quot;&gt;&lt;/script&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/2030359933436897085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/11/jaxb-generation-using-gradle.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/2030359933436897085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/2030359933436897085'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/11/jaxb-generation-using-gradle.html' title='JAXB generation using gradle'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-5860706849625207808</id><published>2012-10-17T12:01:00.000-07:00</published><updated>2012-10-17T12:01:24.141-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><title type='text'>Merge Sort</title><content type='html'>If you have an array of 8 elements, merge sort works by grouping these 8 into 4 sorted sets of 2. The sort is done through sibling pairs.&lt;br /&gt;
&lt;br /&gt;
With these 4 pairs, you pair these with their siblings and take the first elements of each. Compare element 1 in both and place the lowest value in a third new array. You then compare element 1 with element 2 and place the lowest in the third array. This will go on until you are left with single pair merge sorting into a single final array.&lt;br /&gt;
&lt;iframe width=&quot;420&quot; height=&quot;315&quot; src=&quot;http://www.youtube.com/embed/GCae1WNvnZM&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/5860706849625207808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/10/merge-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/5860706849625207808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/5860706849625207808'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/10/merge-sort.html' title='Merge Sort'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/GCae1WNvnZM/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-1111588903247722820</id><published>2012-10-17T11:50:00.001-07:00</published><updated>2012-10-17T11:51:12.310-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><title type='text'>Insertion Sort</title><content type='html'>Insertion sort works by maintaining a fully sorted list and inserting unsorted data one at a time then immediately sorting it.&lt;br /&gt;
&lt;br /&gt;
So to begin with you have a single element, and that is considered sorted.&lt;br /&gt;
Then you add an item to the right of it. You compare these with each other and you might have to swap them. Then you have a sorted list of 2.&lt;br /&gt;
Then you add another item to the right of your list. You compare this with the one before it, if they&#39;re already sorted then you&#39;re done comparing for that iteration, otherwise swap them and move to the left. This goes on till you have no more data to insert.&lt;br /&gt;
&lt;br /&gt;
&lt;iframe width=&quot;420&quot; height=&quot;315&quot; src=&quot;http://www.youtube.com/embed/c4BRHC7kTaQ&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/1111588903247722820/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/10/insertion-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1111588903247722820'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1111588903247722820'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/10/insertion-sort.html' title='Insertion Sort'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/c4BRHC7kTaQ/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-3442114839314639183</id><published>2012-10-17T11:43:00.000-07:00</published><updated>2012-10-17T11:43:39.789-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><title type='text'>Bubble Sort</title><content type='html'>Bubble sort is a simple sorting algorithm that compares the first two elements in the array and keeps hold of the largest, for each pass the largest will &#39;bubble&#39; to the top. Each pass will require n-i comparisons.&lt;br /&gt;
&lt;br /&gt;
This algorithm is considered O(N^2)</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/3442114839314639183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/10/bubble-sort.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/3442114839314639183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/3442114839314639183'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/10/bubble-sort.html' title='Bubble Sort'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-4261809617313633712</id><published>2012-09-02T04:46:00.000-07:00</published><updated>2012-09-02T04:46:24.080-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clojure"/><title type='text'>Clojure multimethods</title><content type='html'>&lt;h2&gt;Defmulti&lt;/h2&gt;
&lt;p&gt;Defmulti defines a multimethod call, the methods don&#39;t need to be defined yet. It can be as simple as the following&lt;/p&gt;
&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;(&lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;defmulti &lt;/span&gt;&lt;span style=&quot;color: #906030&quot;&gt;salutation&lt;/span&gt; &lt;span style=&quot;color: #A06000&quot;&gt;:gender&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;/code&gt;
&lt;p&gt;With this defined now, we can add conditions in the form of multimethods&lt;/p&gt;

&lt;h2&gt;Defmethod&lt;/h2&gt;
&lt;p&gt;To add a condition to this we can use the following&lt;/p&gt;
&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;(&lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;defmethod &lt;/span&gt;&lt;span style=&quot;color: #906030&quot;&gt;salutation&lt;/span&gt; &lt;span style=&quot;color: #A06000&quot;&gt;:f&lt;/span&gt; [&lt;span style=&quot;color: #906030&quot;&gt;_&lt;/span&gt;] &lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;Madam&amp;quot;&lt;/span&gt;)
(&lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;defmethod &lt;/span&gt;&lt;span style=&quot;color: #906030&quot;&gt;salutation&lt;/span&gt; &lt;span style=&quot;color: #A06000&quot;&gt;:m&lt;/span&gt; [&lt;span style=&quot;color: #906030&quot;&gt;_&lt;/span&gt;] &lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;Sir&amp;quot;&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;/code&gt;
&lt;p&gt;This allows us to make calls to the function and have it transparently dispatch to the correct function based on the gender keyword in the map.&lt;/p&gt;
&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;(&lt;span style=&quot;color: #0060B0; font-weight: bold&quot;&gt;salutation&lt;/span&gt; {&lt;span style=&quot;color: #A06000&quot;&gt;:name&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;Kirsty&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #A06000&quot;&gt;:gender&lt;/span&gt; &lt;span style=&quot;color: #A06000&quot;&gt;:f&lt;/span&gt;})
&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;Madam&amp;quot;&lt;/span&gt;
(&lt;span style=&quot;color: #0060B0; font-weight: bold&quot;&gt;salutation&lt;/span&gt; {&lt;span style=&quot;color: #A06000&quot;&gt;:name&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;Josh&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #A06000&quot;&gt;:gender&lt;/span&gt; &lt;span style=&quot;color: #A06000&quot;&gt;:m&lt;/span&gt;})
&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;Sir&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/4261809617313633712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/09/clojure-multimethods.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/4261809617313633712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/4261809617313633712'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/09/clojure-multimethods.html' title='Clojure multimethods'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-2614962396310084788</id><published>2012-09-02T04:21:00.000-07:00</published><updated>2012-09-02T04:21:42.024-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="css"/><category scheme="http://www.blogger.com/atom/ns#" term="web-design"/><title type='text'>Web Design</title><content type='html'>&lt;h2&gt;Web Dev&lt;/h2&gt;
&lt;p&gt;I&#39;ve annoying been lumbered with some front-end web stuff lately. Generally, I protest vehemently at any suggestion of me doing front facing work but this task has got me a bit interested. It probably won&#39;t last.&lt;/p&gt;
&lt;h2&gt;Pseudo&lt;/h2&gt;
&lt;p&gt;There are two kinds of pseudo in CSS: &lt;b&gt;pseudo-classes&lt;/b&gt; and &lt;b&gt;pseudo-elements&lt;/b&gt;&lt;/p&gt;
&lt;h3&gt;Pseudo-classes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;:link&lt;/li&gt;
&lt;li&gt;:visited&lt;/li&gt;
&lt;li&gt;:hover&lt;/li&gt;
&lt;li&gt;:focus&lt;/li&gt;
&lt;li&gt;:active&lt;/li&gt;
&lt;li&gt;:first-child&lt;/li&gt;
&lt;li&gt;:lang()&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Pseudo-elements&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;::first-line&lt;/li&gt;
&lt;li&gt;::first-letter&lt;/li&gt;
&lt;li&gt;::before&lt;/li&gt;
&lt;li&gt;::after&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/2614962396310084788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/09/web-design.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/2614962396310084788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/2614962396310084788'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/09/web-design.html' title='Web Design'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-9072349619038686923</id><published>2012-08-21T09:04:00.001-07:00</published><updated>2012-08-21T09:04:29.656-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Classpath error snippet</title><content type='html'>&lt;h2&gt;File Not Found (Classpath Resource)&lt;/h2&gt;

&lt;p&gt;If this is encountered, either try modifying the classpath or prepending the file location with &#39;&lt;b&gt;file://&lt;/b&gt;&#39;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/9072349619038686923/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/08/classpath-error-snippet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/9072349619038686923'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/9072349619038686923'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/08/classpath-error-snippet.html' title='Classpath error snippet'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-5540469913507033251</id><published>2012-08-21T04:22:00.001-07:00</published><updated>2012-08-21T04:22:15.984-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Jersey"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><title type='text'>Spring Jersey Contrib</title><content type='html'>&lt;h2&gt;Adding Jersey to a spring webapp&lt;/h2&gt;
&lt;p&gt;Since jersey has its own servlet that would normally take the REST requests, it&#39;s difficult to wire this in with Spring beans. That&#39;s where the spring contrib library comes in. Instead of having the &lt;b&gt;WEB-INF/web.xml&lt;/b&gt; use the servlet &lt;b&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/b&gt;, you can use the below &lt;b&gt;com.sun.jersey.spi.spring.container.servlet.SpringServlet&lt;/b&gt;.&lt;/p&gt;

&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;web-app&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
         &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://java.sun.com/xml/ns/javaee&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns:web=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&amp;quot;&lt;/span&gt;
         &lt;span style=&quot;color: #0000C0&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&amp;quot;&lt;/span&gt;
         &lt;span style=&quot;color: #0000C0&quot;&gt;id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;WebApp_ID&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;version=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;2.5&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;context-param&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;param-name&amp;gt;&lt;/span&gt;contextConfigLocation&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/param-name&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;param-value&amp;gt;&lt;/span&gt;classpath:application-context.xml&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/param-value&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/context-param&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;listener&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;listener-class&amp;gt;&lt;/span&gt;org.springframework.web.context.ContextLoaderListener&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/listener-class&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/listener&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet-name&amp;gt;&lt;/span&gt;service&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet-name&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet-class&amp;gt;&lt;/span&gt;com.sun.jersey.spi.spring.container.servlet.SpringServlet&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet-class&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;init-param&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;param-name&amp;gt;&lt;/span&gt;com.sun.jersey.config.feature.DisableWADL&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/param-name&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;param-value&amp;gt;&lt;/span&gt;true&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/param-value&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/init-param&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;init-param&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;param-name&amp;gt;&lt;/span&gt;com.sun.jersey.api.json.POJOMappingFeature&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/param-name&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;param-value&amp;gt;&lt;/span&gt;true&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/param-value&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/init-param&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet-mapping&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet-name&amp;gt;&lt;/span&gt;service&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet-name&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;url-pattern&amp;gt;&lt;/span&gt;/*&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/url-pattern&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet-mapping&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/web-app&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;/code&gt;

&lt;h2&gt;Maven dependency&lt;/h2&gt;
&lt;p&gt;Adding this using maven would consist of the following.&lt;/p&gt;
&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #808080&quot;&gt;&amp;lt;!-- Jersey + Spring --&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;com.sun.jersey.contribs&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;jersey-spring&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;version&amp;gt;&lt;/span&gt;${jersey.version}&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;exclusions&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;exclusion&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/exclusion&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;exclusion&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-core&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/exclusion&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;exclusion&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-web&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/exclusion&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;exclusion&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-beans&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/exclusion&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;exclusion&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-context&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/exclusion&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/exclusions&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/5540469913507033251/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/08/spring-jersey-contrib.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/5540469913507033251'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/5540469913507033251'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/08/spring-jersey-contrib.html' title='Spring Jersey Contrib'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-6858944600752032348</id><published>2012-08-17T16:26:00.000-07:00</published><updated>2012-08-17T16:26:25.309-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><title type='text'>Spring web</title><content type='html'>&lt;h2&gt;Servlets and Naming&lt;/h2&gt;
&lt;p&gt;When defining a spring web project, requests come through to the &lt;b&gt;DispatcherServlet&lt;/b&gt;. Therefor this must be defined in the &lt;b&gt;WEB-INF/web.xml&lt;/b&gt;.&lt;/p&gt;

&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;1
2
3
4
5
6
7
8
9&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet-name&amp;gt;&lt;/span&gt;test&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet-name&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet-class&amp;gt;&lt;/span&gt;org.springframework.web.servlet.DispatcherServlet&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet-class&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet&amp;gt;&lt;/span&gt;
    
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet-mapping&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;servlet-name&amp;gt;&lt;/span&gt;test&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet-name&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;url-pattern&amp;gt;&lt;/span&gt;/&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/url-pattern&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/servlet-mapping&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;/code&gt;

&lt;p&gt;The important thing to note with this config is the name however. The name test is used and will result in spring looking for a &lt;b&gt;WEB-INF/test-servlet.xml&lt;/b&gt;.&lt;/p&gt;

&lt;h2&gt;Components and Config&lt;/h2&gt;
&lt;p&gt;Now that the servlet is defined, the config that goes into spring can be configured. With this example i&#39;m using component scan to pickup beans automatically and i&#39;m specifying the view finder which i&#39;ll explain next.&lt;/p&gt;

&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #507090&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns:mvc=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/mvc&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns:context=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0&quot;&gt;  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0&quot;&gt;  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;context:component-scan&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;base-package=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;com.aphexmunky.web&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #007000&quot;&gt;/&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;mvc:annotation-driven&lt;/span&gt; &lt;span style=&quot;color: #007000&quot;&gt;/&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;mvc:resources&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;location=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;/resources/&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;mapping=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;/resources/**&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #007000&quot;&gt;/&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;bean&lt;/span&gt;
  &lt;span style=&quot;color: #0000C0&quot;&gt;class=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;org.springframework.web.servlet.view.InternalResourceViewResolver&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #007000&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;name=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;prefix&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;value=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;/WEB-INF/views/&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #007000&quot;&gt;/&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;name=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;suffix&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;value=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;.jsp&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #007000&quot;&gt;/&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/beans&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;/code&gt;

&lt;p&gt;So the InternalResourceViewResolver points to locations where spring can find files. Should a bean return a String &quot;home&quot;, it will then as part of it&#39;s view cycle go to /WEB-INF/views/home.jsp to find the content. The jsp could be anything really but here is an example of the bean.&lt;/p&gt;

&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;package&lt;/span&gt; com&lt;span style=&quot;color: #303030&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000C0&quot;&gt;aphexmunky&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000C0&quot;&gt;web&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold&quot;&gt;java.util.Map&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold&quot;&gt;org.springframework.stereotype.Controller&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #0e84b5; font-weight: bold&quot;&gt;org.springframework.web.bind.annotation.RequestMapping&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;;&lt;/span&gt;

&lt;span style=&quot;color: #505050; font-weight: bold&quot;&gt;@Controller&lt;/span&gt;
&lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;class&lt;/span&gt; &lt;span style=&quot;color: #B00060; font-weight: bold&quot;&gt;HomeController&lt;/span&gt; &lt;span style=&quot;color: #303030&quot;&gt;{&lt;/span&gt;
 
 &lt;span style=&quot;color: #505050; font-weight: bold&quot;&gt;@RequestMapping&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;({&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;/&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;/home&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;})&lt;/span&gt;
 &lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;public&lt;/span&gt; String &lt;span style=&quot;color: #0060B0; font-weight: bold&quot;&gt;showHomePage&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;(&lt;/span&gt;Map&lt;span style=&quot;color: #303030&quot;&gt;&amp;lt;&lt;/span&gt;String&lt;span style=&quot;color: #303030&quot;&gt;,&lt;/span&gt; Object&lt;span style=&quot;color: #303030&quot;&gt;&amp;gt;&lt;/span&gt; model&lt;span style=&quot;color: #303030&quot;&gt;)&lt;/span&gt; &lt;span style=&quot;color: #303030&quot;&gt;{&lt;/span&gt;
  model&lt;span style=&quot;color: #303030&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000C0&quot;&gt;put&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;Hello, World!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;);&lt;/span&gt;
  &lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;home&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;;&lt;/span&gt;
 &lt;span style=&quot;color: #303030&quot;&gt;}&lt;/span&gt;
&lt;span style=&quot;color: #303030&quot;&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/6858944600752032348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/08/spring-web.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/6858944600752032348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/6858944600752032348'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/08/spring-web.html' title='Spring web'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-717694444013623257</id><published>2012-08-16T06:19:00.000-07:00</published><updated>2012-08-16T06:19:35.385-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><title type='text'>Spring config</title><content type='html'>&lt;h2&gt;Properties&lt;/h2&gt;
&lt;p&gt;Using properties files is a handy way of externalizing the config without forcing people to play about with spring xml. The easiest way of dealing with this is though &lt;a href=&quot;http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html&quot;&gt;PropertyPlaceholderConfigurer&lt;/a&gt;. You can pass to it a property set of locations which then is a list of locations. See the snippet below.&lt;/p&gt;

&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;1
2
3
4
5
6
7
8&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;class=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;property&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;name=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;locations&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;list&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;value&amp;gt;&lt;/span&gt;classpath:warehouse.adaptor.properties&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;
   &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;value&amp;gt;&lt;/span&gt;classpath:warehouse.adaptor.scheduler.properties&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/value&amp;gt;&lt;/span&gt;
  &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/list&amp;gt;&lt;/span&gt;
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/property&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/bean&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;/code&gt;

&lt;p&gt;These properties can then be referenced through ${}.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/717694444013623257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/08/spring-config.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/717694444013623257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/717694444013623257'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/08/spring-config.html' title='Spring config'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-1614006088895722220</id><published>2012-08-15T14:44:00.000-07:00</published><updated>2012-08-15T14:44:20.428-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><category scheme="http://www.blogger.com/atom/ns#" term="Spring"/><title type='text'>Spring</title><content type='html'>&lt;h2&gt;Spring Wiring&lt;/h2&gt;
&lt;p&gt;To begin wiring spring beans together we need to create an &lt;b&gt;applicationContext.xml&lt;/b&gt;. That looks like this:&lt;/p&gt;

&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #507090&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;default-autowire=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;byType&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;knight&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;class=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;com.aphexmunky.spring.BraveKnight&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #007000&quot;&gt;/&amp;gt;&lt;/span&gt;
 
 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;bean&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;id=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;quest&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;class=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;com.aphexmunky.spring.Quester&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #007000&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/beans&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;/code&gt;

&lt;p&gt;With these two beans explicitly wired, we can create spring and grab our beans out of it.&lt;/p&gt;

&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;1
2&lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;ApplicationContext ac &lt;span style=&quot;color: #303030&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #008000; font-weight: bold&quot;&gt;new&lt;/span&gt; ClassPathXmlApplicationContext&lt;span style=&quot;color: #303030&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;application.xml&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;);&lt;/span&gt;
Knight knight &lt;span style=&quot;color: #303030&quot;&gt;=&lt;/span&gt; ac&lt;span style=&quot;color: #303030&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000C0&quot;&gt;getBean&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;(&lt;/span&gt;Knight&lt;span style=&quot;color: #303030&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #0000C0&quot;&gt;class&lt;/span&gt;&lt;span style=&quot;color: #303030&quot;&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;
&lt;/code&gt;

&lt;h2&gt;Autowiring&lt;/h2&gt;

&lt;p&gt;Autowiring can be done by annotating a private member with &lt;b&gt;@Autowired&lt;/b&gt;. For this to work however the bean still needs to be defined.&lt;/p&gt;
&lt;p&gt;However, there is spring context which can allow us to find beans automatically. The following needs to be added to the spring config file.&lt;/p&gt;

&lt;code&gt;
&lt;!-- HTML generated using hilite.me --&gt;&lt;div style=&quot;background: #ffffff; overflow:auto;width:auto;color:black;background:white;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;&quot;&gt;&lt;pre style=&quot;margin: 0; line-height: 125%&quot;&gt;&lt;span style=&quot;color: #507090&quot;&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;beans&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns:xsi=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;xmlns:context=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/context&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;xsi:schemaLocation=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd&lt;/span&gt;
&lt;span style=&quot;background-color: #fff0f0&quot;&gt;      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd&amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #0000C0&quot;&gt;default-autowire=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;byType&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #007000&quot;&gt;&amp;gt;&lt;/span&gt;

 &lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;context:component-scan&lt;/span&gt; &lt;span style=&quot;color: #0000C0&quot;&gt;base-package=&lt;/span&gt;&lt;span style=&quot;background-color: #fff0f0&quot;&gt;&amp;quot;com.aphexmunky.spring&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #007000&quot;&gt;/&amp;gt;&lt;/span&gt;

&lt;span style=&quot;color: #007000&quot;&gt;&amp;lt;/beans&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/code&gt;

&lt;p&gt;With this configuration, we&#39;ve added spring context to the xml namespace and added &lt;b&gt;context:component-scan&lt;/b&gt; which allows spring to find beans annotated with certain annotations and automatically consider them beans. They are&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;@Component&lt;/li&gt;
&lt;li&gt;@Controller&lt;/li&gt;
&lt;li&gt;@Repository&lt;/li&gt;
&lt;li&gt;@Service&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With these, any bean annotated with one and in the base-package specified can now be instantiated by spring.&lt;/p&gt;

&lt;br /&gt;
&lt;a href=&quot;http://www.springframework.org/schema/&quot;&gt;spring xsd locations&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/1614006088895722220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/08/spring.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1614006088895722220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1614006088895722220'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/08/spring.html' title='Spring'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-4452804198897282594</id><published>2012-08-12T13:13:00.000-07:00</published><updated>2012-08-12T13:13:22.324-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clojure"/><title type='text'>Refs</title><content type='html'>&lt;h2&gt;Updating refs&lt;/h2&gt;
&lt;p&gt;Refs, unlike atoms are a coordinated. They are however like Atoms, synchronous. All updates to refs must be done within a transaction. This can be done by wrapping the changes within a &lt;b&gt;dosync&lt;/b&gt; block.&lt;/p&gt;

&lt;h2&gt;Alter&lt;/h2&gt;
&lt;p&gt;alter is the most like &lt;b&gt;swap!&lt;/b&gt;. It will always be applied in the order designed and it makes no assumptions the re-orderability.&lt;/p&gt;
&lt;h2&gt;Commute&lt;/h2&gt;
&lt;p&gt;Commute is used when the order the changes are applied does not matter. It gets its name from &lt;i&gt;commutative&lt;/i&gt;. Commute never attempts to retry and as such can be significantly faster.&lt;/p&gt;
&lt;h2&gt;Ref-set&lt;/h2&gt;
&lt;p&gt;Ref-set, like alter will retry on values. It is generally only used to to reinitialise refs state to starting values.&lt;/p&gt;

&lt;h2&gt;Validators&lt;/h2&gt;
&lt;p&gt;Validators must return true for a transactional change to take place. They can be applied using &lt;b&gt;:validator fn&lt;/b&gt;.&lt;/p&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA-IsUWs5lufeY1B4_jwxxLKai-qxESmVF0ZdRxecRxujJythYaz_mcpvjhSZk19npQtL-E-0Sj1V4qlrcA8qalr9Wh0409PjkMFoZu_QmssxbaGpauFlAZOsp9o7MlsRjfiVCc4Kg6eQ/s1600/Screen+shot+2012-08-11+at+22.28.28.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left:1em; margin-right:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;229&quot; width=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA-IsUWs5lufeY1B4_jwxxLKai-qxESmVF0ZdRxecRxujJythYaz_mcpvjhSZk19npQtL-E-0Sj1V4qlrcA8qalr9Wh0409PjkMFoZu_QmssxbaGpauFlAZOsp9o7MlsRjfiVCc4Kg6eQ/s400/Screen+shot+2012-08-11+at+22.28.28.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;

&lt;h2&gt;The dark side of STM&lt;/h2&gt;
&lt;p&gt;The problem with all these retries that the STM provides is that it has no idea if what you&#39;re doing is unsafe. If you&#39;re writing to database, you don&#39;t want it written multiple times while another part of your application fails and the whole thing retries. For that reason there is an &lt;b&gt;io!&lt;/b&gt; macro which throws an error if done within a transaction. &lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/4452804198897282594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/08/refs.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/4452804198897282594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/4452804198897282594'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/08/refs.html' title='Refs'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA-IsUWs5lufeY1B4_jwxxLKai-qxESmVF0ZdRxecRxujJythYaz_mcpvjhSZk19npQtL-E-0Sj1V4qlrcA8qalr9Wh0409PjkMFoZu_QmssxbaGpauFlAZOsp9o7MlsRjfiVCc4Kg6eQ/s72-c/Screen+shot+2012-08-11+at+22.28.28.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-7280689741136616169</id><published>2012-08-11T16:06:00.000-07:00</published><updated>2012-08-11T16:06:02.489-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="atom"/><category scheme="http://www.blogger.com/atom/ns#" term="clojure"/><title type='text'>Atoms</title><content type='html'>&lt;h2&gt;Practicality&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Atoms&lt;/b&gt; are uncoordinated and synchronous reference types. Their name comes from the atomic nature. The most common way of manipulating them is through &lt;b&gt;swap!&lt;/b&gt;.&lt;/p&gt;

&lt;code&gt;
&lt;b&gt;(def sarah (atom {:name &quot;Sarah&quot; :age 25 :wears-glasses? false}))&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;(swap! sarah update-in [:age] + 3)&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
&lt;b&gt;(swap! sarah (comp #(update-in % [:age] inc) #(assoc % :wears-glasses? true)))&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
&lt;/code&gt;

&lt;p&gt;Should an atom change during the &lt;b&gt;swap!&lt;/b&gt; operation, it will automatically retry the operation. It will keep retrying until it updates undisturbed.&lt;/p&gt;

&lt;h2&gt;Reset!&lt;/h2&gt;
&lt;p&gt;reset is a way of changing an atoms value with no regard to what its current value is.&lt;/p&gt;

&lt;code&gt;
&lt;b&gt;(reset! sarah :y)&lt;/b&gt;&lt;br /&gt;
:y&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgND_DX_h9mJ0H-Uicg3XYW73-ZCTdxVRJOdJ8Dw9sXebvi-_KsQhM8LGPhclBBojN1a8VaGhWaSHgodo9phWqwsiEPjGs7Yni-X55Af89d1timq9piRM9DAbrbzOWOQG5vQwzL-0SSPO8/s1600/Screen+shot+2012-08-11+at+22.28.28.png&quot; imageanchor=&quot;1&quot; style=&quot;clear:left; float:left;margin-right:1em; margin-bottom:1em&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;229&quot; width=&quot;238&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgND_DX_h9mJ0H-Uicg3XYW73-ZCTdxVRJOdJ8Dw9sXebvi-_KsQhM8LGPhclBBojN1a8VaGhWaSHgodo9phWqwsiEPjGs7Yni-X55Af89d1timq9piRM9DAbrbzOWOQG5vQwzL-0SSPO8/s320/Screen+shot+2012-08-11+at+22.28.28.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/7280689741136616169/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/08/atoms.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/7280689741136616169'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/7280689741136616169'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/08/atoms.html' title='Atoms'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgND_DX_h9mJ0H-Uicg3XYW73-ZCTdxVRJOdJ8Dw9sXebvi-_KsQhM8LGPhclBBojN1a8VaGhWaSHgodo9phWqwsiEPjGs7Yni-X55Af89d1timq9piRM9DAbrbzOWOQG5vQwzL-0SSPO8/s72-c/Screen+shot+2012-08-11+at+22.28.28.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-1173521109796731996</id><published>2012-08-11T13:09:00.000-07:00</published><updated>2012-08-11T13:32:10.317-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clojure"/><category scheme="http://www.blogger.com/atom/ns#" term="Concurrency"/><title type='text'>delays, futures and promise</title><content type='html'>&lt;h2&gt;Delay&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Delay&lt;/b&gt; is a concurrency function that delays the execution of some code until it is wanted.&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(def s (delay (slurp &quot;http://squidoop.blogspot.co.uk/&quot;)))&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;s&lt;/b&gt;&lt;br /&gt;
#&amp;lt;Delay@26e7127: :pending&amp;gt;&lt;br /&gt;
&lt;b&gt;@s&lt;/b&gt;&lt;br /&gt;
&quot;&amp;lt;!DOCTYPE html&amp;gt;\n&amp;lt;ht...&lt;br /&gt;
&lt;/code&gt;
&lt;p&gt;The code takes some time to execute on the first run, however once it is realized it is cached and the next dereference will be typical execution of any string.&lt;/p&gt;

&lt;h2&gt;Future&lt;/h2&gt;
&lt;p&gt;Future is an idiomatic way of creating execution for a new thread. Unlike native Java that requires a implmentation of Runnable for a piece of code, any function wrapped in a future will create and start a new thread but return execution immediately. You can use the ref of the future straight away however it may not be fully realized when you use it.&lt;/p&gt;
&lt;p&gt;Unlike delays however, you can specify a timeout when dereferencing a future.&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(deref (future (Thread/sleep 5000) :done!) 1000 :impatient!)&lt;/b&gt;&lt;br /&gt;
:impatient!
&lt;/code&gt;

&lt;h2&gt;Promise&lt;/h2&gt;
&lt;p&gt;A promise is a completely uninitialised value. You promise to deliver a value to it some point in time later.&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;user=&amp;gt; (def p (promise))&lt;/b&gt;&lt;br /&gt;
#&#39;user/p&lt;br /&gt;
&lt;b&gt;user=&amp;gt; p&lt;/b&gt;&lt;br /&gt;
#&amp;lt;core$promise$reify__6153@5200089: :pending&amp;gt;&lt;br /&gt;
&lt;b&gt;user=&amp;gt; (realized? p)&lt;/b&gt;&lt;br /&gt;
false&lt;br /&gt;
&lt;b&gt;user=&amp;gt; (deliver p 42)&lt;/b&gt;&lt;br /&gt;
#&amp;lt;core$promise$reify__6153@5200089: 42&amp;gt;&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;Combining a future promise&lt;/h2&gt;
&lt;code&gt;
&lt;b&gt;(def a (promise))&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;(def b (promise))&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;(def c (promise))&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;(future (deliver c (+ @a @b)) (println &quot;Delivery complete!&quot;))&lt;/b&gt;&lt;br /&gt;
&lt;/code&gt;
&lt;p&gt;The future can&#39;t deliver because both a and b are unrealised promises. &lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(deliver a 15)&lt;/b&gt;&lt;br /&gt;
;= #&amp;lt;core$promise$reify__5727@56278e83: 15&amp;gt;&lt;br /&gt;
&lt;b&gt;(deliver b 16)&lt;/b&gt;&lt;br /&gt;
; Delivery complete!&lt;br /&gt;
;= #&amp;lt;core$promise$reify__5727@47ef7de4: 16&amp;gt;&lt;br /&gt;
&lt;b&gt;@c&lt;/b&gt;&lt;br /&gt;
;= 31&lt;br /&gt;
&lt;/code&gt;
&lt;p&gt;As soon as both promises have been delivered, the future stops being blocked and the delivery execution happens.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/1173521109796731996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/08/delays-futures-and-promise.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1173521109796731996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1173521109796731996'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/08/delays-futures-and-promise.html' title='delays, futures and promise'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-8053745454684137188</id><published>2012-07-31T16:37:00.000-07:00</published><updated>2012-07-31T16:38:54.093-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clojure"/><category scheme="http://www.blogger.com/atom/ns#" term="Functional Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Partial &amp; Tagged Literals</title><content type='html'>&lt;h2&gt;Partial&lt;/h2&gt;
&lt;p&gt;Partial is a great function. The doc &lt;b&gt;(doc partial)&lt;/b&gt; describes it as taking function &lt;b&gt;f&lt;/b&gt; and fewer than the normal arguments to &lt;b&gt;f&lt;/b&gt;. What is returned is a function that a variable number of remainder args. There are many potential applications and allow you to essentially create duplicate but similar functions without code duplication.&lt;/p&gt;

&lt;code&gt;
&lt;b&gt;(def only-strings (partial filter string?))&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;(only-strings [&quot;first test&quot; :anothertest 3 4 &quot;last test&quot;])&lt;/b&gt;&lt;br /&gt;
(&quot;first test&quot; &quot;last test&quot;)&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;Tagged Literals&lt;/h2&gt;
&lt;p&gt;I mentioned a tagged literal in my last post. Namely the &lt;b&gt;#inst &quot;2012&quot;&lt;/b&gt; part. That convenience is a tagged literal for creating a date. I accidently noticed there&#39;s a new one in the build i&#39;ve done from github. That&#39;s the &lt;b&gt;#uuid&lt;/b&gt; which seems to have appeared from 1.4-alpha4. It appears there aren&#39;t many available beyond that yet but they&#39;re definitely worth keeping an eye on as they&#39;re very handy. Hopefully at some point i&#39;ll do a post on creating your own.&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/8053745454684137188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/partial-tagged-literals.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/8053745454684137188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/8053745454684137188'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/partial-tagged-literals.html' title='Partial &amp; Tagged Literals'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-5118156314467388961</id><published>2012-07-29T14:43:00.001-07:00</published><updated>2012-07-29T17:53:20.542-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clojure"/><category scheme="http://www.blogger.com/atom/ns#" term="Functional Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Focusing on Clojure</title><content type='html'>&lt;h2&gt;Back on Numbers&lt;/h2&gt;
&lt;p&gt;Numbers can be appended with letters that allow you to specify the type.&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(type 1000)&lt;/b&gt;&lt;br /&gt;
java.lang.Long&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;(type 1000N)&lt;/b&gt;&lt;br /&gt;
clojure.lang.BigInt&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;(type 1000M)&lt;/b&gt;&lt;br /&gt;
clojure.lang.BigDecimal&lt;br /&gt;
&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;Map, Reduce &amp; Filter&lt;/h2&gt;
&lt;p&gt;These healthy staples allow you to apply functions to sequences. The usage is dependant on context. I&#39;ll go through each one:&lt;/p&gt;

&lt;h2&gt;Map&lt;/h2&gt;
&lt;p&gt;Map applies a function to a sequence of data and returns a sequence of the same length with the function applied to each&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(map (fn [n] (* n 10)) &#39;(1 2 3 4 5 6 7 8 9 10))&lt;/b&gt;&lt;br /&gt;
(10 20 30 40 50 60 70 80 90 100)&lt;br /&gt;
&lt;/code&gt;
&lt;p&gt;Functions with multiple &lt;b&gt;arity&lt;/b&gt; can also be used. The result of this function is multiplying arg 1 with arg 2. This has given us a list of square numbers.&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(map (fn [n m] (* n m)) (range 1 11) (range 1 11))&lt;/b&gt;&lt;br /&gt;
(1 4 9 16 25 36 49 64 81 100)&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;Reduce&lt;/h2&gt;
&lt;p&gt;Reduce is similar however instead of returning a list of the same size, the goal is to get to a single result. So arg 1 and arg 2 are used in combination to produce a single result, which then becomes arg 1 and #3 becomes arg 2. This is best shown with an example.&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(reduce * (range 1 6))&lt;/b&gt;&lt;br /&gt;
120&lt;br /&gt;
&lt;/code&gt;
&lt;p&gt;To produce that output the following is equivalent:&lt;br /&gt;
((((1 * 2) * 3) * 4) * 5) * 6 =  120&lt;/p&gt;

&lt;h2&gt;Filter&lt;/h2&gt;
&lt;p&gt;Filter is again similar, however the size of the output is variable. You could end up with a list as long as the original or empty or anywhere in between. Filter works by providing a &lt;b&gt;predicate&lt;/b&gt; function with the list and outputs the values of the list where the function returns a truthy value.&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(filter even? (range 1 11))&lt;/b&gt;&lt;br /&gt;
(2 4 6 8 10)&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;ArrayList&lt;/h2&gt;
&lt;p&gt;Since clojure is on the JVM, it can work with java code seemlessly&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(def x (java.util.ArrayList.))&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;(map #(.add x %) (range 1 11))&lt;/b&gt;&lt;br /&gt;
(true true true true true true true true true true)&lt;br /&gt;
&lt;b&gt;x&lt;/b&gt;&lt;br /&gt;
#&amp;lt;ArrayList [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]&amp;gt;&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;Sequential destructuring&lt;/h2&gt;
&lt;p&gt;Vectors can be sequentially destructured as demonstrated here&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(def x [5 10 [3 5] 99.9])&lt;/b&gt;&lt;br /&gt;
[5 10 [3 5] 99.9]&lt;br /&gt;
&lt;b&gt;(let [[a b _] x] (+ a b))&lt;/b&gt;&lt;br /&gt;
15&lt;br /&gt;
&lt;/code&gt;
&lt;p&gt;The &lt;b&gt;&amp;amp;&lt;/b&gt; can also be used&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(let [[a &amp; rest] x] rest)&lt;/b&gt;&lt;br /&gt;
[10 [3 5] 99.9]&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;Date&lt;/h2&gt;
&lt;p&gt;Just as a quick reference, #inst &quot;&quot; can be used for quick date creation&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(def d #inst &quot;2012&quot;)&lt;/b&gt;&lt;br /&gt;
#inst &quot;2012-01-01T00:00:00.000-00:00&quot;&lt;br /&gt;
&lt;b&gt;(type d)&lt;/b&gt;&lt;br /&gt;
java.util.Date&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;Repeatedly Partial&lt;/h2&gt;
&lt;p&gt;Lookup these values&lt;/p&gt;
&lt;code&gt;
&lt;b&gt;(take 15 (repeatedly (partial rand-int 60)))&lt;/b&gt;&lt;br /&gt;
(48 18 41 4 41 49 45 22 0 25 17 57 45 36 52)&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;Others&lt;/h2&gt;
&lt;p&gt;Some other useful functions found are &lt;b&gt;memoize&lt;/b&gt;, &lt;b&gt;doseq&lt;/b&gt;, &lt;b&gt;dotimes&lt;/b&gt;, &lt;b&gt;for&lt;/b&gt;, &lt;b&gt;range&lt;/b&gt;, &lt;b&gt;doc&lt;/b&gt;, &lt;b&gt;find-doc&lt;/b&gt; and &lt;b&gt;source&lt;/b&gt;.</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/5118156314467388961/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/focusing-on-clojure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/5118156314467388961'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/5118156314467388961'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/focusing-on-clojure.html' title='Focusing on Clojure'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-3334850013027346272</id><published>2012-07-26T10:09:00.000-07:00</published><updated>2012-07-26T15:31:26.638-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clojure"/><category scheme="http://www.blogger.com/atom/ns#" term="Functional Programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Clojure revisit</title><content type='html'>Well, it appears i&#39;ve forgotton all my clojure knowledge. The only thing I appear to have remembered is the thinking style behind it all. So, after reviewing some basics today let&#39;s write them down.
&lt;br /&gt;
&lt;h2&gt;
Getting to the REPL&lt;/h2&gt;
&lt;code&gt;
java -cp clojure-1.4.0.jar clojure.main
&lt;/code&gt;
&lt;br /&gt;
&lt;h2&gt;
Basic Math&lt;/h2&gt;
&lt;code&gt;
(+ 1 2 3)&lt;br /&gt;
(- 3 2 1)&lt;br /&gt;
(/ 1 2 3)&lt;br /&gt;
(* 1 2 3)&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;h2&gt;
Numbers&lt;/h2&gt;
Numbers can be represented infinitely appended with an M or as ratio&#39;s.&lt;br /&gt;
&lt;code&gt;
2r10110110 ; this is radix 2 (bin)&lt;br /&gt;
8r755 ; this is radix 8 (oct)&lt;br /&gt;
16rFFF ; this is radix 16 (hex)&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;h2&gt;
Types&lt;/h2&gt;
There are many forms of types available in clojure&lt;br /&gt;
&lt;code&gt;
nil ; equivalent to null essentially, it is neither true or false&lt;br /&gt;
true false ; these are boolean values
:fred ; this is a symbol&lt;br /&gt;
\c \newline \space \tab ; these are chars&lt;br /&gt;
&quot;string&quot; ; this is a string literal&lt;br /&gt;
(1 2 3) ; this is a list&lt;br /&gt;
[1 2 3] ; this is a vector&lt;br /&gt;
{:a 1 :b 2 :c 3} ; this is a map&lt;br /&gt;
#{:a :b :c} ; this is a set&lt;br /&gt;
^{:a 1}[1 2 3] ; this is a vector with metadata&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;h2&gt;Functions&lt;/h2&gt;
Functions are defined with the fn function, however this creates anonymous functions and to store them you need to use defn&lt;br /&gt;
&lt;code&gt;
(&lt;span style=&quot;color: red;&quot;&gt;defn&lt;/span&gt; average [x y] (/ (+ x y) 2))&lt;br /&gt;
&lt;/code&gt;
&lt;h2&gt;Useful functions&lt;/h2&gt;
&lt;p&gt;Just some I remember from last time&lt;/p&gt;
&lt;p&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;
(zipmap [:a :b :c] [1 2 3])&lt;br /&gt;
&lt;i&gt;{:c 3, :b 2, :a 1}&lt;/i&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;
(doc zipmap)&lt;br /&gt;
; prints current documentation
&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;
(source zipmap)&lt;br /&gt;
; prints source
&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;
(cons :y [:a :b :c])&lt;br /&gt;
&lt;i&gt;[:y :a :b :c]&lt;/i&gt;
&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;

&lt;p&gt;In my next post about clojure I want to include some stuff about &lt;b&gt;map&lt;/b&gt;, &lt;b&gt;reduce&lt;/b&gt; and &lt;b&gt;filter&lt;/b&gt;.</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/3334850013027346272/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/clojure-revisit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/3334850013027346272'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/3334850013027346272'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/clojure-revisit.html' title='Clojure revisit'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-1605958421674515503</id><published>2012-07-13T15:07:00.002-07:00</published><updated>2012-07-13T15:07:57.093-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><title type='text'>Starting an new Activity</title><content type='html'>&lt;p&gt;
Before starting a new activity from a current one, you need to setup the classes.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
Intent display = new Intent(this, DisplayMessageActivity.class);&lt;br /&gt;
EditText editText = findViewById(R.id.edit_text);&lt;br /&gt;
String message = editText.getText().toString();&lt;br /&gt;
display.putExtra(EXTRA_MESSAGE, message);&lt;br /&gt;
startActivity(display);&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;
From the DisplayMessageActivity then, you can get the extra like this.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;
Intent intent = getIntent();&lt;br /&gt;
String message = intent.getStringExtra(PreviousActivityClassname.EXTRA_MESSAGE);&lt;br /&gt;
&lt;/code&gt;
&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/1605958421674515503/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/starting-new-activity.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1605958421674515503'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1605958421674515503'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/starting-new-activity.html' title='Starting an new Activity'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-4220774248672524661</id><published>2012-07-12T17:10:00.000-07:00</published><updated>2012-07-12T17:10:36.149-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="Layout"/><title type='text'>Android UI Weight</title><content type='html'>Android weights are like drink mixes, &quot;2 parts vodka, 1 part coffee liqueur&quot;. If you set one widget to a weight of 2 and another to a weight of 1 - the first will get 2/3rds of the space and the other will get 1/3rd.&lt;br /&gt;
When using weights, it&#39;s a good idea to set the layout_width to 0 to improve performance. It improves performance because it doesn&#39;t need to work out something that ultimately is irrelevant.</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/4220774248672524661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/android-ui-weight.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/4220774248672524661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/4220774248672524661'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/android-ui-weight.html' title='Android UI Weight'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-1027112402533420797</id><published>2012-07-10T17:28:00.000-07:00</published><updated>2012-07-10T17:28:36.968-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Design Patterns"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming"/><title type='text'>Design Patterns</title><content type='html'>&lt;p&gt;Some I can think of off the top of my head:
&lt;ul&gt;
&lt;li&gt;Subscriber&lt;/li&gt;
&lt;li&gt;Builder&lt;/li&gt;
&lt;li&gt;Singleton&lt;/li&gt;
&lt;li&gt;Adapter&lt;/li&gt;
&lt;li&gt;Factory&lt;/li&gt;
&lt;li&gt;Facade&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Patterns can be broken down into five types, four of which were described in gang of four. The fifth has been added later but its contents predate many of the other patterns. They are
&lt;ol&gt;
&lt;li&gt;Creational Patterns&lt;/li&gt;
&lt;li&gt;Structural Patterns&lt;/li&gt;
&lt;li&gt;Behavioural Patterns&lt;/li&gt;
&lt;li&gt;Concurrency Patterns&lt;/li&gt;
&lt;li&gt;Architectural Patterns&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;

&lt;h2&gt;Creational Patterns&lt;/h2&gt;
&lt;p&gt;So this includes &lt;b&gt;Abstract Factory&lt;/b&gt;, &lt;b&gt;Builder&lt;/b&gt;, &lt;b&gt;Factory Method&lt;/b&gt;, &lt;b&gt;Lazy Initialisation&lt;/b&gt;, &lt;b&gt;Multiton Pattern&lt;/b&gt;, &lt;b&gt;Object Pool&lt;/b&gt;, &lt;b&gt;Prototype&lt;/b&gt; and &lt;b&gt;Singleton&lt;/b&gt;&lt;/p&gt;

&lt;h2&gt;Structural Patterns&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Adapter&lt;/b&gt;, &lt;b&gt;Bridge&lt;/b&gt;, &lt;b&gt;Composite&lt;/b&gt;, &lt;b&gt;Decorator&lt;/b&gt;, &lt;b&gt;Facade&lt;/b&gt;, &lt;b&gt;Front Controller&lt;/b&gt;, &lt;b&gt;Flyweight&lt;/b&gt;, &lt;b&gt;Proxy&lt;/b&gt; and &lt;b&gt;Module&lt;/b&gt;&lt;/p&gt;

&lt;h2&gt;Behavioural Patterns&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Blackboard&lt;/b&gt;, &lt;b&gt;Chain of Responsibility&lt;/b&gt;, &lt;b&gt;Command&lt;/b&gt;, &lt;b&gt;Interpreter&lt;/b&gt;, &lt;b&gt;Iterator&lt;/b&gt;, &lt;b&gt;Mediator&lt;/b&gt;, &lt;b&gt;Momento&lt;/b&gt;, &lt;b&gt;Null Object&lt;/b&gt;, &lt;b&gt;Observer&lt;/b&gt;, &lt;b&gt;Servant&lt;/b&gt;, &lt;b&gt;Specification&lt;/b&gt;, &lt;b&gt;State&lt;/b&gt;, &lt;b&gt;Strategy&lt;/b&gt;, &lt;b&gt;Template method and Visitor&lt;/b&gt;&lt;/p&gt;

&lt;h2&gt;Concurrency Patterns&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;Active Object&lt;/b&gt;, &lt;b&gt;Balking&lt;/b&gt;, &lt;b&gt;Message Design&lt;/b&gt;, &lt;b&gt;Double-checked Locking&lt;/b&gt;, &lt;b&gt;Event-based asynchronous&lt;/b&gt;, &lt;b&gt;Guarded Suspension&lt;/b&gt;, &lt;b&gt;Lock&lt;/b&gt;, &lt;b&gt;Monitor Object&lt;/b&gt;, &lt;b&gt;Reactor&lt;/b&gt;, &lt;b&gt;Read-Write Lock&lt;/b&gt;, &lt;b&gt;Scheduler&lt;/b&gt;, &lt;b&gt;Thread Pool&lt;/b&gt; and &lt;b&gt;Thread-Specific Storage&lt;/b&gt;&lt;/p&gt;

&lt;h2&gt;Architectural Patterns&lt;/h2&gt;
&lt;p&gt;&lt;b&gt;SOA&lt;/b&gt;, &lt;b&gt;MVC&lt;/b&gt;, &lt;b&gt;N-Tier&lt;/b&gt;, &lt;b&gt;Event Driven&lt;/b&gt;, &lt;b&gt;Peer-to-Peer&lt;/b&gt; et al&lt;/p&gt;

&lt;p&gt;As each pattern could be its own post, i won&#39;t attempt to describe them here but will work through the list as individual posts&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/1027112402533420797/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/design-patterns.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1027112402533420797'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1027112402533420797'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/design-patterns.html' title='Design Patterns'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-2762727837140795985</id><published>2012-07-09T23:40:00.000-07:00</published><updated>2012-07-09T23:40:36.474-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C language"/><category scheme="http://www.blogger.com/atom/ns#" term="GCC"/><category scheme="http://www.blogger.com/atom/ns#" term="Make"/><title type='text'>Makefile</title><content type='html'>&lt;p&gt;Before we can have a useful makefile, we should first create some files that the build tool can be run against.&lt;/p&gt;

&lt;h2&gt;module.h&lt;/h2&gt;
&lt;code&gt;
#include &lt;stdio.h&gt;&lt;br /&gt;
&lt;br /&gt;
void sample_func();&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;

&lt;h2&gt;module.c&lt;/h2&gt;
&lt;code&gt;
#include &quot;module.h&quot;&lt;br /&gt;
&lt;br /&gt;
void sample_func() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;printf(&quot;Hello World!&quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;

&lt;h2&gt;main.c&lt;/h2&gt;
&lt;code&gt;
#include &quot;module.h&quot;&lt;br /&gt;
&lt;br /&gt;
void sample_func();&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sample_func();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;
&lt;br /&gt;

&lt;p&gt;So, now we have a directory with 3 files. A module which includes a header and source file. And a main source file that includes an entry point and has a dependency on our module. Let&#39;s make a Makefile for this.&lt;/p&gt;

&lt;code&gt;
GCC = gcc&lt;br /&gt;
FLAGS = -O2 -j3&lt;br /&gt;
CC = ${GCC} ${FLAGS}&lt;br /&gt;
&lt;br /&gt;
all: main.o module.o&lt;br /&gt;
&amp;nbsp;&amp;nbsp;${CC} main.o module.o -o target_bin&lt;br /&gt;
main.o: main.c module.h&lt;br /&gt;
&amp;nbsp;&amp;nbsp;${CC} -I . -c main.c&lt;br /&gt;
module.o: module.c module.h&lt;br /&gt;
&amp;nbsp;&amp;nbsp;${CC} -I . -c module.c&lt;br /&gt;
clean:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;rm -rf *.o&lt;br /&gt;
&amp;nbsp;&amp;nbsp;rm target_bin&lt;br /&gt;
&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/2762727837140795985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/makefile.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/2762727837140795985'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/2762727837140795985'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/makefile.html' title='Makefile'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-3256571927171118919</id><published>2012-07-08T07:21:00.001-07:00</published><updated>2012-07-08T07:21:36.639-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="Layout"/><category scheme="http://www.blogger.com/atom/ns#" term="LinearLayout"/><category scheme="http://www.blogger.com/atom/ns#" term="UI"/><category scheme="http://www.blogger.com/atom/ns#" term="View"/><category scheme="http://www.blogger.com/atom/ns#" term="ViewGroup"/><category scheme="http://www.blogger.com/atom/ns#" term="XML"/><title type='text'>Android UI basic</title><content type='html'>&lt;h2&gt;Basic LinearLayout&lt;/h2&gt;
&lt;code&gt;
&amp;lt;?xml&amp;nbsp;version=&amp;quot;1.0&amp;quot;&amp;nbsp;encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;br/&gt;&amp;lt;LinearLayout&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:orientation=&amp;quot;vertical&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:layout_width=&amp;quot;fill_parent&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:layout_height=&amp;quot;wrap_content&amp;quot;&amp;nbsp;&amp;gt;&lt;br/&gt;&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;p&gt;When this code is saved, the ADK will use the &lt;b&gt;Android Asset Packaging Tool&lt;/b&gt; (AAPT) to generate &lt;b&gt;R.java&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;In Android, a widget is called a &lt;b&gt;View&lt;/b&gt; and a layout container like LinearLayout is called a &lt;b&gt;ViewGroup&lt;/b&gt;. Above has created an empty &lt;b&gt;ViewGroup&lt;/b&gt;&lt;/p&gt;

&lt;h2&gt;Asking a Question&lt;/h2&gt;
&lt;p&gt;In order to ask a question, we&#39;ll need to add a &lt;b&gt;TextView&lt;/b&gt; to the top of the layout. To add this, put the following in between the LinearLayout element.&lt;/p&gt;
&lt;code&gt;
&amp;lt;TextView&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:id=&amp;quot;@+id/question&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:layout_width=&amp;quot;fill_parent&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:layout_height=&amp;quot;wrap_content&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:text=&amp;quot;Please&amp;nbsp;wait...&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;/&amp;gt;
&lt;/code&gt;
&lt;p&gt;Now for the answers we&#39;re going to want multiple choices. If we use buttons for starters that&#39;ll do, but since we can&#39;t set a variable number of buttons we&#39;ll need to contain them. So let&#39;s create a new LinearLayout.&lt;/p&gt;
&lt;code&gt;
&amp;lt;LinearLayout&amp;nbsp;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:id=&amp;quot;@+id/answers&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:orientation=&amp;quot;vertical&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:layout_width=&amp;quot;fill_parent&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:layout_height=&amp;quot;wrap_content&amp;quot;&amp;nbsp;&amp;gt;&lt;br/&gt;&amp;lt;/LinearLayout&amp;gt;
&lt;/code&gt;
&lt;p&gt;Then, for each button we want something similar to this:&lt;/p&gt;
&lt;code&gt;
&amp;lt;Button&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:id=&amp;quot;@+id/yes&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:text=&amp;quot;Yes!&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:layout_width=&amp;quot;fill_parent&amp;quot;&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;android:layout_height=&amp;quot;wrap_content&amp;quot;&lt;br/&gt;/&amp;gt;
&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/3256571927171118919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/android-ui-basic.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/3256571927171118919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/3256571927171118919'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/android-ui-basic.html' title='Android UI basic'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-1577384087143785711</id><published>2012-07-07T11:59:00.000-07:00</published><updated>2012-07-09T05:44:42.791-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="BASH"/><category scheme="http://www.blogger.com/atom/ns#" term="Encryption"/><category scheme="http://www.blogger.com/atom/ns#" term="expand"/><category scheme="http://www.blogger.com/atom/ns#" term="ffmpeg"/><category scheme="http://www.blogger.com/atom/ns#" term="find"/><category scheme="http://www.blogger.com/atom/ns#" term="LPIC"/><category scheme="http://www.blogger.com/atom/ns#" term="OpenSSL"/><title type='text'>Terminal Stuff</title><content type='html'>&lt;code&gt;ffmpeg -i input.mp4 -c:v copy -c:a copy output.mkv&lt;/code&gt;
&lt;br /&gt;
&lt;p&gt;ffmpeg takes an input file, copies the codec for video and audio and sets the output file and format&lt;/p&gt;
&lt;br /&gt;
&lt;code&gt;openssl enc -aes-256-cbc -salt -in file.tar.gz &gt; outfile.tar.gz&lt;/code&gt;
&lt;br /&gt;
&lt;p&gt;openssl set to encryption mode with aes-256-cbc encryption algorithm and salted. Sets the input file and directs the output to a file&lt;/p&gt;
&lt;br /&gt;
&lt;code&gt;expand -t4 Tabs.java&lt;/code&gt;
&lt;br /&gt;
&lt;p&gt;expand sets a number of spaces to replace tabs with and an input file, outputs to stdout&lt;/p&gt;
&lt;br /&gt;
&lt;code&gt;find . -iname \*\.epub -exec mv {} ~/epub/ \;&lt;/code&gt;
&lt;br /&gt;
&lt;p&gt;finds files using the current directory as the root, filters on the case insensitive name a regex pattern of *.epub and for each find executes mv the result to ~/epub/&lt;/p&gt;
&lt;br /&gt;
&lt;code&gt;nmap -sTUV -O -p- -PN 192.168.1.*&lt;/code&gt;
&lt;br /&gt;
&lt;p&gt;nmap set to TCP and UDP and versioning mode, also set to identify an operating system. Will scan all ports and behave as if the host is up regardless of responses. Will scan a class C network for all ip&#39;s between 192.168.1.1-255&lt;/p&gt;
&lt;br /&gt;
&lt;code&gt;:%s/search_regex/replacement_text/g&lt;/code&gt;
&lt;br /&gt;
&lt;p&gt;Vim command for finding and replacing text, the G flag represents globally across the whole file. Otherwise it will be limited to the current line&lt;/p&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/1577384087143785711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/terminal-stuff.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1577384087143785711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/1577384087143785711'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/terminal-stuff.html' title='Terminal Stuff'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-6667097915577100878</id><published>2012-07-02T16:41:00.001-07:00</published><updated>2012-07-02T16:41:06.627-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Citrix"/><category scheme="http://www.blogger.com/atom/ns#" term="Hypervisor"/><category scheme="http://www.blogger.com/atom/ns#" term="KVM"/><category scheme="http://www.blogger.com/atom/ns#" term="RHCSA"/><category scheme="http://www.blogger.com/atom/ns#" term="Virtualisation"/><category scheme="http://www.blogger.com/atom/ns#" term="VM"/><category scheme="http://www.blogger.com/atom/ns#" term="Xen"/><title type='text'>Virtual Machine Options</title><content type='html'>As Virtualisation makes it relatively easy to setup a large number of systems, it can help you configure a large number of systems. Each dedicated to a specific service. To that end, it can be separated into 5 different categories.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Application Level&lt;/li&gt;
&lt;li&gt;Platform-level VMs&lt;/li&gt;
&lt;li&gt;Paravirtualization&lt;/li&gt;
&lt;li&gt;Hardware-assisted Virtualisation&lt;/li&gt;
&lt;li&gt;Bare-metal Virtualisation&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;br /&gt;

&lt;h2&gt;&lt;b&gt;Application Level&lt;/b&gt;&lt;/h2&gt;
&lt;br /&gt;
Systems like WINE are application level virtualisations. They allow the installation of a single application that were designed to be run on an entirely different system.
&lt;br /&gt;
&lt;br /&gt;

&lt;h2&gt;&lt;b&gt;Platform-level VMs&lt;/b&gt;&lt;/h2&gt;
&lt;br /&gt;
Applications such as VirtualBox or VMware Player are platform-level VMs. They emulate systems to allow for contained systems to have their own hardware that systems can be installed against.
&lt;br /&gt;
&lt;br /&gt;

&lt;h2&gt;&lt;b&gt;Paravirtualization&lt;/b&gt;&lt;/h2&gt;
While similar to Platform-level VMs, they work with fewer resources and usually require a specialised kernel such as Xen.
&lt;br /&gt;
&lt;br /&gt;

&lt;h2&gt;&lt;b&gt;Hardware-assisted Virtualisation&lt;/b&gt;&lt;/h2&gt;
&lt;br /&gt;
A hardware interface where VMs have access to hardware features of the CPU such as &lt;a href=&quot;http://en.wikipedia.org/wiki/X86_virtualization&quot;&gt;VMX/SVM flags&lt;/a&gt; on Intel/AMD chips respectively.
&lt;br /&gt;
&lt;br /&gt;

&lt;h2&gt;&lt;b&gt;Bare-metal Virtualisation&lt;/b&gt;&lt;/h2&gt;
&lt;br /&gt;
Some VM systems include a minimal operating system  dedicated to VM operation. Two examples of this are Citrix XenServer and VMware ESX.
&lt;br /&gt;
&lt;br /&gt;

&lt;h2&gt;Notes&lt;/h2&gt;
&lt;br /&gt;
The KVM solution that comes with RHEL6 is known as hypervisor, a VM monitor that supports the running of multiple operating systems concurrently on the same CPU. KVM replaces the previous default of Xen.&lt;br /&gt;
&lt;br /&gt;
KVM has replaced Xen in many open-source operating systems. XenSource which is owned by Citrix started working with Microsoft after RHEL5 was released.
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/6667097915577100878/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/virtual-machine-options.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/6667097915577100878'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/6667097915577100878'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/virtual-machine-options.html' title='Virtual Machine Options'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1559840812483088227.post-8992943573160654490</id><published>2012-07-02T16:16:00.002-07:00</published><updated>2012-07-02T16:16:41.670-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Hard Drives"/><category scheme="http://www.blogger.com/atom/ns#" term="RHCSA"/><category scheme="http://www.blogger.com/atom/ns#" term="SAN"/><category scheme="http://www.blogger.com/atom/ns#" term="SATA"/><category scheme="http://www.blogger.com/atom/ns#" term="SCSI"/><title type='text'>Hard Drives and Linux (snippet)</title><content type='html'>&lt;h2&gt;SATA or Serial Advanced Technology Attachment&lt;/h2&gt;
&lt;br /&gt;
Systems now with port multipliers, can easily be configured to have 16 drives through SATA. Older systems could only handle 4 through PATA (Parallel Advanced Technology Attachment).&lt;br /&gt;&lt;br /&gt;
&lt;h2&gt;SCSI or Small Computer Systems Interface&lt;/h2&gt;
&lt;br /&gt;
Depending on the SCSI hardware, you could have up to 31 hard drive devices connected at a time.&lt;br /&gt;&lt;br /&gt;
&lt;h2&gt;Pick &#39;n&#39; Mix&lt;/h2&gt;
&lt;br /&gt;
While you can combine these in as many configurations as your hardware will allow, the Linux boot files from &lt;b&gt;/boot/&lt;/b&gt; works on only one of the first two hard drives. If Linux is installed on the second drive, you&#39;ll need other media recognised by the BIOS/UEFI to get access to it.&lt;br /&gt;
&lt;br /&gt;
The caveat to this however is that Linux doesn&#39;t have to be installed to a local drive. There are options that allow it to be placed on SAN (&lt;b&gt;Storage Area Network&lt;/b&gt;), DASD (&lt;b&gt;Direct Access Storage Device&lt;/b&gt;), hardware RAID devices (&lt;b&gt;Redundant Array of Independent Disk&lt;/b&gt;) and more.</content><link rel='replies' type='application/atom+xml' href='http://squidoop.blogspot.com/feeds/8992943573160654490/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://squidoop.blogspot.com/2012/07/hard-drives-and-linux-snippet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/8992943573160654490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1559840812483088227/posts/default/8992943573160654490'/><link rel='alternate' type='text/html' href='http://squidoop.blogspot.com/2012/07/hard-drives-and-linux-snippet.html' title='Hard Drives and Linux (snippet)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/12713298510822695860</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>