List of usage examples for javax.management AttributeList AttributeList
public AttributeList()
AttributeList
. From source file:gestionale.persistence.DAOSalva.java
public void creaClienteXML(Gestionale gestionale) { gestionale.ordinaClienti();/*w ww . ja va2 s . co m*/ Document documet = new Document(); Element radiceXML = new Element("generale"); for (int i = 0; i < gestionale.numeroClienti(); i++) { ClienteAstratto cliente = gestionale.getClienteAstratto(i); if (cliente instanceof Privato) { Privato privato = (Privato) cliente; Element elementCliente = new Element("cliente"); List newAttributes = new AttributeList(); newAttributes = new AttributeList(); newAttributes.add(new Attribute("type", "privato")); elementCliente.setAttributes(newAttributes); Element subElemId = new Element("id"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", "" + privato.getId())); subElemId.setAttributes(newAttributes); Element subElemNome = new Element("nome"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getNome())); subElemNome.setAttributes(newAttributes); Element subElementNumTel = new Element("numTel"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getReato())); subElementNumTel.setAttributes(newAttributes); Element subElementRecapito = new Element("recapito"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getRecapito())); subElementRecapito.setAttributes(newAttributes); Element subElementReato = new Element("reato"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getReato())); subElementReato.setAttributes(newAttributes); Element subElementCellulare = new Element("cellulare"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getCellulare())); subElementCellulare.setAttributes(newAttributes); Element subElementCognome = new Element("cognome"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getCognome())); subElementCognome.setAttributes(newAttributes); Element subElementCodFisc = new Element("codFisc"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getCodFisc())); subElementCodFisc.setAttributes(newAttributes); Element subElementLuogoNascita = new Element("luogoNascita"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getLuogoNascita())); subElementLuogoNascita.setAttributes(newAttributes); Element subElementProvNascita = new Element("provNascita"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.getProvNascita())); subElementProvNascita.setAttributes(newAttributes); Element subElementDataNascita = new Element("dataNascita"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", privato.formatDataNascita())); subElementDataNascita.setAttributes(newAttributes); elementCliente.addContent(subElemId); elementCliente.addContent(subElemNome); elementCliente.addContent(subElementNumTel); elementCliente.addContent(subElementRecapito); elementCliente.addContent(subElementReato); elementCliente.addContent(subElementCellulare); elementCliente.addContent(subElementCognome); elementCliente.addContent(subElementCodFisc); elementCliente.addContent(subElementLuogoNascita); elementCliente.addContent(subElementProvNascita); elementCliente.addContent(subElementDataNascita); radiceXML.addContent(elementCliente); } else { Ente ente = (Ente) cliente; Element elementCliente = new Element("cliente"); List newAttributes = new AttributeList(); newAttributes = new AttributeList(); newAttributes.add(new Attribute("type", "ente")); elementCliente.setAttributes(newAttributes); Element subElemId = new Element("id"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", "" + ente.getId())); subElemId.setAttributes(newAttributes); Element subElemNome = new Element("nome"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", ente.getNome())); subElemNome.setAttributes(newAttributes); Element subElementNumTel = new Element("numTel"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", ente.getReato())); subElementNumTel.setAttributes(newAttributes); Element subElementRecapito = new Element("recapito"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", ente.getRecapito())); subElementRecapito.setAttributes(newAttributes); Element subElementReato = new Element("reato"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", ente.getReato())); subElementReato.setAttributes(newAttributes); Element subElementCellulare = new Element("cellulare"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", ente.getCellulare())); subElementCellulare.setAttributes(newAttributes); Element subElementPIva = new Element("partIva"); newAttributes = new AttributeList(); newAttributes.add(new Attribute("value", ente.getPartitaIva())); subElementPIva.setAttributes(newAttributes); elementCliente.addContent(subElemId); elementCliente.addContent(subElemNome); elementCliente.addContent(subElementNumTel); elementCliente.addContent(subElementRecapito); elementCliente.addContent(subElementReato); elementCliente.addContent(subElementCellulare); elementCliente.addContent(subElementPIva); radiceXML.addContent(elementCliente); } } documet.addContent(radiceXML); XMLOutputter outputter = new XMLOutputter(); Format format = Format.getPrettyFormat(); format.setIndent(" "); format.setLineSeparator("\n"); outputter.setFormat(format); FileWriter fileWriter = null; try { fileWriter = new FileWriter("cliente.xml"); outputter.output(documet, fileWriter); logger.info("Cliente creato correttamente"); } catch (IOException ioe) { logger.info("IOException: " + ioe.getMessage()); return; } finally { if (fileWriter != null) { try { fileWriter.close(); } catch (IOException ioe) { logger.info("IOException: " + ioe.getMessage()); return; } } } creaFascicoli(gestionale.listaFascicoli()); //creaCause(gestionale.listaCause()); creaUdienze(gestionale.listaUdienze()); }
From source file:org.rifidi.edge.configuration.RifidiService.java
/** * Get all attributes and their values./* w w w . j a v a 2s. c o m*/ * * @return */ public AttributeList getAttributes() { AttributeList ret = new AttributeList(); for (String name : nameToMethod.keySet()) { try { Object value = nameToMethod.get(name).invoke(this); ret.add(new Attribute(name, value)); } catch (IllegalArgumentException e) { logger.error("Error when invoking getter " + nameToMethod.get(name) + ": " + e); } catch (IllegalAccessException e) { logger.error("Error when invoking getter " + nameToMethod.get(name) + ": " + e); } catch (InvocationTargetException e) { logger.error("Error when invoking getter " + nameToMethod.get(name) + ": " + e); } } return ret; }
From source file:com.wakacommerce.common.cache.StatisticsServiceImpl.java
@Override public AttributeList getAttributes(String[] attributes) { AttributeList list = new AttributeList(); for (Map.Entry<String, CacheStat> stats : cacheStats.entrySet()) { list.add(new Attribute(stats.getKey(), stats.getValue().getHitRate().doubleValue())); }/*from ww w . j ava 2 s . c o m*/ return list; }
From source file:com.zavakid.mushroom.impl.MetricsSourceAdapter.java
@Override public AttributeList getAttributes(String[] attributes) { updateJmxCache();/*w w w . j a v a 2 s . c om*/ synchronized (this) { AttributeList ret = new AttributeList(); for (String key : attributes) { Attribute attr = attrCache.get(key); if (LOG.isDebugEnabled()) { LOG.debug(key + ": " + attr.getName() + "=" + attr.getValue()); } ret.add(attr); } return ret; } }
From source file:org.rifidi.edge.configuration.RifidiService.java
/** * Get a list of attributes./* ww w . ja v a 2 s . com*/ * * @param attributeNames * @return */ public AttributeList getAttributes(Collection<String> attributeNames) { AttributeList ret = new AttributeList(); try { for (String name : nameToMethod.keySet()) { if (attributeNames.contains(name)) { Object value = nameToMethod.get(name).invoke(this); ret.add(new Attribute(name, value)); } } return ret; } catch (IllegalArgumentException e) { logger.error(e); } catch (IllegalAccessException e) { logger.error(e); } catch (InvocationTargetException e) { logger.error(e); } return ret; }
From source file:org.eclipse.smila.management.jmx.AgentMBean.java
/** * {@inheritDoc}/*from w w w . ja v a2s . c o m*/ * * @see javax.management.DynamicMBean#getAttributes(java.lang.String[]) */ public AttributeList getAttributes(final String[] attributes) { if (attributes == null) { throw new RuntimeOperationsException(new IllegalArgumentException("attributeNames must not be null"), "Exception occured trying to get attributes of a " + "LocalMBean"); } final AttributeList attributeList = new AttributeList(); String attributeName; for (int i = 0; i < attributes.length; i++) { attributeName = attributes[i]; try { attributeList.add(new Attribute(attributeName, getAttribute(attributeName))); } catch (final Throwable e) { _log.error("getAttributes(String[]), failed to get \"" + attributeName + "\"", e); } } return attributeList; }
From source file:org.rifidi.edge.core.configuration.services.ConfigurationServiceImpl.java
/** * Load the configuration. Not thread safe. * /*from w w w .ja v a2s. c o m*/ * @return */ private ConcurrentHashMap<String, Set<DefaultConfigurationImpl>> loadConfig() { ConcurrentHashMap<String, Set<DefaultConfigurationImpl>> ret = new ConcurrentHashMap<String, Set<DefaultConfigurationImpl>>(); ConfigurationStore store; try { store = (ConfigurationStore) jaxbContext.createUnmarshaller().unmarshal(persistanceResource.getFile()); } catch (IOException e) { logger.error(e); return ret; } catch (JAXBException e) { logger.error(e); return ret; } if (store.getServices() != null) { for (ServiceStore service : store.getServices()) { if (ret.get(service.getFactoryID()) == null) { ret.put(service.getFactoryID(), new CopyOnWriteArraySet<DefaultConfigurationImpl>()); } AttributeList attributes = new AttributeList(); // get all properties for (String key : service.getAttributes().keySet()) { // factoryid is already processed if (Constants.FACTORYID.equals(key)) { continue; } // type is already processed if (Constants.FACTORY_TYPE.equals(key)) { continue; } attributes.add(new Attribute(key, service.getAttributes().get(key))); } if (!checkName(service.getServiceID())) { continue; } ret.get(service.getFactoryID()).add(createAndRegisterConfiguration(service.getServiceID(), service.getFactoryID(), attributes, service.getSessionDTOs())); serviceNames.add(service.getServiceID()); } } return ret; }
From source file:org.rifidi.edge.configuration.ConfigurationServiceImpl.java
/** * Load the configuration. Not thread safe. * /*from www . java 2 s. c om*/ * @return */ private ConcurrentHashMap<String, Set<DefaultConfigurationImpl>> loadConfig() { ConcurrentHashMap<String, Set<DefaultConfigurationImpl>> ret = new ConcurrentHashMap<String, Set<DefaultConfigurationImpl>>(); ConfigurationStore store; try { store = (ConfigurationStore) jaxbContext.createUnmarshaller().unmarshal(persistanceResource.getFile()); } catch (IOException e) { logger.error("Error loading config/rifidi.xml, no configuration loaded"); return ret; } catch (JAXBException e) { logger.error("Exception loading config/rifidi.xml or file not found, no configuration loaded"); return ret; } if (store.getServices() != null) { for (ServiceStore service : store.getServices()) { if (ret.get(service.getFactoryID()) == null) { ret.put(service.getFactoryID(), new CopyOnWriteArraySet<DefaultConfigurationImpl>()); } AttributeList attributes = new AttributeList(); // get all properties for (String key : service.getAttributes().keySet()) { // factoryid is already processed if (Constants.FACTORYID.equals(key)) { continue; } // type is already processed if (Constants.FACTORY_TYPE.equals(key)) { continue; } attributes.add(new Attribute(key, service.getAttributes().get(key))); } if (!checkName(service.getServiceID())) { continue; } ret.get(service.getFactoryID()).add(createAndRegisterConfiguration(service.getServiceID(), service.getFactoryID(), attributes, service.getSessionDTOs())); serviceNames.add(service.getServiceID()); } } return ret; }
From source file:org.eclipse.gyrex.monitoring.internal.mbeans.MetricSetMBean.java
@Override public AttributeList getAttributes(final String[] attributes) { final AttributeList attributeList = new AttributeList(); for (final String attributeName : attributes) { try {/*from ww w .j a v a 2 s .c o m*/ attributeList.add(new Attribute(attributeName, getAttribute(attributeName))); } catch (final AttributeNotFoundException e) { // ignore } catch (final MBeanException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (final ReflectionException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return attributeList; }
From source file:org.eclipse.smila.management.jmx.AgentMBean.java
/** * {@inheritDoc}/*from w ww . ja v a 2 s .c om*/ * * @see javax.management.DynamicMBean#setAttributes(javax.management.AttributeList) */ public AttributeList setAttributes(final AttributeList attributes) { if (attributes == null) { throw new RuntimeOperationsException(new IllegalArgumentException("attributes must not be null"), "Exception occured trying to set attributes of a " + "LocalMBean"); } final AttributeList attributeList = new AttributeList(); for (final Iterator i = attributes.iterator(); i.hasNext();) { final Attribute attribute = (Attribute) i.next(); try { setAttribute(attribute); attributeList.add(attribute); } catch (final Exception e) { i.remove(); } } return attributeList; }