本文整理汇总了Java中aQute.bnd.osgi.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于aQute.bnd.osgi包,在下文中一共展示了Resource类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addFileToJar
import aQute.bnd.osgi.Resource; //导入依赖的package包/类
private boolean addFileToJar(Jar jar, String destination, String sourceAbsPath) {
if (includedResources.contains(sourceAbsPath)) {
log("Skipping already included resource: %s\n", sourceAbsPath);
return false;
}
File file = new File(sourceAbsPath);
if (!file.isFile()) {
throw new RuntimeException(
String.format("Skipping non-existent file: %s\n", sourceAbsPath));
}
Resource resource = new FileResource(file);
if (jar.getResource(destination) != null) {
warn("Skipping duplicate resource: %s\n", destination);
return false;
}
jar.putResource(destination, resource);
includedResources.add(sourceAbsPath);
log("Adding resource: %s\n", destination);
return true;
}
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:OSGiWrapper.java
示例2: putResource
import aQute.bnd.osgi.Resource; //导入依赖的package包/类
@Override
public boolean putResource(String path, Resource resource, boolean override) {
/*
* we override the resource path given to "simulate" an actual jar. TODO
* : use the build.properties to do that reliably.
*/
if (path.startsWith("bin/")) {
path = path.substring(4);
}
return super.putResource(path, resource, override);
}
开发者ID:cbrun,项目名称:baseliner,代码行数:12,代码来源:WorkspaceJar.java
示例3: analyzeJar
import aQute.bnd.osgi.Resource; //导入依赖的package包/类
@Override
public boolean analyzeJar(Analyzer analyzer) throws Exception {
try {
// create tmp directory
String TMP_PATH = analyzer.getBase().getAbsolutePath()+File.separator
+"generated"+File.separator+"android"+File.separator
+analyzer.getBsn()+File.separator;
File f = new File(TMP_PATH);
f.mkdirs();
// get all .class files
Jar jar = analyzer.getJar();
if(jar==null)
return false;
Map<String, Resource> resources = jar.getResources();
boolean containsClasses = false;
for(String name : resources.keySet()){
if(name.endsWith(".class")){
containsClasses = true;
InputStream is = null;
FileOutputStream fos = null;
try {
is = resources.get(name).openInputStream();
File dir = new File(TMP_PATH+name.substring(0,name.lastIndexOf(File.separator)));
dir.mkdirs();
fos = new FileOutputStream(new File(TMP_PATH+name));
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
} finally {
is.close();
fos.close();
}
}
}
if(!containsClasses)
return false;
// create classes.dex using dx tool
if(dx==null)
findDX();
if (dx==null)
throw new Exception("dx not found, make sure dx location is configured and the Android SDK is correctly set up");
Process p = Runtime.getRuntime().exec(dx+" --dex --output="+TMP_PATH+"classes.dex "+TMP_PATH);
p.waitFor();
// TODO parse dx output to spot errors
// add classes.dex to the .jar
File dexFile = new File(TMP_PATH+"classes.dex");
if(!dexFile.exists()){
throw new Exception("Failed to create classes.dex, make sure compiler level is 1.6");
}
analyzer.addIncluded(dexFile);
jar.putResource("classes.dex", new DexResource(dexFile));
} catch(Exception e){
analyzer.warning("Error embedding classes.dex file: " + e.getLocalizedMessage());
return false;
}
return true;
}
开发者ID:ibcn-cloudlet,项目名称:androsgi,代码行数:70,代码来源:AndroidPlugin.java
注:本文中的aQute.bnd.osgi.Resource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论