create abs project in twenty minutes

55
Create ABS Project in Twenty minutes! Jérôme BENOIS Open-Source : <jerome.benois AT gmail.com> Corporate : <benois AT argia-engineering.fr> Create A.B.S (Advanced Build System) Project in Twenty minutes!

Upload: benois-jerome

Post on 29-Jan-2018

1.187 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Create ABS Project In Twenty Minutes

Create ABS Project

inTwenty minutes!

Jérôme BENOIS

Open-Source : <jerome.benois AT gmail.com>Corporate : <benois AT argia-engineering.fr>

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 2: Create ABS Project In Twenty Minutes

Presentation goals

● Intalling ABS

● Develop your first application

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 3: Create ABS Project In Twenty Minutes

AgendaShow ...

● How to install ABS?● How to use UML model?● How to generate code?● How to code, test, configure and run application?● Dealing with Web Services!

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 4: Create ABS Project In Twenty Minutes

How to Install ABS?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 5: Create ABS Project In Twenty Minutes

Install command lineHow to install ABS?

● Create directory : ~/abs

● Download installer : ● http://prdownloads.sourceforge.net/abs/workshop-repository-manager-0.6.jar?download

● Run : ● java -jar workshop-repository-manager-0.6.jar http://sharengo.org/abs/0.7/abs-core

● java -jar workshop-repository-manager-0.6.jar http://sharengo.org/abs/0.7/mda

● java -jar workshop-repository-manager-0.6.jar http://sharengo.org/abs/0.7/qa

● java -jar workshop-repository-manager-0.6.jar http://sharengo.org/abs/0.7/doc

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 6: Create ABS Project In Twenty Minutes

Install command lineHow to install ABS?

● Register environment variable : ABS_HOME=~/abs

● Add in your execution path : $ABS_HOME/tc/ant/bin

● Configure ABS (choose default value with ENTER) : ● cd $ABS_HOME

● abs init

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 7: Create ABS Project In Twenty Minutes

Install Eclipse PluginHow to install ABS?

● Dowload eclipse 3.3 : http://download.forge.objectweb.org/acceleo/eclipse-europa-linux-modeling-topcased-acceleo-2.1.1.zip

● Use eclipse update manager : ● "Help" -> "Software Updates" -> "Find and Install ..."

● Add new remote site : http://sharengo.org/update/europa

● And choose all features.

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 8: Create ABS Project In Twenty Minutes

How to use UML Model?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 9: Create ABS Project In Twenty Minutes

Create «person» componentHow to use UML Model?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 10: Create ABS Project In Twenty Minutes

Get technical component (I)How to use UML Model?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 11: Create ABS Project In Twenty Minutes

Get technical component (I)How to use UML model?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 12: Create ABS Project In Twenty Minutes

Add source dependencyHow to use UML Model?

● Edit srcdep.txt file in “person” component and add one technical dependency :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 13: Create ABS Project In Twenty Minutes

Create a Conception modelHow to use UML Model?

● Create a new model in server/model/conception:

● conception.uml (Model)● conception.umldi (Diagrams)● conception.properties

(used to configure generation)

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 14: Create ABS Project In Twenty Minutes

Define model nameHow to use UML Model?

● Define model name (used to define root package of all classes):

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 15: Create ABS Project In Twenty Minutes

How to apply Stererotype?How to use UML Model?

● You canapply stereotype in properties view:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 16: Create ABS Project In Twenty Minutes

Populate entities packageHow to use UML Model?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 17: Create ABS Project In Twenty Minutes

Populate process packageHow to use UML Model?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 18: Create ABS Project In Twenty Minutes

Populate ui packageHow to use UML Model?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 19: Create ABS Project In Twenty Minutes

How to generate code?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 20: Create ABS Project In Twenty Minutes

Choose target Architecture (I)How to generate code?

● Choose architecture / Platform Specific Model(launch wizard from server/model/conception)

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 21: Create ABS Project In Twenty Minutes

Choose target Architecture (II)How to generate code?

● In architecture catalog :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 22: Create ABS Project In Twenty Minutes

