Input: / * ( non - Javadoc ) [CODESPLIT] public void setSbbPriority ( byte priority ) throws TransactionRequiredLocalException , NoSuchObjectLocalException , SLEEException { if ( trace ) logger . trace ( "setSbbPriority( priority = " + priority + " )" ) ; validateInvocation ( ) ; sbbEntity . setPriority ( priority ) ; }


Input: Builds the DU component from a jar with the specified file name contained in the specified DU jar file . The component is built in the specified deployment dir . [CODESPLIT] @ SuppressWarnings ( "deprecation" ) public List < AbstractSleeComponent > buildComponents ( String componentJarFileName , JarFile deployableUnitJar , File deploymentDir ) throws DeploymentException { // extract the component jar from the DU jar, to the temp du dir File extractedFile = extractFile ( componentJarFileName , deployableUnitJar , deploymentDir ) ; JarFile componentJarFile = null ; try { componentJarFile = new JarFile ( extractedFile ) ; } catch ( IOException e ) { throw new DeploymentException ( "failed to create jar file for extracted file " + extractedFile ) ; } InputStream componentDescriptorInputStream = null ; List < AbstractSleeComponent > components = new ArrayList < AbstractSleeComponent > ( ) ; try { // now extract the jar file to a new dir File componentJarDeploymentDir = new File ( deploymentDir , componentJarFileName + "-contents" ) ; if ( ! componentJarDeploymentDir . exists ( ) ) { // the jar may not be on root of DU, create additional dirs if needed LinkedList < File > dirsToCreate = new LinkedList < File > ( ) ; File dir = componentJarDeploymentDir . getParentFile ( ) ; while ( ! dir . equals ( deploymentDir ) ) { dirsToCreate . addFirst ( dir ) ; dir = dir . getParentFile ( ) ; } for ( File f : dirsToCreate ) { f . mkdir ( ) ; } // now create the dir for the component jar if ( ! componentJarDeploymentDir . mkdir ( ) ) { throw new SLEEException ( "dir for jar " + componentJarFileName + " not created in " + deploymentDir ) ; } } else { throw new SLEEException ( "dir for jar " + componentJarFileName + " already exists in " + deploymentDir ) ; } extractJar ( componentJarFile , componentJarDeploymentDir ) ; // create components from descriptor JarEntry componentDescriptor = null ; if ( ( componentDescriptor = componentJarFile . getJarEntry ( "META-INF/sbb-jar.xml" ) ) != null ) { // create class loader domain shared by all components URLClassLoaderDomainImpl classLoaderDomain = componentManagement . getClassLoaderFactory ( ) . newClassLoaderDomain ( new URL [ ] { componentJarDeploymentDir . toURL ( ) } , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; // parse descriptor componentDescriptorInputStream = componentJarFile . getInputStream ( componentDescriptor ) ; SbbDescriptorFactoryImpl descriptorFactory = componentManagement . getComponentDescriptorFactory ( ) . getSbbDescriptorFactory ( ) ; List < SbbDescriptorImpl > descriptors = descriptorFactory . parse ( componentDescriptorInputStream ) ; // create components for ( SbbDescriptorImpl descriptor : descriptors ) { PreferredPackagesBuilder . buildPreferredPackages ( descriptor , classLoaderDomain ) ; SbbComponentImpl component = new SbbComponentImpl ( descriptor ) ; component . setDeploymentDir ( componentJarDeploymentDir ) ; component . setClassLoaderDomain ( classLoaderDomain ) ; components . add ( component ) ; } } else if ( ( componentDescriptor = componentJarFile . getJarEntry ( "META-INF/profile-spec-jar.xml" ) ) != null ) { // create class loader domain shared by all components URLClassLoaderDomainImpl classLoaderDomain = componentManagement . getClassLoaderFactory ( ) . newClassLoaderDomain ( new URL [ ] { componentJarDeploymentDir . toURL ( ) } , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; // parse descriptor componentDescriptorInputStream = componentJarFile . getInputStream ( componentDescriptor ) ; ProfileSpecificationDescriptorFactoryImpl descriptorFactory = componentManagement . getComponentDescriptorFactory ( ) . getProfileSpecificationDescriptorFactory ( ) ; List < ProfileSpecificationDescriptorImpl > descriptors = descriptorFactory . parse ( componentDescriptorInputStream ) ; // create components for ( ProfileSpecificationDescriptorImpl descriptor : descriptors ) { ProfileSpecificationComponentImpl component = new ProfileSpecificationComponentImpl ( descriptor ) ; component . setDeploymentDir ( componentJarDeploymentDir ) ; component . setClassLoaderDomain ( classLoaderDomain ) ; components . add ( component ) ; } } else if ( ( componentDescriptor = componentJarFile . getJarEntry ( "META-INF/library-jar.xml" ) ) != null ) { Set < LibraryComponentImpl > libraryComponents = new HashSet < LibraryComponentImpl > ( ) ; // we need to gather all URLs for the shared class loader domain // to watch Set < URL > classLoaderDomainURLs = new HashSet < URL > ( ) ; classLoaderDomainURLs . add ( componentJarDeploymentDir . toURL ( ) ) ; // parse the descriptor componentDescriptorInputStream = componentJarFile . getInputStream ( componentDescriptor ) ; LibraryDescriptorFactoryImpl descriptorFactory = componentManagement . getComponentDescriptorFactory ( ) . getLibraryDescriptorFactory ( ) ; List < LibraryDescriptorImpl > descriptors = descriptorFactory . parse ( componentDescriptorInputStream ) ; // create components for ( LibraryDescriptorImpl descriptor : descriptors ) { LibraryComponentImpl component = new LibraryComponentImpl ( descriptor ) ; for ( JarDescriptor mJar : descriptor . getJars ( ) ) { classLoaderDomainURLs . add ( new File ( componentJarDeploymentDir , mJar . getJarName ( ) ) . toURL ( ) ) ; } // set deploy dir and cl domain component . setDeploymentDir ( componentJarDeploymentDir ) ; components . add ( component ) ; libraryComponents . add ( component ) ; } // create shared url domain URLClassLoaderDomainImpl classLoaderDomain = componentManagement . getClassLoaderFactory ( ) . newClassLoaderDomain ( classLoaderDomainURLs . toArray ( new URL [ classLoaderDomainURLs . size ( ) ] ) , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; // add it to each component for ( LibraryComponentImpl component : libraryComponents ) { component . setClassLoaderDomain ( classLoaderDomain ) ; } } else if ( ( componentDescriptor = componentJarFile . getJarEntry ( "META-INF/event-jar.xml" ) ) != null ) { // create class loader domain shared by all components URLClassLoaderDomainImpl classLoaderDomain = componentManagement . getClassLoaderFactory ( ) . newClassLoaderDomain ( new URL [ ] { componentJarDeploymentDir . toURL ( ) } , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; // parse descriptor componentDescriptorInputStream = componentJarFile . getInputStream ( componentDescriptor ) ; EventTypeDescriptorFactoryImpl descriptorFactory = componentManagement . getComponentDescriptorFactory ( ) . getEventTypeDescriptorFactory ( ) ; List < EventTypeDescriptorImpl > descriptors = descriptorFactory . parse ( componentDescriptorInputStream ) ; // create components for ( EventTypeDescriptorImpl descriptor : descriptors ) { EventTypeComponentImpl component = new EventTypeComponentImpl ( descriptor ) ; component . setDeploymentDir ( componentJarDeploymentDir ) ; component . setClassLoaderDomain ( classLoaderDomain ) ; components . add ( component ) ; } } else if ( ( componentDescriptor = componentJarFile . getJarEntry ( "META-INF/resource-adaptor-type-jar.xml" ) ) != null ) { // create class loader domain shared by all components URLClassLoaderDomainImpl classLoaderDomain = componentManagement . getClassLoaderFactory ( ) . newClassLoaderDomain ( new URL [ ] { componentJarDeploymentDir . toURL ( ) } , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; // parse descriptor componentDescriptorInputStream = componentJarFile . getInputStream ( componentDescriptor ) ; ResourceAdaptorTypeDescriptorFactoryImpl descriptorFactory = componentManagement . getComponentDescriptorFactory ( ) . getResourceAdaptorTypeDescriptorFactory ( ) ; List < ResourceAdaptorTypeDescriptorImpl > descriptors = descriptorFactory . parse ( componentDescriptorInputStream ) ; // create components for ( ResourceAdaptorTypeDescriptorImpl descriptor : descriptors ) { ResourceAdaptorTypeComponentImpl component = new ResourceAdaptorTypeComponentImpl ( descriptor ) ; component . setDeploymentDir ( componentJarDeploymentDir ) ; component . setClassLoaderDomain ( classLoaderDomain ) ; components . add ( component ) ; } } else if ( ( componentDescriptor = componentJarFile . getJarEntry ( "META-INF/resource-adaptor-jar.xml" ) ) != null ) { // create class loader domain shared by all components URLClassLoaderDomainImpl classLoaderDomain = componentManagement . getClassLoaderFactory ( ) . newClassLoaderDomain ( new URL [ ] { componentJarDeploymentDir . toURL ( ) } , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; // parse descriptor componentDescriptorInputStream = componentJarFile . getInputStream ( componentDescriptor ) ; ResourceAdaptorDescriptorFactoryImpl descriptorFactory = componentManagement . getComponentDescriptorFactory ( ) . getResourceAdaptorDescriptorFactory ( ) ; List < ResourceAdaptorDescriptorImpl > descriptors = descriptorFactory . parse ( componentDescriptorInputStream ) ; // create components for ( ResourceAdaptorDescriptorImpl descriptor : descriptors ) { ResourceAdaptorComponentImpl component = new ResourceAdaptorComponentImpl ( descriptor ) ; component . setDeploymentDir ( componentJarDeploymentDir ) ; component . setClassLoaderDomain ( classLoaderDomain ) ; components . add ( component ) ; } } else { throw new DeploymentException ( "No Deployment Descriptor found in the " + componentJarFile . getName ( ) + " entry of a deployable unit." ) ; } } catch ( IOException e ) { throw new DeploymentException ( "failed to parse jar descriptor from " + componentJarFile . getName ( ) , e ) ; } finally { if ( componentDescriptorInputStream != null ) { try { componentDescriptorInputStream . close ( ) ; } catch ( IOException e ) { logger . error ( "failed to close inputstream of descriptor for jar " + componentJarFile ) ; } } } // close component jar file try { componentJarFile . close ( ) ; } catch ( IOException e ) { logger . error ( "failed to close component jar file" , e ) ; } // and delete the extracted jar file, we don't need it anymore if ( ! extractedFile . delete ( ) ) { logger . warn ( "failed to delete " + extractedFile ) ; } return components ; }


Input: Extracts the file with name <code > fileName< / code > out of the <code > containingJar< / code > archive and stores it in <code > dstDir< / code > . [CODESPLIT] private File extractFile ( String fileName , JarFile containingJar , File dstDir ) throws DeploymentException { ZipEntry zipFileEntry = containingJar . getEntry ( fileName ) ; logger . trace ( "Extracting file " + fileName + " from " + containingJar . getName ( ) ) ; if ( zipFileEntry == null ) { throw new DeploymentException ( "Error extracting jar file  " + fileName + " from " + containingJar . getName ( ) ) ; } File extractedFile = new File ( dstDir , new File ( zipFileEntry . getName ( ) ) . getName ( ) ) ; try { pipeStream ( containingJar . getInputStream ( zipFileEntry ) , new FileOutputStream ( extractedFile ) ) ; } catch ( FileNotFoundException e ) { throw new DeploymentException ( "file " + fileName + " not found in " + containingJar . getName ( ) , e ) ; } catch ( IOException e ) { throw new DeploymentException ( "erro extracting file " + fileName + " from " + containingJar . getName ( ) , e ) ; } logger . debug ( "Extracted file " + extractedFile . getName ( ) ) ; return extractedFile ; }


Input: This method will extract all the files in the jar file [CODESPLIT] private void extractJar ( JarFile jarFile , File dstDir ) throws DeploymentException { // Extract jar contents to a classpath location JarInputStream jarIs = null ; try { jarIs = new JarInputStream ( new BufferedInputStream ( new FileInputStream ( jarFile . getName ( ) ) ) ) ; for ( JarEntry entry = jarIs . getNextJarEntry ( ) ; jarIs . available ( ) > 0 && entry != null ; entry = jarIs . getNextJarEntry ( ) ) { logger . trace ( "jar entry = " + entry . getName ( ) ) ; if ( entry . isDirectory ( ) ) { // Create jar directories. File dir = new File ( dstDir , entry . getName ( ) ) ; if ( ! dir . exists ( ) ) { if ( ! dir . mkdirs ( ) ) { logger . debug ( "Failed to create directory " + dir . getAbsolutePath ( ) ) ; throw new IOException ( "Failed to create directory " + dir . getAbsolutePath ( ) ) ; } } else logger . trace ( "Created directory" + dir . getAbsolutePath ( ) ) ; } else // unzip files { File file = new File ( dstDir , entry . getName ( ) ) ; File dir = file . getParentFile ( ) ; if ( ! dir . exists ( ) ) { if ( ! dir . mkdirs ( ) ) { logger . debug ( "Failed to create directory " + dir . getAbsolutePath ( ) ) ; throw new IOException ( "Failed to create directory " + dir . getAbsolutePath ( ) ) ; } else logger . trace ( "Created directory" + dir . getAbsolutePath ( ) ) ; } pipeStream ( jarFile . getInputStream ( entry ) , new FileOutputStream ( file ) ) ; } } } catch ( Exception e ) { throw new DeploymentException ( "failed to extract jar file " + jarFile . getName ( ) ) ; } finally { if ( jarIs != null ) { try { jarIs . close ( ) ; } catch ( IOException e ) { logger . error ( "failed to close jar input stream" , e ) ; } } } }


Input: Pipes data from the input stream into the output stream . [CODESPLIT] private void pipeStream ( InputStream is , OutputStream os ) throws IOException { synchronized ( buffer ) { try { for ( int bytesRead = is . read ( buffer ) ; bytesRead != - 1 ; bytesRead = is . read ( buffer ) ) os . write ( buffer , 0 , bytesRead ) ; is . close ( ) ; os . close ( ) ; } catch ( IOException ioe ) { try { is . close ( ) ; } catch ( Exception ioexc ) { /* do sth? */ } try { os . close ( ) ; } catch ( Exception ioexc ) { /* do sth? */ } throw ioe ; } } }


Input: Puts an object in cache data [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public Object putObject ( Object key , Object value ) { return getNode ( ) . put ( key , value ) ; }


Input: Tries to attaches an sbb entity [CODESPLIT] public boolean attachSbbEntity ( SbbEntityID sbbEntityId ) { final Node node = getAttachedSbbsNode ( true ) ; if ( ! node . hasChild ( sbbEntityId ) ) { node . addChild ( Fqn . fromElements ( sbbEntityId ) ) ; return true ; } else { return false ; } }


Input: Detaches an sbb entity [CODESPLIT] public boolean detachSbbEntity ( SbbEntityID sbbEntityId ) { final Node node = getAttachedSbbsNode ( false ) ; return node != null ? node . removeChild ( sbbEntityId ) : false ; }


Input: Verifies if there at least one sbb entity attached [CODESPLIT] public boolean noSbbEntitiesAttached ( ) { final Node node = getAttachedSbbsNode ( false ) ; return node != null ? node . getChildrenNames ( ) . isEmpty ( ) : true ; }


Input: Return a set with all sbb entities attached . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public Set < SbbEntityID > getSbbEntitiesAttached ( ) { final Node node = getAttachedSbbsNode ( false ) ; return node != null ? node . getChildrenNames ( ) : Collections . emptySet ( ) ; }


Input: Attaches a timer [CODESPLIT] public boolean attachTimer ( TimerID timerID ) { final Node node = getAttachedTimersNode ( true ) ; if ( ! node . hasChild ( timerID ) ) { node . addChild ( Fqn . fromElements ( timerID ) ) ; return true ; } else { return false ; } }


Input: Detaches a timer [CODESPLIT] public boolean detachTimer ( TimerID timerID ) { final Node node = getAttachedTimersNode ( false ) ; return node != null ? node . removeChild ( timerID ) : false ; }


Input: Verifies if there at least one timer attached [CODESPLIT] public boolean noTimersAttached ( ) { final Node node = getAttachedTimersNode ( false ) ; return node != null ? node . getChildrenNames ( ) . isEmpty ( ) : true ; }


Input: Returns the set of timers attached to the ac [CODESPLIT] public Set getAttachedTimers ( ) { final Node node = getAttachedTimersNode ( false ) ; return node != null ? node . getChildrenNames ( ) : Collections . emptySet ( ) ; }


Input: Adds the specified name to the set of names bound to the ac [CODESPLIT] public void nameBound ( String name ) { final Node node = getNamesBoundNode ( true ) ; if ( ! node . hasChild ( name ) ) { node . addChild ( Fqn . fromElements ( name ) ) ; } }


Input: Removes the specified name from the set of names bound to the ac [CODESPLIT] public boolean nameUnbound ( String name ) { final Node node = getNamesBoundNode ( false ) ; return node != null ? node . removeChild ( name ) : false ; }


Input: Verifies if there at least one name bound to the ac [CODESPLIT] public boolean noNamesBound ( ) { final Node node = getNamesBoundNode ( false ) ; return node != null ? node . getChildrenNames ( ) . isEmpty ( ) : true ; }


Input: Returns the set of names bound to the ac [CODESPLIT] public Set getNamesBoundCopy ( ) { final Node node = getNamesBoundNode ( false ) ; return node != null ? node . getChildrenNames ( ) : Collections . emptySet ( ) ; }


Input: Sets the aci cmp attribute [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public void setCmpAttribute ( String attrName , Object attrValue ) { final Node node = getCmpAttributesNode ( true ) ; Node cmpNode = node . getChild ( attrName ) ; if ( cmpNode == null ) { cmpNode = node . addChild ( Fqn . fromElements ( attrName ) ) ; } cmpNode . put ( CMP_ATTRIBUTES_NODE_MAP_KEY , attrValue ) ; }


Input: Retrieves the aci cmp attribute [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public Object getCmpAttribute ( String attrName ) { final Node node = getCmpAttributesNode ( false ) ; if ( node == null ) { return null ; } else { final Node cmpNode = node . getChild ( attrName ) ; if ( cmpNode != null ) { return cmpNode . get ( CMP_ATTRIBUTES_NODE_MAP_KEY ) ; } else { return null ; } } }


Input: Retrieves a map copy of the aci attributes set [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public Map getCmpAttributesCopy ( ) { final Node node = getCmpAttributesNode ( false ) ; if ( node == null ) { return Collections . emptyMap ( ) ; } else { Map result = new HashMap ( ) ; Node cmpNode = null ; for ( Object obj : node . getChildren ( ) ) { cmpNode = ( Node ) obj ; result . put ( cmpNode . getFqn ( ) . getLastElement ( ) , cmpNode . get ( CMP_ATTRIBUTES_NODE_MAP_KEY ) ) ; } return result ; } }


Input: FIXME : add check for access? [CODESPLIT] protected String appendToBuffer ( String message , String section , String buffer ) { buffer += ( this . component . getDescriptor ( ) . getResourceAdaptorID ( ) + " : violates section " + section + " of jSLEE 1.1 specification : " + message + "\n" ) ; return buffer ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] @ Override protected void processArguments ( String [ ] args ) throws CommandException { String sopts = ":a:f:sug" ; LongOpt [ ] lopts = { new LongOpt ( "tracers-used" , LongOpt . REQUIRED_ARGUMENT , null , ' ' ) , new LongOpt ( "tracers-set" , LongOpt . REQUIRED_ARGUMENT , null , ' ' ) , new LongOpt ( "set-level" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "cid" , LongOpt . REQUIRED_ARGUMENT , null , SetLevelOperation . cid ) , new LongOpt ( "nsrc" , LongOpt . REQUIRED_ARGUMENT , null , SetLevelOperation . nsrc ) , new LongOpt ( "name" , LongOpt . REQUIRED_ARGUMENT , null , SetLevelOperation . name ) , new LongOpt ( "level" , LongOpt . REQUIRED_ARGUMENT , null , SetLevelOperation . level ) , new LongOpt ( "un-set-level" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "nsrc" , LongOpt . REQUIRED_ARGUMENT , null , UnsetLevelOperation . nsrc ) , new LongOpt ( "name" , LongOpt . REQUIRED_ARGUMENT , null , UnsetLevelOperation . name ) , new LongOpt ( "get-level" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "cid" , LongOpt . REQUIRED_ARGUMENT , null , GetLevelOperation . cid ) , new LongOpt ( "nsrc" , LongOpt . REQUIRED_ARGUMENT , null , GetLevelOperation . nsrc ) , new LongOpt ( "name" , LongOpt . REQUIRED_ARGUMENT , null , GetLevelOperation . name ) , } ; Getopt getopt = new Getopt ( null , args , sopts , lopts ) ; // getopt.setOpterr(false);
 int code ; while ( ( code = getopt . getopt ( ) ) != - 1 ) { switch ( code ) { case ' ' : throw new CommandException ( "Option requires an argument: " + args [ getopt . getOptind ( ) - 1 ] ) ; case ' ' : throw new CommandException ( "Invalid (or ambiguous) option: " + args [ getopt . getOptind ( ) - 1 ] ) ; case ' ' : super . operation = new GetTracersUsedOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : super . operation = new GetTracersSetOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : super . operation = new SetLevelOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : super . operation = new UnsetLevelOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : super . operation = new GetLevelOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; default : throw new CommandException ( "Command: \"" + getName ( ) + "\", found unexpected opt: " + args [ getopt . getOptind ( ) - 1 ] ) ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public ActivityContextInterface getActivityContextInterface ( ProfileTableActivity profileTableActivity ) throws NullPointerException , TransactionRequiredLocalException , UnrecognizedActivityException , FactoryException { if ( profileTableActivity == null || profileTableActivity . getProfileTableName ( ) == null ) { throw new NullPointerException ( "null profile table activity" ) ; } serviceContainer . getTransactionManager ( ) . mandateTransaction ( ) ; ProfileTableImpl profileTableImpl = null ; try { // check if this is an assigned profile table // name. profileTableImpl = profileManagementImpl . getProfileTable ( profileTableActivity . getProfileTableName ( ) ) ; } catch ( UnrecognizedProfileTableNameException e ) { throw new UnrecognizedActivityException ( profileTableActivity . getProfileTableName ( ) , e ) ; } ActivityContext ac = profileTableImpl . getActivityContext ( ) ; if ( ac == null ) { throw new UnrecognizedActivityException ( "No resource for: " + profileTableActivity . getProfileTableName ( ) , profileTableActivity ) ; } return ac . getActivityContextInterface ( ) ; }


Input: Initiates the notification info for usage mbeans [CODESPLIT] private static MBeanNotificationInfo [ ] initNotificationInfo ( ) { String [ ] notificationTypes = new String [ ] { ProfileTableNotification . USAGE_NOTIFICATION_TYPE , ResourceAdaptorEntityNotification . USAGE_NOTIFICATION_TYPE , SbbNotification . USAGE_NOTIFICATION_TYPE , SubsystemNotification . USAGE_NOTIFICATION_TYPE } ; return new MBeanNotificationInfo [ ] { new MBeanNotificationInfo ( notificationTypes , UsageNotification . class . getName ( ) , "JAIN SLEE 1.1 Usage MBean Notification" ) } ; }


Input: Send the notification . [CODESPLIT] public void sendUsageNotification ( long value , long seqno , String usageParameterSetName , String usageParameterName , boolean isCounter ) { UsageNotificationManagerMBeanImpl notificationManager = parent . getUsageNotificationManagerMBean ( notificationSource ) ; if ( notificationManager == null || notificationManager . getNotificationsEnabled ( usageParameterName ) ) { // if the notification manager is null we consider the notification // can be sent UsageNotification notification = createUsageNotification ( value , seqno , usageParameterSetName , usageParameterName , isCounter ) ; for ( ListenerFilterHandbackTriplet triplet : listeners . values ( ) ) { if ( triplet . notificationFilter == null || triplet . notificationFilter . isNotificationEnabled ( notification ) ) { triplet . notificationListener . handleNotification ( notification , triplet . handbackObject ) ; } } } }


Input: Creates an instance of an { @link UsageNotification } for the specified args . This operation is exposed to allow it be overriden by { @link SbbUsageMBean } impl . [CODESPLIT] protected UsageNotification createUsageNotification ( long value , long seqno , String usageParameterSetName , String usageParameterName , boolean isCounter ) { return new UsageNotification ( notificationSource . getUsageNotificationType ( ) , this , notificationSource , usageParameterSetName , usageParameterName , isCounter , value , seqno , System . currentTimeMillis ( ) ) ; }


Input: Retrieves the JAIN SLEE specs descriptor [CODESPLIT] public javax . slee . resource . ResourceAdaptorTypeDescriptor getSpecsDescriptor ( ) { if ( specsDescriptor == null ) { final LibraryID [ ] libraryIDs = descriptor . getLibraryRefs ( ) . toArray ( new LibraryID [ descriptor . getLibraryRefs ( ) . size ( ) ] ) ; final String [ ] activityTypes = descriptor . getActivityTypes ( ) . toArray ( new String [ descriptor . getActivityTypes ( ) . size ( ) ] ) ; final EventTypeID [ ] eventTypes = descriptor . getEventTypeRefs ( ) . toArray ( new EventTypeID [ descriptor . getEventTypeRefs ( ) . size ( ) ] ) ; String raInterface = descriptor . getResourceAdaptorInterface ( ) == null ? null : descriptor . getResourceAdaptorInterface ( ) ; specsDescriptor = new javax . slee . resource . ResourceAdaptorTypeDescriptor ( getResourceAdaptorTypeID ( ) , getDeployableUnit ( ) . getDeployableUnitID ( ) , getDeploymentUnitSource ( ) , libraryIDs , activityTypes , raInterface , eventTypes ) ; } return specsDescriptor ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] @ Override protected void processArguments ( String [ ] args ) throws CommandException { String sopts = ":lcrng" ; LongOpt [ ] lopts = { new LongOpt ( "list" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "table" , LongOpt . OPTIONAL_ARGUMENT , null , ListOperation . table ) , new LongOpt ( "profile" , LongOpt . REQUIRED_ARGUMENT , null , ListOperation . profile ) , new LongOpt ( "create" , LongOpt . NO_ARGUMENT , null , ' ' ) , //those are also for remove
 new LongOpt ( "profile-name" , LongOpt . REQUIRED_ARGUMENT , null , CreateOperation . profile_name ) , new LongOpt ( "table-name" , LongOpt . REQUIRED_ARGUMENT , null , CreateOperation . table_name ) , new LongOpt ( "profile-spec" , LongOpt . REQUIRED_ARGUMENT , null , CreateOperation . profile_spec ) , new LongOpt ( "remove" , LongOpt . NO_ARGUMENT , null , ' ' ) , //covered above
 new LongOpt ( "rename" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "current-name" , LongOpt . REQUIRED_ARGUMENT , null , RenameOperation . current_name ) , new LongOpt ( "new-name" , LongOpt . REQUIRED_ARGUMENT , null , RenameOperation . new_name ) , new LongOpt ( "get" , LongOpt . NO_ARGUMENT , null , ' ' ) , //new LongOpt("profile-name", LongOpt.REQUIRED_ARGUMENT, null, GetOperation.profile_name),
 new LongOpt ( "profile-spec" , LongOpt . REQUIRED_ARGUMENT , null , GetOperation . profile_spec ) , //new LongOpt("profile", LongOpt.REQUIRED_ARGUMENT, null, GetOperation.profile),
 } ; Getopt getopt = new Getopt ( null , args , sopts , lopts ) ; getopt . setOpterr ( false ) ; int code ; while ( ( code = getopt . getopt ( ) ) != - 1 ) { switch ( code ) { case ' ' : throw new CommandException ( "Option requires an argument: " + args [ getopt . getOptind ( ) - 1 ] ) ; case ' ' : throw new CommandException ( "Invalid (or ambiguous) option: " + args [ getopt . getOptind ( ) - 1 ] ) ; case ' ' : super . operation = new ListOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : super . operation = new CreateOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : super . operation = new RemoveOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : super . operation = new RenameOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : super . operation = new GetOperation ( super . context , super . log , this ) ; super . operation . buildOperation ( getopt , args ) ; break ; default : throw new CommandException ( "Command: \"" + getName ( ) + "\", found unexpected opt: " + args [ getopt . getOptind ( ) - 1 ] ) ; } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void persistentInstall ( URL deployableUnitURL ) throws DeploymentException { try { doPersistentInstall ( deployableUnitURL , deployDir ) ; } catch ( Exception e ) { throw new DeploymentException ( e ) ; } }


Input:
/ * ( non - Javadoc ) [CODESPLIT] public void persistentUninstall ( URL deployableUnitURL ) throws DeploymentException { try { // All we really care is for the filename
 String fullPath = deployableUnitURL . getFile ( ) ; String filename = fullPath . substring ( fullPath . lastIndexOf ( ' ' ) + 1 ) ; // Here's what we want to delete
 String filePath = deployDir + File . separator + filename ; // Delete it
 if ( ! new File ( filePath ) . delete ( ) ) { throw new DeploymentException ( "Failed to delete " + filePath ) ; } } catch ( Exception e ) { throw new DeploymentException ( e ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void clusterInstall ( URL deployableUnitURL ) throws DeploymentException { try { doPersistentInstall ( deployableUnitURL , farmDeployDir ) ; } catch ( Exception e ) { throw new DeploymentException ( e ) ; } }


Input:
/ * ( non - Javadoc ) [CODESPLIT] public void clusterUninstall ( URL deployableUnitURL ) throws DeploymentException { try { // All we really care is for the filename
 String fullPath = deployableUnitURL . getFile ( ) ; String filename = fullPath . substring ( fullPath . lastIndexOf ( ' ' ) + 1 ) ; // Here's what we want to delete
 String filePath = farmDeployDir + File . separator + filename ; // Delete it
 if ( ! new File ( filePath ) . delete ( ) ) { throw new DeploymentException ( "Failed to delete " + filePath ) ; } } catch ( Exception e ) { throw new DeploymentException ( e ) ; } }


Input:
Downloads a remote DU to a local folder [CODESPLIT] private File downloadRemoteDU ( URL duURL , File deploymentRoot ) throws Exception { InputStream in = null ; OutputStream out = null ; try { // Get the filename out of the URL
 String filename = new File ( duURL . getPath ( ) ) . getName ( ) ; // Prepare for creating the file at deploy folder
 File tempFile = new File ( deploymentRoot , filename ) ; out = new BufferedOutputStream ( new FileOutputStream ( tempFile ) ) ; URLConnection conn = duURL . openConnection ( ) ; in = conn . getInputStream ( ) ; // Get the data
 byte [ ] buffer = new byte [ 1024 ] ; int numRead ; while ( ( numRead = in . read ( buffer ) ) != - 1 ) { out . write ( buffer , 0 , numRead ) ; } // Done! Successful.
 return tempFile ; } finally { // Do the clean up.
 try { if ( in != null ) { in . close ( ) ; in = null ; } if ( out != null ) { out . close ( ) ; out = null ; } } catch ( IOException ioe ) { // Shouldn't happen, let's ignore.
 } } }


Input: Updates the list of components already deployed to SLEE . [CODESPLIT] public void updateDeployedComponents ( ) { try { // Get the SLEE Component Repo ComponentRepository componentRepository = sleeContainerDeployer . getSleeContainer ( ) . getComponentRepository ( ) ; // First we'll put the components in a temp Collection ConcurrentLinkedQueue < String > newDeployedComponents = new ConcurrentLinkedQueue < String > ( ) ; // Get the deployed Profile Specifications for ( ComponentID componentID : componentRepository . getProfileSpecificationIDs ( ) ) { newDeployedComponents . add ( componentID . toString ( ) ) ; } // Get the deployed Event Types for ( ComponentID componentID : componentRepository . getEventComponentIDs ( ) ) { newDeployedComponents . add ( componentID . toString ( ) ) ; } // Get the deployed Resource Adaptor Types for ( ComponentID componentID : componentRepository . getResourceAdaptorTypeIDs ( ) ) { newDeployedComponents . add ( componentID . toString ( ) ) ; } // Get the deployed Resource Adaptors for ( ComponentID componentID : componentRepository . getResourceAdaptorIDs ( ) ) { newDeployedComponents . add ( componentID . toString ( ) ) ; } // Get the deployed Service Building Blocks (SBBs) for ( ComponentID componentID : componentRepository . getSbbIDs ( ) ) { newDeployedComponents . add ( componentID . toString ( ) ) ; } // Get the deployed Services for ( ComponentID componentID : componentRepository . getServiceIDs ( ) ) { newDeployedComponents . add ( componentID . toString ( ) ) ; } // Get the deployed Libraries for ( ComponentID componentID : componentRepository . getLibraryIDs ( ) ) { newDeployedComponents . add ( componentID . toString ( ) ) ; } ResourceManagement resourceManagement = sleeContainerDeployer . getSleeContainer ( ) . getResourceManagement ( ) ; // Get the existing Resource Adaptor Entity links String [ ] entityNames = resourceManagement . getResourceAdaptorEntities ( ) ; for ( String entityName : entityNames ) { newDeployedComponents . addAll ( Arrays . asList ( resourceManagement . getLinkNames ( entityName ) ) ) ; } // All good.. Make the temp the good one. deployedComponents = newDeployedComponents ; } catch ( Exception e ) { logger . warn ( "Failure while updating deployed components." , e ) ; } }


Input: Method for installing a Deployable Unit into SLEE . [CODESPLIT] public void installDeployableUnit ( DeployableUnit du ) throws Exception { // Update the deployed components from SLEE updateDeployedComponents ( ) ; // Check if the DU is ready to be installed if ( du . isReadyToInstall ( true ) ) { // Get and Run the actions needed for installing this DU sciAction ( du . getInstallActions ( ) , du ) ; // Set the DU as installed du . setInstalled ( true ) ; // Add the DU to the installed list deployedDUs . add ( du ) ; // Update the deployed components from SLEE updateDeployedComponents ( ) ; // Go through the remaining DUs waiting for installation Iterator < DeployableUnit > duIt = waitingForInstallDUs . iterator ( ) ; while ( duIt . hasNext ( ) ) { DeployableUnit waitingDU = duIt . next ( ) ; // If it is ready for installation, follow the same procedure if ( waitingDU . isReadyToInstall ( false ) ) { // Get and Run the actions needed for installing this DU sciAction ( waitingDU . getInstallActions ( ) , waitingDU ) ; // Set the DU as installed waitingDU . setInstalled ( true ) ; // Add the DU to the installed list deployedDUs . add ( waitingDU ) ; // Update the deployed components from SLEE updateDeployedComponents ( ) ; // Remove the DU from the waiting list. waitingForInstallDUs . remove ( waitingDU ) ; // Let's start all over.. :) duIt = waitingForInstallDUs . iterator ( ) ; } } } else { logger . warn ( "Unable to INSTALL " + du . getDeploymentInfoShortName ( ) + " right now. Waiting for dependencies to be resolved." ) ; // The DU can't be installed now, let's wait... waitingForInstallDUs . add ( du ) ; } }


Input: Method for uninstalling a Deployable Unit into SLEE . [CODESPLIT] public void uninstallDeployableUnit ( DeployableUnit du ) throws Exception { // Update the deployed components from SLEE updateDeployedComponents ( ) ; // It isn't installed? if ( ! du . isInstalled ( ) ) { // Then it should be in the waiting list... remove and we're done. if ( waitingForInstallDUs . remove ( du ) ) { logger . info ( du . getDeploymentInfoShortName ( ) + " wasn't deployed. Removing from waiting list." ) ; } } // Check if DU components are still present  else if ( ! du . areComponentsStillPresent ( ) ) { logger . info ( du . getDeploymentInfoShortName ( ) + " components already removed. Removing DU info." ) ; // Process internals of undeployment... processInternalUndeploy ( du ) ; } // Check if the DU is ready to be uninstalled else if ( du . isReadyToUninstall ( ) ) { // Get and Run the actions needed for uninstalling this DU sciAction ( du . getUninstallActions ( ) , du ) ; // Process internals of undeployment... processInternalUndeploy ( du ) ; } else { // Have we been her already? If so, don't flood user with log messages... if ( ! waitingForUninstallDUs . contains ( du ) ) { // Add it to the waiting list. waitingForUninstallDUs . add ( du ) ; logger . warn ( "Unable to UNINSTALL " + du . getDeploymentInfoShortName ( ) + " right now. Waiting for dependents to be removed." ) ; } throw new DependencyException ( "Unable to undeploy " + du . getDeploymentInfoShortName ( ) ) ; } }


Input: Sets the DU as not installed and remove it from waiting list if present there . Also tries to undeploy DU s waiting for dependencies to be removed . [CODESPLIT] private void processInternalUndeploy ( DeployableUnit du ) throws Exception { // Set the DU as not installed du . setInstalled ( false ) ; // Remove if it was present in waiting list waitingForUninstallDUs . remove ( du ) ; // Update the deployed components from SLEE updateDeployedComponents ( ) ; // Go through the remaining DUs waiting for uninstallation Iterator < DeployableUnit > duIt = waitingForUninstallDUs . iterator ( ) ; while ( duIt . hasNext ( ) ) { DeployableUnit waitingDU = duIt . next ( ) ; // If it is ready for being uninstalled, follow the same procedure if ( waitingDU . isReadyToUninstall ( ) ) { // Schedule removal sleeContainerDeployer . getSleeSubDeployer ( ) . stop ( waitingDU . getURL ( ) , waitingDU . getDeploymentInfoShortName ( ) ) ; // Remove the DU from the waiting list. If it fails, will go back. waitingForUninstallDUs . remove ( waitingDU ) ; // Let's start all over.. :) duIt = waitingForUninstallDUs . iterator ( ) ; } } }


Input:
Method for performing the actions needed for ( un ) deployment . [CODESPLIT] private void sciAction ( Collection < ManagementAction > actions , DeployableUnit du ) throws Exception { // For each action, get the params.. for ( ManagementAction action : actions ) { // Shall we skip this action? if ( actionsToAvoidByDU . get ( du ) != null && actionsToAvoidByDU . get ( du ) . remove ( action ) ) { // Clean if it was the last one. if ( actionsToAvoidByDU . get ( du ) . size ( ) == 0 ) { actionsToAvoidByDU . remove ( du ) ; } continue ; } if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Invoking " + action ) ; } // We are isolating each action, so it won't affect the whole proccess try { // Invoke it. action . invoke ( ) ; // We need to wait for service/entity to deactivate... /*if(action instanceof DeactivateServiceAction) {
          waitForServiceDeactivation((DeactivateServiceAction) action);
        }
        else if (action instanceof DeactivateResourceAdaptorEntityAction) {
          waitForResourceAdaptorEntityDeactivation((DeactivateResourceAdaptorEntityAction) action);
        }*/ } catch ( Exception e ) { // We might expect some exceptions... if ( e . getCause ( ) instanceof ResourceAdaptorEntityAlreadyExistsException || ( e . getCause ( ) instanceof InvalidStateException && action instanceof ActivateResourceAdaptorEntityAction ) ) { Class < ? extends ManagementAction > actionToAvoid = null ; // If the activate/create failed then we don't want to deactivate/remove if ( action instanceof ActivateResourceAdaptorEntityAction ) { actionToAvoid = DeactivateResourceAdaptorEntityAction . class ; } else if ( action instanceof CreateResourceAdaptorEntityAction ) { actionToAvoid = RemoveResourceAdaptorEntityAction . class ; } Collection < Class < ? extends ManagementAction > > actionsToAvoid ; if ( ( actionsToAvoid = actionsToAvoidByDU . get ( du ) ) == null ) { actionsToAvoid = new ArrayList < Class < ? extends ManagementAction > > ( ) ; // Add it to the list of actions to skip on undeploy actionsToAvoid . add ( actionToAvoid ) ; // And put it to the map actionsToAvoidByDU . put ( du , actionsToAvoid ) ; } else { // Add it to the list of actions to skip on undeploy actionsToAvoid . add ( actionToAvoid ) ; } logger . warn ( e . getCause ( ) . getMessage ( ) ) ; } else if ( e . getCause ( ) instanceof InvalidStateException && action instanceof DeactivateServiceAction ) { logger . info ( "Delaying uninstall due to service deactivation not complete." ) ; } else if ( e . getCause ( ) instanceof InvalidStateException && action instanceof DeactivateResourceAdaptorEntityAction ) { // ignore this... someone has already deactivated the link. } else if ( e . getCause ( ) instanceof UnrecognizedLinkNameException && action instanceof UnbindLinkNameAction ) { // ignore this... someone has already removed the link. } else if ( action . getType ( ) == ManagementAction . Type . DEPLOY_MANAGEMENT ) { logger . error ( "Failure invoking '" + action , e ) ; } else { throw e ; } } // Wait a little while just to make sure it finishes Thread . sleep ( waitTimeBetweenOperations ) ; } }


Input:
Method for showing current status of the Deployment Manager . [CODESPLIT] public String showStatus ( ) { // Update the currently deployed components. updateDeployedComponents ( ) ; String output = "" ; output += "
Deployable Units Waiting For Install:
" ; for ( DeployableUnit waitingDU : waitingForInstallDUs ) { output += "+-- " + waitingDU . getDeploymentInfoShortName ( ) + "
" ; for ( String dependency : waitingDU . getExternalDependencies ( ) ) { if ( ! deployedComponents . contains ( dependency ) ) dependency += " MISSING!" ; output += "  +-- depends on " + dependency + "
" ; } } output += "
Deployable Units Waiting For Uninstall:
" ; for ( DeployableUnit waitingDU : waitingForUninstallDUs ) { output += "+-- " + waitingDU . getDeploymentInfoShortName ( ) + "
" ; } return output ; }


Input: Callback for { [CODESPLIT] public void sleeShutdown ( ) { logger . info ( "Undeploying all Deployable Units due to SLEE shutdown" ) ; // undeploy each DU in reverse order  while ( ! deployedDUs . isEmpty ( ) ) { DeployableUnit du = deployedDUs . removeLast ( ) ; try { uninstallDeployableUnit ( du ) ; } catch ( Exception e ) { logger . error ( "Failed to uninstall DU, in SLEE shutdown" , e ) ; } } }


Input: If the message should be logged convert the JDK 1 . 4 LogRecord to a Log4J message . [CODESPLIT] public boolean isLoggable ( LogRecord record ) { Logger logger = getLogger ( record ) ; if ( record . getThrown ( ) != null ) { logWithThrowable ( logger , record ) ; } else { logWithoutThrowable ( logger , record ) ; } return false ; }


Input: get the Log4J logger corresponding to the java . util . logger . LogRecord [CODESPLIT] private Logger getLogger ( LogRecord record ) { String loggerName = record . getLoggerName ( ) ; Logger logger = loggerCache . get ( loggerName ) ; if ( logger == null ) { logger = Logger . getLogger ( loggerName ) ; loggerCache . put ( loggerName , logger ) ; } return logger ; }


Input: Retrieves the component ids for components that refers the specified component [CODESPLIT] public Set < SleeComponent > getReferringComponents ( SleeComponent component ) { Set < SleeComponent > result = new HashSet < SleeComponent > ( ) ; for ( EventTypeComponent otherComponent : eventTypeComponents . values ( ) ) { if ( ! otherComponent . getComponentID ( ) . equals ( component . getComponentID ( ) ) ) { if ( otherComponent . getDependenciesSet ( ) . contains ( component . getComponentID ( ) ) ) { result . add ( otherComponent ) ; } } } for ( LibraryComponent otherComponent : libraryComponents . values ( ) ) { if ( ! otherComponent . getComponentID ( ) . equals ( component . getComponentID ( ) ) ) { if ( otherComponent . getDependenciesSet ( ) . contains ( component . getComponentID ( ) ) ) { result . add ( otherComponent ) ; } } } for ( ProfileSpecificationComponent otherComponent : profileSpecificationComponents . values ( ) ) { if ( ! otherComponent . getComponentID ( ) . equals ( component . getComponentID ( ) ) ) { if ( otherComponent . getDependenciesSet ( ) . contains ( component . getComponentID ( ) ) ) { result . add ( otherComponent ) ; } } } for ( ResourceAdaptorComponent otherComponent : resourceAdaptorComponents . values ( ) ) { if ( ! otherComponent . getComponentID ( ) . equals ( component . getComponentID ( ) ) ) { if ( otherComponent . getDependenciesSet ( ) . contains ( component . getComponentID ( ) ) ) { result . add ( otherComponent ) ; } } } for ( ResourceAdaptorTypeComponent otherComponent : resourceAdaptorTypeComponents . values ( ) ) { if ( ! otherComponent . getComponentID ( ) . equals ( component . getComponentID ( ) ) ) { if ( otherComponent . getDependenciesSet ( ) . contains ( component . getComponentID ( ) ) ) { result . add ( otherComponent ) ; } } } for ( SbbComponent otherComponent : sbbComponents . values ( ) ) { if ( ! otherComponent . getComponentID ( ) . equals ( component . getComponentID ( ) ) ) { if ( otherComponent . getDependenciesSet ( ) . contains ( component . getComponentID ( ) ) ) { result . add ( otherComponent ) ; } } } for ( ServiceComponent otherComponent : serviceComponents . values ( ) ) { if ( ! otherComponent . getComponentID ( ) . equals ( component . getComponentID ( ) ) ) { if ( otherComponent . getDependenciesSet ( ) . contains ( component . getComponentID ( ) ) ) { result . add ( otherComponent ) ; } } } return result ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] @ Override public void displayHelp ( ) { PrintWriter out = context . getWriter ( ) ; out . println ( desc ) ; // out.println("usage: " + name +
 // " <-tprofileTableName> [-pprofileName] <operation> <arg>*");
 addHeaderDescription ( out ) ; out . println ( "'SetID' refers to SetName or SbbID and SetName." ) ; out . println ( ) ; out . println ( "operation:" ) ; out . println ( "    -l, --list                     Lists certain information about parameters sets. Requires one of options to be present:" ) ; out . println ( "           --sets                  Instructs command to list declared parameter sets. Does not require argument." ) ; out . println ( "           --parameters            Instructs command to list parameters of parameter set. Does not require argument." ) ; //TODO: make 'list' also list notification mngr conf for resource set.
 out . println ( "    -g, --get                      Fetches value of certain parameter in set. Does not take argument." ) ; out . println ( "                                   Requires '--name' option to be present. Following options are supported: " ) ; out . println ( "           --name                  Specifies name of parameter in a set for get operation. Requires parameter name as argument. This option is mandatory." ) ; out . println ( "           --rst                   If present, indicates that 'get' operation should reset parameter value. Does not require argument." ) ; out . println ( "    -r, --reset                    Resets assets in 'Usage' realm. Does not take argument. If 'SetID' is specified, reset command resets specific set, otherwise it acts on default one." ) ; out . println ( "                                   If it is not present, reset command performs operation on default set. Following option is supported:" ) ; out . println ( "           --all                   Resets ALL parameters for 'ResourceName', ignores 'SetID'." ) ; out . println ( "    -c, --create                   Creates usage parameter set for given 'SetID'. Does not require argument." ) ; out . println ( "    -d, --delete                   Deletes usage parameter set with given 'SetID'. Does not require argument." ) ; out . println ( "    -n, --notify                   This operation either turn on/off notifications for parameter or queries about state of notifications." ) ; out . println ( "                                   Does not take parameter, supports following options:" ) ; out . println ( "           --name                  Specifies name of parameter. Requires parameter name as argument. It is mandatory." ) ; out . println ( "           --value                 Specifies value of parameter. Requires boolean argument." ) ; out . println ( "           --is                    Request information about notification(if its enabled). Does not require argument." ) ; //out.println("    -i, --is-notify                Checks if notification is on for certain parameter in set. Following options are supported:");
 //out.println("           --name                  Specifies name of parameter. Requires parameter name as argument. It is mandatory.");
 out . println ( "" ) ; out . println ( "Examples: " ) ; addExamples ( out ) ; out . flush ( ) ; }


Input:
/ * ( non - Javadoc ) [CODESPLIT] @ Override protected void processArguments ( String [ ] args ) throws CommandException { //String sopts = "-:lgrcdni";
 String sopts = "-:lgrcdn" ; LongOpt [ ] lopts = { new LongOpt ( "noprefix" , LongOpt . NO_ARGUMENT , null , 0x1000 ) , // operration part
 new LongOpt ( "list" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "sets" , LongOpt . NO_ARGUMENT , null , ListOperation . sets ) , new LongOpt ( "parameters" , LongOpt . NO_ARGUMENT , null , ListOperation . parameters ) , new LongOpt ( "get" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "name" , LongOpt . REQUIRED_ARGUMENT , null , GetOperation . name ) , new LongOpt ( "rst" , LongOpt . NO_ARGUMENT , null , GetOperation . rst ) , new LongOpt ( "reset" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "all" , LongOpt . NO_ARGUMENT , null , ResetOperation . all ) , new LongOpt ( "create" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "delete" , LongOpt . NO_ARGUMENT , null , ' ' ) , //mgmt
 new LongOpt ( "notify" , LongOpt . NO_ARGUMENT , null , ' ' ) , new LongOpt ( "value" , LongOpt . REQUIRED_ARGUMENT , null , NotifyOperation . value ) , new LongOpt ( "is-notify" , LongOpt . NO_ARGUMENT , null , NotifyOperation . is ) , } ; Getopt getopt = new Getopt ( null , args , sopts , lopts ) ; getopt . setOpterr ( false ) ; int nonOptArgIndex = 0 ; int code ; while ( ( code = getopt . getopt ( ) ) != - 1 ) { switch ( code ) { case ' ' : throw new CommandException ( "Option requires an argument: " + args [ getopt . getOptind ( ) - 1 ] ) ; case ' ' : throw new CommandException ( "Invalid (or ambiguous) option: " + args [ getopt . getOptind ( ) - 1 ] ) ; case 0x1000 : break ; case 1 : // non opt args, table and profile name(maybe)
 switch ( nonOptArgIndex ) { case 0 : resourceName = getopt . getOptarg ( ) ; if ( resourceName . startsWith ( PREFIX_SERVICEID ) ) { try { editor . setAsText ( resourceName ) ; } catch ( Exception e ) { throw new CommandException ( "Command: \"" + getName ( ) + "\" failed to parse ServiceID." , e ) ; } this . serviceID = ( ServiceID ) editor . getValue ( ) ; this . resourceName = null ; } nonOptArgIndex ++ ; break ; case 1 : if ( this . serviceID != null ) { try { this . editor . setAsText ( getopt . getOptarg ( ) ) ; } catch ( Exception e ) { throw new CommandException ( "Command: \"" + getName ( ) + "\" failed to parse SbbID." , e ) ; } this . sbbID = ( SbbID ) this . editor . getValue ( ) ; } else { usageSetName = getopt . getOptarg ( ) ; } nonOptArgIndex ++ ; break ; case 2 : if ( this . serviceID == null ) { throw new CommandException ( "Command: \"" + getName ( ) + "\" expects at most two non opt arguments!" ) ; } usageSetName = getopt . getOptarg ( ) ; nonOptArgIndex ++ ; break ; default : throw new CommandException ( "Command: \"" + getName ( ) + "\" expects at most three non opt arguments!" ) ; } break ; case ' ' : // list
 super . operation = new ListOperation ( super . context , super . log , this ) ; prepareCommand ( ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : // get
 super . operation = new GetOperation ( super . context , super . log , this ) ; prepareCommand ( ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : // reset
 super . operation = new ResetOperation ( super . context , super . log , this ) ; prepareCommand ( ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : // create
 super . operation = new CreateOperation ( super . context , super . log , this ) ; prepareCommand ( ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : // delete
 super . operation = new DeleteOperation ( super . context , super . log , this ) ; prepareCommand ( ) ; super . operation . buildOperation ( getopt , args ) ; break ; case ' ' : // notify mngr
 super . operation = new NotifyOperation ( super . context , super . log , this ) ; prepareCommand ( ) ; super . operation . buildOperation ( getopt , args ) ; break ; //			case 'i':
 //				// check notify
 //				super.operation = new IsNotifyOperation(super.context, super.log, this);
 //				prepareCommand();
 //				super.operation.buildOperation(getopt, args);
 //				break;
 default : throw new CommandException ( "Command: \"" + getName ( ) + "\", found unexpected opt: " + args [ getopt . getOptind ( ) - 1 ] ) ; } } }


Input: Get a <code > TimerPreserveMissed< / code > object from an integer value . [CODESPLIT] public static TimerPreserveMissed fromInt ( int option ) throws IllegalArgumentException { switch ( option ) { case PRESERVE_NONE : return NONE ; case PRESERVE_ALL : return ALL ; case PRESERVE_LAST : return LAST ; default : throw new IllegalArgumentException ( "Invalid preserve-missed value: " + option ) ; } }


Input: Get a <code > TimerPreserveMissed< / code > object from a string value . [CODESPLIT] public static TimerPreserveMissed fromString ( String option ) throws NullPointerException , IllegalArgumentException { if ( option == null ) throw new NullPointerException ( "option is null" ) ; if ( option . equalsIgnoreCase ( NONE_STRING ) ) return NONE ; if ( option . equalsIgnoreCase ( ALL_STRING ) ) return ALL ; if ( option . equalsIgnoreCase ( LAST_STRING ) ) return LAST ; throw new IllegalArgumentException ( "Invalid preserve-missed value: " + option ) ; }


Input: Retrieves a set containing sbb entity ids in the factory cache data [CODESPLIT] public Set < SbbEntityID > getSbbEntities ( ) { final Node node = getNode ( ) ; if ( node == null ) { return Collections . emptySet ( ) ; } HashSet < SbbEntityID > result = new HashSet < SbbEntityID > ( ) ; ServiceID serviceID = null ; for ( Object obj : node . getChildrenNames ( ) ) { serviceID = ( ServiceID ) obj ; for ( SbbEntityID sbbEntityID : getRootSbbEntityIDs ( serviceID ) ) { result . add ( sbbEntityID ) ; collectSbbEntities ( sbbEntityID , result ) ; } } return result ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public ActivityContextInterface [ ] getActivities ( ) throws TransactionRequiredLocalException , IllegalStateException , SLEEException { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "getActivities() " + this . sbbObject . getState ( ) ) ; } if ( SbbObjectState . READY != this . sbbObject . getState ( ) ) { throw new IllegalStateException ( "Cannot call SbbContext.getActivities() in " + this . sbbObject . getState ( ) ) ; } ActivityContextFactory acf = sleeContainer . getActivityContextFactory ( ) ; List < ActivityContextInterface > result = new ArrayList < ActivityContextInterface > ( ) ; ActivityContext ac = null ; for ( ActivityContextHandle ach : sbbObject . getSbbEntity ( ) . getActivityContexts ( ) ) { ac = acf . getActivityContext ( ach ) ; if ( ac != null ) { result . add ( ac . getActivityContextInterface ( ) ) ; } } return result . toArray ( EMPTY_ACI_ARRAY ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean getRollbackOnly ( ) throws TransactionRequiredLocalException , SLEEException { SleeTransactionManager txMgr = sleeContainer . getTransactionManager ( ) ; txMgr . mandateTransaction ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "in getRollbackOnly on " + this ) ; } try { return txMgr . getRollbackOnly ( ) ; } catch ( SystemException e ) { throw new SLEEException ( "Problem with the tx manager!" ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public SbbLocalObject getSbbLocalObject ( ) throws TransactionRequiredLocalException , IllegalStateException , SLEEException { sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; if ( this . sbbObject . getState ( ) != SbbObjectState . READY ) throw new IllegalStateException ( "Bad state : " + this . sbbObject . getState ( ) ) ; return sbbObject . getSbbEntity ( ) . getSbbLocalObject ( ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void maskEvent ( String [ ] eventNames , ActivityContextInterface aci ) throws NullPointerException , TransactionRequiredLocalException , IllegalStateException , UnrecognizedEventException , NotAttachedException , SLEEException { if ( SbbObjectState . READY != this . sbbObject . getState ( ) ) { throw new IllegalStateException ( "Cannot call SbbContext maskEvent in " + this . sbbObject . getState ( ) ) ; } if ( this . sbbObject . getSbbEntity ( ) == null ) { // this shouldnt happen since SbbObject state ready shoudl be set // when its fully setup, but.... throw new IllegalStateException ( "Wrong state! SbbEntity is not assigned" ) ; } sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; ActivityContextHandle ach = ( ( org . mobicents . slee . container . activity . ActivityContextInterface ) aci ) . getActivityContext ( ) . getActivityContextHandle ( ) ; if ( ! sbbObject . getSbbEntity ( ) . isAttached ( ach ) ) throw new NotAttachedException ( "ACI is not attached to SBB " ) ; sbbObject . getSbbEntity ( ) . setEventMask ( ach , eventNames ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setRollbackOnly ( ) throws TransactionRequiredLocalException , SLEEException { final SleeTransactionManager sleeTransactionManager = sleeContainer . getTransactionManager ( ) ; sleeTransactionManager . mandateTransaction ( ) ; try { sleeTransactionManager . setRollbackOnly ( ) ; } catch ( SystemException e ) { throw new SLEEException ( "failed to mark tx for rollback" , e ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public Object getActivityContextInterfaceFactory ( ResourceAdaptorTypeID raTypeID ) throws NullPointerException , IllegalArgumentException { if ( raTypeID == null ) { throw new NullPointerException ( "null ra type id" ) ; } if ( ! sbbObject . getSbbComponent ( ) . getDependenciesSet ( ) . contains ( raTypeID ) ) { throw new IllegalArgumentException ( "ra type " + raTypeID + " not referred by the sbb." ) ; } return sleeContainer . getComponentRepository ( ) . getComponentByID ( raTypeID ) . getActivityContextInterfaceFactory ( ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public Object getResourceAdaptorInterface ( ResourceAdaptorTypeID raTypeID , String raLink ) throws NullPointerException , IllegalArgumentException { if ( raTypeID == null ) { throw new NullPointerException ( "null ra type id" ) ; } if ( raLink == null ) { throw new NullPointerException ( "null ra link" ) ; } if ( ! sbbObject . getSbbComponent ( ) . getDependenciesSet ( ) . contains ( raTypeID ) ) { throw new IllegalArgumentException ( "ra type " + raTypeID + " not referred by the sbb." ) ; } final ResourceManagement resourceManagement = sleeContainer . getResourceManagement ( ) ; String raEntityName = null ; try { raEntityName = resourceManagement . getResourceAdaptorEntityName ( raLink ) ; } catch ( UnrecognizedLinkNameException e ) { throw new IllegalArgumentException ( "ra link " + raLink + " not found." ) ; } return resourceManagement . getResourceAdaptorEntity ( raEntityName ) . getResourceAdaptorInterface ( raTypeID ) ; }


Input: special handling of serialization [CODESPLIT] private void writeObject ( ObjectOutputStream out ) throws IOException { VendorExtensionUtils . writeObject ( out , vendorDataSerializationEnabled ? vendorData : null ) ; }


Input: special handling of deserialization [CODESPLIT] private void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { vendorData = VendorExtensionUtils . readObject ( in , vendorDataDeserializationEnabled ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public List < EventTypeDescriptorImpl > parse ( InputStream inputStream ) throws DeploymentException { Object jaxbPojo = buildJAXBPojo ( inputStream ) ; List < EventTypeDescriptorImpl > result = new ArrayList < EventTypeDescriptorImpl > ( ) ; boolean isSlee11 = false ; MEventJar mEventJar = null ; if ( jaxbPojo instanceof org . mobicents . slee . container . component . deployment . jaxb . slee . event . EventJar ) { mEventJar = new MEventJar ( ( org . mobicents . slee . container . component . deployment . jaxb . slee . event . EventJar ) jaxbPojo ) ; } else if ( jaxbPojo instanceof org . mobicents . slee . container . component . deployment . jaxb . slee11 . event . EventJar ) { mEventJar = new MEventJar ( ( org . mobicents . slee . container . component . deployment . jaxb . slee11 . event . EventJar ) jaxbPojo ) ; isSlee11 = true ; } else { throw new SLEEException ( "unexpected class of jaxb pojo built: " + ( jaxbPojo != null ? jaxbPojo . getClass ( ) : null ) ) ; } List < LibraryID > libraryRefs = mEventJar . getLibraryRef ( ) ; for ( MEventDefinition mEventDefinition : mEventJar . getEventDefinition ( ) ) { result . add ( new EventTypeDescriptorImpl ( mEventDefinition , libraryRefs , isSlee11 ) ) ; } return result ; }


Input: generic for all calls [CODESPLIT] private Permissions getPermissions ( Permissions permissions , final CodeSource cs , Principal [ ] principals ) { List < PolicyHolderEntry > entries = this . currentPolicy . get ( ) . policyHolderEntries ; for ( PolicyHolderEntry phe : entries ) { // general selectPermissions ( permissions , cs , principals , phe ) ; // FIXME: certs? } return permissions ; }


Input: newGlobalPolicyHolder ) { [CODESPLIT] private boolean loadPolicy ( String policyURLString , GlobalPolicyHolder newGlobalPolicyHolder ) { // System.err.println("Load policy: " + policyURLString); try { URI policyURI = null ; if ( policyURLString . startsWith ( _PROTOCOL_FILE ) ) { File policyFile = new File ( policyURLString . replaceFirst ( _PROTOCOL_FILE_PREFIX , "" ) ) ; if ( ! policyFile . exists ( ) || ! policyFile . isFile ( ) || ! policyFile . canRead ( ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Could not load file: " + policyURLString + ", exists[" + policyFile . exists ( ) + "] isFile[" + policyFile . isFile ( ) + "] canRead[" + policyFile . canRead ( ) + "] " ) ; } // Hmm... return false ; } else { policyURI = policyFile . toURI ( ) . normalize ( ) ; } } else { policyURI = new URI ( policyURLString ) ; } PolicyParser pp = new PolicyParser ( true ) ; InputStream is = getStream ( policyURI ) ; InputStreamReader reader = new InputStreamReader ( is ) ; pp . read ( reader ) ; reader . close ( ) ; // KeyStore ks = ..... FIXME: KeyStore ks = null ; Enumeration < PolicyParser . GrantEntry > grantEntries = pp . grantElements ( ) ; while ( grantEntries . hasMoreElements ( ) ) { parseGrantEntry ( grantEntries . nextElement ( ) , ks , newGlobalPolicyHolder ) ; } } catch ( Exception e ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Failed to read policy file due to some error." ) ; e . printStackTrace ( ) ; } return false ; } return true ; }


Input: private InputStream getStream ( URL url ) throws IOException { [CODESPLIT] private InputStream getStream ( URI uri ) throws IOException { try { if ( uri . toURL ( ) . getProtocol ( ) . equals ( _PROTOCOL_FILE ) ) { String path = uri . toURL ( ) . getFile ( ) . replace ( ' ' , File . separatorChar ) ; return new FileInputStream ( path ) ; } else { return uri . toURL ( ) . openStream ( ) ; } } catch ( java . lang . IllegalArgumentException e ) { // this happens if url is relative, meaning a file? return new FileInputStream ( new File ( uri ) ) ; } }


Input: This function MUST convert code source passed . Meaning it must normalize URL . For instance security framework may pass url that conceptualy matches pat specified policy files but comparison wont match . See url belowe . <ul > <li > <b > 1 - < / b > jar : file : / D : / java / servers / jboss - 5 . 0 . 0 . GA / server / default / deploy / restcomm . sar / lib / jar . jar! / < / li > <li > <b > 2 - < / b > file : / D : / java / servers / jboss - 5 . 0 . 0 . GA / server / default / deploy / - < / li > < / ul > URL 1 is passed from security framework as source of loaded classes . However it is not matched by second one ( and is should ) [CODESPLIT] CodeSource performUrlConversion ( CodeSource cs , boolean extractSignerCerts ) { String path = null ; CodeSource parsedCodeSource = null ; URL locationURL = cs . getLocation ( ) ; if ( locationURL != null ) { // can happen for default. Permission urlAccessPermission = null ; try { urlAccessPermission = locationURL . openConnection ( ) . getPermission ( ) ; } catch ( IOException e ) { } if ( urlAccessPermission != null && urlAccessPermission instanceof FilePermission ) { path = ( ( FilePermission ) urlAccessPermission ) . getName ( ) ; } else if ( ( urlAccessPermission == null ) && ( locationURL . getProtocol ( ) . equals ( "file" ) ) ) { path = locationURL . getFile ( ) . replace ( "/" , File . separator ) ; // FIXME: do more? } else { // FIXME: ?? } } if ( path == null ) { if ( extractSignerCerts ) { parsedCodeSource = new CodeSource ( cs . getLocation ( ) , getSignerCertificates ( cs ) ) ; } } else { try { // Sun says it fails if ( path . endsWith ( "*" ) ) { // remove trailing '*' because it causes // canonicaization // to fail on win32 path = path . substring ( 0 , path . length ( ) - 1 ) ; boolean removeTrailingFileSep = false ; if ( path . endsWith ( File . separator ) ) removeTrailingFileSep = true ; if ( path . equals ( "" ) ) { path = System . getProperty ( "user.dir" ) ; } File f = new File ( path ) ; path = f . getCanonicalPath ( ) ; StringBuffer sb = new StringBuffer ( path ) ; // reappend '*' to canonicalized filename (note that // canonicalization may have removed trailing file // separator, so we have to check for that, too) if ( ! path . endsWith ( File . separator ) && removeTrailingFileSep ) sb . append ( File . separator ) ; sb . append ( ' ' ) ; path = sb . toString ( ) ; } else if ( path . endsWith ( File . separator ) ) { // this is xxxx/x.jar!/ case..... path = path . substring ( 0 , path . length ( ) - 1 ) ; if ( path . endsWith ( "!" ) ) { path = path . substring ( 0 , path . length ( ) - 1 ) ; } } else { path = new File ( path ) . getCanonicalPath ( ) ; } // FIXME: possible convert URL? what is check this in // rfc locationURL = fileToEncodedURL ( new File ( path ) ) ; //locationURL = new URL("file", "", path); if ( extractSignerCerts ) { parsedCodeSource = new CodeSource ( locationURL , getSignerCertificates ( cs ) ) ; } else { parsedCodeSource = new CodeSource ( locationURL , cs . getCertificates ( ) ) ; } } catch ( IOException ioe ) { // leave codesource as it is, unless we have to extract // its // signer certificates if ( extractSignerCerts ) { parsedCodeSource = new CodeSource ( cs . getLocation ( ) , getSignerCertificates ( cs ) ) ; } } } return parsedCodeSource ; // CodeSource o = AccessController.doPrivileged(new // PerformURLConversionAction(extractSignerCerts,cs)); // return o; }


Input: Some methods to expose info about what is goign on . [CODESPLIT] public String getCodeSources ( ) { List < String > css = new ArrayList < String > ( ) ; for ( PolicyHolderEntry phe : this . currentPolicy . get ( ) . policyHolderEntries ) { css . add ( phe . getCodeSource ( ) . getLocation ( ) == null ? "default" : phe . getCodeSource ( ) . getLocation ( ) . toString ( ) ) ; } return Arrays . toString ( css . toArray ( ) ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public void dataRemoved ( FqnWrapper fqnWrapper ) { final Fqn fqn = fqnWrapper . getFqn ( ) ; ra . dataRemoved ( ( K ) fqn . getLastElement ( ) ) ; }


Input: Create a new instance of this object and set the SbbContext This places it into the object pool . [CODESPLIT] public Object makeObject ( ) { SbbObject retval ; if ( doTraceLogs ) { logger . trace ( "makeObject() for " + serviceID + " and " + sbbComponent ) ; } final ClassLoader oldClassLoader = SleeContainerUtils . getCurrentThreadClassLoader ( ) ; try { final ClassLoader cl = sbbComponent . getClassLoader ( ) ; if ( System . getSecurityManager ( ) != null ) AccessController . doPrivileged ( new PrivilegedAction < Object > ( ) { public Object run ( ) { Thread . currentThread ( ) . setContextClassLoader ( cl ) ; return null ; } } ) ; else Thread . currentThread ( ) . setContextClassLoader ( cl ) ; retval = new SbbObjectImpl ( serviceID , sbbComponent ) ; } finally { if ( System . getSecurityManager ( ) != null ) AccessController . doPrivileged ( new PrivilegedAction < Object > ( ) { public Object run ( ) { Thread . currentThread ( ) . setContextClassLoader ( oldClassLoader ) ; return null ; } } ) ; else Thread . currentThread ( ) . setContextClassLoader ( oldClassLoader ) ; } retval . setState ( SbbObjectState . POOLED ) ; return retval ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public ProfileLocalObject create ( String profileName ) throws NullPointerException , IllegalArgumentException , TransactionRequiredLocalException , ReadOnlyProfileException , ProfileAlreadyExistsException , CreateException , SLEEException { sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; checkProfileSpecIsNotReadOnly ( ) ; ProfileObjectImpl profileObject = createProfile ( profileName ) ; profileObject . profilePersist ( ) ; return profileObject . getProfileLocalObject ( ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public ProfileLocalObject find ( String profileName ) throws NullPointerException , TransactionRequiredLocalException , SLEEException { if ( profileName == null ) { throw new NullPointerException ( ) ; } ProfileObjectImpl profileObject = getProfile ( profileName ) ; return profileObject == null ? null : profileObject . getProfileLocalObject ( ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public Collection < ProfileLocalObject > findAll ( ) throws TransactionRequiredLocalException , SLEEException { sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; Collection < ProfileLocalObject > result = new ArrayList < ProfileLocalObject > ( ) ; for ( ProfileEntity profileEntity : component . getProfileEntityFramework ( ) . findAll ( this . getProfileTableName ( ) ) ) { result . add ( transactionView . getProfile ( profileEntity ) . getProfileLocalObject ( ) ) ; } return Collections . unmodifiableCollection ( result ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean remove ( String profileName ) throws NullPointerException , ReadOnlyProfileException , TransactionRequiredLocalException , SLEEException { if ( profileName == null ) { throw new NullPointerException ( "Profile name must not be null" ) ; } checkProfileSpecIsNotReadOnly ( ) ; return this . removeProfile ( profileName , true , false ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public ProfileLocalObject findProfileByAttribute ( String attributeName , Object attributeValue ) throws NullPointerException , IllegalArgumentException , TransactionRequiredLocalException , SLEEException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "findProfileByAttribute( attributeName = " + attributeName + " , attributeValue = " + attributeValue + " )" ) ; } Collection < ProfileLocalObject > plocs = findProfilesByAttribute ( attributeName , attributeValue ) ; if ( plocs . size ( ) == 0 ) { return null ; } else { return plocs . iterator ( ) . next ( ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public Collection < ProfileLocalObject > findProfilesByAttribute ( String attributeName , Object attributeValue ) throws NullPointerException , IllegalArgumentException , TransactionRequiredLocalException , SLEEException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "findProfilesByAttribute( attributeName = " + attributeName + " , attributeValue = " + attributeValue + " )" ) ; } sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; // We get profile entities Collection < ProfileEntity > profileEntities = null ; try { profileEntities = getProfileEntitiesByAttribute ( attributeName , attributeValue , true ) ; } catch ( AttributeNotIndexedException e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; } catch ( UnrecognizedAttributeException e ) { throw new IllegalArgumentException ( e ) ; } catch ( AttributeTypeMismatchException e ) { throw new IllegalArgumentException ( e ) ; } // We need ProfileLocalObjects ArrayList < ProfileLocalObject > plocs = new ArrayList < ProfileLocalObject > ( ) ; for ( ProfileEntity profileEntity : profileEntities ) { plocs . add ( transactionView . getProfile ( profileEntity ) . getProfileLocalObject ( ) ) ; } return Collections . unmodifiableCollection ( plocs ) ; }


Input: / * [CODESPLIT] public Collection < ProfileID > getProfilesByAttribute ( String attributeName , Object attributeValue , boolean isSlee11 ) throws UnrecognizedAttributeException , AttributeNotIndexedException , AttributeTypeMismatchException , SLEEException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "getProfilesByAttribute( attributeName = " + attributeName + " , attributeValue = " + attributeValue + " , isSlee11 = " + isSlee11 + " )" ) ; } // We get profile entities Collection < ProfileEntity > profileEntities = getProfileEntitiesByAttribute ( attributeName , attributeValue , isSlee11 ) ; // We need ProfileIDs Collection < ProfileID > profileIDs = new ArrayList < ProfileID > ( ) ; for ( ProfileEntity profileEntity : profileEntities ) { profileIDs . add ( new ProfileID ( profileEntity . getTableName ( ) , profileEntity . getProfileName ( ) ) ) ; } return Collections . unmodifiableCollection ( profileIDs ) ; }


Input: Retrieves the { [CODESPLIT] private Collection < ProfileEntity > getProfileEntitiesByAttribute ( String attributeName , Object attributeValue , boolean isSlee11 ) throws UnrecognizedAttributeException , AttributeNotIndexedException , AttributeTypeMismatchException , SLEEException { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "getProfileEntitiesByAttribute( attributeName = " + attributeName + " , attributeValue = " + attributeValue + " , isSlee11 = " + isSlee11 + " )" ) ; } ProfileAttribute profileAttribute = getProfileAttribute ( attributeName , attributeValue ) ; if ( isSlee11 ) { // validate attr value type if ( ! ProfileTableImpl . PROFILE_ATTR_ALLOWED_TYPES . contains ( attributeValue . getClass ( ) . getName ( ) ) ) { throw new AttributeTypeMismatchException ( attributeValue . getClass ( ) + " is not a valid profile attribute value type" ) ; } } else { if ( ! profileAttribute . isIndex ( ) ) { throw new AttributeNotIndexedException ( component . toString ( ) + " defines an attribute named " + attributeName + " but not indexed" ) ; } } return component . getProfileEntityFramework ( ) . findProfilesByAttribute ( this . getProfileTableName ( ) , profileAttribute , attributeValue ) ; }


Input: Retrieves the { [CODESPLIT] private ProfileAttribute getProfileAttribute ( String attributeName , Object attributeValue ) throws NullPointerException , UnrecognizedAttributeException , AttributeTypeMismatchException { if ( attributeName == null ) { throw new NullPointerException ( "attribute name is null" ) ; } if ( attributeValue == null ) { throw new NullPointerException ( "attribute value is null" ) ; } ProfileAttribute profileAttribute = component . getProfileAttributes ( ) . get ( attributeName ) ; if ( profileAttribute == null ) { throw new UnrecognizedAttributeException ( component . toString ( ) + " does not defines an attribute named " + attributeName ) ; } else { Class < ? > allowedProfileAttributeType = profileAttribute . getNonPrimitiveType ( ) . isArray ( ) ? profileAttribute . getNonPrimitiveType ( ) . getComponentType ( ) : profileAttribute . getNonPrimitiveType ( ) ; if ( ! allowedProfileAttributeType . getName ( ) . equals ( attributeValue . getClass ( ) . getName ( ) ) ) { throw new AttributeTypeMismatchException ( component . toString ( ) + " defines an attribute named " + attributeName + " with value type " + profileAttribute . getType ( ) + ", the specified value is of type " + attributeValue . getClass ( ) ) ; } else { return profileAttribute ; } } }


Input: Determines if profile is in back end storage == visible to other compoenents than MBean if null is passed as argumetn it must check for any other than defualt? [CODESPLIT] public boolean profileExists ( String profileName ) { boolean result = component . getProfileEntityFramework ( ) . findProfile ( this . getProfileTableName ( ) , profileName ) != null ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Profile named " + profileName + ( result ? "" : " does not" ) + " exists on table named " + this . getProfileTableName ( ) ) ; } return result ; }


Input: This method renames Profile Table in backend storage . NOTE : It should not be called directly use SleeProfileTableManager instead! [CODESPLIT] public void rename ( String newProfileTableName ) { //we have to do this like that cause once JPA is done, those profiles wont exist, since we do UPDATE of a table name, not a copy //thus no profiles will be returned on this call later on. ouch :) Collection < ProfileID > profileIDs = this . getProfiles ( ) ; component . getProfileEntityFramework ( ) . renameProfileTable ( this . profileTableName , newProfileTableName ) ; //here we remove beans. for ( ProfileID pid : profileIDs ) { try { AbstractProfileMBeanImpl . close ( pid . getProfileTableName ( ) , pid . getProfileName ( ) ) ; } catch ( Exception e ) { if ( logger . isEnabledFor ( Level . WARN ) ) { logger . warn ( "Unexpected behaviour on MBean deregistration." , e ) ; } } } }


Input: Triggers remove operation on this profile table . [CODESPLIT] public void remove ( boolean isUninstall ) throws SLEEException { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "removeProfileTable: removing profileTable=" + profileTableName ) ; } // remove the table profiles, at this stage they may use notification source, lets leave it. for ( ProfileID profileID : getProfiles ( ) ) { // don't invoke the profile concrete object, to avoid evil profile lifecycle impls  // that rollbacks tx, as Test1110251Test this . removeProfile ( profileID . getProfileName ( ) , false , isUninstall ) ; } // remove default profile if ( getDefaultProfileEntity ( ) != null ) { this . removeProfile ( null , false , false ) ; } // add action after commit to remove tracer and close uncommitted mbeans TransactionalAction commitAction = new TransactionalAction ( ) { public void execute ( ) { // remove notification sources for profile table final TraceManagement traceMBeanImpl = sleeContainer . getTraceManagement ( ) ; traceMBeanImpl . deregisterNotificationSource ( new ProfileTableNotification ( profileTableName ) ) ; // close uncommitted mbeans closeUncommittedProfileMBeans ( ) ; } } ; sleeContainer . getTransactionManager ( ) . getTransactionContext ( ) . getAfterCommitActions ( ) . add ( commitAction ) ; if ( sleeContainer . getSleeState ( ) == SleeState . RUNNING ) { endActivity ( ) ; } // unregister mbean unregisterUsageMBean ( ) ; // remove object pool profileManagement . getObjectPoolManagement ( ) . removeObjectPool ( this , sleeContainer . getTransactionManager ( ) ) ; }


Input: Retrieves the JAIN SLEE specs descriptor [CODESPLIT] public javax . slee . management . SbbDescriptor getSpecsDescriptor ( ) { if ( specsDescriptor == null ) { final LibraryID [ ] libraryIDs = descriptor . getLibraryRefs ( ) . toArray ( new LibraryID [ descriptor . getLibraryRefs ( ) . size ( ) ] ) ; Set < SbbID > sbbIDSet = new HashSet < SbbID > ( ) ; for ( SbbRefDescriptor mSbbRef : descriptor . getSbbRefs ( ) ) { sbbIDSet . add ( mSbbRef . getComponentID ( ) ) ; } SbbID [ ] sbbIDs = sbbIDSet . toArray ( new SbbID [ sbbIDSet . size ( ) ] ) ; Set < ProfileSpecificationID > profileSpecSet = new HashSet < ProfileSpecificationID > ( ) ; for ( ProfileSpecRefDescriptor mProfileSpecRef : descriptor . getProfileSpecRefs ( ) ) { profileSpecSet . add ( mProfileSpecRef . getComponentID ( ) ) ; } ProfileSpecificationID [ ] profileSpecs = profileSpecSet . toArray ( new ProfileSpecificationID [ profileSpecSet . size ( ) ] ) ; Set < EventTypeID > eventTypeSet = new HashSet < EventTypeID > ( ) ; for ( EventEntryDescriptor mEventEntry : descriptor . getEventEntries ( ) . values ( ) ) { eventTypeSet . add ( mEventEntry . getEventReference ( ) ) ; } EventTypeID [ ] eventTypes = eventTypeSet . toArray ( new EventTypeID [ eventTypeSet . size ( ) ] ) ; Set < ResourceAdaptorTypeID > raTypeIDSet = new HashSet < ResourceAdaptorTypeID > ( ) ; Set < String > raLinksSet = new HashSet < String > ( ) ; for ( ResourceAdaptorTypeBindingDescriptor mResourceAdaptorTypeBinding : descriptor . getResourceAdaptorTypeBindings ( ) ) { raTypeIDSet . add ( mResourceAdaptorTypeBinding . getResourceAdaptorTypeRef ( ) ) ; for ( ResourceAdaptorEntityBindingDescriptor mResourceAdaptorEntityBinding : mResourceAdaptorTypeBinding . getResourceAdaptorEntityBinding ( ) ) { raLinksSet . add ( mResourceAdaptorEntityBinding . getResourceAdaptorEntityLink ( ) ) ; } } ResourceAdaptorTypeID [ ] raTypeIDs = raTypeIDSet . toArray ( new ResourceAdaptorTypeID [ raTypeIDSet . size ( ) ] ) ; String [ ] raLinks = raLinksSet . toArray ( new String [ raLinksSet . size ( ) ] ) ; specsDescriptor = new javax . slee . management . SbbDescriptor ( getSbbID ( ) , getDeployableUnit ( ) . getDeployableUnitID ( ) , getDeploymentUnitSource ( ) , libraryIDs , sbbIDs , eventTypes , profileSpecs , descriptor . getAddressProfileSpecRef ( ) , raTypeIDs , raLinks ) ; } return specsDescriptor ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public Object getActivity ( ) throws TransactionRequiredLocalException , SLEEException { sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; return activityContext . getActivityContextHandle ( ) . getActivityObject ( ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void attach ( SbbLocalObject sbbLocalObject ) throws NullPointerException , TransactionRequiredLocalException , TransactionRolledbackLocalException , SLEEException { if ( doTraceLogs ) { logger . trace ( "attach( ac = " + activityContext + " , sbbLocalObject = " + sbbLocalObject + " )" ) ; } if ( sbbLocalObject == null ) throw new NullPointerException ( "null SbbLocalObject !" ) ; sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; org . mobicents . slee . container . sbb . SbbLocalObject sbbLocalObjectImpl = ( org . mobicents . slee . container . sbb . SbbLocalObject ) sbbLocalObject ; SbbEntity sbbEntity = sbbLocalObjectImpl . getSbbEntity ( ) ; boolean attached = getActivityContext ( ) . attachSbbEntity ( sbbEntity . getSbbEntityId ( ) ) ; boolean setRollbackAndThrowException = false ; if ( attached ) { try { if ( sbbEntity . isRemoved ( ) ) { setRollbackAndThrowException = true ; } else { // attach entity from ac sbbEntity . afterACAttach ( getActivityContext ( ) . getActivityContextHandle ( ) ) ; } } catch ( Exception e ) { setRollbackAndThrowException = true ; } } if ( setRollbackAndThrowException ) { try { sleeContainer . getTransactionManager ( ) . setRollbackOnly ( ) ; } catch ( SystemException e ) { logger . warn ( "failed to set rollback flag while asserting valid sbb entity" , e ) ; } throw new TransactionRolledbackLocalException ( "Failed to attach invalid sbb entity. SbbID " + sbbEntity . getSbbEntityId ( ) ) ; } if ( attached ) { //            	JSLEE 1.0 Spec, Section 8.5.8 excerpt: //        		The SLEE delivers the event to an SBB entity that stays attached once. The SLEE may deliver the //        		event to the same SBB entity more than once if it has been detached and then re -attached.  final EventRoutingTask routingTask = activityContext . getLocalActivityContext ( ) . getCurrentEventRoutingTask ( ) ; EventContext eventContextImpl = routingTask != null ? routingTask . getEventContext ( ) : null ; if ( eventContextImpl != null && eventContextImpl . getSbbEntitiesThatHandledEvent ( ) . remove ( sbbEntity . getSbbEntityId ( ) ) ) { if ( doTraceLogs ) { logger . trace ( "Removed the SBB Entity [" + sbbEntity . getSbbEntityId ( ) + "] from the delivered set of activity context [" + getActivityContext ( ) . getActivityContextHandle ( ) + "]. Seems to be a reattachment after detachment in the same event delivery transaction. See JSLEE 1.0 Spec, Section 8.5.8." ) ; } } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void detach ( SbbLocalObject sbbLocalObject ) throws NullPointerException , TransactionRequiredLocalException , TransactionRolledbackLocalException , SLEEException { if ( doTraceLogs ) { logger . trace ( "detach( ac = " + activityContext + " , sbbLocalObject = " + sbbLocalObject + " )" ) ; } if ( sbbLocalObject == null ) throw new NullPointerException ( "null SbbLocalObject !" ) ; sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; org . mobicents . slee . container . sbb . SbbLocalObject sbbLocalObjectImpl = ( org . mobicents . slee . container . sbb . SbbLocalObject ) sbbLocalObject ; SbbEntity sbbEntity = sbbLocalObjectImpl . getSbbEntity ( ) ; // detach ac from entity final ActivityContext ac = getActivityContext ( ) ; ac . detachSbbEntity ( sbbEntity . getSbbEntityId ( ) ) ; boolean setRollbackAndThrowException = false ; try { if ( sbbEntity . isRemoved ( ) ) { setRollbackAndThrowException = true ; } else { // detach entity from ac sbbEntity . afterACDetach ( getActivityContext ( ) . getActivityContextHandle ( ) ) ; } } catch ( Exception e ) { setRollbackAndThrowException = true ; } if ( setRollbackAndThrowException ) { try { sleeContainer . getTransactionManager ( ) . setRollbackOnly ( ) ; } catch ( SystemException e ) { logger . warn ( "failed to set rollback flag while asserting valid sbb entity" , e ) ; } throw new TransactionRolledbackLocalException ( "Failed to detach invalid sbb entity. SbbID " + sbbEntity . getSbbEntityId ( ) ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public boolean isAttached ( SbbLocalObject sbbLocalObject ) throws NullPointerException , TransactionRequiredLocalException , TransactionRolledbackLocalException , SLEEException { if ( sbbLocalObject == null ) { throw new NullPointerException ( "null sbbLocalObject" ) ; } sleeContainer . getTransactionManager ( ) . mandateTransaction ( ) ; if ( sbbLocalObject instanceof org . mobicents . slee . container . sbb . SbbLocalObject ) { org . mobicents . slee . container . sbb . SbbLocalObject sbbLocalObjectImpl = ( org . mobicents . slee . container . sbb . SbbLocalObject ) sbbLocalObject ; SbbEntity sbbEntity = sbbLocalObjectImpl . getSbbEntity ( ) ; if ( sbbEntity != null && ! sbbEntity . isRemoved ( ) ) { return sbbEntity . isAttached ( activityContext . getActivityContextHandle ( ) ) ; } } try { sleeContainer . getTransactionManager ( ) . setRollbackOnly ( ) ; } catch ( Exception e ) { throw new SLEEException ( e . getMessage ( ) , e ) ; } throw new TransactionRolledbackLocalException ( "the sbbLocalObject argument must represent a valid SBB entity" ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void addDeployableUnit ( final DeployableUnit deployableUnit ) { if ( deployableUnit == null ) throw new NullPointerException ( "null deployableUnit" ) ; if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Adding DU :  " + deployableUnit . getDeployableUnitID ( ) ) ; } deployableUnits . put ( deployableUnit . getDeployableUnitID ( ) , ( DeployableUnitImpl ) deployableUnit ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public DeployableUnitID [ ] getDeployableUnits ( ) { Set < DeployableUnitID > deployableUnitIDs = deployableUnits . keySet ( ) ; return deployableUnitIDs . toArray ( new DeployableUnitID [ deployableUnitIDs . size ( ) ] ) ; }


Input: / * ( non - Javadoc ) [CODESPLIT] public void removeDeployableUnit ( DeployableUnitID deployableUnitID ) { if ( logger . isTraceEnabled ( ) ) { logger . trace ( "Removing DU with id:  " + deployableUnitID ) ; } if ( deployableUnitID == null ) throw new NullPointerException ( "null id" ) ; deployableUnits . remove ( deployableUnitID ) ; }


Input: Updates the ra entity config properties [CODESPLIT] public void updateConfigurationProperties ( ConfigProperties properties ) throws InvalidConfigurationException , InvalidStateException { if ( ! component . getDescriptor ( ) . getSupportsActiveReconfiguration ( ) && ( sleeContainer . getSleeState ( ) != SleeState . STOPPED ) && ( state == ResourceAdaptorEntityState . ACTIVE || state == ResourceAdaptorEntityState . STOPPING ) ) { throw new InvalidStateException ( "the value of the supports-active-reconfiguration attribute of the resource-adaptor-class element in the deployment descriptor of the Resource Adaptor of the resource adaptor entity is False and the resource adaptor entity is in the Active or Stopping state and the SLEE is in the Starting, Running, or Stopping state" ) ; } else { object . raConfigurationUpdate ( properties ) ; } }


Input:
Signals that the container is in RUNNING state [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public void sleeRunning ( ) throws InvalidStateException { // if entity is active then activate the ra object
 if ( this . state . isActive ( ) ) { if ( setFTContext ) { setFTContext = false ; if ( object . isFaultTolerant ( ) ) { // set fault tolerant context, it is a ft ra
 try { this . ftResourceAdaptorContext = new FaultTolerantResourceAdaptorContextImpl ( name , sleeContainer , ( FaultTolerantResourceAdaptor ) object . getResourceAdaptorObject ( ) ) ; object . setFaultTolerantResourceAdaptorContext ( ftResourceAdaptorContext ) ; } catch ( Throwable t ) { logger . error ( "Got exception invoking setFaultTolerantResourceAdaptorContext(...) for entity " + name , t ) ; } } } try { object . raActive ( ) ; } catch ( Throwable t ) { logger . error ( "Got exception invoking raActive() for entity " + name , t ) ; } } }


Input: Signals that the container is in STOPPING state [CODESPLIT] public void sleeStopping ( ) throws InvalidStateException , TransactionRequiredLocalException { if ( state != null && state . isActive ( ) ) { try { object . raStopping ( ) ; } catch ( Throwable t ) { logger . error ( "Got exception from RA object" , t ) ; } scheduleAllActivitiesEnd ( ) ; } }


Input:
Activates the ra entity [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public void activate ( ) throws InvalidStateException { if ( ! this . state . isInactive ( ) ) { throw new InvalidStateException ( "entity " + name + " is in state: " + this . state ) ; } this . state = ResourceAdaptorEntityState . ACTIVE ; // if slee is running then activate ra object
 if ( sleeContainer . getSleeState ( ) == SleeState . RUNNING ) { if ( setFTContext ) { setFTContext = false ; if ( object . isFaultTolerant ( ) ) { // set fault tolerant context, it is a ft ra
 try { this . ftResourceAdaptorContext = new FaultTolerantResourceAdaptorContextImpl ( name , sleeContainer , ( FaultTolerantResourceAdaptor ) object . getResourceAdaptorObject ( ) ) ; object . setFaultTolerantResourceAdaptorContext ( ftResourceAdaptorContext ) ; } catch ( Throwable t ) { logger . error ( "Got exception invoking setFaultTolerantResourceAdaptorContext(...) for entity " + name , t ) ; } } } try { object . raActive ( ) ; } catch ( Throwable t ) { logger . error ( "Got exception invoking raActive() for entity " + name , t ) ; } } }


Input:
Deactivates the ra entity [CODESPLIT] public void deactivate ( ) throws InvalidStateException , TransactionRequiredLocalException { if ( ! this . state . isActive ( ) ) { throw new InvalidStateException ( "entity " + name + " is in state: " + this . state ) ; } this . state = ResourceAdaptorEntityState . STOPPING ; if ( object . getState ( ) == ResourceAdaptorObjectState . ACTIVE ) { object . raStopping ( ) ; } // tck requires that the method returns with stopping state so do
 // all deactivation logic half a sec later
 TimerTask t = new TimerTask ( ) { @ Override public void run ( ) { try { cancel ( ) ; if ( state == ResourceAdaptorEntityState . STOPPING ) { if ( object . getState ( ) == ResourceAdaptorObjectState . STOPPING ) { scheduleAllActivitiesEnd ( ) ; } else { allActivitiesEnded ( ) ; } } } catch ( Throwable e ) { logger . error ( e . getMessage ( ) , e ) ; } } } ; resourceAdaptorContext . getTimer ( ) . schedule ( t , 500 ) ; }


Input:
schedules the ending of all the entity activities this is needed on ra entity deactivation or slee container stop once the process ends it will invoke allActivitiesEnded to complete those processes [CODESPLIT] private void scheduleAllActivitiesEnd ( ) throws TransactionRequiredLocalException { // schedule the end of all activities if the node is the single member of the cluster
 boolean skipActivityEnding = ! sleeContainer . getCluster ( ) . isSingleMember ( ) ; if ( ! skipActivityEnding && hasActivities ( ) ) { logger . info ( "RA entity " + name + " activities end scheduled." ) ; timerTask = new EndAllActivitiesRAEntityTimerTask ( this , sleeContainer ) ; } else { allActivitiesEnded ( ) ; } }


Input:
Checks if the entity has activities besides the one passed as parameter ( if not null ) . [CODESPLIT] private boolean hasActivities ( ) { try { for ( ActivityContextHandle handle : sleeContainer . getActivityContextFactory ( ) . getAllActivityContextsHandles ( ) ) { if ( handle . getActivityType ( ) == ActivityType . RA ) { ResourceAdaptorActivityContextHandle raHandle = ( ResourceAdaptorActivityContextHandle ) handle ; if ( raHandle . getResourceAdaptorEntity ( ) . equals ( this ) ) { logger . debug ( "**** AllActivityContextsHandles: " + sleeContainer . getActivityContextFactory ( ) . getAllActivityContextsHandles ( ) ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "RA entity " + name + " has (at least) activity " + handle . getActivityHandle ( ) ) ; } //return true;
 logger . warn ( "WORKAROUND USAGE: ENDING RESOURCE ADAPTOR ACTIVITIES" ) ; sleeContainer . getActivityContextFactory ( ) . WAremove ( "RA" ) ; return false ; } } } } catch ( Throwable e ) { logger . error ( e . getMessage ( ) , e ) ; } return false ; }


Input: Removes the entity it will unconfigure and unset the ra context the entity object can not be reused [CODESPLIT] public void remove ( ) throws InvalidStateException { if ( ! this . state . isInactive ( ) ) { throw new InvalidStateException ( "entity " + name + " is in state: " + this . state ) ; } object . raUnconfigure ( ) ; if ( object . isFaultTolerant ( ) ) { object . unsetFaultTolerantResourceAdaptorContext ( ) ; ftResourceAdaptorContext . shutdown ( ) ; } object . unsetResourceAdaptorContext ( ) ; this . sleeContainer . getTraceManagement ( ) . deregisterNotificationSource ( this . getNotificationSource ( ) ) ; state = null ; }


Input: Retrieves the ra interface for this entity and the specified ra type [CODESPLIT] public Object getResourceAdaptorInterface ( ResourceAdaptorTypeID raType ) { return object . getResourceAdaptorInterface ( sleeContainer . getComponentRepository ( ) . getComponentByID ( raType ) . getDescriptor ( ) . getResourceAdaptorInterface ( ) ) ; }


Input: Indicates a service was activated the entity will forward this notification to the ra object . [CODESPLIT] public void serviceActive ( ServiceID serviceID ) { try { ReceivableService receivableService = resourceAdaptorContext . getServiceLookupFacility ( ) . getReceivableService ( serviceID ) ; if ( receivableService . getReceivableEvents ( ) . length > 0 ) { object . serviceActive ( receivableService ) ; } } catch ( Throwable e ) { logger . warn ( "invocation resulted in unchecked exception" , e ) ; } }


Input: if it is a handle reference it gets the referred handle [CODESPLIT] ActivityHandle derreferActivityHandle ( ActivityHandle handle ) { ActivityHandle ah = null ; if ( resourceManagement . getHandleReferenceFactory ( ) != null && handle . getClass ( ) == ActivityHandleReference . class ) { ActivityHandleReference ahReference = ( ActivityHandleReference ) handle ; ah = resourceManagement . getHandleReferenceFactory ( ) . getActivityHandle ( ahReference ) ; } else { ah = handle ; } return ah ; }


Input:
Callback to notify the entity and possibly the ra object informing activity handled ended . [CODESPLIT] public void activityEnded ( final ActivityHandle handle , int activityFlags ) { logger . trace ( "activityEnded( handle = " + handle + " )" ) ; ActivityHandle ah = null ; if ( handle instanceof ActivityHandleReference ) { // handle is a ref, derrefer and remove the ref
 ah = resourceManagement . getHandleReferenceFactory ( ) . removeActivityHandleReference ( ( ActivityHandleReference ) handle ) ; } else { // handle is not a reference
 ah = handle ; } if ( ah != null && ActivityFlags . hasRequestEndedCallback ( activityFlags ) ) { object . activityEnded ( ah ) ; } if ( object . getState ( ) == ResourceAdaptorObjectState . STOPPING ) { synchronized ( this ) { // the ra object is stopping, check if the timer task is still
 // needed
 if ( ! hasActivities ( ) ) { if ( timerTask != null ) { timerTask . cancel ( ) ; } allActivitiesEnded ( ) ; } } } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void activate ( ServiceID serviceID ) throws NullPointerException , UnrecognizedServiceException , InvalidStateException , InvalidLinkNameBindingStateException , ManagementException { try { serviceManagement . activate ( serviceID ) ; } catch ( NullPointerException e ) { throw e ; } catch ( UnrecognizedServiceException e ) { throw e ; } catch ( InvalidLinkNameBindingStateException e ) { throw e ; } catch ( InvalidStateException e ) { throw e ; } catch ( Throwable e ) { throw new ManagementException ( e . getMessage ( ) , e ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void activate ( ServiceID [ ] serviceIDs ) throws NullPointerException , InvalidArgumentException , UnrecognizedServiceException , InvalidStateException , InvalidLinkNameBindingStateException , ManagementException { try { serviceManagement . activate ( serviceIDs ) ; } catch ( NullPointerException e ) { throw e ; } catch ( InvalidArgumentException e ) { throw e ; } catch ( UnrecognizedServiceException e ) { throw e ; } catch ( InvalidLinkNameBindingStateException e ) { throw e ; } catch ( InvalidStateException e ) { throw e ; } catch ( Throwable e ) { throw new ManagementException ( e . getMessage ( ) , e ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void setResourceAdaptorContext ( ResourceAdaptorContext context ) throws InvalidStateException { if ( doTraceLogs ) { logger . trace ( "setResourceAdaptorContext( context = " + context + " )" ) ; } if ( state == null ) { state = ResourceAdaptorObjectState . UNCONFIGURED ; object . setResourceAdaptorContext ( context ) ; } else { throw new InvalidStateException ( "ra object is in state " + state ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public void setFaultTolerantResourceAdaptorContext ( FaultTolerantResourceAdaptorContext < Serializable , Serializable > context ) throws IllegalArgumentException { if ( doTraceLogs ) { logger . trace ( "setFaultTolerantResourceAdaptorContext( context = " + context + " )" ) ; } if ( isFaultTolerant ( ) ) { ( ( FaultTolerantResourceAdaptor < Serializable , Serializable > ) this . object ) . setFaultTolerantResourceAdaptorContext ( context ) ; } else { throw new IllegalArgumentException ( "RA Object is not fault tolerant!" ) ; } }


Input: / * ( non - Javadoc ) [CODESPLIT] public void raConfigure ( ConfigProperties properties ) throws InvalidConfigurationException { if ( doTraceLogs ) { logger . trace ( "raConfigure( properties = " + properties + " )" ) ; } verifyConfigProperties ( properties ) ; object . raConfigure ( configProperties ) ; if ( state == ResourceAdaptorObjectState . UNCONFIGURED ) { state = ResourceAdaptorObjectState . INACTIVE ; } }