container/services/src/main/java/org/mobicents/slee/container/management/ServiceManagementImpl.java
public void activityEnded(final ServiceActivityHandle activityHandle) {
		// do this only on tx commit and in a new thread, to escape the tx context
		final Runnable r = new Runnable() {			
			public void run() {
				final ServiceID serviceID = activityHandle.getServiceID();
				if (logger.isDebugEnabled()) {
					logger.debug("Activity end for " + serviceID);
				}		
				// remove and cancel the timer task to force activity ending
				ScheduledFuture<?> scheduledFuture = activityEndingTasks.remove(serviceID);
				if (scheduledFuture != null) {
					scheduledFuture.cancel(true);
				}
				// get stopping service
				final ServiceComponent serviceComponent = componentRepositoryImpl
				.getComponentByID(serviceID);
				if (serviceComponent != null) {
					synchronized (serviceComponent) {
						if (logger.isDebugEnabled()) {
							logger.debug("Service is in "
									+ serviceComponent.getServiceState() + " state.");
						}
						if (serviceComponent.getServiceState().isStopping()) {
							completeServiceStop(serviceComponent);
						}
						serviceComponent.setActivityEnded(true);
					}
				}
				else {
					if (logger.isDebugEnabled()) {
						logger.debug(serviceID.toString()+ " activity ended, but component not found, removed concurrently?");
					}
				}				
			}
		};
		final ExecutorService executorService = Executors.newSingleThreadExecutor(SLEE_THREAD_FACTORY);
		TransactionContext txContext = sleeContainer.getTransactionManager().getTransactionContext();
		if (txContext != null) {
			TransactionalAction txAction = new TransactionalAction() {
				public void execute() {
					try {
						executorService.execute(r);
					}
					catch (Exception e) {
						logger.error("failed to execute task to complete service deactivation",e);
					}
					executorService.shutdown();
				}
			};
			txContext.getAfterCommitActions().add(txAction);
		}
		else {
			try {
				executorService.execute(r);
			}
			catch (Exception e) {
				logger.error("failed to execute task to complete service deactivation",e);
			}
			executorService.shutdown();
		}
	}
public void activityEnded(final ServiceActivityHandle activityHandle) {
		// do this only on tx commit and in a new thread, to escape the tx context
		final Runnable r = new Runnable() {			
			public void run() {
				final ServiceID serviceID = activityHandle.getServiceID();
				if (logger.isDebugEnabled()) {
					logger.debug("Activity end for " + serviceID);
				}		
				// remove and cancel the timer task to force activity ending
				ScheduledFuture<?> scheduledFuture = activityEndingTasks.remove(serviceID);
				if (scheduledFuture != null) {
					scheduledFuture.cancel(true);
				}
				// get stopping service
				final ServiceComponent serviceComponent = componentRepositoryImpl
				.getComponentByID(serviceID);
				if (serviceComponent != null) {
					synchronized (serviceComponent) {
						if (logger.isDebugEnabled()) {
							logger.debug("Service is in "
									+ serviceComponent.getServiceState() + " state.");
						}
						if (serviceComponent.getServiceState().isStopping()) {
							completeServiceStop(serviceComponent);
						}
						serviceComponent.setActivityEnded(true);
					}
				}
				else {
					if (logger.isDebugEnabled()) {
						logger.debug(serviceID.toString()+ " activity ended, but component not found, removed concurrently?");
					}
				}				
			}
		};
		final ExecutorService executorService = Executors.newSingleThreadExecutor(SLEE_THREAD_FACTORY);
		TransactionContext txContext = sleeContainer.getTransactionManager().getTransactionContext();
		if (txContext != null) {
			TransactionalAction txAction = new TransactionalAction() {
				public void execute() {
					try {
						executorService.execute(r);
					}
					catch (Exception e) {
						logger.error("failed to execute task to complete service deactivation",e);
					}
					executorService.shutdown();
				}
			};
			txContext.getAfterCommitActions().add(txAction);
		}
		else {
			try {
				executorService.execute(r);
			}
			catch (Exception e) {
				logger.error("failed to execute task to complete service deactivation",e);
			}
			executorService.shutdown();
		}
	}
public void activityEnded ( final ServiceActivityHandle activityHandle ) { // do this only on tx commit and in a new thread, to escape the tx context final Runnable r = new Runnable ( ) { public void run ( ) { final ServiceID serviceID = activityHandle . getServiceID ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Activity end for " + serviceID ) ; } // remove and cancel the timer task to force activity ending ScheduledFuture < ? > scheduledFuture = activityEndingTasks . remove ( serviceID ) ; if ( scheduledFuture != null ) { scheduledFuture . cancel ( true ) ; } // get stopping service final ServiceComponent serviceComponent = componentRepositoryImpl . getComponentByID ( serviceID ) ; if ( serviceComponent != null ) { synchronized ( serviceComponent ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Service is in " + serviceComponent . getServiceState ( ) + " state." ) ; } if ( serviceComponent . getServiceState ( ) . isStopping ( ) ) { completeServiceStop ( serviceComponent ) ; } serviceComponent . setActivityEnded ( true ) ; } } else { if ( logger . isDebugEnabled ( ) ) { logger . debug ( serviceID . toString ( ) + " activity ended, but component not found, removed concurrently?" ) ; } } } } ; final ExecutorService executorService = Executors . newSingleThreadExecutor ( SLEE_THREAD_FACTORY ) ; TransactionContext txContext = sleeContainer . getTransactionManager ( ) . getTransactionContext ( ) ; if ( txContext != null ) { TransactionalAction txAction = new TransactionalAction ( ) { public void execute ( ) { try { executorService . execute ( r ) ; } catch ( Exception e ) { logger . error ( "failed to execute task to complete service deactivation" , e ) ; } executorService . shutdown ( ) ; } } ; txContext . getAfterCommitActions ( ) . add ( txAction ) ; } else { try { executorService . execute ( r ) ; } catch ( Exception e ) { logger . error ( "failed to execute task to complete service deactivation" , e ) ; } executorService . shutdown ( ) ; } }
/*
(non-Javadoc)

@see
org.mobicents.slee.container.management.ServiceManagement#activityEnded
(org.mobicents.slee.container.service.ServiceActivityHandle)
/ * ( non - Javadoc )