Package org.apache.felix.scrplugin.helper

Examples of org.apache.felix.scrplugin.helper.MetatypeContainer


                String metatypeLocation = MetaTypeService.METATYPE_DOCUMENTS_LOCATION + "/metatype";

                // check if all labels and descriptions are inlined
                boolean allInlined = true;
                for(final ComponentContainer cc : ccc.components) {
                    final MetatypeContainer mc = cc.getMetatypeContainer();

                    if ( mc.getName() == null ) {
                        if ( oldStyle ) {
                            mc.setName( "%" + cc.getComponentDescription().getName() + ".name");
                        } else {
                            mc.setName("Component " + cc.getComponentDescription().getName());
                        }
                    }
                    if ( mc.getName() != null && mc.getName().startsWith("%") ) {
                        allInlined = false;
                    }
                    if ( mc.getDescription() == null ) {
                        if ( oldStyle ) {
                            mc.setDescription("%" + cc.getComponentDescription().getName() + ".description");
                        } else {
                            mc.setDescription("Description for " + cc.getComponentDescription().getName());
                        }
                    }
                    if ( mc.getDescription() != null && mc.getDescription().startsWith("%") ) {
                        allInlined = false;
                    }
                    for(final MetatypeAttributeDefinition mad : mc.getProperties()) {
                        if ( mad.getName() == null ) {
                            if ( oldStyle ) {
                                mad.setName("%" + mad.getId() + ".name");
                            } else {
                                mad.setName("Property " + mad.getId());
                            }
                        }
                        if ( mad.getName() != null && mad.getName().startsWith("%") ) {
                            allInlined = false;
                        }
                        if ( mad.getDescription() == null ) {
                            if ( oldStyle ) {
                                mad.setDescription("%" + mad.getId() + ".description");
                            } else {
                                mad.setDescription("Description for " + mad.getId());
                            }
                        }
                        if ( mad.getDescription() != null && mad.getDescription().startsWith("%") ) {
                            allInlined = false;
                        }
                    }
                }
                if ( allInlined ) {
                    final Properties metatypeProps = new Properties();

                    // externalize all labels and descriptions
                    for(final ComponentContainer cc : ccc.components) {
                        final MetatypeContainer mc = cc.getMetatypeContainer();

                        final String baseKey = cc.getComponentDescription().getName().replace("$", ".");

                        if ( mc.getName() != null ) {
                            final String key = baseKey + ".name";
                            metatypeProps.put(key, mc.getName());
                            mc.setName("%" + key);
                        }
                        if ( mc.getDescription() != null ) {
                            final String key = baseKey + ".description";
                            metatypeProps.put(key, mc.getDescription());
                            mc.setDescription("%" + key);
                        }
                        for(final MetatypeAttributeDefinition mad : mc.getProperties()) {
                            if ( mad.getName() != null ) {
                                final String key = baseKey + "." + mad.getId() + ".name";
                                metatypeProps.put(key, mad.getName());
                                mad.setName("%" + key);
                            }
View Full Code Here


        }

        final ComponentContainer container = new ComponentContainer(desc, componentDesc);

        // Create metatype (if required)
        final MetatypeContainer ocd;
        if ( !componentDesc.isAbstract() && componentDesc.isCreateMetatype() ) {
            // OCD
            ocd = new MetatypeContainer();
            container.setMetatypeContainer( ocd );
            ocd.setId( componentDesc.getName() );
            if ( componentDesc.getLabel() != null ) {
                ocd.setName( componentDesc.getLabel() );
            }
            if ( componentDesc.getDescription() != null ) {
                ocd.setDescription( componentDesc.getDescription() );
            }

            // Factory pid
            if ( componentDesc.isSetMetatypeFactoryPid() ) {
                if ( componentDesc.getFactory() == null ) {
                    ocd.setFactoryPid( componentDesc.getName() );
                } else {
                    iLog.addWarning( "Component factory " + componentDesc.getName()
                        + " should not set metatype factory pid.", desc.getSource() );
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.felix.scrplugin.helper.MetatypeContainer

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.