Removes the subscription from the MatchSpace and removes the associated itemstream
if non durable.

@param cd The consumer dispatcher
@param isNonDurable If a nondurable subscription.
@param callProxyCode If we need to call the proxy code at all.
486245
public void dereferenceSubscriptionConsumerDispatcher(
                                                          ConsumerDispatcher cd,
                                                          boolean isNonDurable,
                                                          boolean callProxyCode)
                    throws SIResourceException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "dereferenceSubscriptionConsumerDispatcher",
                        new Object[] {
                                      cd,
                                      new Boolean(isNonDurable),
                                      new Boolean(callProxyCode) });

        try
        {
            _subscriptionIndex.remove(cd);

            // Remove all entries for the consumerDispatcher from the matchspace

            SelectionCriteria[] selCriteria = cd.getConsumerDispatcherState().getSelectionCriteriaList();

            if (selCriteria != null)
            {
                for (int i = 0; i < selCriteria.length; i++)
                {
                    // Remove the CD from the MatchSpace
                    _messageProcessor
                                    .getMessageProcessorMatching()
                                    .removeConsumerDispatcherMatchTarget(cd, selCriteria[i]);
                }
            }

            // 166833.2
            // Calls to the proxy code only need to occur on a non durable delete
            // subscription, or a createDurableSubscription rolled back.
            // It won't be called in the case that a durableSubscription.
            // eventCommittedRemove as the proxy message will have already been sent.

            //716917
            //isNonDurable was passed insted of callProxyCode
            //Due to which always false was being passed when we had durable subscriber, hence
            //the unsubscribe events was not being sent to neighbouring ME's when durable subscriber was unsubscribed
            //Its an Fix to 166833.2
//    sanjay liberty change
//      if (callProxyCode)
//        _messageProcessor.getProxyHandler().unsubscribeEvent(
//          cd.getConsumerDispatcherState(),
//          null,
//          callProxyCode);
//
//      // 175488
            if (isNonDurable)
            {
                // Need to attempt cleanup of the subscription.  If it cant be completed
                // now, it will be attempted by the asynch-deletion thread at a later
                // time.

                try
                {
                    //remove the CD from ME wide hash map maintained for non durable shared consumers in Destination Manager.
                    // All non-durable shared consumer's subscriberID do not start with _NON_DURABLE_NON_SHARED
                    if (!(cd.getConsumerDispatcherState().getSubscriberID().contains("_NON_DURABLE_NON_SHARED")))
                        _destinationManager.getNondurableSharedSubscriptions().remove(cd.getConsumerDispatcherState().getSubscriberID());
                    // Find the subscription in the topicspace itemstream
                    final SubscriptionItemStream subscription =
                                    (
                                    SubscriptionItemStream) _pubsubMessageItemStream
                                                    .findFirstMatchingReferenceStream(
                                                    new SubscriptionFilter(cd));

                    // Remove any items on the subscription reference stream, and remove the stream itself
                    if (subscription != null)
                    {
                        //Mark the subscription as requiring deletion
                        subscription.markAsToBeDeleted();

                        //Drive the deletion of the subscription now.  It may not be possible to
                        //complete it now if there are indoubt messages on the subscription, in
                        //which case the commit/backout of those messages will drive the delete.
                        subscription.deleteIfPossible(true);
                    }
                } catch (MessageStoreException e)
                {
                    FFDCFilter.processException(
                                                e,
                                                "com.ibm.ws.sib.processor.impl.destination.PubSubRealization.dereferenceSubscriptionConsumerDispatcher",
                                                "1:1835:1.35.2.4",
                                                this);

                    SibTr.exception(tc, e);
                    SibTr.error(
                                tc,
                                "INTERNAL_MESSAGING_ERROR_CWSIP0003",
                                new Object[] {
                                              "com.ibm.ws.sib.processor.impl.destination.PubSubRealization",
                                              "1:1844:1.35.2.4",
                                              e,
                                              cd.getConsumerDispatcherState().getSubscriberID() });

                    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                        SibTr.exit(tc, "dereferenceSubscriptionConsumerDispatcher");

                    throw new SIResourceException(
                                    nls.getFormattedMessage(
                                                            "INTERNAL_MESSAGING_ERROR_CWSIP0003",
                                                            new Object[] {
                                                                          "com.ibm.ws.sib.processor.impl.destination.PubSubRealization",
                                                                          "1:1856:1.35.2.4",
                                                                          e,
                                                                          cd.getConsumerDispatcherState().getSubscriberID() },
                                                            null),
                                    e);
                }
            } // end of 175488
        } catch (SIException e)
        {
            // Exceptions should not be thrown by proxy handler code
            FFDCFilter.processException(
                                        e,
                                        "com.ibm.ws.sib.processor.impl.destination.PubSubRealization.dereferenceSubscriptionConsumerDispatcher",
                                        "1:1869:1.35.2.4",
                                        this);

            SibTr.exception(tc, e);
            SibTr.error(
                        tc,
                        "INTERNAL_MESSAGING_ERROR_CWSIP0003",
                        new Object[] {
                                      "com.ibm.ws.sib.processor.impl.destination.PubSubRealization",
                                      "1:1878:1.35.2.4",
                                      e,
                                      cd.getConsumerDispatcherState().getSubscriberID() });

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "dereferenceSubscriptionConsumerDispatcher");

            throw new SIResourceException(
                            nls.getFormattedMessage(
                                                    "INTERNAL_MESSAGING_ERROR_CWSIP0003",
                                                    new Object[] {
                                                                  "com.ibm.ws.sib.processor.impl.destination.PubSubRealization",
                                                                  "1:1890:1.35.2.4",
                                                                  e,
                                                                  cd.getConsumerDispatcherState().getSubscriberID() },
                                                    null),
                            e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "dereferenceSubscriptionConsumerDispatcher");
    }
