Input:
Checks expression to check if collator refs and cmp fields are referenced correctly . type constraints are checked later . Since in case of lack of parameter we have to relly totaly on CMP field type . Additionaly this check if parameter and value are present together . [CODESPLIT] boolean validateExpression ( String queryName , QueryExpressionDescriptor expression , Set < String > usedQueryParameter , Set < String > cmpFieldNames , Set < String > collatorAliasses ) { boolean passed = true ; String attributeName = null ; String collatorRef = null ; String parameter = null ; String value = null ; boolean ignoreAbsence = false ; // We dont have access to type of cmp, we just simply check parameter
 String errorBuffer = new String ( "" ) ; try { switch ( expression . getType ( ) ) { // "complex types"
 case And : for ( QueryExpressionDescriptor mqe : expression . getAnd ( ) ) { if ( ! validateExpression ( queryName , mqe , usedQueryParameter , cmpFieldNames , collatorAliasses ) ) { passed = false ; } } break ; case Or : for ( QueryExpressionDescriptor mqe : expression . getOr ( ) ) { if ( ! validateExpression ( queryName , mqe , usedQueryParameter , cmpFieldNames , collatorAliasses ) ) { passed = false ; } } break ; // "simple" types
 case Not : // this is one akward case :)
 if ( ! validateExpression ( queryName , expression . getNot ( ) , usedQueryParameter , cmpFieldNames , collatorAliasses ) ) { passed = false ; } break ; case Compare : attributeName = expression . getCompare ( ) . getAttributeName ( ) ; collatorRef = expression . getCompare ( ) . getCollatorRef ( ) ; parameter = expression . getCompare ( ) . getParameter ( ) ; value = expression . getCompare ( ) . getValue ( ) ; break ; case HasPrefix : attributeName = expression . getHasPrefix ( ) . getAttributeName ( ) ; collatorRef = expression . getHasPrefix ( ) . getCollatorRef ( ) ; parameter = expression . getHasPrefix ( ) . getParameter ( ) ; value = expression . getHasPrefix ( ) . getValue ( ) ; break ; case LongestPrefixMatch : attributeName = expression . getLongestPrefixMatch ( ) . getAttributeName ( ) ; collatorRef = expression . getLongestPrefixMatch ( ) . getCollatorRef ( ) ; parameter = expression . getLongestPrefixMatch ( ) . getParameter ( ) ; value = expression . getLongestPrefixMatch ( ) . getValue ( ) ; break ; case RangeMatch : attributeName = expression . getRangeMatch ( ) . getAttributeName ( ) ; collatorRef = expression . getRangeMatch ( ) . getCollatorRef ( ) ; RangeMatchDescriptor mrm = expression . getRangeMatch ( ) ; ignoreAbsence = true ; if ( mrm . getFromParameter ( ) == null && mrm . getFromValue ( ) == null ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query wrong properties, either fromValue or fromParameter can be present, query name: " + queryName , "10.20.2" , errorBuffer ) ; } if ( mrm . getFromParameter ( ) != null && mrm . getFromValue ( ) != null ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query wrong properties, either fromValue or fromParameter can be present, not both, query name: " + queryName , "10.20.2" , errorBuffer ) ; } if ( mrm . getToParameter ( ) == null && mrm . getToValue ( ) == null ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query wrong properties, either toValue or toParameter can be present, query name: " + queryName , "10.20.2" , errorBuffer ) ; } if ( mrm . getToParameter ( ) != null && mrm . getToValue ( ) != null ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query wrong properties, either toValue or toParameter can be present, not both, query name: " + queryName , "10.20.2" , errorBuffer ) ; } if ( mrm . getFromParameter ( ) != null ) { usedQueryParameter . add ( mrm . getFromParameter ( ) ) ; } if ( mrm . getToParameter ( ) != null ) { usedQueryParameter . add ( mrm . getToParameter ( ) ) ; } break ; } //This will hapen for Not,And, Or operators
 if ( attributeName != null ) { if ( ! Character . isLowerCase ( attributeName . charAt ( 0 ) ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query usage of cmp attribute that is not valid cmp identifier, declared cmp field: " + attributeName + ", query name: " + queryName , "10.20.2" , errorBuffer ) ; } else if ( ! cmpFieldNames . contains ( attributeName ) && ! checkForCmpMethodFromFieldName ( attributeName ) ) { //we have to check this. stupid specs for profile cmps are not so strict..... You can defined CMP methods but not define them in descriptor.....!!!!!!!
 passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query usage of cmp field that does not exist(its not declared in descritpro and in cmp interface), declared cmp field: " + attributeName + ", query name: " + queryName , "10.20.2" , errorBuffer ) ; } if ( collatorRef != null && ! collatorAliasses . contains ( collatorRef ) ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query usage of collator that is not aliased, collator alias: " + collatorRef + ", query name: " + queryName , "10.20.2" , errorBuffer ) ; } if ( ! ignoreAbsence && parameter != null && value != null ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query wrong properties, value and parameter can not be present at the same time, query name: " + queryName , "10.20.2" , errorBuffer ) ; } if ( ! ignoreAbsence && parameter == null && value == null ) { passed = false ; errorBuffer = appendToBuffer ( "Profile specification declares in static query wrong properties, either value or parameter must be present, query name: " + queryName , "10.20.2" , errorBuffer ) ; } if ( parameter != null ) { usedQueryParameter . add ( parameter ) ; } } } finally { if ( ! passed ) { if ( logger . isEnabledFor ( Level . ERROR ) ) logger . error ( errorBuffer ) ; //System.err.println(errorBuffer);
 } } return passed ; }


Input:
Set the element as text value parse it and setValue . The separator is CID_SEPARATOR [CODESPLIT] 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 ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void execute ( Runnable task ) { if ( stats == null ) { executor . execute ( task ) ; } else { executor . execute ( new MiscTaskStatsCollector ( task ) ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void executeNow ( Runnable task ) throws InterruptedException , ExecutionException { if ( stats == null ) { executor . submit ( task ) . get ( ) ; } else { executor . submit ( new MiscTaskStatsCollector ( task ) ) . get ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void routeEvent ( EventContext event ) { final EventRoutingTaskImpl eventRoutingTask = new EventRoutingTaskImpl ( event , sleeContainer ) ; if ( stats == null ) { executor . execute ( eventRoutingTask ) ; } else { executor . execute ( new EventRoutingTaskStatsCollector ( eventRoutingTask ) ) ; } }


Input: ------- MANAGEMENT OPERATIONS [CODESPLIT] public void createResourceAdaptorEntity ( ResourceAdaptorID id , String entityName , ConfigProperties properties ) throws NullPointerException , InvalidArgumentException , UnrecognizedResourceAdaptorException , ResourceAdaptorEntityAlreadyExistsException , InvalidConfigurationException , ManagementException { try { synchronized ( getSleeContainer ( ) . getManagementMonitor ( ) ) { resourceManagement . createResourceAdaptorEntity ( id , entityName , properties ) ; } } catch ( NullPointerException e ) { throw e ; } catch ( InvalidArgumentException e ) { throw e ; } catch ( UnrecognizedResourceAdaptorException e ) { throw e ; } catch ( ResourceAdaptorEntityAlreadyExistsException e ) { throw e ; } catch ( InvalidConfigurationException e ) { throw e ; } catch ( Throwable e ) { String s = "failed to create RA entity with name " + entityName ; logger . error ( s , e ) ; throw new ManagementException ( s , e ) ; } }


Input:
Generate the Activity Context Interface Class [CODESPLIT] 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 ; }


Input:
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 [CODESPLIT] 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 ) ; } } }


Input: TODO [CODESPLIT] private static ProfileEntityArrayAttributeValue newProfileEntityArrayAttributeValueInstance ( Class < ? > profileAttrArrayValueClass , ProfileEntity owner ) { ProfileEntityArrayAttributeValue profileAttrArrayValue = null ; try { profileAttrArrayValue = ( ProfileEntityArrayAttributeValue ) profileAttrArrayValueClass . newInstance ( ) ; profileAttrArrayValue . setProfileEntity ( owner ) ; } catch ( Throwable e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; } return profileAttrArrayValue ; }


Input: / * public String getLoggingConfiguration ( String profile ) throws ManagementException { try { return readFile ( getLog4jPath ( profile )) ; } catch ( IOException ioe ) { throw new ManagementException ( Failed to read log4j configuration file for profile + profile + . Does it exists? ioe ) ; } } [CODESPLIT] private String getLog4jPath ( String profile ) { return ( profile == null || profile . equals ( "" ) || profile . equalsIgnoreCase ( "current" ) ) ? log4jConfigFilePath : log4jTemplatesPath + profile ; }


