void _fireEvent(ActivityHandle realHandle, ActivityHandle refHandle,
			FireableEventType eventType, Object event, Address address,
			ReceivableService receivableService, int eventFlags, final SleeTransaction barrierTx)
			throws ActivityIsEndingException, SLEEException {
		final ActivityContextHandle ach = new ResourceAdaptorActivityContextHandleImpl(
				raEntity, refHandle);
		// get ac
		final ActivityContext ac = acFactory.getActivityContext(ach);
		if (ac == null) {
			throw new UnrecognizedActivityHandleException("Unable to fire "
					+ eventType.getEventType() + " on activity handle "
					+ realHandle
					+ " , the handle is not mapped to an activity context");
		} else {
			// suspend activity if needed
			if (barrierTx != null) {
				final ActivityEventQueueManager aeqm = ac.getLocalActivityContext().getEventQueueManager();
				aeqm.createBarrier(barrierTx);
				TransactionalAction action = new TransactionalAction() {
					public void execute() {
						aeqm.removeBarrier(barrierTx);
					}
				};
				final TransactionContext tc = barrierTx.getTransactionContext();
				tc.getAfterCommitActions().add(action);
				tc.getAfterRollbackActions().add(action);
			}
			final EventProcessingCallbacks callbacks = new EventProcessingCallbacks(
					realHandle, eventType, event, address, receivableService,
					eventFlags, raEntity);
			final EventProcessingSucceedCallback succeedCallback = EventFlags
					.hasRequestProcessingSuccessfulCallback(eventFlags) ? callbacks
					: null;
			final EventProcessingFailedCallback failedCallback = EventFlags
					.hasRequestProcessingFailedCallback(eventFlags) ? callbacks
					: null;
			final EventUnreferencedCallback unreferencedCallback = EventFlags
					.hasRequestEventReferenceReleasedCallback(eventFlags) ? callbacks
					: null;
			ac.fireEvent(eventType.getEventType(), event, address,
					receivableService == null ? null : receivableService
							.getService(), succeedCallback, failedCallback,
					unreferencedCallback);
		}
	}

Event firing logic independent of transaction management.

@param realHandle
@param refHandle
@param eventType
@param event
@param address
@param receivableService
@param eventFlags
@param barrierTx
@throws ActivityIsEndingException
@throws SLEEException

Event firing logic independent of transaction management .


public Class generateSbbLocalObjectConcreteClass() {
        //Generates the implements link
        if (logger.isTraceEnabled()) {
            logger.trace("generateSbbLocalObjectConcreteClass: sbbLocalObjectInterface = "
                            + sbbLocalObjectName
                            + " deployPath = "
                            + deployPath);
        }

        try {

        	concreteSbbLocalObject = pool.makeClass(ConcreteClassGeneratorUtils.SBB_LOCAL_OBJECT_CLASS_NAME_PREFIX + sbbLocalObjectName + ConcreteClassGeneratorUtils.SBB_LOCAL_OBJECT_CLASS_NAME_SUFFIX);

            try {
                sleeSbbLocalObject = pool.get(SbbLocalObjectImpl.class
                        .getName());
                sbbLocalObjectInterface = pool.get(sbbLocalObjectName);
            } catch (NotFoundException nfe) {
                nfe.printStackTrace();
                String s = "Problem with pool ";
                logger.error(s, nfe);
                throw new RuntimeException(s, nfe);
            }
            // This is our implementation interface.
            CtClass concreteClassInterface;
            try {
                concreteClassInterface = pool.get(SbbLocalObjectConcrete.class
                        .getName());
            } catch (NotFoundException nfe) {
                nfe.printStackTrace();
                String s = "Problem with the pool! ";
                logger.error(s, nfe);
                throw new RuntimeException(s, nfe);
            }

            ConcreteClassGeneratorUtils.createInterfaceLinks(
                    concreteSbbLocalObject, new CtClass[] {
                            sbbLocalObjectInterface, concreteClassInterface });
            //Generates an inheritance link to the slee implementation of the
            // SbbLocalObject interface
            ConcreteClassGeneratorUtils.createInheritanceLink(
                    concreteSbbLocalObject, sleeSbbLocalObject);

            //Generates the methods to implement from the interface

            Map interfaceMethods = ClassUtils
                    .getInterfaceMethodsFromInterface(sbbLocalObjectInterface);

            generateConcreteMethods(interfaceMethods, sbbAbstractClassName);

            try {
            	concreteSbbLocalObject.writeFile(deployPath);
            	if (logger.isDebugEnabled()) {
                    logger
                        .debug("Concrete Class "
                                + concreteSbbLocalObject.getName()
                                + " generated in the following path "
                                + deployPath);
                }
            } catch (CannotCompileException e) {

                String s = " Unexpected exception ! ";
                logger.fatal(s, e);
                throw new RuntimeException(s, e);

            } catch (IOException e) {
                String s = "IO Exception!";
                logger.error(s, e);
                return null;

            }
            //load the class
            try {
				return Thread.currentThread().getContextClassLoader().loadClass(concreteSbbLocalObject.getName());
			} catch (ClassNotFoundException e) {
				logger.error("unable to load sbb local object impl class", e);
				return null;
			}

        } finally {
            if (this.concreteSbbLocalObject != null)
                this.concreteSbbLocalObject.defrost();
        }
    }

Generate the Sbb Local Object Class

@param sbbLocalObjectName
the name of the Sbb Local Object
@return the concrete Sbb Local Object class implementing the Sbb Local
Object


protected void makeGetter() {
		if(fieldClass.equals(boolean.class) || fieldClass.equals(Boolean.class)) {
			super.operationName = "is" + this.beanFieldName;
		} else {
			super.operationName = "get" + this.beanFieldName;
		}
	}

protected void makeGetter ( ) { if ( fieldClass . equals ( boolean . class ) || fieldClass . equals ( Boolean . class ) ) { super . operationName = "is" + this . beanFieldName ; } else { super . operationName = "get" + this . beanFieldName ; } }

User should overide it to provide different name, for instance for boolean \"is\" prefix

User should overide it to provide different name for instance for boolean \ is \ prefix


protected Object convert(String optArg) throws SecurityException, NoSuchMethodException, IllegalArgumentException,
			InstantiationException, IllegalAccessException, InvocationTargetException, CommandException {
		if (fieldClass.isPrimitive()) {
			// TODO: to optimize, to rework new to valueOf
			if (fieldClass.equals(int.class)) {
				return new Integer(optArg);
			} else if (fieldClass.equals(long.class)) {
				return new Long(optArg);
			} else if (fieldClass.equals(int.class)) {
				return new Integer(optArg);
			} else if (fieldClass.equals(byte.class)) {
				return new Byte(optArg);
			} else if (fieldClass.equals(short.class)) {
				return new Short(optArg);
			} else if (fieldClass.equals(float.class)) {
				return new Float(optArg);
			} else if (fieldClass.equals(double.class)) {
				return new Double(optArg);
			} else if (fieldClass.equals(boolean.class)) {
				return new Boolean(optArg);
			} else if(fieldClass.equals(char.class)) {
				return new Character(optArg.charAt(0));
			} //?

			throw new CommandException("Unpredicted place. Please report.");
		} else if (isClassNumber()) {
			//Handle Long, Integer, .., Boolean
			Constructor<?> con = fieldClass.getConstructor(String.class);
			return con.newInstance(optArg);
		}

		return optArg;
	}

This method is called to convert optArg from string form, if no conversion is needed it should return passed object.
@param optArg
@return
@throws NoSuchMethodException
@throws SecurityException
@throws InvocationTargetException
@throws IllegalAccessException
@throws InstantiationException
@throws IllegalArgumentException
@throws CommandException

This method is called to convert optArg from string form if no conversion is needed it should return passed object .


public final void setProfileID(String profileTableName, String profileName) throws NullPointerException, IllegalArgumentException {
        if (profileTableName == null) throw new NullPointerException("profileTableName is null");
        if (profileName == null) throw new NullPointerException("profileName is null");

        if (profileTableName.indexOf('/') >= 0) throw new IllegalArgumentException("profileTableName cannot contain the '/' character");

        this.profileTableName = profileTableName;
        this.profileName = profileName;
        this.address = null;
    }

Set the profile table and profile referenced by this profile identifier to new
values.
@param profileTableName the name of the profile table.
@param profileName the name of the profile within the profile table.
@throws NullPointerException if either argument is null.
@throws IllegalArgumentException if profileTableName includes the
'<tt>/</tt>' character.  This character is not permitted in profile table names.

Set the profile table and profile referenced by this profile identifier to new values .


private String extractMessage(String result) {

    // Fix:
    // Firefox 2 encapsulates the text inside <pre> tag
    String startPreTag = "<pre>";
    String endPreTag = "</pre>";

    result = result.trim();

    if (result.startsWith(startPreTag) && result.endsWith(endPreTag)) {
      result = result.substring(startPreTag.length(), result.length() - endPreTag.length());
    }

    return result;
  }

protected DeployableUnitsCard deployableUnitsCard ;


public boolean contains(Object object) {

    	if (!(object instanceof SbbLocalObject))
            return false;

    	final SbbLocalObjectImpl sbblocal = (SbbLocalObjectImpl) object;
        final SbbEntityID sbbEntityId = sbblocal.getSbbEntityId();
        if(!idBelongsToChildRelation(sbbEntityId)) {
        	return false;
        }

        return new SbbEntityCacheData(sbbEntityId,sleeContainer.getCluster().getMobicentsCache()).exists();
    }

public boolean contains ( Object object ) { if ( ! ( object instanceof SbbLocalObject ) ) return false ; final SbbLocalObjectImpl sbblocal = ( SbbLocalObjectImpl ) object ; final SbbEntityID sbbEntityId = sbblocal . getSbbEntityId ( ) ; if ( ! idBelongsToChildRelation ( sbbEntityId ) ) { return false ; } return new SbbEntityCacheData ( sbbEntityId , sleeContainer . getCluster ( ) . getMobicentsCache ( ) ) . exists ( ) ; }

The contains method. This method returns true if the SBB entity
represented by the SBB local object specified by the input argument is a
member of this child relation. If the method argument is not an SBB local
object, is an invalid SBB local object, or is an SBB local object whose
underlying SBB entity is not a member of this child relation, then this
method returns false.

The contains method . This method returns true if the SBB entity represented by the SBB local object specified by the input argument is a member of this child relation . If the method argument is not an SBB local object is an invalid SBB local object or is an SBB local object whose underlying SBB entity is not a member of this child relation then this method returns false .


@SuppressWarnings("rawtypes")
    public boolean containsAll(Collection c) {

    	if (c == null)
            throw new NullPointerException("null collection!");

        for (Iterator it = c.iterator(); it.hasNext(); ) {
            if (!contains(it.next())) {
            	return false;
            }
        }

        if(logger.isDebugEnabled()) {
        	logger.debug("containsAll : collection = " + c + " > all in child relation");
        }
        return true;
    }

@
SuppressWarnings
(
"rawtypes"
)
public
boolean
containsAll
(
Collection
c
)
{
if
(
c
==
)
throw
new
NullPointerException
(
"null collection!"
)
;
for
(
Iterator
it
=
c
.
iterator
(
)
;
it
.
hasNext
(
)
;
)
{
if
(
!
contains
(
it
.
next
(
)
)
)
{
return
false
;
}
}
if
(
logger
.
isDebugEnabled
(
)
)
{
logger
.
debug
(
"containsAll : collection = "
+
c
+
" > all in child relation"
)
;
}
return
true
;
}

This method returns true if all SBB entities represented by the SBB local
objects in the collection specified by the input argument are members of
this child relation. If the collection contains an object that is not an
SBB local object, an SBB local object that is invalid, or an SBB local
object whose underlying SBB entity is not a member of this child
relation, then this method returns false.

This method returns true if all SBB entities represented by the SBB local objects in the collection specified by the input argument are members of this child relation . If the collection contains an object that is not an SBB local object an SBB local object that is invalid or an SBB local object whose underlying SBB entity is not a member of this child relation then this method returns false .


@SuppressWarnings("rawtypes")
    public boolean removeAll(Collection c) {
        boolean flag = true;
        if (c == null)
            throw new NullPointerException(" null collection ! ");
        for ( Iterator it = c.iterator(); it.hasNext();	) {
           flag &= this.remove( it.next());

        }
        return flag;
    }

