This documentation is for WSO2 App Factory 1.0.0. View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

The sample is described in the following topics.


Introduction

<Describe what the sample does. What is the business use case it demonstrates>

Prerequisites

Download and set up WSO2 App Factory using the instructions given in section Obtaining the Product.

<Anything else?>

Building the Sample


Executing the Sample

<Please make sure you provide information as to WHY a particular step is executed. For example, rather than just mentioning "copy file x to location, also mention the purpose of that step>

1. Create a API that gives Washington whether details in sandbox and London whether details in the production environment. Lets call this Weather API. Internally it calls the API of  www.worldweatheronline.com

 





2. Create an application in AppFactory. Lets call it Customer Portal - cportal application. When you create an application in App Factory it will be automatically created in API-M.


 











3. Subscribe the application to the Weather API as follows.


 







4. Generate keys by clicking on the create dependencies.


 











5.  Write your application to get keys by calling the CarbonContext and Registry APIs. The correct sandbox and production keys will be used depending on where the application is deployed. Here is the code to do that.

 

{applicationName}
CarbonContext cCtx = CarbonContext.getCurrentContext();
Registry registry = (Registry) cCtx.getRegistry(RegistryType.SYSTEM_GOVERNANCE);
Resource resource = registry.get("Key");
if(resource.getContent() instanceof String){
    key = (String) resource.getContent();
}else{
    key = new String((byte[]) resource.getContent());
}

  6. Deploy the application to "Development" environment and view results


 



7. Promote the application to "Production" environment and view results.




The results of Development environment  differs from Production environment because the keys that is used by the two environments are different. The programmer is unaware about the sandbox and production keys, and everything is handled underneath.

<pls also mention observations and conclusions based on what you mentioned in the sample description section as applicable>

  • No labels