Surya \’s Blog

… ever streaming tools and technologies….!!!

Archive for the ‘AndroMDA’ Category

How to get started AndroMDA – in brief

Posted by kathayat on July 10, 2007

A: Set up Configuration

1. Download and Install/Configure – AndroMDA, Maven, JBoss, MagicDraw, Databases, Eclipse [http://galaxy.andromda.org/index.php?option=com_content&task=view&id=105&Itemid=89]

2. Set Environment Variables
 JAVA_HOME=;  JBOSS_HOME= ;  M2_HOME=;  M2_REPO=;  PATH=%JAVA_HOME%\bin;%M2_HOME%\bin; etc

3.  Create the temporary project using the following command
mvn archetype:create -DgroupId=testapp -DartifactId=testapp
Make sure “Build Successful” message appears at the end and verify that the temporary project is created in the current directory and in the repository. You can delete the temporary project you have just created.

4.  Download AndroMDA maven plug-in and extract it to the repository that you set in SETP 2 above.

5.  Create “pom.xml” file in any temporary directory. Issue the “mvn” command from the command line inside that temporary directory and make sure “Build Successful” message appears at the end.

Contents of pom.xml

<project>

    <modelVersion>4.0.0</modelVersion>
    <groupId>samples.test</groupId>
    <artifactId>test</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>test</name>

    <build>
        <defaultGoal>compile</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.andromda.maven.plugins</groupId>
                <artifactId>andromdapp-maven-plugin</artifactId>
                <version>3.2</version>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>andromda</id>
            <name>AndroMDA Repository</name>
            <url>http://team.andromda.org/maven2</url&gt;
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>andromda</id>
            <name>AndroMDA Repository</name>
            <url>http://team.andromda.org/maven2</url&gt;
        </pluginRepository>
    </pluginRepositories>

</project>

B: Starting a Project

6. Issue the following command (may differ according to the andromeda plug-in version) from any directory where you want to create your project.
mvn org.andromda.maven.plugins:andromdapp-maven-plugin:3.2:generate
Configure your application answering several on-screen questions. For reference – refer to page [http://galaxy.andromda.org/index.php?option=com_content&task=view&id=107&Itemid=89]. Make sure that “build successful” message should appear at the end.

7. Configure the generated files. Refer [http://galaxy.andromda.org/index.php?option=com_content&task=view&id=107&Itemid=89]

a. Configure Database drivers, usernames, passwords, app server version
b. Configure Repositories etc

1. mda/src/main/config/andromda.xml
a. Update EnableSpringTransactionsWhenEjbsEnabled == false
b. Add property in bpm4struts namespace “<property name=”normalizeMessages”>true</property>”
2. /pom.xml
a. Update jdbc driver (what version of driver you have in your system) <jdbc.driver.jar>${jboss.home}/server/default/lib/mysql-connector-java-5.0.4.jar</jdbc.driver.jar
b. Update username and password (database) ..simple search for work ‘username’ and update
c. Update repositories
    <repositories>
        <repository>
            <id>andromda</id>
            <name>AndroMDA Repository</name>
            <url>http://team.andromda.org/maven2</url&gt;
        </repository>
        <repository>
            <id>maven2-repository.dev.java.net</id>
            <name>Java.net Repository for Maven 2</name>
            <url>https://maven2-repository.dev.java.net/nonav/repository</url&gt;
            <layout>default</layout>
        </repository>
    </repositories>
d. Comment out ‘junit’ dependency and add ‘testng’ dependencies (this is for unit testing with ‘testng’.
<dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>4.7</version>
            <scope>test</scope>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.0.4</version>
            <scope>test</scope>
        </dependency>
e. Copy(if you have template)/Create Test directory to Core/src directory
f. Search for word ‘maven-resources-plugin’ and add other plugins below its section.
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
                <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-surefire-plugin</artifactId>
                   <version>2.2</version>
                   <configuration>
                     <suiteXmlFiles>
                       <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
                     </suiteXmlFiles>
                   </configuration>
                </plugin>

8. Open the generated UML project (yourapp/mda/src/main/uml/yourapp.xml) from MagicDraw and export it to the same location. Then issue the command “mvn install” from the command line (inside ‘yourapp’ directory) and make sure that “build successful” message appears at the end.

9. Start your real work – create models, packages, services, use case diagrams, activity diagrams etc in the MagicDraw according to the needs of your application and then export it to the project directory again. Finally generate code and edit if necessary…happy coding!!!
a. Create Model
b. Create root package inside model
c. Create ‘vo’ subpackage and add class diagram and create the valued object class (say UserVO)
d. Create ‘service’ subpackage and add class diagram and create service class (say UserService)
e. Create the  ‘domain’ subpackage and add class diagrams for domain objects (entities).
f. Define the dependencies between the value objects and entities
g. Define the dependencies between services and entities

10.  Build common and web projects and deploy
a. Edit deploy configuration in web/pom.xml
b. mvn -f common/pom.xml install and mvn -f web/pom.xml install
c. Run Jboss
d. mvn -f app/pom.xml -Ddeploy (if you creating war file….use mvn -f web/pom.xml instead)


NOTE for Eclipse Users: Open the AndroMDA generated .classpath file. Note that AndroMDA does not add TestNG to the classpath. Add the following entry to this file to make sure TestNG is in the classpath. Furthermore, if you do not want AndroMDA to overwrite the modified .classpath file, simply disable its generation by commenting out the andromdapp-maven-plugin section in mda\pom.xml.

<classpathentry kind=”var” path=”M2_REPO/org/testng/testng/4.7/testng-4.7-jdk15.jar”/>

or modify that plugin section as below

         <plugin>
            <groupId>org.andromda.maven.plugins</groupId>
            <artifactId>andromdapp-maven-plugin</artifactId>
            <executions>
               <execution>
                  <goals>
                     <goal>eclipse</goal>
                  </goals>
               </execution>
            </executions>
            <configuration>
               <excludes>
                  <exclude>mda/pom.xml</exclude>
               </excludes>
               <classpathMerge>
                  <![CDATA[
                    <classpathentry kind=”var” path=”M2_REPO/org/testng/testng/4.7/testng-4.7-jdk15.jar”/>
                  <classpathentry kind=”src” path=”core/target/test-src”/>
                  ]]>
               </classpathMerge>
            </configuration>
         </plugin>

Advertisements

Posted in AndroMDA | 9 Comments »

AndroMDA Tutorial

Posted by kathayat on July 5, 2007

http://www-128.ibm.com/developerworks/library/wi-arch19/

>> Short androMDA tutorial at IBM

Posted in AndroMDA | 2 Comments »