Input: Compare this alarm with the specified object for order . Returns a negative integer zero or a positive integer if this object is less than equal to or greater than the specified object . <p > Alarm ordering is determined by comparing unique the alarm identifier . [CODESPLIT] public int compareTo ( Object obj ) { if ( obj == this ) return 0 ; if ( ! ( obj instanceof Alarm ) ) throw new ClassCastException ( "Not a javax.slee.management.Alarm: " + obj ) ; Alarm that = ( Alarm ) obj ; // compare alarm identifiers return this . alarmID . compareTo ( that . alarmID ) ; }


Input: Retrieves the JAIN SLEE specs descriptor [CODESPLIT] public javax . slee . resource . ResourceAdaptorDescriptor getSpecsDescriptor ( ) { if ( specsDescriptor == null ) { final LibraryID [ ] libraryIDs = descriptor . getLibraryRefs ( ) . toArray ( new LibraryID [ descriptor . getLibraryRefs ( ) . size ( ) ] ) ; final ResourceAdaptorTypeID [ ] raTypeIDs = descriptor . getResourceAdaptorTypeRefs ( ) . toArray ( new ResourceAdaptorTypeID [ descriptor . getResourceAdaptorTypeRefs ( ) . size ( ) ] ) ; Set < ProfileSpecificationID > profileSpecSet = new HashSet < ProfileSpecificationID > ( ) ; for ( ProfileSpecRefDescriptor mProfileSpecRef : descriptor . getProfileSpecRefs ( ) ) { profileSpecSet . add ( mProfileSpecRef . getComponentID ( ) ) ; } ProfileSpecificationID [ ] profileSpecs = profileSpecSet . toArray ( new ProfileSpecificationID [ profileSpecSet . size ( ) ] ) ; specsDescriptor = new javax . slee . resource . ResourceAdaptorDescriptor ( getResourceAdaptorID ( ) , getDeployableUnit ( ) . getDeployableUnitID ( ) , getDeploymentUnitSource ( ) , libraryIDs , raTypeIDs , profileSpecs , getDescriptor ( ) . getSupportsActiveReconfiguration ( ) ) ; } return specsDescriptor ; }


Input: Creates an instance of the { @link ConfigProperties } for this component [CODESPLIT] public ConfigProperties getDefaultConfigPropertiesInstance ( ) { ConfigProperties defaultProperties = new ConfigProperties ( ) ; for ( ConfigPropertyDescriptor mConfigProperty : getDescriptor ( ) . getConfigProperties ( ) ) { Object configPropertyValue = mConfigProperty . getConfigPropertyValue ( ) == null ? null : ConfigProperties . Property . toObject ( mConfigProperty . getConfigPropertyType ( ) , mConfigProperty . getConfigPropertyValue ( ) ) ; defaultProperties . addProperty ( new ConfigProperties . Property ( mConfigProperty . getConfigPropertyName ( ) , mConfigProperty . getConfigPropertyType ( ) , configPropertyValue ) ) ; } return defaultProperties ; }


Input: Retrieve the { @link ActivityFlags } for this activity context [CODESPLIT] public int getActivityFlags ( ) { if ( flags == null ) { // instance has no flags stored, check local ac if ( localActivityContext != null ) { flags = localActivityContext . getActivityFlags ( ) ; } else { // local ac does not exists, get from cache flags = ( Integer ) cacheData . getObject ( NODE_MAP_KEY_ACTIVITY_FLAGS ) ; } } return flags != null ? flags : ActivityFlags . NO_FLAGS ; }


Input: Set a shared data item for the ACI [CODESPLIT] 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 ) ; } }


Input: add a naming binding to this activity context . [CODESPLIT] public void addNameBinding ( String aciName ) { cacheData . nameBound ( aciName ) ; if ( acReferencesHandler != null ) { acReferencesHandler . nameReferenceCreated ( ) ; } }


Input: This is called to release all the name bindings after the activity end event is delivered to the sbb . [CODESPLIT] 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 ) ; } } }


Input: 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 . [CODESPLIT] public boolean removeNameBinding ( String aciName ) { boolean removed = cacheData . nameUnbound ( aciName ) ; if ( removed && acReferencesHandler != null ) { acReferencesHandler . nameReferenceRemoved ( ) ; } return removed ; }


Input: attach the given timer to the current activity context . [CODESPLIT] public boolean attachTimer ( TimerID timerID ) { if ( cacheData . attachTimer ( timerID ) ) { if ( acReferencesHandler != null ) { acReferencesHandler . timerReferenceCreated ( ) ; } return true ; } else { return false ; } }


Input: Detach timer [CODESPLIT] public boolean detachTimer ( TimerID timerID ) { boolean detached = cacheData . detachTimer ( timerID ) ; if ( detached && acReferencesHandler != null ) { acReferencesHandler . timerReferenceRemoved ( ) ; } return detached ; }


Input: End Event has been delivered on the Activity Context . [CODESPLIT] 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 ) ; } }


Input: attach an sbb entity to this AC . [CODESPLIT] 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 ; }


Input: Detach the sbb entity [CODESPLIT] 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 ( ) ) ; } } }


Input: get an ordered copy of the set of SBBs attached to this ac . The ordering is by SBB priority . [CODESPLIT] 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 ; }


Input: --- private helpers [CODESPLIT] private void updateLastAccessTime ( boolean creation ) { if ( creation ) { cacheData . putObject ( NODE_MAP_KEY_LAST_ACCESS , Long . valueOf ( System . currentTimeMillis ( ) ) ) ; } else { ActivityManagementConfiguration configuration = factory . getConfiguration ( ) ; Long lastUpdate = ( Long ) cacheData . getObject ( NODE_MAP_KEY_LAST_ACCESS ) ; if ( lastUpdate != null ) { final long now = System . currentTimeMillis ( ) ; if ( ( now - configuration . getMinTimeBetweenUpdatesInMs ( ) ) > lastUpdate . longValue ( ) ) { // last update if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Updating access time for AC with handle " + getActivityContextHandle ( ) ) ; } cacheData . putObject ( NODE_MAP_KEY_LAST_ACCESS , Long . valueOf ( now ) ) ; } else { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Skipping update of access time for AC with handle " + getActivityContextHandle ( ) ) ; } } } else { cacheData . putObject ( NODE_MAP_KEY_LAST_ACCESS , Long . valueOf ( System . currentTimeMillis ( ) ) ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Updating access time for AC with handle " + getActivityContextHandle ( ) ) ; } } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void fireEvent ( EventTypeID eventTypeId , Object event , Address address , ServiceID serviceID , EventProcessingSucceedCallback succeedCallback , EventProcessingFailedCallback failedCallback , EventUnreferencedCallback unreferencedCallback ) throws ActivityIsEndingException , SLEEException { if ( isEnding ( ) ) { throw new ActivityIsEndingException ( getActivityContextHandle ( ) . toString ( ) ) ; } if ( acReferencesHandler != null ) { acReferencesHandler . eventReferenceCreated ( ) ; } fireEvent ( sleeContainer . getEventContextFactory ( ) . createEventContext ( eventTypeId , event , this , address , serviceID , succeedCallback , failedCallback , unreferencedCallback ) , sleeContainer . getTransactionManager ( ) . getTransactionContext ( ) ) ; }


Input: Ends the activity context . [CODESPLIT] 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 ( ) ) ; } }


Input:
Adder method for a Deployable Component . [CODESPLIT] 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 ( ) ) ; }


Input:
Method for obtaining the external dependencies for this DU if any . [CODESPLIT] 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 ; }


Input:
Method for checking if the DU has all the dependencies needed to be deployed . [CODESPLIT] 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 ; }


Input:
Method for checking if this DU contains any component that is already deployed . [CODESPLIT] 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 ; }


Input:
Getter for the Install Actions . [CODESPLIT] 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 ; }


Input:
Getter for the Uninstall Actions . [CODESPLIT] 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 ; }


Input:
Method for checking if this DU components are referred by any others . [CODESPLIT] 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 ; }


Input:
Parser for the deployment config xml . [CODESPLIT] private void parseDUDeployConfig ( ) throws Exception { JarFile componentJarFile = new JarFile ( diURL . getFile ( ) ) ; try { // Get the JarEntry for the deploy-config.xml
 JarEntry deployInfoXML = componentJarFile . getJarEntry ( "META-INF/deploy-config.xml" ) ; if ( deployInfoXML != null ) { DeployConfigParser deployConfigParser = new DeployConfigParser ( componentJarFile . getInputStream ( deployInfoXML ) , sleeContainerDeployer . getSleeContainer ( ) . getResourceManagement ( ) ) ; for ( Entry < String , Collection < ManagementAction > > e : deployConfigParser . getPostInstallActions ( ) . entrySet ( ) ) { postInstallActions . put ( e . getKey ( ) , e . getValue ( ) ) ; } for ( Entry < String , Collection < ManagementAction > > e : deployConfigParser . getPreUninstallActions ( ) . entrySet ( ) ) { preUninstallActions . put ( e . getKey ( ) , e . getValue ( ) ) ; } } } finally { componentJarFile . close ( ) ; } }


Input: Closes and unregisters the mbean for the specified profile if exists [CODESPLIT] 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 ( ) ; } }


Input: Retrieves the JMX ObjectName for a profile given its profile name and profile table name [CODESPLIT] 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 ) ; } } }


Input: Moves to the write mode using specified object . The current java transaction will be suspended . [CODESPLIT] 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 ( ) ) ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void closeProfile ( ) throws InvalidStateException , ManagementException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "closeProfile() on: " + profileName + ", from table:" + profileTable . getProfileTableName ( ) ) ; } // The closeProfile method must throw a javax.slee.InvalidStateException if the Profile MBean object is in the read-write state. if ( this . isProfileWriteable ( ) ) throw new InvalidStateException ( ) ; // unregister mbean unregister ( ) ; }


