Step 3: Use spring to develop osgi -- (step 2: Engineering) Step 3: Use spring to develop osgi -- (step 1: Environment) step 3: Use spring to develop osgi -- (step 2: Engineering)

Source: Internet
Author: User

The STS and Virgo environments have been configured above, and the Virgo server can be successfully run. Next we will use STS to build several projects.

We simulate an example of registration. In our actual case, data is sometimes written to the database, written to a file, or written to the memory, which is convenient for different operations. This example may not completely explain the problem, but it is enough to explain how to build a project through STs.

We will create four bundle, one is the bundle registered through the page, and the other is the bundle of the input interface, one is the bundle that writes files to the database (of course, it is only a simple implementation and is not actually written into the database), and the other is the bundle that writes files.

Interface Project Creation

Create a vigro plug-in Project

Enter the project name, click Next, and wait until the project is completed. Select the default one. No additional modifications are required.

Because it is an interface project, no additional configuration is required. You only need to export the directory to be exported.

Create an istore interface to identify the interface to store login information. The interface content is as follows:

View code

 
Public InterfaceIstore {VoidStore (loginbean );}

Javabean is used to name loginbean, which is used to simulate the storage of login information,CodeAs follows:

View code

 Public   Class  Loginbean {  Private  String name;  Private  String pass;  Private  String repass;  Private   Int  Age;  Public String getname (){  Return  Name ;}  Public   Void  Setname (string name ){  This . Name = Name ;}  Public  String getpass (){  Return  Pass ;}  Public   Void  Setpass (string pass ){ This . Pass = Pass ;}  Public  String getrepass (){  Return  Repass ;}  Public   Void  Setrepass (string repass ){  This . Repass = Repass ;}  Public   Int  Getage (){  Return Age ;}  Public   Void Setage ( Int  Age ){  This . Age = Age ;}} 

Then double-click the manifest. MF file under the META-INF, set the exported directory, that is, other modules can access the directory or interface

Select the runtime tag and add the directory you just set

Then read the content in mainifest. MF:

View code

Manifest-version: 1.0Bundle-Version: 1.0.0Bundle-Name: registerbundle-Manifestversion: 2Bundle-Description: tgytbundle-Symbolicname: COM. tgyt. Test. registerexport-Package: COM. tgyt. Test. Register
Create a database storage project

The purpose of this project is to store data in the database. Of course, it is only a schematic project, and the data is not actually stored.

The creation method is the same as above. Modify the project name and then import the interface created above in the import package.

Here, you need to reference the above project, right-click the new project, select project reference, and reference the project created above

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.