Choose target Architecture (III)How to generate code?

● In architecture catalog :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 23: Create ABS Project In Twenty Minutes

Choose target Architecture (IV)How to generate code?

● In architecture catalog :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 24: Create ABS Project In Twenty Minutes

Choose target Architecture (IV)How to generate code?

● Generate code :

● use conception.launch :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 25: Create ABS Project In Twenty Minutes

How to code, test, configure and run application?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 26: Create ABS Project In Twenty Minutes

Configure applicationHow to code, test, configure and run application?

● Edit srcdep.txt file to add source dependency: sharengo:middleware/gluon-core/trunk

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 27: Create ABS Project In Twenty Minutes

Unit test on EntitiesManagerHow to code, test, configure and run application?

● Run generated unit tests to validate EntitiesManager :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 28: Create ABS Project In Twenty Minutes

Coding process Unit testHow to code, test, configure and run application?

● Coding Process unit test and run :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 29: Create ABS Project In Twenty Minutes

Coding ProcessHow to code, test, configure and run application?

● Coding Process :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 30: Create ABS Project In Twenty Minutes

Run process Unit testHow to code, test, configure and run application?

● Yeah !

Green Bar:

Business

Layer

is OK !

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 31: Create ABS Project In Twenty Minutes

Coding PersonControllerHow to code, test, configure and run application?

● Coding

Web

Controller:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 32: Create ABS Project In Twenty Minutes

Coding PersonUIImplHow to code, test, configure and run application?

● Coding Ui :

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 33: Create ABS Project In Twenty Minutes

Create static project (I)How to code, test, configure and run application?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 34: Create ABS Project In Twenty Minutes

Create static project (II)How to code, test, configure and run application?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 35: Create ABS Project In Twenty Minutes

Coding Velocity View (I)How to code, test, configure and run application?

● Coding AddPersonView.vsl in static-project:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>AddPersonView</title><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /></head><body><h1>Add Person View</h1><br/><form method="post" action="actions/personController/doAddPerson">Fisrt Name : <input type="text" name="firstName"/>Last Name : <input type="text" name="lastName"/><input type="submit"/></form><br/><br/><a href="actions/personController/listPerson">List all persons</a></body></html>

Page 36: Create ABS Project In Twenty Minutes

Coding Velocity View (II)How to code, test, configure and run application?

● Coding ListPersonView.vsl:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title>ListPersonView</title><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /></head><body><h1>List Person View</h1><br/><ul>#foreach( $person in $persons )<li>$person.firstName $person.lastName</li>#end</ul></body></html>

Page 37: Create ABS Project In Twenty Minutes

Create project (I)How to code, test, configure and run application?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 38: Create ABS Project In Twenty Minutes

Create project (II)How to code, test, configure and run application?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 39: Create ABS Project In Twenty Minutes

Add dependency to PersonHow to code, test, configure and run application?

● Edit srcdep.txt in your module' s project in order to add dependency:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 40: Create ABS Project In Twenty Minutes

Configure VelocityHow to code, test, configure and run application?

● Edit server/main/conf/velocity.properties in your module' s project:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

## specify three resource loaders to use##resource.loader = file, class, jarresource.loader = file, class

## for the loader we call 'file', set the FileResourceLoader as the# class to use, turn off caching, and use 3 directories for templates#file.resource.loader.description = Velocity File Resource Loaderfile.resource.loader.class = org.apache.velocity.runtime.resource.loader.FileResourceLoaderfile.resource.loader.path = /home/jeromeb/workspaces/ws-demo3/static-projectfile.resource.loader.cache = falsefile.resource.loader.modificationCheckInterval = 0

## for the loader we call 'class', use the ClasspathResourceLoader#class.resource.loader.description = Velocity Classpath Resource Loaderclass.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader

Page 41: Create ABS Project In Twenty Minutes

Configure Database Access (I)How to code, test, configure and run application?

● Edit server/main/conf/context.xml in your module' s project:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

