Familiar with the APIs that will be used for Apache Tuscany SCA for C ++. This document describes the main components of this API for quick start.
Build and connect simple C ++ Service Components
About Tuscany
Apache Tuscany is an incubator Apache Software Foundation project. One of the goals of this project is to obtain the C ++ runtime that implements the following service component architecture (SCA) specifications:
- SCA assembly model)
- Sca c ++ client and implementation (sca c ++ client and implementation)
- In this article, we will detail how to develop and deploy service components when using C ++ for Apache Tuscany C ++.
Introduction
The Tuscany C ++ service component architecture (SCA) allows you to use standard C ++ code to build an SCA component and deploy it to the location where it can be searched and loaded during the SCA runtime. To realize the dynamic loading function of this component, a series of description files are required during the runtime. These components and your own header files are used together to generate proxy and packaging, allows you to call your components from other components or client code in a way similar to processing local C ++ objects.
We will first create a simple SCA component, then create the second component, and connect the two together.
Microsoft Visual Studio is used as the development environment, but you can also use the command line compiler and text editor. You will learn how to set up studio projects and develop applications.
Note: Tuscany SCA depends on the Tuscany SDO project and Apache axis2/C Project. Before starting work, make sure that the Tuscany SCA/SDO library and Apache axis library are set in your path environment variable. For more information, see project download instructions.
When running Tuscany sca c ++, you need to know where the modules and components are deployed. The deployment root directory is identified by the Environment Variable tuscany_scacpp_system_root. We will immediately set this variable so that we can run our test program from Visual Studio. If you are using a command line, you do not need to set the content before running.
Tuscany_scacpp_system_root specifies the path of the deployed modules and subsystems for the runtime, which will be described later. The root directory must have two subdirectories named "modules" and "subsystems ".
Use Control Panel settings: tuscany_scacpp_system_root = C:/mybasicsample.
Go to control panel and system, select the Advanced tab, and click environment variables. Click "new", set "variable name" to tuscany_scacpp_system_root, and set "variable value" to C:/mybasicsample. Click OK to set the environment variable.
Create a directory named mybasicsample, which contains two subdirectories: modules and subsystems.
Now you are ready for deployment. We may need to write something that can be deployed.
A brief review of the SCA specification (you have read this specification-Right ?), Remember that the SCA system contains one or more subsystems. Each subsystem contains a list of module components. Each module component is actually implemented by the module. In C ++, there is a set of descriptive XML files used to generate service proxies and packages during compilation and to find the services provided during runtime. Before you start development, you need to understand these files. The file describing the subsystem must be named SCA. subsystem and saved in its own subdirectory, which is located in the subsystems directory in the root directory. The SCA. Subsystem File describes which modules are involved in the subsystem. A module component can be regarded as a simple component of a subsystem. A module component has a name and simultaneously instructs the module component to implement its behavior:
List 1. module components
<Subsystem xmlns = "http://www.osoa.org/xmlns/sca/0.9" name = "myservicesubsystem"> <Modulecomponent name = "mymodulecomponent" module = "floatconverter"/> </Subsystem> |
Listing 1 tells SCA that the module component "mymodulecomponent" is implemented by a module named "floatconverter", so we must build this module.
The SCA. subsystem file is actually a runtime component and is useless during compilation. Other files (component type files and SCA. Module files) Describe the "floatconverter" module so that it can be found at runtime. These files also help code generators build packaging and proxies for services. We will discuss these files in more detail in the following development process.
Now let's go back to the beginning of this process. We want to deploy the C ++ class as a service and put the service into a module named "floatconverter. The following steps describe how to complete this task.
First, although there may be a risk of redundancy (many people have already done this before), we will create an example c ++ application.
Note: Before you start the development process, you must download and build the SCA/SDO code, or download the binary version, so that you can later tell the project where to find the SCA runtime. Set two environment variables, tuscany_scacpp and tuscany_sdocpp, to the deployment directories of the SCA and SDO projects. The corresponding bin, Lib, and include directories exist under these two directories.
First, I want to create an abstract base class to indicate the services we want to publish. This is equivalent to defining Java interfaces. The header file we created here will be used by the client application to explain available service interfaces.
This class is located in the header file named "example. H:
......
View Original