@
SuppressWarnings
(
"rawtypes"
)
public
boolean
removeAll
(
Collection
c
)
{
boolean
flag
=
true
;
if
(
c
==
)
throw
new
NullPointerException
(
" null collection ! "
)
;
for
(
Iterator
it
=
c
.
iterator
(
)
;
it
.
hasNext
(
)
;
)
{
flag
&=
this
.
remove
(
it
.
next
(
)
)
;
}
return
flag
;
}

Removing an SBB entity from a child relation initiates a cascading
removal of the SBB entity tree rooted by the SBB entity, similar to
invoking the remove method on an SBB local object that represents the SBB
entity.

Removing an SBB entity from a child relation initiates a cascading removal of the SBB entity tree rooted by the SBB entity similar to invoking the remove method on an SBB local object that represents the SBB entity .


public boolean isHigherLevel(Level other) throws NullPointerException {
        if (other == null) throw new NullPointerException("other is null");

        return this.level < other.level;
    }

public
boolean
isHigherLevel
(
Level
other
)
throws
NullPointerException
{
if
(
other
==
)
throw
new
NullPointerException
(
"other is null"
)
;
return
this
.
level
<
other
.
level
;
}

Determine if this Level object represents a level that is higher or more severe
that some other Level object.  For the purposes of the comparison OFF
is considered a higher level than SEVERE.
@param other the Level object to compare this with.
@return true if the level represented by this Level
object is a higher level than the level represented by the specified
Level object, false otherwise.
@throws NullPointerException if other is null.
@deprecated Trace and alarm levels now defined in {@link TraceLevel} and {@link AlarmLevel}.

Determine if this Level object represents a level that is higher or more severe that some other Level object . For the purposes of the comparison OFF is considered a higher level than SEVERE .


private Object readResolve() throws StreamCorruptedException {
        if (level == LEVEL_OFF) return OFF;
        if (level == LEVEL_SEVERE) return SEVERE;
        if (level == LEVEL_WARNING) return WARNING;
        if (level == LEVEL_INFO) return INFO;
        if (level == LEVEL_CONFIG) return CONFIG;
        if (level == LEVEL_FINE) return FINE;
        if (level == LEVEL_FINER) return FINER;
        if (level == LEVEL_FINEST) return FINEST;
        throw new StreamCorruptedException("Invalid internal state found");
    }

private
Object
readResolve
(
)
throws
StreamCorruptedException
{
if
(
level
==
LEVEL_OFF
)
return
OFF
;
if
(
level
==
LEVEL_SEVERE
)
return
SEVERE
;
if
(
level
==
LEVEL_WARNING
)
return
WARNING
;
if
(
level
==
LEVEL_INFO
)
return
INFO
;
if
(
level
==
LEVEL_CONFIG
)
return
CONFIG
;
if
(
level
==
LEVEL_FINE
)
return
FINE
;
if
(
level
==
LEVEL_FINER
)
return
FINER
;
if
(
level
==
LEVEL_FINEST
)
return
FINEST
;
throw
new
StreamCorruptedException
(
"Invalid internal state found"
)
;
}

Resolve deserialisation references so that the singleton property of each
enumerated object is preserved.

Resolve deserialisation references so that the singleton property of each enumerated object is preserved .


public void clean() {
		for (ClassPath classPath : classPaths) {
			classPool.removeClassPath(classPath);
		}
		for (String classMade : classesMade) {
			try {
				classPool.get(classMade).detach();
			} catch (NotFoundException e) {
				if (logger.isDebugEnabled()) {
					logger.debug("Failed to detach class " + classMade
						+ " from class pool", e);
				}
			}
		}
	}

public
void
clean
(
)
{
for
(
ClassPath
classPath
:
classPaths
)
{
classPool
.
removeClassPath
(
classPath
)
;
}
for
(
String
classMade
:
classesMade
)
{
try
{
classPool
.
get
(
classMade
)
.
detach
(
)
;
}
catch
(
NotFoundException
e
)
{
if
(
logger
.
isDebugEnabled
(
)
)
{
logger
.
debug
(
"Failed to detach class "
+
classMade
+
" from class pool"
,
e
)
;
}
}
}
}


@SuppressWarnings("unchecked")
	public static void addProfileCall(ProfileObjectImpl po) throws SLEEException
	{
    SleeTransactionManager sleeTransactionManager = sleeContainer.getTransactionManager();

    try {
      if(sleeTransactionManager.getTransaction() == null) {
        return;
      }
    }
    catch ( SystemException se ) {
      throw new SLEEException("Unable to verify SLEE Transaction.", se);
    }

	  String key = makeKey(po);

		if (logger.isTraceEnabled()) {
			logger.trace("Recording call to profile. Key[" + key + "]");
		}

		final TransactionContext txContext = sleeTransactionManager.getTransactionContext();
		ProfileCallRecorderTransactionData data = (ProfileCallRecorderTransactionData) txContext.getData().get(TRANSACTION_CONTEXT_KEY);

		// If data does not exist, create it
		if (data == null) {
			data = new ProfileCallRecorderTransactionData();
			txContext.getData().put(TRANSACTION_CONTEXT_KEY, data);
		}

		if (!po.isProfileReentrant())
		{
			// we need to check
			if (data.invokedProfiles.contains(key) && data.invokedProfiles.getLast().compareTo(key) != 0) {
				throw new SLEEException("Detected loopback call. Call sequence: " + data.invokedProfiles);
			}
			data.invokedProfiles.add(key);
			data.invokedProfileTablesNames.add(po.getProfileTable().getProfileTableName());
		}

	}

Adds call to this profile.

@param po
@throws SLEEException


public ProfileObjectImpl getProfile(String profileName)
			throws TransactionRequiredLocalException, SLEEException {

		Map txData = getTxData();
		ProfileTransactionID key = new ProfileTransactionID(profileName,
				profileTable.getProfileTableName());
		ProfileObjectImpl value = (ProfileObjectImpl) txData.get(key);
		if (value == null) {
			ProfileObjectPool pool = profileTable.getProfileManagement()
				.getObjectPoolManagement().getObjectPool(
							profileTable.getProfileTableName());
			value = pool.borrowObject();
			passivateProfileObjectOnTxEnd(profileTable.getSleeContainer()
					.getTransactionManager(), value, pool);
			try {
				value.profileActivate(profileName);
			} catch (UnrecognizedProfileNameException e) {
				value.invalidateObject();
				pool.invalidateObject(value);
				return null;
			}
			txData.put(key, value);
		}
		return value;
	}

public ProfileObjectImpl getProfile ( String profileName ) throws TransactionRequiredLocalException , SLEEException { Map txData = getTxData ( ) ; ProfileTransactionID key = new ProfileTransactionID ( profileName , profileTable . getProfileTableName ( ) ) ; ProfileObjectImpl value = ( ProfileObjectImpl ) txData . get ( key ) ; if ( value == null ) { ProfileObjectPool pool = profileTable . getProfileManagement ( ) . getObjectPoolManagement ( ) . getObjectPool ( profileTable . getProfileTableName ( ) ) ; value = pool . borrowObject ( ) ; passivateProfileObjectOnTxEnd ( profileTable . getSleeContainer ( ) . getTransactionManager ( ) , value , pool ) ; try { value . profileActivate ( profileName ) ; } catch ( UnrecognizedProfileNameException e ) { value . invalidateObject ( ) ; pool . invalidateObject ( value ) ; return null ; } txData . put ( key , value ) ; } return value ; }

Retrieves a profile object for the table and specified profile name,
there is only one profile object per profile entity per transaction

@param profileName
@return
@throws TransactionRequiredLocalException
@throws SLEEException

Retrieves a profile object for the table and specified profile name there is only one profile object per profile entity per transaction


public static void passivateProfileObjectOnTxEnd(
			SleeTransactionManager txManager,
			final ProfileObjectImpl profileObject, final ProfileObjectPool pool) {
		TransactionalAction afterRollbackAction = new TransactionalAction() {
			public void execute() {
				profileObject.invalidateObject();
				pool.returnObject(profileObject);
			}
		};
		TransactionalAction beforeCommitAction = new TransactionalAction() {
			public void execute() {
				if (profileObject.getState() == ProfileObjectState.READY) {
					if (!profileObject.getProfileEntity().isRemove()) {
						profileObject.fireAddOrUpdatedEventIfNeeded();
						profileObject.profilePassivate();
					} else {
						profileObject.profileRemove(true, false);
					}
					pool.returnObject(profileObject);
				}
			}
		};
		final TransactionContext txContext = txManager.getTransactionContext();
		txContext.getAfterRollbackActions().add(afterRollbackAction);
		txContext.getBeforeCommitActions().add(beforeCommitAction);
	}

public static void passivateProfileObjectOnTxEnd ( SleeTransactionManager txManager , final ProfileObjectImpl profileObject , final ProfileObjectPool pool ) { TransactionalAction afterRollbackAction = new TransactionalAction ( ) { public void execute ( ) { profileObject . invalidateObject ( ) ; pool . returnObject ( profileObject ) ; } } ; TransactionalAction beforeCommitAction = new TransactionalAction ( ) { public void execute ( ) { if ( profileObject . getState ( ) == ProfileObjectState . READY ) { if ( ! profileObject . getProfileEntity ( ) . isRemove ( ) ) { profileObject . fireAddOrUpdatedEventIfNeeded ( ) ; profileObject . profilePassivate ( ) ; } else { profileObject . profileRemove ( true , false ) ; } pool . returnObject ( profileObject ) ; } } } ; final TransactionContext txContext = txManager . getTransactionContext ( ) ; txContext . getAfterRollbackActions ( ) . add ( afterRollbackAction ) ; txContext . getBeforeCommitActions ( ) . add ( beforeCommitAction ) ; }

Adds transactional actions to the active transaction to passivate a
profile object.

@param txManager
@param profileObject
@param pool

Adds transactional actions to the active transaction to passivate a profile object .


public void setAsText(String text ) {
        if ( text == null || text.equals("")) {
            super.setValue( new ComponentID[0]);
        } else {
            java.util.ArrayList results = new java.util.ArrayList();
            // the format for component ID is name vendor version.
            java.util.StringTokenizer st = new java.util.StringTokenizer(text,CID_SEPARATOR,true);
            ComponentIDPropertyEditor cidPropEditor = new ComponentIDPropertyEditor();
            while (st.hasMoreTokens()) {
                cidPropEditor.setAsText(st.nextToken());
                if (st.hasMoreTokens()) {
                	st.nextToken();
                }
                results.add(cidPropEditor.getValue());
            }
            ComponentID[] cid = new ComponentID[results.size()];
            results.toArray(cid);
            this.setValue(cid);
        }

    }

Set the element as text value, parse it and setValue.
The separator is CID_SEPARATOR

Set the element as text value parse it and setValue . The separator is CID_SEPARATOR


public Class generateActivityContextInterfaceConcreteClass()
			throws DeploymentException {

		String tmpClassName = ConcreteClassGeneratorUtils.CONCRETE_ACTIVITY_INTERFACE_CLASS_NAME_PREFIX
				+ activityContextInterfaceName
				+ ConcreteClassGeneratorUtils.CONCRETE_ACTIVITY_INTERFACE_CLASS_NAME_SUFFIX;

		concreteActivityContextInterface = pool.makeClass(tmpClassName);
		CtClass sbbActivityContextInterface = null;
		try {
			activityContextInterface = pool.get(activityContextInterfaceName);
			sbbActivityContextInterface = pool
					.get(SbbActivityContextInterfaceImpl.class.getName());
		} catch (NotFoundException nfe) {
			throw new DeploymentException("Could not find aci "
					+ activityContextInterfaceName, nfe);
		}

		// Generates the extends link
		ConcreteClassGeneratorUtils.createInheritanceLink(
				concreteActivityContextInterface, sbbActivityContextInterface);

		// Generates the implements link
		ConcreteClassGeneratorUtils.createInterfaceLinks(
				concreteActivityContextInterface,
				new CtClass[] { activityContextInterface });

		// Generates the methods to implement from the interface
		Map interfaceMethods = ClassUtils
				.getInterfaceMethodsFromInterface(activityContextInterface);
		generateConcreteMethods(interfaceMethods);
		// generates the class
		String sbbDeploymentPathStr = deployDir;

		try {
			concreteActivityContextInterface.writeFile(sbbDeploymentPathStr);
			if (logger.isDebugEnabled()) {
				logger.debug("Concrete Class " + tmpClassName
						+ " generated in the following path "
						+ sbbDeploymentPathStr);
			}
		} catch (Exception e) {

			logger.error("problem generating concrete class", e);
			throw new DeploymentException(
					"problem generating concrete class! ", e);
		}

		// load the class
		Class clazz = null;
		try {
			clazz = Thread.currentThread().getContextClassLoader().loadClass(
					tmpClassName);
		} catch (Exception e1) {
			logger.error("problem loading generated class", e1);
			throw new DeploymentException(
					"problem loading the generated class! ", e1);
		}

		this.concreteActivityContextInterface.defrost();

		return clazz;

	}

