container/activities/src/main/java/org/mobicents/slee/container/management/jmx/ActivityManagementMBeanImpl.java
private Object[] listWithCriteria(boolean listIDsOnly, boolean inDetails,
			int criteria, String comparisonCriteria) {

		logger.info("Listing with criteria[" + criteria + "] with details["
				+ inDetails + "] only IDS[" + listIDsOnly + "]");

		Iterator<ActivityContextHandle> it = this.acFactory.getAllActivityContextsHandles().iterator();
		ArrayList<Object> lst = new ArrayList<Object>();

		// Needed by LIST_BY_SBBID
		HashMap<SbbEntityID,SbbID> sbbEntityIdToSbbID = new HashMap<SbbEntityID,SbbID>();

		while (it.hasNext()) {
			ActivityContextHandle achOrig = it.next();
			//JmxActivityContextHandle ach = ActivityContextHandleSerializer.encode(achOrig);
			ActivityContextImpl ac = this.acFactory.getActivityContext(achOrig);
			if (ac == null) {
				continue;
			}
			Object activity = achOrig.getActivityObject();

			if (activity != null) {  
				
	      String acId = ac.getStringID();
	      String acSource = achOrig.getActivityType() == ActivityType.RA ? ((ResourceAdaptorActivityContextHandle)achOrig).getResourceAdaptorEntity().getName() : "";

	      switch (criteria) {
				case LIST_BY_ACTIVITY_CLASS:

					if (!activity.getClass().getCanonicalName().equals(comparisonCriteria)) {
						ac = null; // we dont want this one here
					}						
					break;

				case LIST_BY_RAENTITY:

					if (achOrig.getActivityType() == ActivityType.RA) {
						if (!acSource.equals(comparisonCriteria))
							ac = null;
					} else
						ac = null;
					break;

				case LIST_BY_SBBENTITY:
					
					for (SbbEntityID sbbEntityID : ac.getSbbAttachmentSet()) {
						if (sbbEntityID.toString().equals(comparisonCriteria)) {
							break;
						}
					}
					ac = null;
					break;

				case LIST_BY_SBBID:
					ComponentIDPropertyEditor propertyEditor = new ComponentIDPropertyEditor();
					propertyEditor.setAsText(comparisonCriteria);
					SbbID idBeingLookedUp = (SbbID) propertyEditor.getValue();
					boolean match = false;
					SbbID implSbbID = null;
					for (SbbEntityID sbbEntityID : ac.getSbbAttachmentSet()) {
						if (sbbEntityIdToSbbID.containsKey(sbbEntityID)) {
							implSbbID = sbbEntityIdToSbbID.get(sbbEntityID);
						} else {
							SbbEntity sbbe = sbbEntityFactory.getSbbEntity(sbbEntityID,false);
							if (sbbe == null) {
								continue;
							}
							implSbbID = sbbe.getSbbId();
							sbbEntityIdToSbbID.put(sbbEntityID, implSbbID);
						}

						if (!implSbbID.equals(idBeingLookedUp)) {

							match = false;
							continue;
						} else {
							match = true;
							break;
						}

					}

					if (!match) {
						ac = null;
					}

					break;

				case LIST_BY_NO_CRITERIA:

					break;

				default:

					continue;
				}

				if (ac == null)
					continue;

				// Now we have to check - if we want only IDS
				Object singleResult = null;
				if (!listIDsOnly) {
					logger.debug("Adding AC[" + acId + "]");

					Object[] o = getDetails(ac);

					if (!inDetails) {

						// This is stupid, but can save some bandwith, not sure if
						// we
						// should care. But Console is java script, and
						// sometimes that can be pain, so lets ease it
					    o[SBB_ATTACHMENTS] = Integer.toString(((Object[]) o[SBB_ATTACHMENTS]).length);
						o[NAMES_BOUND_TO] = Integer.toString(((Object[]) o[NAMES_BOUND_TO]).length);
						o[TIMERS_ATTACHED] = Integer.toString(((Object[]) o[TIMERS_ATTACHED]).length);
						o[DATA_PROPERTIES] = Integer.toString(((Object[]) o[DATA_PROPERTIES]).length);
					}

					singleResult = o;

				} else {

					singleResult = acId;
				}

				lst.add(singleResult);
			}

		}
		if (lst.isEmpty())
			return null;

		logger.info("RETURN SIZE[" + lst.size() + "]");

		Object[] ret = new Object[lst.size()];
		ret = lst.toArray(ret);

		return ret;
	}
