Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    *
    *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.felix.webconsole.internal.compendium;
  
  
  import java.util.Arrays;
  import java.util.Locale;
  import java.util.Map;
  import java.util.TreeMap;
  import java.util.TreeSet;
  import java.util.Vector;
  
  
  import  org.osgi.framework.Bundle;
  import  org.osgi.framework.Constants;
  import  org.osgi.framework.Filter;
  import  org.osgi.framework.InvalidSyntaxException;
  import  org.osgi.framework.ServiceReference;
  import  org.osgi.framework.Version;
  import  org.osgi.service.cm.Configuration;
  import  org.osgi.service.cm.ConfigurationAdmin;
  import  org.osgi.service.cm.ManagedService;
  import  org.osgi.service.cm.ManagedServiceFactory;
  import  org.osgi.service.log.LogService;
  import  org.osgi.service.metatype.AttributeDefinition;
  import  org.osgi.service.metatype.ObjectClassDefinition;


The ConfigManager TODO
  
  public class ConfigManager extends ConfigManagerBase
  {
  
      private static final String PID_FILTER = "pidFilter";
  
      public static final String NAME = "configMgr";
  
      public static final String LABEL = "Configuration";
  
      public static final String PID = "pid";
  
      public static final String factoryPID = "factoryPid";
  
      private static final String PLACEHOLDER_PID = "[Temporary PID replaced by real PID upon save]";
  
  
      public String getTitle()
      {
          return ;
      }
  
  
      public String getLabel()
      {
          return ;
      }
  
  
      protected void doPostHttpServletRequest requestHttpServletResponse response ) throws IOException
      {
          // needed multiple times below
          String pid = request.getParameter. );
         if ( pid == null )
         {
             String info = request.getPathInfo();
             pid = info.substringinfo.lastIndexOf'/' ) + 1 );
         }
 
         // the filter to select part of the configurations
         String pidFilter = request.getParameter );
 
         final ConfigurationAdmin ca = this.getConfigurationAdmin();
 
         // ignore this request if the pid and/or configuration admin is missing
         if ( pid == null || ca == null )
         {
             // should log this here !!
             return;
         }
 
         // the configuration to operate on (to be created or "missing")
         Configuration config = null;
 
         // should actually apply the configuration before redirecting
         if ( request.getParameter"create" ) != null )
         {
             config = new PlaceholderConfigurationpid ); // ca.createFactoryConfiguration( pid, null );
             pid = config.getPid();
         }
         else if ( request.getParameter"apply" ) != null )
         {
             String redirect = applyConfigurationrequestcapid );
             if ( redirect != null )
             {
                 if (pidFilter != null) {
                     redirect += "?" +  + "=" + pidFilter;
                 }
 
                 this.sendRedirect(requestresponseredirect);
             }
 
             return;
         }
 
         if ( config == null )
         {
             config = getConfigurationcapid );
         }
 
         // check for configuration unbinding
         if ( request.getParameter"unbind" ) != null )
         {
             config.setBundleLocation( null );
             sendRedirectrequestresponseconfig.getPid() );
             return;
         }
 
         // send the result
         response.setContentType"application/json" );
         response.setCharacterEncoding"UTF-8" );
         final Locale loc = getLocalerequest );
         final String locale = ( loc != null ) ? loc.toString() : null;
         printConfigurationJsonresponse.getWriter(), pidconfigpidFilterlocale );
     }


    

