我的项目由以下包组成,它们使用给定的 .xml 文件定义声明式服务:
角色生成器.gui
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="characterbuilder.gui">
<implementation class="characterbuilder.gui.ApplicationFrame"/>
<reference bind="setMenuScripting" cardinality="1..1" interface="characterbuilder.scripting.menu.IMenuScripting" name="IMenuScripting" policy="dynamic"/>
</scr:component>
characterbuilder.pluginmanager
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="characterbuilder.pluginmanager">
<implementation class="characterbuilder.pluginmanager.implementation.PluginManager"/>
</scr:component>
characterbuilder.scripting
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="characterbuilder.scripting">
<implementation class="characterbuilder.scripting.internal.CharacterBuilderScripting"/>
<reference bind="setGameSystem" cardinality="1..1" interface="characterbuilder.systemmanager.IGameSystem" name="IGameSystem" policy="static"/>
<reference bind="setXMLHandler" cardinality="1..1" interface="characterbuilder.xmlhandling.xmlhandler.IXMLHandler" name="IXMLHandler" policy="static"/>
<reference bind="setPluginManager" cardinality="1..1" interface="systemplugin.manager.IPluginManager" name="IPluginManager" policy="static"/>
<service>
<provide interface="characterbuilder.scripting.menu.IMenuScripting"/>
</service>
</scr:component>
characterbuilder.xml 处理
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="character.builder.xml.handling">
<implementation class="characterbuilder.xmlhandling.implementation.XMLHandler"/>
<service>
<provide interface="characterbuilder.xmlhandling.xmlhandler.IXMLHandler"/>
</service>
</scr:component>
characterbuilder.dummysystem
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="DummySystem">
<implementation class="dummygamedefinition.systemmanager.DummySystemManager"/>
<service>
<provide interface="characterbuilder.systemmanager.IGameSystem"/>
</service>
</scr:component>
当我从控制台使用“服务”命令获取所有注册的服务时,只有 IXMLHandler 和 IGameSystem 被注册过。
在过去的三天里,我花了十几个小时试图让这些服务正常工作,但我的情况比开始时最糟糕,因为我仍然不知道该做什么,什么时候开始我没有不要感到如此沮丧和愚蠢。