Package org.osgi.service.metatype

Examples of org.osgi.service.metatype.ObjectClassDefinition


  }
 
  public void designate(String factoryPid, String pid, String ocdref,
                    Configuration conf, Vector currentAttributes){
   
    ObjectClassDefinition ocd;
    ocd = (ObjectClassDefinition) OCDs.get(ocdref);
   
    if(ocd != null){
      if(conf != null && currentAttributes.size() > 0){
        AttributeDefinition[] attrDefs = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL);
        Hashtable ADs = new Hashtable(); //id is key
        for(int i = 0; i < attrDefs.length; i++){
          AttributeDefinition ad = attrDefs[i];
          ADs.put(ad.getID(), ad);
        }
View Full Code Here


            {
                return ocd;
            }
        }

        ObjectClassDefinition xocd = null;
        final Locale localeObj = Util.parseLocaleString( locale );
        final ResourceBundle rb = osgiManager.resourceBundleManager.getResourceBundle( osgiManager.getBundleContext()
            .getBundle(), localeObj );
        final Map defaultConfig = osgiManager.getDefaultConfiguration();

        // simple configuration properties
        final ArrayList adList = new ArrayList();
        for ( int i = 0; i < CONF_PROPS.length; i++ )
        {
            final String key = CONF_PROPS[i++];
            final String defaultValue = ConfigurationUtil.getProperty( defaultConfig, key, CONF_PROPS[i] );
            final String name = getString( rb, "metadata." + key + ".name", key ); //$NON-NLS-1$ //$NON-NLS-2$
            final String descr = getString( rb, "metadata." + key + ".description", key ); //$NON-NLS-1$ //$NON-NLS-2$
            adList.add( new AttributeDefinitionImpl( key, name, descr, defaultValue ) );
        }

        // log level is select - so no simple default value; requires localized option labels
        adList.add( new AttributeDefinitionImpl( OsgiManager.PROP_LOG_LEVEL, getString( rb,
            "metadata.loglevel.name", OsgiManager.PROP_LOG_LEVEL ), //$NON-NLS-1$
            getString( rb, "metadata.loglevel.description", OsgiManager.PROP_LOG_LEVEL ), //$NON-NLS-1$
            AttributeDefinition.INTEGER, // type
            new String[]
                { String.valueOf( ConfigurationUtil.getProperty( defaultConfig, OsgiManager.PROP_LOG_LEVEL,
                    OsgiManager.DEFAULT_LOG_LEVEL ) ) }, // default values
            0, // cardinality
            new String[]
                { // option labels
            getString( rb, "log.level.debug", "Debug" ), //$NON-NLS-1$ //$NON-NLS-2$
                getString( rb, "log.level.info", "Information" ), //$NON-NLS-1$ //$NON-NLS-2$
                getString( rb, "log.level.warn", "Warn" ), //$NON-NLS-1$ //$NON-NLS-2$
                getString( rb, "log.level.error", "Error" ), //$NON-NLS-1$ //$NON-NLS-2$
            }, new String[]
            { "4", "3", "2", "1" } ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

        // list plugins - requires localized plugin titles
        final TreeMap namesByClassName = new TreeMap();
        final String[] defaultPluginsClasses = OsgiManager.PLUGIN_MAP;
        for ( int i = 0; i < defaultPluginsClasses.length; i++ )
        {
            final String clazz = defaultPluginsClasses[i++];
            final String label = defaultPluginsClasses[i];
            final String name = getString( rb, label + ".pluginTitle", label ); //$NON-NLS-1$
            namesByClassName.put( clazz, name );
        }
        final String[] classes = ( String[] ) namesByClassName.keySet().toArray( new String[namesByClassName.size()] );
        final String[] names = ( String[] ) namesByClassName.values().toArray( new String[namesByClassName.size()] );

        adList.add( new AttributeDefinitionImpl( OsgiManager.PROP_ENABLED_PLUGINS, getString( rb,
            "metadata.plugins.name", OsgiManager.PROP_ENABLED_PLUGINS ), //$NON-NLS-1$
            getString( rb, "metadata.plugins.description", OsgiManager.PROP_ENABLED_PLUGINS ), //$NON-NLS-1$
            AttributeDefinition.STRING, classes, Integer.MIN_VALUE, names, classes ) );

        xocd = new ObjectClassDefinition()
        {

            private final AttributeDefinition[] attrs = ( AttributeDefinition[] ) adList
                .toArray( new AttributeDefinition[adList.size()] );
View Full Code Here

                        // After getting the list of PIDs, a configuration  might be
                        // removed. So the getObjectClassDefinition will throw
                        // an exception, and this will prevent ALL configuration from
                        // being displayed. By catching it, the configurations will be
                        // visible
                        ObjectClassDefinition ocd = null;
                        try
                        {
                            ocd = mti.getObjectClassDefinition( idList[j], locale );
                        }
                        catch ( IllegalArgumentException ignore )
View Full Code Here

        Bundle[] bundles = this.getBundleContext().getBundles();
        for ( int i = 0; i < bundles.length; i++ )
        {
            try
            {
                ObjectClassDefinition ocd = this.getObjectClassDefinition( bundles[i], pid, locale );
                if ( ocd != null )
                {
                    return ocd;
                }
            }
View Full Code Here


    Map getAttributeDefinitionMap( Configuration config, String locale )
    {
        Map adMap = new HashMap();
        ObjectClassDefinition ocd = this.getObjectClassDefinition( config, locale );
        if ( ocd != null )
        {
            AttributeDefinition[] ad = ocd.getAttributeDefinitions( ObjectClassDefinition.ALL );
            if ( ad != null )
            {
                for ( int i = 0; i < ad.length; i++ )
                {
                    adMap.put( ad[i].getID(), new MetatypePropertyDescriptor( ad[i] ) );
View Full Code Here

                    "If a single value ends with a dot, all topics in exactly this package are ignored. " +
                    "If a single value ends with a star, all topics in this package and all sub packages " +
                    "are ignored. If a single value neither ends with a dot nor with a start, this is assumed " +
                    "to define an exact topic. A single star can be used to disable delivery completely.",
                    AttributeDefinition.STRING, m_ignoreTopic, Integer.MAX_VALUE, null, null));
            ocd = new ObjectClassDefinition()
            {

                private final AttributeDefinition[] attrs = adList
                    .toArray( new AttributeDefinition[adList.size()] );
View Full Code Here

        boolean doSimpleMerge = true;
        final MetaTypeServiceSupport mtss = getMetaTypeSupport();
        if ( mtss != null )
        {
            ObjectClassDefinition ocd = null;
            if ( config != null )
            {
                ocd = mtss.getObjectClassDefinition( config, locale );
            }
            if ( ocd == null )
View Full Code Here

                // insert and entry for the PID
                if ( mtss != null )
                {
                    try
                    {
                        ObjectClassDefinition ocd = mtss.getObjectClassDefinition( cfgs[i], locale );
                        if ( ocd != null )
                        {
                            optionsPlain.put( pid, ocd.getName() );
                            continue;
                        }
                    }
                    catch ( IllegalArgumentException t )
                    {
View Full Code Here

                String name = pid;
                boolean haveOcd = !ocdRequired;
                final MetaTypeServiceSupport mtss = getMetaTypeSupport();
                if ( mtss != null )
                {
                    final ObjectClassDefinition ocd = mtss.getObjectClassDefinition( refs[i].getBundle(), pid, locale );
                    if ( ocd != null )
                    {
                        name = ocd.getName();
                        haveOcd = true;
                    }
                }

                if ( haveOcd )
View Full Code Here

        for ( Iterator ei = ocdCollection.entrySet().iterator(); ei.hasNext(); )
        {
            Entry ociEntry = ( Entry ) ei.next();
            final String pid = ( String ) ociEntry.getKey();
            final ObjectClassDefinition ocd = ( ObjectClassDefinition ) ociEntry.getValue();
            if ( filter == null )
            {
                pidMap.put( pid, ocd.getName() );
            }
            else
            {
                final Dictionary props = new Hashtable();
                props.put( type, pid );
                if ( filter.match( props ) )
                {
                    pidMap.put( pid, ocd.getName() );
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.osgi.service.metatype.ObjectClassDefinition

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.