Skip to content

Appdynamics/dropwizard-sample-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

The drop wizard example application was developed to, as its name implies, provide examples of some of the features present in drop wizard.

Overview

Included with this application is an example of the optional db API module. The examples provided illustrate a few of the features available in JDBI, along with demonstrating how these are used from within dropwizard.

This database example is comprised of the following classes.

  • The PersonDAO illustrates using the SQL Object Queries and string template features in JDBI.

  • The PeopleDAO.sql.stg stores all the SQL statements for use in the PersonDAO, note this is located in the src/resources under the same path as the PersonDAO class file.

  • migrations.xml illustrates the usage of dropwizard-migrations which can create your database prior to running your application for the first time.

  • The PersonResource and PeopleResource are the REST resource which use the PersonDAO to retrieve data from the database, note the injection of the PersonDAO in their constructors.

As with all the modules the db example is wired up in the initialize function of the HelloWorldApplication.

Running The Application

To test the example application run the following commands.

  • To package the example run.

      mvn package
    
  • To setup the h2 database run.

      java -jar target/dropwizard-example-0.7.0-SNAPSHOT.jar db migrate example.yml
    
  • To run the server run.

      java -jar target/dropwizard-example-0.7.0-SNAPSHOT.jar server example.yml
    
  • To hit the Hello World example (hit refresh a few times).

    http://localhost:8080/hello-world

  • To post data into the application.

    curl -H "Content-Type: application/json" -X POST -d '{"fullName":"Other Person","jobTitle":"Other Title"}' http://localhost:8080/people open http://localhost:8080/people

Adding The AppDynamics Java Agent

  • Download the AppDynamics Java Agent from the SAAS controller

      unzip appagent.zip -d /opt/appdynamics/java-agent
    
  • To run the server with the appdyanmics java agent:

      java -javaagent:/opt/appdynamics/java-agent/javaagent.jar -jar target/dropwizard-example-0.7.0-SNAPSHOT.jar server example.yml
    

Releases

No releases published

Packages

No packages published

Languages