-----------------------------------------
?接口的实现部分
-------------------------------------------
<?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="com.cvicse.usap.framework.views.MyAccordionView"> <implementation class="com.cvicse.usap.framework.views.MyAccordionView"/> <service> <provide interface="com.cvicse.usap.framework.myapplication.api.IMyAccordionView"/> </service> </scr:component>
-------------------------------------------
类com.cvicse.usap.framework.MyVappcation
-------------------------------------------
------------------------------------
? 实现类中引入了其他的service
------------------------------------
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="myVapplication" factory='vaadin.app'> <implementation class="com.cvicse.usap.framework.MyVappcation"/> <reference bind="bindAccordionTab" cardinality="0..n" interface="com.cvicse.usap.framework.myapplication.api.IMyAccordionView" name="com.cvicse.usap.framework.myapplication.api.IMyAccordionView" policy="dynamic" unbind="unbindAccordionTab"/> <reference bind="bindTabsheetTab" cardinality="0..n" interface="com.cvicse.usap.framework.myapplication.api.IMyTabsheetView" name="com.cvicse.usap.framework.myapplication.api.IMyTabsheetView" policy="dynamic" unbind="unbindTabsheetTab"/> </scr:component>
?
------------------------------------
?? 定义了一个集合
------------------------------------
// 左侧导航菜单内容集合--单例对象--小心使用 public List<IAccordionView> accordionContributions = Collections .synchronizedList(new ArrayList<IAccordionView>());
?
------------------------------------------------------------------------------------------------------------
?bind="bindAccordionTab" 对应的方法。 bind是指bundle加载时注册用的也就是向集合中增加实现的方法。
?如果有多个实现,该方法会被调用多次。
------------------------------------------------------------------------------------------------------------
/** * 注册左侧Accordion菜单 * * @param accordionView */ public void bindAccordionTab(IAccordionView accordionView) { // 将要绑定的菜单页加入集合中 accordionContributions.add(accordionView); // Component component = accordionView.getView(this); if (initialized) { try { // TODO 从OSGI DS 获取 Component component = accordionView.getView(this); // 判断权限,如果有权限,就增加到导航菜单 if (getSecurity().isPermitted(accordionView.getResourceURI())) { accordionComponentMap.put(accordionView.getResourceURI(), component); doAccordionClick(component); if (null == accordionView.getIconPathType()) { homeScreen.getNavigationAccorion().addTab(component, accordionView.getName(), null); } else if (accordionView.THEME_RESOURCE .equals(accordionView.getIconPathType())) { homeScreen.getNavigationAccorion().addTab(component, accordionView.getName(), new ThemeResource(accordionView.getIconPath())); } else { homeScreen.getNavigationAccorion().addTab( component, accordionView.getName(), new ClassResource(accordionView.getClass(), accordionView.getIconPath(), this)); } } } catch (Exception e) { e.printStackTrace(); } } }?
?