Input: / * ( non - Javadoc ) @see javax . slee . profile . ProfileMBean#commitProfile () [CODESPLIT] public void commitProfile ( ) throws InvalidStateException , ProfileVerificationException , ManagementException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "commitProfile() on: " + profileName + ", from table:" + profileTable . getProfileTableName ( ) ) ; } if ( ! this . isProfileWriteable ( ) ) throw new InvalidStateException ( "not in write state" ) ; final SleeTransactionManager txManager = sleeContainer . getTransactionManager ( ) ; ProfileEntity profileEntity = null ; try { // resume tx txManager . resume ( this . transaction ) ; // verify state ProfileObjectImpl profileObject = getProfileObject ( ) ; profileObject . profileVerify ( ) ; // check if the tx is marked for rollback if ( txManager . getRollbackOnly ( ) ) { // FIXME can't undertsand why the rollback and change of state, perhaps tests/profiles/lifecycle/Test1110227Test.xml is faulty?? // FIXME: Do we need to close EntityManager here? EntityManager em = getEntityManager ( txManager ) ; txManager . rollback ( ) ; if ( em != null && em . isOpen ( ) ) { em . close ( ) ; } readMode ( ) ; this . transaction = null ; throw new RollbackException ( "the tx is marked for rollback, can't proceeed with commit" ) ; } // "save" profile entity, we may need to recover its current state profileEntity = profileObject . getProfileEntity ( ) ; // commit tx this . transaction = null ; txManager . commit ( ) ; // change mode readMode ( ) ; } catch ( ProfileVerificationException e ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( e . getMessage ( ) , e ) ; } throw e ; } catch ( RollbackException e ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( e . getMessage ( ) , e ) ; } if ( e . getCause ( ) instanceof PersistenceException && e . getCause ( ) . getCause ( ) instanceof ConstraintViolationException ) { throw new ProfileVerificationException ( e . getCause ( ) . getMessage ( ) , e ) ; } else if ( e . getCause ( ) != null && e . getCause ( ) . getClass ( ) == Throwable . class && e . getCause ( ) . getMessage ( ) != null && e . getCause ( ) . getMessage ( ) . equals ( "setRollbackOnly called from:" ) ) { // workaround for issue with jboss AS 5.1.0 GA / Hibernate Entity Manager 3.4.0.GA / JBoss TS 4.6.1.GA, the persistentexception is not thrown throw new ProfileVerificationException ( e . getCause ( ) . getMessage ( ) , e ) ; } else { throw new ManagementException ( e . getMessage ( ) , e ) ; } } catch ( Throwable e ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( e . getMessage ( ) , e ) ; } throw new ManagementException ( e . getMessage ( ) , e ) ; } finally { if ( this . transaction == null ) { if ( isProfileWriteable ( ) ) { // still in write mode if ( logger . isDebugEnabled ( ) ) { logger . debug ( "The tx commit failed, recreating tx with current profile entity state" ) ; } try { txManager . begin ( ) ; this . transaction = txManager . getTransaction ( ) ; ProfileEntity newTxProfileEntity = profileEntity . isCreate ( ) ? profileTable . createProfile ( profileName ) . getProfileEntity ( ) : getProfileObject ( ) . getProfileEntity ( ) ; profileTable . getProfileSpecificationComponent ( ) . getProfileEntityFramework ( ) . getProfileEntityFactory ( ) . copyAttributes ( profileEntity , newTxProfileEntity ) ; newTxProfileEntity . setReadOnly ( false ) ; txManager . suspend ( ) ; } catch ( Throwable e ) { throw new ManagementException ( e . getMessage ( ) , e ) ; } } } else { // tx still valid try { txManager . suspend ( ) ; } catch ( Throwable f ) { logger . error ( f . getMessage ( ) , f ) ; } } } }


Input: Logic to execute before invoking a cmp setter method on the mbean [CODESPLIT] 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 ( ) ; } }


Input: Logic to execute after invoking a cmp setter method on the mbean [CODESPLIT] 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 ) ; } }


Input: Logic to execute before invoking a cmp getter method on the mbean [CODESPLIT] protected boolean beforeGetCmpField ( ) throws ManagementException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "beforeGetCmpField() on profile with name " + profileName + " of table " + profileTable . getProfileTableName ( ) ) ; } return beforeNonSetCmpField ( ) ; }


Input: Logic to execute after invoking a cmp getter method on the mbean [CODESPLIT] 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 ) ; }


Input: Logic to execute before invoking a management method on the mbean [CODESPLIT] 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 ( ) ; }


Input: Logic to execute after invoking a management method on the mbean [CODESPLIT] 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 ( ) ; }


