Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "BaSyx.Examples.Snippets.AASCreation.Java"
m |
|||
Line 10: | Line 10: | ||
<syntaxhighlight lang="java" style="margin-left: 4em"> | <syntaxhighlight lang="java" style="margin-left: 4em"> | ||
/** | /** | ||
− | + | * Example Asset Administration Shell | |
− | + | */ | |
static class ExampleAssetAdministrationShell extends AssetAdministrationShell { | static class ExampleAssetAdministrationShell extends AssetAdministrationShell { | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
/** | /** | ||
* Constructor | * Constructor | ||
Line 24: | Line 18: | ||
public ExampleAssetAdministrationShell() { | public ExampleAssetAdministrationShell() { | ||
// Set Asset Administration Shell ID | // Set Asset Administration Shell ID | ||
− | + | setIdShort("aas-001"); | |
} | } | ||
} | } | ||
Line 35: | Line 29: | ||
<syntaxhighlight lang="java" style="margin-left: 4em"> | <syntaxhighlight lang="java" style="margin-left: 4em"> | ||
/** | /** | ||
− | * | + | * The BaSyx Deployment instantiates and starts context elements for this example. |
− | + | * | |
+ | * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory | ||
+ | * example context that creates one AAS server, and one SQL based AAS registry. | ||
+ | * | ||
+ | * BaSyxDeployment contexts instantiate all components on the IP address of the host. | ||
+ | * Therefore, all components use the same IP address. | ||
*/ | */ | ||
public static BaSyxDeployment context = new BaSyxDeployment( | public static BaSyxDeployment context = new BaSyxDeployment( | ||
− | + | // Simulated servlets | |
− | + | // - BaSys topology with one AAS Server and one SQL directory | |
− | + | TestContext.sqlContext. | |
− | + | // Deploy example specific servlets to Tomcat server in this context | |
− | + | addServletMapping("/Components/BaSys/1.0/aasServer/*", new AASServerServlet()) | |
− | + | ); | |
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 09:31, 18 August 2020
This code snippet illustrates the creation of an Asset Administration Shell (AAS) with the Java SDK. The BaSys setup for this code snippet is the following:
The BaSys setup consists of a Apache Tomcat server that runs BaSyx Servlets. It contains an Asset Administration Shell provider servlet that exports the created example Asset Administration Shell. The snippet code runs in context of a servlet in the tomcat server and creates, and exports the AAS. It is created as following:
/** * Example Asset Administration Shell */ static class ExampleAssetAdministrationShell extends AssetAdministrationShell { /** * Constructor */ public ExampleAssetAdministrationShell() { // Set Asset Administration Shell ID setIdShort("aas-001"); } }
The AAS sets its short Id meta property to "aas-001". The following code illustrates the deployment of the AAS to the Apache Tomcat server. It maps the path on the HTTP server "/Testsuite/components/BaSys/1.0/SampleAAS/*" to an instance of class AASServlet
. This class exports an Asset Administration Shell as HTTP accessible servlet using the BaSys API for Asset Administration Shells.
/** * The BaSyx Deployment instantiates and starts context elements for this example. * * This example instantiates the BaSyxExamplesContext_1MemoryAASServer_1SQLDirectory * example context that creates one AAS server, and one SQL based AAS registry. * * BaSyxDeployment contexts instantiate all components on the IP address of the host. * Therefore, all components use the same IP address. */ public static BaSyxDeployment context = new BaSyxDeployment( // Simulated servlets // - BaSys topology with one AAS Server and one SQL directory TestContext.sqlContext. // Deploy example specific servlets to Tomcat server in this context addServletMapping("/Components/BaSys/1.0/aasServer/*", new AASServerServlet()) );
The complete, executable code is available in the basyx.examples project in package <<<>>>.
BaSyx project links: Project BaSyx main wiki page | What is BaSyx? | BaSyx Developer Documentation |