Generate the Activity Context Interface Class

@param activityContextInterfaceName
the name of the Activity Context Interface
@return the concrete Activity Context Interface class implementing the
Activity Context Interface


private void generateConcreteMethods(Map interfaceMethods) {
		if (interfaceMethods == null)
			return;

		Iterator it = interfaceMethods.values().iterator();
		while (it.hasNext()) {
			CtMethod interfaceMethod = (CtMethod) it.next();
			if (interfaceMethod != null
					//&& isBaseInterfaceMethod(interfaceMethod.getName()))
					&& (interfaceMethod.getDeclaringClass().getName().equals(
							javax.slee.ActivityContextInterface.class.getName()) || interfaceMethod.getDeclaringClass().getName().equals(
									ActivityContextInterfaceExt.class.getName())))
				continue; // @todo: need to check args also

			try {
				// copy method from abstract to concrete class
				CtMethod concreteMethod = CtNewMethod.copy(interfaceMethod,
						concreteActivityContextInterface, null);
				// create the method body
				String fieldName = interfaceMethod.getName().substring(3);
				fieldName = fieldName.substring(0, 1).toLowerCase()
						+ fieldName.substring(1);
				String concreteMethodBody = null;
				if (interfaceMethod.getName().startsWith("get")) {
					concreteMethodBody = "{ return ($r)getFieldValue(\""
							+ fieldName + "\","+concreteMethod.getReturnType().getName()+".class); }";
				} else if (interfaceMethod.getName().startsWith("set")) {
					concreteMethodBody = "{ setFieldValue(\"" + fieldName
							+ "\",$1); }";
				} else {
					throw new SLEEException("unexpected method name <"
							+ interfaceMethod.getName()
							+ "> to implement in sbb aci interface");
				}

				if (logger.isTraceEnabled()) {
		            logger.trace("Generated method "
							+ interfaceMethod.getName() + " , body = "
							+ concreteMethodBody);
				}
				concreteMethod.setBody(concreteMethodBody);
				concreteActivityContextInterface.addMethod(concreteMethod);
			} catch (Exception cce) {
				throw new SLEEException("Cannot compile method "
						+ interfaceMethod.getName(), cce);
			}
		}

	}

Generates the concrete methods of the class It generates a specific
method implementation for the javax.slee.ActivityContextInterface methods
for the methods coming from the ActivityContextInterface developer the
call is routed to the base asbtract class

@param interfaceMethods
the methods to implement coming from the
ActivityContextInterface developer

Generates the concrete methods of the class It generates a specific method implementation for the javax . slee . ActivityContextInterface methods for the methods coming from the ActivityContextInterface developer the call is routed to the base asbtract class


public void setDataAttribute(String key, Object newValue) {
		cacheData.setCmpAttribute(key, newValue);
		if (logger.isDebugEnabled()) {
			logger.debug("Activity context with handle "
					+ getActivityContextHandle() + " set cmp attribute named "
					+ key + " to value " + newValue);
		}
	}

public
void
setDataAttribute
(
String
key
,
Object
newValue
)
{
cacheData
.
setCmpAttribute
(
key
,
newValue
)
;
if
(
logger
.
isDebugEnabled
(
)
)
{
logger
.
debug
(
"Activity context with handle "
+
getActivityContextHandle
(
)
+
" set cmp attribute named "
+
key
+
" to value "
+
newValue
)
;
}
}

Set a shared data item for the ACI

@param key
-- name of the shared data item.
@param newValue
-- value of the shared data item.


public void addNameBinding(String aciName) {
		cacheData.nameBound(aciName);
		if (acReferencesHandler != null) {
			acReferencesHandler.nameReferenceCreated();
		}
	}

public void addNameBinding ( String aciName ) { cacheData . nameBound ( aciName ) ; if ( acReferencesHandler != null ) { acReferencesHandler . nameReferenceCreated ( ) ; } }

add a naming binding to this activity context.

@param aciName
- new name binding to be added.

add a naming binding to this activity context .


private void removeNamingBindings() {
		ActivityContextNamingFacility acf = sleeContainer
				.getActivityContextNamingFacility();
		for (Object obj : cacheData.getNamesBoundCopy()) {
			String aciName = (String) obj;
			try {
				acf.removeName(aciName);
			} catch (Exception e) {
				logger.warn("failed to unbind name: " + aciName + " from ac:"
						+ getActivityContextHandle(), e);
			}
		}
	}

private
void
removeNamingBindings
(
)
{
ActivityContextNamingFacility
acf
=
sleeContainer
.
getActivityContextNamingFacility
(
)
;
for
(
Object
obj
:
cacheData
.
getNamesBoundCopy
(
)
)
{
String
aciName
=
(
String
)
obj
;
try
{
acf
.
removeName
(
aciName
)
;
}
catch
(
Exception
e
)
{
logger
.
warn
(
"failed to unbind name: "
+
aciName
+
" from ac:"
+
getActivityContextHandle
(
)
,
e
)
;
}
}
}

This is called to release all the name bindings after the activity end
event is delivered to the sbb.

This is called to release all the name bindings after the activity end event is delivered to the sbb .


public boolean removeNameBinding(String aciName) {
		boolean removed = cacheData.nameUnbound(aciName);
		if (removed && acReferencesHandler != null) {
			acReferencesHandler.nameReferenceRemoved();
		}
		return removed;
	}

public boolean removeNameBinding ( String aciName ) { boolean removed = cacheData . nameUnbound ( aciName ) ; if ( removed && acReferencesHandler != null ) { acReferencesHandler . nameReferenceRemoved ( ) ; } return removed ; }

Add the given name to the set of activity context names that we are bound
to. The AC Naming facility implicitly ends the activity after all names
are unbound.

@param aciName
-- name to which we are bound.
@return true if name bind was removed; false otherwise

Add the given name to the set of activity context names that we are bound to . The AC Naming facility implicitly ends the activity after all names are unbound .


public boolean attachTimer(TimerID timerID) {
		if (cacheData.attachTimer(timerID)) {
			if (acReferencesHandler != null) {
				acReferencesHandler.timerReferenceCreated();
			}
			return true;
		} else {
			return false;
		}
	}

public boolean attachTimer ( TimerID timerID ) { if ( cacheData . attachTimer ( timerID ) ) { if ( acReferencesHandler != null ) { acReferencesHandler . timerReferenceCreated ( ) ; } return true ; } else { return false ; } }

attach the given timer to the current activity context.

@param timerID
-- timer id to attach.

attach the given timer to the current activity context .


private void removeFromTimers() {
		TimerFacility timerFacility = sleeContainer.getTimerFacility();
		// Iterate through the attached timers, telling the timer facility to
		// remove them
		for (Object obj : cacheData.getAttachedTimers()) {
			timerFacility.cancelTimer((TimerID) obj, false);
		}
	}

End Event has been delivered on the Activity Context.

End Event has been delivered on the Activity Context .


public boolean attachSbbEntity(SbbEntityID sbbEntityId) {

		boolean attached = cacheData.attachSbbEntity(sbbEntityId);
		if (attached) {
			if (acReferencesHandler != null) {
				acReferencesHandler.sbbeReferenceCreated(false);
			}
		}
		if (logger.isTraceEnabled()) {
			logger.trace("Attachement from sbb entity " + sbbEntityId
					+ " to AC " + getActivityContextHandle() + " result: "
					+ attached);
		}
		return attached;
	}

public
boolean
attachSbbEntity
(
SbbEntityID
sbbEntityId
)
{
boolean
attached
=
cacheData
.
attachSbbEntity
(
sbbEntityId
)
;
if
(
attached
)
{
if
(
acReferencesHandler
!=
)
{
acReferencesHandler
.
sbbeReferenceCreated
(
false
)
;
}
}
if
(
logger
.
isTraceEnabled
(
)
)
{
logger
.
trace
(
"Attachement from sbb entity "
+
sbbEntityId
+
" to AC "
+
getActivityContextHandle
(
)
+
" result: "
+
attached
)
;
}
return
attached
;
}

attach an sbb entity to this AC.

@param sbbEntityId
-- sbb entity to attach.
@return true if the SBB Entity is attached successfully, otherwise when
the SBB Entitiy has already been attached before, return false


public void detachSbbEntity(SbbEntityID sbbEntityId)
			throws javax.slee.TransactionRequiredLocalException {

		boolean detached = cacheData.detachSbbEntity(sbbEntityId);

		if (detached && acReferencesHandler != null && !isEnding()) {
			acReferencesHandler.sbbeReferenceRemoved();
			if (logger.isTraceEnabled()) {
				logger.trace("Detached sbb entity " + sbbEntityId
						+ " from AC with handle " + getActivityContextHandle());
			}
		}
	}

public
void
detachSbbEntity
(
SbbEntityID
sbbEntityId
)
throws
javax
.
slee
.
TransactionRequiredLocalException
{
boolean
detached
=
cacheData
.
detachSbbEntity
(
sbbEntityId
)
;
if
(
detached
&&
acReferencesHandler
!=
&&
!
isEnding
(
)
)
{
acReferencesHandler
.
sbbeReferenceRemoved
(
)
;
if
(
logger
.
isTraceEnabled
(
)
)
{
logger
.
trace
(
"Detached sbb entity "
+
sbbEntityId
+
" from AC with handle "
+
getActivityContextHandle
(
)
)
;
}
}
}

Detach the sbb entity

@param sbbEntityId


public Set<SbbEntityID> getSortedSbbAttachmentSet(
			Set<SbbEntityID> excludeSet) {
		final Set<SbbEntityID> sbbAttachementSet = cacheData
				.getSbbEntitiesAttached();
		Set<SbbEntityID> result = new HashSet<SbbEntityID>();
		for (SbbEntityID sbbEntityId : sbbAttachementSet) {
			if (!excludeSet.contains(sbbEntityId)) {
				result.add(sbbEntityId);
			}
		}
		if (result.size() > 1) {
			result = sleeContainer.getSbbEntityFactory().sortByPriority(result);
		}
		return result;
	}

public Set < SbbEntityID > getSortedSbbAttachmentSet ( Set < SbbEntityID > excludeSet ) { final Set < SbbEntityID > sbbAttachementSet = cacheData . getSbbEntitiesAttached ( ) ; Set < SbbEntityID > result = new HashSet < SbbEntityID > ( ) ; for ( SbbEntityID sbbEntityId : sbbAttachementSet ) { if ( ! excludeSet . contains ( sbbEntityId ) ) { result . add ( sbbEntityId ) ; } } if ( result . size ( ) > 1 ) { result = sleeContainer . getSbbEntityFactory ( ) . sortByPriority ( result ) ; } return result ; }

get an ordered copy of the set of SBBs attached to this ac. The ordering
is by SBB priority.

@return list of SbbEIDs

get an ordered copy of the set of SBBs attached to this ac . The ordering is by SBB priority .


public void endActivity() {
		if (logger.isDebugEnabled()) {
			logger.debug("Ending activity context with handle "
					+ getActivityContextHandle());
		}
		if (cacheData.setEnding(true)) {
			fireEvent(
					sleeContainer
							.getEventContextFactory()
							.createActivityEndEventContext(
									this,
									new ActivityEndEventUnreferencedCallback(
											getActivityContextHandle(), factory)),
					sleeContainer.getTransactionManager()
							.getTransactionContext());
		}
	}

