+1 (972) 883-2091
ECSS 4.220, 800 W Campbell Rd, Richardson, TX 75083–0688, US

Tunning the “traffic-simulation” module configuration and creating its inner packages

The “traffic-simulation” module is responsible for creating the simulation host and executing the core of the simulation. In this tutorial, we illustrate the process of tuning the configuration of the “traffic-simulation” module and the creation of its inner packages

1. Tunning the POM configurations of the Traffic Simulation System

First, we start by updating the POM configuration of the “traffic-simulation” module to manage its dependencies.

  1. Double click on the file “pom.xml” under the “traffic-simulation” module. The Maven POM Editor should appear.
  2. In the opened window, click on the tab “pom.xml”. The content of the project object model (POM) should be displayed in XML format as follows:
                
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <parent>
             <groupId>edu.utdallas.mavs.traffic</groupId>
             <artifactId>traffic</artifactId>
             <version>1.0.0-SNAPSHOT</version>
          </parent>
          <artifactId>traffic-simulation</artifactId>
          <name>traffic-simulation</name>
          <description>Simualtion of the traffic system</description>
       <packaging>jar</packaging>
    </project>
    
  3. Add the module dependencies configuration as follows:
                
    <!-- ======================================= -->
    <!-- ==== Dependencies === -->
    <!-- ======================================= -->
    <dependencies>
    <!-- Project Dependencies -->
       <dependency>
          <groupId>edu.utdallas.mavs.divas</groupId>
          <artifactId>divas-core</artifactId>
          <version>${divas.version}</version>
       </dependency>
       <!-- General Dependencies -->
       <dependency>
          <groupId>com.google.inject</groupId>
          <artifactId>guice</artifactId>
          <version>${guice.version}</version>
       </dependency>
    </dependencies>
    

    Please import DIVAs if there exists error at dependency “divas-core”.

  1. The assembly mechanism in Maven provides an easy way to create distributions using a assembly descriptor and dependency information found in you POM. In order to use the assembly plug-in you need to configure the assembly plug-in in your POM. To do so, copy/paste the following code into the “pom.xml” to define maven configuration used to build the “traffic-simulation” module:
                <!-- ======================================= -->
                <!-- ==== Assembly Plugin Configuration ==== -->
                <!-- ======================================= -->
                <build>
                   <plugins>
                      <plugin>
                         <artifactId>maven-assembly-plugin</artifactId>
                         <configuration>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <archive>
                               <manifest>
                                  <mainClass>edu.utdallas.mavs.traffic.simulation.TrafficMain</mainClass>
                               </manifest>
                            </archive>
                            <descriptorRefs>
                               <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <appendAssemblyId>false</appendAssemblyId>
                         </configuration>
                         <executions>
                            <execution>
                               <id>make-assembly</id>
                               <phase>install</phase>
                               <goals>
                                  <goal>single</goal>
                               </goals>
                            </execution>
                         </executions>
                      </plugin>
                      <plugin>
                         <artifactId>maven-antrun-plugin</artifactId>
                         <executions>
                            <execution>
                               <id>copy_resources</id>
                               <phase>install</phase>
                               <configuration>
                                  <tasks>
                                     <copy todir="${project.build.directory}">
                                        <fileset dir="${basedir}" includes="*.properties" />
                                     </copy>
                                  </tasks>
                               </configuration>
                               <goals>
                                  <goal>run</goal>
                               </goals>
                            </execution>
                         </executions>
                      </plugin>
                   </plugins>
                </build>
    

2. Creating the “traffic-simulation” main packages

 

  1. Right click on the folder “src/main/java” > New > Package and create a package named “edu.utdallas.mavs.traffic.simulation”. You can use your own rules to name the package.
  2. Inside the package “edu.utdallas.mavs.traffic.simulation”, create a class named “TrafficMain”. This is done by: Right click the “edu.utdallas.mavs.traffic.simulation” package > select “New” > “Class” and type “TrafficMain” inside the “Name” text box. At this stage, we will leave the class implementation empty as we are interested in specifying the main taxonomy of our project. Detailed implementation steps of this class will be discussed in tutorial 9.
  3. Create the following sub-packages inside “edu.utdallas.mavs.traffic.simulation”:
      1. config
      2. guice
      3. host
      4. sim

    This can be done by repeating the following steps for each of the aforementioned sub-packages: Right click the “edu.utdallas.mavs.traffic.simulation” package > select “New” > “Package” and type the package name inside the “Name” text box.

    At the end of this tutorial, your package hierarchy should look like the following: