Search in sources :

Example 1 with MetaTypeObjectDTO

use of io.fabric8.api.jmx.MetaTypeObjectDTO in project fabric8 by jboss-fuse.

the class ProfileMetadata method createMetaTypeObjectDTO.

protected static MetaTypeObjectDTO createMetaTypeObjectDTO(Properties resources, OCD ocd) {
    MetaTypeObjectDTO answer = new MetaTypeObjectDTO();
    answer.setId(ocd.getID());
    answer.setName(localize(resources, ocd.getName()));
    answer.setDescription(localize(resources, ocd.getDescription()));
    List<MetaTypeAttributeDTO> attributeList = new ArrayList<>();
    Map<String, Object> attributes = ocd.getAttributeDefinitions();
    if (attributes != null) {
        Set<Map.Entry<String, Object>> entries = attributes.entrySet();
        for (Map.Entry<String, Object> entry : entries) {
            String name = entry.getKey();
            Object value = entry.getValue();
            if (value instanceof AD) {
                AD ad = (AD) value;
                MetaTypeAttributeDTO attributeDTO = createMetaTypeAttributeDTO(resources, ocd, name, ad);
                if (attributeDTO != null) {
                    attributeList.add(attributeDTO);
                }
            }
        }
    }
    answer.setAttributes(attributeList);
    return answer;
}
Also used : JarEntry(java.util.jar.JarEntry) AD(org.apache.felix.metatype.AD) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) MetaTypeObjectDTO(io.fabric8.api.jmx.MetaTypeObjectDTO) MetaTypeAttributeDTO(io.fabric8.api.jmx.MetaTypeAttributeDTO)

Example 2 with MetaTypeObjectDTO

use of io.fabric8.api.jmx.MetaTypeObjectDTO in project fabric8 by jboss-fuse.

the class ProfileMetadata method getPidMetaTypeObject.

@Override
public MetaTypeObjectDTO getPidMetaTypeObject(String versionId, String profileId, final String pid) throws Exception {
    final AtomicReference<MetaTypeObjectDTO> answer = new AtomicReference<>(null);
    MetadataHandler handler = new MetadataHandler() {

        @Override
        public void invoke(MetaData metadata, Properties resources) {
            Map<String, Object> map = metadata.getDesignates();
            Map<String, Object> objects = metadata.getObjectClassDefinitions();
            Set<Map.Entry<String, Object>> entries = map.entrySet();
            for (Map.Entry<String, Object> entry : entries) {
                String aPid = entry.getKey();
                Object value = objects.get(aPid);
                if (Objects.equal(pid, aPid) && value instanceof OCD) {
                    OCD ocd = (OCD) value;
                    answer.set(createMetaTypeObjectDTO(resources, ocd));
                }
            }
        }
    };
    findMetadataForProfile(versionId, profileId, handler);
    return answer.get();
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) Properties(java.util.Properties) OCD(org.apache.felix.metatype.OCD) JarEntry(java.util.jar.JarEntry) MetaData(org.apache.felix.metatype.MetaData) Map(java.util.Map) HashMap(java.util.HashMap) MetaTypeObjectDTO(io.fabric8.api.jmx.MetaTypeObjectDTO)

Example 3 with MetaTypeObjectDTO

use of io.fabric8.api.jmx.MetaTypeObjectDTO in project fabric8 by jboss-fuse.

the class MetaTypeFacade method getPidMetaTypeObject.

@Override
public MetaTypeObjectDTO getPidMetaTypeObject(String pid, String locale) {
    Bundle[] bundles = bundleContext.getBundles();
    MetaTypeObjectDTO answer = null;
    for (Bundle bundle : bundles) {
        MetaTypeInformation info = getMetaTypeInformation(bundle);
        if (info != null) {
            ObjectClassDefinition object = MetaTypeSummaryDTO.tryGetObjectClassDefinition(info, pid, locale);
            if (object != null) {
                if (answer == null) {
                    answer = new MetaTypeObjectDTO(object);
                } else {
                    answer.appendObjectDefinition(object);
                }
            }
        }
    }
    return answer;
}
Also used : Bundle(org.osgi.framework.Bundle) MetaTypeInformation(org.osgi.service.metatype.MetaTypeInformation) MetaTypeObjectDTO(io.fabric8.api.jmx.MetaTypeObjectDTO) ObjectClassDefinition(org.osgi.service.metatype.ObjectClassDefinition)

Aggregations

MetaTypeObjectDTO (io.fabric8.api.jmx.MetaTypeObjectDTO)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 JarEntry (java.util.jar.JarEntry)2 MetaTypeAttributeDTO (io.fabric8.api.jmx.MetaTypeAttributeDTO)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 AD (org.apache.felix.metatype.AD)1 MetaData (org.apache.felix.metatype.MetaData)1 OCD (org.apache.felix.metatype.OCD)1 Bundle (org.osgi.framework.Bundle)1 MetaTypeInformation (org.osgi.service.metatype.MetaTypeInformation)1 ObjectClassDefinition (org.osgi.service.metatype.ObjectClassDefinition)1