/*
 * Copyright (C) 2010 Google Inc.
 *
 * Licensed 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 com.google.ase.facade;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;

import com.google.ase.facade.ui.UiFacade;
import com.google.ase.jsonrpc.JsonRpcServer;
import com.google.ase.jsonrpc.RpcInfo;

public class FacadeConfiguration {
  private FacadeConfiguration() {
    // Utility class.
  }

  public static JsonRpcServer buildJsonRpcServer(Service service, Intent intent, Handler handler) {
    AndroidFacade androidFacade = new AndroidFacade(service, handler, intent);
    SettingsFacade settingsFacade = new SettingsFacade(service);
    UiFacade uiFacade = new UiFacade(service);
    MediaFacade mediaFacade = new MediaFacade();
    TextToSpeechFacade ttsFacade = new TextToSpeechFacade(service);
    SpeechRecognitionFacade srFacade = new SpeechRecognitionFacade(androidFacade);
    EventFacade eventFacade = new EventFacade(service);
    SensorManagerFacade sensorManagerFacade = new SensorManagerFacade(service, eventFacade);
    LocationManagerFacade locationManagerFacade = new LocationManagerFacade(service, eventFacade);
    TelephonyManagerFacade telephonyManagerFacade =
        new TelephonyManagerFacade(service, eventFacade);
    AlarmManagerFacade alarmManagerFacade = new AlarmManagerFacade(service, eventFacade);
    return new JsonRpcServer(androidFacade, settingsFacade, mediaFacade, ttsFacade, srFacade,
        uiFacade, eventFacade, sensorManagerFacade, locationManagerFacade, telephonyManagerFacade,
        alarmManagerFacade);
  }

  public static List<RpcInfo> buildRpcInfoList() {
    List<RpcInfo> list = new ArrayList<RpcInfo>();
    list.addAll(JsonRpcServer.buildRpcInfoMap(AndroidFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(MediaFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(SpeechRecognitionFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(TextToSpeechFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(TelephonyManagerFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(AlarmManagerFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(SensorManagerFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(EventFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(LocationManagerFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(SettingsFacade.class).values());
    list.addAll(JsonRpcServer.buildRpcInfoMap(UiFacade.class).values());
    Collections.sort(list, new Comparator<RpcInfo>() {
      public int compare(RpcInfo info1, RpcInfo info2) {
        return info1.getName().compareTo(info2.getName());
      }
    });
    return list;
  }
}

@@ -950,103 +950,586 @@
 o;%0A%0A
-public class FacadeConfiguration %7B%0A  private FacadeConfiguration() %7B%0A    // Utility class.%0A  %7D%0A
+/**%0A * Encapsulates the list of supported facades and their construction.%0A *%0A * @author Damon Kohler %3Cdamonkohler@gmail.com%3E%0A */%0Apublic class FacadeConfiguration %7B%0A  private FacadeConfiguration() %7B%0A    // Utility class.%0A  %7D%0A%0A  /**%0A   * Returns a %7B@link JsonRpcServer%7D with all facades configured.%0A   *%0A   * @param service%0A   *          service to configure facades with%0A   * @param intent%0A   *          intent to configure facades with%0A   * @param handler%0A   *          handler to configure facades with%0A   * @return a new %7B@link JsonRpcServer%7D configured with all facades%0A   */
 %0A  p
@@ -2691,16 +2691,92 @@
 );%0A  %7D%0A%0A
+  /**%0A   * Returns a list of %7B@link RpcInfo%7D objects for all facades.%0A   */%0A
   public

Add some missing Javadoc to FacadeConfiguration.