Input: Handles a { @link Throwable } which was the result of a management method invocation [CODESPLIT] protected void throwableOnManagementMethodInvocation ( Throwable t ) throws ProfileImplementationException , InvalidStateException , ManagementException { if ( t instanceof ProfileImplementationException ) { throw ( ProfileImplementationException ) t ; } else if ( t instanceof InvalidStateException ) { throw ( InvalidStateException ) t ; } else if ( t instanceof ReadOnlyProfileException ) { throw new InvalidStateException ( t . getMessage ( ) ) ; } else if ( t instanceof ManagementException ) { throw ( ManagementException ) t ; } else if ( t instanceof RuntimeException ) { try { getProfileObject ( ) . invalidateObject ( ) ; sleeContainer . getTransactionManager ( ) . setRollbackOnly ( ) ; } catch ( Throwable e ) { throw new ManagementException ( e . getMessage ( ) , e ) ; } throw new ProfileImplementationException ( t ) ; } else { // checked exception throw new ProfileImplementationException ( t ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void suspendDelivery ( int arg0 ) throws IllegalArgumentException , IllegalStateException , TransactionRequiredLocalException , SLEEException { suspensionHandlerLazyInit ( ) ; suspensionHandler . suspendDelivery ( arg0 ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void eventProcessingFailed ( FailureReason reason ) { if ( data . getFailedCallback ( ) != null ) { try { data . getFailedCallback ( ) . eventProcessingFailed ( reason ) ; } catch ( Throwable e ) { // ignore } } canceled ( ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void eventProcessingSucceed ( boolean sbbProcessedEvent ) { if ( data . getSucceedCallback ( ) != null ) { data . getSucceedCallback ( ) . eventProcessingSucceed ( sbbProcessedEvent ) ; // ensure failed never gets called, even if event is refired data . unsetFailedCallback ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean routedRequiresTransaction ( ) { final EventUnreferencedCallback unreferencedCallback = data . getUnreferencedCallback ( ) ; if ( unreferencedCallback == null ) { return false ; } else { return unreferencedCallback . requiresTransaction ( ) ; } }


Input: Get a JMX Object Name property string that uniquely identifies the specified resource adaptor entity suitable for inclusion in the Object Name of a Usage MBean . This method makes use of the { [CODESPLIT] public static String getUsageMBeanProperties ( String entityName ) { if ( entityName == null ) throw new NullPointerException ( "entityName is null" ) ; return RESOURCE_ADAPTOR_ENTITY_NAME_KEY + ' ' + ObjectName . quote ( entityName ) ; }


Input: Compare this notification source with the specified object for order . Returns a negative integer zero or a positive integer if this object is less than equal to or greater than the specified object . <p > If <code > obj< / code > is a <code > ResourceAdaptorEntityNotification< / code > order is determined by comparing the encapsulated resource adaptor entity name . Otherwise if <code > obj< / code > is a <code > NotificationSource< / code > ordering is determined by comparing the class name of this class with the class name of <code > obj< / code > . [CODESPLIT] public int compareTo ( Object obj ) { // can't compare with null if ( obj == null ) throw new NullPointerException ( "obj is null" ) ; if ( obj == this ) return 0 ; if ( obj instanceof ResourceAdaptorEntityNotification ) { // compare the entity name ResourceAdaptorEntityNotification that = ( ResourceAdaptorEntityNotification ) obj ; return this . entityName . compareTo ( that . entityName ) ; } else { return super . compareTo ( TYPE , obj ) ; } }


Input: Get a JMX Object Name property string that uniquely identifies the specified service and SBB suitable for inclusion in the Object Name of a Usage MBean . This method makes use of the { [CODESPLIT] public static String getUsageMBeanProperties ( ServiceID service , SbbID sbb ) { if ( service == null ) throw new NullPointerException ( "service is null" ) ; if ( sbb == null ) throw new NullPointerException ( "sbb is null" ) ; StringBuffer buf = new StringBuffer ( ) ; buf . append ( SERVICE_NAME_KEY ) . append ( ' ' ) . append ( ObjectName . quote ( service . getName ( ) ) ) . append ( ' ' ) ; buf . append ( SERVICE_VENDOR_KEY ) . append ( ' ' ) . append ( ObjectName . quote ( service . getVendor ( ) ) ) . append ( ' ' ) ; buf . append ( SERVICE_VERSION_KEY ) . append ( ' ' ) . append ( ObjectName . quote ( service . getVersion ( ) ) ) . append ( ' ' ) ; buf . append ( SBB_NAME_KEY ) . append ( ' ' ) . append ( ObjectName . quote ( sbb . getName ( ) ) ) . append ( ' ' ) ; buf . append ( SBB_VENDOR_KEY ) . append ( ' ' ) . append ( ObjectName . quote ( sbb . getVendor ( ) ) ) . append ( ' ' ) ; buf . append ( SBB_VERSION_KEY ) . append ( ' ' ) . append ( ObjectName . quote ( sbb . getVersion ( ) ) ) ; return buf . toString ( ) ; }


Input: Compare this notification source with the specified object for order . Returns a negative integer zero or a positive integer if this object is less than equal to or greater than the specified object . <p > If <code > obj< / code > is an <code > SbbNotification< / code > order is determined by comparing first the encapsulated service component identifier and then if the service component identifiers are equal the encapsulated SBB component identifier . Otherwise if <code > obj< / code > is a <code > NotificationSource< / code > ordering is determined by comparing the class name of this class with the class name of <code > obj< / code > . [CODESPLIT] public int compareTo ( Object obj ) { // can't compare with null if ( obj == null ) throw new NullPointerException ( "obj is null" ) ; if ( obj == this ) return 0 ; if ( obj instanceof SbbNotification ) { // compare the service id then the sbb id SbbNotification that = ( SbbNotification ) obj ; int serviceComparison = this . service . compareTo ( that . service ) ; return serviceComparison != 0 ? serviceComparison : this . sbb . compareTo ( that . sbb ) ; } else { return super . compareTo ( TYPE , obj ) ; } }


Input: Returns an unmodifiable set with all { @link AbstractSleeComponent } s of the deployable unit . [CODESPLIT] public Set < SleeComponent > getDeployableUnitComponents ( ) { Set < SleeComponent > result = new HashSet < SleeComponent > ( ) ; result . addAll ( getEventTypeComponents ( ) . values ( ) ) ; result . addAll ( getLibraryComponents ( ) . values ( ) ) ; result . addAll ( getProfileSpecificationComponents ( ) . values ( ) ) ; result . addAll ( getResourceAdaptorComponents ( ) . values ( ) ) ; result . addAll ( getResourceAdaptorTypeComponents ( ) . values ( ) ) ; result . addAll ( getSbbComponents ( ) . values ( ) ) ; result . addAll ( getServiceComponents ( ) . values ( ) ) ; return Collections . unmodifiableSet ( result ) ; }


Input: deletes the whole path going through directories [CODESPLIT] private void deletePath ( File path ) { if ( path . isDirectory ( ) ) { File [ ] files = path . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { deletePath ( file ) ; } } } path . delete ( ) ; }


Input: Returns the { @link DeployableUnitDescriptor } for this deployable unit . [CODESPLIT] public javax . slee . management . DeployableUnitDescriptor getSpecsDeployableUnitDescriptor ( ) { Set < ComponentID > componentIDs = new HashSet < ComponentID > ( ) ; for ( SleeComponent component : getDeployableUnitComponents ( ) ) { componentIDs . add ( component . getComponentID ( ) ) ; } return new DeployableUnitDescriptor ( getDeployableUnitID ( ) , date , componentIDs . toArray ( new ComponentID [ 0 ] ) ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void eventUnreferenced ( ) { ActivityContextImpl ac = factory . getActivityContext ( ach ) ; if ( ac != null ) { ac . activityEnded ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { this . activityHandle = new ProfileTableActivityHandleImpl ( in . readUTF ( ) , ( Address ) in . readObject ( ) ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public void writeExternal ( ObjectOutput out ) throws IOException { out . writeUTF ( activityHandle . getProfileTable ( ) ) ; out . writeObject ( activityHandle . getClusterLocalAddress ( ) ) ; }


Input: Create a constructor . This method simply records the input parameters in appropriately named fields . [CODESPLIT] private void createConstructor ( CtClass concreteClass , CtClass usageMBeanInterface , CtClass notificationSource , CtClass usageComponent ) throws Exception { CtConstructor ctCons = new CtConstructor ( new CtClass [ ] { usageMBeanInterface , notificationSource , usageComponent } , concreteClass ) ; ctCons . setBody ( "{ super($1,$2,$3); }" ) ; concreteClass . addConstructor ( ctCons ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setMinFreeMemoryToTurnOn ( int minFreeMemoryToTurnOn ) throws IllegalArgumentException { if ( minFreeMemoryToTurnOn < 0 || minFreeMemoryToTurnOn > 100 ) { throw new IllegalArgumentException ( "param value must be within 0 - 100%" ) ; } this . minFreeMemoryToTurnOn = minFreeMemoryToTurnOn ; if ( congestureControl != null ) { congestureControl . configurationUpdate ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setMinFreeMemoryToTurnOff ( int minFreeMemoryToTurnOff ) throws IllegalArgumentException { if ( minFreeMemoryToTurnOff < 0 || minFreeMemoryToTurnOff > 100 ) { throw new IllegalArgumentException ( "param value must be within 0 - 100%" ) ; } this . minFreeMemoryToTurnOff = minFreeMemoryToTurnOff ; if ( congestureControl != null ) { congestureControl . configurationUpdate ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setPeriodBetweenChecks ( int periodBetweenChecks ) throws IllegalArgumentException { if ( periodBetweenChecks < 0 ) { throw new IllegalArgumentException ( "param value must not be negative" ) ; } this . periodBetweenChecks = periodBetweenChecks ; if ( congestureControl != null ) { congestureControl . configurationUpdate ( ) ; } }


Input:
Generate the concrete sbb Class [CODESPLIT] public void generateConcreteSbb ( ) throws DeploymentException { String sbbAbstractClassName = sbbComponent . getAbstractSbbClass ( ) . getName ( ) ; String sbbConcreteClassName = ConcreteClassGeneratorUtils . getSbbConcreteClassName ( sbbAbstractClassName ) ; sbbConcreteClass = pool . makeClass ( sbbConcreteClassName ) ; try { try { sbbAbstractClass = pool . get ( sbbAbstractClassName ) ; } catch ( NotFoundException nfe ) { throw new DeploymentException ( nfe . getMessage ( ) , nfe ) ; } generateAbstractSbbClassInfo ( ) ; try { ConcreteClassGeneratorUtils . createInterfaceLinks ( sbbConcreteClass , new CtClass [ ] { pool . get ( SbbConcrete . class . getName ( ) ) } ) ; } catch ( NotFoundException nfe ) { throw new DeploymentException ( nfe . getMessage ( ) , nfe ) ; } ConcreteClassGeneratorUtils . createInheritanceLink ( sbbConcreteClass , sbbAbstractClass ) ; abstractMethods = ClassUtils . getAbstractMethodsFromClass ( sbbAbstractClass ) ; superClassesAbstractMethods = ClassUtils . getSuperClassesAbstractMethodsFromClass ( sbbAbstractClass ) ; try { createFields ( new CtClass [ ] { pool . get ( SbbEntity . class . getName ( ) ) , pool . get ( SbbObjectState . class . getName ( ) ) } ) ; CtClass [ ] parameters = new CtClass [ ] { pool . get ( SbbEntity . class . getName ( ) ) } ; createSbbEntityGetterAndSetter ( sbbConcreteClass ) ; createDefaultUsageParameterGetter ( sbbConcreteClass ) ; createNamedUsageParameterGetter ( sbbConcreteClass ) ; createDefaultConstructor ( ) ; createConstructorWithParameter ( parameters ) ; } catch ( NotFoundException nfe ) { logger . error ( "Constructor With Parameter not created" ) ; throw new DeploymentException ( "Constructor not created." , nfe ) ; } SbbAbstractClassDescriptor mSbbAbstractClass = sbbComponent . getDescriptor ( ) . getSbbAbstractClass ( ) ; createCMPAccessors ( mSbbAbstractClass . getCmpFields ( ) ) ; createGetChildRelationsMethod ( mSbbAbstractClass . getChildRelationMethods ( ) . values ( ) ) ; createGetProfileCMPMethods ( mSbbAbstractClass . getProfileCMPMethods ( ) . values ( ) ) ; createFireEventMethods ( sbbComponent . getDescriptor ( ) . getEventEntries ( ) . values ( ) ) ; // GetUsageParametersMethod[] usageParameters= // sbbDeploymentDescriptor.getUsageParametersMethods(); // if the activity context interface has been defined in the // descriptor // file // then generates the concrete class of the activity context // interface // and implements the narrow method if ( sbbComponent . getDescriptor ( ) . getSbbActivityContextInterface ( ) != null ) { Class < ? > activityContextInterfaceClass = null ; try { activityContextInterfaceClass = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( sbbComponent . getDescriptor ( ) . getSbbActivityContextInterface ( ) ) ; } catch ( ClassNotFoundException e2 ) { String s = "Error creating constructor -  class not found" ; logger . error ( s , e2 ) ; throw new DeploymentException ( s , e2 ) ; } // Check the activity context interface for illegal method // names. Method [ ] methods = activityContextInterfaceClass . getMethods ( ) ; ArrayList < String > allSetters = new ArrayList < String > ( ) ; ArrayList < String > missingSetters = new ArrayList < String > ( ) ; if ( methods != null ) { for ( int i = 0 ; i < methods . length ; i ++ ) { if ( ! methods [ i ] . getDeclaringClass ( ) . getName ( ) . equals ( javax . slee . ActivityContextInterface . class . getName ( ) ) && ! methods [ i ] . getDeclaringClass ( ) . getName ( ) . equals ( ActivityContextInterfaceExt . class . getName ( ) ) ) { String methodName = methods [ i ] . getName ( ) ; // setters should have a single parameter and should // return void type. if ( methodName . startsWith ( "set" ) ) { Class < ? > [ ] args = methods [ i ] . getParameterTypes ( ) ; // setter should only have one argument if ( args . length != 1 ) throw new DeploymentException ( "Setter method '" + methodName + "' should only have one argument." ) ; // setter return type should be void Class < ? > returnClass = methods [ i ] . getReturnType ( ) ; if ( ! returnClass . equals ( Void . TYPE ) ) throw new DeploymentException ( "Setter method '" + methodName + "' return type should be void." ) ; allSetters . add ( methodName ) ; } else if ( methodName . startsWith ( "get" ) ) { Class < ? > [ ] args = methods [ i ] . getParameterTypes ( ) ; // getter should have no parameters. if ( args != null && args . length != 0 ) throw new DeploymentException ( "Getter method '" + methodName + "' should have no parameters." ) ; // getter return type should not be void if ( methods [ i ] . getReturnType ( ) . equals ( Void . TYPE ) ) throw new DeploymentException ( "Getter method '" + methodName + "' return type cannot be void." ) ; String setterName = methodName . replaceFirst ( "get" , "set" ) ; try { activityContextInterfaceClass . getMethod ( setterName , methods [ i ] . getReturnType ( ) ) ; } catch ( NoSuchMethodException nsme ) { missingSetters . add ( setterName ) ; } } else { throw new DeploymentException ( "Invalid method '" + methodName + "' in SBB Activity Context Interface." ) ; } } } // Check if the missing setters aren't defined with // different arg for ( String setter : missingSetters ) if ( allSetters . contains ( setter ) ) throw new DeploymentException ( "Getter argument type and" + " setter return type for attribute '" + setter . replaceFirst ( "set" , "" ) . toLowerCase ( ) + "' must be the same." ) ; } /*
				 * CtMethod[] abstractClassMethods =
				 * sbbAbstractClass.getDeclaredMethods();
				 *
				 * for ( int i = 0; i < abstractClassMethods.length; i ++ ) {
				 * CtMethod ctMethod = abstractClassMethods[i]; if ( !
				 * Modifier.isAbstract(ctMethod.getModifiers())) {
				 * this.createMethodWrapper(sbbConcreteClass,ctMethod); } }
				 */ // check if the concrete class has already been generated. // if that the case, the guess is that the concrete class is a // safe // one // and so it is not generated again // avoid also problems of class already loaded from the class // loader //   CtClass activityContextInterface = null ; try { activityContextInterface = pool . get ( activityContextInterfaceClass . getName ( ) ) ; createField ( activityContextInterface , "sbbActivityContextInterface" ) ; this . createSetActivityContextInterfaceMethod ( activityContextInterface ) ; ConcreteActivityContextInterfaceGenerator concreteActivityContextInterfaceGenerator = new ConcreteActivityContextInterfaceGenerator ( activityContextInterfaceClass . getName ( ) , deployDir , pool ) ; Class < ? > concreteActivityContextInterfaceClass = concreteActivityContextInterfaceGenerator . generateActivityContextInterfaceConcreteClass ( ) ; createGetSbbActivityContextInterfaceMethod ( activityContextInterface , concreteActivityContextInterfaceClass ) ; // set the concrete activity context interface class in // the // descriptor if ( logger . isDebugEnabled ( ) ) { logger . debug ( "SETTING ACI concrete class  " + concreteActivityContextInterfaceClass + " in " + sbbComponent ) ; } sbbComponent . setActivityContextInterfaceConcreteClass ( concreteActivityContextInterfaceClass ) ; } catch ( NotFoundException nfe ) { logger . error ( "Narrow Activity context interface method and " + "activity context interface concrete class not created" ) ; throw new DeploymentException ( nfe . getMessage ( ) , nfe ) ; } finally { /*
					 * if (activityContextInterface != null) {
					 * activityContextInterface.detach(); }
					 */ } } // if the sbb local object has been defined in the descriptor file // then generates the concrete class of the sbb local object // and implements the narrow method Class < ? > sbbLocalInterfaceClass = sbbComponent . getSbbLocalInterfaceClass ( ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Sbb Local Object interface :" + sbbLocalInterfaceClass ) ; } if ( sbbLocalInterfaceClass != null && ! sbbLocalInterfaceClass . getName ( ) . equals ( "javax.slee.SbbLocalObject" ) ) { try { pool . get ( sbbLocalInterfaceClass . getName ( ) ) ; ConcreteSbbLocalObjectGenerator concreteSbbLocalObjectGenerator = new ConcreteSbbLocalObjectGenerator ( sbbLocalInterfaceClass . getName ( ) , sbbAbstractClassName , this . deployDir , pool ) ; Class < ? > concreteSbbLocalObjectClass = concreteSbbLocalObjectGenerator . generateSbbLocalObjectConcreteClass ( ) ; // set the sbb Local object class in the descriptor sbbComponent . setSbbLocalInterfaceConcreteClass ( concreteSbbLocalObjectClass ) ; } catch ( NotFoundException nfe ) { String s = "sbb Local Object concrete class not created for interface " + sbbLocalInterfaceClass . getName ( ) ; throw new DeploymentException ( s , nfe ) ; } } // if there is no interface defined in the descriptor for sbb local // object // then the slee implementation is taken else { try { sbbComponent . setSbbLocalInterfaceClass ( SbbLocalObject . class ) ; sbbComponent . setSbbLocalInterfaceConcreteClass ( SbbLocalObjectImpl . class ) ; } catch ( Exception e ) { throw new DeploymentException ( e . getMessage ( ) , e ) ; } } try { sbbConcreteClass . writeFile ( deployDir ) ; // @@2.4+ -> 3.4+ // pool.writeFile(sbbConcreteClassName, deployPath); if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Concrete Class " + sbbConcreteClassName + " generated in the following path " + deployDir ) ; } } catch ( Exception e ) { String s = "Error generating concrete class" ; throw new DeploymentException ( s , e ) ; } Class < ? > clazz = null ; try { clazz = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( sbbConcreteClassName ) ; } catch ( ClassNotFoundException e1 ) { String s = "What the heck?! Could not find generated class. Is it under the chair?" ; throw new DeploymentException ( s , e1 ) ; } // set the concrete class in the descriptor sbbComponent . setConcreteSbbClass ( clazz ) ; } finally { if ( sbbConcreteClass != null ) { sbbConcreteClass . defrost ( ) ; } } // uh uh if ( sbbComponent . getConcreteSbbClass ( ) == null ) { throw new DeploymentException ( "concrete sbb class generation failed and I don't know why, bug bug ?!? :)" ) ; } }


Input: Generates info that indicates if a method from { [CODESPLIT] private void generateAbstractSbbClassInfo ( ) { CtClass sbbClass = null ; try { sbbClass = pool . get ( Sbb . class . getName ( ) ) ; } catch ( NotFoundException e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; } AbstractSbbClassInfo abstractSbbClassInfo = sbbComponent . getAbstractSbbClassInfo ( ) ; for ( CtMethod sbbClassMethod : sbbClass . getDeclaredMethods ( ) ) { for ( CtMethod sbbAbstractClassMethod : sbbAbstractClass . getMethods ( ) ) { if ( sbbAbstractClassMethod . getName ( ) . equals ( sbbClassMethod . getName ( ) ) && sbbAbstractClassMethod . getSignature ( ) . equals ( sbbClassMethod . getSignature ( ) ) ) { // match, save info abstractSbbClassInfo . setInvokeInfo ( sbbAbstractClassMethod . getMethodInfo ( ) . getName ( ) , ! sbbAbstractClassMethod . isEmpty ( ) ) ; break ; } } } }


Input:
Creates a constructor with parameters <BR > For every parameter a field of the same class is created in the concrete class And each field is gonna be initialized with the corresponding parameter [CODESPLIT] protected void createConstructorWithParameter ( CtClass [ ] parameters ) throws DeploymentException { CtConstructor constructorWithParameter = new CtConstructor ( parameters , sbbConcreteClass ) ; String constructorBody = "{" + "this();" ; /*
		 * for (int i = 0; i < parameters.length; i++) { String parameterName =
		 * parameters[i].getName(); parameterName =
		 * parameterName.substring(parameterName .lastIndexOf(".") + 1); String
		 * firstCharLowerCase = parameterName.substring(0, 1) .toLowerCase();
		 * parameterName = firstCharLowerCase.concat(parameterName
		 * .substring(1));
		 *
		 * int paramNumber = i + 1; constructorBody += parameterName + "=$" +
		 * paramNumber + ";"; }
		 */ constructorBody += "this.setSbbEntity($1);" ; constructorBody += "}" ; try { sbbConcreteClass . addConstructor ( constructorWithParameter ) ; constructorWithParameter . setBody ( constructorBody ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "ConstructorWithParameter created" ) ; } } catch ( CannotCompileException e ) { throw new DeploymentException ( e . getMessage ( ) , e ) ; } }


Input: Create a default constructor on the Sbb Concrete Class [CODESPLIT] 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 ) ; } }


Input: Create a default usage parameter getter and setter . [CODESPLIT] 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 ) ; } } }


Input: Create a method to retrive the entity from the SbbObject . [CODESPLIT] 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 ) ; } }


Input: Create the cmp field setters and getters [CODESPLIT] protected void createCMPAccessors ( Collection < CMPFieldDescriptor > cmps ) throws DeploymentException { for ( CMPFieldDescriptor cmp : cmps ) { String fieldName = cmp . getCmpFieldName ( ) ; // Set the first char of the accessor to UpperCase to follow the // javabean requirements fieldName = fieldName . substring ( 0 , 1 ) . toUpperCase ( ) + fieldName . substring ( 1 ) ; String getterMethodName = "get" + fieldName ; CtMethod getterMethod = ( CtMethod ) abstractMethods . get ( getterMethodName ) ; if ( getterMethod == null ) { getterMethod = ( CtMethod ) this . superClassesAbstractMethods . get ( getterMethodName ) ; } if ( getterMethod == null ) { throw new SLEEException ( "can't find abstract method " + getterMethodName ) ; } // generate the acessor method name sufix from type String getterHandlerMethodName = "getCMPFieldOfType" ; boolean getterHandlerMethodNeedResultCast = false ; String setterHandlerMethodName = "setCMPFieldOfType" ; try { CtClass ctClassCmpType = getterMethod . getReturnType ( ) ; if ( ctClassCmpType . isPrimitive ( ) ) { // boolean, byte, char, short, int, long, float, double String ctClassCmpTypeName = ctClassCmpType . getName ( ) ; if ( ctClassCmpTypeName . equals ( boolean . class . getName ( ) ) ) { getterHandlerMethodName += "Boolean" ; } else if ( ctClassCmpTypeName . equals ( byte . class . getName ( ) ) ) { getterHandlerMethodName += "Byte" ; } else if ( ctClassCmpTypeName . equals ( char . class . getName ( ) ) ) { getterHandlerMethodName += "Char" ; } else if ( ctClassCmpTypeName . equals ( short . class . getName ( ) ) ) { getterHandlerMethodName += "Short" ; } else if ( ctClassCmpTypeName . equals ( int . class . getName ( ) ) ) { getterHandlerMethodName += "Integer" ; } else if ( ctClassCmpTypeName . equals ( long . class . getName ( ) ) ) { getterHandlerMethodName += "Long" ; } else if ( ctClassCmpTypeName . equals ( float . class . getName ( ) ) ) { getterHandlerMethodName += "Float" ; } else if ( ctClassCmpTypeName . equals ( double . class . getName ( ) ) ) { getterHandlerMethodName += "Double" ; } else { throw new SLEEException ( "unexpected primitive type " + ctClassCmpTypeName ) ; } getterHandlerMethodNeedResultCast = true ; setterHandlerMethodName += "PrimitiveOrUnknown" ; } else { // aci, event context, sbb local object, profile local object, Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown, array, enum, annotation if ( ! ctClassCmpType . isArray ( ) && ! ctClassCmpType . isEnum ( ) && ! ctClassCmpType . isAnnotation ( ) ) { // aci, event context, sbb local object, profile local object, Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown Class < ? > classCmpType = Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( ctClassCmpType . getName ( ) ) ; if ( javax . slee . ActivityContextInterface . class . isAssignableFrom ( classCmpType ) ) { getterHandlerMethodName += "ActivityContextInterface" ; setterHandlerMethodName += "ActivityContextInterface" ; } else if ( EventContext . class . isAssignableFrom ( classCmpType ) ) { getterHandlerMethodName += "EventContext" ; setterHandlerMethodName += "EventContext" ; } else if ( ProfileLocalObject . class . isAssignableFrom ( classCmpType ) ) { getterHandlerMethodName += "ProfileLocalObject" ; setterHandlerMethodName += "ProfileLocalObject" ; } else if ( SbbLocalObject . class . isAssignableFrom ( classCmpType ) ) { getterHandlerMethodName += "SbbLocalObject" ; setterHandlerMethodName += "SbbLocalObject" ; } else { // Boolean, Byte, Char, Short, Integer, Long, Float, Double, unknown if ( this . initializeReferenceDataTypesWithNull ) { getterHandlerMethodName += "Unknown" ; getterHandlerMethodNeedResultCast = true ; } else { // initialized with 0 String ctClassCmpTypeName = ctClassCmpType . getName ( ) ; if ( ctClassCmpTypeName . equals ( Boolean . class . getName ( ) ) ) { getterHandlerMethodName += "Boolean" ; } else if ( ctClassCmpTypeName . equals ( Byte . class . getName ( ) ) ) { getterHandlerMethodName += "Byte" ; } else if ( ctClassCmpTypeName . equals ( Character . class . getName ( ) ) ) { getterHandlerMethodName += "Char" ; } else if ( ctClassCmpTypeName . equals ( Short . class . getName ( ) ) ) { getterHandlerMethodName += "Short" ; } else if ( ctClassCmpTypeName . equals ( Integer . class . getName ( ) ) ) { getterHandlerMethodName += "Integer" ; } else if ( ctClassCmpTypeName . equals ( Long . class . getName ( ) ) ) { getterHandlerMethodName += "Long" ; } else if ( ctClassCmpTypeName . equals ( Float . class . getName ( ) ) ) { getterHandlerMethodName += "Float" ; } else if ( ctClassCmpTypeName . equals ( Double . class . getName ( ) ) ) { getterHandlerMethodName += "Double" ; } else { getterHandlerMethodName += "Unknown" ; getterHandlerMethodNeedResultCast = true ; } } setterHandlerMethodName += "PrimitiveOrUnknown" ; } } else { // array, enum, annotation == same as unknown getterHandlerMethodName += "Unknown" ; getterHandlerMethodNeedResultCast = true ; setterHandlerMethodName += "PrimitiveOrUnknown" ; } } } catch ( Exception cce ) { throw new SLEEException ( "Cannot determine the cmp type for cmp field named " + fieldName , cce ) ; } try { // copy method from abstract to concrete class CtMethod concreteGetterMethod = CtNewMethod . copy ( getterMethod , sbbConcreteClass , null ) ; // create the method body // FIXED: NPE when accessing not initialized CMP // see https://github.com/RestComm/jain-slee/issues/87 String concreteGetterMethodBody = "{ " + "if (sbbEntity == null) " + "    throw new TransactionRequiredLocalException(\"Cannot get CMP field. SBB entity is null\");" + "return " + ( getterHandlerMethodNeedResultCast ? "($r)" : "" ) + SbbAbstractMethodHandler . class . getName ( ) + "." + getterHandlerMethodName + "(sbbEntity,\"" + cmp . getCmpFieldName ( ) + "\");" + " }" ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Generated method " + getterMethodName + " , body = " + concreteGetterMethodBody ) ; } concreteGetterMethod . setBody ( concreteGetterMethodBody ) ; sbbConcreteClass . addMethod ( concreteGetterMethod ) ; } catch ( Exception cce ) { throw new SLEEException ( "Cannot compile method " + getterMethod . getName ( ) , cce ) ; } String setterMethodName = "set" + fieldName ; CtMethod setterMethod = ( CtMethod ) abstractMethods . get ( setterMethodName ) ; if ( setterMethod == null ) { setterMethod = ( CtMethod ) this . superClassesAbstractMethods . get ( setterMethodName ) ; } if ( setterMethod == null ) { throw new SLEEException ( "can't find abstract method " + setterMethodName ) ; } try { // copy method from abstract to concrete class CtMethod concreteSetterMethod = CtNewMethod . copy ( setterMethod , sbbConcreteClass , null ) ; // create the method body // FIXED: NPE when accessing not initialized CMP // see https://github.com/RestComm/jain-slee/issues/87 String concreteSetterMethodBody = "{ " + "if (sbbEntity == null) " + "    throw new TransactionRequiredLocalException(\"Cannot set CMP field. SBB entity is null\");" + SbbAbstractMethodHandler . class . getName ( ) + "." + setterHandlerMethodName + "(sbbEntity,\"" + cmp . getCmpFieldName ( ) + "\",$1); }" ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Generated method " + setterMethodName + " , body = " + concreteSetterMethodBody ) ; } concreteSetterMethod . setBody ( concreteSetterMethodBody ) ; sbbConcreteClass . addMethod ( concreteSetterMethod ) ; } catch ( CannotCompileException cce ) { throw new SLEEException ( "Cannot compile method " + getterMethod . getName ( ) , cce ) ; } } }


Input: Create the implementation of the fire event methods [CODESPLIT] 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 ) ; } } } } }


Input: Create the get child relation method ( this method redirects the call to a child relation interceptor ) [CODESPLIT] protected void createGetChildRelationsMethod ( Collection < GetChildRelationMethodDescriptor > childRelations ) { if ( childRelations == null ) return ; for ( GetChildRelationMethodDescriptor childRelation : childRelations ) { String methodName = childRelation . getChildRelationMethodName ( ) ; 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 " + SbbAbstractMethodHandler . class . getName ( ) + ".getChildRelation(sbbEntity,\"" + methodName + "\"); }" ; 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 ) ; } } } }


Input: Create the get profile CMP method ( this method redirects the call to a profile cmp interceptor ) [CODESPLIT] protected void createGetProfileCMPMethods ( Collection < GetProfileCMPMethodDescriptor > cmpProfiles ) { if ( cmpProfiles == null ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "no CMP Profile method implementation to generate." ) ; } return ; } for ( GetProfileCMPMethodDescriptor cmpProfile : cmpProfiles ) { String methodName = cmpProfile . getProfileCmpMethodName ( ) ; 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 " + SbbAbstractMethodHandler . class . getName ( ) + ".getProfileCMPMethod(sbbEntity,\"" + methodName + "\",$1); }" ; 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 ) ; } } }


Input: Create the narrow method to get the activity context interface [CODESPLIT] 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 ) ; } }


