Package org.apache.felix.metatype

Examples of org.apache.felix.metatype.MetaData


        while ( docs.hasMoreElements() )
        {
            URL doc = ( URL ) docs.nextElement();
            try
            {
                MetaData metaData = reader.parse( doc );
                if ( metaData != null )
                {
                    cmti.addMetaData( metaData );
                }
            }
View Full Code Here


            if (m_session == null) {
                throw new ResourceProcessorException(ResourceProcessorException.CODE_OTHER_ERROR, "Can not process resource without a Deployment Session");
            }
        }
        MetaDataReader reader = new MetaDataReader();
        MetaData data = null;
        try {
            data = reader.parse(stream);
        }
        catch (IOException e) {
            throw new ResourceProcessorException(ResourceProcessorException.CODE_OTHER_ERROR, "Unable to process resource.", e);
        }
        if (data == null) {
            throw new ResourceProcessorException(ResourceProcessorException.CODE_OTHER_ERROR, "Supplied configuration is not conform the metatype xml specification.");
        }
        // process resources
        String filter = null;
        Map optionalAttributes = data.getOptionalAttributes();
        if (optionalAttributes != null) {
            filter = (String) optionalAttributes.get(AutoConfResourceProcessor.CONFIGURATION_ADMIN_FILTER_ATTRIBUTE);
        }
        // add to session data
        if (!m_toBeInstalled.containsKey(name)) {
            m_toBeInstalled.put(name, new ArrayList());
        }
        Map designates = data.getDesignates();
        if (designates == null) {
            // if there are no designates, there's nothing to process
            m_log.log(LogService.LOG_INFO, "No designates found in the resource, so there's nothing to process.");
            return;
        }
        Map localOcds = data.getObjectClassDefinitions();
        if (localOcds == null) {
            localOcds = Collections.EMPTY_MAP;
        }
        Iterator i = designates.keySet().iterator();
        while (i.hasNext()) {
View Full Code Here

                    if (name.endsWith(XML_SUFFIX)) {
                        MetaDataReader reader = new MetaDataReader();
                        InputStream in = jarFile.getInputStream(entry);
                        if (in != null) {
                            String text = IOHelpers.readFully(in);
                            MetaData metadata = reader.parse(new ByteArrayInputStream(text.getBytes()));
                            if (metadata != null) {
                                String pid = name.substring(0, name.length() - XML_SUFFIX.length());
                                xmlMap.put(pid, text);
                                metadataMap.put(pid, metadata);
                            }
                        }
                    } else if (name.endsWith(PROPERTIES_SUFFIX)) {
                        String pid = name.substring(0, name.length() - PROPERTIES_SUFFIX.length());
                        Properties properties = new Properties();
                        InputStream in = jarFile.getInputStream(entry);
                        if (in != null) {
                            properties.load(in);
                            propertiesMap.put(pid, properties);
                        }
                    }
                }
            }
            Set<Map.Entry<String, MetaData>> metadataEntries = metadataMap.entrySet();
            for (Map.Entry<String, MetaData> metadataEntry : metadataEntries) {
                String pid = metadataEntry.getKey();
                MetaData metadata = metadataEntry.getValue();
                Properties properties = propertiesMap.get(pid);
                if (properties == null) {
                    properties = new Properties();
                }
                String xml = xmlMap.get(pid);
View Full Code Here

        answer.setTypeName(typeName(ad.getType()));
        return answer;
    }

    protected void addMetaTypeInformation(MetadataHandler handler, String pid, File xmlFile, File propertiesFile) throws IOException {
        MetaData metadata;
        if (!xmlFile.exists()) {
            LOG.info("Warning! " + xmlFile + " does not exist so no OSGi MetaType metadata");
            metadata = new MetaData();
            Designate designate = new Designate();
            designate.setPid(pid);
            metadata.addDesignate(designate);
            OCD ocd = new OCD();
            ocd.setId(pid);
            metadata.addObjectClassDefinition(ocd);
        } else {
            MetaDataReader reader = new MetaDataReader();
            metadata = reader.parse(new FileInputStream(xmlFile));
        }
        // lets try get the i18n properties
View Full Code Here

            if (name.startsWith("OSGI-INF/metatype/")) {
                if (name.endsWith(XML_SUFFIX)) {
                    MetaDataReader reader = new MetaDataReader();
                    InputStream in = jarFile.getInputStream(entry);
                    if (in != null) {
                        MetaData metadata = reader.parse(in);
                        if (metadata != null) {
                            String pid = name.substring(0, name.length() - XML_SUFFIX.length());
                            metadataMap.put(pid, metadata);
                        }
                    }
                } else if (name.endsWith(PROPERTIES_SUFFIX)) {
                    String pid = name.substring(0, name.length() - PROPERTIES_SUFFIX.length());
                    Properties properties = new Properties();
                    InputStream in = jarFile.getInputStream(entry);
                    if (in != null) {
                        properties.load(in);
                        propertiesMap.put(pid, properties);
                    }
                }
            }
        }
        Set<Map.Entry<String, MetaData>> metadataEntries = metadataMap.entrySet();
        for (Map.Entry<String, MetaData> metadataEntry : metadataEntries) {
            String pid = metadataEntry.getKey();
            MetaData metadata = metadataEntry.getValue();
            Properties properties = propertiesMap.get(pid);
            if (properties == null) {
                properties = new Properties();
            }
            handler.invoke(metadata, properties);
View Full Code Here

        while ( docs.hasMoreElements() )
        {
            URL doc = ( URL ) docs.nextElement();
            try
            {
                MetaData metaData = reader.parse( doc );
                if ( metaData != null )
                {
                    cmti.addMetaData( metaData );
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.felix.metatype.MetaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.