📄 myjxta.java
字号:
} addToJoinedGroups(group); if (group.isVisible()) { PeerGroup cpg = AuthenticationUtil.getTLSPeerGroup(peerGroup); if (!AuthenticationUtil.isAuthenticated(cpg)) { if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) { LOG.info("authenticating"); } AuthenticationUtil.authenticate(getView(), cpg); } if (!AuthenticationUtil.isAuthenticated(cpg)) { if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) { LOG.info("not authenticated"); } } } // tell the plugins that we have joined a group m_pluginContainer.notifyAboutGroupJoin(group); if (useAutoRdvMode) { if (shouldBeAutoRdv(group)) { setStatus(STRINGS.getString("status.group.rendezvous.auto") + ": " + group.getAutoRendezVousPeriod()); peerGroup.getRendezVousService().setAutoStart(useAutoRdvMode, group.getAutoRendezVousPeriod()); } } } private void registerCommandDialogPipeListener(final Group group) { String dialogName; // START 1to1Command setStatus(STRINGS.getString("status.dialog.command.register")); dialogName = Dialog.getDialogNamer(OneToOneCommandDialog.class) .getDialogName(group.getPeerGroup().getPeerName()); setStatus(STRINGS.getString("status.dialog.listener.add") + ": " + dialogName); DialogManager.getInstance(group, dialogName, PipeService.UnicastType).addPipeListener(group.getPeerGroup(), new DialogPipeListener() { public void receive(@SuppressWarnings(value = "unused") PeerGroup pg, JxtaBiDiPipe pipe) { // install a local command listener at the // incomming pipe // (each module registers its specific commands // via CommandFactory. DialogManager.installCommandListener(OneToOneCommandDialog.class, group, pipe, MyJXTA.this); } public void receive(PeerGroup pg, Message msg) { // commands are transported via BiDiPipes only - // no need to handle incomming messages LOG.warning("should never happen!" + pg + msg); } }); // END ONE2ONE Command } private void addToJoinedGroups(Group p_group) { joinedGroups.add(p_group); } private void removeFromJoinedGroups(Group p_group) { joinedGroups.remove(p_group); } /** * has this peer the needed tcp-ip connectivity to act as an auto-rdv? * * @param p_group * @return true if the peer should be configured for auto-rdv behaviour */ private boolean shouldBeAutoRdv(Group p_group) { if (p_group.isConnected()) { // comments on this one? are proxyed peers able to act as a rdv? String proxyHost = System.getProperty(Env.HTTP_PROXY_HOST); return proxyHost == null || proxyHost.trim().length() == 0; } return true; // not connected -->enable auto-rdv (not an optimal // solution, // because we may connect later, but the only one that can prevent // complete rdv-less groups right now) } /** * Part of group Lifecycle. Resigns from group. Dismesses all group * resources. */ public void resignGroup(GroupNode groupNode) { Group g = groupNode.getGroup(); boolean resigned = resignGroup(g); if (resigned) { // and update the JxtaTree for (Iterator n = groupNode.getChildren(); n.hasNext();) { removeJxtaNode((JxtaNode) n.next()); } if (g.isVisible()) { view.removeGroupNavigation(g); } } } private boolean resignGroup(Group g) { setStatus(STRINGS.getString("status.group.resign") + " " + g.getName()); // first notify the plugins that we are leaving a group m_pluginContainer.notifyAboutGroupResign(g); // now lets remove the core modules und listeners that are no longer // needed // in this group if (g.isJoined()) { PeerGroup peerGroup = g.getPeerGroup(); String peerNameInGroup = peerGroup.getPeerName(); String pn = Dialog.getDialogNamer(OneToOneCommandDialog.class) .getDialogName(peerNameInGroup); setStatus(STRINGS.getString("status.dialog.listener.remove") + ": " + pn); DialogManager.getInstance(g, pn, PipeService.UnicastType) .clearPipeListeners(peerGroup); setStatus(STRINGS.getString("status.dialog.clear") + ": " + g.getName()); List<Dialog> dialogsInGroup = DialogManager.getDialogsForGroup(g); if (dialogsInGroup != null) { for (Dialog d : dialogsInGroup) { removeDialog(d); } } // xxx: sould the following call remove all of the above // pipe listeners DialogManager.clear(g); SearchManager.getInstance().destoy(); // LOG.error(g.getName()+" - sharemanger stopped"); // and finally resign try { // xxx: shouldn't group.resign() do this peerGroup.getMembershipService().resign(); g.resign(false); // LOG.error(g.getName()+" - resign done"); } catch (PeerGroupException pge) { String msg = "Error resigning from " + g.getName() + ": " + pge.getMessage(); if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) { LOG.log(Level.SEVERE, msg, pge); } setStatus(msg); } if (!g.isJoined()) { // todo: clarify: we can call removeFromJoinedGroups from within // a Object repository listener, // but due to the fact that the repository removes all dependend // nodes recursivly this // will not be accurate (sub groups would also be removed, but // they are still joined?) removeFromJoinedGroups(g); // xxx: hack Group parentGroup = g.getParentGroup(); if (this.view != null && parentGroup != null) { this.view.setTitle(parentGroup.getName()); } } } return !g.isJoined(); } /** * Add a new JxtaNode object to the displayed tree. View takes care to * not put in nodes twice * * @param node the node to display */ public void addJxtaNode(JxtaNode node) { addJxtaNode(node, false); } public void addJxtaNode(JxtaNode node, boolean select) { this.view.addJxtaNode(node, select); JxtaNode parent = node.getParent(); if (parent == null) { parent = node.getJxtaNode().getParent(); } boolean added= MyJxtaObjectRepository.getObjectRepository().add(node, parent); if (added && node instanceof PeerNode) { PeerNode peerNode = (PeerNode) node; if (peerNode.getParent().getGroup().isVisible()){ PresenceController controller = PresenceController.getController(peerNode.getParent().getGroup().getPeerGroup()); if (controller!=null){ controller.addEntry(new PeerEntry(peerNode),this); } } } } public void removeJxtaNode(JxtaNode p_jxtaNode) { view.removeJxtaNode(p_jxtaNode); MyJxtaObjectRepository.getObjectRepository().remove(p_jxtaNode); } public void addListener(DialogListener listener) { boolean isEmpty = true; for (PluginView pluginView : this.view.getPluginPanels()) { pluginView.getDialog().addListener(listener); isEmpty = false; } if (isEmpty) { if (Logging.SHOW_WARNING && LOG.isLoggable(Level.WARNING)) { LOG.severe("PluginView Plugin Collection is empty"); } } } public void removeListener(DialogListener listener) { for (PluginView pluginView : this.view.getPluginPanels()) { pluginView.getDialog().removeListener(listener); } } public void addInboundFilter(DialogFilter filter) { for (PluginView pluginView : this.view.getPluginPanels()) { pluginView.getDialog().getInboundFilters().addFilter(filter); } } public void removeInboundFilter(Class dialogFilterClass) { for (PluginView pluginView : this.view.getPluginPanels()) { pluginView.getDialog().getInboundFilters().removeFilter( dialogFilterClass); } } public void addOutboundFilter(DialogFilter filter) { for (PluginView pluginView : this.view.getPluginPanels()) { pluginView.getDialog().getOutboundFilters().addFilter(filter); } } public void removeOutboundFilter(Class<?> dialogFilterClass) { for (PluginView pluginView : this.view.getPluginPanels()) { pluginView.getDialog().getOutboundFilters().removeFilter( dialogFilterClass); } } public View getView() { return this.view; } /** * Application shutdown */ public void destroy() { new Thread("DestroyMyJxta Thread") { public synchronized void start() { setDaemon(true); super.start(); } public void run() { try { int joinedCount = joinedGroups.size(); for (int i = joinedCount - 1; i >= 0; i--) { Group g = joinedGroups.get(i); resignGroup(g); } if (joinedGroups.size() > 0) { LOG.severe("did not leave all groups cleanly!"); } try { if (m_pluginContainer != null) { m_pluginContainer.destroy(); } } catch (Exception e) { e.printStackTrace(); } if (MyJXTA.this.administrationListener != null) { MyJXTA.this.administrationListener.interrupt(); Env.delete(new File(Env.getHomeDirPath() + File.separator + Env.ADMINISTRATION_PORT)); } view.disposeView(); MyPreferenceManager.getInstance().shutdown(); administrationListener.stopListener(); } catch (Throwable e) { e.printStackTrace(); } finally { // nano: i would like to avoid this call - but CMS has a bug and will never close one // of his MessageProcessor Threads // @see net.jxta.share.MessageProcessor.run(MessageProcessor.java:105) Thread hardTerminateThread = new Thread("Hard Terminate after Timeout Thread") {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -