<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.conference;

import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Callable;

import javax.media.mscontrol.Parameters;
import javax.media.mscontrol.join.Joinable.Direction;

import org.apache.log4j.Logger;

import com.voxeo.moho.ApplicationContextImpl;
import com.voxeo.moho.JoinWorker;
import com.voxeo.moho.Joint;
import com.voxeo.moho.JointImpl;
import com.voxeo.moho.MixerEndpoint;
import com.voxeo.moho.MixerImpl;
import com.voxeo.moho.Participant;
import com.voxeo.moho.ParticipantContainer;
import com.voxeo.moho.Unjoint;
import com.voxeo.moho.UnjointImpl;
import com.voxeo.moho.event.JoinCompleteEvent;
import com.voxeo.moho.event.MohoUnjoinCompleteEvent;
import com.voxeo.moho.event.UnjoinCompleteEvent;
import com.voxeo.moho.remotejoin.RemoteParticipant;
import com.voxeo.moho.spi.ExecutionContext;
import com.voxeo.moho.util.IDGenerator;

public class ConferenceImpl extends MixerImpl implements Conference, ParticipantContainer {

  private static final Logger LOG = Logger.getLogger(ConferenceImpl.class);

  protected String _id;

  protected int _maxSeats;

  protected int _occupiedSeats;

  protected ConferenceController _controller;

  protected Object _lock = new Object();

  protected ConferenceImpl(final ExecutionContext context, final MixerEndpoint address,
      final Map<Object, Object> params, final String id, final int seats, final ConferenceController controller,
      Parameters parameters) {
    super(context, address, params, parameters);
    _id = IDGenerator.generateId(_context, RemoteParticipant.RemoteParticipant_TYPE_CONFERENCE, id);
    _maxSeats = seats;
    _controller = controller;
    
    if (_context != null && getId() != null) {
      ((ApplicationContextImpl) _context).addParticipant(this);
    }
  }

  @Override
  public String getId() {
    return _id;
  }

  @Override
  public Joint join(final Participant other, final JoinType type, final Direction direction)
      throws IllegalStateException {
    checkState();
    return new JointImpl(_context.getExecutor(), new JoinWorker() {
      @Override
      public JoinCompleteEvent call() throws Exception {
        synchronized (_lock) {
          if (_controller != null) {
            _controller.preJoin(other, ConferenceImpl.this);
          }
          final JoinCompleteEvent retval = ConferenceImpl.super.join(other, type, direction).get();
          _occupiedSeats = _occupiedSeats + 1;
          if (_controller != null) {
            _controller.postJoin(other, ConferenceImpl.this);
          }
          return retval;
        }<commit_msg>conference id value.<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.conference;

import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Callable;

import javax.media.mscontrol.Parameters;
import javax.media.mscontrol.join.Joinable.Direction;

import org.apache.log4j.Logger;

import com.voxeo.moho.ApplicationContextImpl;
import com.voxeo.moho.JoinWorker;
import com.voxeo.moho.Joint;
import com.voxeo.moho.JointImpl;
import com.voxeo.moho.MixerEndpoint;
import com.voxeo.moho.MixerImpl;
import com.voxeo.moho.Participant;
import com.voxeo.moho.ParticipantContainer;
import com.voxeo.moho.Unjoint;
import com.voxeo.moho.UnjointImpl;
import com.voxeo.moho.event.JoinCompleteEvent;
import com.voxeo.moho.event.MohoUnjoinCompleteEvent;
import com.voxeo.moho.event.UnjoinCompleteEvent;
import com.voxeo.moho.remotejoin.RemoteParticipant;
import com.voxeo.moho.spi.ExecutionContext;
import com.voxeo.moho.util.IDGenerator;

public class ConferenceImpl extends MixerImpl implements Conference, ParticipantContainer {

  private static final Logger LOG = Logger.getLogger(ConferenceImpl.class);

  protected String _id;

  protected int _maxSeats;

  protected int _occupiedSeats;

  protected ConferenceController _controller;

  protected Object _lock = new Object();

  protected ConferenceImpl(final ExecutionContext context, final MixerEndpoint address,
      final Map<Object, Object> params, final String id, final int seats, final ConferenceController controller,
      Parameters parameters) {
    super(context, address, params, parameters);
    //TODO 
    _id = id;
    _maxSeats = seats;
    _controller = controller;
    
    if (_context != null && getId() != null) {
      ((ApplicationContextImpl) _context).addParticipant(this);
    }
  }

  @Override
  public String getId() {
    return _id;
  }

  @Override
  public Joint join(final Participant other, final JoinType type, final Direction direction)
      throws IllegalStateException {
    checkState();
    return new JointImpl(_context.getExecutor(), new JoinWorker() {
      @Override
      public JoinCompleteEvent call() throws Exception {
        synchronized (_lock) {
          if (_controller != null) {
            _controller.preJoin(other, ConferenceImpl.this);
          }
          final JoinCompleteEvent retval = ConferenceImpl.super.join(other, type, direction).get();
          _occupiedSeats = _occupiedSeats + 1;
          if (_controller != null) {
            _controller.postJoin(other, ConferenceImpl.this);
          }
          return retval;
        }
{'fraction_non_alphanumeric': 0.08701787394167451, 'fraction_numerical': 0.004390090937597993, 'mean_word_length': 3.9603421461897357, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '2654328', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1829, 'n_words': 513}