本文整理汇总了Java中org.apache.felix.bundlerepository.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于org.apache.felix.bundlerepository包,在下文中一共展示了Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: downloadFile
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
/**
* downloads a file and saves it in the bundle directory
* @param uri = URI of the repository file
* @param resource = bundle that should be downloaded
* @param bundleDir = destination directory
*/
public static File downloadFile(String uri, Resource resource, File bundleDir) throws Exception {
File localFile = new File(bundleDir,resource.getSymbolicName()+"-"+resource.getVersion()+".jar");
FileOutputStream fos = null;
ReadableByteChannel rbc = null;
URL website = new URL(uri);
rbc = Channels.newChannel(website.openStream());
fos = new FileOutputStream(localFile);
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
fos.close();
rbc.close();
return localFile;
}
开发者ID:PathVisio,项目名称:pathvisio,代码行数:20,代码来源:Utils.java
示例2: deployResource
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
/**
* Deploys as OSGi resource to the runtime framework.
*
* @param repoAdmin the repository admin
* @param r the repository resource to install
*/
private void deployResource(RepositoryAdmin repoAdmin, Resource r) {
logger.debug("Attempting to install plugin: " + r.getSymbolicName());
Resolver resolver = repoAdmin.resolver();
resolver.add(r);
if (resolver.resolve()) {
resolver.deploy(Resolver.START);
}
logger.info("Plugin completed installation: " + r.getSymbolicName());
}
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:16,代码来源:OSGIPluginManager.java
示例3: buildRepoDescription
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
protected String buildRepoDescription(Resource resource) {
String description = null;
if (resource.getProperties() != null) {
Object o = resource.getProperties().get("description");
if (o != null) {
description = o.toString();
}
}
return description;
}
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:11,代码来源:OSGIRepoPluginListSource.java
示例4: isCorePlugin
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
protected boolean isCorePlugin(Resource resource) {
for (String c : resource.getCategories()) {
if (c.contains("hobson-core-plugin")) {
return true;
}
}
return false;
}
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:9,代码来源:OSGIRepoPluginListSource.java
示例5: isPlugin
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
protected boolean isPlugin(Resource resource) {
for (String c : resource.getCategories()) {
if (c.contains("hobson-plugin")) {
return true;
}
}
return false;
}
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:9,代码来源:OSGIRepoPluginListSource.java
示例6: getAPIRequirement
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
/**
* Returns the first resource requirement associated with the Hobson API.
*
* @param resource the resource to analyze
*
* @return a Requirement instance (or null if the resource has no dependency on the Hobson API)
*/
protected Requirement getAPIRequirement(Resource resource) {
// Note: This code grabs the first Hobson API package requirement.
// The assumption being made here is that a plugin will never require different versions for
// different packages within the Hobson API. While this is almost certainly a safe assumption,
// it seemed worth making a note of :-)
for (Requirement req : resource.getRequirements()) {
if (req.getFilter().contains("(&(package=com.whizzosoftware.hobson.api")) {
return req;
}
}
return null;
}
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:20,代码来源:OSGIRepoPluginListSource.java
示例7: testGetPluginsWithTwoDifferentVersions
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
@Test
public void testGetPluginsWithTwoDifferentVersions() {
List<Resource> resources = new ArrayList<>();
resources.add(new MockResource("foo", new Version(0, 1, 1)));
resources.add(new MockResource("foo", new Version(0, 1, 0)));
OSGIRepoPluginListSource pls = new OSGIRepoPluginListSource(null, null);
Map<String,HobsonPluginDescriptor> pds = pls.getPlugins(resources.toArray(new Resource[resources.size()]));
assertEquals(1, pds.size());
assertNotNull(pds.get("foo"));
HobsonPluginDescriptor pd = pds.get("foo");
assertEquals("0.1.1", pd.getVersion());
}
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:14,代码来源:OSGIRepoPluginListSourceTest.java
示例8: KonektiFelixResource
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
public KonektiFelixResource(String id, Long bundleId, String symbolicName, String version,
String presentationName, Repository repository, String url,
Requirement[] requeriments, Capability[] capabilities, String[] categories,
String licenseUrl, String description, String documentation,
String copyright, String sourceUrl, String size, String[] keys, Resource resource,
String bundleStatus, Bundle bundle) {
super();
this.id = id;
this.bundleId = bundleId;
this.symbolicName = symbolicName;
this.version = version;
this.presentationName = presentationName;
this.repository = repository;
this.url = url;
this.requeriments = requeriments;
this.capabilities = capabilities;
this.categories = categories;
this.licenseUrl = licenseUrl;
this.description = description;
this.documentation = documentation;
this.copyright = copyright;
this.sourceUrl = sourceUrl;
this.size = size;
this.keys = keys;
this.resource = resource;
this.bundleStatus = bundleStatus;
this.bundle = bundle;
}
开发者ID:thingtrack,项目名称:konekti,代码行数:29,代码来源:KonektiFelixResource.java
示例9: BundleUris
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
BundleUris(Repository repository) {
for (Resource res : repository.getResources()) {
bundleUri.put(getKey(res) , res.getURI());
}
}
开发者ID:cschneider,项目名称:reactive-components,代码行数:6,代码来源:BundleUris.java
示例10: getKey
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
private String getKey(Resource res) {
Version version = res.getVersion();
Version simpleVersion = new Version(version.getMajor(), version.getMinor(), version.getMicro());
return res.getSymbolicName() + ";" + simpleVersion.toString();
}
开发者ID:cschneider,项目名称:reactive-components,代码行数:6,代码来源:BundleUris.java
示例11: getAllPossibleValues
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
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;
}
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:52,代码来源:BundleSymbolicNameConverter.java
示例12: getPlugins
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
protected Map<String,HobsonPluginDescriptor> getPlugins(Resource[] resources) {
Capability[] apiCapabilities = getAPICapabilities();
Map<String,HobsonPluginDescriptor> resultMap = new HashMap<>();
for (Resource repoResource : resources) {
String sname = repoResource.getSymbolicName();
PluginType pluginType = PluginType.FRAMEWORK;
if (isCorePlugin(repoResource)) {
pluginType = PluginType.CORE;
} else if (isPlugin(repoResource)) {
pluginType = PluginType.PLUGIN;
}
// check that plugin requirements are satisfied by installed capabilities
try {
if (isSatisfied(getAPIRequirement(repoResource), apiCapabilities)) {
// get the last processed version number for this plugin
String lastVersionString = resultMap.get(sname) != null ? resultMap.get(sname).getVersion() : null;
// if there was no last processed version number, get the currently installed version
if (lastVersionString == null && installedPlugins != null) {
lastVersionString = installedPlugins.get(sname);
}
// only add the remote plugin to the result list if its version is newer than what is currently known
if (lastVersionString == null || VersionUtil.versionCompare(lastVersionString, repoResource.getVersion().toString()) < 0) {
// see if there's an image associated with the plugin
String imageUrl = null;
for (Capability c : repoResource.getCapabilities()) {
if ("hobsonPlugin".equals(c.getName())) {
imageUrl = (String)c.getPropertiesAsMap().get("image");
}
}
HobsonPluginDescriptor pd = new HobsonPluginDescriptor(sname, pluginType, repoResource.getPresentationName(), buildRepoDescription(repoResource), repoResource.getVersion().toString(), PluginStatus.notInstalled(), imageUrl);
resultMap.put(sname, pd);
}
}
} catch (InvalidSyntaxException ise) {
logger.debug("Ignoring resource due to bad filter string", ise);
}
}
return resultMap;
}
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:46,代码来源:OSGIRepoPluginListSource.java
示例13: getResource
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
/**
* @return the resource
*/
public Resource getResource() {
return resource;
}
开发者ID:thingtrack,项目名称:konekti,代码行数:7,代码来源:KonektiFelixResource.java
示例14: setResource
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
/**
* @param resource the resource to set
*/
public void setResource(Resource resource) {
this.resource = resource;
}
开发者ID:thingtrack,项目名称:konekti,代码行数:7,代码来源:KonektiFelixResource.java
示例15: findResource
import org.apache.felix.bundlerepository.Resource; //导入依赖的package包/类
/**
* Finds a Resource in a repository.
*
* @param repoAdmin the repository to search
* @param pluginRef the plugin reference
*
* @return a Resource instance or null if not found
*
* @throws InvalidSyntaxException
*/
static private Resource findResource(RepositoryAdmin repoAdmin, PluginRef pluginRef) throws InvalidSyntaxException {
Resource[] resources = repoAdmin.discoverResources("(symbolicname=" + pluginRef.symbolicName + ")");
for (Resource r : resources) {
if (pluginRef.symbolicName.equals(r.getSymbolicName()) && pluginRef.version.equals(r.getVersion().toString())) {
return r;
}
}
return null;
}
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:20,代码来源:OSGIPluginManager.java
注:本文中的org.apache.felix.bundlerepository.Resource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论