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 @Override 042 public String getDescription() { 043 return info.getDocumentation(); 044 } 045 046 @Override 047 public Integer getExtensionPointsCount() { 048 return info.getExtensionPoints().length; 049 } 050 051 @Override 052 public Set<String> getExtensionPointsName() { 053 Set<String> names = new HashSet<>(); 054 for (ExtensionPoint extensionPoint : info.getExtensionPoints()) { 055 names.add(extensionPoint.getName()); 056 } 057 return names; 058 } 059 060 @Override 061 public String getName() { 062 return info.getName().getRawName(); 063 } 064 065 @Override 066 public Map<String, Property> getProperties() { 067 return info.getProperties(); 068 } 069 070 @Override 071 public Set<String> getProvidedServices() { 072 Set<String> names = new HashSet<>(); 073 names.addAll(Arrays.asList(info.getProvidedServiceNames())); 074 return names; 075 } 076 077 @Override 078 public Integer getProvidedServicesCount() { 079 return info.getProvidedServiceNames().length; 080 } 081 082 @Override 083 public String getVersion() { 084 return info.getVersion().toString(); 085 } 086 087}