/** {@inheritDoc} */
  public SynapseConfiguration createSynapseConfiguration() {

    String synapseXMLLocation = serverConfigurationInformation.getSynapseXMLLocation();
    Properties properties = SynapsePropertiesLoader.loadSynapseProperties();
    if (serverConfigurationInformation.getResolveRoot() != null) {
      properties.put(
          SynapseConstants.RESOLVE_ROOT, serverConfigurationInformation.getResolveRoot());
    }

    if (serverConfigurationInformation.getSynapseHome() != null) {
      properties.put(
          SynapseConstants.SYNAPSE_HOME, serverConfigurationInformation.getSynapseHome());
    }

    if (synapseXMLLocation != null) {
      synapseConfiguration =
          SynapseConfigurationBuilder.getConfiguration(synapseXMLLocation, properties);
    } else {
      log.warn(
          "System property or init-parameter '"
              + SynapseConstants.SYNAPSE_XML
              + "' is not specified. Using default configuration..");
      synapseConfiguration = SynapseConfigurationBuilder.getDefaultConfiguration();
    }

    Enumeration keys = properties.keys();
    while (keys.hasMoreElements()) {
      String key = (String) keys.nextElement();
      synapseConfiguration.setProperty(key, properties.getProperty(key));
    }

    // Set the Axis2 ConfigurationContext to the SynapseConfiguration
    synapseConfiguration.setAxisConfiguration(configurationContext.getAxisConfiguration());
    MessageContextCreatorForAxis2.setSynConfig(synapseConfiguration);

    // set the Synapse configuration into the Axis2 configuration
    Parameter synapseConfigurationParameter =
        new Parameter(SynapseConstants.SYNAPSE_CONFIG, synapseConfiguration);
    try {
      configurationContext.getAxisConfiguration().addParameter(synapseConfigurationParameter);
    } catch (AxisFault e) {
      handleFatal(
          "Could not set parameters '"
              + SynapseConstants.SYNAPSE_CONFIG
              + "' to the Axis2 configuration : "
              + e.getMessage(),
          e);
    }

    addServerIPAndHostEntries();

    return synapseConfiguration;
  }
  /**
   * Setup synapse in axis2 environment and return the created instance.
   *
   * @return SynapseEnvironment instance
   */
  public SynapseEnvironment createSynapseEnvironment() {

    try {
      deployMediationLibraryArtifacts();
      deployMediatorExtensions();
      deploySynapseService();
      deployProxyServices();
      deployEventSources();
      // deployMediatorExtensions();
    } catch (AxisFault axisFault) {
      log.fatal("Synapse startup failed...", axisFault);
      throw new SynapseException("Synapse startup failed", axisFault);
    }

    synapseEnvironment =
        new Axis2SynapseEnvironment(
            configurationContext, synapseConfiguration, serverContextInformation);
    MessageContextCreatorForAxis2.setSynEnv(synapseEnvironment);

    Parameter synapseEnvironmentParameter =
        new Parameter(SynapseConstants.SYNAPSE_ENV, synapseEnvironment);
    try {
      configurationContext.getAxisConfiguration().addParameter(synapseEnvironmentParameter);
    } catch (AxisFault e) {
      handleFatal(
          "Could not set parameter '"
              + SynapseConstants.SYNAPSE_ENV
              + "' to the Axis2 configuration : "
              + e.getMessage(),
          e);
    }

    synapseEnvironment.getTaskManager().init(taskDescriptionRepository, taskScheduler);
    synapseConfiguration.init(synapseEnvironment);
    synapseEnvironment.setInitialized(true);

    return synapseEnvironment;
  }