<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cribbs Technologies</title>
	<atom:link href="http://www.cribbstechnologies.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cribbstechnologies.com</link>
	<description>Custom Software and Hardware</description>
	<lastBuildDate>Mon, 17 Oct 2011 16:28:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Technology introduction &#8211; Will grandma use it?</title>
		<link>http://www.cribbstechnologies.com/2011/10/08/technology-introduction-will-grandma-use-it/</link>
		<comments>http://www.cribbstechnologies.com/2011/10/08/technology-introduction-will-grandma-use-it/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 02:32:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Jobs]]></category>
		<category><![CDATA[Steve]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/2011/10/08/technology-introduction-will-grandma-use-it/</guid>
		<description><![CDATA[I was on a cruise this past week when I learned that Steve Jobs had died. I watched a short news story that tried to discuss why he was such an important figure in technology but I think they completely &#8230; <a href="http://www.cribbstechnologies.com/2011/10/08/technology-introduction-will-grandma-use-it/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I was on a cruise this past week when I learned that Steve Jobs had died. I watched a short news story that tried to discuss why he was such an important figure in technology but I think they completely missed the mark.</p>
<p>New technologies need to pass the grandma test: if the average grandma couldn&#8217;t figure it out or just plain wouldn&#8217;t use it, it&#8217;s likely not going to be successful. Whether you think Apple products are aesthetically pleasing or not, the majority of their design focuses on simplicity; I think this is the essence of their success.</p>
<p>While on the ship almost everything works through a single plastic card with a magnetic stripe and a single bar code: room access, payments for purchases, and tracking ingress and egress. Everybody seems to handle this well, even grandma. There are more advanced things you can do with the card like balance tracking on your in-room TV and modifying information on an interactive touchscreen kiosk. The fact that the card does almost everything and is simple to use is why it&#8217;s a winner. The fact that more advanced users have the option for further use makes it even better.</p>
<p>This is exactly what someone at Apple likely figured out. If you cater to the widest possible audience by making something so powerful easy to use you&#8217;re almost guaranteed success. The pair of 80 somethings talking about sending picture messages and using cell phone video conferencing is certainly evidence of this.  Make it simple, make it powerful, try to manufacture it fast enough to keep up with demand.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/10/08/technology-introduction-will-grandma-use-it/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Loading CSS from a JAR file evaluating EL</title>
		<link>http://www.cribbstechnologies.com/2011/06/22/loading-css-from-a-jar-file-evaluating-el/</link>
		<comments>http://www.cribbstechnologies.com/2011/06/22/loading-css-from-a-jar-file-evaluating-el/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 17:17:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[EL]]></category>
		<category><![CDATA[JAR]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=315</guid>
		<description><![CDATA[Yesterday I briefly explained how I was loading CSS files from a JAR and forcing their content through Velocity to evaluate expressions.  A co-worker offered up a more simple solution, it&#8217;s after the break. Carlos really comments his code well &#8230; <a href="http://www.cribbstechnologies.com/2011/06/22/loading-css-from-a-jar-file-evaluating-el/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday I briefly explained how I was loading CSS files from a JAR and forcing their content through Velocity to evaluate expressions.  A co-worker offered up a more simple solution, it&#8217;s after the break.</p>
<p><span id="more-315"></span><br />
<a href="http://blakgeek.com">Carlos</a> really comments his code well so this shouldn&#8217;t be too hard to follow.</p>
<pre class="brush:java">package com.blakgeek.dynamicss.servlet;

import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * User: chenry
 * Date: 6/20/11
 * Time: 12:02 PM
 */
public class CssServlet extends HttpServlet {

    private JspFactory jspFactory = JspFactory.getDefaultFactory();
    private ExpressionFactory expressionFactory;
    private List paths = new ArrayList();

    @Override
    public void init(ServletConfig config) throws ServletException {

        super.init(config);
        expressionFactory = jspFactory.getJspApplicationContext(getServletContext()).getExpressionFactory();

        // get the list paths to try from init params
        String pathsStr = config.getInitParameter("paths");
        if (pathsStr != null) {
            String[] paths = pathsStr.trim().split(",");
            for (String path : paths) {
                this.paths.add(path.trim());
            }
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        InputStream cssInputStream = null;

        // set the proper content type so it will work even if its chunked
        resp.setContentType("text/css");

        // get the filename from url path
        String cssFilename = getFilename(req.getRequestURI());

        // see if its possible to load the resource from any of the defined paths
        for (String path : this.paths) {
            // I know string concatenation is bad but this just an example;
            if (!path.endsWith("/")) path += "/";
            cssInputStream = getClass().getResourceAsStream(path + cssFilename);
            // as soon as you find a good resource use it
            if (cssInputStream != null) break;
        }

        if (cssInputStream != null) {
            String evaluatedCss = evaluateEL(inputStreamToString(cssInputStream), req, resp);
            resp.getWriter().write(evaluatedCss);
        }
    }

    private String inputStreamToString(InputStream is) {

        return new Scanner(is).useDelimiter("\\A").next();
    }

    private String evaluateEL(String content, HttpServletRequest req, HttpServletResponse resp) {

        ELContext elContext = jspFactory.getPageContext(this, req, resp, null, true, 8192, true).getELContext();
        ValueExpression expression = expressionFactory.createValueExpression(elContext, content, String.class);
        return (String) expression.getValue(elContext);
    }

    public String getFilename(String fullPath) {

        int sep = fullPath.lastIndexOf("/");
        return fullPath.substring(sep);
    }

}</pre>
<p>The next blog post should probably be about integrating this solution with WRO4J in order to bulk-load CSS and JS even from jar files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/06/22/loading-css-from-a-jar-file-evaluating-el/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Loading CSS from a JAR file</title>
		<link>http://www.cribbstechnologies.com/2011/06/21/loading-css-from-a-jar-file/</link>
		<comments>http://www.cribbstechnologies.com/2011/06/21/loading-css-from-a-jar-file/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 22:47:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Velocity]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[EL]]></category>
		<category><![CDATA[JAR]]></category>
		<category><![CDATA[JSP]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=312</guid>
		<description><![CDATA[Recently a co-worker created a jar with common utilities in it including some JSP tags. The tag was easy enough to deal with but how do you load CSS/JS from a jar file? His solution was pretty simple; create a &#8230; <a href="http://www.cribbstechnologies.com/2011/06/21/loading-css-from-a-jar-file/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently a co-worker created a jar with common utilities in it including some JSP tags. The tag was easy enough to deal with but how do you load CSS/JS from a jar file? His solution was pretty simple; create a servlet that lives in the JAR that loads resources off of the classpath. All you had to do then was map the servlet in the webapp where you want to use it and it would snag requests and &#8220;serve&#8221; content from the JAR. This was good enough for static files but what about the CSS with paths that changed based on environment?</p>
<p><span id="more-312"></span>Normally, there&#8217;s EL in the CSS file and we just map *.css to the JSP servlet for our container. This works fantastically well when the application has the CSS files exploded but doesn&#8217;t work at all when the CSS is streamed to the JSP&#8217;s writer; enter Velocity. Rather than having Velocity start up and filter all requests, you can start the engine up just to process certain files, then shut it down after you&#8217;re done. Since Velocity tags are in the same format as EL you don&#8217;t have to modify the CSS files at all.</p>
<p>This is a great start and will get you going but there&#8217;s a better way that doesn&#8217;t rely on third party libraries, I&#8217;ll cover that in a <a title="Loading CSS from a JAR file evaluating EL" href="http://www.cribbstechnologies.com/2011/06/22/loading-css-from-a-jar-file-evaluating-el/">future post</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/06/21/loading-css-from-a-jar-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring MVC AJAX web services Part 2, attack of the JSON post</title>
		<link>http://www.cribbstechnologies.com/2011/04/08/spring-mvc-ajax-web-services-part-2-attack-of-the-json-post/</link>
		<comments>http://www.cribbstechnologies.com/2011/04/08/spring-mvc-ajax-web-services-part-2-attack-of-the-json-post/#comments</comments>
		<pubDate>Fri, 08 Apr 2011 12:54:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[annotation]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=301</guid>
		<description><![CDATA[Previously I covered how to create simple AJAX web services using Spring MVC and annotated controllers. This made it very easy to create robust services that automatically convert your java beans into JSON for easy consumption by your AJAX client. &#8230; <a href="http://www.cribbstechnologies.com/2011/04/08/spring-mvc-ajax-web-services-part-2-attack-of-the-json-post/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="Spring MVC AJAX web services" href="http://www.cribbstechnologies.com/2011/03/16/spring-mvc-ajax-web-services/">Previously</a> I covered how to create simple AJAX web services using Spring MVC and annotated controllers. This made it very easy to create robust services that automatically convert your java beans into JSON for easy consumption by your AJAX client. In this post, I&#8217;ll show how to use a simple javascript library to convert your HTML form into a JSON object that your Spring controller can consume and marshal to a java bean automagically.<span id="more-301"></span></p>
<p>Using <a href="http://www.cribbstechnologies.com/wp-content/uploads/2011/04/json.min_.js">this</a> simple JS library coupled with jQuery you can easily create a JSON object by calling $(&#8216;#formId&#8217;).serializeObject(); and pass that information using jQuery&#8217;s $.post or $.get methods.</p>
<pre class="brush:html">&lt;form id="deviceForm"&gt;
&lt;input type="text" name="name"/&gt;
&lt;input type="text" name="manufacturer"/&gt;
&lt;input type="button" id="submit"/&gt;
&lt;/form&gt;
&lt;script&gt;
$('#submit').click(function() {
var deviceJSON = $('#deviceForm').serializeObject();
$.post("/devices/addDevice", deviceJSON, function(data) {
alert("callback");
});
}
&lt;/script&gt;</pre>
<p>All you need to do is change the method signature and annotations within your controller to let it know what type of object the JSON is supposed to be converted to.</p>
<pre class="brush:java">@Controller
public class DeviceController {
@RequestMapping(value="/devices/byManufacturer", method=RequestMethod.GET)
@ResponseBody
public List&lt;Device&gt; getDevicesByManufacturer(@RequestParam String manufacturer) {
DeviceDAO dao = new DeviceDAO();
return dao.findByManufacturer(manufacturer);
}

@RequestMapping(value="/devices/addDevice", method=RequestMethos.POST)
@ResponseBody
public Device addDevice(@RequestBody Device toAdd) {
DeviceDAO dao = new DeviceDAO();
return dao.store(toAdd);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/04/08/spring-mvc-ajax-web-services-part-2-attack-of-the-json-post/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cygwin Gotchas</title>
		<link>http://www.cribbstechnologies.com/2011/03/28/cygwin-gotchas/</link>
		<comments>http://www.cribbstechnologies.com/2011/03/28/cygwin-gotchas/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 16:47:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[environment variables]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=296</guid>
		<description><![CDATA[I&#8217;m going to use this post to detail issues I run into when using cygwin on windows so I&#8217;ll be able to easily find them when I have that &#8220;Oh, I&#8217;ve run into this before&#8221; moment. Environment Variables: Cygwin only &#8230; <a href="http://www.cribbstechnologies.com/2011/03/28/cygwin-gotchas/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to use this post to detail issues I run into when using cygwin on windows so I&#8217;ll be able to easily find them when I have that &#8220;Oh, I&#8217;ve run into this before&#8221; moment.</p>
<p>Environment Variables:<br />
Cygwin only converts the PATH variable automatically. Any other variables you may need will have to be added to your .bashrc file in your home directory.</p>
<p>Missing default functionality:<br />
By default, cygwin doesn&#8217;t install the clear command. Annoying, right? Ctrl + L will clear the buffer and do the same thing essentially.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/03/28/cygwin-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring MVC AJAX web services</title>
		<link>http://www.cribbstechnologies.com/2011/03/16/spring-mvc-ajax-web-services/</link>
		<comments>http://www.cribbstechnologies.com/2011/03/16/spring-mvc-ajax-web-services/#comments</comments>
		<pubDate>Thu, 17 Mar 2011 02:02:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=293</guid>
		<description><![CDATA[With SpringMVC, writing REST type web services is brain-dead simple. The Jackson mapper is a very powerful library that automatically converts your POJOs to and from JSON without any interaction from you. Think it&#8217;s too good to be true?  It&#8217;s &#8230; <a href="http://www.cribbstechnologies.com/2011/03/16/spring-mvc-ajax-web-services/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>With SpringMVC, writing REST type web services is brain-dead simple. The Jackson mapper is a very powerful library that automatically converts your POJOs to and from JSON without any interaction from you. Think it&#8217;s too good to be true?  It&#8217;s not!<span id="more-293"></span>Using annotated controllers in a spring app makes many things much easier. Your spring config file needs to look something like this:</p>
<pre class="brush:xml">&lt;beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd


http://www.springframework.org/schema/context


http://www.springframework.org/schema/context/spring-context-2.5.xsd


http://www.springframework.org/schema/mvc

http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;

&lt;context:component-scan base-package="com.cribbstechnologies.springmvc.web" /&gt;

&lt;mvc:annotation-driven /&gt;

&lt;bean id="viewResolver"&gt;
&lt;property name="prefix"&gt;
&lt;value&gt;/&lt;/value&gt;
&lt;/property&gt;
&lt;property name="suffix"&gt;
&lt;value&gt;.jsp&lt;/value&gt;
&lt;/property&gt;
&lt;/bean&gt;

&lt;/beans&gt;</pre>
<p>And the Jackson library needs to be on your classpath. For a Maven enabled project all you have to do is add this to your POM:</p>
<pre class="brush:xml">&lt;!-- JSON Jackson Libraries --&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
&lt;artifactId&gt;jackson-core-asl&lt;/artifactId&gt;
&lt;version&gt;1.6.1&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.codehaus.jackson&lt;/groupId&gt;
&lt;artifactId&gt;jackson-mapper-asl&lt;/artifactId&gt;
&lt;version&gt;1.6.1&lt;/version&gt;
&lt;/dependency&gt;</pre>
<p>Then you just annotate your controller.</p>
<pre class="brush:java">@Controller
public class DeviceController {

	@RequestMapping(value="/devices/byManufacturer", method=RequestMethod.GET)
	@ResponseBody
	public List&lt;Device&gt; getDevicesByManufacturer(@RequestParam String manufacturer) {
		DeviceDAO dao = new DeviceDAO();
		return dao.findByManufacturer(manufacturer);
	}
}</pre>
<p>That&#8217;s it! The @ResponseBody automatically converts whatever the return value is into JSON and outputs it as the body of the response.  You can see how a JSON object can be automagically mapped to a POJO in <a title="Spring MVC AJAX web services Part 2, attack of the JSON post" href="http://www.cribbstechnologies.com/2011/04/08/spring-mvc-ajax-web-services-part-2-attack-of-the-json-post/">this</a> post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/03/16/spring-mvc-ajax-web-services/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java ORM using mongoDB part 2</title>
		<link>http://www.cribbstechnologies.com/2011/03/16/java-orm-using-mongodb-part-2/</link>
		<comments>http://www.cribbstechnologies.com/2011/03/16/java-orm-using-mongodb-part-2/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 21:21:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Data Store]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[MongoDB]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=270</guid>
		<description><![CDATA[Previously I briefly introduced the mjorm mongo-java-ORM solution I found. This post will go more in-depth and give more specific examples of querying, creating, and removing records from your mongoDB instance. If you don&#8217;t already have mongoDB, you&#8217;ll need it &#8230; <a href="http://www.cribbstechnologies.com/2011/03/16/java-orm-using-mongodb-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="Java ORM using MongoDB" href="http://www.cribbstechnologies.com/2011/03/14/java-orm-using-mongodb/">Previously</a> I briefly introduced the mjorm mongo-java-ORM solution I found. This post will go more in-depth and give more specific examples of querying, creating, and removing records from your mongoDB instance. If you don&#8217;t already have <a href="http://www.mongodb.org/">mongoDB</a>, you&#8217;ll need it for this tutorial. After I&#8217;m through with my dog and pony show, I&#8217;ll provide a link to download a copy of the app that will be created throughout the tutorial.<span id="more-270"></span></p>
<p>If you&#8217;re following along on your own and don&#8217;t want to use the demo app as a crutch you&#8217;ll need <a href="http://www.cribbstechnologies.com/wp-content/uploads/2011/03/mongo-java-orm-0.5.jar">these</a> <a href="http://www.cribbstechnologies.com/wp-content/uploads/2011/03/jot-0.3-SNAPSHOT.jar">two</a> jar files and you&#8217;ll have to manually install them into your local maven repository as I couldn&#8217;t find them on any public repositories anywhere.</p>
<p>I chose Spring MVC as the framework for this demo app because you get a lot of functionality baked in without much effort. You can be up and running with annotations in about 10 minutes including the time it&#8217;ll take Maven to download the requisite libraries.</p>
<p>We&#8217;re going to create an example of everyone&#8217;s favorite things: a used car lot. The seedy buy here pay here type; not an offshoot of a new car lot.  We&#8217;ve got cars. They&#8217;ve got a price, a make, and a model. Let&#8217;s pretend that Salesperson are assigned cars. I know, it&#8217;s a lame idea but I couldn&#8217;t think of a better idea. Salespeople have a name and their assigned cars.</p>
<pre class="brush:java">public class Manufacturer {
     private String name;
}
</pre>
<pre class="brush:java">public class Car {
     private Manufacturer make;
     private String model;
     private long price;
}</pre>
<pre class="brush:java">public class Salesperson{
     private String name;
     private List&lt;Car&gt; assignedVehicles;
}</pre>
<p>You can create your own accessors and mutators, lazy.</p>
<p>Next we&#8217;ll create the xml files that mjorm uses to map the objects to their respective Mongo collections.</p>
<p>Manufacturer.mongo.xml</p>
<pre class="brush:xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;descriptors&gt;
	&lt;object class=&quot;com.cribbstechnologies.springmvc.model.Manufacturer&quot;&gt;
		&lt;property name=&quot;name&quot;&gt;&lt;/property&gt;
	&lt;/object&gt;
&lt;/descriptors&gt;</pre>
<p>Car.mongo.xml</p>
<pre class="brush:xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;descriptors&gt;
	&lt;object class=&quot;com.cribbstechnologies.springmvc.model.Car&quot;&gt;
		&lt;property name=&quot;name&quot;&gt;&lt;/property&gt;
		&lt;property name=&quot;make&quot; class=&quot;com.cribbstechnologies.springmvc.model.Manufacturer&quot;&gt;&lt;/property&gt;
		&lt;property name=&quot;price&quot;&gt;&lt;/property&gt;
	&lt;/object&gt;
&lt;/descriptors&gt;</pre>
<p>Salesperson.mongo.xml</p>
<pre class="brush:xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;descriptors&gt;
	&lt;object class=&quot;com.cribbstechnologies.springmvc.model.Salesperson&quot;&gt;
		&lt;property name=&quot;name&quot;&gt;&lt;/property&gt;
		&lt;property name=&quot;cars&quot;&gt;
			&lt;type-param class=&quot;com.cribbstechnologies.springmvc.model.Car&quot;&gt;&lt;/type-param&gt;
		&lt;/property&gt;
	&lt;/object&gt;
&lt;/descriptors&gt;
</pre>
<p>This post will be continued in part 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/03/16/java-orm-using-mongodb-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IE inconsistencies</title>
		<link>http://www.cribbstechnologies.com/2011/03/16/ie-inconsistencies/</link>
		<comments>http://www.cribbstechnologies.com/2011/03/16/ie-inconsistencies/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 17:40:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Browser Issues]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[z-index]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=264</guid>
		<description><![CDATA[I&#8217;ll keep a running list of new items I find that are inconsistent between Internet Explorer and other browsers. I&#8217;ll skip most of the stuff that&#8217;s already public knowledge. Internet Explorer doesn&#8217;t treat z-index for absolutely positioned objects the same &#8230; <a href="http://www.cribbstechnologies.com/2011/03/16/ie-inconsistencies/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll keep a running list of new items I find that are inconsistent between Internet Explorer and other browsers. I&#8217;ll skip most of the stuff that&#8217;s already public knowledge.</p>
<p>Internet Explorer doesn&#8217;t treat z-index for absolutely positioned objects the same as other browsers: it creates a new &#8220;stack&#8221; of objects that it re-indexes based on the z-index of the nearest relatively positioned ancestor. If you&#8217;ve got an absolutely positioned div that&#8217;s supposed to have a z-index that&#8217;s higher than something else within another div, make sure its ancestor has the appropriate z-index. The following will give you what you want.</p>
<pre class="brush:html">&lt;div style="position: relative; z-index: 999"&gt;
&lt;div id="inner" style="position: absolute: top: 0, left: 0;"&gt;
Yay, I'm indexed
&lt;/div&gt;
&lt;/div&gt;</pre>
<p>This will not:</p>
<pre class="brush:html">&lt;div style="position: relative;"&gt;
&lt;div id="inner" style="position: absolute: top: 0,
left: 0; z-index: 999"&gt;
Boo, I'm not indexed
&lt;/div&gt;
&lt;/div&gt;</pre>
<p>IE&#8217;s javascript engine is pretty sorry. It&#8217;s got plenty of bugs but the one I found today has to deal with boolean equality. In every other browser if the element is disabled this evaluates to true but IE evaluates it to false.</p>
<pre class="brush:js">$('#element').attr('disabled') == 'true';</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/03/16/ie-inconsistencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>595 Shift Register Simulator</title>
		<link>http://www.cribbstechnologies.com/2011/03/15/595-shift-register-simulator/</link>
		<comments>http://www.cribbstechnologies.com/2011/03/15/595-shift-register-simulator/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 14:17:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[ICs]]></category>
		<category><![CDATA[595]]></category>
		<category><![CDATA[shift register]]></category>
		<category><![CDATA[simulator]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=258</guid>
		<description><![CDATA[Sometimes when creating a controller using a microcontroller, you run out of output pins; usually when driving displays. A 595 serial-in parallel-out shift register allows you to control up to 8 lines of data using four microcontroller pins. You can &#8230; <a href="http://www.cribbstechnologies.com/2011/03/15/595-shift-register-simulator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Sometimes when creating a controller using a microcontroller, you run out of output pins; usually when driving displays. A 595 serial-in parallel-out shift register allows you to control up to 8 lines of data using four microcontroller pins. You can also cascade multiple 595 ICs together to enable even more outputs without using additional pins. Click <a href="http://conductiveresistance.com/interactive-595-shift-register-simulator/">here</a> to check out the simulator and hopefully learn how to use a shift register.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/03/15/595-shift-register-simulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java ORM using MongoDB</title>
		<link>http://www.cribbstechnologies.com/2011/03/14/java-orm-using-mongodb/</link>
		<comments>http://www.cribbstechnologies.com/2011/03/14/java-orm-using-mongodb/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 19:57:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Data Store]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[XML mapping]]></category>

		<guid isPermaLink="false">http://www.cribbstechnologies.com/?p=251</guid>
		<description><![CDATA[My previous blog post covered a little about MongoDB. It&#8217;s really simple to use on the command line and thanks to an open-source developer, it&#8217;s really simple to use in a java application. You can check out the project here: &#8230; <a href="http://www.cribbstechnologies.com/2011/03/14/java-orm-using-mongodb/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My <a title="Persistence using MongoDB" href="http://www.cribbstechnologies.com/2011/03/09/persistence-using-mongodb/">previous blog post</a> covered a little about MongoDB. It&#8217;s really simple to use on the command line and thanks to an open-source developer, it&#8217;s really simple to use in a java application.<span id="more-251"></span><br />
You can check out the project here: <a href="http://code.google.com/p/mongo-java-orm/">http://code.google.com/p/mongo-java-orm/</a>. Unfortunately there&#8217;s not much information available in the form of documentation but you can find everything you need to know to get started using the code examples in the testing package.</p>
<p>What you need to get it working: a MongoDB database and some java POJOs. You&#8217;ll then create some XML files that will tell Mongo how to marshal your object to and from Mongo DBObject instances.</p>
<p>Here&#8217;s a simple POJO that represents a car.</p>
<pre class="brush:java">public class Car {

private String model;
private String make;

public String getModel() {
return model;
}

public void setModel(String model) {
this.model = model;
}

public String getMake() {
return make;
}

public void setMake(String make) {
this.make = make;
}
}
</pre>
<p>Here&#8217;s an example of an XML mapping file</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;descriptors&gt;

&lt;object&gt;
&lt;property name="make" /&gt;
&lt;property name="model" /&gt;
&lt;/object&gt;

&lt;/descriptors&gt;
</pre>
<p>Here&#8217;s an example of the DAO class that would handle this object&#8217;s insertion and retrieval to/from the MongoDB instance.</p>
<pre class="brush:java">public class CarDAO {

private XmlDescriptorObjectMapper mapper;

public CarDAO() {
mapper = new XmlDescriptorObjectMapper();
try {
mapper.addXmlObjectDescriptor(this.getClass().
getClassLoader().getResourceAsStream("Car.mongo.xml"));
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("It failed trying to load the mappings");
}
}

public void store(Car toStore) {
DbFactoryBean bean = new DbFactoryBean();
try {
DB db = bean.getObject();
DBCollection carCollection = db.getCollection("cars");
WriteResult result = carCollection.insert(mapper.mapToDBObject(toStore));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}
</pre>
<p>That&#8217;s all you&#8217;ve gotta do. It wouldn&#8217;t take much to get this functionality pushed into Java annotations and if I end up using this project extensively, I&#8217;ll likely volunteer my time to modify it to do so.</p>
<p>Read the <a title="Java ORM using mongoDB part 2" href="http://www.cribbstechnologies.com/2011/03/16/java-orm-using-mongodb-part-2/">next</a> installation in this series.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cribbstechnologies.com/2011/03/14/java-orm-using-mongodb/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.cribbstechnologies.com @ 2012-02-22 19:09:51 -->
