public Object deployThisResource ( String packageName , String versionRange , boolean start ) { int options = 0 ; //?if (start) //? options = Resolver.START; if ( repositoryAdmin == null ) return null ; DataModelHelper helper = repositoryAdmin . getHelper ( ) ; if ( this . getResourceFromCache ( packageName ) != null ) return this . getResourceFromCache ( packageName ) ; String filter = "(package=" + packageName + ")" ; filter = ClassFinderActivator . addVersionFilter ( filter , versionRange ) ; Requirement requirement = helper . requirement ( "package" , filter ) ; Requirement [ ] requirements = { requirement } ; // repositoryAdmin Resource [ ] resources = repositoryAdmin . discoverResources ( requirements ) ; Resource bestResource = null ; if ( resources != null ) { Version bestVersion = null ; for ( Resource resource : resources ) { Version resourceVersion = resource . getVersion ( ) ; if ( ! isValidVersion ( resourceVersion , versionRange ) ) continue ; if ( ( bestVersion == null ) || ( resourceVersion . compareTo ( bestVersion ) >= 0 ) ) { bestVersion = resourceVersion ; // Use the highest version number bestResource = resource ; } } } if ( bestResource != null ) { this . deployResource ( bestResource , options ) ; Bundle bundle = this . findBundle ( bestResource , bundleContext , packageName , versionRange ) ; if ( start ) this . startBundle ( bundle ) ; this . addResourceToCache ( packageName , bestResource ) ; } return bestResource ; }
Find this resource in the repository then deploy and optionally start it .