Java netbeans ServiceProvider未从方法返回变量
我正在使用NetBeans平台开发一个桌面应用程序。该应用程序将在topcomponent中放置一张地图,用户可以在上面绘制布局和其他元素。元素存储在hashmap中。它们通过鼠标手势添加到hashmap中 此时,我需要在按下UI上的按钮时检索hashmap对象。按钮位于Java netbeans ServiceProvider未从方法返回变量,java,netbeans,lookup,netbeans-platform,service-provider,Java,Netbeans,Lookup,Netbeans Platform,Service Provider,我正在使用NetBeans平台开发一个桌面应用程序。该应用程序将在topcomponent中放置一张地图,用户可以在上面绘制布局和其他元素。元素存储在hashmap中。它们通过鼠标手势添加到hashmap中 此时,我需要在按下UI上的按钮时检索hashmap对象。按钮位于模块a中,hashmap、映射和对象在模块b中定义。我正试图通过使用ServiceProvider模式来实现这一点。因此,我的代码如下: package org.dhviz.design.gui.buttonToolbar; /
模块a
中,hashmap、映射和对象在模块b
中定义。我正试图通过使用ServiceProvider
模式来实现这一点。因此,我的代码如下:
package org.dhviz.design.gui.buttonToolbar;
//...annotations here...
public final class AssociateConsToPipes implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
Collection<? extends DhvizJMapViewerInterface> allHandlers1 = Lookup.
getDefault().lookupAll(DhvizJMapViewerInterface.class);
for (DhvizJMapViewerInterface chi1 : allHandlers1) {
System.out.println(chi1.getMapConsumerHashMap());
}
}
}
package org.dhviz.design.gui.buttonoolbar;
//…这里有注释。。。
公共最终类AssociateConsToPipes实现ActionListener{
@凌驾
已执行的公共无效操作(操作事件e){
集合有很多不相关的代码,不清楚如何初始化HashMap,尝试发布最小(非)工作代码。
@ServiceProvider(service = DhvizJMapViewerInterface.class)
public class DhvizJMapViewer
extends JMapViewer implements DhvizJMapViewerInterface {
protected LinkedHashMap<Integer, MapMarkerElementImpl> mapSourceHashMap = null;
protected LinkedHashMap<Integer, MapMarkerElementImpl> mapConsumerHashMap = null;
protected LinkedHashMap<Integer, MapPipeImpl> mapPipeHashMap = null;
public DhvizJMapViewer() {
this(new MemoryTileCache(), 8);
//map controllers for interaction on the map
mapController = new DefaultDhvizMapController(this);
this.setScrollWrapEnabled(false);
}
public DhvizJMapViewer(TileCache tileCache, int downloadThreadCount) {
//some init code here
}