See also:
org.apache.felix.webconsole.AbstractWebConsolePlugin.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 
     protected void doGetHttpServletRequest requestHttpServletResponse response )
     throws ServletExceptionIOException
     {
         // let's check for a json request
         final String info = request.getPathInfo();
         if ( info.endsWith".json" ) )
         {
             response.setContentType"application/json" );
             response.setCharacterEncoding"UTF-8" );
 
             // after last slash and without extension
             String pid = info.substringinfo.lastIndexOf'/' ) + 1, info.length() - 5 );
             // check whether the pid is actually a filter for the selection
             // of configurations to display, if the filter correctly converts
             // into an OSGi filter, we use it to select configurations
             // to display
             String pidFilter = request.getParameter );
             if ( pidFilter == null )
             {
                 pidFilter = pid;
             }
             try
             {
                 getBundleContext().createFilter( pidFilter );
 
                 // if the pidFilter was set from the pid, clear the pid
                 if ( pid == pidFilter )
                 {
                     pid = null;
                 }
             }
             catch ( InvalidSyntaxException ise )
             {
                 // its ok, if the pid is just a single PID
                 pidFilter = null;
             }
 
             final ConfigurationAdmin ca = this.getConfigurationAdmin();
 
             final Locale loc = getLocalerequest );
             final String locale = ( loc != null ) ? loc.toString() : null;
 
             final PrintWriter pw = response.getWriter();
 
             try {
                 pw.write("[");
                 final SortedMap services = this.getServices(pidpidFilterlocalefalse);
                 final Iterator i = services.keySet().iterator();
                 boolean printColon = false;
                 while ( i.hasNext() ) {
                     final String servicePid = i.next().toString();
 
                     final Configuration config = this.getConfiguration(caservicePid);
                     if ( config != null ) {
                         if ( printColon ) {
                             pw.print(',');
                         }
                         this.printConfigurationJson(pwservicePidconfigpidFilterlocale);
                         printColon = true;
                     }
                 }
                 pw.write("]");
             } catch (InvalidSyntaxException e) {
                 // this should not happend as we checked the filter before
             }
             // nothing more to do
             return;
         }
 
         super.doGetrequestresponse );
     }

    