public
void
endActivity
(
)
{
if
(
logger
.
isDebugEnabled
(
)
)
{
logger
.
debug
(
"Ending activity context with handle "
+
getActivityContextHandle
(
)
)
;
}
if
(
cacheData
.
setEnding
(
true
)
)
{
fireEvent
(
sleeContainer
.
getEventContextFactory
(
)
.
createActivityEndEventContext
(
this
,
new
ActivityEndEventUnreferencedCallback
(
getActivityContextHandle
(
)
,
factory
)
)
,
sleeContainer
.
getTransactionManager
(
)
.
getTransactionContext
(
)
)
;
}
}


public void addComponent(DeployableComponent dc) {
    if (logger.isTraceEnabled())
      logger.trace("Adding Component " + dc.getComponentKey());

    // Add the component ..
    components.add(dc);

    // .. the key ..
    componentIDs.add(dc.getComponentKey());

    // .. the dependencies ..
    dependencies.addAll(dc.getDependencies());

    // .. the install actions to be taken ..
    installActions.addAll(dc.getInstallActions());

    // .. post-install actions (if any) ..
    Collection<ManagementAction> postInstallActionsStrings = postInstallActions
    .remove(dc.getComponentKey());

    if (postInstallActionsStrings != null
        && !postInstallActionsStrings.isEmpty()) {
      installActions.addAll(postInstallActionsStrings);
    }

    // .. pre-uninstall actions (if any) ..
    Collection<ManagementAction> preUninstallActionsStrings = preUninstallActions
    .remove(dc.getComponentKey());

    if (preUninstallActionsStrings != null)
      uninstallActions.addAll(preUninstallActionsStrings);

    // .. and finally the uninstall actions to the DU.
    uninstallActions.addAll(dc.getUninstallActions());
  }

Adder method for a Deployable Component.
@param dc the deployable component object.

Adder method for a Deployable Component .


public Collection<String> getExternalDependencies() {
    // Take all dependencies...
    Collection<String> externalDependencies = new HashSet<String>(dependencies);

    // Remove those which are contained in this DU
    externalDependencies.removeAll(componentIDs);

    // Return what's left.
    return externalDependencies;
  }

Method for obtaining the external dependencies for this DU, if any.
@return a Collection of external dependencies identifiers.

Method for obtaining the external dependencies for this DU if any .


public boolean hasDependenciesSatisfied(boolean showMissing) {
    // First of all check if it is self-sufficient
    if (isSelfSufficient())
      return true;

    // If not self-sufficient, get the remaining dependencies
    Collection<String> externalDependencies = getExternalDependencies();

    // Remove those that are already installed...
    externalDependencies.removeAll(sleeContainerDeployer.getDeploymentManager().getDeployedComponents());

    // Some remaining?
    if (!externalDependencies.isEmpty()) {
      if (showMissing) {
        // List them to the user...
        String missingDepList = "";

        for (String missingDep : externalDependencies)
          missingDepList += "\r\n +-- " + missingDep;

        logger.info("Missing dependencies for " + this.diShortName
            + ":" + missingDepList);
      }

      // Return dependencies not satified.
      return false;
    }

    // OK, dependencies satisfied!
    return true;
  }

Method for checking if the DU has all the dependencies needed to be deployed.
@param showMissing param to set whether to show or not missing dependencies.
@return true if all the dependencies are satisfied.

Method for checking if the DU has all the dependencies needed to be deployed .


public boolean hasDuplicates() {
    ArrayList<String> duplicates = new ArrayList<String>();

    // For each component in the DU ..
    for (String componentId : componentIDs) {
      // Check if it is already deployed
      if (sleeContainerDeployer.getDeploymentManager().getDeployedComponents().contains(componentId)) {
        duplicates.add(componentId);
      }
    }

    if (!duplicates.isEmpty()) {
      logger.warn("The deployable unit '" + this.diShortName + "' contains components that are already deployed. The following are already installed:");

      for (String dupComponent : duplicates) {
        logger.warn(" - " + dupComponent);
      }

      return true;
    }

    // If we got here, there's no dups.
    return false;
  }

Method for checking if this DU contains any component that is already deployed.
@return true if there's a component that is already deployed.

Method for checking if this DU contains any component that is already deployed .


public Collection<ManagementAction> getInstallActions() {

	  ArrayList<ManagementAction> iActions = new ArrayList<ManagementAction>();

	  // if we have some remaining post install actions it means it is actions related with components already installed
	  // thus should be executed first
	  if (!postInstallActions.values().isEmpty()) {
		  for (String componentId : postInstallActions.keySet()) {
			  iActions.addAll(postInstallActions.get(componentId));
		  }
	  }

	  iActions.addAll(installActions);

	  return iActions;
  }

Getter for the Install Actions.
@return a Collection of actions.


public Collection<ManagementAction> getUninstallActions() {
	  Collection<ManagementAction> uActions = new ArrayList<ManagementAction>(uninstallActions);

	  // ensures uninstall is the last action related with DU components
	  uActions.add(new UninstallDeployableUnitAction(diURL.toString(), sleeContainerDeployer.getDeploymentMBean()));

	  // if we have some remaining uninstall actions it means it is actions related with components not in DU
	  // thus should be executed last
	  if (!preUninstallActions.values().isEmpty()) {
		  for (String componentId : preUninstallActions.keySet()) {
			  uActions.addAll(preUninstallActions.get(componentId));
		  }
	  }

	  return uActions;
  }

Getter for the Uninstall Actions.
@return a Collection of actions.


private boolean hasReferringDU() throws Exception {

    // Get SleeContainer instance from JNDI
    SleeContainer sC = SleeContainer.lookupFromJndi();

    for (String componentIdString : this.getComponents()) {
      ComponentIDPropertyEditor cidpe = new ComponentIDPropertyEditor();
      cidpe.setAsText( componentIdString );

      ComponentID componentId = (ComponentID) cidpe.getValue();

      for (ComponentID referringComponentId : sC.getComponentRepository().getReferringComponents(componentId)) {
        ComponentIDPropertyEditor rcidpe = new ComponentIDPropertyEditor();
        rcidpe.setValue( referringComponentId );

        String referringComponentIdString = rcidpe.getAsText();

        if (!this.getComponents().contains( referringComponentIdString )) {
          return true;
        }
      }
    }

    return false;
  }

Method for checking if this DU components are referred by any others.
@return true if there are other DUs installed referring this.
@throws Exception

Method for checking if this DU components are referred by any others .


public static void close(String profileTableName, String profileName) {
        final ObjectName objectName = getObjectName(profileTableName, profileName);
        if (sleeContainer.getMBeanServer().isRegistered(objectName)) {
            Runnable r = new Runnable() {
                public void run() {
                    try {
                        sleeContainer.getMBeanServer().invoke(objectName, "close", new Object[]{}, new String[]{});
                    } catch (Throwable e) {
                        logger.error(e.getMessage(), e);
                    }
                }
            };
            Thread t = new Thread(r);
            t.start();
        }
    }

public static void close ( String profileTableName , String profileName ) { final ObjectName objectName = getObjectName ( profileTableName , profileName ) ; if ( sleeContainer . getMBeanServer ( ) . isRegistered ( objectName ) ) { Runnable r = new Runnable ( ) { public void run ( ) { try { sleeContainer . getMBeanServer ( ) . invoke ( objectName , "close" , new Object [ ] { } , new String [ ] { } ) ; } catch ( Throwable e ) { logger . error ( e . getMessage ( ) , e ) ; } } } ; Thread t = new Thread ( r ) ; t . start ( ) ; } }

Closes and unregisters the mbean for the specified profile, if exists

@param profileTableName
@param profileName

Closes and unregisters the mbean for the specified profile if exists


public static ObjectName getObjectName(
            String profileTableName, String profileName) {
        // FIXME use only the "quoted" version when issue is fully solved at the JMX Console side
        try {
            return new ObjectName(ProfileMBean.BASE_OBJECT_NAME + ','
                    + ProfileMBean.PROFILE_TABLE_NAME_KEY + '='
                    + profileTableName + ','
                    + ProfileMBean.PROFILE_NAME_KEY + '='
                    + (profileName != null ? profileName : ""));
        } catch (Throwable e) {
            try {
                return new ObjectName(ProfileMBean.BASE_OBJECT_NAME + ','
                        + ProfileMBean.PROFILE_TABLE_NAME_KEY + '='
                        + ObjectName.quote(profileTableName) + ','
                        + ProfileMBean.PROFILE_NAME_KEY + '='
                        + ObjectName.quote(profileName != null ? profileName : ""));
            } catch (Throwable f) {
                throw new SLEEException(e.getMessage(), e);
            }
        }
    }

Retrieves the JMX ObjectName for a profile, given its profile name and
profile table name

@param profileTableName
@param profileName
@return
@throws MalformedObjectNameException

Retrieves the JMX ObjectName for a profile given its profile name and profile table name


private void writeMode() throws SLEEException, ManagementException {
        if (!isProfileWriteable()) {
            if (logger.isDebugEnabled()) {
                logger.debug("Changing state to read-write, for profile mbean with name " + profileName + ", from table with name " + this.profileTable.getProfileTableName());
            }
            // get object & make it writable
            ProfileObjectImpl profileObject = profileTable.getProfile(profileName);
            profileObject.getProfileEntity().setReadOnly(false);
            // change state
            state = State.write;
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("Already in write state, for profile mbean with name " + profileName + ", from table with name " + this.profileTable.getProfileTableName());
            }
        }
    }

Moves to the write mode, using specified object. The current java transaction will be suspended.

@throws ManagementException

Moves to the write mode using specified object . The current java transaction will be suspended .


protected void beforeSetCmpField() throws ManagementException, InvalidStateException {

        if (logger.isDebugEnabled()) {
            logger.debug("beforeSetCmpField() on profile with name " + profileName + " of table " + profileTable.getProfileTableName());
        }

        if (isProfileWriteable()) {
            try {
                sleeContainer.getTransactionManager().resume(transaction);
            } catch (Throwable e) {
                throw new ManagementException(e.getMessage(), e);
            }
        } else {
            throw new InvalidStateException();
        }
    }

Logic to execute before invoking a cmp setter method on the mbean

@return true if the method resumed a transaction
@throws ManagementException


protected void afterSetCmpField() throws ManagementException {

        if (logger.isDebugEnabled()) {
            logger.debug("afterSetCmpField() on profile with name " + profileName + " of table " + profileTable.getProfileTableName());
        }

        try {
            sleeContainer.getTransactionManager().suspend();
        } catch (Throwable e) {
            throw new ManagementException(e.getMessage(), e);
        }
    }

Logic to execute after invoking a cmp setter method on the mbean

@throws ManagementException


protected boolean beforeGetCmpField() throws ManagementException {

        if (logger.isDebugEnabled()) {
            logger.debug("beforeGetCmpField() on profile with name " + profileName + " of table " + profileTable.getProfileTableName());
        }

        return beforeNonSetCmpField();
    }

Logic to execute before invoking a cmp getter method on the mbean

@return true if the method initiated or resumed a transaction
@throws ManagementException


protected void afterGetCmpField(boolean activatedTransaction) throws ManagementException {

        if (logger.isDebugEnabled()) {
            logger.debug("afterGetCmpField( activatedTransaction = " + activatedTransaction + " ) on profile with name " + profileName + " of table " + profileTable.getProfileTableName());
        }

        afterNonSetCmpField(activatedTransaction);
    }

Logic to execute after invoking a cmp getter method on the mbean

@param activatedTransaction if the method beforeGetCmpField() initiated or resumed a transaction
@throws ManagementException


protected boolean beforeManagementMethodInvocation() throws ManagementException {

        if (logger.isDebugEnabled()) {
            logger.debug("beforeManagementMethodInvocation() on profile with name " + profileName + " of table " + profileTable.getProfileTableName());
        }

        jndiManagement = sleeContainer.getJndiManagement();
        jndiManagement.pushJndiContext(profileTable.getProfileSpecificationComponent());

        return beforeNonSetCmpField();
    }

Logic to execute before invoking a management method on the mbean

@return true if the method initiated or resumed a transaction
@throws ManagementException


