container/router/src/main/java/org/mobicents/slee/runtime/eventrouter/routingtask/InitialEventProcessor.java
private String computeConvergenceName(EventContext eventContext,
			ServiceComponent serviceComponent, SleeContainer sleeContainer) throws Exception {

		final SbbComponent sbbComponent = serviceComponent.getRootSbbComponent();
		final EventEntryDescriptor eventEntryDescriptor = sbbComponent.getDescriptor().getEventEntries().get(eventContext.getEventTypeId());
		StringBuilder buff = null;
		
		/*
		 * An initial-event-selector-method-name element. This element is
		 * optional and is meaningful only if initial-event is true. It
		 * identifies an in itial event selector method. The SLEE invokes this
		 * optional method to d etermine if an event of the specified event type
		 * is an initial event if the SBB is a root SBB of a Service (see
		 * Section 8.5.4). Note that this method is not static. You can either
		 * used a pooled instance of the object or create a new instance of the
		 * object to run the specified method.
		 */		
		if (eventEntryDescriptor.getInitialEventSelectorMethod() != null) {
			// IES METHOD DEFINED
			// invoke method
			InitialEventSelectorImpl selector = new InitialEventSelectorImpl(eventContext,eventEntryDescriptor);
			SbbObjectPool pool = sleeContainer.getSbbManagement().getObjectPool(serviceComponent.getServiceID(),
					sbbComponent.getSbbID());
			SbbObject sbbObject = pool.borrowObject();
			Object[] args = new Object[] { selector };
			ClassLoader oldCl = Thread.currentThread().getContextClassLoader();

			final JndiManagement jndiManagement = sleeContainer.getJndiManagement();
			jndiManagement.pushJndiContext(sbbComponent);

			try {
				Thread.currentThread().setContextClassLoader(
						sbbComponent.getClassLoader());
				final Method m = sbbComponent.getInitialEventSelectorMethods().get(eventEntryDescriptor.getInitialEventSelectorMethod());
				selector = (InitialEventSelectorImpl) m.invoke(sbbObject.getSbbConcrete(),
						args);
				if (selector == null) {
					return null;
				}
				if (!selector.isInitialEvent()) {
					return null;
				}
			} finally {
				jndiManagement.popJndiContext();
				Thread.currentThread().setContextClassLoader(oldCl);
				pool.returnObject(sbbObject);
			}
			// build convergence name
			// AC VARIABLE
			if (selector.isActivityContextSelected()) {
				buff = new StringBuilder(eventContext.getLocalActivityContext().getStringId());
			} else {
				buff = new StringBuilder(NOT_SELECTED_STRING);
			}
			// ADDRESS VARIABLE
			if (selector.isAddressSelected() && selector.getAddress() != null) {
				buff.append(selector.getAddress().toString());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// EVENT TYPE
			if (selector.isEventTypeSelected()) {
				buff.append(eventContext.getEventTypeId());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// EVENT
			if (selector.isEventSelected()) {
				buff.append(eventContext.getEventContextHandle().getId());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// ADDRESS PROFILE
			if (selector.isAddressProfileSelected() && selector.getAddress() != null) {
				final Collection<ProfileID> profileIDs = getAddressProfilesMatching(selector.getAddress(), serviceComponent, sbbComponent, sleeContainer);
				if (profileIDs.isEmpty())
					// no profiles located
					return null;
				else {
					buff.append(profileIDs.iterator().next());
				}
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// CUSTOM NAME
			if (selector.getCustomName() != null) {
				buff.append(selector.getCustomName());
			}

		}
		else {
			// NO IES METHOD DEFINED
			// build convergence name considering the variabes selected in sbb's xml descriptor
			// AC VARIABLE
			final InitialEventSelectorVariables initialEventSelectorVariables = eventEntryDescriptor.getInitialEventSelectVariables();
			if(initialEventSelectorVariables.isActivityContextSelected()) {
				if (initialEventSelectorVariables.isActivityContextOnlySelected()) {
					// special most used case where convergence name is only bound to activity context
					return new StringBuilder(eventContext.getLocalActivityContext().getStringId()).append(ALL_NOT_SELECTED_EXCEPT_AC).toString();
				}
				else {
					buff = new StringBuilder(eventContext.getLocalActivityContext().getStringId());
				}
			}
			else {
				buff = new StringBuilder(NOT_SELECTED_STRING);
			}
			// ADDRESS VARIABLE
			if(initialEventSelectorVariables.isAddressSelected() && eventContext.getAddress() != null) {
				buff.append(eventContext.getAddress().toString());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// EVENT TYPE
			if(initialEventSelectorVariables.isEventTypeSelected()) {
				buff.append(eventContext.getEventTypeId());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// EVENT
			if(initialEventSelectorVariables.isEventSelected()) {
				buff.append(eventContext.getEventContextHandle().getId());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// ADDRESS PROFILE
			if(initialEventSelectorVariables.isAddressProfileSelected() && eventContext.getAddress() != null) {
				final Collection<ProfileID> profileIDs = getAddressProfilesMatching(eventContext.getAddress(), serviceComponent, sbbComponent, sleeContainer);
				if (profileIDs.isEmpty())
					// no profiles located
					return null;
				else {
					buff.append(profileIDs.iterator().next());
				} 
			}
			else {
				buff.append(NOT_SELECTED);
			}
		}
		
		return buff.toString();
	}
private String computeConvergenceName(EventContext eventContext,
			ServiceComponent serviceComponent, SleeContainer sleeContainer) throws Exception {

		final SbbComponent sbbComponent = serviceComponent.getRootSbbComponent();
		final EventEntryDescriptor eventEntryDescriptor = sbbComponent.getDescriptor().getEventEntries().get(eventContext.getEventTypeId());
		StringBuilder buff = null;
		
		/*
		 * An initial-event-selector-method-name element. This element is
		 * optional and is meaningful only if initial-event is true. It
		 * identifies an in itial event selector method. The SLEE invokes this
		 * optional method to d etermine if an event of the specified event type
		 * is an initial event if the SBB is a root SBB of a Service (see
		 * Section 8.5.4). Note that this method is not static. You can either
		 * used a pooled instance of the object or create a new instance of the
		 * object to run the specified method.
		 */		
		if (eventEntryDescriptor.getInitialEventSelectorMethod() != null) {
			// IES METHOD DEFINED
			// invoke method
			InitialEventSelectorImpl selector = new InitialEventSelectorImpl(eventContext,eventEntryDescriptor);
			SbbObjectPool pool = sleeContainer.getSbbManagement().getObjectPool(serviceComponent.getServiceID(),
					sbbComponent.getSbbID());
			SbbObject sbbObject = pool.borrowObject();
			Object[] args = new Object[] { selector };
			ClassLoader oldCl = Thread.currentThread().getContextClassLoader();

			final JndiManagement jndiManagement = sleeContainer.getJndiManagement();
			jndiManagement.pushJndiContext(sbbComponent);

			try {
				Thread.currentThread().setContextClassLoader(
						sbbComponent.getClassLoader());
				final Method m = sbbComponent.getInitialEventSelectorMethods().get(eventEntryDescriptor.getInitialEventSelectorMethod());
				selector = (InitialEventSelectorImpl) m.invoke(sbbObject.getSbbConcrete(),
						args);
				if (selector == null) {
					return null;
				}
				if (!selector.isInitialEvent()) {
					return null;
				}
			} finally {
				jndiManagement.popJndiContext();
				Thread.currentThread().setContextClassLoader(oldCl);
				pool.returnObject(sbbObject);
			}
			// build convergence name
			// AC VARIABLE
			if (selector.isActivityContextSelected()) {
				buff = new StringBuilder(eventContext.getLocalActivityContext().getStringId());
			} else {
				buff = new StringBuilder(NOT_SELECTED_STRING);
			}
			// ADDRESS VARIABLE
			if (selector.isAddressSelected() && selector.getAddress() != null) {
				buff.append(selector.getAddress().toString());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// EVENT TYPE
			if (selector.isEventTypeSelected()) {
				buff.append(eventContext.getEventTypeId());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// EVENT
			if (selector.isEventSelected()) {
				buff.append(eventContext.getEventContextHandle().getId());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// ADDRESS PROFILE
			if (selector.isAddressProfileSelected() && selector.getAddress() != null) {
				final Collection<ProfileID> profileIDs = getAddressProfilesMatching(selector.getAddress(), serviceComponent, sbbComponent, sleeContainer);
				if (profileIDs.isEmpty())
					// no profiles located
					return null;
				else {
					buff.append(profileIDs.iterator().next());
				}
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// CUSTOM NAME
			if (selector.getCustomName() != null) {
				buff.append(selector.getCustomName());
			}

		}
		else {
			// NO IES METHOD DEFINED
			// build convergence name considering the variabes selected in sbb's xml descriptor
			// AC VARIABLE
			final InitialEventSelectorVariables initialEventSelectorVariables = eventEntryDescriptor.getInitialEventSelectVariables();
			if(initialEventSelectorVariables.isActivityContextSelected()) {
				if (initialEventSelectorVariables.isActivityContextOnlySelected()) {
					// special most used case where convergence name is only bound to activity context
					return new StringBuilder(eventContext.getLocalActivityContext().getStringId()).append(ALL_NOT_SELECTED_EXCEPT_AC).toString();
				}
				else {
					buff = new StringBuilder(eventContext.getLocalActivityContext().getStringId());
				}
			}
			else {
				buff = new StringBuilder(NOT_SELECTED_STRING);
			}
			// ADDRESS VARIABLE
			if(initialEventSelectorVariables.isAddressSelected() && eventContext.getAddress() != null) {
				buff.append(eventContext.getAddress().toString());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// EVENT TYPE
			if(initialEventSelectorVariables.isEventTypeSelected()) {
				buff.append(eventContext.getEventTypeId());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// EVENT
			if(initialEventSelectorVariables.isEventSelected()) {
				buff.append(eventContext.getEventContextHandle().getId());
			}
			else {
				buff.append(NOT_SELECTED);
			}
			// ADDRESS PROFILE
			if(initialEventSelectorVariables.isAddressProfileSelected() && eventContext.getAddress() != null) {
				final Collection<ProfileID> profileIDs = getAddressProfilesMatching(eventContext.getAddress(), serviceComponent, sbbComponent, sleeContainer);
				if (profileIDs.isEmpty())
					// no profiles located
					return null;
				else {
					buff.append(profileIDs.iterator().next());
				} 
			}
			else {
				buff.append(NOT_SELECTED);
			}
		}
		
		return buff.toString();
	}
Compute a convergence name for the Sbb for the given Slee event.
Convergence names are used to instantiate the Sbb. I really ought to move
this to SleeContainer.java

@param eventContext -
slee event for the convergence name computation
@return the convergence name or null if this is not an initial event for
this service