Sunday, March 3, 2013

New chapter on Security

The first part about Basic Authentication is now added to the Security chapter of my tutorial on how to develop a component-based Google App Engine app.

Enjoy your Sunday!

Saturday, February 23, 2013

Developing a component-based Google App Engine app

Goals with this tutorial

The main goal with this tutorial is to share the learnings I've made the past years, developing apps for Google App Engine.
Promoting the open-source framework with server components is another reason for writing this tutorial.

@Deprecated

Please note that the home for this tutorial has moved to http://blog.bassac.se/p/tutorial.html
where it is properly updated.

Sunday, September 23, 2012

Mardao 2 is released


I am very pleased to announce the first release of Mardao 2! The following requirements have been considered when rewriting from scratch:
  • Domain objects are now true POJOs with Annotations - no need to extend a class or implement an interface
  • Application code and generated code are completely agnostic of persistence type
  • @CreatedBy and @UpdatedBy are new auto-populated fields
  • @GeoLocation supports creating geo-hashes to do nearby and spatial searches
  • Domain fields can be of basically any field
  • Support for transient fields - by omitting @Basic annotation
  • All non-unique queries return an Iterable or a page
  • Support for cursors and cursor keys
  • Generator uses reflection to scan objects
  • True separation between generic Dao functionality, persistence-specific code and domain-specific methods

Example apps in production using Mardao

The following apps or services are in production and are using mardao:
  • Heathrow Airport Guide (Backend / Google App Engine)
  • TwoForOne voucher app (Android application / SQLite)
  • European Directories Mobile (XHTML web app / Spring JDBC / MySQL)
  • SonyEricsson Update Service (Backend / Spring JDBC / Oracle)
  • Golden Gekko device detection service (Backend / Google App Engine)
  • Google Search Prototype (BlackBerry / SQLite)

Read more at the mardao wiki on GitHub: https://github.com/sosandstrom/mardao/wiki

Tuesday, March 27, 2012

Spring Social on Google AppEngine

If you run into the 
javax.net.ssl.HttpsURLConnection is a restricted class
issues using Spring Social on Google AppEngine, please note that ClientHttpRequestFactorySelector 
"Picks a HttpComponentsClientRequestFactory factory if Apache HttpComponents HttpClient is in the classpath. If not, falls back to SimpleClientHttpRequestFactory."


So check your classpath! Avoid HttpClient on AppEngine!

Monday, February 27, 2012

Storing Documents in AppEngine's Datastore

Storing Documents in AppEngine's Datastore

One of the advantages of Google AppEngine's Datastore is that it is schema-less. You can simply store any Entity you wish, as long as you abide the indexes.
In this post, I will mimic the MongoDB document store, where you can store any kind of JSON document in your collection, as long as it has attributes for your collection's indexes.

Objectives

  • I would like to access the document store using a generic REST-JSON API, which implements basic CRUD methods plus a query method
  • On the consumer side, I  would like to map to POJOs, not a map
  • I would like to be able to store new kinds of objects without interrupting the service
  • I would like to be able to introduce new attributes on my entities without updating any of the existing entities

Source for the json-doc-store

The source code is hosted on BitBucket.
hg clone https://bitbucket.org/f94os/json-doc-store

Binding request from JSON to Map

