Search in sources :

Example 1 with FeaturesProcessingSerializer

use of org.apache.karaf.features.internal.service.FeaturesProcessingSerializer in project fuse-karaf by jboss-fuse.

the class FeatureProcessingTest method writeProcessingInstructions.

@Test
public void writeProcessingInstructions() {
    FeaturesProcessing fp1 = InternalUtils.loadFeatureProcessing(new File("src/test/resources/processing/oakf.1.xml"), null);
    fp1.getBlacklistedBundles().add("mvn:x/y");
    fp1.getBlacklistedFeatures().add(new FeaturesProcessing.BlacklistedFeature("f", "1"));
    FeaturesProcessingSerializer serializer = new FeaturesProcessingSerializer();
    serializer.write(fp1, System.out);
    System.out.flush();
}
Also used : FeaturesProcessingSerializer(org.apache.karaf.features.internal.service.FeaturesProcessingSerializer) File(java.io.File) FeaturesProcessing(org.apache.karaf.features.internal.model.processing.FeaturesProcessing) Test(org.junit.Test)

Example 2 with FeaturesProcessingSerializer

use of org.apache.karaf.features.internal.service.FeaturesProcessingSerializer in project fuse-karaf by jboss-fuse.

the class InternalUtils method loadFeatureProcessing.

/**
 * Loads processing definition, possibly with additional version properties
 * @param featureProcessing location of feature processing file
 * @param properties properties for placeholder resolver
 * @return
 */
public static FeaturesProcessing loadFeatureProcessing(File featureProcessing, File properties) {
    try {
        Properties props = new Properties();
        if (properties != null && properties.isFile()) {
            try (FileInputStream fis = new FileInputStream(properties)) {
                props.load(fis);
            }
        }
        FeaturesProcessingSerializer serializer = new FeaturesProcessingSerializer();
        try (FileInputStream fis = new FileInputStream(featureProcessing)) {
            return serializer.read(fis, props);
        }
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : FeaturesProcessingSerializer(org.apache.karaf.features.internal.service.FeaturesProcessingSerializer) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream)

Aggregations

FeaturesProcessingSerializer (org.apache.karaf.features.internal.service.FeaturesProcessingSerializer)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Properties (java.util.Properties)1 FeaturesProcessing (org.apache.karaf.features.internal.model.processing.FeaturesProcessing)1 Test (org.junit.Test)1