signature:
public class AbstractSleeComponent { /** * Indicates that the component was undeployed and thus should clean up any resources */
public void undeployed ( ) { } }

implementation: classLoader = null ; if ( classLoaderDomain != null ) { classLoaderDomain . clear ( ) ; classLoaderDomain = null ; } if ( classPool != null ) { classPool . clean ( ) ; classPool = null ; } if ( permissions != null ) { permissions . clear ( ) ; permissions = null ; }


signature:
public class SleeContainerDeployerImpl { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . deployment . InternalDeployer # init ( java . net
 * . URL ) */
public void init ( URL deployableUnitURL , String deployableUnitName ) throws DeploymentException { } }

implementation: synchronized ( this ) { if ( ! shutdown ) { sleeSubDeployer . init ( deployableUnitURL , deployableUnitName ) ; } }


signature:
public class SleeContainerDeployerImpl { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . deployment . InternalDeployer # start ( java . net
 * . URL ) */
public void start ( URL deployableUnitURL , String deployableUnitName ) throws DeploymentException { } }

implementation: synchronized ( this ) { if ( ! shutdown ) { sleeSubDeployer . start ( deployableUnitURL , deployableUnitName ) ; } else { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Ignoring deploy invoked from external deployer, SLEE in shutdown" ) ; } }


signature:
public class ServiceLookupFacilityImpl { /** * Creates a { @ link ReceivableServiceImpl } instance from the specified
 * service component
 * @ param serviceComponent
 * @ return */
private ReceivableService createReceivableService ( ServiceComponent serviceComponent ) { } }

implementation:
ComponentRepository componentRepository = container . getComponentRepository ( ) ; HashSet < ReceivableEvent > resultSet = new HashSet < ReceivableEvent > ( ) ; for ( SbbID sbbID : serviceComponent . getSbbIDs ( componentRepository ) ) { SbbComponent sbbComponent = componentRepository . getComponentByID ( sbbID ) ; for ( EventEntryDescriptor eventEntry : sbbComponent . getDescriptor ( ) . getEventEntries ( ) . values ( ) ) { EventTypeID eventTypeID = eventEntry . getEventReference ( ) ; final Set < EventTypeID > allowedEventTypes = raEntity . getAllowedEventTypes ( ) ; if ( allowedEventTypes == null || allowedEventTypes . contains ( eventTypeID ) ) { /* * The Service Lookup Facility will only return Service
 * event type information forthe event types referenced by
 * the resource adaptor types implemented by the Resource
 * Adaptor . */
ReceivableEventImpl receivableEventImpl = new ReceivableEventImpl ( eventTypeID , eventEntry . getResourceOption ( ) , eventEntry . isInitialEvent ( ) ) ; // add it if it ' s not in the set or if it is but initial
// event is set ( this way if there is a conflict the one
// with initial as true wins )
if ( ! resultSet . contains ( receivableEventImpl ) || receivableEventImpl . isInitialEvent ( ) ) { resultSet . add ( receivableEventImpl ) ; } } } } return new ReceivableServiceImpl ( serviceComponent . getServiceID ( ) , resultSet . toArray ( new ReceivableEventImpl [ resultSet . size ( ) ] ) ) ;


signature:
public class SleeEndpointStartActivityNotTransactedExecutor { /** * Executes a non transacted start activity operation .
 * @ param handle
 * @ param activityFlags
 * @ throws SLEEException */
void execute ( final ActivityHandle handle , final int activityFlags , boolean suspendActivity ) throws SLEEException { } }

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


signature:
public class QueryCollator { /** * Get the { @ link Collator java . text . Collator } described by this
 * < code > QueryCollator < / code > object .
 * @ return the < code > Collator < / code > described by this object . */
public Collator getCollator ( ) { } }

implementation: if ( collator == null ) { collator = Collator . getInstance ( locale ) ; if ( hasStrength ) collator . setStrength ( strength ) ; if ( hasDecomposition ) collator . setDecomposition ( decomposition ) ; } return collator ;


signature: public class JPAQueryBuilder { public static QueryWrapper parseDynamicQuery ( QueryExpression query ) { } }

implementation: ArrayList < Object > params = new ArrayList < Object > ( ) ; long s = System . currentTimeMillis ( ) ; String sqlQuery = "SELECT * " + parseDynamicQuery ( query , 0 , null , params ) ; logger . info ( "Query :: SQL[" + sqlQuery + "]" ) ; long e = System . currentTimeMillis ( ) ; logger . info ( "Query :: Parsed in " + ( e - s ) + "ms." ) ; return new QueryWrapper ( sqlQuery , params ) ;


signature: public class JPAQueryBuilder { private static String replaceLast ( String sourceString , String toBeReplaced , String replacement ) { } }

implementation: StringBuilder x = new StringBuilder ( sourceString ) ; int liof = x . lastIndexOf ( toBeReplaced ) ; if ( liof >= 0 ) x . replace ( liof , liof + 4 , replacement ) ; return new String ( x ) ;


signature:
public class UsageInterfaceValidator { /** * This methods validate component which has usage parameter interface . Its
 * interface for methods . In case of 1.1 components parameters list must
 * match evey method defined . In case of 1.0 components parameters list MUST
 * be empty . It does not validate get usage method , those
 * @ param isSlee11
 * @ param usageInterface
 * - interface class itself
 * @ param parameters
 * - list of parameters , in case of 1.0 sbb this MUST be null .
 * @ return */
static boolean validateUsageParameterInterface ( ComponentID id , boolean isSlee11 , Class < ? > usageInterface , List < UsageParameterDescriptor > parameters ) { } }

implementation:
boolean passed = true ; String errorBuffer = new String ( "" ) ; try { if ( ! usageInterface . isInterface ( ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Usage parameter interface class is not an interface" , "11.2" , errorBuffer ) ; return passed ; } // Interface constraints
if ( isSlee11 && usageInterface . getPackage ( ) == null ) { passed = false ; errorBuffer = appendToBuffer ( id , "Usage parameter interface must be declared in pacakge name space." , "11.2" , errorBuffer ) ; } if ( ! Modifier . isPublic ( usageInterface . getModifiers ( ) ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Usage parameter interface must be declared as public." , "11.2" , errorBuffer ) ; } // parameters check
Set < String > ignore = new HashSet < String > ( ) ; ignore . add ( "java.lang.Object" ) ; Map < String , Method > interfaceMethods = ClassUtils . getAllInterfacesMethods ( usageInterface , ignore ) ; Map < String , UsageParameterDescriptor > localParametersMap = new HashMap < String , UsageParameterDescriptor > ( ) ; Set < String > identifiedIncrement = new HashSet < String > ( ) ; Set < String > identifiedGetIncrement = new HashSet < String > ( ) ; Set < String > identifiedSample = new HashSet < String > ( ) ; Set < String > identifiedGetSample = new HashSet < String > ( ) ; // this is for 1.1 , get and increment methods must match with type
// validate parameter names if we are slee11
if ( isSlee11 ) for ( UsageParameterDescriptor usage : parameters ) { char c = usage . getName ( ) . charAt ( 0 ) ; if ( ! Character . isLowerCase ( c ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Parameter name must start with lower case character and be start of valid jva identifier, parameter name from descriptor: " + usage . getName ( ) , "11.2" , errorBuffer ) ; } localParametersMap . put ( usage . getName ( ) , usage ) ; } // at the end we have to have empty list
for ( Entry < String , Method > entry : interfaceMethods . entrySet ( ) ) { // String declaredLongMethodName = entry . getKey ( ) ;
Method m = entry . getValue ( ) ; String declaredMethodName = m . getName ( ) ; String declaredPrameterName = null ; Character c = null ; // he we just do checks , methods against constraints
// we remove them from parameters map , there is something left
// or not present in map in case of 1.1
// some variable that we need to store info about method
boolean isIncrement = false ; boolean isGetIncrement = false ; boolean isGetSample = false ; boolean isSample = false ; // 1.0 comp
if ( declaredMethodName . startsWith ( _SAMPLE_METHOD_PREFIX ) ) { declaredPrameterName = declaredMethodName . replaceFirst ( _SAMPLE_METHOD_PREFIX , "" ) ; c = declaredPrameterName . charAt ( 0 ) ; isSample = true ; // 1.0 comp
} else if ( declaredMethodName . startsWith ( _INCREMENT_METHOD_PREFIX ) ) { declaredPrameterName = declaredMethodName . replaceFirst ( _INCREMENT_METHOD_PREFIX , "" ) ; c = declaredPrameterName . charAt ( 0 ) ; isIncrement = true ; // 1.1 only
} else if ( declaredMethodName . startsWith ( _GET_METHOD_PREFIX ) ) { declaredPrameterName = declaredMethodName . replaceFirst ( _GET_METHOD_PREFIX , "" ) ; c = declaredPrameterName . charAt ( 0 ) ; if ( ! isSlee11 ) { passed = false ; errorBuffer = appendToBuffer ( id , "Wrong method declared in parameter usage interface. Get method for counter parameter types are allowed only in JSLEE 1.1, method: " + declaredMethodName , "11.2.X" , errorBuffer ) ; } if ( m . getReturnType ( ) . getName ( ) . compareTo ( "javax.slee.usage.SampleStatistics" ) == 0 ) { isGetSample = true ; } else { // we asume thats increment get
isGetIncrement = true ; } } else { passed = false ; errorBuffer = appendToBuffer ( id , "Wrong method decalred in parameter usage interface. Methods must start with either \"get\", \"sample\" or \"increment\", method: " + declaredMethodName , "11.2.X" , errorBuffer ) ; continue ; } if ( ! Character . isUpperCase ( c ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Method stripped of prefix, either \"get\", \"sample\" or \"increment\", must have following upper case character,method: " + declaredMethodName , "11.2" , errorBuffer ) ; } declaredPrameterName = Introspector . decapitalize ( declaredPrameterName ) ; if ( ! isValidJavaIdentifier ( declaredPrameterName ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Parameter name must be valid java identifier: " + declaredPrameterName , "11.2" , errorBuffer ) ; } // well we have indentified parameter , lets store ;
if ( isIncrement ) { if ( identifiedIncrement . contains ( declaredMethodName ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Duplicate declaration of usage parameter, possibly twe methods with the same name and different signature, method: " + declaredMethodName , "11.2" , errorBuffer ) ; } else { identifiedIncrement . add ( declaredPrameterName ) ; if ( ! validateParameterSetterSignatureMethod ( id , m , "11.2.3" ) ) { passed = false ; } } } else if ( isGetIncrement ) { if ( identifiedGetIncrement . contains ( declaredMethodName ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Duplicate declaration of usage parameter, possibly twe methods with the same name and different signature, method: " + declaredMethodName , "11.2" , errorBuffer ) ; } else { identifiedGetIncrement . add ( declaredPrameterName ) ; if ( ! validateParameterGetterSignatureMethod ( id , m , "11.2.2" , Long . TYPE ) ) { passed = false ; } } } else if ( isGetSample ) { if ( identifiedGetSample . contains ( declaredMethodName ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Duplicate declaration of usage parameter, possibly twe methods with the same name and different signature, method: " + declaredMethodName , "11.2" , errorBuffer ) ; } else { identifiedGetSample . add ( declaredPrameterName ) ; if ( ! validateParameterGetterSignatureMethod ( id , m , "11.2.4" , javax . slee . usage . SampleStatistics . class ) ) { passed = false ; } } } else if ( isSample ) { if ( identifiedSample . contains ( declaredMethodName ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Duplicate declaration of usage parameter, possibly twe methods with the same name and different signature, method: " + declaredMethodName , "11.2" , errorBuffer ) ; } else { identifiedSample . add ( declaredPrameterName ) ; if ( ! validateParameterSetterSignatureMethod ( id , m , "11.2.1" ) ) { passed = false ; errorBuffer = appendToBuffer ( id , "Duplicate declaration of usage parameter, possibly twe methods with the same name and different signature, method: " + declaredMethodName , "11.2" , errorBuffer ) ; } } } // UFFF , lets start the play
// / uh its a bit complicated
} // we siganture here is ok , return types also , no duplicates , left :
// 1 . cross check field types that we found - sample vs increments -
// there cant be doubles
// 2 . remove all from list , if something is left , bam , we lack one
// method or have to many : )
Set < String > agregatedIncrement = new HashSet < String > ( ) ; Set < String > agregatedSample = new HashSet < String > ( ) ; agregatedIncrement . addAll ( identifiedGetIncrement ) ; agregatedIncrement . addAll ( identifiedIncrement ) ; agregatedSample . addAll ( identifiedGetSample ) ; agregatedSample . addAll ( identifiedSample ) ; Set < String > tmp = new HashSet < String > ( agregatedSample ) ; tmp . retainAll ( agregatedIncrement ) ; if ( ! tmp . isEmpty ( ) ) { // ugh , its the end
passed = false ; errorBuffer = appendToBuffer ( id , "Usage parameters can be associated only with single type - increment or sample, offending parameters: " + Arrays . toString ( tmp . toArray ( ) ) , "11.2" , errorBuffer ) ; return passed ; } if ( isSlee11 ) { tmp . clear ( ) ; tmp . addAll ( agregatedSample ) ; tmp . addAll ( agregatedIncrement ) ; // localParametersMap . size ( ) ! = 0 - cause we can have zero of them
// - usage - parameter may not be present so its generation is
// turned off
if ( localParametersMap . size ( ) != tmp . size ( ) && localParametersMap . size ( ) != 0 ) { passed = false ; String errorPart = null ; if ( localParametersMap . size ( ) > tmp . size ( ) ) { // is there any bettter way ?
for ( String s : localParametersMap . keySet ( ) ) tmp . remove ( s ) ; errorPart = "More parameters are defined in descriptor, offending parameters: " + Arrays . toString ( tmp . toArray ( ) ) ; } else { for ( String s : tmp ) localParametersMap . remove ( s ) ; errorPart = "More parameters are defined in descriptor, offending parameters: " + Arrays . toString ( localParametersMap . keySet ( ) . toArray ( ) ) ; } errorBuffer = appendToBuffer ( id , "Failed to map descriptor defined usage parameters against interface class methods. " + errorPart , "11.2" , errorBuffer ) ; } } } finally { if ( ! passed ) { logger . error ( errorBuffer ) ; // System . err . println ( errorBuffer ) ;
} } return passed ;


signature:
public class ClassUtils { /** * Searches for provided interface in passed Class object - it can be class
 * or interface . If it finds , it return instance of it .
 * @ param classOrInterfaceWithInterfaces
 * @ param interfaceSearched
 * @ return */
public static Class checkInterfaces ( Class classOrInterfaceWithInterfaces , String interfaceSearched ) { } }

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


signature:
public class ClassUtils { /** * Returns methods of this interface and all super interfaces
 * @ param ctInterfaceClass
 * @ return */
public static Map < String , Method > getAllInterfacesMethods ( Class xInterfaceClass , Set < String > ignore ) { } }

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


signature: public class ClassUtils { public static Method getMethodFromMap ( String name , Class [ ] parameters , Map < String , Method > ... methods ) { } }

implementation: String key = name + Arrays . toString ( parameters ) ; for ( Map < String , Method > m : methods ) { if ( m . containsKey ( key ) ) { return m . get ( key ) ; } else { } } return null ;


signature:
public class SleeDeployerEntityResolver { /** * Creates an InputSource with a SystemID corresponding to a local dtd file .
 * @ param publicId The public identifier of the external entity being referenced , or null if none was supplied .
 * @ param systemId The system identifier of the external entity being referenced ( This is a dummy parameter and is overridden by the resource names
 * earlier specified by the < code > registrerResource < / code > ) method to correspond to the publicID .
 * @ return An InputSource object describing the new input source , or null to request that the parser open a regular URI connection to the system identifier .
 * @ exception org . xml . sax . SAXException Any SAX exception , possibly wrapping another exception .
 * @ exception java . io . IOException A Java - specific IO exception , possibly the result of creating a new InputStream or Reader for the InputSource . */
public InputSource resolveEntity ( String publicId , String systemId ) throws SAXException , IOException { } }

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


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see
 * javax . slee . management . TraceMBean # setTraceLevel ( javax . slee . ComponentID ,
 * javax . slee . facilities . Level ) */
public void setTraceLevel ( ComponentID componentId , Level level ) throws NullPointerException , UnrecognizedComponentException , ManagementException { } }

implementation: if ( componentId == null ) throw new NullPointerException ( "null component Id" ) ; this . traceFacility . checkComponentID ( componentId ) ; this . traceFacility . setTraceLevel ( componentId , level ) ;


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see
 * javax . slee . management . TraceMBean # getTraceLevel ( javax . slee . ComponentID ) */
public Level getTraceLevel ( ComponentID componentId ) throws NullPointerException , UnrecognizedComponentException , ManagementException { } }

implementation: if ( componentId == null ) throw new NullPointerException ( " null component Id " ) ; return this . traceFacility . getTraceLevel ( componentId ) ;


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see javax . management . NotificationBroadcaster # getNotificationInfo ( ) */
public MBeanNotificationInfo [ ] getNotificationInfo ( ) { } }

implementation: if ( this . traceFacility == null ) return null ; String [ ] notificationTypes = this . traceFacility . getNotificationTypes ( ) ; return new MBeanNotificationInfo [ ] { new MBeanNotificationInfo ( notificationTypes , TraceMBean . TRACE_NOTIFICATION_TYPE , "SLEE Spec 1.0, #13.4. SBBs use the Trace Facility to generate trace messages intended for " + "consumption by external management clients, such as a network management console or a management policy engine." ) } ;


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see javax . slee . management . TraceMBean # getTraceLevel ( javax . slee . management . NotificationSource , java . lang . String ) */
public TraceLevel getTraceLevel ( NotificationSource src , String tracerName ) throws NullPointerException , InvalidArgumentException , UnrecognizedNotificationSourceException , ManagementException { } }

implementation:
if ( src == null ) { throw new NullPointerException ( "NotificationSource must not be null!" ) ; } if ( ! this . isNotificationSourceDefined ( src ) ) { throw new UnrecognizedNotificationSourceException ( "Notification source not recognized: " + src ) ; } TracerImpl . checkTracerName ( tracerName , src ) ; if ( ! this . isTracerDefined ( src , tracerName ) ) { // FIXME : what is valid tracer name ? JDOC contradicts that not existing tracer name is invalid
this . createTracer ( src , tracerName , false ) ; } TracerStorage ts = this . tracerStorage . get ( src ) ; if ( ts == null ) { throw new ManagementException ( "NotificationSource has been uninstalled from SLEE. Can not create tracer." ) ; } try { return ts . getTracerLevel ( tracerName ) ; } catch ( Exception e ) { throw new ManagementException ( "Failed to get trace level due to: " , e ) ; }


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see javax . slee . management . TraceMBean # getTracersSet ( javax . slee . management . NotificationSource ) */
public String [ ] getTracersSet ( NotificationSource src ) throws NullPointerException , UnrecognizedNotificationSourceException , ManagementException { } }

implementation: if ( src == null ) { throw new NullPointerException ( "NotificationSource must nto be null!" ) ; } if ( ! this . isNotificationSourceDefined ( src ) ) { throw new UnrecognizedNotificationSourceException ( "Notification source not recognized: " + src ) ; } TracerStorage ts = this . tracerStorage . get ( src ) ; if ( ts == null ) { throw new ManagementException ( "NotificationSource has been uninstalled from SLEE. Can not create tracer." ) ; } return ts . getDefinedTracerNames ( ) ;


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see javax . slee . management . TraceMBean # getTracersUsed ( javax . slee . management . NotificationSource ) */
public String [ ] getTracersUsed ( NotificationSource src ) throws NullPointerException , UnrecognizedNotificationSourceException , ManagementException { } }

implementation: if ( src == null ) { throw new NullPointerException ( "NotificationSource must nto be null!" ) ; } if ( ! this . isNotificationSourceDefined ( src ) ) { throw new UnrecognizedNotificationSourceException ( "Notification source not recognized: " + src ) ; } TracerStorage ts = this . tracerStorage . get ( src ) ; if ( ts == null ) { throw new ManagementException ( "NotificationSource has been uninstalled from SLEE. Can not create tracer." ) ; } return ts . getRequestedTracerNames ( ) ;


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see javax . slee . management . TraceMBean # setTraceLevel ( javax . slee . management . NotificationSource , java . lang . String , javax . slee . facilities . TraceLevel ) */
public void setTraceLevel ( NotificationSource src , final String tracerName , TraceLevel lvl ) throws NullPointerException , UnrecognizedNotificationSourceException , InvalidArgumentException , ManagementException { } }

implementation:
if ( src == null ) { throw new NullPointerException ( "NotificationSource must nto be null!" ) ; } if ( lvl == null ) { throw new NullPointerException ( "TraceLevel must not be null!" ) ; } if ( ! this . isNotificationSourceDefined ( src ) ) { throw new UnrecognizedNotificationSourceException ( "Notification source not recognized: " + src ) ; } TracerImpl . checkTracerName ( tracerName , src ) ; if ( ! this . isTracerDefined ( src , tracerName ) ) { // FIXME : what is valid tracer name ? JDOC contradicts that not existing tracer name is invalid
this . createTracer ( src , tracerName , false ) ; } final TracerStorage ts = this . tracerStorage . get ( src ) ; if ( ts == null ) { throw new ManagementException ( "NotificationSource has been uninstalled from SLEE. Can not create tracer." ) ; } try { try { final SleeTransactionManager sleeTransactionManager = sleeContainer . getTransactionManager ( ) ; if ( sleeTransactionManager . getTransaction ( ) != null ) { final TraceLevel _oldLevel = ts . getTracerLevel ( tracerName ) ; TransactionalAction action = new TransactionalAction ( ) { TraceLevel oldLevel = _oldLevel ; public void execute ( ) { try { ts . setTracerLevel ( oldLevel , tracerName ) ; } catch ( InvalidArgumentException e ) { logger . error ( e . getMessage ( ) , e ) ; } } } ; sleeTransactionManager . getTransactionContext ( ) . getAfterRollbackActions ( ) . add ( action ) ; } } catch ( SystemException e ) { e . printStackTrace ( ) ; } ts . setTracerLevel ( lvl , tracerName ) ; } catch ( Exception e ) { throw new ManagementException ( "Failed to set trace level due to: " , e ) ; }


signature:
public class TraceMBeanImpl { /** * This checks if tracer name is ok . It must not be null ;
 * @ param split
 * @ throws IllegalArgumentException */
public static void checkTracerName ( String tracerName , NotificationSource notificationSource ) throws IllegalArgumentException { } }

implementation:
if ( tracerName . compareTo ( "" ) == 0 ) { // This is root
return ; } // String [ ] splitName = tracerName . split ( " \ \ . " ) ;
StringTokenizer stringTokenizer = new StringTokenizer ( tracerName , "." , true ) ; int fqdnPartIndex = 0 ; // if ( splitName . length = = 0)
// throw new IllegalArgumentException ( " Passed tracer : " + tracerName +
// " , name for source : " + notificationSource + " , is illegal " ) ;
String lastToken = null ; while ( stringTokenizer . hasMoreTokens ( ) ) { String token = stringTokenizer . nextToken ( ) ; if ( lastToken == null ) { // this is start
lastToken = token ; } if ( lastToken . compareTo ( token ) == 0 && token . compareTo ( "." ) == 0 ) { throw new IllegalArgumentException ( "Passed tracer:" + tracerName + ", name for source: " + notificationSource + ", is illegal" ) ; } if ( token . compareTo ( "." ) != 0 ) { for ( int charIndex = 0 ; charIndex < token . length ( ) ; charIndex ++ ) { Character c = token . charAt ( charIndex ) ; if ( Character . isLetter ( c ) || Character . isDigit ( c ) ) { // Its ok ?
} else { throw new IllegalArgumentException ( "Passed tracer:" + tracerName + " Token[" + token + "], name for source: " + notificationSource + ", is illegal, contains illegal character: " + charIndex ) ; } } fqdnPartIndex ++ ; } lastToken = token ; } if ( lastToken . compareTo ( "." ) == 0 ) { throw new IllegalArgumentException ( "Passed tracer:" + tracerName + ", name for source: " + notificationSource + ", is illegal" ) ; }


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see org . mobicents . slee . container . management . jmx . TraceManagement # registerNotificationSource ( javax . slee . management . NotificationSource ) */
public void registerNotificationSource ( final NotificationSource src ) { } }

implementation: if ( ! this . tracerStorage . containsKey ( src ) ) { TracerStorage ts = new TracerStorage ( src , this ) ; this . tracerStorage . put ( src , ts ) ; }


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see org . mobicents . slee . container . management . jmx . TraceManagement # isTracerDefined ( javax . slee . management . NotificationSource , java . lang . String ) */
public boolean isTracerDefined ( NotificationSource src , String tracerName ) throws ManagementException { } }

implementation: TracerStorage ts = this . tracerStorage . get ( src ) ; if ( ts == null ) { throw new ManagementException ( "NotificationSource has been uninstalled from SLEE. Can not create tracer." ) ; } return ts . isTracerDefined ( tracerName ) ;


signature:
public class TraceMBeanImpl { /** * ( non - Javadoc )
 * @ see org . mobicents . slee . container . management . TraceManagement # createTracer ( javax . slee . management . NotificationSource , java . lang . String , boolean ) */
public Tracer createTracer ( NotificationSource src , String tracerName , boolean createdBySource ) throws NullPointerException , InvalidArgumentException { } }

implementation: TracerImpl . checkTracerName ( tracerName , src ) ; TracerStorage ts = this . tracerStorage . get ( src ) ; if ( ts == null ) { throw new IllegalStateException ( "NotificationSource has been uninstalled from SLEE. Can not create tracer." ) ; } return ts . createTracer ( tracerName , createdBySource ) ;


signature:
public class ProfileQueryHandler { /** * Method that does lookup and creates PLOs
 * @ param profileTable
 * @ param queryName
 * @ param arguments
 * @ return
 * @ throws InvalidArgumentException
 * @ throws AttributeTypeMismatchException
 * @ throws UnrecognizedQueryNameException
 * @ throws SLEEException
 * @ throws NullPointerException */
public static Collection < ProfileLocalObject > handle ( ProfileTableImpl profileTable , String queryName , Object [ ] arguments ) throws NullPointerException , TransactionRequiredLocalException , SLEEException , UnrecognizedQueryNameException , AttributeTypeMismatchException , InvalidArgumentException { } }

implementation: return profileTable . getProfilesByStaticQuery ( queryName , arguments ) ;


signature:
public class DeployableUnitBuilderImpl { /** * Installs a JAIN SLEE DU .
 * @ param sourceUrl
 * the original URL of the deployable unit jar
 * @ param deploymentRoot
 * the root dir where this du will be installed
 * @ param componentRepository
 * the repository to retrieve components
 * @ return
 * @ throws DeploymentException */
public DeployableUnitImpl build ( String url , File deploymentRoot , ComponentRepository componentRepository ) throws DeploymentException , AlreadyDeployedException , MalformedURLException { } }

implementation:
if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Building DU from " + url ) ; } DeployableUnitID deployableUnitID = new DeployableUnitID ( url ) ; if ( deploymentRoot == null ) { throw new NullPointerException ( "null deploymentRoot" ) ; } URL sourceUrl = new URL ( url ) ; // support remote deployment
if ( sourceUrl . getProtocol ( ) . equals ( "http" ) || sourceUrl . getProtocol ( ) . equals ( "https" ) ) { try { // Fetch the remote file to a temporary location
File downloadedFile = downloadRemoteDU ( sourceUrl , deploymentRoot ) ; // Update the pointers from URL and String
sourceUrl = downloadedFile . toURI ( ) . toURL ( ) ; url = sourceUrl . toString ( ) ; } catch ( Exception e ) { throw new DeploymentException ( "Failed to retrieve remote DU file : " + sourceUrl . getFile ( ) , e ) ; } } // create jar file
JarFile deployableUnitJar = null ; try { deployableUnitJar = new JarFile ( sourceUrl . getFile ( ) ) ; } catch ( IOException e ) { throw new DeploymentException ( "Failed to open DU file as JAR file: " + sourceUrl . getFile ( ) , e ) ; } // get and parse du descriptor
JarEntry duXmlEntry = deployableUnitJar . getJarEntry ( "META-INF/deployable-unit.xml" ) ; if ( duXmlEntry == null ) { throw new DeploymentException ( "META-INF/deployable-unit.xml was not found in " + deployableUnitJar . getName ( ) ) ; } DeployableUnitDescriptorFactoryImpl descriptorFactory = componentManagement . getComponentDescriptorFactory ( ) . getDeployableUnitDescriptorFactory ( ) ; DeployableUnitDescriptorImpl deployableUnitDescriptor = null ; try { deployableUnitDescriptor = descriptorFactory . parse ( deployableUnitJar . getInputStream ( duXmlEntry ) ) ; } catch ( IOException e ) { try { deployableUnitJar . close ( ) ; } catch ( IOException e1 ) { logger . error ( e . getMessage ( ) , e ) ; } throw new DeploymentException ( "Failed to get DU descriptor DU inputstream from JAR file " + sourceUrl . getFile ( ) , e ) ; } // create the du dir
File deploymentDir = createTempDUDeploymentDir ( deploymentRoot , deployableUnitID ) ; // build du object
DeployableUnitImpl deployableUnit = null ; try { deployableUnit = new DeployableUnitImpl ( deployableUnitID , deployableUnitDescriptor , componentRepository , deploymentDir ) ; // build each du jar component
for ( String jarFileName : deployableUnitDescriptor . getJarEntries ( ) ) { for ( SleeComponent sleeComponent : duComponentBuilder . buildComponents ( jarFileName , deployableUnitJar , deployableUnit . getDeploymentDir ( ) ) ) { sleeComponent . setDeployableUnit ( deployableUnit ) ; if ( componentRepository . isInstalled ( sleeComponent . getComponentID ( ) ) ) { throw new AlreadyDeployedException ( "Component " + sleeComponent . getComponentID ( ) + " already deployed" ) ; } sleeComponent . setDeploymentUnitSource ( jarFileName ) ; } } // build each du service component
for ( String serviceDescriptorFileName : deployableUnitDescriptor . getServiceEntries ( ) ) { for ( ServiceComponentImpl serviceComponent : duServiceComponentBuilder . buildComponents ( serviceDescriptorFileName , deployableUnitJar ) ) { serviceComponent . setDeployableUnit ( deployableUnit ) ; if ( componentRepository . isInstalled ( serviceComponent . getComponentID ( ) ) ) { throw new AlreadyDeployedException ( "Component " + serviceComponent . getComponentID ( ) + " already deployed" ) ; } // set the direct reference to the sbb component
serviceComponent . setRootSbbComponent ( deployableUnit . getDeployableUnitRepository ( ) . getComponentByID ( serviceComponent . getDescriptor ( ) . getRootSbbID ( ) ) ) ; serviceComponent . setDeploymentUnitSource ( serviceDescriptorFileName ) ; } } // get a set with all components of the DU
Set < SleeComponent > duComponentsSet = deployableUnit . getDeployableUnitComponents ( ) ; // now that all components are built we need to
for ( SleeComponent sleeComponent : duComponentsSet ) { // check if all
// dependencies are available
checkDependencies ( sleeComponent , deployableUnit ) ; // build its class loader
createClassLoader ( ( AbstractSleeComponent ) sleeComponent ) ; } // load the provided classes for the component
for ( SleeComponent sleeComponent : duComponentsSet ) { loadAndSetNonGeneratedComponentClasses ( ( AbstractSleeComponent ) sleeComponent ) ; } // boolean secEnabled = SleeContainer . isSecurityEnabled ( ) ;
// validate each component
for ( SleeComponent sleeComponent : duComponentsSet ) { ClassLoader componentClassLoader = sleeComponent . getClassLoader ( ) ; ClassLoader oldClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { if ( componentClassLoader != null ) { Thread . currentThread ( ) . setContextClassLoader ( componentClassLoader ) ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Validating " + sleeComponent ) ; } if ( ! sleeComponent . validate ( ) ) { throw new DeploymentException ( sleeComponent . toString ( ) + " validation failed, check logs for errors found" ) ; } // Make permissions object , this instruments codebase etc , and store POJOs in component .
// if ( secEnabled )
sleeComponent . processSecurityPermissions ( ) ; } catch ( Throwable e ) { throw new DeploymentException ( "failed to validate " + sleeComponent , e ) ; } finally { if ( componentClassLoader != null ) { Thread . currentThread ( ) . setContextClassLoader ( oldClassLoader ) ; } } } try { deployableUnitJar . close ( ) ; } catch ( IOException e ) { logger . error ( "failed to close deployable jar from " + url , e ) ; } return deployableUnit ; } catch ( Throwable e ) { if ( deployableUnit == null ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Deleting deployable unit temp dir " + deploymentDir ) ; } deploymentDir . delete ( ) ; } if ( e instanceof DeploymentException ) { throw ( DeploymentException ) e ; } else if ( e instanceof AlreadyDeployedException ) { throw ( AlreadyDeployedException ) e ; } else { throw new DeploymentException ( "failed to build deployable unit" , e ) ; } }


signature:
public class DeployableUnitBuilderImpl { /** * Loads all non SLEE generated classes from the component class loader to
 * the component , those will be needed for validation or runtime purposes
 * @ param sleeComponent
 * @ throws DeploymentException */
private void loadAndSetNonGeneratedComponentClasses ( AbstractSleeComponent sleeComponent ) throws DeploymentException { } }

implementation:
if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Loading classes for component " + sleeComponent ) ; } ClassLoader oldClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { ComponentClassLoaderImpl componentClassLoader = sleeComponent . getClassLoader ( ) ; if ( componentClassLoader != null ) { // change class loader
Thread . currentThread ( ) . setContextClassLoader ( componentClassLoader ) ; // load and set non generated component classes
if ( sleeComponent instanceof EventTypeComponentImpl ) { EventTypeComponentImpl component = ( EventTypeComponentImpl ) sleeComponent ; Class < ? > eventTypeClass = componentClassLoader . loadClass ( component . getDescriptor ( ) . getEventClassName ( ) ) ; component . setEventTypeClass ( eventTypeClass ) ; } else if ( sleeComponent instanceof ProfileSpecificationComponentImpl ) { ProfileSpecificationComponentImpl component = ( ProfileSpecificationComponentImpl ) sleeComponent ; Class < ? > profileCmpInterfaceClass = componentClassLoader . loadClass ( component . getDescriptor ( ) . getProfileCMPInterface ( ) . getProfileCmpInterfaceName ( ) ) ; component . setProfileCmpInterfaceClass ( profileCmpInterfaceClass ) ; if ( component . getDescriptor ( ) . getProfileLocalInterface ( ) != null ) { Class < ? > profileLocalInterfaceClass = componentClassLoader . loadClass ( component . getDescriptor ( ) . getProfileLocalInterface ( ) . getProfileLocalInterfaceName ( ) ) ; component . setProfileLocalInterfaceClass ( profileLocalInterfaceClass ) ; } if ( component . getDescriptor ( ) . getProfileManagementInterface ( ) != null ) { Class < ? > profileManagementInterfaceClass = componentClassLoader . loadClass ( component . getDescriptor ( ) . getProfileManagementInterface ( ) ) ; component . setProfileManagementInterfaceClass ( profileManagementInterfaceClass ) ; } if ( component . getDescriptor ( ) . getProfileAbstractClass ( ) != null ) { boolean decoratedClass = new ProfileAbstractClassDecorator ( component ) . decorateAbstractClass ( ) ; Class < ? > profileAbstractClass = null ; if ( decoratedClass ) { // need to ensure we load the class from disk , not one coming from SLEE shared class loading domain
profileAbstractClass = componentClassLoader . loadClassLocally ( component . getDescriptor ( ) . getProfileAbstractClass ( ) . getProfileAbstractClassName ( ) ) ; } else { profileAbstractClass = componentClassLoader . loadClass ( component . getDescriptor ( ) . getProfileAbstractClass ( ) . getProfileAbstractClassName ( ) ) ; } component . setProfileAbstractClass ( profileAbstractClass ) ; } String mProfileTableInterface = component . getDescriptor ( ) . getProfileTableInterface ( ) ; if ( mProfileTableInterface != null ) { component . setProfileTableInterfaceClass ( componentClassLoader . loadClass ( mProfileTableInterface ) ) ; } UsageParametersInterfaceDescriptor mUsageParametersInterface = component . getDescriptor ( ) . getProfileUsageParameterInterface ( ) ; if ( mUsageParametersInterface != null ) { component . setUsageParametersInterface ( componentClassLoader . loadClass ( mUsageParametersInterface . getUsageParametersInterfaceName ( ) ) ) ; } } else if ( sleeComponent instanceof ResourceAdaptorComponentImpl ) { ResourceAdaptorComponentImpl component = ( ResourceAdaptorComponentImpl ) sleeComponent ; Class < ? > resourceAdaptorClass = componentClassLoader . loadClass ( component . getDescriptor ( ) . getResourceAdaptorClassName ( ) ) ; component . setResourceAdaptorClass ( resourceAdaptorClass ) ; MUsageParametersInterface mUsageParametersInterface = component . getDescriptor ( ) . getResourceAdaptorUsageParametersInterface ( ) ; if ( mUsageParametersInterface != null ) { component . setUsageParametersInterface ( componentClassLoader . loadClass ( mUsageParametersInterface . getUsageParametersInterfaceName ( ) ) ) ; } } else if ( sleeComponent instanceof ResourceAdaptorTypeComponentImpl ) { ResourceAdaptorTypeComponentImpl component = ( ResourceAdaptorTypeComponentImpl ) sleeComponent ; if ( component . getDescriptor ( ) . getActivityContextInterfaceFactoryInterface ( ) != null ) { Class < ? > activityContextInterfaceFactoryInterface = componentClassLoader . loadClass ( component . getDescriptor ( ) . getActivityContextInterfaceFactoryInterface ( ) ) ; component . setActivityContextInterfaceFactoryInterface ( activityContextInterfaceFactoryInterface ) ; } } else if ( sleeComponent instanceof SbbComponentImpl ) { SbbComponentImpl component = ( SbbComponentImpl ) sleeComponent ; // before loading the abstract class , we may have to decorate it
boolean decoratedClass = new SbbAbstractClassDecorator ( component ) . decorateAbstractSbb ( ) ; Class < ? > abstractSbbClass = null ; if ( decoratedClass ) { // need to ensure we load the class from disk , not one coming from SLEE shared class loading domain
abstractSbbClass = componentClassLoader . loadClassLocally ( component . getDescriptor ( ) . getSbbAbstractClass ( ) . getSbbAbstractClassName ( ) ) ; } else { abstractSbbClass = componentClassLoader . loadClass ( component . getDescriptor ( ) . getSbbAbstractClass ( ) . getSbbAbstractClassName ( ) ) ; } component . setAbstractSbbClass ( abstractSbbClass ) ; SbbLocalInterfaceDescriptor mSbbLocalInterface = component . getDescriptor ( ) . getSbbLocalInterface ( ) ; if ( mSbbLocalInterface != null ) { component . setSbbLocalInterfaceClass ( componentClassLoader . loadClass ( mSbbLocalInterface . getSbbLocalInterfaceName ( ) ) ) ; } String mSbbActivityContextInterface = component . getDescriptor ( ) . getSbbActivityContextInterface ( ) ; if ( mSbbActivityContextInterface != null ) { component . setActivityContextInterface ( componentClassLoader . loadClass ( mSbbActivityContextInterface ) ) ; } UsageParametersInterfaceDescriptor mUsageParametersInterface = component . getDescriptor ( ) . getSbbUsageParametersInterface ( ) ; if ( mUsageParametersInterface != null ) { component . setUsageParametersInterface ( componentClassLoader . loadClass ( mUsageParametersInterface . getUsageParametersInterfaceName ( ) ) ) ; } } } } catch ( NoClassDefFoundError e ) { throw new DeploymentException ( "Component " + sleeComponent . getComponentID ( ) + " requires a class that was not found" , e ) ; } catch ( ClassNotFoundException e ) { throw new DeploymentException ( "Component " + sleeComponent . getComponentID ( ) + " requires a class that was not found" , e ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( oldClassLoader ) ; }


signature:
public class DeployableUnitBuilderImpl { /** * Checks if all dependencies of a DU component exists
 * @ param sleeComponent
 * @ param deployableUnit
 * @ throws DependencyException
 * if a dependency is missing */
private void checkDependencies ( SleeComponent sleeComponent , DeployableUnitImpl deployableUnit ) throws DependencyException { } }

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


signature:
public class DeployableUnitBuilderImpl { /** * Creates the directory that will be used for unpacking the child jars for
 * a given DU .
 * @ param rootDir
 * @ param sourceUrl
 * @ throws SLEEException
 * if the dir can ' t be created
 * @ return */
private File createTempDUDeploymentDir ( File deploymentRoot , DeployableUnitID deployableUnitID ) { } }

implementation:
try { // first create a dummy file to gurantee uniqueness . I would have
// been nice if the File class had a createTempDir ( ) method
// IVELIN - - do not use jarName here because windows cannot see the
// path ( exceeds system limit )
File tempFile = File . createTempFile ( "restcomm-slee-du-" , "" , deploymentRoot ) ; File tempDUDeploymentDir = new File ( tempFile . getAbsolutePath ( ) + "-contents" ) ; if ( ! tempDUDeploymentDir . exists ( ) ) { tempDUDeploymentDir . mkdirs ( ) ; } else { throw new SLEEException ( "Dir " + tempDUDeploymentDir + " already exists, unable to create deployment dir for DU " + deployableUnitID ) ; } tempFile . delete ( ) ; return tempDUDeploymentDir ; } catch ( IOException e ) { throw new SLEEException ( "Failed to create deployment dir for DU " + deployableUnitID , e ) ; }


signature:
public class DefaultEventContextFactoryDataSource { /** * / * ( non - Javadoc )
 * @ see org . mobicents . slee . container . event . EventContextFactoryDataSource # addEventContext ( org . mobicents . slee . container . event . EventContextHandle , org . mobicents . slee . container . event . EventContext ) */
public void addEventContext ( EventContextHandle handle , EventContext eventContext ) { } }

implementation: if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Adding event context " + eventContext + " to datasource. Event context handle is " + handle ) ; } dataSource . put ( handle , eventContext ) ;


signature:
public class DefaultEventContextFactoryDataSource { /** * / * ( non - Javadoc )
 * @ see org . mobicents . slee . container . event . EventContextFactoryDataSource # newEventContextData ( javax . slee . EventTypeID , java . lang . Object , org . mobicents . slee . container . activity . ActivityContext , javax . slee . Address , javax . slee . ServiceID , org . mobicents . slee . container . event . EventProcessingSucceedCallback , org . mobicents . slee . container . event . EventProcessingFailedCallback , org . mobicents . slee . container . event . EventUnreferencedCallback , org . mobicents . slee . container . event . EventReferencesHandler ) */
public EventContextData newEventContextData ( EventTypeID eventTypeId , Object event , ActivityContext ac , Address address , ServiceID serviceID , EventProcessingSucceedCallback succeedCallback , EventProcessingFailedCallback failedCallback , EventUnreferencedCallback unreferencedCallback , ReferencesHandler referencesHandler ) { } }

implementation: return new DefaultEventContextData ( eventTypeId , event , ac , address , serviceID , succeedCallback , failedCallback , unreferencedCallback , referencesHandler ) ;


signature:
public class DefaultEventContextFactoryDataSource { /** * / * ( non - Javadoc )
 * @ see org . mobicents . slee . container . event . EventContextFactoryDataSource # removeEventContext ( org . mobicents . slee . container . event . EventContextHandle ) */
public void removeEventContext ( EventContextHandle handle ) { } }

implementation: if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Removing event context from datasource. Event context handle is " + handle ) ; } dataSource . remove ( handle ) ;


signature:
public class EventRoutingTaskImpl { /** * ( non - Javadoc )
 * @ see java . lang . Runnable # run ( ) */
public void run ( ) { } }

implementation: if ( System . getSecurityManager ( ) != null ) { AccessController . doPrivileged ( new PrivilegedAction < Object > ( ) { public Object run ( ) { routeQueuedEvent ( ) ; return null ; } } ) ; } else { routeQueuedEvent ( ) ; }


signature:
public class EventRoutingTaskImpl { /** * Delivers to SBBs an event off the top of the queue for an activity
 * context
 * @ param de
 * @ return true if the event processing suceeds */
private void routeQueuedEvent ( ) { } }

implementation:
boolean debugLogging = logger . isDebugEnabled ( ) ; final SleeTransactionManager txMgr = container . getTransactionManager ( ) ; ClassLoader oldClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { final LocalActivityContext lac = eventContext . getLocalActivityContext ( ) ; final EventRoutingTask activityCurrentEventRoutingTask = lac . getCurrentEventRoutingTask ( ) ; EventContext activityCurrentEventContext = activityCurrentEventRoutingTask == null ? null : activityCurrentEventRoutingTask . getEventContext ( ) ; if ( activityCurrentEventContext == null ) { if ( debugLogging ) logger . debug ( "\n\n\nStarting routing for " + eventContext ) ; activityCurrentEventContext = eventContext ; // activity has no event routing task set
lac . setCurrentEventRoutingTask ( this ) ; EventTypeComponent eventTypeComponent = container . getComponentRepository ( ) . getComponentByID ( eventContext . getEventTypeId ( ) ) ; if ( eventTypeComponent == null ) { logger . error ( "Unable to route event, the related component is not installed" ) ; eventContext . eventProcessingFailed ( FailureReason . OTHER_REASON ) ; return ; } // setup initial event processing
if ( eventContext . getService ( ) != null ) { ServiceComponent serviceComponent = container . getComponentRepository ( ) . getComponentByID ( eventContext . getService ( ) ) ; if ( eventTypeComponent . getActiveServicesWhichDefineEventAsInitial ( ) . contains ( serviceComponent ) ) { activityCurrentEventContext . getActiveServicesToProcessEventAsInitial ( ) . add ( serviceComponent ) ; } } else { Set < ServiceComponent > services = eventTypeComponent . getActiveServicesWhichDefineEventAsInitial ( ) ; if ( services != null ) { activityCurrentEventContext . getActiveServicesToProcessEventAsInitial ( ) . addAll ( services ) ; } } } else { if ( activityCurrentEventContext . isSuspendedNotTransacted ( ) ) { if ( debugLogging ) logger . debug ( "\n\n\nFreezing (due to suspended context) the routing for " + eventContext ) ; activityCurrentEventContext . barrierEvent ( eventContext ) ; return ; } else { if ( debugLogging ) logger . debug ( "\n\n\nResuming the routing for" + eventContext ) ; // needed to ensure tests / events / eventcontext / Test1108039Test . xml passes
// the test must be fixed
Thread . sleep ( 10 ) ; } } LinkedList < ServiceComponent > serviceComponents = activityCurrentEventContext . getActiveServicesToProcessEventAsInitial ( ) ; if ( debugLogging ) logger . debug ( "Active services which define " + eventContext . getEventTypeId ( ) + " as initial: " + serviceComponents ) ; boolean finished ; SbbEntityID rootSbbEntityId ; ClassLoader invokerClassLoader ; SbbEntity sbbEntity ; SbbObject sbbObject ; ServiceComponent serviceComponent ; boolean keepSbbEntityIfTxRollbacks ; NextSbbEntityFinder . Result nextSbbEntityFinderResult ; ActivityContext ac = null ; Exception caught = null ; Set < SbbEntityID > sbbEntitiesThatHandledCurrentEvent ; boolean deliverEvent ; boolean rollbackTx ; boolean rollbackOnlySet ; boolean sbbHandledEvent = false ; do { // For each SBB that is attached to this activity context and active service to process event as initial
rootSbbEntityId = null ; invokerClassLoader = null ; sbbEntity = null ; sbbObject = null ; serviceComponent = null ; keepSbbEntityIfTxRollbacks = false ; nextSbbEntityFinderResult = null ; finished = false ; ac = null ; caught = null ; deliverEvent = true ; rollbackTx = true ; rollbackOnlySet = false ; try { /* * Start of SLEE Originated Invocation Sequence
 * = = = = = This
 * sequence consists of either : 1 ) One " Op Only " SLEE
 * Originated Invocation - in the case that it ' s a
 * straightforward event routing for the sbb entity . 2 ) One
 * " Op and Remove " SLEE Originated Invocation - in the case
 * it ' s an event routing to a root sbb entity that ends up
 * in a remove to the same entity since the attachment count
 * goes to zero after the event invocation 3 ) One " Op Only "
 * followed by one " Remove Only " SLEE Originated Invocation -
 * in the case it ' s an event routing to a non - root sbb
 * entity that ends up in a remove to the corresponding root
 * entity since the root attachment count goes to zero after
 * the event invocation Each Invocation Sequence is handled
 * in it ' s own transaction . All exception handling for each
 * invocation sequence is handled here . Any exceptions that
 * propagate up aren ' t necessary to be caught . - Tim */
// If this fails then we propagate up since there ' s nothing to roll - back anyway
txMgr . begin ( ) ; sbbEntitiesThatHandledCurrentEvent = activityCurrentEventContext . getSbbEntitiesThatHandledEvent ( ) ; try { // load ac
ac = container . getActivityContextFactory ( ) . getActivityContext ( eventContext . getActivityContextHandle ( ) , true ) ; if ( ac == null ) { logger . error ( "Unable to route event " + eventContext + ". The activity context is gone" ) ; try { eventContext . eventProcessingFailed ( FailureReason . OTHER_REASON ) ; txMgr . commit ( ) ; } catch ( Throwable e ) { logger . error ( e . getMessage ( ) , e ) ; } return ; } if ( routingPhase == RoutingPhase . DELIVERING ) { // calculate highest priority attached sbb entity that needs to handle the event
try { nextSbbEntityFinderResult = nextSbbEntityFinder . next ( ac , eventContext , sbbEntitiesThatHandledCurrentEvent , container ) ; } catch ( Exception e ) { logger . warn ( "Failed to find next sbb entity to deliver the event " + eventContext + " in " + ac . getActivityContextHandle ( ) , e ) ; } // calculate highest priority service to process event as initial
if ( ! serviceComponents . isEmpty ( ) ) { serviceComponent = serviceComponents . getFirst ( ) ; } // compare highest priority sbb entity already attached with highest priority service to process event as initial
if ( nextSbbEntityFinderResult == null ) { if ( serviceComponent != null ) { if ( debugLogging ) logger . debug ( "No sbb entities attached, which didn't already route the event, but " + serviceComponent + " defines the event type as initial, starting initial event processing" ) ; // let the service process event as initial
serviceComponents . removeFirst ( ) ; sbbEntity = initialEventProcessor . processInitialEvent ( serviceComponent , eventContext , container , ac ) ; // if service returned no sbb entity and there are no more service components we are done
if ( sbbEntity == null && serviceComponents . isEmpty ( ) ) { finished = true ; } } else { // nothing else to route
finished = true ; if ( debugLogging ) logger . debug ( "No sbb entities attached, which didn't already route the event, and no services left to process the event as initial" ) ; } } else { if ( serviceComponent != null && serviceComponent . getDescriptor ( ) . getDefaultPriority ( ) >= nextSbbEntityFinderResult . sbbEntity . getPriority ( ) ) { if ( debugLogging ) logger . debug ( "Found an sbb entity attached, which didn't already route the event, but " + serviceComponent + " defines the event type as initial and has the same or higher priority, starting initial event processing" ) ; // the service has higher or equal priority as the sbb entity , let the service process the eventas initial
serviceComponents . removeFirst ( ) ; sbbEntity = initialEventProcessor . processInitialEvent ( serviceComponent , eventContext , container , ac ) ; } else { if ( debugLogging ) logger . debug ( "Found an sbb entity attached, which didn't already route the event, and either there are no more services, which defines the event type as initial, or their priorities is lower than the attached sbb entity found" ) ; sbbEntity = nextSbbEntityFinderResult . sbbEntity ; // in this case it needs to find out if the sbb entity should receive the event or not
// it may be an activity end event and the attached sbb entity does not receives such event
deliverEvent = nextSbbEntityFinderResult . deliverEvent ; } } } if ( sbbEntity != null ) { sbbEntitiesThatHandledCurrentEvent . add ( sbbEntity . getSbbEntityId ( ) ) ; if ( debugLogging ) { logger . debug ( "Highest priority SBB entity, which is attached to the ac " + eventContext . getActivityContextHandle ( ) + " , to deliver the event: " + sbbEntity . getSbbEntityId ( ) ) ; } // CHANGE CLASS LOADER
invokerClassLoader = sbbEntity . getSbbComponent ( ) . getClassLoader ( ) ; Thread . currentThread ( ) . setContextClassLoader ( invokerClassLoader ) ; if ( ! sbbEntity . getSbbEntityId ( ) . isRootSbbEntity ( ) ) { rootSbbEntityId = sbbEntity . getSbbEntityId ( ) . getRootSBBEntityID ( ) ; } SleeThreadLocals . setInvokingService ( sbbEntity . getSbbEntityId ( ) . getServiceID ( ) ) ; // we deliver the event in case it is an initial
// event processing or if the highest priority
// attached sbb entity should do it ( in activity
// end event it may not if the service id was
// set in the event firing , or if the sbb entity
// does not declares the event in sbb descriptor
if ( deliverEvent ) { sbbEntity . assignSbbObject ( ) ; sbbObject = sbbEntity . getSbbObject ( ) ; if ( sbbEntity . isCreated ( ) && ! txMgr . getRollbackOnly ( ) ) { keepSbbEntityIfTxRollbacks = true ; } // GET AND CHECK EVENT MASK FOR THIS SBB ENTITY
Set < EventTypeID > eventMask = sbbEntity . getMaskedEventTypes ( eventContext . getActivityContextHandle ( ) ) ; if ( eventMask == null || ! eventMask . contains ( eventContext . getEventTypeId ( ) ) ) { // TIME TO INVOKE THE EVENT HANDLER METHOD
sbbObject . setSbbInvocationState ( SbbInvocationState . INVOKING_EVENT_HANDLER ) ; ac . beforeDeliveringEvent ( eventContext ) ; if ( debugLogging ) { logger . debug ( "---> Invoking event handler: ac=" + eventContext . getActivityContextHandle ( ) + " , sbbEntity=" + sbbEntity . getSbbEntityId ( ) + " , sbbObject=" + sbbObject ) ; } sbbEntity . invokeEventHandler ( eventContext , ac , activityCurrentEventContext ) ; sbbHandledEvent = true ; if ( debugLogging ) { logger . debug ( "<--- Invoked event handler: ac=" + eventContext . getActivityContextHandle ( ) + " , sbbEntity=" + sbbEntity . getSbbEntityId ( ) + " , sbbObject=" + sbbObject ) ; } // check to see if the transaction is marked for
// rollback if it is then we need to get out of
// here soon as we can .
rollbackOnlySet = txMgr . getRollbackOnly ( ) ; if ( ! rollbackOnlySet ) { // TODO understand why the invoking state is not changed if rollback is set
sbbObject . setSbbInvocationState ( SbbInvocationState . NOT_INVOKING ) ; } } else { if ( debugLogging ) { logger . debug ( "Not invoking event handler since event is masked" ) ; } } } if ( ! rollbackOnlySet ) { // IF IT ' S AN ACTIVITY END EVENT DETACH SBB ENTITY HERE
if ( eventContext . isActivityEndEvent ( ) && activityCurrentEventContext . getSbbEntitiesThatHandledEvent ( ) . contains ( sbbEntity . getSbbEntityId ( ) ) ) { if ( debugLogging ) { logger . debug ( "The event is an activity end event, detaching ac=" + eventContext . getActivityContextHandle ( ) + " , sbbEntity=" + sbbEntity . getSbbEntityId ( ) ) ; } ac . detachSbbEntity ( sbbEntity . getSbbEntityId ( ) ) ; sbbEntity . afterACDetach ( eventContext . getActivityContextHandle ( ) ) ; } // CHECK IF WE CAN CLAIM THE ROOT SBB ENTITY
if ( rootSbbEntityId != null ) { SbbEntity rootSbbEntity = container . getSbbEntityFactory ( ) . getSbbEntity ( rootSbbEntityId , false ) ; if ( rootSbbEntity == null || rootSbbEntity . getAttachmentCount ( ) != 0 ) { if ( debugLogging ) { logger . debug ( "Not removing sbb entity " + sbbEntity . getSbbEntityId ( ) + " , the attachment count is not 0" ) ; } // the root sbb entity is not be claimed
rootSbbEntityId = null ; } } else { // it ' s a root sbb
if ( ! sbbEntity . isRemoved ( ) && sbbEntity . getAttachmentCount ( ) == 0 ) { if ( debugLogging ) { logger . debug ( "Removing sbb entity " + sbbEntity . getSbbEntityId ( ) + " , the attachment count is not 0" ) ; } // If it ' s the same entity then this is an
// " Op and
// Remove Invocation Sequence "
// so we do the remove in the same
// invocation
// sequence as the Op
container . getSbbEntityFactory ( ) . removeSbbEntity ( sbbEntity , true ) ; } } } } } catch ( Exception e ) { logger . error ( "Caught exception while routing " + eventContext , e ) ; if ( sbbEntity != null ) { sbbObject = sbbEntity . getSbbObject ( ) ; } caught = e ; } catch ( Throwable e ) { // not an exception , wrap it in exception so sbb learns about it
logger . error ( "Caught throwable while routing " + eventContext , e ) ; if ( sbbEntity != null ) { sbbObject = sbbEntity . getSbbObject ( ) ; } caught = new SLEEException ( "Caught throwable!" , e ) ; } // do a final check to see if there is another SBB to
// deliver .
// We don ' t want to waste another loop . Note that
// rollback
// will not has any impact on this because the
// ac . DeliveredSet
// is not in the cache .
if ( ! finished ) { if ( serviceComponents . isEmpty ( ) ) { // no more services to process event as initial
try { if ( nextSbbEntityFinder . next ( ac , eventContext , sbbEntitiesThatHandledCurrentEvent , container ) == null ) { // if ( nextSbbEntityFinder . next ( ac , de . getEventTypeId ( ) , de . getService ( ) , sbbEntitiesThatHandledCurrentEvent ) = = null & & sbbEntitiesThatHandledCurrentEvent . contains ( sbbEntity . getSbbEntityID ( ) ) ) {
// no more attached sbb entities to route the event
finished = true ; } } catch ( Throwable e ) { if ( debugLogging ) { logger . debug ( "failed to get next attached sbb entity to handle event" , e ) ; } } } } boolean invokeSbbRolledBack = handleRollback . handleRollback ( sbbObject , caught , invokerClassLoader , txMgr ) ; boolean invokeSbbRolledBackRemove = false ; ClassLoader rootInvokerClassLoader = null ; SbbEntity rootSbbEntity = null ; if ( ! invokeSbbRolledBack && rootSbbEntityId != null ) { /* * If we get here this means that we need to do a
 * cascading remove of the root sbb entity - since the
 * original invocation was done on a non - root sbb entity
 * then this is done in a different SLEE originated
 * invocation , but inside the same SLEE originated
 * invocation sequence . Confused yet ? This is case 3 ) in
 * my previous comment - the SLEE originated invocation
 * sequence contains two SLEE originated invocations :
 * One " Op Only " and One " Remove Only " This is the
 * " Remove Only " part . We don ' t bother doing this if we
 * already need to rollback */
caught = null ; try { rootSbbEntity = container . getSbbEntityFactory ( ) . getSbbEntity ( rootSbbEntityId , false ) ; if ( rootSbbEntity != null ) { container . getSbbEntityFactory ( ) . removeSbbEntity ( rootSbbEntity , false ) ; } } catch ( Exception e ) { logger . error ( "Failure while routing event; third phase. Event Posting [" + eventContext + "]" , e ) ; caught = e ; } // We have no target sbb object in a Remove Only SLEE
// originated invocation
// FIXME emmartins review
invokeSbbRolledBackRemove = handleRollback . handleRollback ( null , caught , rootSbbEntity . getSbbComponent ( ) . getClassLoader ( ) , txMgr ) ; } /* * We are now coming to the end of the SLEE originated
 * invocation sequence We may need to run sbbRolledBack This
 * is done in the same tx if there is no target sbb entity
 * in any of the SLEE originated invocations making up this
 * SLEE originated invocation sequence Otherwise we do it in
 * a separate tx for each SLEE originated invocation that
 * has a target sbb entity . In other words we might have a
 * maximum of 2 sbbrolledback callbacks invoked in separate
 * tx in the case this SLEE Originated Invocation Sequence
 * contained an Op Only and a Remove Only ( since these have
 * different target sbb entities ) Pretty obvious really ! ; ) */
if ( invokeSbbRolledBack && sbbEntity == null ) { // We do it in this tx
handleSbbRollback . handleSbbRolledBack ( null , sbbObject , null , null , invokerClassLoader , false , container , false ) ; } else if ( sbbEntity != null && ! txMgr . getRollbackOnly ( ) && sbbEntity . getSbbObject ( ) != null ) { sbbEntity . passivateAndReleaseSbbObject ( ) ; // fixes https : / / github . com / RestComm / jain - slee / issues / 53
/* add new tx action before tx commit in which
 * get all sbb entities in the tx context except target sbb entity
 * and invoke passivateAndReleaseSbbObject method if the sbb object is not null */
final Collection coll = txMgr . getTransactionContext ( ) . getData ( ) . keySet ( ) ; final SbbEntityID ongoingEntID = sbbEntity . getSbbEntityId ( ) ; TransactionalAction removeLoadedSBBAction = new TransactionalAction ( ) { @ Override public void execute ( ) { for ( Object obj : coll ) { if ( obj instanceof SbbEntityID ) { if ( ! obj . equals ( ongoingEntID ) ) { SbbEntity currentEntity = ( SbbEntity ) txMgr . getTransactionContext ( ) . getData ( ) . get ( obj ) ; if ( currentEntity . getSbbObject ( ) != null ) { currentEntity . passivateAndReleaseSbbObject ( ) ; } } } } } } ; txMgr . getTransactionContext ( ) . getBeforeCommitPriorityActions ( ) . add ( removeLoadedSBBAction ) ; } if ( txMgr . getRollbackOnly ( ) ) { if ( debugLogging ) { logger . trace ( "Rolling back SLEE Originated Invocation Sequence" ) ; } txMgr . rollback ( ) ; } else { if ( finished ) { switch ( routingPhase ) { case DELIVERING : // last tx for this event delivering and it is going to commit ( hopefully )
// if it has a unrefrenced callback which is tx aware try to take advantage of that
// and do post processing in this tx , in the worst ( and unexpected ) scenario
// the tx will rollback and we will do another spin , due to setting gotSbb as true
if ( eventContext . routedRequiresTransaction ( ) ) { finished = false ; routingPhase = RoutingPhase . DELIVERED ; eventContext . routed ( ) ; } break ; case DELIVERED : if ( eventContext . routedRequiresTransaction ( ) ) { // we had bad luck and last tx rollbacked , repeat action
finished = false ; eventContext . routed ( ) ; } break ; default : logger . error ( "Unknown routing phase!!!" ) ; break ; } } if ( debugLogging ) { logger . trace ( "Committing SLEE Originated Invocation Sequence" ) ; } txMgr . commit ( ) ; // if we are not in delivering mode anymore and tx commits then we allow the loop to exit
if ( routingPhase != RoutingPhase . DELIVERING ) { finished = true ; } } /* * Now we invoke sbbRolledBack for each SLEE originated
 * invocation that had a target sbb entity in a new tx - the
 * new tx creating is handled inside the handleSbbRolledBack
 * method */
if ( invokeSbbRolledBack && sbbEntity != null ) { // Firstly for the " Op only " or " Op and Remove " part
if ( debugLogging ) { logger . trace ( "Invoking sbbRolledBack for Op Only or Op and Remove" ) ; } // FIXME : baranowb : de is passed for test : tests / sbb / abstractclass / SbbRolledBackNewTransaction . xml
handleSbbRollback . handleSbbRolledBack ( sbbEntity , null , eventContext , ac , invokerClassLoader , false , container , keepSbbEntityIfTxRollbacks ) ; } if ( invokeSbbRolledBackRemove ) { // Now for the " Remove Only " if appropriate
handleSbbRollback . handleSbbRolledBack ( rootSbbEntity , null , null , null , rootInvokerClassLoader , true , container , keepSbbEntityIfTxRollbacks ) ; } /* * A note on exception handling here - Any exceptions thrown
 * further further up that need to be caught in order to
 * handle rollback or otherwise maintain consistency of the
 * SLEE state are all handled further up I . e . We * do not *
 * need to call rollback here . So any exceptions that get
 * here do not result in the SLEE being in an inconsistent
 * state , therefore we just log them and carry on . */
rollbackTx = false ; } catch ( RuntimeException e ) { logger . error ( "Unhandled RuntimeException in event router: " , e ) ; } catch ( Exception e ) { logger . error ( "Unhandled Exception in event router: " , e ) ; } catch ( Error e ) { logger . error ( "Unhandled Error in event router: " , e ) ; throw e ; // Always rethrow errors
} catch ( Throwable t ) { logger . error ( "Unhandled Throwable in event router: " , t ) ; } finally { try { // FIXME this should not be possible , check if this is ever called by tck ! ! !
final Transaction forgottenTx = txMgr . getTransaction ( ) ; if ( forgottenTx != null ) { logger . error ( "HOUSTON WE HAVE A PROBLEM! Transaction " + forgottenTx + " left open in event routing." ) ; if ( rollbackTx ) { txMgr . rollback ( ) ; } else { txMgr . commit ( ) ; } } } catch ( SystemException se ) { logger . error ( se . getMessage ( ) , se ) ; } if ( sbbEntity != null ) { if ( debugLogging ) { logger . debug ( "Finished routing for " + eventContext + "\n\n\n" ) ; } } } SleeThreadLocals . setInvokingService ( null ) ; if ( activityCurrentEventContext . isSuspendedNotTransacted ( ) ) { if ( debugLogging ) logger . debug ( "Suspended routing for " + eventContext + "\n\n\n" ) ; return ; } } while ( ! finished ) ; /* * End of SLEE Originated Invocation Sequence */
eventContext . eventProcessingSucceed ( sbbHandledEvent ) ; // we got to the end of the event routing , remove from local ac
lac . setCurrentEventRoutingTask ( null ) ; if ( ! eventContext . routedRequiresTransaction ( ) ) { eventContext . routed ( ) ; } } catch ( Exception e ) { logger . error ( "Unhandled Exception in event router top try" , e ) ; } Thread . currentThread ( ) . setContextClassLoader ( oldClassLoader ) ;


signature:
public class ResourceAdaptorActivityContextHandleImpl { /** * ( non - Javadoc )
 * @ see java . io . Externalizable # readExternal ( java . io . ObjectInput ) */
@ Override public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { } }

implementation:
// read ra entity name
final String raEntityName = in . readUTF ( ) ; // read activity handle
this . raEntity = SleeContainer . lookupFromJndi ( ) . getResourceManagement ( ) . getResourceAdaptorEntity ( raEntityName ) ; if ( raEntity == null ) { throw new IOException ( "RA Entity with name " + raEntityName + " not found." ) ; } // read activity handle
boolean handleReference = in . readBoolean ( ) ; if ( handleReference ) { // a reference
activityHandle = new ActivityHandleReference ( null , ( Address ) in . readObject ( ) , in . readUTF ( ) ) ; } else { final Marshaler marshaler = raEntity . getMarshaler ( ) ; if ( marshaler != null ) { activityHandle = marshaler . unmarshalHandle ( in ) ; } else { throw new IOException ( "marshaller from RA is null" ) ; } }


signature:
public class ResourceAdaptorActivityContextHandleImpl { /** * ( non - Javadoc )
 * @ see java . io . Externalizable # writeExternal ( java . io . ObjectOutput ) */
@ Override public void writeExternal ( ObjectOutput out ) throws IOException { } }

implementation:
// write ra entity name
out . writeUTF ( raEntity . getName ( ) ) ; // write activity handle
if ( activityHandle . getClass ( ) == ActivityHandleReference . class ) { // a reference
out . writeBoolean ( true ) ; final ActivityHandleReference reference = ( ActivityHandleReference ) activityHandle ; out . writeObject ( reference . getAddress ( ) ) ; out . writeUTF ( reference . getId ( ) ) ; } else { out . writeBoolean ( false ) ; final Marshaler marshaler = raEntity . getMarshaler ( ) ; if ( marshaler != null ) { marshaler . marshalHandle ( activityHandle , out ) ; } else { throw new IOException ( "marshaller from RA is null" ) ; } }


signature:
public class ConcreteProfileEntityGenerator { /** * Generates the concrete profile entity class and a profile entity array
 * attr value class for each attribute that is an array */
public void generateClasses ( ) { } }

implementation:
try { ProfileSpecificationDescriptor profileDescriptor = profileComponent . getDescriptor ( ) ; String deployDir = profileComponent . getDeploymentDir ( ) . getAbsolutePath ( ) ; ProfileCMPInterfaceDescriptor cmpInterface = profileDescriptor . getProfileCMPInterface ( ) ; // define the concrete profile entity class name
String concreteProfileEntityClassName = cmpInterface . getProfileCmpInterfaceName ( ) + "_PE" ; // create javassist class
CtClass concreteProfileEntityClass = ClassGeneratorUtils . createClass ( concreteProfileEntityClassName , new String [ ] { cmpInterface . getProfileCmpInterfaceName ( ) , Serializable . class . getName ( ) } ) ; // set inheritance
ClassGeneratorUtils . createInheritanceLink ( concreteProfileEntityClass , ProfileEntity . class . getName ( ) ) ; // annotate with @ Entity
ClassGeneratorUtils . addAnnotation ( Entity . class . getName ( ) , new LinkedHashMap < String , Object > ( ) , concreteProfileEntityClass ) ; // annotate the @ IdClass
LinkedHashMap < String , Object > idClassMVs = new LinkedHashMap < String , Object > ( ) ; idClassMVs . put ( "value" , JPAProfileId . class ) ; ClassGeneratorUtils . addAnnotation ( IdClass . class . getName ( ) , idClassMVs , concreteProfileEntityClass ) ; Set < String > uniqueConstraints = new HashSet < String > ( ) ; // override @ id & @ basic getter methods
String getProfileNameMethodSrc = "public String getProfileName() { return super.getProfileName(); }" ; CtMethod getProfileNameMethod = CtNewMethod . make ( getProfileNameMethodSrc , concreteProfileEntityClass ) ; ClassGeneratorUtils . addAnnotation ( Id . class . getName ( ) , new LinkedHashMap < String , Object > ( ) , getProfileNameMethod ) ; concreteProfileEntityClass . addMethod ( getProfileNameMethod ) ; String getTableNameMethodSrc = "public String getTableName() { return super.getTableName(); }" ; CtMethod getTableNameMethod = CtNewMethod . make ( getTableNameMethodSrc , concreteProfileEntityClass ) ; ClassGeneratorUtils . addAnnotation ( Id . class . getName ( ) , new LinkedHashMap < String , Object > ( ) , getTableNameMethod ) ; concreteProfileEntityClass . addMethod ( getTableNameMethod ) ; // generate the getters / setters in the profile entity
// gather the fieldNames of array type attributes
ClassPool pool = profileComponent . getClassPool ( ) ; CtClass cmpInterfaceClass = pool . get ( cmpInterface . getProfileCmpInterfaceName ( ) ) ; CtClass listClass = pool . get ( List . class . getName ( ) ) ; Map < String , Class < ? > > profileEntityArrayAttrValueClassMap = new HashMap < String , Class < ? > > ( ) ; for ( CtMethod method : cmpInterfaceClass . getMethods ( ) ) { if ( ! method . getDeclaringClass ( ) . getName ( ) . equals ( Object . class . getName ( ) ) && method . getName ( ) . startsWith ( "get" ) ) { String fieldName = Introspector . decapitalize ( method . getName ( ) . replaceFirst ( "get" , "" ) ) ; boolean array = method . getReturnType ( ) . isArray ( ) ; CtClass returnType = array ? listClass : method . getReturnType ( ) ; CtField genField = ClassGeneratorUtils . addField ( returnType , fieldName , concreteProfileEntityClass ) ; // see issue # 23 : [ Profiles ] getting correct fieldName from method of ProfileCMP interface
fieldName = genField . getName ( ) ; String pojoCmpAccessorSufix = ClassGeneratorUtils . getPojoCmpAccessorSufix ( genField . getName ( ) ) ; // create the getter
CtMethod ctMethod = CtNewMethod . getter ( "get" + pojoCmpAccessorSufix , genField ) ; ProfileAttribute profileAttribute = profileComponent . getProfileAttributes ( ) . get ( fieldName ) ; concreteProfileEntityClass . addMethod ( ctMethod ) ; if ( array ) { // we need to generate a class for this attribute , to hold the one to many relation
Class < ? > profileAttributeArrayValueClass = generateProfileAttributeArrayValueClass ( concreteProfileEntityClass , fieldName , profileAttribute . isUnique ( ) ) ; profileEntityArrayAttrValueClassMap . put ( fieldName , profileAttributeArrayValueClass ) ; // add the annotations of one to many association with array attr value class
LinkedHashMap < String , Object > map = new LinkedHashMap < String , Object > ( ) ; map . put ( "targetEntity" , profileAttributeArrayValueClass ) ; // FIXME see comment on generation of avv , it is possible to work wituout a join table but needs more work
// THE MAPPEDBY IS REQUIRED FOR THE RELATION WITHOUT A JOIN TABLE
map . put ( "mappedBy" , "owner" ) ; map . put ( "cascade" , new CascadeType [ ] { CascadeType . ALL } ) ; ClassGeneratorUtils . addAnnotation ( OneToMany . class . getName ( ) , map , ctMethod ) ; // we need to add a special hibernate annotation because the jpa cascade delete only deletes from join table , not the orphan row at the PEAAV table
map = new LinkedHashMap < String , Object > ( ) ; map . put ( "value" , new org . hibernate . annotations . CascadeType [ ] { org . hibernate . annotations . CascadeType . DELETE_ORPHAN } ) ; ClassGeneratorUtils . addAnnotation ( Cascade . class . getName ( ) , map , ctMethod ) ; // make setter from src
/* String setterSrc =
 " public void set " + pojoCmpAccessorSufix + " ( " + List . class . getName ( ) + " value ) { " +
 " System . out . println ( \ " PEAAV setter : " + genField . getName ( ) + " = \ " + this . " + genField . getName ( ) + " + \ " value = \ " + value ) ; " +
 " if ( this . " + genField . getName ( ) + " ! = null ) { " +
 " this . " + genField . getName ( ) + " . clear ( ) ; " +
 " if ( value ! = null ) { " +
 " for ( " + Iterator . class . getName ( ) + " i = value . iterator ( ) ; i . hasNext ( ) ; ) { " +
 " " + profileAttributeArrayValueClass . getName ( ) + " otherArrayValue = ( " + profileAttributeArrayValueClass . getName ( ) + " ) i . next ( ) ; " +
 " " + profileAttributeArrayValueClass . getName ( ) + " thisArrayValue = new " + profileAttributeArrayValueClass . getName ( ) + " ( ) ; " +
 " thisArrayValue . setString ( otherArrayValue . getString ( ) ) ; " +
 " thisArrayValue . setSerializable ( ( " + Serializable . class . getName ( ) + " ) " + ObjectCloner . class . getName ( ) + " . makeDeepCopy ( otherArrayValue . getSerializable ( ) ) ) ; " +
 " this . " + genField . getName ( ) + " . add ( thisArrayValue ) ; " +
 " } else { " +
 " this . " + genField . getName ( ) + " = value ; " +
 ctMethod = CtMethod . make ( setterSrc , concreteProfileEntityClass ) ;
 concreteProfileEntityClass . addMethod ( ctMethod ) ; */
} else { // not an array , just add column annotation with or without unique constraint
if ( profileAttribute . isUnique ( ) ) { // just collect uniqueConstraints attributtes
uniqueConstraints . add ( Introspector . decapitalize ( pojoCmpAccessorSufix ) ) ; } // String , primitive types , Array , Date will not be modified , only serialized data
LinkedHashMap < String , Object > map = new LinkedHashMap < String , Object > ( ) ; if ( ! returnType . isPrimitive ( ) && ! returnType . getName ( ) . equals ( "java.lang.String" ) ) map . put ( "length" , 512 ) ; ClassGeneratorUtils . addAnnotation ( Column . class . getName ( ) , map , ctMethod ) ; } // add usual setter
ctMethod = CtNewMethod . setter ( "set" + pojoCmpAccessorSufix , genField ) ; concreteProfileEntityClass . addMethod ( ctMethod ) ; } } String tableName = "SLEE_PE_" + profileComponent . getProfileCmpInterfaceClass ( ) . getSimpleName ( ) + "_" + Math . abs ( ( long ) profileComponent . getComponentID ( ) . hashCode ( ) ) ; addTableAnnotation ( tableName , uniqueConstraints , concreteProfileEntityClass ) ; jpaProfileDataSource . setProfileEntityArrayAttrValueClassMap ( profileEntityArrayAttrValueClassMap ) ; // write and load profile entity class
if ( logger . isDebugEnabled ( ) ) logger . debug ( "Writing PROFILE ENTITY CONCRETE CLASS ( " + concreteProfileEntityClass . getName ( ) + " ) to: " + deployDir ) ; concreteProfileEntityClass . writeFile ( deployDir ) ; jpaProfileDataSource . setProfileEntityClass ( Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( concreteProfileEntityClass . getName ( ) ) ) ; concreteProfileEntityClass . defrost ( ) ; } catch ( Throwable e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; }


signature:
public class ConcreteProfileEntityGenerator { /** * Generates a class that extends { @ link ProfileEntityArrayAttributeValue } for a specific entity attribute of array type value
 * @ param concreteProfileEntityClass
 * @ param profileAttributeName
 * @ return */
private Class < ? > generateProfileAttributeArrayValueClass ( CtClass concreteProfileEntityClass , String profileAttributeName , boolean unique ) { } }

implementation:
CtClass concreteArrayValueClass = null ; try { // define the concrete profile attribute array value class name
String concreteArrayValueClassName = profileComponent . getProfileCmpInterfaceClass ( ) . getName ( ) + "PEAAV_" + ClassGeneratorUtils . capitalize ( profileAttributeName ) ; // create javassist class
concreteArrayValueClass = ClassGeneratorUtils . createClass ( concreteArrayValueClassName , new String [ ] { Serializable . class . getName ( ) } ) ; // set inheritance
ClassGeneratorUtils . createInheritanceLink ( concreteArrayValueClass , ProfileEntityArrayAttributeValue . class . getName ( ) ) ; // annotate class with @ Entity
ClassGeneratorUtils . addAnnotation ( Entity . class . getName ( ) , new LinkedHashMap < String , Object > ( ) , concreteArrayValueClass ) ; // generate a random table name
addTableAnnotationToPEAAV ( "SLEE_PEAAV_" + profileComponent . getProfileCmpInterfaceClass ( ) . getSimpleName ( ) + "_" + Math . abs ( ( long ) profileComponent . getComponentID ( ) . hashCode ( ) ) + profileAttributeName , unique , concreteArrayValueClass ) ; // override @ id
String getIdNameMethodSrc = "public long getId() { return super.getId(); }" ; CtMethod getIdNameMethod = CtNewMethod . make ( getIdNameMethodSrc , concreteArrayValueClass ) ; ClassGeneratorUtils . addAnnotation ( Id . class . getName ( ) , new LinkedHashMap < String , Object > ( ) , getIdNameMethod ) ; ClassGeneratorUtils . addAnnotation ( GeneratedValue . class . getName ( ) , new LinkedHashMap < String , Object > ( ) , getIdNameMethod ) ; concreteArrayValueClass . addMethod ( getIdNameMethod ) ; // override getter methods
String getSerializableMethodSrc = "public " + Serializable . class . getName ( ) + " getSerializable() { return super.getSerializable(); }" ; CtMethod getSerializableMethod = CtNewMethod . make ( getSerializableMethodSrc , concreteArrayValueClass ) ; LinkedHashMap < String , Object > map = new LinkedHashMap < String , Object > ( ) ; map . put ( "name" , "serializable" ) ; map . put ( "length" , 512 ) ; // if ( unique ) map . put ( " unique " , true ) ;
ClassGeneratorUtils . addAnnotation ( Column . class . getName ( ) , map , getSerializableMethod ) ; concreteArrayValueClass . addMethod ( getSerializableMethod ) ; String getStringMethodSrc = "public String getString() { return super.getString(); }" ; CtMethod getStringMethod = CtNewMethod . make ( getStringMethodSrc , concreteArrayValueClass ) ; map = new LinkedHashMap < String , Object > ( ) ; map . put ( "name" , "string" ) ; // if ( unique ) map . put ( " unique " , true ) ;
ClassGeneratorUtils . addAnnotation ( Column . class . getName ( ) , map , getStringMethod ) ; concreteArrayValueClass . addMethod ( getStringMethod ) ; // FIXME add join columns here or in profile entity class to make
// the relation without a join table , atm if this is changed , the
// inserts on this table go with profile and table name as null % )
// THE PROFILENTITY FIELD IN AAV CLASS IS REQUIRED FOR THE RELATION WITH PROFILE ENTITY CLASS WITHOUT A JOIN TABLE
// add join column regarding the relation from array attr value to profile entity
CtField ctField = ClassGeneratorUtils . addField ( concreteProfileEntityClass , "owner" , concreteArrayValueClass ) ; ClassGeneratorUtils . generateSetter ( ctField , null ) ; CtMethod getter = ClassGeneratorUtils . generateGetter ( ctField , null ) ; // ClassGeneratorUtils . addAnnotation ( ManyToOne . class . getName ( ) , new LinkedHashMap < String , Object > ( ) , getter ) ;
ConstPool cp = getter . getMethodInfo ( ) . getConstPool ( ) ; AnnotationsAttribute attr = ( AnnotationsAttribute ) getter . getMethodInfo ( ) . getAttribute ( AnnotationsAttribute . visibleTag ) ; if ( attr == null ) { attr = new AnnotationsAttribute ( cp , AnnotationsAttribute . visibleTag ) ; } Annotation manyToOne = new Annotation ( ManyToOne . class . getName ( ) , cp ) ; manyToOne . addMemberValue ( "optional" , new BooleanMemberValue ( false , cp ) ) ; attr . addAnnotation ( manyToOne ) ; Annotation joinColumns = new Annotation ( JoinColumns . class . getName ( ) , cp ) ; Annotation joinColumn1 = new Annotation ( JoinColumn . class . getName ( ) , cp ) ; joinColumn1 . addMemberValue ( "name" , new StringMemberValue ( "owner_tableName" , cp ) ) ; joinColumn1 . addMemberValue ( "referencedColumnName" , new StringMemberValue ( "tableName" , cp ) ) ; Annotation joinColumn2 = new Annotation ( JoinColumn . class . getName ( ) , cp ) ; joinColumn2 . addMemberValue ( "name" , new StringMemberValue ( "owner_profileName" , cp ) ) ; joinColumn2 . addMemberValue ( "referencedColumnName" , new StringMemberValue ( "profileName" , cp ) ) ; ArrayMemberValue joinColumnsMemberValue = new ArrayMemberValue ( cp ) ; joinColumnsMemberValue . setValue ( new MemberValue [ ] { new AnnotationMemberValue ( joinColumn1 , cp ) , new AnnotationMemberValue ( joinColumn2 , cp ) } ) ; joinColumns . addMemberValue ( "value" , joinColumnsMemberValue ) ; attr . addAnnotation ( joinColumns ) ; getter . getMethodInfo ( ) . addAttribute ( attr ) ; // generate concrete setProfileEntity method
String setProfileEntityMethodSrc = "public void setProfileEntity(" + ProfileEntity . class . getName ( ) + " profileEntity){ setOwner((" + concreteProfileEntityClass . getName ( ) + ")profileEntity); }" ; CtMethod setProfileEntityMethod = CtMethod . make ( setProfileEntityMethodSrc , concreteArrayValueClass ) ; concreteArrayValueClass . addMethod ( setProfileEntityMethod ) ; // write and load the attr array value class
String deployDir = profileComponent . getDeploymentDir ( ) . getAbsolutePath ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Writing PROFILE ATTR ARRAY VALUE CONCRETE CLASS ( " + concreteArrayValueClass . getName ( ) + " ) to: " + deployDir ) ; } concreteArrayValueClass . writeFile ( deployDir ) ; return Thread . currentThread ( ) . getContextClassLoader ( ) . loadClass ( concreteArrayValueClass . getName ( ) ) ; } catch ( Throwable e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; } finally { if ( concreteArrayValueClass != null ) { concreteArrayValueClass . defrost ( ) ; } }


signature:
public class SbbEntityIDComparator { /** * ( non - Javadoc )
 * @ see java . util . Comparator # compare ( java . lang . Object , java . lang . Object ) */
public int compare ( SbbEntityID sbbEntityID1 , SbbEntityID sbbEntityID2 ) { } }

implementation: if ( sbbEntityID1 == sbbEntityID2 ) { return 0 ; } if ( sbbEntityID1 == null ) { return 1 ; } if ( sbbEntityID2 == null ) { return - 1 ; } return higherPrioritySbb ( sbbEntityID1 , sbbEntityID2 ) ;


signature:
public class JPAProfileEntityFramework { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . component . profile . ProfileEntityFramework
 * # findProfilesByAttribute ( java . lang . String ,
 * org . mobicents . slee . container . component . profile . ProfileAttribute ,
 * java . lang . Object ) */
@ SuppressWarnings ( "unchecked" ) public Collection < ProfileEntity > findProfilesByAttribute ( String profileTable , ProfileAttribute profileAttribute , Object attributeValue ) { } }

implementation:
if ( logger . isTraceEnabled ( ) ) { logger . trace ( "findProfilesByAttribute( profileTable = " + profileTable + " , profileAttribute = " + profileAttribute + " , attributeValue = " + attributeValue + " )" ) ; } EntityManager em = getEntityManager ( ) ; Query query = null ; if ( profileAttribute == null ) { query = em . createQuery ( "SELECT x FROM " + profileEntityClassName + " x WHERE x.tableName = :tableName" ) . setParameter ( "tableName" , profileTable ) ; } else { if ( profileAttribute . isArray ( ) ) { query = em . createQuery ( "SELECT x FROM " + profileEntityClassName + " x , IN (x.c" + profileAttribute . getName ( ) + ") y WHERE x.tableName = :tableName AND y.string = :attrValue" ) . setParameter ( "tableName" , profileTable ) . setParameter ( "attrValue" , attributeValue . toString ( ) ) ; } else { // TODO handle Address objects in this use case , they can ' t be
// binary for search
query = em . createQuery ( "SELECT x FROM " + profileEntityClassName + " x WHERE x.tableName = :tableName AND x.c" + profileAttribute . getName ( ) + " = :attrValue" ) . setParameter ( "tableName" , profileTable ) . setParameter ( "attrValue" , attributeValue ) ; } } Collection < ProfileEntity > result = query . getResultList ( ) ; /* if ( logger . isDebugEnabled ( ) ) {
 logger . debug ( " findProfilesByAttribute : query = "
 + ( ( org . hibernate . ejb . QueryImpl ) query ) . getHibernateQuery ( ) . getQueryString ( )
 + " , result = " + result ) ; */
return result ;


signature:
public class JPAProfileEntityFramework { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . component . profile . ProfileEntityFramework
 * # findProfile ( java . lang . String , java . lang . String ) */
public ProfileEntity findProfile ( String profileTable , String profileName ) { } }

implementation: EntityManager em = getEntityManager ( ) ; Query query = em . createQuery ( "FROM " + profileEntityClassName + " WHERE tableName = ?1 AND profileName = ?2" ) . setParameter ( 1 , profileTable ) . setParameter ( 2 , profileName ) ; List < ? > resultList = query . getResultList ( ) ; if ( resultList . isEmpty ( ) ) { return null ; } else { return ( ProfileEntity ) resultList . get ( 0 ) ; }


signature:
public class JPAProfileEntityFramework { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . component . profile . ProfileEntityFramework
 * # getProfilesByStaticQuery ( java . lang . String , java . lang . String ,
 * java . lang . Object [ ] ) */
@ SuppressWarnings ( "unchecked" ) public Collection < ProfileEntity > getProfilesByStaticQuery ( String profileTable , String queryName , final Object [ ] parameters ) throws NullPointerException , UnrecognizedQueryNameException , AttributeTypeMismatchException , InvalidArgumentException { } }

implementation:
// TODO check for exceptions
final QueryWrapper wQuery = JPAQueryBuilder . getQuery ( queryName ) ; final EntityManager em = getEntityManager ( ) ; if ( System . getSecurityManager ( ) == null ) { Query staticQuery = em . createQuery ( wQuery . getQuerySQL ( profileEntityClassName ) ) ; if ( wQuery . getMaxMatches ( ) > 0 ) staticQuery . setMaxResults ( ( int ) wQuery . getMaxMatches ( ) ) ; for ( int i = 0 ; i < parameters . length ; i ++ ) { try { staticQuery . setParameter ( i + 1 , parameters [ i ] ) ; } catch ( Exception ignore ) { // We don ' t care , it ' s because there ' s no such parameter .
} } return staticQuery . getResultList ( ) ; } else { try { return AccessController . doPrivileged ( new PrivilegedExceptionAction < Collection < ProfileEntity > > ( ) { public Collection < ProfileEntity > run ( ) throws Exception { Query staticQuery = em . createQuery ( wQuery . getQuerySQL ( profileEntityClassName ) ) ; if ( wQuery . getMaxMatches ( ) > 0 ) staticQuery . setMaxResults ( ( int ) wQuery . getMaxMatches ( ) ) ; for ( int i = 0 ; i < parameters . length ; i ++ ) { try { staticQuery . setParameter ( i + 1 , parameters [ i ] ) ; } catch ( Exception ignore ) { // We don ' t care , it ' s because there ' s no such parameter .
} } return staticQuery . getResultList ( ) ; } } ) ; } catch ( PrivilegedActionException e ) { Throwable t = e . getCause ( ) ; if ( t instanceof NullPointerException ) throw ( NullPointerException ) t ; if ( t instanceof UnrecognizedQueryNameException ) throw ( UnrecognizedQueryNameException ) t ; if ( t instanceof AttributeTypeMismatchException ) throw ( AttributeTypeMismatchException ) t ; if ( t instanceof InvalidArgumentException ) throw ( InvalidArgumentException ) t ; throw new SLEEException ( "" , t ) ; } }


signature:
public class JPAProfileEntityFramework { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . component . profile . ProfileEntityFramework
 * # getProfilesByDynamicQuery ( java . lang . String ,
 * javax . slee . profile . query . QueryExpression ) */
@ SuppressWarnings ( "unchecked" ) public Collection < ProfileEntity > getProfilesByDynamicQuery ( String profileTable , QueryExpression expr ) throws UnrecognizedAttributeException , AttributeTypeMismatchException { } }

implementation:
// TODO check for exceptions
QueryWrapper wQuery = JPAQueryBuilder . parseDynamicQuery ( expr ) ; EntityManager em = getEntityManager ( ) ; Query dynamicQuery = em . createQuery ( wQuery . getQuerySQL ( profileEntityClassName ) ) ; int i = 1 ; for ( Object param : wQuery . getDynamicParameters ( ) ) { dynamicQuery . setParameter ( i ++ , param ) ; } if ( wQuery . getMaxMatches ( ) > 0 ) dynamicQuery . setMaxResults ( ( int ) wQuery . getMaxMatches ( ) ) ; return dynamicQuery . getResultList ( ) ;


signature:
public class JPAProfileEntityFramework { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . component . profile . ProfileEntityFramework
 * # persistProfile
 * ( org . mobicents . slee . container . component . profile . ProfileEntity ) */
public void persistProfile ( ProfileEntity profileEntity ) { } }

implementation:
EntityManager em = null ; // if ( checkUniqueFields ( profileObject ) )
em = getEntityManager ( ) ; em . persist ( profileEntity ) ; /* * } else { / / FIXME : We need to throw this PVException ! / / throw new
 * ProfileVerificationException
 * ( " Failed to persist profile due to uniqueness constraint . " ) ; throw
 * new
 * SLEEException ( " Failed to persist profile due to uniqueness constraint . " */


signature:
public class JPAProfileEntityFramework { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . component . profile . ProfileEntityFramework
 * # retrieveProfile ( java . lang . String , java . lang . String ) */
public ProfileEntity retrieveProfile ( String profileTable , String profileName ) { } }

implementation: if ( logger . isTraceEnabled ( ) ) { logger . trace ( "retrieveProfile( profileTableName = " + profileTable + " , profileName = " + profileName + " )" ) ; } if ( profileName == null ) { profileName = DEFAULT_PROFILE_NAME ; } EntityManager em = getEntityManager ( ) ; final Query q = em . createQuery ( "FROM " + profileEntityClassName + " WHERE tableName = ?1 AND profileName = ?2" ) . setParameter ( 1 , profileTable ) . setParameter ( 2 , profileName ) ; if ( System . getSecurityManager ( ) == null ) { List < ? > resultList = q . getResultList ( ) ; if ( resultList . size ( ) > 0 ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "ProfileEntity retrieved -> " + resultList . get ( 0 ) ) ; } return ( ProfileEntity ) resultList . get ( 0 ) ; } else { return null ; } } else { return AccessController . doPrivileged ( new PrivilegedAction < ProfileEntity > ( ) { public ProfileEntity run ( ) { List < ? > resultList = q . getResultList ( ) ; if ( resultList . size ( ) > 0 ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "ProfileEntity retrieved -> " + resultList . get ( 0 ) ) ; } return ( ProfileEntity ) resultList . get ( 0 ) ; } else { return null ; } } } ) ; }


