2015年7月9日 星期四

Create a sample project(3) - WebService Choice


The interesting thing is when I have finished studying AngularJ S, using server-client method is a good way to develop outside website. Because that we can reduce the network flow and more efficiency web app. But, SpringMVC is still a good way to develop some types website, because it can handle Session, redirect URL, and so on more easier.

So, should I choice a more efficient web service framework to handle backend server? I think the answer is YES!  Jersey is most popular Restful web service framework, and has high performance.  I have thought about using SpringMVC, but when I see this experiment. I decide change to Jersey.
https://github.com/jhipster/generator-jhipster/issues/814

The performance is bothered me for a long time. There is a solution appear called Netty. Netty is a network communication framework. It supports event-driven, asynchronise , non-blocking IO feathers.

Netty article
http://ifeve.com/netty1/

But, do we need to give up SpringMVC? Maybe yes or not, because SpringMVC is more suitable for small scale or inside website. Anyway, the last example project have add and query function. You can implement delete and update functions by your own.

Next, we should change our webservice framework to Jersey.







2015年7月6日 星期一

Front End Resorces

Angular.js And React.js are the two popular front end framework recently.
I choice the Angular be my front end backbone, may use some react components do some special job. 

This is an angular tutorial vedio
http://campus.codeschool.com/courses/shaping-up-with-angular-js/intro

Another tutorial from W3CSchool

Angular API

EggHead. An expert do some examples on Angular( and also react).

Some Chinese resources
http://blog.miniasp.com/archive.aspx#cat-AngularJS

React, not a good tutorial, but a good sample code library

The CSS is also be my weakness, so I don't want to spend time for creating CSS template.
You can use bootstrap CSS or Wix web site template


2015年7月1日 星期三

Create a sample project(2) - Setup PostgreSQL on JBoss

After finishing the Maven hell, we can finally start the fun part. I choice the PostgerSQL be our database. There are some reasons. First, it's free. Then, it is more like Oracle, such SQL syntax, design model. So, this is why I don't choice MySQL. Moreover, why  not choice RMDB instead of NoSQL. There some pros and cons. RMDB is more convenient by using SQL. But , NoSQL is more powerful on big data. Anyway, I just choice a simple for starting. After then, I will also study MongoDB.

Actually, this is a simple one to install PostgreSQL on your computer, you can choice raphic installation which conclude pgAdmin. So, you can build db and execute SQL command on pgAdmin.
http://www.postgresql.org/download/
Otherwise, I not sure homebrew wheather contain pgAdmin.

All right, after we install PostgreSQL, we should build an example database on it. So, we create a new database called TEST. Note that using capital is prefer for naming rule, it will effect the SQL command after. Then, we use JPA tool to create the schema of example table.

We use previous project for our practice,

First, setup the connection of DB.
On project -> property -> Hibernate, setup up the Postgre Driver

Second, use JPA Tool to generate
Project -> JPA Tool -> Generate xxx
In here, we change Entity to Table


Next, we should setup the JBoss db connection, or used db configuration on JBoss.
Actually, this is hard part. If I don't see the document, I will never figure it out.
Anyway, we change the DB configuration on this step. Maybe we try not to config JBoss server config file.

I have use maven to import Postgre driver, but the result is fail. I don't know why

You can see this blog to config the database connection
http://wei-meilin.blogspot.tw/2012/07/jeap-6-datasource.html

I choice the module method to setup up. Note that please use the JDBC4(not JDBC41) for setup.

There are some tips you need to know on our prototype project.

  1. Remove spring-quickstart-ds.xml
  2. Change the value of hibernate.hbm2dll.auto on persistence.xml
  3. Setup up datasource and driver on standalone.xml(or domain.xml) which is in JBoss folder(...this depend on that which you need is standalone or domain).
  4. If you change the datasource JNDI name, you should change the JNDI value of dataSource on infrastructure.xml.
  5. You also need to add dependence of PostgreSQL.


standalone.xml
<datasources>

    <datasource jndi-name="java:jboss/datasources/SpringQuickstartDS" pool-name="PostgresDS" enabled="true" use-java-context="true">

        <connection-url>jdbc:postgresql://172.0.0.1:5432/Test</connection-url>

        <driver>postgres</driver>

        <security>

            <user-name>postgres</user-name>

            <password>xxxx</password>

        </security>

    </datasource>

    <drivers>

        <driver name="postgres" module="com.postgresql">

            <xa-datasource-class>org.postgresql.Driver</xa-datasource-class>

        </driver>

    </drivers>

</datasources>


pom.xml
<dependency>

 <groupId>postgresql</groupId>

 <artifactId>postgresql</artifactId>

 <version>9.1-901.jdbc4</version>

</dependency>

Pardon me for such mess article. I avoided to write  to much detail for some reasons. Maybe I will reorganize this article one day. Finally, we create the Database connection. JPA and its annotation are such great tools to create relation with the database. But, we should not focus on that, because it so easy to use. Next time, we we will write the our backend code by using SpringMVC and its unit test. See you~