. The solution to the problem after multiple modules in net: OSGi prototype

Source: Internet
Author: User
Tags definition

At present, only the basic functions have been done, such as:

Separate AppDomain containers for each module

Activator activation

Exported service Checks

However, although this, but the current version has been able to achieve module separation, interdependence and other functions, the module division has been very good role.

First, the basic structure:

Currently, this framework does not support the modularity of the UI, it only supports module loading under a single machine (which will be improved later).

Characteristics:

Runtime, Module1, Module2, Module3 are all running under their own AppDomain, without interfering with each other.

By loading the module in an isolated AppDomain way, you can easily uninstall tasks such as AppDomain, a DLL, DLL version switching, and facilitate subsequent extensions

To see how the module is written.

The Ordermodule library is the main business logic and the location of the module definition

Ordermodule.publicinterfaces are common definitions, such as interfaces, events, DTO, etc. that are independent (if you don't mind this, and can be merged into a single library), given the convenience of distribution.

Module definition file:

<?xml version= "1.0" encoding= "Utf-8"?>
<Module>
  <name>order
  module</name> <Version>1</Version>
  <Assembly>OrderModule</Assembly>
  <Activator> Ordermodule.activator</activator>  //This is the

first ClassType of the OSGi call, which will execute the 2 methods inside: Start and stop
  

< Requiredservice>loggingmodule.publicinterfaces.ilog</required

service>//which other Service the module needs to rely on, can have multiple
  

<ProvidedService>OrderModule.PublicInterfaces.IOrderProcessor<

/providedservice>// This module will provide services that can have multiple
</Module>

Activator:

Class Activator:OSGIFramework.BundleActivator
    {public
        override void Startup (bundlecontext BC)
        {
            Console.WriteLine ("Ordermodule Startup");
    
            

Bundlecontext.current.registerprovidedservice<iorderprocessor, orderprocessorimpl> ();
            Registration Service
        } public
    
        override void Stop (bundlecontext BC)
        {
            Console.WriteLine ("Ordermodule Stop");
    
            

Bundlecontext.current.unregisterprovidedservice<iorderprocessor, 

orderprocessorimpl> ();
            Uninstall Service
        }
    }

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.