protected void afterManagementMethodInvocation(boolean activatedTransaction) throws ManagementException {
        if (logger.isDebugEnabled()) {
            logger.debug("afterManagementMethodInvocation( activatedTransaction = " + activatedTransaction + " ) on profile with name " + profileName + " of table " + profileTable.getProfileTableName());
        }

        afterNonSetCmpField(activatedTransaction);

        jndiManagement.popJndiContext();
    }

Logic to execute after invoking a management method on the mbean

@param activatedTransaction if the method beforeManagementMethodInvocation() initiated or resumed a transaction
@throws ManagementException


private void deletePath(File path) {
		if (path.isDirectory()) {
			File[] files = path.listFiles();
			if (files != null) {
				for (File file : files) {
					deletePath(file);
				}
			}
		}
		path.delete();
	}

private void deletePath ( File path ) { if ( path . isDirectory ( ) ) { File [ ] files = path . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { deletePath ( file ) ; } } } path . delete ( ) ; }

deletes the whole path, going through directories

@param path

deletes the whole path going through directories


protected void createDefaultConstructor() throws DeploymentException {

		CtConstructor defaultConstructor = new CtConstructor(null,
				sbbConcreteClass);
		// We need a "do nothing" constructor because the
		// convergence name creation method may need to actually
		// create the object instance to run the method that
		// creates the convergence name.

		String constructorBody = "{ }";

		try {
			defaultConstructor.setBody(constructorBody);
			sbbConcreteClass.addConstructor(defaultConstructor);
			logger.trace("DefaultConstructor created");
		} catch (CannotCompileException e) {
			throw new DeploymentException(e.getMessage(), e);
		}
	}

Create a default constructor on the Sbb Concrete Class

@throws DeploymentException


private void createDefaultUsageParameterGetter(CtClass sbbConcrete)
			throws DeploymentException {
		String methodName = "getDefaultSbbUsageParameterSet";
		CtMethod method = (CtMethod) abstractMethods.get(methodName);
		if (method == null) {
			method = (CtMethod) superClassesAbstractMethods.get(methodName);
		}
		if (method != null) {
			try {
				// copy method from abstract to concrete class
				CtMethod concreteMethod = CtNewMethod.copy(method,
						sbbConcreteClass, null);
				// create the method body
				String concreteMethodBody = "{ return ($r)"
						+ SbbAbstractMethodHandler.class.getName()
						+ ".getDefaultSbbUsageParameterSet(sbbEntity); }";
				if (logger.isTraceEnabled()) {
		            logger.trace("Generated method " + methodName
							+ " , body = " + concreteMethodBody);
				}
				concreteMethod.setBody(concreteMethodBody);
				sbbConcreteClass.addMethod(concreteMethod);
			} catch (CannotCompileException cce) {
				throw new SLEEException("Cannot compile method "
						+ method.getName(), cce);
			}
		}
	}

Create a default usage parameter getter and setter.

@param sbbConcrete
@throws DeploymentException

Create a default usage parameter getter and setter .


private void createSbbEntityGetterAndSetter(CtClass sbbConcrete)
			throws DeploymentException {
		try {
			CtMethod getSbbEntity = CtNewMethod
					.make("public " + SbbEntity.class.getName()
							+ " getSbbEntity() { return this.sbbEntity; }",
							sbbConcrete);
			getSbbEntity.setModifiers(Modifier.PUBLIC);
			sbbConcrete.addMethod(getSbbEntity);
			CtMethod setSbbEntity = CtNewMethod.make(
					"public void setSbbEntity ( " + SbbEntity.class.getName()
							+ " sbbEntity )" + "{"
							+ "this.sbbEntity = sbbEntity;" + "}", sbbConcrete);

			setSbbEntity.setModifiers(Modifier.PUBLIC);
			sbbConcrete.addMethod(setSbbEntity);
		} catch (Exception e) {
			throw new DeploymentException(e.getMessage(), e);
		}
	}

Create a method to retrive the entity from the SbbObject.

@param sbbConcrete
@throws DeploymentException

Create a method to retrive the entity from the SbbObject .


protected void createFireEventMethods(Collection<EventEntryDescriptor> mEventEntries) {
		if (mEventEntries == null)
			return;
		for (EventEntryDescriptor mEventEntry : mEventEntries) {
			if (mEventEntry.isFired()) {
				String methodName = "fire" + mEventEntry.getEventName();
				CtMethod method = (CtMethod) abstractMethods.get(methodName);
				if (method == null) {
					method = (CtMethod) superClassesAbstractMethods
							.get(methodName);
				}
				if (method != null) {
					try {
						// copy method from abstract to concrete class
						CtMethod concreteMethod = CtNewMethod.copy(method,
								sbbConcreteClass, null);
						// create the method body
						String concreteMethodBody = "{";
						concreteMethodBody += getEventTypeIDInstantionString(mEventEntry);
						concreteMethodBody += SbbAbstractMethodHandler.class
								.getName()
								+ ".fireEvent(sbbEntity,eventTypeID";
						for (int i = 0; i < method.getParameterTypes().length; i++) {
							concreteMethodBody += ",$" + (i + 1);
						}
						concreteMethodBody += ");}";
						if (logger.isTraceEnabled()) {
				            logger.trace("Generated method " + methodName
									+ " , body = " + concreteMethodBody);
						}
						concreteMethod.setBody(concreteMethodBody);
						sbbConcreteClass.addMethod(concreteMethod);
					} catch (Exception e) {
						throw new SLEEException("Cannot compile method "
								+ method.getName(), e);
					}
				}
			}
		}
	}

Create the implementation of the fire event methods

@param mEventEntries
the set of fire event


protected void createGetSbbActivityContextInterfaceMethod(
			CtClass activityContextInterface,
			Class<?> concreteActivityContextInterfaceClass)
			throws DeploymentException {
		String methodToAdd = "public "
				+ activityContextInterface.getName()
				+ " asSbbActivityContextInterface(javax.slee.ActivityContextInterface aci) {"
				+ "if(aci==null)"
				+ "     throw new "
				+ IllegalStateException.class.getName()
				+ "(\"Passed argument can not be of null value.\");"
				+ " if(sbbEntity == null || sbbEntity.getSbbObject().getState() != "
				+ SbbObjectState.class.getName() + ".READY) { throw new "
				+ IllegalStateException.class.getName()
				+ "(\"Cannot call asSbbActivityContextInterface\"); } "
				+ "else if ( aci instanceof "
				+ concreteActivityContextInterfaceClass.getName()
				+ ") return aci;" + "else return  new "
				+ concreteActivityContextInterfaceClass.getName() + " ( (" + ActivityContextInterface.class.getName() + ") $1, "
				+ "sbbEntity.getSbbComponent());" + "}";
		CtMethod methodTest;
		try {
			methodTest = CtNewMethod.make(methodToAdd, sbbConcreteClass);
			sbbConcreteClass.addMethod(methodTest);
			if (logger.isTraceEnabled()) {
				logger.trace("Method " + methodToAdd + " added");
			}
		} catch (CannotCompileException e) {
			throw new DeploymentException(e.getMessage(), e);
		}
	}

Create the narrow method to get the activity context interface

@param activityContextInterface
the activity context interface return type of the narrow
method
@param concreteActivityContextInterfaceClass
@throws DeploymentException


protected final void add(QueryExpression expr) throws NullPointerException, IllegalArgumentException {
        if (expr == null) throw new NullPointerException("expr is null");

        // check for cycles
        if (expr instanceof CompositeQueryExpression) {
            ((CompositeQueryExpression)expr).checkForCycles(this);
        }
        else if (expr instanceof Not) {
            ((Not)expr).checkForCycles(this);
        }

        // no cycles, so add the expression to the list
        exprs.add(expr);
    }

Add a query expression to this composite expression.
@param expr the expression to add.
@throws NullPointerException if expr is null.
@throws IllegalArgumentException if adding the query expression to this
composite expression would generate a cyclic expression.

Add a query expression to this composite expression .


public static synchronized void bind(String key, Object target) throws NameAlreadyBoundException
    {
        if( wrapperMap.containsKey(key) == true )
            throw new NameAlreadyBoundException(key+" already exists in the NonSerializableFactory map");
        wrapperMap.put(key, target);
    }

Place an object into the NonSerializableFactory namespace for subsequent
access by getObject. There cannot be an already existing binding for key.

@param key the name to bind target under. This should typically be the
name that will be used to bind target in the JNDI namespace, but it does
not have to be.
@param target the non-Serializable object to bind.
@throws javax.naming.NameAlreadyBoundException thrown if key already exists in the
NonSerializableFactory map

Place an object into the NonSerializableFactory namespace for subsequent access by getObject . There cannot be an already existing binding for key .


public static synchronized void rebind(Name name, Object target) throws NamingException
   {
      rebind(name, target, false);
   }

public static synchronized void rebind ( Name name , Object target ) throws NamingException { rebind ( name , target , false ) ; }

A convience method that simplifies the process of rebinding a
non-zerializable object into a JNDI context. This version binds the
target object into the default IntitialContext using name path.

@param name the name to use as JNDI path name. The key into the
NonSerializableFactory map is obtained from the toString() value of name.
The name parameter cannot be a 0 length name.
Any subcontexts between the root and the name must exist.
@param target the non-Serializable object to bind.
@throws javax.naming.NamingException thrown on failure to rebind key into ctx.

A convience method that simplifies the process of rebinding a non - zerializable object into a JNDI context . This version binds the target object into the default IntitialContext using name path .


public boolean decorateAbstractSbb() throws DeploymentException {

    	ClassPool pool = component.getClassPool();
    	String sbbAbstractClassName = component.getDescriptor().getSbbAbstractClass().getSbbAbstractClassName();
        try {
            sbbAbstractClass = pool.get(sbbAbstractClassName);
        } catch (NotFoundException nfe) {
            throw new DeploymentException("Could not find Abstract Sbb Class: "
                    + sbbAbstractClassName, nfe);
        }

        // populate the list of concrete methods. It will be needed by the
        // decorating methods.
        concreteMethods = new HashMap();
    	CtMethod[] methods = sbbAbstractClass.getDeclaredMethods();
    	for (int i = 0; i < methods.length; i++) {
    	    int mods = methods[i].getModifiers();
    		if (!Modifier.isAbstract(mods) && !Modifier.isNative(mods)) {
    			concreteMethods.put(methods[i].getName() + methods[i].getSignature(), methods[i]);
    		}
    	}

        decorateENCBindCalls();
        decorateNewThreadCalls();

        if (isAbstractSbbClassDecorated) {
        	try {
        		String deployDir = component.getDeploymentDir().getAbsolutePath();
        		sbbAbstractClass.writeFile(deployDir);
        		sbbAbstractClass.detach();
        		// the file on disk is now in sync with the latest in-memory version
        		if (logger.isDebugEnabled()) {
        			logger.debug("Modified Abstract Class "
        					+ sbbAbstractClass.getName()
        					+ " generated in the following path "
        					+ deployDir);
        		}
        		//} catch (NotFoundException e) {
        		//    String s = "Error writing modified abstract sbb class";
        		//    logger.error(s,e);
        		//    throw new DeploymentException (s,e);
        	} catch (Throwable e) {
        		throw new SLEEException ( e.getMessage(), e);
        	} finally {
        		sbbAbstractClass.defrost();
        	}
        	return true;
        }
        else {
        	return false;
        }
    }

//    throw new DeploymentException (s,e);

Decorate the abstract sbb Class

@return the decorated sbb abstract class


public void invokeAndReturnvoid(SbbConcrete proxy, String methodName,
			Object[] args, Class<?>[] argTypes) throws Exception {
		invokeAndReturnObject(proxy, methodName, args, argTypes);
	}

public void invokeAndReturnvoid ( SbbConcrete proxy , String methodName , Object [ ] args , Class < ? > [ ] argTypes ) throws Exception { invokeAndReturnObject ( proxy , methodName , args , argTypes ) ; }


private String getRealFieldName(String fieldName) {
		String realFieldName = sbbComponent.getDescriptor()
				.getActivityContextAttributeAliases().get(fieldName);
		if (realFieldName == null) {
			// not there then it has no alias, lets set one based on sbb id
			realFieldName = sbbComponent.getSbbID().toString() + "."
					+ fieldName;
			final Map<String, String> aliases = sbbComponent.getDescriptor()
					.getActivityContextAttributeAliases();
			synchronized (aliases) {
				aliases.put(fieldName, realFieldName);
			}
		}
		return realFieldName;
	}

