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();
}
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();
}
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);
}
}
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);
}
}
Aggregations