use of org.apache.felix.ipojo.manipulator.store.JarFileResourceStore in project felix by apache.
the class Pojoization method pojoization.
/**
* Manipulates an input bundle.
* This method creates an iPOJO bundle based on the given metadata file.
* The original and final bundles must be different.
*
* @param in the original bundle.
* @param out the final bundle.
* @param metadataFile the iPOJO metadata file (XML).
* @param loader the classloader used to compute the bytecode frames.
*/
public void pojoization(File in, File out, File metadataFile, ClassLoader loader) {
MetadataProvider provider = new EmptyMetadataProvider();
if (metadataFile != null) {
FileMetadataProvider fileMetadataProvider = new FileMetadataProvider(metadataFile, m_reporter);
fileMetadataProvider.setValidateUsingLocalSchemas(m_useLocalXSD);
provider = fileMetadataProvider;
}
ResourceStore store;
try {
JarFile origin = new JarFile(in);
JarFileResourceStore jfrs = new JarFileResourceStore(origin, out);
jfrs.setClassLoader(loader);
if (in.getName().endsWith(".war")) {
// this is a war file, use the right mapper
jfrs.setResourceMapper(new WABResourceMapper());
}
jfrs.setManifest(origin.getManifest());
DefaultManifestBuilder dmb = new DefaultManifestBuilder();
dmb.setMetadataRenderer(new MetadataRenderer());
jfrs.setManifestBuilder(dmb);
store = jfrs;
} catch (IOException e) {
m_reporter.error("The input file " + in.getAbsolutePath() + " is not a Jar file");
return;
}
ManipulationVisitor visitor = createDefaultVisitorChain(store);
pojoization(store, provider, visitor, loader);
}
use of org.apache.felix.ipojo.manipulator.store.JarFileResourceStore in project felix by apache.
the class Pojoization method pojoization.
/**
* Manipulates an input bundle.
* This method creates an iPOJO bundle based on the given metadata file.
* The original and final bundles must be different.
*
* @param in the original bundle.
* @param out the final bundle.
* @param metadata the iPOJO metadata input stream.
* @param loader the classloader used to compute the bytecode frames.
*/
public void pojoization(File in, File out, InputStream metadata, ClassLoader loader) {
StreamMetadataProvider provider = new StreamMetadataProvider(metadata, m_reporter);
provider.setValidateUsingLocalSchemas(m_useLocalXSD);
ResourceStore store;
try {
JarFile origin = new JarFile(in);
JarFileResourceStore jfrs = new JarFileResourceStore(origin, out);
jfrs.setClassLoader(loader);
if (in.getName().endsWith(".war")) {
// this is a war file, use the right mapper
jfrs.setResourceMapper(new WABResourceMapper());
}
jfrs.setManifest(origin.getManifest());
DefaultManifestBuilder dmb = new DefaultManifestBuilder();
dmb.setMetadataRenderer(new MetadataRenderer());
jfrs.setManifestBuilder(dmb);
store = jfrs;
} catch (IOException e) {
m_reporter.error("The input file " + in.getAbsolutePath() + " is not a Jar file");
return;
}
ManipulationVisitor visitor = createDefaultVisitorChain(store);
pojoization(store, provider, visitor, loader);
}
Aggregations