1141719
public static CommerceRegion removeByC_C(long commerceCountryId, String code)
		throws com.liferay.commerce.exception.NoSuchRegionException {
		return getPersistence().removeByC_C(commerceCountryId, code);
	}
708818
@Indexable(type = IndexableType.DELETE)
	@Override
	public CPFriendlyURLEntry deleteCPFriendlyURLEntry(
		CPFriendlyURLEntry cpFriendlyURLEntry) {
		return cpFriendlyURLEntryPersistence.remove(cpFriendlyURLEntry);
	}
181253
@Override
    protected void denyImportDeclaration(ImportDeclaration importDeclaration) {
        LOG.debug("CXFImporter destroy a proxy for " + importDeclaration);
        ServiceRegistration serviceRegistration = map.get(importDeclaration);
        serviceRegistration.unregister();

        // set the importDeclaration has unhandled
        super.unhandleImportDeclaration(importDeclaration);

        map.remove(importDeclaration);
    }
990573
public void unproxyRemoteObject (DObjectAddress addr)
    {
        Tuple<Subscriber<?>, DObject> bits = _proxies.remove(addr);
        if (bits == null) {
            log.warning("Requested to clear unknown proxy", "addr", addr);
            return;
        }

        // If it's local, just remove the subscriber we added and bail
        if (Objects.equal(addr.nodeName, _nodeName)) {
            bits.right.removeSubscriber(bits.left);
            return;
        }


        // clear out the local object manager's proxy mapping
        _omgr.clearProxyObject(addr.oid, bits.right);

        final Client peer = getPeerClient(addr.nodeName);
        if (peer == null) {
            log.warning("Unable to unsubscribe from proxy, missing peer", "addr", addr);
            return;
        }

        // restore the object's omgr reference to our ClientDObjectMgr and its oid back to the
        // remote oid so that it can properly finish the unsubscription process
        bits.right.setOid(addr.oid);
        bits.right.setManager(peer.getDObjectManager());

        // finally unsubscribe from the object on our peer
        peer.getDObjectManager().unsubscribeFromObject(addr.oid, bits.left);
    }
1196305
public static boolean waitForRemovalFromJNDI(final Context ctx, final String jndiName, long timeout) {
        boolean removed = false;
        while (!removed && timeout > 0) {
            try {
                ctx.lookup(jndiName);
            } catch (NameNotFoundException ex) {
                removed = true;
            } catch (NamingException ex) {
                throw new RuntimeException("Failed JNDI lookup for " + jndiName, ex);
            }

            try {
                Thread.sleep(10);
            } catch (InterruptedException ex) {
                throw new RuntimeException("Interrupted while doing JNDI lookup for " + jndiName);
            }

            timeout -= 10;
        }

        return removed;
    }
508080
@Override
    public void destroy() // PK20881
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "destroy");

        // Dummy transactionWrappers may not be in any table and so
        // will not have a resourceCallback registered to remove them.
        if (_resourceCallback != null)
            _resourceCallback.destroy();

        _wrappers.remove(_transaction.getGlobalId());

        //      Do not remove connection with the TransactionImpl.  This will delay garbage
//      collection until the TransactionWrapper is garbage collected.
//      There is a window when an incoming request can access the remoteable object
//      (ie WSCoordinator or CoordinatorResource) and get access to the TransactionWrapper
//      while destroy() is called by another thread as the synchronization is on the
//      TransactionWrapper.  When the incoming request gets control, it will find that
//      _transaction is null.  Rather than check for this case, we leave the connection
//      to the TransactionImpl and its associated TransactionState.  The code above will
//      then check the transaction state and respond appropriately.  These checks are
//      already required as the superior may retry requests, etc.
//        _transaction = null;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "destroy");
    }