Input: Add a query expression to this composite expression . [CODESPLIT] 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 ) ; }


Input: Check whether the specified expression contains a reference either direct or indirect to this expression . [CODESPLIT] void checkForCycles ( QueryExpression expr ) throws IllegalArgumentException { // is the expression argument equal to this? if ( expr == this ) throw new IllegalArgumentException ( "Cyclic expression detected" ) ; // recurse through all nested expressions that are composite expressions for ( int i = 0 ; i < exprs . size ( ) ; i ++ ) { QueryExpression nested = ( QueryExpression ) exprs . get ( i ) ; if ( nested instanceof CompositeQueryExpression ) { ( ( CompositeQueryExpression ) nested ) . checkForCycles ( expr ) ; } else if ( nested instanceof Not ) { ( ( Not ) nested ) . checkForCycles ( expr ) ; } } }


Input: Place an object into the NonSerializableFactory namespace for subsequent access by getObject . There cannot be an already existing binding for key . [CODESPLIT] 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 ) ; }


Input: Remove a binding from the NonSerializableFactory map . [CODESPLIT] public static void unbind ( String key ) throws NameNotFoundException { if ( wrapperMap . remove ( key ) == null ) throw new NameNotFoundException ( key + " was not found in the NonSerializableFactory map" ) ; }