<Context path="/person-management" debug="1" reloadable="true"> <Resource name="@@hibernate.datasource@@" auth="Container" type="javax.sql.DataSource" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/person-management" username="postgres" password="" maxIdle="2"maxActive="4" maxWait="5000" validationQuery="select now();"/> </Context>

Page 42: Create ABS Project In Twenty Minutes

Configure Database Access (II)How to code, test, configure and run application?

● Create project database: createdb -U postgres -E unicode person-management

● Edit person-management/deployment/localhost/replace.server.properties: @@hibernate.datasource@@=person-management

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 43: Create ABS Project In Twenty Minutes

Configure ApplicationEdit server/main/conf/applicationContext.xml in your module' s project:

How to code, test, configure and run application?

Create A.B.S (Advanced Build System) Project in Twenty minutes!

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">

<import resource="classpath*:META-INF/spring/component.xml"/>

<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean"> <property name="configLocation" value="WEB-INF/classes/velocity.properties"/> </bean>

<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/@@hibernate.datasource@@"/>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mappingResources"> <!-- Allow hibernate mapping file to use --> <list> <value>org/sharengo/person/entities/hibernate/Person.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.generate_statistics">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.jdbc.batch_size">1</prop> </props> </property></bean></beans>

Page 44: Create ABS Project In Twenty Minutes

Configure TomcatHow to code, test, configure and run application?

● Configure

application context

root for Tomcat:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 45: Create ABS Project In Twenty Minutes

Run Tomcat (I)How to code, test, configure and run application?

● Run Application

on tomcat server:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 46: Create ABS Project In Twenty Minutes

Run Tomcat (II)How to code, test, configure and run application?

● Run Application

on tomcat server:

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 47: Create ABS Project In Twenty Minutes

Use application (I)How to code, test, configure and run application?

● You can use your application here:http://localhost:8080/person-management/actions/personController/showPersonForm

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 48: Create ABS Project In Twenty Minutes

Use application (I)How to code, test, configure and run application?

● You can use your application here:http://localhost:8080/person-management/actions/personController/actions/personController/listPerson

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 49: Create ABS Project In Twenty Minutes

Dealing with Web Services!

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 50: Create ABS Project In Twenty Minutes

Shared business operationDealing with Web Services!

● Use stereotype <<Remote>> on your <<process>> operations:

● Get component from repository and add source dependency (srcdep.txt on your component):

sharengo:middleware/gluon-xfire/trunk

● Add binary dependency: -spring-mock.jar

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 51: Create ABS Project In Twenty Minutes

Configure services startupDealing with Web Services!

● Import Xfire config in server/resources/META-INF/spring/component.xml

Create A.B.S (Advanced Build System) Project in Twenty minutes!

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<!-- Start of user code component definition --><import resource="classpath:META-INF/spring/org.sharengo.person/layer-controllers.xml"/><import resource="classpath:META-INF/spring/org.sharengo.person/layer-uis.xml"/><import resource="classpath:META-INF/spring/org.sharengo.person/layer-services.xml"/><import resource="classpath:META-INF/spring/org.sharengo.person/layer-daos-hibernate.xml"/><import resource="classpath:META-INF/spring/org.sharengo.person/layer-xfire-services.xml"/>

<!-- technical layers --><import resource="classpath:META-INF/spring/layer-hibernate.xml"/><import resource="classpath:META-INF/spring/layer-velocity.xml"/><import resource="classpath:META-INF/spring/layer-xfire.xml"/><!-- End of user code component definition -->

</beans>

Page 52: Create ABS Project In Twenty Minutes

Run Unit TestsDealing with Web Services!

● Adapt PersonProcessTest and run unit test in remote mode with: « PersonProcessWebServiceTest.java »

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 53: Create ABS Project In Twenty Minutes

Shared your Web ServicesDealing with Web Services!

Create A.B.S (Advanced Build System) Project in Twenty minutes!

Page 54: Create ABS Project In Twenty Minutes

Merci!

A.B.S (Advanced Build System) in Twenty minutes!

Page 55: Create ABS Project In Twenty Minutes

Sources

● ABS reference doc : http://sharengo.org/abs/

A.B.S (Advanced Build System) in Twenty minutes!