Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/962#discussion_r43097124
--- Diff: core/src/main/java/org/apache/brooklyn/util/core/osgi/Osgis.java
---
@@ -336,195 +277,56 @@ public static BundleFinder bundleFinder(Framework
framework) {
return
bundleFinder(framework).symbolicName(symbolicName).version(Predicates.equalTo(version)).findUnique();
}
- // -------- creating
-
- /*
- * loading framework factory and starting framework based on:
- *
http://felix.apache.org/documentation/subprojects/apache-felix-framework/apache-felix-framework-launching-and-embedding.html
+ /**
+ * Provides an OSGI framework.
+ *
+ * When running inside an OSGi container, the container framework is
returned.
+ * When running standalone a new Apache Felix container is created.
+ *
+ * Calling {@link #ungetFramework(Framework) } is needed in both
cases, either to stop
+ * the embedded framework or to release the service reference.
+ *
+ * @param felixCacheDir
+ * @param clean
+ * @return
+ * @todo Use felixCacheDir ?
*/
-
- public static FrameworkFactory newFrameworkFactory() {
- URL url = Osgis.class.getClassLoader().getResource(
-
"META-INF/services/org.osgi.framework.launch.FrameworkFactory");
- if (url != null) {
- try {
- BufferedReader br = new BufferedReader(new
InputStreamReader(url.openStream()));
- try {
- for (String s = br.readLine(); s != null; s =
br.readLine()) {
- s = s.trim();
- // load the first non-empty, non-commented line
- if ((s.length() > 0) && (s.charAt(0) != '#')) {
- return (FrameworkFactory)
Class.forName(s).newInstance();
- }
- }
- } finally {
- if (br != null) br.close();
- }
- } catch (Exception e) {
- // class creation exceptions are not interesting to
caller...
- throw Exceptions.propagate(e);
- }
- }
- throw new IllegalStateException("Could not find framework
factory.");
- }
-
- public static Framework newFrameworkStarted(String felixCacheDir,
boolean clean, Map<?,?> extraStartupConfig) {
--- End diff --
keep for compatibility, but deprecated
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---