659160
@Override
	public void removeByG_C(long groupId, String couponCode) {
		for (CommerceDiscount commerceDiscount : findByG_C(groupId, couponCode,
				QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceDiscount);
		}
	}
853707
public ConsumerDispatcher getDurableSubscriptionConsumerDispatcher(ConsumerDispatcherState subState)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "getDurableSubscriptionConsumerDispatcher", subState);

        ConsumerDispatcher consumerDispatcher = null;

        // NOTE: there are two unsynchronized calls to this method from SIMPSubscriptionAssert
        // The more common call from createDurableSubscription already holds the lock
        // here in which case the extra synchronized is minor overhead.

        synchronized (_consumerDispatchersDurable)
        {
            consumerDispatcher =
                            (ConsumerDispatcher) _consumerDispatchersDurable.get(
                                            subState.getSubscriberID());
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(
                       tc,
                       "getDurableSubscriptionConsumerDispatcher",
                       consumerDispatcher);

        return consumerDispatcher;
    }
677755
public void markUnresolvable(EObject referenced) {
		if (!referenced.eIsProxy()) {
			throw new IllegalArgumentException("Cannot mark an instance as unresolvable if it is already resolved");
		}
		URI proxyURI = ((InternalEObject)referenced).eProxyURI();
		getUnresolvableURIFragments().add(proxyURI.fragment());
	}
398159
public void unregisterCallback(UOWScopeCallback callback)
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "unregisterCallback", new Object[]{callback, this});
        
        _callbackManager.removeCallback(callback);
        
        if (tc.isEntryEnabled()) Tr.exit(tc, "unregisterCallback");
    }
908231
@Override
    public void deleteDurableSubscription(
                                          String subscriptionId,
                                          String durableHome)
                    throws
                    SIDestinationLockedException,
                    SIDurableSubscriptionNotFoundException,
                    SIResourceException
    {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "deleteDurableSubscription",
                        new Object[] { subscriptionId, durableHome });

        // ASSERT: subState.getDurableHome().equals(messageProcessor.getMessagingEngineName()
        _pubSubRealization.deleteLocalDurableSubscription(subscriptionId);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "deleteDurableSubscription");
    }
1164447
public void removeDependency(final Registry registry) throws CouldNotPerformException {
        if (registry == null) {
            throw new NotAvailableException("registry");
        }
        registryLock.writeLock().lock();
        try {
            dependingRegistryMapLock.writeLock().lock();
            try {
                if (!dependingRegistryMap.containsKey(registry)) {
                    logger.warn("Could not remove a dependency which was never registered!");
                    return;
                }
                dependingRegistryMap.remove(registry).shutdown();
            } finally {
                dependingRegistryMapLock.writeLock().unlock();
            }
        } finally {
            registryLock.writeLock().unlock();
        }
    }
905068
public void removeConsumerDispatcherMatchTarget(ConsumerDispatcher consumerDispatcher, SelectionCriteria selectionCriteria)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(
        tc,
        "removeConsumerDispatcherMatchTarget",
        new Object[] {consumerDispatcher, selectionCriteria});

    // Remove the consumer point from the matchspace
    // Set the CD and selection criteria into a wrapper that extends MatchTarget

    MatchingConsumerDispatcherWithCriteira key = new MatchingConsumerDispatcherWithCriteira (consumerDispatcher,selectionCriteria);

    // Reset the CD flag to indicate that this subscription is not in the MatchSpace.
    consumerDispatcher.setIsInMatchSpace(false);

    try
    {
      removeTarget(key);
    }
    catch (MatchingException e)
    {
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.matching.MessageProcessorMatching.removeConsumerDispatcherMatchTarget",
        "1:1312:1.117.1.11",
        this);

      SibTr.exception(tc, e);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
        SibTr.exit(tc, "removeConsumerDispatcherMatchTarget", "SICoreException");

      SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002",
        new Object[] {
          "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
          "1:1323:1.117.1.11",
          e });

      throw new SIErrorException(
        nls.getFormattedMessage(
          "INTERNAL_MESSAGING_ERROR_CWSIP0002",
          new Object[] {
            "com.ibm.ws.sib.processor.matching.MessageProcessorMatching",
            "1:1331:1.117.1.11",
            e },
          null),
        e);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "removeConsumerDispatcherMatchTarget");
  }
