use of org.apache.felix.bundlerepository.Resource in project aries by apache.
the class Aries1522Test method createRepositoryXml.
private URL createRepositoryXml(DataModelHelper helper) throws Exception {
File dir;
String cwd = new File("").getAbsolutePath();
if (cwd.endsWith(File.separator + "target")) {
dir = new File("test-classes/aries1523");
} else {
dir = new File("target/test-classes/aries1523");
}
File jar = new File(dir, "aries1523fragment.jar");
assertTrue("The fragment jar does not exist: " + jar.getAbsolutePath(), jar.exists());
Resource resource = helper.createResource(jar.toURI().toURL());
Repository repository = helper.repository(new Resource[] { resource });
File file = new File(dir, "repository.xml");
FileWriter fw = new FileWriter(file);
try {
helper.writeRepository(repository, fw);
return file.toURI().toURL();
} finally {
fw.close();
}
}
use of org.apache.felix.bundlerepository.Resource in project spring-roo by spring-projects.
the class SubsystemCommands method deploy.
public void deploy(String symbolicName) throws Exception {
repositories = new ArrayList<Repository>();
// Getting all installed repositories
populateRepositories();
// Getting subsystem resource from OBR Repository by resource
// symbolicName
Resource subsystemResource = getSubsystemResource(symbolicName);
// Install related repositories or related subsystems if needed
LOGGER.log(Level.INFO, "Subsystem dependency manager started.");
LOGGER.log(Level.INFO, "");
installSubsystemDependencies(subsystemResource);
LOGGER.log(Level.INFO, "Subsystem dependency manager finished.");
LOGGER.log(Level.INFO, "");
// Install subsystem using symbolicName
Subsystem subsystem = install(subsystemResource.getURI());
// Starting installed subsystem
start(subsystem.getSubsystemId());
}
use of org.apache.felix.bundlerepository.Resource in project spring-roo by spring-projects.
the class ObrAddonSearchOperationsImpl method populateBundlesToInstall.
/**
* Method to populate bundles to install. Depending of the search type, will be displayed
* different kinds of bundles.
*
* @param requiresCommand
* @param type
*/
private void populateBundlesToInstall(String searchTerms, SearchType type) {
// Refreshing Repositories
populateRepositories();
// Cleaning Bundles to install
bundlesToInstall.clear();
// Cleaning previous search
searchResultCache.clear();
int bundleId = 0;
for (Repository repo : repositories) {
// Getting all resources from every repo
Resource[] repoResources = repo.getResources();
for (Resource repoResource : repoResources) {
// Creating bundle of current resource
ObrBundle bundle = new ObrBundle(repoResource.getSymbolicName(), repoResource.getPresentationName(), repoResource.getSize(), repoResource.getVersion(), repoResource.getURI());
// If current bundle is installed, continue with the next one
if (checkIfBundleIsInstalled(bundle)) {
continue;
}
// Getting Resource Capabilites
Capability[] resourceCapabilities = repoResource.getCapabilities();
for (Capability capability : resourceCapabilities) {
// capabilities
if (type.equals(SearchType.ADDON)) {
// Getting resource commands
if (capability.getName().equals(CAPABILITY_COMMANDS_NAME)) {
// Getting all resource properties
Map<String, Object> capabilityProperties = capability.getPropertiesAsMap();
boolean match = false;
for (Entry capabilityProperty : capabilityProperties.entrySet()) {
String capabilityCommand = (String) capabilityProperty.getValue();
bundle.addCommand(capabilityCommand);
if (capabilityCommand.startsWith(searchTerms)) {
match = true;
}
}
if (match) {
bundleId++;
bundlesToInstall.add(bundle);
searchResultCache.put(String.format("%02d", bundleId), bundle);
}
}
} else if (type.equals(SearchType.JDBCDRIVER)) {
// Getting resource driver
if (capability.getName().equals(CAPABILITY_JDBCDRIVER_NAME)) {
// Getting all resource properties
Map<String, Object> capabilityProperties = capability.getPropertiesAsMap();
boolean match = false;
for (Entry capabilityProperty : capabilityProperties.entrySet()) {
String capabilityKey = (String) capabilityProperty.getKey();
// Getting driver class
if (capabilityKey.toLowerCase().equals("driver")) {
String capabilityDriver = (String) capabilityProperty.getValue();
if (capabilityDriver.startsWith(searchTerms)) {
match = true;
}
}
}
if (match) {
bundleId++;
bundlesToInstall.add(bundle);
searchResultCache.put(String.format("%02d", bundleId), bundle);
}
}
} else if (type.equals(SearchType.LIBRARY)) {
// TODO: Implement library bundle search
}
}
}
}
}
use of org.apache.felix.bundlerepository.Resource in project spring-roo by spring-projects.
the class BundleSymbolicNameConverter method getAllPossibleValues.
public boolean getAllPossibleValues(final List<Completion> completions, final Class<?> requiredType, final String originalUserInput, final String optionContext, final MethodTarget target) {
boolean local = false;
boolean obr = false;
if ("".equals(optionContext)) {
local = true;
}
if (optionContext.contains("local")) {
local = true;
}
if (optionContext.contains("obr")) {
obr = true;
}
if (local) {
final Bundle[] bundles = context.getBundleContext().getBundles();
if (bundles != null) {
for (final Bundle bundle : bundles) {
final String bsn = bundle.getSymbolicName();
if (bsn != null && bsn.startsWith(originalUserInput)) {
completions.add(new Completion(bsn));
}
}
}
}
if (obr) {
final Repository[] repositories = repositoryAdmin.listRepositories();
if (repositories != null) {
for (final Repository repository : repositories) {
final Resource[] resources = repository.getResources();
if (resources != null) {
for (final Resource resource : resources) {
if (resource.getSymbolicName().startsWith(originalUserInput)) {
completions.add(new Completion(resource.getSymbolicName()));
}
}
}
}
}
}
return false;
}
use of org.apache.felix.bundlerepository.Resource in project spring-roo by spring-projects.
the class AddonSuiteOperationsImpl method listAllSubsystemsOnRepository.
@Override
public void listAllSubsystemsOnRepository(ObrRepositorySymbolicName obrRepository) {
LOGGER.log(Level.INFO, "Getting all 'Roo Addon Suites' located on '" + obrRepository.getKey() + "' repository... ");
LOGGER.log(Level.INFO, " ");
int repos = 0;
// Getting all repositories
Repository[] repositories = getRepositoryAdmin().listRepositories();
for (Repository repo : repositories) {
if (repo.getURI().equals(obrRepository.getKey())) {
// Getting all resources from repository
Resource[] repositoryResource = repo.getResources();
for (Resource resource : repositoryResource) {
// If current resource ends with .esa, means that is a ROO Addon Suite
if (resource.getURI().endsWith(".esa")) {
LOGGER.log(Level.INFO, " " + resource.getSymbolicName());
repos++;
}
}
}
}
LOGGER.log(Level.INFO, " ");
LOGGER.log(Level.INFO, String.format("%s Roo Addon Suites were found on '%s' repository", repos, obrRepository.getKey()));
}
Aggregations