Computes the real aci data field name

@param fieldName
@return


public void setFieldValue(String fieldName, Object value) {
		String realFieldName = getRealFieldName(fieldName);
		aciImpl.getActivityContext().setDataAttribute(realFieldName, value);
	}

public void setFieldValue ( String fieldName , Object value ) { String realFieldName = getRealFieldName ( fieldName ) ; aciImpl . getActivityContext ( ) . setDataAttribute ( realFieldName , value ) ; }

Sets an sbb aci data field value

@param fieldName
@param value


public Object getFieldValue(String fieldName, Class<?> returnType) {

		String realFieldName = getRealFieldName(fieldName);

		Object value = aciImpl.getActivityContext().getDataAttribute(
				realFieldName);

		if (value == null) {
			if (returnType.isPrimitive()) {
				if (returnType.equals(Integer.TYPE)) {
					return Integer.valueOf(0);
				} else if (returnType.equals(Boolean.TYPE)) {
					return Boolean.FALSE;
				} else if (returnType.equals(Long.TYPE)) {
					return Long.valueOf(0);
				} else if (returnType.equals(Double.TYPE)) {
					return Double.valueOf(0);
				} else if (returnType.equals(Float.TYPE)) {
					return Float.valueOf(0);
				}
			}
		}

		return value;
	}

public Object getFieldValue ( String fieldName , Class < ? > returnType ) { String realFieldName = getRealFieldName ( fieldName ) ; Object value = aciImpl . getActivityContext ( ) . getDataAttribute ( realFieldName ) ; if ( value == null ) { if ( returnType . isPrimitive ( ) ) { if ( returnType . equals ( Integer . TYPE ) ) { return Integer . valueOf ( 0 ) ; } else if ( returnType . equals ( Boolean . TYPE ) ) { return Boolean . FALSE ; } else if ( returnType . equals ( Long . TYPE ) ) { return Long . valueOf ( 0 ) ; } else if ( returnType . equals ( Double . TYPE ) ) { return Double . valueOf ( 0 ) ; } else if ( returnType . equals ( Float . TYPE ) ) { return Float . valueOf ( 0 ) ; } } } return value ; }

Retrieves an sbb aci data field value

@param fieldName
@param returnType
@return


public void setProfileContext(ProfileContextImpl profileContext) {

		if(logger.isTraceEnabled()) {
			logger.trace("[setProfileContext] "+this);
		}

		if (profileContext == null) {
			throw new NullPointerException("Passed context must not be null.");
		}

		if (state != ProfileObjectState.DOES_NOT_EXIST) {
			throw new IllegalStateException("Wrong state: " + this.state + ",on profile set context operation, for profile table: "
					+ this.profileTable.getProfileTableName() + " with specification: " + this.profileTable.getProfileSpecificationComponent().getProfileSpecificationID());
		}

		this.profileContext = profileContext;
		this.profileContext.setProfileObject(this);

		if (profileConcreteClassInfo.isInvokeSetProfileContext()) {
			final ClassLoader oldClassLoader = SleeContainerUtils.getCurrentThreadClassLoader();

			try {
				final ClassLoader cl = this.profileTable.getProfileSpecificationComponent().getClassLoader();

				if (System.getSecurityManager()!=null) {
					AccessController.doPrivileged(new PrivilegedAction<Object>() {
						public Object run() {
							Thread.currentThread().setContextClassLoader(cl);
							return null;
						}
					});
				}
				else {
					Thread.currentThread().setContextClassLoader(cl);
				}

				try {
					if (isSlee11) {
						try {
							profileConcrete.setProfileContext(profileContext);
						}
						catch (RuntimeException e) {
							runtimeExceptionOnProfileInvocation(e);
						}
					}
				}
				catch (Exception e) {
					if (logger.isDebugEnabled())
						logger.debug("Exception encountered while setting profile context for profile table: "
								+ this.profileTable.getProfileTableName() + " with specification: " + this.profileTable.getProfileSpecificationComponent().getProfileSpecificationID(), e);
				}
			}
			finally {
				if (System.getSecurityManager()!=null) {
					AccessController.doPrivileged(new PrivilegedAction<Object>() {
						public Object run() {
							Thread.currentThread().setContextClassLoader(oldClassLoader);
							return null;
						}
					});
				}
				else {
					Thread.currentThread().setContextClassLoader(oldClassLoader);
				}
			}
		}

		state = ProfileObjectState.POOLED;

	}

Invoked from pool.

@param profileContext


private void profileInitialize(String profileName) {

		if(logger.isTraceEnabled()) {
			logger.trace("[profileInitialize] "+this+" , profileName = "+profileName);
		}

		if (this.state != ProfileObjectState.POOLED) {
			throw new SLEEException(this.toString());
		}

		if (profileName == null) {
			// default profile creation
			// create instance of entity
			profileEntity = profileEntityFramework.getProfileEntityFactory().newInstance(profileTable.getProfileTableName(), null);
			// change state
			this.state = ProfileObjectState.PROFILE_INITIALIZATION;
			// invoke life cycle method on profile
			if (profileConcreteClassInfo.isInvokeProfileInitialize()) {
				try {
					profileConcrete.profileInitialize();
				}
				catch (RuntimeException e) {
					runtimeExceptionOnProfileInvocation(e);
				}
			}
		}
		else {
			// load the default profile entity
			if (logger.isTraceEnabled()) {
				logger.trace("Copying state from default profile on object "+this);
			}
			profileEntity = cloneEntity(profileTable.getDefaultProfileEntity());
			profileEntity.setProfileName(profileName);
		}

		// mark entity as dirty and for creation
		profileEntity.create();
		profileEntity.setDirty(true);
	}


public void unsetProfileContext() {

		if(logger.isTraceEnabled()) {
			logger.trace("[unsetProfileContext] "+this);
		}

		if (state == ProfileObjectState.POOLED  && profileConcreteClassInfo.isInvokeUnsetProfileContext()) {

			final ClassLoader oldClassLoader = SleeContainerUtils.getCurrentThreadClassLoader();
			try	{
				final ClassLoader cl = profileTable.getProfileSpecificationComponent().getClassLoader();
				if (System.getSecurityManager()!=null) {
					AccessController.doPrivileged(new PrivilegedAction<Object>() {
						public Object run()	{
							Thread.currentThread().setContextClassLoader(cl);
							return null;
						}
					});
				}
				else {
					Thread.currentThread().setContextClassLoader(cl);
				}

				if (isSlee11) {
					try {
						profileConcrete.unsetProfileContext();
					}
					catch (RuntimeException e) {
						runtimeExceptionOnProfileInvocation(e);
					}
				}
				profileContext.setProfileObject(null);
				state = ProfileObjectState.DOES_NOT_EXIST;
			}
			finally {
				if (System.getSecurityManager()!=null) {
					AccessController.doPrivileged(new PrivilegedAction<Object>() {
						public Object run() {
							Thread.currentThread().setContextClassLoader(oldClassLoader);
							return null;
						}
					});
				}
				else {
					Thread.currentThread().setContextClassLoader(oldClassLoader);
				}
			}
		}
	}

public
void
unsetProfileContext
(
)
{
if
(
logger
.
isTraceEnabled
(
)
)
{
logger
.
trace
(
"[unsetProfileContext] "
+
this
)
;
}
if
(
state
==
ProfileObjectState
.
POOLED
&&
profileConcreteClassInfo
.
isInvokeUnsetProfileContext
(
)
)
{
final
ClassLoader
oldClassLoader
=
SleeContainerUtils
.
getCurrentThreadClassLoader
(
)
;
try
{
final
ClassLoader
cl
=
profileTable
.
getProfileSpecificationComponent
(
)
.
getClassLoader
(
)
;
if
(
System
.
getSecurityManager
(
)
!=
)
{
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Object
>
(
)
{
public
Object
run
(
)
{
Thread
.
currentThread
(
)
.
setContextClassLoader
(
cl
)
;
return
;
}
}
)
;
}
else
{
Thread
.
currentThread
(
)
.
setContextClassLoader
(
cl
)
;
}
if
(
isSlee11
)
{
try
{
profileConcrete
.
unsetProfileContext
(
)
;
}
catch
(
RuntimeException
e
)
{
runtimeExceptionOnProfileInvocation
(
e
)
;
}
}
profileContext
.
setProfileObject
(
)
;
state
=
ProfileObjectState
.
DOES_NOT_EXIST
;
}
finally
{
if
(
System
.
getSecurityManager
(
)
!=
)
{
AccessController
.
doPrivileged
(
new
PrivilegedAction
<
Object
>
(
)
{
public
Object
run
(
)
{
Thread
.
currentThread
(
)
.
setContextClassLoader
(
oldClassLoader
)
;
return
;
}
}
)
;
}
else
{
Thread
.
currentThread
(
)
.
setContextClassLoader
(
oldClassLoader
)
;
}
}
}
}


public ProfileLocalObject getProfileLocalObject() {
		final Class<?> profileLocalObjectConcreteClass = profileTable.getProfileSpecificationComponent().getProfileLocalObjectConcreteClass();
		ProfileLocalObject profileLocalObject = null;
		if (profileLocalObjectConcreteClass == null) {
			profileLocalObject = new ProfileLocalObjectImpl(this);
		}
		else {
			try {
				profileLocalObject = (ProfileLocalObject) profileLocalObjectConcreteClass.getConstructor(ProfileObjectImpl.class).newInstance(this);
			} catch (Throwable e) {
				throw new SLEEException(e.getMessage(),e);
			}
		}

		return profileLocalObject;
	}

public ProfileLocalObject getProfileLocalObject ( ) { final Class < ? > profileLocalObjectConcreteClass = profileTable . getProfileSpecificationComponent ( ) . getProfileLocalObjectConcreteClass ( ) ; ProfileLocalObject profileLocalObject = null ; if ( profileLocalObjectConcreteClass == null ) { profileLocalObject = new ProfileLocalObjectImpl ( this ) ; } else { try { profileLocalObject = ( ProfileLocalObject ) profileLocalObjectConcreteClass . getConstructor ( ProfileObjectImpl . class ) . newInstance ( this ) ; } catch ( Throwable e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; } } return profileLocalObject ; }

Retrieves the local representation for this profile object
@return


public void fireAddOrUpdatedEventIfNeeded() {

		if (state == ProfileObjectState.READY) {
			if (profileEntity.isDirty()) {
				// check the table fires events and the object is not assigned to a default profile
				if (profileTable.doesFireEvents() && profileEntity.getProfileName() != null && profileTable.getSleeContainer().getSleeState() == SleeState.RUNNING) {
					// Fire a Profile Added or Updated Event
					ActivityContext ac = profileTable.getActivityContext();
					AbstractProfileEvent event = null;
					if (profileEntity.isCreate()) {
						if (persisted) {
							event = new ProfileAddedEventImpl(profileEntity,profileTable.getProfileManagement());
							persisted = false;
							if (logger.isTraceEnabled()) {
								logger.trace("firing profile added event for profile named "+profileEntity);
							}
						}
						else {
							return;
						}
					}
					else {
						event = new ProfileUpdatedEventImpl(profileEntitySnapshot,profileEntity,profileTable.getProfileManagement());
						if (logger.isTraceEnabled()) {
							logger.trace("firing profile updated event for profile named "+profileEntity);
						}
					}
					ac.fireEvent(event.getEventTypeID(), event,
							event.getProfileAddress(), null, null,null,null);
				}
			}
		}

	}

Fires a profile added or updated event if the profile object state is ready and the persistent state is dirty


public AbstractProfileCmpSlee10Wrapper getProfileCmpSlee10Wrapper() {
		if (profileCmpSlee10Wrapper == null) {
			try {
				profileCmpSlee10Wrapper = (AbstractProfileCmpSlee10Wrapper) profileTable.getProfileSpecificationComponent().getProfileCmpSlee10WrapperClass().getConstructor(ProfileObjectImpl.class).newInstance(this);
			} catch (Throwable e) {
				throw new SLEEException(e.getMessage(),e);
			}
		}
		return profileCmpSlee10Wrapper;
	}