signature:
public class JPAProfileEntityFramework { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . component . profile . ProfileEntityFramework
 * # removeprofile
 * ( org . mobicents . slee . container . component . profile . ProfileEntity ) */
public void renameProfileTable ( String oldProfileTableName , String newProfileTableName ) { } }

implementation: EntityManager em = getEntityManager ( ) ; final Query q = em . createQuery ( "UPDATE " + profileEntityClassName + " SET tableName = ?1 WHERE tableName = ?2" ) . setParameter ( 1 , newProfileTableName ) . setParameter ( 2 , oldProfileTableName ) ; q . executeUpdate ( ) ;


signature:
public class JPAProfileEntityFramework { /** * ( non - Javadoc )
 * @ see
 * org . mobicents . slee . container . component . profile . ProfileEntityFramework
 * # install ( ) */
public void install ( ) { } }

implementation:
synchronized ( this ) { // generate profile entity & related classes
new ConcreteProfileEntityGenerator ( component , this ) . generateClasses ( ) ; // this one is just a runtime optimization for faster query building
// now , later to use named queries
profileEntityClassName = profileEntityClass . getName ( ) ; profileEntityFactoryClass = new ConcreteProfileEntityFactoryGenerator ( component , profileEntityClass , profileEntityArrayAttrValueClassMap ) . generateClass ( ) ; try { profileEntityFactory = ( ProfileEntityFactory ) profileEntityFactoryClass . newInstance ( ) ; } catch ( Throwable e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; } // 1 . Generate CMP Interface Impl with JPA Annotations
component . setProfileCmpConcreteClass ( new ConcreteProfileGenerator ( component ) . generateConcreteProfile ( ) ) ; // 2 . Create the corresponding JPA PU - - FIXME : Should be somewhere
// else ?
createPersistenceUnit ( component ) ; new JPAQueryBuilder ( component ) . parseStaticQueries ( ) ; }