Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Start Application  (uuid means installed application uuid)

    Code Block
    languagebash
    curl -H "Content-Type: application/json" –X POST http://localhost:9090/rest/apps/start --data '
    {
         "uuid":"9acf6792-60e8-46ea-93a6-160fb6ef0b3f"
    }'
  • Stop Application (uuid means installed application uuid) 

    Code Block
    languagebash
    curl -XPOST http://localhost:9090/rest/apps/stop '
    {
     "uuid": "9acf6792-60e8-46ea-93a6-160fb6ef0b3f"
    }'
  • Uninstall Application (uuid means installed application uuid) 

    Code Block
    languagebash
    curl -XDELETE http://localhost:9090/rest/apps/uninstall '
    {
     "uuid": "9acf6792-60e8-46ea-93a6-160fb6ef0b3f"
    }' 

Create a new Application

How to develop applications

Each application should be developed under independent modules (including backend code and front-end code)

...

    • META-INF/services/org.apache.eagle.app.spi.ApplicationProvider: support to dynamically scan and load extensible application provider using java service provider.
  • webapp/app/apps/${APP_TYPE}: if the application has web portal, then it could add more web code under this directory and make sure building as following in pom.xml 

    Code Block
    <build>
       <resources>
           <resource>
               <directory>src/main/webapp/app</directory>
               <targetPath>assets/</targetPath>
           </resource>
           <resource>
               <directory>src/main/resources</directory>
           </resource>
       </resources>
       <testResources>
           <testResource>
               <directory>src/test/resources</directory>
           </testResource>
       </testResources>
    </build>

...

Test Applications

  • Extend org.apache.eagle.app.test.ApplicationTestBase and initialize injector context
  • Access shared service with @Inject
  • Test application lifecycle with related web resource. 
Code Block
languagejava
@Inject private SiteResource siteResource;
@Inject private ApplicationResource applicationResource;


// Create local site
SiteEntity siteEntity = new SiteEntity();
siteEntity.setSiteId("test_site");
siteEntity.setSiteName("Test Site");
siteEntity.setDescription("Test Site for ExampleApplicationProviderTest");
siteResource.createSite(siteEntity);
Assert.assertNotNull(siteEntity.getUuid());


ApplicationOperations.InstallOperation installOperation = new ApplicationOperations.InstallOperation("test_site", "EXAMPLE_APPLICATION", ApplicationEntity.Mode.LOCAL);
installOperation.setConfiguration(getConf());
// Install application
ApplicationEntity applicationEntity = applicationResource.installApplication(installOperation).getData();
// Start application
applicationResource.startApplication(new ApplicationOperations.StartOperation(applicationEntity.getUuid()));
// Stop application
applicationResource.stopApplication(new ApplicationOperations.StopOperation(applicationEntity.getUuid()));
// Uninstall application
applicationResource.uninstallApplication(new ApplicationOperations.UninstallOperation(applicationEntity.getUuid()));
try {
   applicationResource.getApplicationEntityByUUID(applicationEntity.getUuid());
   Assert.fail("Application instance (UUID: " + applicationEntity.getUuid() + ") should have been uninstalled");
} catch (Exception ex) {
   // Expected exception
}

 

...

Manage Applications and REST API

ApplicationProviderSPILoader: default behavior, automatically loading from class path using SPI

...