/* * jconsole only */ @Override public void _create(String flowName, String link, String attributes) throws XbowException { Map<FlowAttribute, String> attrs = new HashMap<FlowAttribute, String>(); for (String entry : attributes.split(",")) { attrs.put(FlowAttribute.fromString(entry.split("=")[0]), entry.split("=")[1]); } Map<FlowProperty, String> props = new HashMap<FlowProperty, String>(); props.put(FlowProperty.PRIORITY, "medium"); Flow flow = FlowToFlowInfoTranslator.toFlow(new FlowInfo(flowName, link, attrs, props, false)); flow.setFlowadm(flowadm); create(flow); }
/** * Discovers flows present in the system and, if a publisher has been set, publishes each * discovered flow. * * @see FlowManagerMBean#discover() */ @Override public void discover() { if (publisher != null) { synchronized (publisher) { List<FlowInfo> flowsInfo = flowadm.getFlowsInfo(); logger.debug(flowsInfo.size() + " flow(s) discovered."); for (FlowInfo flowInfo : flowsInfo) { // Create new Flow object, initialize and register it. Flow flow = FlowToFlowInfoTranslator.toFlow(flowInfo); flow.setFlowadm(flowadm); publisher.publish(flow); } // Unpublish flows user deleted manually. Set<String> published = new HashSet<String>(); for (Object flow : publisher.getPublished()) { published.add(((Flow) flow).getName()); } Set<String> discovered = new HashSet<String>(); for (Object flowInfo : flowsInfo) { discovered.add(((FlowInfo) flowInfo).getName()); } published.removeAll(discovered); for (Object flowName : published) { try { publisher.unpublish((String) flowName); } catch (NotPublishedException e) { logger.fatal("Error while removing stale flows.", e); } } } } }