Example usage for javax.management AttributeList add

List of usage examples for javax.management AttributeList add

Introduction

In this page you can find the example usage for javax.management AttributeList add.

Prototype

@Override
public boolean add(Object element) 

Source Link

Usage

From source file:org.rifidi.edge.configuration.RifidiService.java

/**
 * Get a list of attributes./*from ww  w  . ja  va  2s .  c om*/
 * 
 * @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.rifidi.edge.core.configuration.services.ConfigurationServiceImpl.java

/**
 * Load the configuration. Not thread safe.
 * /*from   w  ww .j a va 2  s  .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.rest.SensorManagerServiceRestletImpl.java

/**
 * Processes a chain of semicolon separated properties and checks whether it
 * is a well formed pair/*w w w  .  j ava  2s  . c om*/
 * 
 * @param propertiesChain
 *            separated values of properties, for example:
 *            (prop1=val2;prop2=val2;prop3=val3)
 * @return AttributeList containing the attributes
 * @throws Exception
 *             if any property has no recognizable value
 */
private AttributeList getProcessedAttributes(String propertiesChain) throws Exception {

    AttributeList attributes = new AttributeList();

    // Check if propertiesChain has properties to process...
    if (propertiesChain != null && !propertiesChain.isEmpty()) {

        String[] splitProp = propertiesChain.split(";");

        for (String pair : splitProp) {

            String[] prop = pair.split("=");

            // check if property has a property and a value
            if (prop.length == 2) {

                // It has property and value
                attributes.add(new Attribute(prop[0], prop[1]));

            } else {

                // Property with no recognizable value, for example
                // Port=123=456, or Port,
                throw new Exception("Property with no recognizable value: " + prop[0]);

            }
        }

    }

    return attributes;
}