See also:
org.apache.felix.webconsole.AbstractWebConsolePlugin.renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 
     public void renderContentHttpServletRequest requestHttpServletResponse response ) throws IOException
     {
 
         // extract the configuration pid from the request path
         String pid = request.getPathInfo().substring(this.getLabel().length() + 1);
         if ( pid.length() == 0 ) {
             pid = null;
         } else {
             pid = pid.substringpid.lastIndexOf'/' ) + 1 );
         }
         // check whether the pid is actually a filter for the selection
         // of configurations to display, if the filter correctly converts
         // into an OSGi filter, we use it to select configurations
         // to display
         String pidFilter = request.getParameter );
         if ( pidFilter == null )
         {
             pidFilter = pid;
         }
         if ( pidFilter != null )
         {
             try
             {
                 getBundleContext().createFilter( pidFilter );
 
                 // if the pidFilter was set from the pid, clear the pid
                 if ( pid == pidFilter )
                 {
                     pid = null;
                 }
             }
             catch ( InvalidSyntaxException ise )
             {
                 // its ok, if the pid is just a single PID
                 pidFilter = null;
             }
         }
 
         final ConfigurationAdmin ca = this.getConfigurationAdmin();
 
         final Locale loc = getLocalerequest );
         final String locale = ( loc != null ) ? loc.toString() : null;
 
         final PrintWriter pw = response.getWriter();
 
         final String appRoot = (Stringrequest.getAttribute. );
         pw.println"<script src='" + appRoot + "/res/ui/configmanager.js' language='JavaScript'></script>" );
 
         pw.println"<table class='content' cellpadding='0' cellspacing='0' width='100%'>" );
 
         if ( ca == null )
         {
             pw.println"<tr class='content' id='configField'>" );
             pw.println"<td class='content'>&nbsp;</th>" );
             pw.println"<td class='content'>" );
             pw.print"Configuration Admin Service not available" );
             pw.println"</td>" );
             pw.println"</tr>" );
         }
         else
         {
             pw.println"<tr class='content' id='configField'>" );
             pw.println"<td class='content'>Configurations</th>" );
             pw.println"<td class='content'>" );
             this.listConfigurationspwcapidFilterlocale );
             pw.println"</td>" );
             pw.println"</tr>" );
 
             pw.println"<tr class='content' id='factoryField'>" );
             pw.println"<td class='content'>Factory Configurations</th>" );
             pw.println"<td class='content'>" );
             this.listFactoryConfigurationspwcapidFilterlocale );
             pw.println"</td>" );
             pw.println"</tr>" );
         }
 
         pw.println"</table>" );
 
         // if a configuration is addressed, display it immediately
         final Configuration config;
         if ( request.getParameter"create" ) != null && pid != null )
         {
             config = new PlaceholderConfigurationpid );
             pid = config.getPid();
         }
         else
         {
             config = getConfigurationcapid );
         }
 
         if ( pid != null )
         {
             Util.startScriptpw );
 
             pw.println"var configuration=" );
             printConfigurationJsonpwpidconfigpidFilterlocale );
             pw.println";" );
 
             pw.println"displayConfigForm(configuration);" );
 
             Util.endScriptpw );
         }
     }
 
 
     private Configuration getConfiguration( ConfigurationAdmin caString pid )
     {
         if ( ca != null && pid != null )
         {
             try
             {
                 // we use listConfigurations to not create configuration
                 // objects persistently without the user providing actual
                 // configuration
                 String filter = "(" + Constants.SERVICE_PID + "=" + pid + ")";
                 Configuration[] configs = ca.listConfigurations( filter );
                 if ( configs != null && configs.length > 0 )
                 {
                     return configs[0];
                 }
             }
             catch ( InvalidSyntaxException ise )
             {
                 // should print message
             }
             catch ( IOException ioe )
             {
                 // should print message
             }
         }
 
         // fallback to no configuration at all
         return null;
     }
 
 
     private void listConfigurationsPrintWriter pw, ConfigurationAdmin caString pidFilterString locale )
     {
         try
         {
             // start with ManagedService instances
             SortedMap optionsPlain = getServices( ManagedService.class.getName(), pidFilterlocaletrue );
 
             // next are the MetaType informations without ManagedService
             addMetaTypeNamesoptionsPlaingetPidObjectClasseslocale ), pidFilter, Constants.SERVICE_PID );
 
             // add in existing configuration (not duplicating ManagedServices)
             Configuration[] cfgs = ca.listConfigurations( pidFilter );
             for ( int i = 0; cfgs != null && i < cfgs.length; i++ )
             {
 
                 // ignore configuration object if an entry already exists in the
                 // map
                 String pid = cfgs[i].getPid();
                 if ( optionsPlain.containsKeypid ) )
                 {
                     continue;
                 }
 
                 // insert and entry for the pid
                 ObjectClassDefinition ocd = this.getObjectClassDefinitioncfgs[i], locale );
                 String name;
                 if ( ocd != null )
                 {
                     name = ocd.getName() + " (";
                     name += pid + ")";
                 }
                 else
                 {
                     name = pid;
                 }
 
                 optionsPlain.putpidname );
             }
 
             printOptionsFormpwoptionsPlain"configSelection_pid""configure""Configure" );
         }
         catch ( Exception e )
         {
             getLog().log( LogService.LOG_ERROR, "listConfigurations: Unexpected problem encountered"e );
         }
     }
 
 
     private void listFactoryConfigurationsPrintWriter pw, ConfigurationAdmin caString pidFilter,
         String locale )
     {
         try
         {
             SortedMap optionsFactory = getServices( ManagedServiceFactory.class.getName(), pidFilterlocaletrue );
             addMetaTypeNamesoptionsFactorygetFactoryPidObjectClasseslocale ), pidFilter,
                 ConfigurationAdmin.SERVICE_FACTORYPID );
             printOptionsFormpwoptionsFactory"configSelection_factory""create""Create" );
         }
         catch ( Exception e )
         {
             getLog().log( LogService.LOG_ERROR, "listFactoryConfigurations: Unexpected problem encountered"e );
         }
     }
 
 
     private SortedMap getServicesString serviceClassString serviceFilterString localeboolean ocdRequired )
         throws InvalidSyntaxException
     {
         // sorted map of options
         SortedMap optionsFactory = new TreeMap. );
 
         // find all ManagedServiceFactories to get the factoryPIDs
         ServiceReference[] refs = this.getBundleContext().getServiceReferences( serviceClassserviceFilter );
         for ( int i = 0; refs != null && i < refs.length; i++ )
         {
             Object pidObject = refs[i].getProperty( Constants.SERVICE_PID );
             if ( pidObject instanceof String )
             {
                 String pid = ( String ) pidObject;
                 String name;
                 final ObjectClassDefinition ocd = this.getObjectClassDefinitionrefs[i].getBundle(), pidlocale );
                 if ( ocd != null )
                 {
                     name = ocd.getName() + " (";
                     name += pid + ")";
                 }
                 else
                 {
                     name = pid;
                 }
 
                 if ( !ocdRequired || ocd != null ) {
                     optionsFactory.putpidname );
                 }
             }
         }
 
         return optionsFactory;
     }
 
 
     private void addMetaTypeNamesfinal Map pidMapfinal Collection ocdCollectionfinal String filterSpecfinal String type )
     {
         Filter filter = null;
         if ( filterSpec != null )
         {
             try
             {
                 filter = getBundleContext().createFilter( filterSpec );
             }
             catch ( InvalidSyntaxException not_expected )
             {
             }
         }
 
         for ( Iterator oci = ocdCollection.iterator(); oci.hasNext(); )
         {
             final ObjectClassDefinition ocd = ( ObjectClassDefinition ) oci.next();
             final String pid = ocd.getID();
             final Dictionary props = new Hashtable();
             props.puttypepid );
             if ( filter == null || filter.match( props ) )
             {
                 final String name = ocd.getName() + " (" + pid + ")";
                 pidMap.putpidname );
             }
         }
 
     }
 
 
     private void printOptionsFormPrintWriter pwSortedMap optionsString formIdString submitMethod,
         String submitLabel )
     {
         SortedSet set = new TreeSet();
         for ( Iterator ei = options.entrySet().iterator(); ei.hasNext(); )
         {
             Entry entry = ( Entry ) ei.next();
             set.add(entry.getValue().toString() + . + entry.getKey().toString());
         }
 
         pw.println"<select class='select' name='pid' id='" + formId + "' onChange='" + submitMethod + "();'>" );
         for ( Iterator ei = set.iterator(); ei.hasNext(); )
         {
             String entry = ( String ) ei.next();
             int sep = entry.indexOf. );
             String value = entry.substring( 0, sep );
             String key = entry.substringsep + 1 );
             pw.print"<option value='" + key + "'>" );
             pw.printvalue );
             pw.println"</option>" );
         }
         pw.println"</select>" );
         pw.println"&nbsp;&nbsp;" );
         pw.println"<input class='submit' type='button' value='" + submitLabel + "' onClick='" + submitMethod
             + "();' />" );
 
     }
 
 
     private void printConfigurationJsonPrintWriter pwString pid, Configuration configString pidFilter,
         String locale )
     {
 
         JSONWriter result = new JSONWriterpw );
 
         if ( pid != null )
         {
             try
             {
                 result.object();
                 this.configFormresultpidconfigpidFilterlocale );
                 result.endObject();
             }
             catch ( Exception e )
             {
                 // add message
             }
         }
 
     }
 
 
     private void configFormJSONWriter jsonString pid, Configuration configString pidFilterString locale )
         throws JSONException
     {
 
         json.key. );
         json.valuepid );
 
         if ( pidFilter != null )
         {
             json.key );
             json.valuepidFilter );
         }
 
         Dictionary props = null;
         ObjectClassDefinition ocd;
         if ( config != null )
         {
             props = config.getProperties();
             ocd = this.getObjectClassDefinitionconfiglocale );
         }
         else
         {
             ocd = this.getObjectClassDefinitionpidlocale );
         }
 
         props = this.mergeWithMetaTypepropsocdjson );
 
         if ( props != null )
         {
 
             json.key"title" );
             json.valuepid );
             json.key"description" );
             json.value"Please enter configuration properties for this configuration in the field below. This configuration has no associated description" );
 
             json.key"propertylist" );
             json.value"properties" );
 
             json.key"properties" );
             json.object();
             for ( Enumeration pe = props.keys(); pe.hasMoreElements(); )
             {
                 Object key = pe.nextElement();
 
                 // ignore well known special properties
                 if ( !key.equals( Constants.SERVICE_PID ) && !key.equals( Constants.SERVICE_DESCRIPTION )
                     && !key.equals( Constants.SERVICE_ID ) && !key.equals( Constants.SERVICE_RANKING )
                     && !key.equals( Constants.SERVICE_VENDOR )
                     && !key.equals( ConfigurationAdmin.SERVICE_BUNDLELOCATION )
                     && !key.equals( ConfigurationAdmin.SERVICE_FACTORYPID ) )
                 {
                     json.key( String.valueOfkey ) );
                     json.valueprops.getkey ) );
                 }
             }
             json.endObject();
 
         }
 
         if ( config != null )
         {
             this.addConfigurationInfoconfigjsonlocale );
         }
     }
 
 
     private Dictionary mergeWithMetaTypeDictionary props, ObjectClassDefinition ocdJSONWriter json )
         throws JSONException
     {
 
         if ( props == null )
         {
             props = new Hashtable();
         }
 
         if ( ocd != null )
         {
 
             json.key"title" );
             json.valueocd.getName() );
 
             if ( ocd.getDescription() != null )
             {
                 json.key"description" );
                 json.valueocd.getDescription() );
             }
 
             AttributeDefinition[] ad = ocd.getAttributeDefinitions( ObjectClassDefinition.ALL );
             if ( ad != null )
             {
 
                 JSONArray propertyList = new JSONArray();
 
                 for ( int i = 0; i < ad.length; i++ )
                 {
                     json.keyad[i].getID() );
                     json.object();
 
                     Object value = props.getad[i].getID() );
                     if ( value == null )
                     {
                         value = ad[i].getDefaultValue();
                         if ( value == null )
                         {
                             if ( ad[i].getCardinality() == 0 )
                             {
                                 value = "";
                             }
                             else
                             {
                                 value = new String[0];
                             }
                         }
                     }
 
                     json.key"name" );
                     json.valuead[i].getName() );
 
                     json.key"type" );
                     if ( ad[i].getOptionLabels() != null && ad[i].getOptionLabels().length > 0 )
                     {
                         json.object();
                         json.key"labels" );
                         json.value( Arrays.asListad[i].getOptionLabels() ) );
                         json.key"values" );
                         json.value( Arrays.asListad[i].getOptionValues() ) );
                         json.endObject();
                     }
                     else
                     {
                         json.valuead[i].getType() );
                     }
 
                     if ( ad[i].getCardinality() == 0 )
                     {
                         // scalar
                         if ( value instanceof Vector )
                         {
                             value = ( ( Vector ) value ).get( 0 );
                         }
                         else if ( value.getClass().isArray() )
                         {
                             value = Array.getvalue, 0 );
                         }
                         json.key"value" );
                         json.valuevalue );
                     }
                     else
                     {
                         if ( value instanceof Vector )
                         {
                             value = new JSONArray( ( Vector ) value );
                         }
                         else if ( value.getClass().isArray() )
                         {
                             value = new JSONArray( Arrays.asList( ( Object[] ) value ) );
                         }
                         else
                         {
                             JSONArray tmp = new JSONArray();
                             tmp.putvalue );
                             value = tmp;
                         }
                         json.key"values" );
                         json.valuevalue );
                     }
 
                     if ( ad[i].getDescription() != null )
                     {
                         json.key"description" );
                         json.valuead[i].getDescription() + " (" + ad[i].getID() + ")" );
                     }
 
                     json.endObject();
                     propertyList.putad[i].getID() );
                 }
 
                 json.key"propertylist" );
                 json.valuepropertyList );
             }
 
             // nothing more to display
             props = null;
         }
 
         return props;
     }
 
 
     private void addConfigurationInfo( Configuration configJSONWriter jsonString locale ) throws JSONException
     {
 
         if ( config.getFactoryPid() != null )
         {
             json.key );
             json.valueconfig.getFactoryPid() );
         }
 
         String location;
         if ( config.getBundleLocation() == null )
         {
             location = "";
         }
         else
         {
             // if the configuration is bound to a bundle location which
             // is not related to an installed bundle, we just print the
             // raw bundle location binding
             Bundle bundle = this.getBundleconfig.getBundleLocation() );
             if ( bundle == null )
             {
                 location = config.getBundleLocation();
             }
             else
             {
                 Dictionary headers = bundle.getHeaders( locale );
                 String name = ( String ) headers.get( Constants.BUNDLE_NAME );
                 if ( name == null )
                 {
                     location = bundle.getSymbolicName();
                 }
                 else
                 {
                     location = name + " (" + bundle.getSymbolicName() + ")";
                 }
 
                 Version v = Version.parseVersion( ( String ) headers.get( Constants.BUNDLE_VERSION ) );
                 location += ", Version " + v.toString();
             }
         }
         json.key"bundleLocation" );
         json.valuelocation );
     }
 
 
     private String applyConfigurationHttpServletRequest request, ConfigurationAdmin caString pid )
         throws IOException
     {
         if ( request.getParameter"delete" ) != null )
         {
             // only delete if the PID is not our place holder
             if ( !.equalspid ) )
             {
                 getLog().log( LogService.LOG_INFO, "applyConfiguration: Deleting configuration " + pid );
                 Configuration config = ca.getConfiguration( pidnull );
                 config.delete();
             }
             return request.getHeader"Referer" );
         }
 
         String factoryPid = request.getParameter. );
         Configuration config = null;
 
         String propertyList = request.getParameter"propertylist" );
         if ( propertyList == null )
         {
             String propertiesString = request.getParameter"properties" );
 
             if ( propertiesString != null )
             {
                 byte[] propBytes = propertiesString.getBytes"ISO-8859-1" );
                 ByteArrayInputStream bin = new ByteArrayInputStreampropBytes );
                 Properties props = new Properties();
                 props.loadbin );
 
                 config = getConfigurationcapidfactoryPid );
                 config.update( props );
             }
         }
         else
         {
             config = getConfigurationcapidfactoryPid );
 
             Dictionary props = config.getProperties();
             if ( props == null )
             {
                 props = new Hashtable();
             }
 
             Map adMap = this.getAttributeDefinitionMapconfignull );
             if ( adMap != null )
             {
                 StringTokenizer propTokens = new StringTokenizerpropertyList"," );
                 while ( propTokens.hasMoreTokens() )
                 {
                     String propName = propTokens.nextToken();
                     AttributeDefinition ad = ( AttributeDefinition ) adMap.getpropName );
                     if ( ad == null || ( ad.getCardinality() == 0 && ad.getType() == AttributeDefinition.STRING ) )
                     {
                         String prop = request.getParameterpropName );
                         if ( prop != null )
                         {
                             props.putpropNameprop );
                         }
                     }
                     else if ( ad.getCardinality() == 0 )
                     {
                         // scalar of non-string
                         String prop = request.getParameterpropName );
                         if ( prop != null )
                         {
                             try
                             {
                                 props.putpropNamethis.toTypead.getType(), prop ) );
                             }
                             catch ( NumberFormatException nfe )
                             {
                                 // don't care
                             }
                         }
                     }
                     else
                     {
                         // array or vector of any type
                         Vector vec = new Vector();
 
                         String[] properties = request.getParameterValuespropName );
                         if ( properties != null )
                         {
                             for ( int i = 0; i < properties.lengthi++ )
                             {
                                 try
                                 {
                                     vec.addthis.toTypead.getType(), properties[i] ) );
                                 }
                                 catch ( NumberFormatException nfe )
                                 {
                                     // don't care
                                 }
                             }
                         }
 
                         // but ensure size (check for positive value since
                         // abs(Integer.MIN_VALUE) is still INTEGER.MIN_VALUE)
                         int maxSize = Math.absad.getCardinality() );
                         if ( vec.size() > maxSize && maxSize > 0 )
                         {
                             vec.setSizemaxSize );
                         }
 
                         if ( ad.getCardinality() < 0 )
                         {
                             // keep the vector
                             props.putpropNamevec );
                         }
                         else
                         {
                             // convert to an array
                             props.putpropNamethis.toArrayad.getType(), vec ) );
                         }
                     }
                 }
             }
 
             config.update( props );
         }
 
         // redirect to the new configuration (if existing)
         return (config != null) ? config.getPid() : "";
     }
 
 
     private Configuration getConfiguration( ConfigurationAdmin caString pidString factoryPid ) throws IOException
     {
         if ( factoryPid != null && ( pid == null || pid.equals ) ) )
         {
             return ca.createFactoryConfiguration( factoryPidnull );
         }
 
         return ca.getConfiguration( pidnull );
     }


    

