Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "BaSyx.Examples.Snippets.AASCreation.Java"

(Created page with "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: {|style="text-ali...")
 
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
  
 
{|style="text-align: center; width: 100%"
 
{|style="text-align: center; width: 100%"
|[[File:BaSyx.Snippet.AASConnectorConnection.Java.png|center|512px]]
+
|[[File:BaSyx.Snippet.AASConnectorConnectionAAS.Java.png|center|512px]]
 
|}
 
|}
  
Line 10: Line 10:
 
<syntaxhighlight lang="java" style="margin-left: 4em">
 
<syntaxhighlight lang="java" style="margin-left: 4em">
 
/**
 
/**
* Example Asset Administration Shell
+
* Example Asset Administration Shell
*/
+
*/
 
static class ExampleAssetAdministrationShell extends AssetAdministrationShell {
 
static class ExampleAssetAdministrationShell extends AssetAdministrationShell {
 
/**
 
* Version number of serialized instance
 
*/
 
private static final long serialVersionUID = 1L;
 
 
 
/**
 
/**
 
* Constructor
 
* Constructor
Line 24: Line 18:
 
public ExampleAssetAdministrationShell() {
 
public ExampleAssetAdministrationShell() {
 
// Set Asset Administration Shell ID
 
// Set Asset Administration Shell ID
setId("aas-001");
+
setIdShort("aas-001");
 
}
 
}
 
}
 
}
Line 35: Line 29:
 
<syntaxhighlight lang="java" style="margin-left: 4em">
 
<syntaxhighlight lang="java" style="margin-left: 4em">
 
/**
 
/**
  * Instantiate and start context elements for this example. BaSyxDeployment contexts instantiate all
+
  * The BaSyx Deployment instantiates and starts context elements for this example.  
* components on the IP address of the host. Therefore, all components use the same IP address.  
+
*
 +
* 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(
// Servlets for example snippet
+
// Simulated servlets
new BaSyxExamplesContext_Empty().
+
// - BaSys topology with one AAS Server and one SQL directory
// Deploy example specific servlets to Tomcat server in this context
+
TestContext.sqlContext.
addServletMapping("/Testsuite/components/BaSys/1.0/SampleAAS/*",         new AASServlet(new ExampleAssetAdministrationShell()))
+
// Deploy example specific servlets to Tomcat server in this context
 
+
addServletMapping("/Components/BaSys/1.0/aasServer/*", new AASServerServlet())
);
+
);
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 50: Line 49:
  
  
The complete, executable code is available in the basyx.examples project in package <<<>>>.
+
The complete, executable code is available in the basyx.examples project in package org.eclipse.basyx.examples.snippets.aas.
  
  

Latest revision as of 09:47, 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:

BaSyx.Snippet.AASConnectorConnectionAAS.Java.png


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 org.eclipse.basyx.examples.snippets.aas.


BaSyx project links: Project BaSyx main wiki page | What is BaSyx? | BaSyx Developer Documentation

Back to the top