OSGi Learning OSGi declared_service Start disabling plug-in deployment

Source: Internet
Author: User

Scene:

1 levels of small to release skills, there are now 2 skills to choose from, Avalanche (V) and Toss (T), because it is a small 1 level, so you can only choose 2 skills of 1.

Creation of 4 bundles

Com.ferry.ability.api There is only one skill interface in the bundle.

Com.ferry.ability.avalanche there is only one implementation class in the bundle that implements the interface avalanche

Com.ferry.ability.toss there is only one implementation class in the bundle that implements the interface toss

Com.ferry.client The bundle calls the skill interface

The code and settings are as follows

Com.ferry.ability.api

[Java] view plain copy public interface iability {public int ability (Int. level); }

COM.FERRY.ABILITY.API Bundle Export Interface package for implementing bundle reference


Com.ferry.ability.Avalanche

[Java] view plain copy public class Avalanche implements iability {@Override public int ability (int           Level) {System.out.println ("V");       return 100; }   }

[Java] view plain copy

The skill interface implements the Bundel Com.ferry.ability.Avalanche and Com.ferry.ability.Toss Import interface package Com.ferry.ability.Toss

[Java] view plain copy public class toss implements iability {@Override public int ability (int leve           L) {System.out.println ("T");       return 100; }   }
Com.ferry.client

[Java]   View plain copy public class hero implements commandprovider{           private IAbility ability;               public void setability (iability ability)  {            this.ability = ability;       }              public  Void unsetability (iability ability)  {            this.ability = null;       }           public void _countdamage (COMMANDINTERPRETER CI) {            if (Ability!=null

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.