public AbstractProfileCmpSlee10Wrapper getProfileCmpSlee10Wrapper ( ) { if ( profileCmpSlee10Wrapper == null ) { try { profileCmpSlee10Wrapper = ( AbstractProfileCmpSlee10Wrapper ) profileTable . getProfileSpecificationComponent ( ) . getProfileCmpSlee10WrapperClass ( ) . getConstructor ( ProfileObjectImpl . class ) . newInstance ( this ) ; } catch ( Throwable e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; } } return profileCmpSlee10Wrapper ; }

Retrieves the profile cmp slee 1.0 wrapper for this profile object
@return

Retrieves the profile cmp slee 1 . 0 wrapper for this profile object


public static CtClass createClass(String className, String[] interfaces) throws Exception
  {
    if(className == null)
    {
      throw new NullPointerException("Class name cannot be null");
    }

    CtClass clazz = classPool.makeClass(className);

    if(interfaces != null && interfaces.length > 0)
    {
      clazz.setInterfaces( classPool.get( interfaces ) );
    }

    return clazz;
  }

public
static
CtClass
createClass
(
String
className
,
String
[
]
interfaces
)
throws
Exception
{
if
(
className
==
)
{
throw
new
NullPointerException
(
"Class name cannot be null"
)
;
}
CtClass
clazz
=
classPool
.
makeClass
(
className
)
;
if
(
interfaces
!=
&&
interfaces
.
length
>
0
)
{
clazz
.
setInterfaces
(
classPool
.
get
(
interfaces
)
)
;
}
return
clazz
;
}

Creates a class with the desired name and linked to the mentioned interfaces.

@param className
@param interfaces
@return
@throws Exception

Creates a class with the desired name and linked to the mentioned interfaces .


public static void createInheritanceLink(CtClass concreteClass, String superClassName)
  {
    if(superClassName != null && superClassName.length() >= 0)
    {
      try
      {
        concreteClass.setSuperclass(classPool.get(superClassName));
      }
      catch ( CannotCompileException e ) {
        e.printStackTrace();
      }
      catch ( NotFoundException e ) {
        e.printStackTrace();
      }
    }
  }

public static void createInheritanceLink ( CtClass concreteClass , String superClassName ) { if ( superClassName != null && superClassName . length ( ) >= 0 ) { try { concreteClass . setSuperclass ( classPool . get ( superClassName ) ) ; } catch ( CannotCompileException e ) { e . printStackTrace ( ) ; } catch ( NotFoundException e ) { e . printStackTrace ( ) ; } } }

Create the inheritance link with the absract class provided by the developer

@param concreteClass the concrete class to which to add the inheritance link
@param superClass the superClass to set


public static void addAnnotation(String annotation, LinkedHashMap<String, Object> memberValues, Object toAnnotate)
  {
    if(toAnnotate instanceof CtClass)
    {
      CtClass classToAnnotate = (CtClass) toAnnotate;

      ClassFile cf = classToAnnotate.getClassFile();
      ConstPool cp = cf.getConstPool();

      AnnotationsAttribute attr = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);

      if(attr == null)
      {
        attr = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
      }

      Annotation a = new Annotation(annotation, cp);

      if(memberValues != null)
      {
        addMemberValuesToAnnotation(a, cp, memberValues);
      }

      attr.addAnnotation( a );

      cf.addAttribute( attr );
    }
    else if(toAnnotate instanceof CtMethod)
    {
      CtMethod methodToAnnotate = (CtMethod) toAnnotate;

      MethodInfo mi = methodToAnnotate.getMethodInfo();
      ConstPool cp = mi.getConstPool();

      AnnotationsAttribute attr = (AnnotationsAttribute) mi.getAttribute(AnnotationsAttribute.visibleTag);

      if(attr == null)
      {
        attr = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
      }

      Annotation a = new Annotation(annotation, cp);

      if(memberValues != null)
      {
        addMemberValuesToAnnotation(a, cp, memberValues);
      }

      attr.addAnnotation( a );

      mi.addAttribute( attr );
    }
    else if(toAnnotate instanceof CtField)
    {
      CtField fieldToAnnotate = (CtField) toAnnotate;

      FieldInfo fi = fieldToAnnotate.getFieldInfo();
      ConstPool cp = fi.getConstPool();

      AnnotationsAttribute attr = (AnnotationsAttribute) fi.getAttribute(AnnotationsAttribute.visibleTag);

      if(attr == null)
      {
        attr = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
      }

      Annotation a = new Annotation(annotation, cp);

      if(memberValues != null)
      {
        addMemberValuesToAnnotation(a, cp, memberValues);
      }

      attr.addAnnotation( a );

      fi.addAttribute( attr );
    }
    else
    {
      throw new UnsupportedOperationException("Unknown object type: " + toAnnotate.getClass());
    }
  }

public
static
void
addAnnotation
(
String
annotation
,
LinkedHashMap
<
String
,
Object
>
memberValues
,
Object
toAnnotate
)
{
if
(
toAnnotate
instanceof
CtClass
)
{
CtClass
classToAnnotate
=
(
CtClass
)
toAnnotate
;
ClassFile
cf
=
classToAnnotate
.
getClassFile
(
)
;
ConstPool
cp
=
cf
.
getConstPool
(
)
;
AnnotationsAttribute
attr
=
(
AnnotationsAttribute
)
cf
.
getAttribute
(
AnnotationsAttribute
.
visibleTag
)
;
if
(
attr
==
)
{
attr
=
new
AnnotationsAttribute
(
cp
,
AnnotationsAttribute
.
visibleTag
)
;
}
Annotation
a
=
new
Annotation
(
annotation
,
cp
)
;
if
(
memberValues
!=
)
{
addMemberValuesToAnnotation
(
a
,
cp
,
memberValues
)
;
}
attr
.
addAnnotation
(
a
)
;
cf
.
addAttribute
(
attr
)
;
}
else
if
(
toAnnotate
instanceof
CtMethod
)
{
CtMethod
methodToAnnotate
=
(
CtMethod
)
toAnnotate
;
MethodInfo
mi
=
methodToAnnotate
.
getMethodInfo
(
)
;
ConstPool
cp
=
mi
.
getConstPool
(
)
;
AnnotationsAttribute
attr
=
(
AnnotationsAttribute
)
mi
.
getAttribute
(
AnnotationsAttribute
.
visibleTag
)
;
if
(
attr
==
)
{
attr
=
new
AnnotationsAttribute
(
cp
,
AnnotationsAttribute
.
visibleTag
)
;
}
Annotation
a
=
new
Annotation
(
annotation
,
cp
)
;
if
(
memberValues
!=
)
{
addMemberValuesToAnnotation
(
a
,
cp
,
memberValues
)
;
}
attr
.
addAnnotation
(
a
)
;
mi
.
addAttribute
(
attr
)
;
}
else
if
(
toAnnotate
instanceof
CtField
)
{
CtField
fieldToAnnotate
=
(
CtField
)
toAnnotate
;
FieldInfo
fi
=
fieldToAnnotate
.
getFieldInfo
(
)
;
ConstPool
cp
=
fi
.
getConstPool
(
)
;
AnnotationsAttribute
attr
=
(
AnnotationsAttribute
)
fi
.
getAttribute
(
AnnotationsAttribute
.
visibleTag
)
;
if
(
attr
==
)
{
attr
=
new
AnnotationsAttribute
(
cp
,
AnnotationsAttribute
.
visibleTag
)
;
}
Annotation
a
=
new
Annotation
(
annotation
,
cp
)
;
if
(
memberValues
!=
)
{
addMemberValuesToAnnotation
(
a
,
cp
,
memberValues
)
;
}
attr
.
addAnnotation
(
a
)
;
fi
.
addAttribute
(
attr
)
;
}
else
{
throw
new
UnsupportedOperationException
(
"Unknown object type: "
+
toAnnotate
.
getClass
(
)
)
;
}
}

Adds the selected annotation to the Object, along with the specified memberValues.

@param annotation the FQDN of the annotation
@param memberValues the member values HashMap (name=value)
@param toAnnotate the object to be annotated

Adds the selected annotation to the Object along with the specified memberValues .


private static void addMemberValuesToAnnotation(Annotation annotation, ConstPool cp, LinkedHashMap<String, Object> memberValues)
  {
    // Get the member value object
    for(String mvName : memberValues.keySet())
    {
      Object mvValue = memberValues.get(mvName);
      MemberValue mv = getMemberValue(mvValue, cp);
      annotation.addMemberValue( mvName, mv );
    }
  }

private
static
void
addMemberValuesToAnnotation
(
Annotation
annotation
,
ConstPool
cp
,
LinkedHashMap
<
String
,
Object
>
memberValues
)
{
// Get the member value object
for
(
String
mvName
:
memberValues
.
keySet
(
)
)
{
Object
mvValue
=
memberValues
.
get
(
mvName
)
;
MemberValue
mv
=
getMemberValue
(
mvValue
,
cp
)
;
annotation
.
addMemberValue
(
mvName
,
mv
)
;
}
}

Private method to add member values to annotation

@param annotation
@param cp
@param memberValues


protected ActivityContextInterface getACI(Object activity)
			throws NullPointerException, UnrecognizedActivityException,
			FactoryException {
		if (activity == null) {
			throw new NullPointerException("null activity object");
		}
		ActivityHandle handle = null;
		for (ResourceAdaptorEntity raEntity : sleeContainer
				.getResourceManagement().getResourceAdaptorEntitiesPerType(resourceAdaptorTypeID)) {
			handle = raEntity.getResourceAdaptorObject().getActivityHandle(
					activity);
			if (handle != null) {
				ActivityContextHandle ach = new ResourceAdaptorActivityContextHandleImpl(raEntity, handle);
				ActivityContext ac = sleeContainer.getActivityContextFactory()
						.getActivityContext(ach);
				if (ac != null) {
					return ac.getActivityContextInterface();
				}
				break;
			}
		}

		throw new UnrecognizedActivityException(activity.toString());
	}

This method returns the aci for the specified activity, if exists, it
should be invoked by each impl of methods of an ra type aci factory.

@param activity
@return
@throws NullPointerException
@throws UnrecognizedActivityException
@throws FactoryException

This method returns the aci for the specified activity if exists it should be invoked by each impl of methods of an ra type aci factory .


public ClassPool getClassPool() {
		if (classPool == null) {
			if (classLoader == null) {
				throw new IllegalStateException("can't init javassit classpool, there is no class loader set for the component");
			}
			classPool = new ClassPool();
			// add class path for domain and dependencies
			classPool.appendClassPath(new LoaderClassPath(classLoaderDomain));
			for(ClassLoader domainDependencies : classLoaderDomain.getAllDependencies()) {
				classPool.appendClassPath(new LoaderClassPath(domainDependencies));
			}
			// add class path also for slee
			classPool.appendClassPath(new LoaderClassPath(classLoaderDomain.getParent()));
		}
		return classPool;
	}

Retrieves the component javassist class pool

@return


public void setDeployableUnit(DeployableUnit deployableUnit)
			throws AlreadyDeployedException {
		if (this.deployableUnit != null) {
			throw new IllegalStateException(
					"deployable unit already set. du = " + this.deployableUnit);
		}
		this.deployableUnit = deployableUnit;
		if (!addToDeployableUnit()) {
			throw new AlreadyDeployedException(
					"unable to install du having multiple components with id "
							+ getComponentID());
		}
	}

Specifies the the Deployable Unit this component belongs. This method
also sets the reverse relation, adding the component to the deployable
unit

@param deployableUnit
@throws AlreadyDeployedException
if a component with same id already exists in the du
@throws IllegalStateException
if this method is invoked and the deployable unit was already
set before

Specifies the the Deployable Unit this component belongs . This method also sets the reverse relation adding the component to the deployable unit


public void undeployed() {

		classLoader = null;

		if (classLoaderDomain != null) {
			classLoaderDomain.clear();
			classLoaderDomain = null;
		}

		if (classPool != null) {
			classPool.clean();
			classPool = null;
		}

		if (permissions != null) {
			permissions.clear();
			permissions = null;
		}
	}

