icegem-core/src/main/java/com/googlecode/icegem/expiration/ExpirationController.java
public long process(Region<?, ?> region, ExpirationPolicy policy) {

		long destroyedEntriesNumber = 0;

		try {

			if (region == null) {
				throw new IllegalStateException("The Region cannot be null");
			}

			if (policy == null) {
				throw new IllegalArgumentException(
					"The ExpirationPolicy cannot be null");
			}

			logger
				.info("Running ExpirationController process with parameters region = "
					+ region
					+ ", policy = "
					+ policy
					+ ", packetSize = "
					+ packetSize + ", packetDelay = " + packetDelay);

			DestroyedEntriesCountCollector collector = (DestroyedEntriesCountCollector) FunctionService
				.onRegion(region)
				.withArgs(
					new ExpirationFunctionArguments(packetSize, packetDelay))
				.withCollector(new DestroyedEntriesCountCollector())
				.execute(new ExpirationFunction(policy));

			Object result = collector.getResult();
			if (result instanceof Long) {
				destroyedEntriesNumber = (Long) result;
			}

			logger
				.info("ExpirationController process with parameters region = "
					+ region + ", policy = " + policy + ", packetSize = "
					+ packetSize + ", packetDelay = " + packetDelay
					+ " has destroyed " + destroyedEntriesNumber + " entries");

		} catch (RuntimeException re) {
			logger.error("RuntimeException during processing", re);
			throw re;
		}

		return destroyedEntriesNumber;
	}
public long process(Region<?, ?> region, ExpirationPolicy policy) {

		long destroyedEntriesNumber = 0;

		try {

			if (region == null) {
				throw new IllegalStateException("The Region cannot be null");
			}

			if (policy == null) {
				throw new IllegalArgumentException(
					"The ExpirationPolicy cannot be null");
			}

			logger
				.info("Running ExpirationController process with parameters region = "
					+ region
					+ ", policy = "
					+ policy
					+ ", packetSize = "
					+ packetSize + ", packetDelay = " + packetDelay);

			DestroyedEntriesCountCollector collector = (DestroyedEntriesCountCollector) FunctionService
				.onRegion(region)
				.withArgs(
					new ExpirationFunctionArguments(packetSize, packetDelay))
				.withCollector(new DestroyedEntriesCountCollector())
				.execute(new ExpirationFunction(policy));

			Object result = collector.getResult();
			if (result instanceof Long) {
				destroyedEntriesNumber = (Long) result;
			}

			logger
				.info("ExpirationController process with parameters region = "
					+ region + ", policy = " + policy + ", packetSize = "
					+ packetSize + ", packetDelay = " + packetDelay
					+ " has destroyed " + destroyedEntriesNumber + " entries");

		} catch (RuntimeException re) {
			logger.error("RuntimeException during processing", re);
			throw re;
		}

		return destroyedEntriesNumber;
	}
public long process ( Region < ? , ? > region , ExpirationPolicy policy ) { long destroyedEntriesNumber = 0 ; try { if ( region == null ) { throw new IllegalStateException ( "The Region cannot be null" ) ; } if ( policy == null ) { throw new IllegalArgumentException ( "The ExpirationPolicy cannot be null" ) ; } logger . info ( "Running ExpirationController process with parameters region = " + region + ", policy = " + policy + ", packetSize = " + packetSize + ", packetDelay = " + packetDelay ) ; DestroyedEntriesCountCollector collector = ( DestroyedEntriesCountCollector ) FunctionService . onRegion ( region ) . withArgs ( new ExpirationFunctionArguments ( packetSize , packetDelay ) ) . withCollector ( new DestroyedEntriesCountCollector ( ) ) . execute ( new ExpirationFunction ( policy ) ) ; Object result = collector . getResult ( ) ; if ( result instanceof Long ) { destroyedEntriesNumber = ( Long ) result ; } logger . info ( "ExpirationController process with parameters region = " + region + ", policy = " + policy + ", packetSize = " + packetSize + ", packetDelay = " + packetDelay + " has destroyed " + destroyedEntriesNumber + " entries" ) ; } catch ( RuntimeException re ) { logger . error ( "RuntimeException during processing" , re ) ; throw re ; } return destroyedEntriesNumber ; }
Applies the specified policy on the specified region and returns number
of destroyed entries.

@param region
- the region
@param policy
- the expiration policy
@return - the number of destroyed region entries
Applies the specified policy on the specified region and returns number of destroyed entries .