244333
public void removeConsumerSetMonitors(ConnectionImpl connection)
  throws SINotPossibleInCurrentConfigurationException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "removeConsumerSetMonitors", new Object[] { connection });

    // Locate the connection in the callback index
    if(_callbackIndex.containsKey(connection))
    {
      // Have found registered callbacks for this connection
      Map connMap = (HashMap)_callbackIndex.get(connection);

      // Iterate through the map removing individual callbacks
      Iterator i = connMap.entrySet().iterator();
      while (i.hasNext())
      {
        Map.Entry entry = (Map.Entry)i.next();
        ConsumerSetChangeCallback callback = (ConsumerSetChangeCallback)entry.getKey();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
          SibTr.debug(tc, "Found registered callback: " + callback);

        // Locate the TopicRecord for the callback
        TopicRecord tRecord = (TopicRecord)entry.getValue();
        if(tRecord != null)
        {
          // Have found the callback in the index, now remove the callback from
          // the appropriate registered monitors table.
          if(tRecord.isWildcarded)
          {
            removeCallbackFromRegisteredMonitors(callback,
                                                 tRecord.topicExpression,
                                                 true, // isWildcarded
                                                 _registeredWildcardConsumerMonitors);
          }
          else
          {
            // Handle the non-wildcard case
            removeCallbackFromRegisteredMonitors(callback,
                                                 tRecord.topicExpression,
                                                 false, // isWildcarded
                                                 _registeredExactConsumerMonitors);
          }
        }
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "removeConsumerSetMonitors");
  }
441744
@Override
    public ItemStream removeFirstMatching(Filter filter, Transaction transaction) throws MessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "removeFirstMatching", new Object[] { filter, transaction });

        if (_rootMembership != null)
        {
            ItemStream item = _rootMembership.removeFirstMatchingItemStream(filter, (PersistentTransaction) transaction);

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "removeFirstMatching", "return=" + item);
            return item;
        }
        else
        {
            MessageStoreUnavailableException msue;
            if (!_startupExceptions.isEmpty())
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    SibTr.event(this, tc, "Operation not possible as MessageStore failed to start!");
                msue = new MessageStoreUnavailableException("Operation not possible as MessageStore failed to start!", _startupExceptions.get(0));
            }
            else
            {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    SibTr.event(this, tc, "Operation not possible as MessageStore is unavailable!");
                msue = new MessageStoreUnavailableException("Operation not possible as MessageStore is unavailable!");
            }

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "removeFirstMatching");
            throw msue;
        }
    }
1288570
@Override
    public boolean registerConsumerSetMonitor(
                                              SIDestinationAddress destinationAddress,
                                              String discriminatorExpression,
                                              ConsumerSetChangeCallback callback)
                    throws SIResourceException,
                    SINotPossibleInCurrentConfigurationException,
                    SIConnectionUnavailableException,
                    SIConnectionDroppedException,
                    SIIncorrectCallException,
                    SICommandInvocationFailedException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(
                        tc,
                        "registerConsumerSetMonitor",
                        new Object[] { destinationAddress,
                                      discriminatorExpression,
                                      callback });

        // Check that a listener has been specified
        if (callback == null)
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "registerConsumerSetMonitor", "SIIncorrectCallException");
            // Parameter is null, throw an excepiton
            throw new SIIncorrectCallException(nls.getFormattedMessage("NULL_CONSUMERSETCHANGECALLBACK_CWSIP0667", null, null));
        } else if (destinationAddress == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "registerConsumerSetMonitor", "SIIncorrectCallException");
            // Parameter is null, throw an excepiton
            throw new SIIncorrectCallException(nls.getFormattedMessage("NULL_DESTINATIONADDRESS_CWSIP0668", null, null));

        } else if (discriminatorExpression == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "registerConsumerSetMonitor", "SIIncorrectCallException");
            // Parameter is null, throw an excepiton
            throw new SIIncorrectCallException(nls.getFormattedMessage("NULL_DISCRIMINATOREXPRESSION_CWSIP0669", null, null));

        }
        boolean areConsumers = false;
        try
        {
            DestinationHandler topicSpace =
                            _destinationManager.getDestination((JsDestinationAddress) destinationAddress, false);

            areConsumers =
                            _messageProcessor.
                                            getMessageProcessorMatching().
                                            registerConsumerSetMonitor(topicSpace,
                                                                       discriminatorExpression,
                                                                       this,
                                                                       callback);
        } catch (Exception e)
        {
            // FFDC
            FFDCFilter
                            .processException(
                                              e,
                                              "com.ibm.ws.sib.processor.impl.ConnectionImpl.registerConsumerSetMonitor",
                                              "1:7378:1.347.1.25",
                                              this);

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.exception(tc, e);

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(tc, "registerConsumerSetMonitor", "SIErrorException");
            //SIErrorException is RuntimeExcetion hence catching this exception in StaticCATConnection
            throw new SIErrorException(e);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "registerConsumerSetMonitor", Boolean.valueOf(areConsumers));
        return areConsumers;
    }