001/*
002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     matic
018 */
019package org.nuxeo.ecm.platform.management.adapters;
020
021import java.util.Arrays;
022import java.util.HashSet;
023import java.util.Map;
024import java.util.Set;
025
026import org.nuxeo.runtime.model.ExtensionPoint;
027import org.nuxeo.runtime.model.Property;
028import org.nuxeo.runtime.model.RegistrationInfo;
029
030/**
031 * @author Stephane Lacoin (Nuxeo EP Software Engineer)
032 */
033public class ComponentInventoryAdapter implements ComponentInventoryMBean {
034
035    protected final RegistrationInfo info;
036
037    public ComponentInventoryAdapter(RegistrationInfo info) {
038        this.info = info;
039    }
040
041    public String getDescription() {
042        return info.getDocumentation();
043    }
044
045    public Integer getExtensionPointsCount() {
046        return info.getExtensionPoints().length;
047    }
048
049    public Set<String> getExtensionPointsName() {
050        Set<String> names = new HashSet<String>();
051        for (ExtensionPoint extensionPoint : info.getExtensionPoints()) {
052            names.add(extensionPoint.getName());
053        }
054        return names;
055    }
056
057    public String getName() {
058        return info.getName().getRawName();
059    }
060
061    public Map<String, Property> getProperties() {
062        return info.getProperties();
063    }
064
065    public Set<String> getProvidedServices() {
066        Set<String> names = new HashSet<String>();
067        names.addAll(Arrays.asList(info.getProvidedServiceNames()));
068        return names;
069    }
070
071    public Integer getProvidedServicesCount() {
072        return info.getProvidedServiceNames().length;
073    }
074
075    public String getVersion() {
076        return info.getVersion().toString();
077    }
078
079}