Jen-Ming Chung

Using MongoDB With Morphia

MongoDB is an extremely useful document-based database in NoSQL field. There are various drivers and client libraries in MongoDB Ecosystem and detailed manual to facilitate the developers to get into it shortly. In the beginning, we use MongoDB Java driver to manipulate CRUD operations on databases. Everything is running well but lots of BasicDBObject cause the code lack of readability and fluency. In addition, we employ POJO classes as intermediates between business logic and databases. However, it also brings many laborious and tedious works for converting POJOs into BasicDBObjects before we want to persist custom objects to the database.

Cross-Domain on Jersey RESTful Web Services

Jersey is based on JAX-RS Java community standard, and quite convenient for implementing a RESTful Web Services to serve various flavors of calls in backend. In general, we may use the JSONP workaround with a Javascript callback function to serve the cross-domain request. In Jersey, it provides a better way to achieve it by utilising the ContainerRequestFilter interface. Most of all, we can easily adapt or remove this feature in the Web configuration file.

Install RockMongo for Mongodb on CentOS

Install the prerequisites for mongo-php-driver and some development tools:

# yum install php-devel git httpd
# yum install gcc make

Compile the driver from the latest source code on Github:

# git clone https://github.com/mongodb/mongo-php-driver.git
# cd mongo-php-driver/
# phpize
# ./configure
# make all
# make install

Return a Swift Object From Jersey REST Service

retrieve-object-from-swift

This scenario assumes that the clients want to grab some objects on OpenStack’s Swift via the RESTful request. The main concern is we don’t want to public our container or create Temporary URL every access. As shown in the figure above, the Tomcat instances can verify the access permission or wrap some information before return to the client.