The intermediate data type when using Spring and jackson JSON mapper is the Map class:
    @RequestMapping(value="{kind}", method= RequestMethod.POST)
    public ResponseEntity createDocument(
            @PathVariable String kind,
            @RequestParam String id,
            @RequestBody Map props
            ) { 
      // Spring and Jackson binds my JSON object to a Map 
// Bind to AppEngine Datastore Entities // persist in datastore }

Read a document from the datastore

The Spring Controller method to create entities looks like this:
Create by kind only (generate key)
    @RequestMapping(value="{kind}/{id}", method= RequestMethod.GET)
    public ResponseEntity> getDocument(
            @PathVariable String kind,
            @PathVariable Object id
            ) {
        
        // query for ancestors, including ancestor

        // bind from Entities to Map
 
        // Jackson will serialize from Map to JSON 
     }

Namespace and Kind

A relational database can be compared to using Namespaces in the Datastore, and a table can be compared to using the Entity Kind.

Admin database

MySQL uses a database with tables for users, user databases, user tables and so on. The same concept is done here, with an admin Namespace of json-doc-store, and two Kinds, _DBs and _Users.

Friday, December 23, 2011

Podcast

Here's a link to the podcast SourceForge created about mardao, featuring me :-)
http://sourceforge.net/blog/podcast-mardao/

Merry Chrismas everyone!
Ola

Saturday, December 10, 2011

Mardao going Mobile

Mardao is a tool saving you hours and hours of boring work writing boilerplate data access code. It could also save you a bug or two, as it generates code.

Currently, Mardao supports generating code for Spring JDBC / MySQL, JPA and Google AppEngine's Datastore. It is used in production services on all three platforms, and the tool is considered stable. The current version is 1.15.

Next step in Mardao's roadmap is to generate code for Android apps, as the fit with the SQLite database is really good.

I'd simply love to hear about your usage, and feedback on the API as well as features. Perhaps even write a review?

Are you keen to contribute? Mardao is open source, and can be found at http://mardao.sourceforge.net/
 

Saturday, August 27, 2011

Ricotta now speaks Khmer!

Welcome Bormy to the Ricotta development team!
The first step of recursion has been taken, making Ricotta a localised service by using Ricotta! So now, point your browsers to
http://ricotta-ost.appspot.com/index.html
and make sure your browser prefers Khmer, and you'll see.

Saturday, May 21, 2011

Ricotta revisited

Hi, after many weeks without new features, Ricotta has now undergone a major refactoring. Switching to mardao 1.9 gives dramatic improvements on the data persistence layer, and changes to the UI based on real user feedback are appreciated.

Ricotta is a translations tool for any software project with resources separated from code, e.g. Android and iPhone apps projects, and most JavaEE web apps.

Make sure you have a look, it's free to use, hosted on Google AppEngine at
http://ricotta-ost.appspot.com

Saturday, January 15, 2011

Ricotta - Translation Management Tool

I have been working on a new open source project called Ricotta, which is a translations management tool.

You define your tokens and translate them online. Then, you download resource files to your workspace, and they are rendered using different templates. One for java web apps, a different one for Android projects and so on.
You can also import your existing resource files into Ricotta, to get a quick start.

This project is using Mardao, and is hosted on Google AppEngine.

For downloads and more information, see
http://ricotta-ost.appspot.com/index.html

Sunday, November 28, 2010

Spring-ws on AppEngine

Use Spring-ws 1.5.8 and Spring framework 3.0.2.RELEASE.

Replace soap's messageFactory with an AxiomMessageFactory. Use Axiom 1.2.8.

Use xmlBeans for marshalling.

Wednesday, November 24, 2010

AppEngine, Maven and Eclipse

First step is to create the maven project:

mvn archetype:create


and select the

gae-archetype-jsp (Archetype for creating maven-gae projects that uses jsp for the view)

archetype.

Then, generate your Eclipse project:

mvn eclipse:eclipse

Create an application on AppEngine. Then, adjust the pom.xml, appengine-web.xml and perhaps the web.xml.
Now, you should be able to copy the app-engine sdk dependencies to your local maven repo:

mvn gae:unpack

and then start the app in your local server:

mvn gae:run

OK!?

Friday, October 22, 2010

Mardao 1.4 is released for download

OK, it's been a while, but now the next version of mardao is released. 1.4 contains one new feature, findBy(Expression... expressions), and one important bug fix, ResultSet.getTimestamp() instead of getDate(). As always, download from sourceforge:
https://sourceforge.net/projects/mardao/files/1.4/

Tuesday, August 3, 2010

Mardao 1.3 is released for download

Including one important bug fix on the findBy(Map args) method, 1.3 is now released and available for download:
https://sourceforge.net/projects/mardao/

Monday, June 14, 2010

Mardao Tutorial

Hi folks,
there is now a tutorial for setting up a mardao project from scratch. Please visit
the project wiki.

Saturday, June 5, 2010

Mardao 1.1 is released for download

So, about a week after the 1.0, next release is due. New features are
  • Support for @Table(name="tblName")
  • Support for @Column(name="colName")
  • Per-table generated CREATE sql scripts
Fixed bugs:
  • Use column names instead of Entity attribute names
Other:
  • More JUnit tests
For more info and downloads: http://mardao.sourceforge.net/

Tuesday, June 1, 2010

Mardao - the Architect's Java DAO generator

Today I released the 1.0 version of mardao, the Architect's Java DAO generator.
It uses your annotated domain objects to generate DAO classes, see image.

For more information and downloads, visit
https://sourceforge.net/projects/mardao

Thursday, May 6, 2010

SVN authentication with Apache and OpenLDAP on Debian


DAV svn
SVNParentPath /svn

AuthType Basic
AuthBasicProvider ldap
AuthName "LDAP auth repo"
AuthLDAPURL ldap://localhost/dc=sub,dc=company,dc=com?uid
AuthLDAPGroupAttribute memberUid
AuthLDAPGroupAttributeIsDN off
AuthzLDAPAuthoritative on
Require ldap-group cn=SVN-inhouse,cn=Groups,dc=sub,dc=company,dc=com