private Object[] listWithCriteria(boolean listIDsOnly, boolean inDetails,
			int criteria, String comparisonCriteria) {

		logger.info("Listing with criteria[" + criteria + "] with details["
				+ inDetails + "] only IDS[" + listIDsOnly + "]");

		Iterator<ActivityContextHandle> it = this.acFactory.getAllActivityContextsHandles().iterator();
		ArrayList<Object> lst = new ArrayList<Object>();

		// Needed by LIST_BY_SBBID
		HashMap<SbbEntityID,SbbID> sbbEntityIdToSbbID = new HashMap<SbbEntityID,SbbID>();

		while (it.hasNext()) {
			ActivityContextHandle achOrig = it.next();
			//JmxActivityContextHandle ach = ActivityContextHandleSerializer.encode(achOrig);
			ActivityContextImpl ac = this.acFactory.getActivityContext(achOrig);
			if (ac == null) {
				continue;
			}
			Object activity = achOrig.getActivityObject();

			if (activity != null) {  
				
	      String acId = ac.getStringID();
	      String acSource = achOrig.getActivityType() == ActivityType.RA ? ((ResourceAdaptorActivityContextHandle)achOrig).getResourceAdaptorEntity().getName() : "";

	      switch (criteria) {
				case LIST_BY_ACTIVITY_CLASS:

					if (!activity.getClass().getCanonicalName().equals(comparisonCriteria)) {
						ac = null; // we dont want this one here
					}						
					break;

				case LIST_BY_RAENTITY:

					if (achOrig.getActivityType() == ActivityType.RA) {
						if (!acSource.equals(comparisonCriteria))
							ac = null;
					} else
						ac = null;
					break;

				case LIST_BY_SBBENTITY:
					
					for (SbbEntityID sbbEntityID : ac.getSbbAttachmentSet()) {
						if (sbbEntityID.toString().equals(comparisonCriteria)) {
							break;
						}
					}
					ac = null;
					break;

				case LIST_BY_SBBID:
					ComponentIDPropertyEditor propertyEditor = new ComponentIDPropertyEditor();
					propertyEditor.setAsText(comparisonCriteria);
					SbbID idBeingLookedUp = (SbbID) propertyEditor.getValue();
					boolean match = false;
					SbbID implSbbID = null;
					for (SbbEntityID sbbEntityID : ac.getSbbAttachmentSet()) {
						if (sbbEntityIdToSbbID.containsKey(sbbEntityID)) {
							implSbbID = sbbEntityIdToSbbID.get(sbbEntityID);
						} else {
							SbbEntity sbbe = sbbEntityFactory.getSbbEntity(sbbEntityID,false);
							if (sbbe == null) {
								continue;
							}
							implSbbID = sbbe.getSbbId();
							sbbEntityIdToSbbID.put(sbbEntityID, implSbbID);
						}

						if (!implSbbID.equals(idBeingLookedUp)) {

							match = false;
							continue;
						} else {
							match = true;
							break;
						}

					}

					if (!match) {
						ac = null;
					}

					break;

				case LIST_BY_NO_CRITERIA:

					break;

				default:

					continue;
				}

				if (ac == null)
					continue;

				// Now we have to check - if we want only IDS
				Object singleResult = null;
				if (!listIDsOnly) {
					logger.debug("Adding AC[" + acId + "]");

					Object[] o = getDetails(ac);

					if (!inDetails) {

						// This is stupid, but can save some bandwith, not sure if
						// we
						// should care. But Console is java script, and
						// sometimes that can be pain, so lets ease it
					    o[SBB_ATTACHMENTS] = Integer.toString(((Object[]) o[SBB_ATTACHMENTS]).length);
						o[NAMES_BOUND_TO] = Integer.toString(((Object[]) o[NAMES_BOUND_TO]).length);
						o[TIMERS_ATTACHED] = Integer.toString(((Object[]) o[TIMERS_ATTACHED]).length);
						o[DATA_PROPERTIES] = Integer.toString(((Object[]) o[DATA_PROPERTIES]).length);
					}

					singleResult = o;

				} else {

					singleResult = acId;
				}

				lst.add(singleResult);
			}

		}
		if (lst.isEmpty())
			return null;

		logger.info("RETURN SIZE[" + lst.size() + "]");

		Object[] ret = new Object[lst.size()];
		ret = lst.toArray(ret);

		return ret;
	}
This is main place where SLEE is accessed. This functions lists AC in
various different ways. It can either return Object[] of arrays
representing AC of simple Object[] that in fact contains String objects
representing IDs of Activity Contexts

@param listIDsOnly -
tells to list only its, if this is true, second boolean flag
is ignored. Return value is Object[]{String,String,....}
@param inDetails -
Tells whether sub-arrays containing name bindings, attached
sbb entities should be passed, or only value representing
their length. If true arrays are passed, if false, only
values.
@param criteria -
Critteria to search by - if this is different than
{@link ActivityManagementMBeanImplMBean.LIST_BY_NO_CRITERIA}
next parameter has to have value.
@param comparisonCriteria -
this has to contain String representation of criteria ac
should be looked by: SbbEID, RA Entity Name , SbbID or
activity class name - like getClass().getName().
@return
<ul>
<li>Object[]{Stirng, String}</li>
<li>Object[] ={@link #retrieveActivityContextDetails()},{@link #retrieveActivityContextDetails()},....
</li>
</ul>