Search in sources :

Example 1 with ClasspathScanner

use of org.apache.felix.connect.launch.ClasspathScanner in project karaf by apache.

the class EncryptableConfigAdminPropertyPlaceholderTest method setUp.

@Before
public void setUp() throws Exception {
    // Configure Jasypt
    enc = new StandardPBEStringEncryptor();
    env = new EnvironmentStringPBEConfig();
    env.setAlgorithm("PBEWithMD5AndDES");
    env.setPassword("password");
    enc.setConfig(env);
    System.setProperty("org.osgi.framework.storage", "target/osgi/" + System.currentTimeMillis());
    System.setProperty("karaf.name", "root");
    List<BundleDescriptor> bundles = new ClasspathScanner().scanForBundles("(Bundle-SymbolicName=*)");
    bundles.add(getBundleDescriptor("target/jasypt2.jar", bundle().add("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "jasypt").set("Bundle-Version", "0.0.0")));
    bundles.add(getBundleDescriptor("target/test2.jar", bundle().add("OSGI-INF/blueprint/configadmin-test.xml", getClass().getResource("configadmin-test.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "configtest").set("Bundle-Version", "0.0.0")));
    Map config = new HashMap();
    config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
    PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
    bundleContext = reg.getBundleContext();
}
Also used : PojoServiceRegistry(org.apache.felix.connect.launch.PojoServiceRegistry) StandardPBEStringEncryptor(org.jasypt.encryption.pbe.StandardPBEStringEncryptor) BundleDescriptor(org.apache.felix.connect.launch.BundleDescriptor) PojoServiceRegistryFactoryImpl(org.apache.felix.connect.PojoServiceRegistryFactoryImpl) EnvironmentStringPBEConfig(org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig) ClasspathScanner(org.apache.felix.connect.launch.ClasspathScanner) Before(org.junit.Before)

Example 2 with ClasspathScanner

use of org.apache.felix.connect.launch.ClasspathScanner in project karaf by apache.

the class EncryptablePropertyPlaceholderTest method setUp.

@Before
public void setUp() throws Exception {
    StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
    EnvironmentStringPBEConfig env = new EnvironmentStringPBEConfig();
    env.setAlgorithm("PBEWithMD5AndDES");
    env.setPassword("password");
    enc.setConfig(env);
    String val = enc.encrypt("bar");
    System.setProperty("foo", val);
    System.setProperty("org.bundles.framework.storage", "target/bundles/" + System.currentTimeMillis());
    System.setProperty("karaf.name", "root");
    List<BundleDescriptor> bundles = new ClasspathScanner().scanForBundles("(Bundle-SymbolicName=*)");
    bundles.add(getBundleDescriptor("target/jasypt.jar", bundle().add("OSGI-INF/blueprint/karaf-jaas-jasypt.xml", getClass().getResource("/OSGI-INF/blueprint/karaf-jaas-jasypt.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "jasypt").set("Bundle-Version", "0.0.0")));
    bundles.add(getBundleDescriptor("target/test.jar", bundle().add("OSGI-INF/blueprint/test.xml", getClass().getResource("test.xml")).set("Manifest-Version", "2").set("Bundle-ManifestVersion", "2").set("Bundle-SymbolicName", "test").set("Bundle-Version", "0.0.0")));
    Map config = new HashMap();
    config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
    PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
    bundleContext = reg.getBundleContext();
}
Also used : PojoServiceRegistry(org.apache.felix.connect.launch.PojoServiceRegistry) StandardPBEStringEncryptor(org.jasypt.encryption.pbe.StandardPBEStringEncryptor) BundleDescriptor(org.apache.felix.connect.launch.BundleDescriptor) HashMap(java.util.HashMap) PojoServiceRegistryFactoryImpl(org.apache.felix.connect.PojoServiceRegistryFactoryImpl) EnvironmentStringPBEConfig(org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig) HashMap(java.util.HashMap) Map(java.util.Map) ClasspathScanner(org.apache.felix.connect.launch.ClasspathScanner) Before(org.junit.Before)

Example 3 with ClasspathScanner

use of org.apache.felix.connect.launch.ClasspathScanner in project jackrabbit-oak by apache.

the class OakOSGiRepositoryFactory method startBundles.

private void startBundles(PojoServiceRegistry registry, String bundleFilter, Map config) {
    try {
        if (bundleFilter == null) {
            bundleFilter = REPOSITORY_BUNDLE_FILTER_DEFAULT;
        }
        List<BundleDescriptor> descriptors = new ClasspathScanner().scanForBundles(bundleFilter);
        descriptors = Lists.newArrayList(descriptors);
        if (PropertiesUtil.toBoolean(config.get(REPOSITORY_ENV_SPRING_BOOT), false)) {
            descriptors = SpringBootSupport.processDescriptors(descriptors);
        }
        descriptors = processDescriptors(descriptors);
        registry.startBundles(descriptors);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : BundleDescriptor(org.apache.felix.connect.launch.BundleDescriptor) TimeoutException(java.util.concurrent.TimeoutException) RepositoryException(javax.jcr.RepositoryException) BundleException(org.osgi.framework.BundleException) ExecutionException(java.util.concurrent.ExecutionException) ClasspathScanner(org.apache.felix.connect.launch.ClasspathScanner)

Example 4 with ClasspathScanner

use of org.apache.felix.connect.launch.ClasspathScanner in project felix by apache.

the class PojoSR method main.

public static void main(String[] args) throws Exception {
    Filter filter = null;
    Class<?> main = null;
    for (int i = 0; (args != null) && (i < args.length) && (i < 2); i++) {
        try {
            filter = FrameworkUtil.createFilter(args[i]);
        } catch (InvalidSyntaxException ie) {
            try {
                main = PojoSR.class.getClassLoader().loadClass(args[i]);
            } catch (Exception ex) {
                throw new IllegalArgumentException("Argument is neither a filter nor a class: " + args[i]);
            }
        }
    }
    Map<String, Object> config = new HashMap<String, Object>();
    config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, (filter != null) ? new ClasspathScanner().scanForBundles(filter.toString()) : new ClasspathScanner().scanForBundles());
    new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
    if (main != null) {
        int count = 0;
        if (filter != null) {
            count++;
        }
        count++;
        String[] newArgs = args;
        if (count > 0) {
            newArgs = new String[args.length - count];
            System.arraycopy(args, count, newArgs, 0, newArgs.length);
        }
        main.getMethod("main", String[].class).invoke(null, newArgs);
    }
}
Also used : HashMap(java.util.HashMap) BundleException(org.osgi.framework.BundleException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) IOException(java.io.IOException) ClasspathScanner(org.apache.felix.connect.launch.ClasspathScanner) Filter(org.osgi.framework.Filter) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException)

Aggregations

ClasspathScanner (org.apache.felix.connect.launch.ClasspathScanner)4 BundleDescriptor (org.apache.felix.connect.launch.BundleDescriptor)3 HashMap (java.util.HashMap)2 PojoServiceRegistryFactoryImpl (org.apache.felix.connect.PojoServiceRegistryFactoryImpl)2 PojoServiceRegistry (org.apache.felix.connect.launch.PojoServiceRegistry)2 StandardPBEStringEncryptor (org.jasypt.encryption.pbe.StandardPBEStringEncryptor)2 EnvironmentStringPBEConfig (org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig)2 Before (org.junit.Before)2 BundleException (org.osgi.framework.BundleException)2 IOException (java.io.IOException)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 RepositoryException (javax.jcr.RepositoryException)1 Filter (org.osgi.framework.Filter)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1