<commit_before>/**
 * Copyright 2010-2011 Voxeo Corporation
 *
 * 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.voxeo.moho;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import javax.media.mscontrol.MsControlFactory;
import javax.sdp.SdpFactory;
import javax.servlet.ServletContext;
import javax.servlet.sip.SipFactory;

import com.voxeo.moho.conference.ConferenceManager;
import com.voxeo.moho.spi.ExecutionContext;
import com.voxeo.moho.spi.ProtocolDriver;
import com.voxeo.moho.spi.SpiFramework;
import com.voxeo.moho.util.Utils.DaemonThreadFactory;

public class ApplicationContextImpl extends AttributeStoreImpl implements ExecutionContext {

  protected Application _application;

  protected MsControlFactory _mcFactory;
  
  protected MediaServiceFactory _msFactory;

  protected ConferenceManager _confMgr;

  protected SipFactory _sipFactory;

  protected SdpFactory _sdpFactory;

  protected String _controller;

  protected Map<String, Call> _calls = new ConcurrentHashMap<String, Call>();

  protected Map<String, String> _parameters = new ConcurrentHashMap<String, String>();

  protected ServletContext _servletContext;

  protected ThreadPoolExecutor _executor;
  
  protected SpiFramework _framework;

  public ApplicationContextImpl(final Application app, final MsControlFactory mc, final SipFactory sip,
      final SdpFactory sdp, final String controller, final ServletContext servletContext, final int threadPoolSize) {
    _application = app;
    _mcFactory = mc;
    _sipFactory = sip;
    _sdpFactory = sdp;
    _controller = controller;
    _servletContext = servletContext;

    _executor = new ThreadPoolExecutor(threadPoolSize, Integer.MAX_VALUE, 60, TimeUnit.SECONDS,
        new SynchronousQueue<Runnable>(), new DaemonThreadFactory("MohoContext"));
  }

  @Override
  public Application getApplication() {
    return _application;
  }

  private Endpoint getEndpoint(final String addr, String type) {
    if (addr == null) {
      throw new IllegalArgumentException("argument is null");
    }
//      if (addr.startsWith("sip:") || addr.startsWith("sips:") || addr.startsWith("<sip:") || addr.startsWith("<sips:")) {
//        return new SIPEndpointImpl(this, _sipFactory.createAddress(addr));
//      }
//      else if (addr.startsWith("mscontrol://")) {
//        return new MixerEndpointImpl(this, addr);
//      }
//      else if (addr.startsWith("file://") || addr.startsWith("http://") || addr.startsWith("https://")
//          || addr.startsWith("ftp://")) {
//        return new VoiceXMLEndpointImpl(this, addr);
//      }
//      else if (addr.startsWith("tel:") || addr.startsWith("fax:") || addr.startsWith("<tel:")
//          || addr.startsWith("<fax:")) {
//        return new SIPEndpointImpl(this, _sipFactory.createAddress(addr));
//      }
//      else if (type != null && TextChannels.getProvider(type) != null) {<commit_msg>workaround for mixer endpoint for now.<commit_after>/**
 * Copyright 2010-2011 Voxeo Corporation
 *
 * 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.voxeo.moho;

import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import javax.media.mscontrol.MsControlFactory;
import javax.sdp.SdpFactory;
import javax.servlet.ServletContext;
import javax.servlet.sip.SipFactory;

import com.voxeo.moho.conference.ConferenceManager;
import com.voxeo.moho.spi.ExecutionContext;
import com.voxeo.moho.spi.ProtocolDriver;
import com.voxeo.moho.spi.SpiFramework;
import com.voxeo.moho.util.Utils.DaemonThreadFactory;

public class ApplicationContextImpl extends AttributeStoreImpl implements ExecutionContext {

  protected Application _application;

  protected MsControlFactory _mcFactory;
  
  protected MediaServiceFactory _msFactory;

  protected ConferenceManager _confMgr;

  protected SipFactory _sipFactory;

  protected SdpFactory _sdpFactory;

  protected String _controller;

  protected Map<String, Call> _calls = new ConcurrentHashMap<String, Call>();

  protected Map<String, String> _parameters = new ConcurrentHashMap<String, String>();

  protected ServletContext _servletContext;

  protected ThreadPoolExecutor _executor;
  
  protected SpiFramework _framework;

  public ApplicationContextImpl(final Application app, final MsControlFactory mc, final SipFactory sip,
      final SdpFactory sdp, final String controller, final ServletContext servletContext, final int threadPoolSize) {
    _application = app;
    _mcFactory = mc;
    _sipFactory = sip;
    _sdpFactory = sdp;
    _controller = controller;
    _servletContext = servletContext;

    _executor = new ThreadPoolExecutor(threadPoolSize, Integer.MAX_VALUE, 60, TimeUnit.SECONDS,
        new SynchronousQueue<Runnable>(), new DaemonThreadFactory("MohoContext"));
  }

  @Override
  public Application getApplication() {
    return _application;
  }

  private Endpoint getEndpoint(final String addr, String type) {
    if (addr == null) {
      throw new IllegalArgumentException("argument is null");
    }
    if (addr.startsWith("mscontrol://")) {
      return new MixerEndpointImpl(this, addr);
    }
//      if (addr.startsWith("sip:") || addr.startsWith("sips:") || addr.startsWith("<sip:") || addr.startsWith("<sips:")) {
//        return new SIPEndpointImpl(this, _sipFactory.createAddress(addr));
//      }
//      else if (addr.startsWith("mscontrol://")) {
//        return new MixerEndpointImpl(this, addr);
//      }
//      else if (addr.startsWith("file://") || addr.startsWith("http://") || addr.startsWith("https://")
//          || addr.startsWith("ftp://")) {
//        return new VoiceXMLEndpointImpl(this, addr);
//      }
//      else if (addr.startsWith("tel:") || addr.startsWith("fax:") || addr.startsWith("<tel:")
//          || addr.startsWith("<fax:")) {
//        return new SIPEndpointImpl(this, _sipFactory.createAddress(addr));
//      }
//      else if (type != null && TextChannels.getProvider(type) != null) {
{'fraction_non_alphanumeric': 0.11009798584648885, 'fraction_numerical': 0.003810560696788242, 'mean_word_length': 4.212056737588653, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2653366', 'n_tokens_mistral': 2144, 'n_tokens_neox': 2091, 'n_words': 561}