Input: Remove a binding from the NonSerializableFactory map . [CODESPLIT] public static void unbind ( Name name ) throws NameNotFoundException { String key = name . toString ( ) ; if ( wrapperMap . remove ( key ) == null ) throw new NameNotFoundException ( key + " was not found in the NonSerializableFactory map" ) ; }


Input: 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 . [CODESPLIT] public static synchronized void rebind ( Name name , Object target ) throws NamingException { rebind ( name , target , false ) ; }


Input:
--- End ObjectFactory interface methods [CODESPLIT] private static Context createSubcontext ( Context ctx , Name name ) throws NamingException { Context subctx = ctx ; for ( int pos = 0 ; pos < name . size ( ) ; pos ++ ) { String ctxName = name . get ( pos ) ; try { subctx = ( Context ) ctx . lookup ( ctxName ) ; } catch ( NameNotFoundException e ) { subctx = ctx . createSubcontext ( ctxName ) ; } // The current subctx will be the ctx for the next name component
 ctx = subctx ; } return subctx ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setLoggerLevel ( String loggerName , String level ) throws ManagementConsoleException { sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . setLoggerLevel ( loggerName , level ) ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] public LoggerInfo fetchLoggerInfo ( String loggerName ) throws ManagementConsoleException { if ( ! sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getLoggerNames ( null ) . contains ( loggerName ) ) sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . addLogger ( loggerName , Level . OFF ) ; int handlerNum = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . numberOfHandlers ( loggerName ) ; String _name = loggerName ; String _level = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getLoggerLevel ( loggerName ) ; boolean _parent = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getUseParentHandlersFlag ( loggerName ) ; String _filter = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getLoggerFilterClassName ( loggerName ) ; HandlerInfo [ ] hInfos = new HandlerInfo [ handlerNum ] ; for ( int i = 0 ; i < handlerNum ; i ++ ) { String _formatterClass = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getGenericHandlerFormatterClassName ( loggerName , i ) ; String _filterClass = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getGenericHandlerFilterClassName ( loggerName , i ) ; String _h_level = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getGenericHandlerLevel ( loggerName , i ) ; String _h_name = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getHandlerName ( loggerName , i ) ; String _h_className = sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . getHandlerClassName ( loggerName , i ) ; // Add fetch for other options
 HandlerInfo hi = new HandlerInfo ( i , ( _h_name == null ? "" : _h_name ) , _filterClass , _formatterClass , _h_className , _h_level , new HashMap ( ) ) ; hInfos [ i ] = hi ; } return new LoggerInfo ( _parent , _name , _filter , _level , hInfos ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setUseParentHandlers ( String loggerName , boolean value ) throws ManagementConsoleException { sleeConnection . getSleeManagementMBeanUtils ( ) . getLogManagementMBeanUtils ( ) . setUseParentHandlersFlag ( loggerName , value ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public Level getTraceLevel ( ComponentID componentId ) throws NullPointerException , UnrecognizedComponentException , FacilityException { checkComponentID ( componentId ) ; return this . traceLevelTable . get ( componentId ) . getLevel ( ) ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] public void createTrace ( ComponentID componentId , Level level , String messageType , String message , long timeStamp ) throws NullPointerException , IllegalArgumentException , UnrecognizedComponentException , FacilityException { if ( log . isDebugEnabled ( ) ) { log . debug ( "createTrace: " + componentId + " level = " + level + " messageType " + messageType + " message " + message + " timeStamp " + timeStamp ) ; } checkComponentID ( componentId ) ; MTraceLevel tl = this . traceLevelTable . get ( componentId ) ; this . notificationTypes . add ( messageType ) ; if ( tl == null ) throw new UnrecognizedComponentException ( "Could not find " + componentId ) ; Level lev = tl . getLevel ( ) ; int seqno = tl . getSeqno ( ) ; if ( lev . isOff ( ) ) return ; // Check if we should log this message.
 // if (level.isHigherLevel(lev)) {
 if ( ! lev . isHigherLevel ( level ) ) { TraceNotification traceNotification = new TraceNotification ( traceMBeanImpl , messageType , componentId , level , message , null , seqno , timeStamp ) ; this . traceMBeanImpl . sendNotification ( traceNotification ) ; } }


Input:
Private ------------------------------------------------------- [CODESPLIT] private void gatherInfoFromURL ( URL url ) throws MalformedURLException { // Weird VFS behavior... returns jar:file:...jar!/
 if ( url . getProtocol ( ) . equals ( "jar" ) ) { this . url = new URL ( url . getFile ( ) . replaceFirst ( "!/" , "/" ) ) ; } else { this . url = url ; } this . fullPath = this . url . getFile ( ) ; this . fileName = getFileNameInternal ( fullPath ) ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] @ Override public void writeExternal ( ObjectOutput out ) throws IOException { if ( this . serializedEvent == null ) { throw new IOException ( "No serialized event set." ) ; } // add id?
 out . writeInt ( this . serializedEvent . length ) ; out . write ( this . serializedEvent ) ; out . flush ( ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ Override public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { int len = in . readInt ( ) ; this . serializedEvent = new byte [ len ] ; in . readFully ( serializedEvent ) ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] public void endActivity ( ) throws TransactionRequiredLocalException , SLEEException { // Check if in valid context.
 if ( logger . isDebugEnabled ( ) ) { logger . debug ( "NullActivity.endActivity()" ) ; } sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; sleeContainer . getActivityContextFactory ( ) . getActivityContext ( new NullActivityContextHandle ( handle ) ) . endActivity ( ) ; }


Input: Check whether the specified expression contains a reference either direct or indirect to this expression . [CODESPLIT] void checkForCycles ( QueryExpression expr ) throws IllegalArgumentException { // is the expression argument equal to this? if ( expr == this ) throw new IllegalArgumentException ( "Cyclic expression detected" ) ; // recurse through nested expression if it's a composite expression QueryExpression nested = this . expr ; if ( nested instanceof CompositeQueryExpression ) { ( ( CompositeQueryExpression ) nested ) . checkForCycles ( expr ) ; } else if ( nested instanceof Not ) { ( ( Not ) nested ) . checkForCycles ( expr ) ; } }


Input:
Decorate the abstract sbb Class [CODESPLIT] 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 ; } }


Input: Invokers for the simple types [CODESPLIT] public void invokeAndReturnvoid ( SbbConcrete proxy , String methodName , Object [ ] args , Class < ? > [ ] argTypes ) throws Exception { invokeAndReturnObject ( proxy , methodName , args , argTypes ) ; }


Input: Create a constructor . This method simply records the input parameters in appropriately named fields . [CODESPLIT] private void createConstructor ( CtClass concreteClass , CtClass sleeContainerClass , CtClass resourceAdaptorTypeIDClass ) throws Exception { CtConstructor ctCons = new CtConstructor ( new CtClass [ ] { sleeContainerClass , resourceAdaptorTypeIDClass } , concreteClass ) ; ctCons . setBody ( "{ super($1,$2); }" ) ; concreteClass . addConstructor ( ctCons ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setTimeBetweenLivenessQueries ( long set ) { acFactory . getConfiguration ( ) . setTimeBetweenLivenessQueries ( set ) ; if ( set == 0 ) { cancelLivenessQuery ( ) ; } else { if ( scheduledFuture == null ) { scheduleLivenessQuery ( ) ; } } }


Input:
--- OPERATIONS [CODESPLIT] public void endActivity ( ActivityContextHandle ach ) throws ManagementException { // Again this is tx method
 logger . info ( "Trying to stop null activity[" + ach + "]!!" ) ; ActivityContext ac = acFactory . getActivityContext ( ach ) ; if ( ac == null ) { logger . debug ( "There is no ac associated with given acID[" + ach + "]!!" ) ; throw new ManagementException ( "Can not find AC for given ID[" + ach + "], try again!!!" ) ; } if ( ac . getActivityContextHandle ( ) . getActivityType ( ) == ActivityType . NULL ) { logger . debug ( "Scheduling activity end for acID[" + ach + "]" ) ; NullActivity nullActivity = ( NullActivity ) ac . getActivityContextHandle ( ) . getActivityObject ( ) ; if ( nullActivity != null ) { nullActivity . endActivity ( ) ; } } else { logger . debug ( "AC is not null activity context" ) ; throw new IllegalArgumentException ( "Given ID[" + ach + "] does not point to NullActivity" ) ; } }


Input:
This is main place where SLEE is accessed . This functions lists AC in various different ways . It can either return Object [] of arrays representing AC of simple Object [] that in fact contains String objects representing IDs of Activity Contexts [CODESPLIT] private Object [ ] listWithCriteria ( boolean listIDsOnly , boolean inDetails , int criteria , String comparisonCriteria ) { logger . info ( "Listing with criteria[" + criteria + "] with details[" + inDetails + "] only IDS[" + listIDsOnly + "]" ) ; Iterator < ActivityContextHandle > it = this . acFactory . getAllActivityContextsHandles ( ) . iterator ( ) ; ArrayList < Object > lst = new ArrayList < Object > ( ) ; // Needed by LIST_BY_SBBID
 HashMap < SbbEntityID , SbbID > sbbEntityIdToSbbID = new HashMap < SbbEntityID , SbbID > ( ) ; while ( it . hasNext ( ) ) { ActivityContextHandle achOrig = it . next ( ) ; //JmxActivityContextHandle ach = ActivityContextHandleSerializer.encode(achOrig);
 ActivityContextImpl ac = this . acFactory . getActivityContext ( achOrig ) ; if ( ac == null ) { continue ; } Object activity = achOrig . getActivityObject ( ) ; if ( activity != null ) { String acId = ac . getStringID ( ) ; String acSource = achOrig . getActivityType ( ) == ActivityType . RA ? ( ( ResourceAdaptorActivityContextHandle ) achOrig ) . getResourceAdaptorEntity ( ) . getName ( ) : "" ; switch ( criteria ) { case LIST_BY_ACTIVITY_CLASS : if ( ! activity . getClass ( ) . getCanonicalName ( ) . equals ( comparisonCriteria ) ) { ac = null ; // we dont want this one here
 } break ; case LIST_BY_RAENTITY : if ( achOrig . getActivityType ( ) == ActivityType . RA ) { if ( ! acSource . equals ( comparisonCriteria ) ) ac = null ; } else ac = null ; break ; case LIST_BY_SBBENTITY : for ( SbbEntityID sbbEntityID : ac . getSbbAttachmentSet ( ) ) { if ( sbbEntityID . toString ( ) . equals ( comparisonCriteria ) ) { break ; } } ac = null ; break ; case LIST_BY_SBBID : ComponentIDPropertyEditor propertyEditor = new ComponentIDPropertyEditor ( ) ; propertyEditor . setAsText ( comparisonCriteria ) ; SbbID idBeingLookedUp = ( SbbID ) propertyEditor . getValue ( ) ; boolean match = false ; SbbID implSbbID = null ; for ( SbbEntityID sbbEntityID : ac . getSbbAttachmentSet ( ) ) { if ( sbbEntityIdToSbbID . containsKey ( sbbEntityID ) ) { implSbbID = sbbEntityIdToSbbID . get ( sbbEntityID ) ; } else { SbbEntity sbbe = sbbEntityFactory . getSbbEntity ( sbbEntityID , false ) ; if ( sbbe == null ) { continue ; } implSbbID = sbbe . getSbbId ( ) ; sbbEntityIdToSbbID . put ( sbbEntityID , implSbbID ) ; } if ( ! implSbbID . equals ( idBeingLookedUp ) ) { match = false ; continue ; } else { match = true ; break ; } } if ( ! match ) { ac = null ; } break ; case LIST_BY_NO_CRITERIA : break ; default : continue ; } if ( ac == null ) continue ; // Now we have to check - if we want only IDS
 Object singleResult = null ; if ( ! listIDsOnly ) { logger . debug ( "Adding AC[" + acId + "]" ) ; Object [ ] o = getDetails ( ac ) ; if ( ! inDetails ) { // This is stupid, but can save some bandwith, not sure if
 // we
 // should care. But Console is java script, and
 // sometimes that can be pain, so lets ease it
 o [ SBB_ATTACHMENTS ] = Integer . toString ( ( ( Object [ ] ) o [ SBB_ATTACHMENTS ] ) . length ) ; o [ NAMES_BOUND_TO ] = Integer . toString ( ( ( Object [ ] ) o [ NAMES_BOUND_TO ] ) . length ) ; o [ TIMERS_ATTACHED ] = Integer . toString ( ( ( Object [ ] ) o [ TIMERS_ATTACHED ] ) . length ) ; o [ DATA_PROPERTIES ] = Integer . toString ( ( ( Object [ ] ) o [ DATA_PROPERTIES ] ) . length ) ; } singleResult = o ; } else { singleResult = acId ; } lst . add ( singleResult ) ; } } if ( lst . isEmpty ( ) ) return null ; logger . info ( "RETURN SIZE[" + lst . size ( ) + "]" ) ; Object [ ] ret = new Object [ lst . size ( ) ] ; ret = lst . toArray ( ret ) ; return ret ; }


Input:
/ * FIXME uncomment code when everything is commited [CODESPLIT] @ SuppressWarnings ( "rawtypes" ) private Object [ ] getDetails ( ActivityContextImpl ac ) { logger . debug ( "Retrieveing details for acID[" + ac . getActivityContextHandle ( ) + "]" ) ; Object [ ] o = new Object [ ARRAY_SIZE ] ; ActivityContextHandle achOrig = ac . getActivityContextHandle ( ) ; //JmxActivityContextHandle ach = ActivityContextHandleSerializer.encode(achOrig);
 String acId = ac . getStringID ( ) ; o [ ActivityManagementMBeanImplMBean . AC_ID ] = acId ; logger . debug ( "======[getDetails][" + o [ ActivityManagementMBeanImplMBean . AC_ID ] + "][" + ac . hashCode ( ) + "]" ) ; if ( achOrig . getActivityType ( ) == ActivityType . RA ) { o [ RA ] = ( ( ResourceAdaptorActivityContextHandle ) achOrig ) . getResourceAdaptorEntity ( ) . getName ( ) ; } o [ ACTIVITY_CLASS ] = achOrig . getActivityObject ( ) . getClass ( ) . getName ( ) ; logger . debug ( "======[getDetails][ACTIVITY_CLASS][" + o [ ACTIVITY_CLASS ] + "]" ) ; // Date d = new Date(ac.getLastAccessTime());
 // o[LAST_ACCESS_TIME] = d;
 o [ LAST_ACCESS_TIME ] = ac . getLastAccessTime ( ) + "" ; logger . debug ( "======[getDetails][LAST_ACCESS_TIME][" + o [ LAST_ACCESS_TIME ] + "][" + new Date ( Long . parseLong ( ( String ) o [ LAST_ACCESS_TIME ] ) ) + "]" ) ; Set < SbbEntityID > sbbAttachmentSet = ac . getSbbAttachmentSet ( ) ; String [ ] tmp = new String [ sbbAttachmentSet . size ( ) ] ; Iterator < ? > it = sbbAttachmentSet . iterator ( ) ; int counter = 0 ; while ( it . hasNext ( ) ) { tmp [ counter ++ ] = it . next ( ) . toString ( ) ; } o [ SBB_ATTACHMENTS ] = tmp ; Set < String > nameBindindsSet = ac . getNamingBindings ( ) ; tmp = new String [ nameBindindsSet . size ( ) ] ; tmp = nameBindindsSet . toArray ( tmp ) ; o [ NAMES_BOUND_TO ] = tmp ; Set < TimerID > attachedTimersSet = ac . getAttachedTimers ( ) ; tmp = new String [ attachedTimersSet . size ( ) ] ; it = attachedTimersSet . iterator ( ) ; counter = 0 ; while ( it . hasNext ( ) ) { tmp [ counter ++ ] = ( ( TimerID ) it . next ( ) ) . toString ( ) ; } o [ TIMERS_ATTACHED ] = tmp ; Map m = ac . getDataAttributes ( ) ; tmp = new String [ m . size ( ) ] ; it = m . keySet ( ) . iterator ( ) ; counter = 0 ; while ( it . hasNext ( ) ) { Object k = it . next ( ) ; Object v = m . get ( k ) ; tmp [ counter ++ ] = k + "=" + v ; } o [ DATA_PROPERTIES ] = tmp ; return o ; }


Input: not exist? [CODESPLIT] public Object [ ] retrieveActivityContextIDByActivityType ( String fullQualifiedActivityClassName ) { logger . info ( "Retrieving AC by activity class name[" + fullQualifiedActivityClassName + "]" ) ; return listWithCriteria ( true , true , LIST_BY_ACTIVITY_CLASS , fullQualifiedActivityClassName ) ; }


Input: Computes the real aci data field name [CODESPLIT] 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 ; }


Input: Sets an sbb aci data field value [CODESPLIT] public void setFieldValue ( String fieldName , Object value ) { String realFieldName = getRealFieldName ( fieldName ) ; aciImpl . getActivityContext ( ) . setDataAttribute ( realFieldName , value ) ; }


Input: Retrieves an sbb aci data field value [CODESPLIT] 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 ; }