Throws:
NumberFormatException If the value cannot be converted to a number and type indicates a numeric type
 
     private Object toTypeint typeString value )
     {
         switch ( type )
         {
             case AttributeDefinition.BOOLEAN:
                 return Boolean.valueOfvalue );
             case AttributeDefinition.BYTE:
                 return Byte.valueOfvalue );
             case AttributeDefinition.CHARACTER:
                 char c = ( value.length() > 0 ) ? value.charAt( 0 ) : 0;
                 return new Characterc );
             case AttributeDefinition.DOUBLE:
                 return Double.valueOfvalue );
             case AttributeDefinition.FLOAT:
                 return Float.valueOfvalue );
             case AttributeDefinition.LONG:
                 return Long.valueOfvalue );
             case AttributeDefinition.INTEGER:
                 return Integer.valueOfvalue );
             case AttributeDefinition.SHORT:
                 return Short.valueOfvalue );
 
             default:
                 // includes AttributeDefinition.STRING
                 return value;
         }
     }
 
 
     private Object toArrayint typeVector values )
     {
         int size = values.size();
 
         // short cut for string array
         if ( type == AttributeDefinition.STRING )
         {
             return values.toArraynew String[size] );
         }
 
         Object array;
         switch ( type )
         {
             case AttributeDefinition.BOOLEAN:
                 array = new boolean[size];
             case AttributeDefinition.BYTE:
                 array = new byte[size];
             case AttributeDefinition.CHARACTER:
                 array = new char[size];
             case AttributeDefinition.DOUBLE:
                 array = new double[size];
             case AttributeDefinition.FLOAT:
                 array = new float[size];
             case AttributeDefinition.LONG:
                 array = new long[size];
             case AttributeDefinition.INTEGER:
                 array = new int[size];
             case AttributeDefinition.SHORT:
                 array = new short[size];
             default:
                 // unexpected, but assume string
                 array = new String[size];
         }
        for ( int i = 0; i < sizei++ )
        {
            Array.setarrayivalues.geti ) );
        }
        return array;
    }
    private static class PlaceholderConfiguration implements Configuration
    {
        private final String factoryPid;
        private String bundleLocation;
        PlaceholderConfigurationString factoryPid )
        {
            this. = factoryPid;
        }
        public String getPid()
        {
            return ;
        }
        public String getFactoryPid()
        {
            return ;
        }
        public void setBundleLocationString bundleLocation )
        {
            this. = bundleLocation;
        }
        public String getBundleLocation()
        {
            return ;
        }
        public Dictionary getProperties()
        {
            // dummy configuration has no properties
            return null;
        }
        public void update()
        {
            // dummy configuration cannot be updated
        }
        public void updateDictionary properties )
        {
            // dummy configuration cannot be updated
        }
        public void delete()
        {
            // dummy configuration cannot be deleted
        }
    }