001/*
002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     matic
016 */
017package org.nuxeo.ecm.platform.management.adapters;
018
019import java.util.Arrays;
020import java.util.HashSet;
021import java.util.Map;
022import java.util.Set;
023
024import org.nuxeo.runtime.model.ExtensionPoint;
025import org.nuxeo.runtime.model.Property;
026import org.nuxeo.runtime.model.RegistrationInfo;
027
028/**
029 * @author Stephane Lacoin (Nuxeo EP Software Engineer)
030 */
031public class ComponentInventoryAdapter implements ComponentInventoryMBean {
032
033    protected final RegistrationInfo info;
034
035    public ComponentInventoryAdapter(RegistrationInfo info) {
036        this.info = info;
037    }
038
039    public String getDescription() {
040        return info.getDocumentation();
041    }
042
043    public Integer getExtensionPointsCount() {
044        return info.getExtensionPoints().length;
045    }
046
047    public Set<String> getExtensionPointsName() {
048        Set<String> names = new HashSet<String>();
049        for (ExtensionPoint extensionPoint : info.getExtensionPoints()) {
050            names.add(extensionPoint.getName());
051        }
052        return names;
053    }
054
055    public String getName() {
056        return info.getName().getRawName();
057    }
058
059    public Map<String, Property> getProperties() {
060        return info.getProperties();
061    }
062
063    public Set<String> getProvidedServices() {
064        Set<String> names = new HashSet<String>();
065        names.addAll(Arrays.asList(info.getProvidedServiceNames()));
066        return names;
067    }
068
069    public Integer getProvidedServicesCount() {
070        return info.getProvidedServiceNames().length;
071    }
072
073    public String getVersion() {
074        return info.getVersion().toString();
075    }
076
077}