public void undeployed ( ) { classLoader = null ; if ( classLoaderDomain != null ) { classLoaderDomain . clear ( ) ; classLoaderDomain = null ; } if ( classPool != null ) { classPool . clean ( ) ; classPool = null ; } if ( permissions != null ) { permissions . clear ( ) ; permissions = null ; } }

Indicates that the component was undeployed and thus should clean up any resources


void execute(final ActivityHandle handle, final int activityFlags, boolean suspendActivity)
			throws SLEEException {

		final SleeTransaction tx = super.suspendTransaction();
		ActivityContextHandle ach = null;
		try {
			ach = sleeEndpoint._startActivity(handle, activityFlags, suspendActivity ? tx : null);
		} finally {
			if (tx != null) {
				super.resumeTransaction(tx);
				// the activity was started out of the tx but it will be suspended, if the flags request the unreferenced callback then
				// we can load the ac now, which will schedule a check for references in the end of the tx, this ensures that the callback is received if no events are fired or
				// events are fired but not handled, that is, no reference is ever ever created
				if (ach != null && ActivityFlags.hasRequestSleeActivityGCCallback(activityFlags)) {
					acFactory.getActivityContext(ach);
				}
			}
		}
	}

Executes a non transacted start activity operation.
@param handle
@param activityFlags
@throws SLEEException

Executes a non transacted start activity operation .


public static Class checkInterfaces(Class classOrInterfaceWithInterfaces, String interfaceSearched) {
		Class returnValue = null;

		if (classOrInterfaceWithInterfaces.getName().compareTo(interfaceSearched) == 0) {
			return classOrInterfaceWithInterfaces;

		}
		// we do check only on get interfaces
		for (Class iface : classOrInterfaceWithInterfaces.getInterfaces()) {
			if (iface.getName().compareTo(interfaceSearched) == 0) {
				returnValue = iface;

			} else {
				returnValue = checkInterfaces(iface, interfaceSearched);
			}

			if (returnValue != null)
				break;
		}

		if (!classOrInterfaceWithInterfaces.isInterface() && returnValue == null) {
			Class superClass = classOrInterfaceWithInterfaces.getSuperclass();
			if (superClass != null) {
				returnValue = checkInterfaces(superClass, interfaceSearched);
			}
		}

		return returnValue;
	}

public
static
Class
checkInterfaces
(
Class
classOrInterfaceWithInterfaces
,
String
interfaceSearched
)
{
Class
returnValue
=
;
if
(
classOrInterfaceWithInterfaces
.
getName
(
)
.
compareTo
(
interfaceSearched
)
==
0
)
{
return
classOrInterfaceWithInterfaces
;
}
// we do check only on get interfaces
for
(
Class
iface
:
classOrInterfaceWithInterfaces
.
getInterfaces
(
)
)
{
if
(
iface
.
getName
(
)
.
compareTo
(
interfaceSearched
)
==
0
)
{
returnValue
=
iface
;
}
else
{
returnValue
=
checkInterfaces
(
iface
,
interfaceSearched
)
;
}
if
(
returnValue
!=
)
break
;
}
if
(
!
classOrInterfaceWithInterfaces
.
isInterface
(
)
&&
returnValue
==
)
{
Class
superClass
=
classOrInterfaceWithInterfaces
.
getSuperclass
(
)
;
if
(
superClass
!=
)
{
returnValue
=
checkInterfaces
(
superClass
,
interfaceSearched
)
;
}
}
return
returnValue
;
}

Searches for provided interface in passed Class object - it can be class
or interface. If it finds, it return instance of it.

@param classOrInterfaceWithInterfaces
@param interfaceSearched
@return

Searches for provided interface in passed Class object - it can be class or interface . If it finds it return instance of it .


public static Map<String, Method> getAllInterfacesMethods(Class xInterfaceClass, Set<String> ignore) {
		HashMap<String, Method> abstractMethods = new HashMap<String, Method>();
		Method[] methods = null;
		Class[] superInterfaces;

		superInterfaces = xInterfaceClass.getInterfaces();

		for (Class superInterface : superInterfaces) {
			if (!ignore.contains(superInterface.getName()))
				abstractMethods.putAll(getAllInterfacesMethods(superInterface, ignore));
		}

		methods = xInterfaceClass.getDeclaredMethods();
		for (int i = 0; i < methods.length; i++) {
			abstractMethods.put(getMethodKey(methods[i]), methods[i]);
		}

		return abstractMethods;
	}

public static Map < String , Method > getAllInterfacesMethods ( Class xInterfaceClass , Set < String > ignore ) { HashMap < String , Method > abstractMethods = new HashMap < String , Method > ( ) ; Method [ ] methods = null ; Class [ ] superInterfaces ; superInterfaces = xInterfaceClass . getInterfaces ( ) ; for ( Class superInterface : superInterfaces ) { if ( ! ignore . contains ( superInterface . getName ( ) ) ) abstractMethods . putAll ( getAllInterfacesMethods ( superInterface , ignore ) ) ; } methods = xInterfaceClass . getDeclaredMethods ( ) ; for ( int i = 0 ; i < methods . length ; i ++ ) { abstractMethods . put ( getMethodKey ( methods [ i ] ) , methods [ i ] ) ; } return abstractMethods ; }

Returns methods of this interface and all super interfaces

@param ctInterfaceClass
@return


public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
    {
        URL resourceURL = resources.get(publicId);

        if(resourceURL != null) {
            InputStream resourceStream = resourceURL.openStream();
            InputSource is = new InputSource(resourceStream);
            is.setPublicId(publicId);
            is.setSystemId(resourceURL.toExternalForm());
            return is;
        }

        return null;
    }

public InputSource resolveEntity ( String publicId , String systemId ) throws SAXException , IOException { URL resourceURL = resources . get ( publicId ) ; if ( resourceURL != null ) { InputStream resourceStream = resourceURL . openStream ( ) ; InputSource is = new InputSource ( resourceStream ) ; is . setPublicId ( publicId ) ; is . setSystemId ( resourceURL . toExternalForm ( ) ) ; return is ; } return null ; }

Creates an InputSource with a SystemID corresponding to a local dtd file.

@param publicId The public identifier of the external entity being referenced, or null if none was supplied.
@param systemId The system identifier of the external entity being referenced (This is a dummy parameter and is overridden by the resource names
earlier specified by the registrerResource) method to correspond to the publicID.
@return An InputSource object describing the new input source, or null to request that the parser open a regular URI connection to the system identifier.
@exception org.xml.sax.SAXException Any SAX exception, possibly wrapping another exception.
@exception java.io.IOException A Java-specific IO exception, possibly the result of creating a new InputStream or Reader for the InputSource.

Creates an InputSource with a SystemID corresponding to a local dtd file .


public static void checkTracerName(String tracerName, NotificationSource notificationSource) throws IllegalArgumentException {

		if (tracerName.compareTo("") == 0) {
			// This is root
			return;
		}

		// String[] splitName = tracerName.split("\\.");
		StringTokenizer stringTokenizer = new StringTokenizer(tracerName, ".", true);

		int fqdnPartIndex = 0;

		// if(splitName.length==0)
		// {
		// throw new IllegalArgumentException("Passed tracer:" + tracerName +
		// ", name for source: " + notificationSource + ", is illegal");
		// }

		String lastToken = null;

		while (stringTokenizer.hasMoreTokens()) {
			String token = stringTokenizer.nextToken();
			if (lastToken == null) {
				// this is start
				lastToken = token;
			}

			if (lastToken.compareTo(token) == 0 && token.compareTo(".") == 0) {
				throw new IllegalArgumentException("Passed tracer:" + tracerName + ", name for source: " + notificationSource + ", is illegal");
			}

			if (token.compareTo(".") != 0) {
				for (int charIndex = 0; charIndex < token.length(); charIndex++) {
					Character c = token.charAt(charIndex);
					if (Character.isLetter(c) || Character.isDigit(c)) {
						// Its ok?
					} else {
						throw new IllegalArgumentException("Passed tracer:" + tracerName + " Token[" + token + "], name for source: " + notificationSource
								+ ", is illegal, contains illegal character: " + charIndex);
					}
				}

				fqdnPartIndex++;
			}
			lastToken = token;

		}

		if (lastToken.compareTo(".") == 0) {
			throw new IllegalArgumentException("Passed tracer:" + tracerName + ", name for source: " + notificationSource + ", is illegal");
		}

	}

This checks if tracer name is ok. It must not be null;

@param split
@throws IllegalArgumentException

This checks if tracer name is ok . It must not be null ;


public static Collection<ProfileLocalObject> handle(
			ProfileTableImpl profileTable, String queryName, Object[] arguments)
			throws NullPointerException, TransactionRequiredLocalException, SLEEException,
			UnrecognizedQueryNameException, AttributeTypeMismatchException,
			InvalidArgumentException {
		return profileTable.getProfilesByStaticQuery(queryName, arguments);
	}

public static Collection < ProfileLocalObject > handle ( ProfileTableImpl profileTable , String queryName , Object [ ] arguments ) throws NullPointerException , TransactionRequiredLocalException , SLEEException , UnrecognizedQueryNameException , AttributeTypeMismatchException , InvalidArgumentException { return profileTable . getProfilesByStaticQuery ( queryName , arguments ) ; }

Method that does lookup and creates PLOs

@param profileTable
@param queryName
@param arguments
@return
@throws InvalidArgumentException
@throws AttributeTypeMismatchException
@throws UnrecognizedQueryNameException
@throws SLEEException
@throws NullPointerException


private void checkDependencies(SleeComponent sleeComponent,
			DeployableUnitImpl deployableUnit) throws DependencyException {
		for (ComponentID componentID : sleeComponent.getDependenciesSet()) {
			if (componentID instanceof EventTypeID) {
				if (deployableUnit.getDeployableUnitRepository()
						.getComponentByID((EventTypeID) componentID) == null) {
					throw new DependencyException(
							"Component "
									+ sleeComponent.getComponentID()
									+ " depends on "
									+ componentID
									+ " which is not available in the component repository or in the deployable unit");
				}
			} else if (componentID instanceof LibraryID) {
				if (deployableUnit.getDeployableUnitRepository()
						.getComponentByID((LibraryID) componentID) == null) {
					throw new DependencyException(
							"Component "
									+ sleeComponent.getComponentID()
									+ " depends on "
									+ componentID
									+ " which is not available in the component repository or in the deployable unit");
				}
			} else if (componentID instanceof ProfileSpecificationID) {
				if (deployableUnit.getDeployableUnitRepository()
						.getComponentByID((ProfileSpecificationID) componentID) == null) {
					throw new DependencyException(
							"Component "
									+ sleeComponent.getComponentID()
									+ " depends on "
									+ componentID
									+ " which is not available in the component repository or in the deployable unit");
				}
			} else if (componentID instanceof ResourceAdaptorID) {
				if (deployableUnit.getDeployableUnitRepository()
						.getComponentByID((ResourceAdaptorID) componentID) == null) {
					throw new DependencyException(
							"Component "
									+ sleeComponent.getComponentID()
									+ " depends on "
									+ componentID
									+ " which is not available in the component repository or in the deployable unit");
				}
			} else if (componentID instanceof ResourceAdaptorTypeID) {
				if (deployableUnit.getDeployableUnitRepository()
						.getComponentByID((ResourceAdaptorTypeID) componentID) == null) {
					throw new DependencyException(
							"Component "
									+ sleeComponent.getComponentID()
									+ " depends on "
									+ componentID
									+ " which is not available in the component repository or in the deployable unit");
				}
			} else if (componentID instanceof SbbID) {
				if (deployableUnit.getDeployableUnitRepository()
						.getComponentByID((SbbID) componentID) == null) {
					throw new DependencyException(
							"Component "
									+ sleeComponent.getComponentID()
									+ " depends on "
									+ componentID
									+ " which is not available in the component repository or in the deployable unit");
				}
			} else if (componentID instanceof ServiceID) {
				throw new SLEEException(
						"Component "
								+ sleeComponent.getComponentID()
								+ " depends on a service component "
								+ componentID
								+ " which is not available in the component repository or in the deployable unit");
			}
		}
	}

Checks if all dependencies of a DU component exists

@param sleeComponent
@param deployableUnit
@throws DependencyException
if a dependency is missing