Author: anierbeck
Date: Tue Mar 26 22:27:06 2013
New Revision: 1461350
URL: http://svn.apache.org/r1461350
Log:
[KARAF-2251] - Cellar: features:install ignores incoming and outgoing blacklist
Modified:
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
karaf/cellar/branches/cellar-2.3.x/samples/camel-hazelcast-app/assembly/
(props changed)
karaf/cellar/branches/cellar-2.3.x/samples/camel-hazelcast-app/consumer/
(props changed)
karaf/cellar/branches/cellar-2.3.x/samples/camel-hazelcast-app/producer/
(props changed)
karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/ (props changed)
karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/api/ (props
changed)
karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/assembly/ (props
changed)
karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/client/ (props
changed)
karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/service/ (props
changed)
karaf/cellar/branches/cellar-2.3.x/samples/hazelcast-app/ (props changed)
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Modified:
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
(original)
+++
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
Tue Mar 26 22:27:06 2013
@@ -13,7 +13,6 @@
*/
package org.apache.karaf.cellar.bundle;
-import java.util.ArrayList;
import java.util.List;
import org.apache.karaf.cellar.core.Configurations;
@@ -22,7 +21,6 @@ import org.apache.karaf.cellar.core.cont
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventHandler;
import org.apache.karaf.cellar.core.event.EventType;
-import org.apache.karaf.features.BundleInfo;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.osgi.framework.BundleEvent;
@@ -33,14 +31,12 @@ import org.slf4j.LoggerFactory;
public class BundleEventHandler extends BundleSupport implements
EventHandler<RemoteBundleEvent> {
- private static final Logger LOGGER =
LoggerFactory.getLogger(BundleEventHandler.class);
+ static final Logger LOGGER =
LoggerFactory.getLogger(BundleEventHandler.class);
public static final String SWITCH_ID =
"org.apache.karaf.cellar.bundle.handler";
private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
- private FeaturesService featureService;
-
/**
* Handles remote bundle events.
*
@@ -63,10 +59,11 @@ public class BundleEventHandler extends
//Check if the pid is marked as local.
if (isAllowed(event.getSourceGroup(), Constants.CATEGORY,
event.getLocation(), EventType.INBOUND)) {
//check the features first
- List<Feature> matchingFeatures = retrieveFeature(event);
+ List<Feature> matchingFeatures =
retrieveFeature(event.getLocation());
for (Feature feature : matchingFeatures) {
if (!isAllowed(event.getSourceGroup(),
"features", feature.getName(), EventType.INBOUND)) {
LOGGER.warn("CELLAR BUNDLE:
bundle {} is contained in a feature marked as BLOCKED INBOUND",
event.getLocation());
+ return;
}
}
if (event.getType() == BundleEvent.INSTALLED) {
@@ -93,22 +90,7 @@ public class BundleEventHandler extends
}
}
- private List<Feature> retrieveFeature(RemoteBundleEvent event) throws
Exception {
- Feature[] features = featureService.listFeatures();
- List<Feature> matchingFeatures = new ArrayList<Feature>();
- for (Feature feature : features) {
- List<BundleInfo> bundles = feature.getBundles();
- for (BundleInfo bundleInfo : bundles) {
- String location = bundleInfo.getLocation();
- if
(location.equalsIgnoreCase(event.getLocation())) {
- matchingFeatures.add(feature);
- }
- }
- }
- return matchingFeatures;
- }
-
- /**
+ /**
* Initialization Method.
*/
public void init() {
@@ -144,18 +126,4 @@ public class BundleEventHandler extends
return RemoteBundleEvent.class;
}
- /**
- * @return the featureService
- */
- public FeaturesService getFeatureService() {
- return featureService;
- }
-
- /**
- * @param featureService the featureService to set
- */
- public void setFeatureService(FeaturesService featureService) {
- this.featureService = featureService;
- }
-
}
Modified:
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
(original)
+++
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
Tue Mar 26 22:27:06 2013
@@ -14,18 +14,24 @@
package org.apache.karaf.cellar.bundle;
import org.apache.karaf.cellar.core.CellarSupport;
+import org.apache.karaf.features.BundleInfo;
+import org.apache.karaf.features.Feature;
+import org.apache.karaf.features.FeaturesService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.service.cm.ConfigurationAdmin;
+import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.List;
import java.util.Properties;
public class BundleSupport extends CellarSupport {
protected BundleContext bundleContext;
+ private FeaturesService featuresService;
/**
* Reads a {@code Dictionary} object and creates a property object out of
it.
@@ -153,4 +159,34 @@ public class BundleSupport extends Cella
this.configurationAdmin = configurationAdmin;
}
+ protected List<Feature> retrieveFeature(String bundleLocation) throws
Exception {
+ Feature[] features = featuresService.listFeatures();
+ List<Feature> matchingFeatures = new ArrayList<Feature>();
+ for (Feature feature : features) {
+ List<BundleInfo> bundles = feature.getBundles();
+ for (BundleInfo bundleInfo : bundles) {
+ String location = bundleInfo.getLocation();
+ if (location.equalsIgnoreCase(bundleLocation)) {
+ matchingFeatures.add(feature);
+ LOGGER.debug("CELLAR BUNDLE: found a
feature {} containing bundle: {}", feature.getName(), bundleLocation);
+ }
+ }
+ }
+ return matchingFeatures;
+ }
+
+ /**
+ * @return the featuresService
+ */
+ public FeaturesService getFeaturesService() {
+ return featuresService;
+ }
+
+ /**
+ * @param featuresService the featuresService to set
+ */
+ public void setFeaturesService(FeaturesService featureService) {
+ this.featuresService = featureService;
+ }
+
}
Modified:
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
(original)
+++
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
Tue Mar 26 22:27:06 2013
@@ -19,6 +19,7 @@ import org.apache.karaf.cellar.core.Node
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventType;
+import org.apache.karaf.features.Feature;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.SynchronousBundleListener;
@@ -92,11 +93,22 @@ public class LocalBundleListener extends
bundles.put(symbolicName + "/" + version,
state);
}
+ // check the features first
+ List<Feature> matchingFeatures =
retrieveFeature(bundleLocation);
+ for (Feature feature : matchingFeatures) {
+ if (!isAllowed(group,
"features", feature.getName(), EventType.OUTBOUND)) {
+ LOGGER.warn("CELLAR
BUNDLE: bundle {} is contained in a feature marked as BLOCKED OUTBOUND",
bundleLocation);
+ return;
+ }
+ }
+
// broadcast the cluster event
RemoteBundleEvent remoteBundleEvent = new
RemoteBundleEvent(symbolicName, version, bundleLocation, type);
remoteBundleEvent.setSourceGroup(group);
eventProducer.produce(remoteBundleEvent);
- } finally {
+ } catch (Exception e) {
+ LOGGER.error("CELLAR BUNDLE: failed to create
bundle event", e);
+ } finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
Modified:
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(original)
+++
karaf/cellar/branches/cellar-2.2.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Tue Mar 26 22:27:06 2013
@@ -22,6 +22,7 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventProducer" ref="eventProducer"/>
+ <property name="featuresService" ref="featuresService"/>
</bean>
<!-- Bundle Synchronizer -->
@@ -32,6 +33,7 @@
<property name="clusterManager" ref="clusterManager"/>
<property name="eventProducer" ref="eventProducer"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
+ <property name="featuresService" ref="featuresService"/>
</bean>
<service ref="synchronizer"
interface="org.apache.karaf.cellar.core.Synchronizer"/>
Modified:
karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java
(original)
+++
karaf/cellar/branches/cellar-2.2.x/core/src/main/java/org/apache/karaf/cellar/core/event/EventDispatchTask.java
Tue Mar 26 22:27:06 2013
@@ -69,13 +69,13 @@ public class EventDispatchTask<E extends
public void run() {
try {
- boolean dispathced = false;
+ boolean dispatched = false;
- for (long delay = 0; delay < timeout && !dispathced; delay +=
interval) {
+ for (long delay = 0; delay < timeout && !dispatched; delay +=
interval) {
EventHandler handler = handlerRegistry.getHandler(event);
if (handler != null) {
handler.handle(event);
- dispathced = true;
+ dispatched = true;
} else {
try {
Thread.sleep(interval);
@@ -84,7 +84,7 @@ public class EventDispatchTask<E extends
}
}
}
- if (!dispathced) {
+ if (!dispatched) {
LOGGER.warn("Failed to retrieve handler for event {}",
event.getClass());
}
}catch(Exception ex) {
Modified:
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
(original)
+++
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
Tue Mar 26 22:27:06 2013
@@ -13,7 +13,6 @@
*/
package org.apache.karaf.cellar.bundle;
-import java.util.ArrayList;
import java.util.List;
import org.apache.karaf.cellar.core.Configurations;
@@ -22,7 +21,6 @@ import org.apache.karaf.cellar.core.cont
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventHandler;
import org.apache.karaf.cellar.core.event.EventType;
-import org.apache.karaf.features.BundleInfo;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.osgi.framework.BundleEvent;
@@ -33,14 +31,12 @@ import org.slf4j.LoggerFactory;
public class BundleEventHandler extends BundleSupport implements
EventHandler<RemoteBundleEvent> {
- private static final Logger LOGGER =
LoggerFactory.getLogger(BundleEventHandler.class);
+ static final Logger LOGGER =
LoggerFactory.getLogger(BundleEventHandler.class);
public static final String SWITCH_ID =
"org.apache.karaf.cellar.bundle.handler";
private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
- private FeaturesService featureService;
-
/**
* Handles remote bundle events.
*
@@ -63,10 +59,11 @@ public class BundleEventHandler extends
//Check if the pid is marked as local.
if (isAllowed(event.getSourceGroup(), Constants.CATEGORY,
event.getLocation(), EventType.INBOUND)) {
//check the features first
- List<Feature> matchingFeatures = retrieveFeature(event);
+ List<Feature> matchingFeatures =
retrieveFeature(event.getLocation());
for (Feature feature : matchingFeatures) {
if (!isAllowed(event.getSourceGroup(),
"features", feature.getName(), EventType.INBOUND)) {
LOGGER.warn("CELLAR BUNDLE:
bundle {} is contained in a feature marked as BLOCKED INBOUND",
event.getLocation());
+ return;
}
}
if (event.getType() == BundleEvent.INSTALLED) {
@@ -93,21 +90,6 @@ public class BundleEventHandler extends
}
}
- private List<Feature> retrieveFeature(RemoteBundleEvent event) throws
Exception {
- Feature[] features = featureService.listFeatures();
- List<Feature> matchingFeatures = new ArrayList<Feature>();
- for (Feature feature : features) {
- List<BundleInfo> bundles = feature.getBundles();
- for (BundleInfo bundleInfo : bundles) {
- String location = bundleInfo.getLocation();
- if
(location.equalsIgnoreCase(event.getLocation())) {
- matchingFeatures.add(feature);
- }
- }
- }
- return matchingFeatures;
- }
-
/**
* Initialization Method.
*/
@@ -144,18 +126,4 @@ public class BundleEventHandler extends
return RemoteBundleEvent.class;
}
- /**
- * @return the featureService
- */
- public FeaturesService getFeatureService() {
- return featureService;
- }
-
- /**
- * @param featureService the featureService to set
- */
- public void setFeatureService(FeaturesService featureService) {
- this.featureService = featureService;
- }
-
}
Modified:
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
(original)
+++
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
Tue Mar 26 22:27:06 2013
@@ -14,18 +14,24 @@
package org.apache.karaf.cellar.bundle;
import org.apache.karaf.cellar.core.CellarSupport;
+import org.apache.karaf.features.BundleInfo;
+import org.apache.karaf.features.Feature;
+import org.apache.karaf.features.FeaturesService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.service.cm.ConfigurationAdmin;
+import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.List;
import java.util.Properties;
public class BundleSupport extends CellarSupport {
protected BundleContext bundleContext;
+ private FeaturesService featuresService;
/**
* Reads a {@code Dictionary} object and creates a property object out of
it.
@@ -153,4 +159,34 @@ public class BundleSupport extends Cella
this.configurationAdmin = configurationAdmin;
}
+ protected List<Feature> retrieveFeature(String bundleLocation) throws
Exception {
+ Feature[] features = featuresService.listFeatures();
+ List<Feature> matchingFeatures = new ArrayList<Feature>();
+ for (Feature feature : features) {
+ List<BundleInfo> bundles = feature.getBundles();
+ for (BundleInfo bundleInfo : bundles) {
+ String location = bundleInfo.getLocation();
+ if (location.equalsIgnoreCase(bundleLocation)) {
+ matchingFeatures.add(feature);
+ LOGGER.debug("CELLAR BUNDLE: found a
feature {} containing bundle: {}", feature.getName(), bundleLocation);
+ }
+ }
+ }
+ return matchingFeatures;
+ }
+
+ /**
+ * @return the featuresService
+ */
+ public FeaturesService getFeaturesService() {
+ return featuresService;
+ }
+
+ /**
+ * @param featuresService the featuresService to set
+ */
+ public void setFeaturesService(FeaturesService featureService) {
+ this.featuresService = featureService;
+ }
+
}
Modified:
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
(original)
+++
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
Tue Mar 26 22:27:06 2013
@@ -19,6 +19,7 @@ import org.apache.karaf.cellar.core.Node
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventType;
+import org.apache.karaf.features.Feature;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.SynchronousBundleListener;
@@ -92,11 +93,22 @@ public class LocalBundleListener extends
bundles.put(symbolicName + "/" + version,
state);
}
+ // check the features first
+ List<Feature> matchingFeatures =
retrieveFeature(bundleLocation);
+ for (Feature feature : matchingFeatures) {
+ if (!isAllowed(group,
"features", feature.getName(), EventType.OUTBOUND)) {
+ LOGGER.warn("CELLAR
BUNDLE: bundle {} is contained in a feature marked as BLOCKED OUTBOUND",
bundleLocation);
+ return;
+ }
+ }
+
// broadcast the cluster event
RemoteBundleEvent remoteBundleEvent = new
RemoteBundleEvent(symbolicName, version, bundleLocation, type);
remoteBundleEvent.setSourceGroup(group);
eventProducer.produce(remoteBundleEvent);
- } finally {
+ } catch (Exception e) {
+ LOGGER.error("CELLAR BUNDLE: failed to create
bundle event", e);
+ } finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
Modified:
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL:
http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.3.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(original)
+++
karaf/cellar/branches/cellar-2.3.x/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Tue Mar 26 22:27:06 2013
@@ -22,6 +22,7 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventProducer" ref="eventProducer"/>
+ <property name="featuresService" ref="featuresService"/>
</bean>
<!-- Bundle Synchronizer -->
@@ -32,6 +33,7 @@
<property name="clusterManager" ref="clusterManager"/>
<property name="eventProducer" ref="eventProducer"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
+ <property name="featuresService" ref="featuresService"/>
</bean>
<service ref="synchronizer"
interface="org.apache.karaf.cellar.core.Synchronizer"/>
Propchange:
karaf/cellar/branches/cellar-2.3.x/samples/camel-hazelcast-app/assembly/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.project
+
+.settings
Propchange:
karaf/cellar/branches/cellar-2.3.x/samples/camel-hazelcast-app/consumer/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.settings
+
+.project
Propchange:
karaf/cellar/branches/cellar-2.3.x/samples/camel-hazelcast-app/producer/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.settings
+
+.project
Propchange: karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.project
+
+.settings
Propchange: karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/api/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.settings
+
+.project
Propchange: karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/assembly/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.settings
+
+.project
Propchange: karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/client/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.settings
+
+.project
Propchange: karaf/cellar/branches/cellar-2.3.x/samples/dosgi-greeter/service/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.settings
+
+.project
Propchange: karaf/cellar/branches/cellar-2.3.x/samples/hazelcast-app/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Mar 26 22:27:06 2013
@@ -1 +1,5 @@
target
+
+.settings
+
+.project
Modified:
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
(original)
+++
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleEventHandler.java
Tue Mar 26 22:27:06 2013
@@ -19,7 +19,6 @@ import org.apache.karaf.cellar.core.cont
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventHandler;
import org.apache.karaf.cellar.core.event.EventType;
-import org.apache.karaf.features.BundleInfo;
import org.apache.karaf.features.Feature;
import org.apache.karaf.features.FeaturesService;
import org.osgi.framework.BundleEvent;
@@ -28,7 +27,6 @@ import org.osgi.service.cm.Configuration
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -40,8 +38,6 @@ public class BundleEventHandler extends
private final Switch eventSwitch = new BasicSwitch(SWITCH_ID);
- private FeaturesService featureService;
-
/**
* Handles remote bundle events.
*
@@ -71,10 +67,11 @@ public class BundleEventHandler extends
//Check if the pid is marked as local.
if (isAllowed(event.getSourceGroup(), Constants.CATEGORY,
event.getLocation(), EventType.INBOUND)) {
//check the features first
- List<Feature> matchingFeatures = retrieveFeature(event);
+ List<Feature> matchingFeatures =
retrieveFeature(event.getLocation());
for (Feature feature : matchingFeatures) {
if (!isAllowed(event.getSourceGroup(),
"features", feature.getName(), EventType.INBOUND)) {
LOGGER.warn("CELLAR BUNDLE:
bundle {} is contained in a feature marked as BLOCKED INBOUND",
event.getLocation());
+ return;
}
}
if (event.getType() == BundleEvent.INSTALLED) {
@@ -101,21 +98,6 @@ public class BundleEventHandler extends
}
}
- private List<Feature> retrieveFeature(RemoteBundleEvent event) throws
Exception {
- Feature[] features = featureService.listFeatures();
- List<Feature> matchingFeatures = new ArrayList<Feature>();
- for (Feature feature : features) {
- List<BundleInfo> bundles = feature.getBundles();
- for (BundleInfo bundleInfo : bundles) {
- String location = bundleInfo.getLocation();
- if
(location.equalsIgnoreCase(event.getLocation())) {
- matchingFeatures.add(feature);
- }
- }
- }
- return matchingFeatures;
- }
-
/**
* Initialization Method.
*/
@@ -151,19 +133,5 @@ public class BundleEventHandler extends
public Class<RemoteBundleEvent> getType() {
return RemoteBundleEvent.class;
}
-
- /**
- * @return the featureService
- */
- public FeaturesService getFeatureService() {
- return featureService;
- }
-
- /**
- * @param featureService the featureService to set
- */
- public void setFeatureService(FeaturesService featureService) {
- this.featureService = featureService;
- }
}
Modified:
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
(original)
+++
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/BundleSupport.java
Tue Mar 26 22:27:06 2013
@@ -14,18 +14,24 @@
package org.apache.karaf.cellar.bundle;
import org.apache.karaf.cellar.core.CellarSupport;
+import org.apache.karaf.features.BundleInfo;
+import org.apache.karaf.features.Feature;
+import org.apache.karaf.features.FeaturesService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.service.cm.ConfigurationAdmin;
+import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.List;
import java.util.Properties;
public class BundleSupport extends CellarSupport {
protected BundleContext bundleContext;
+ private FeaturesService featuresService;
/**
* Reads a {@code Dictionary} object and creates a property object out of
it.
@@ -154,4 +160,34 @@ public class BundleSupport extends Cella
this.configurationAdmin = configurationAdmin;
}
+ protected List<Feature> retrieveFeature(String bundleLocation) throws
Exception {
+ Feature[] features = featuresService.listFeatures();
+ List<Feature> matchingFeatures = new ArrayList<Feature>();
+ for (Feature feature : features) {
+ List<BundleInfo> bundles = feature.getBundles();
+ for (BundleInfo bundleInfo : bundles) {
+ String location = bundleInfo.getLocation();
+ if (location.equalsIgnoreCase(bundleLocation)) {
+ matchingFeatures.add(feature);
+ LOGGER.debug("CELLAR BUNDLE: found a
feature {} containing bundle: {}", feature.getName(), bundleLocation);
+ }
+ }
+ }
+ return matchingFeatures;
+ }
+
+ /**
+ * @return the featuresService
+ */
+ public FeaturesService getFeaturesService() {
+ return featuresService;
+ }
+
+ /**
+ * @param featuresService the featuresService to set
+ */
+ public void setFeaturesService(FeaturesService featureService) {
+ this.featuresService = featureService;
+ }
+
}
Modified:
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
URL:
http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
(original)
+++
karaf/cellar/trunk/bundle/src/main/java/org/apache/karaf/cellar/bundle/LocalBundleListener.java
Tue Mar 26 22:27:06 2013
@@ -19,6 +19,7 @@ import org.apache.karaf.cellar.core.Node
import org.apache.karaf.cellar.core.control.SwitchStatus;
import org.apache.karaf.cellar.core.event.EventProducer;
import org.apache.karaf.cellar.core.event.EventType;
+import org.apache.karaf.features.Feature;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.SynchronousBundleListener;
@@ -92,11 +93,22 @@ public class LocalBundleListener extends
bundles.put(symbolicName + "/" + version,
state);
}
+ // check the features first
+ List<Feature> matchingFeatures =
retrieveFeature(bundleLocation);
+ for (Feature feature : matchingFeatures) {
+ if (!isAllowed(group,
"features", feature.getName(), EventType.OUTBOUND)) {
+ LOGGER.warn("CELLAR
BUNDLE: bundle {} is contained in a feature marked as BLOCKED OUTBOUND",
bundleLocation);
+ return;
+ }
+ }
+
// broadcast the cluster event
RemoteBundleEvent remoteBundleEvent = new
RemoteBundleEvent(symbolicName, version, bundleLocation, type);
remoteBundleEvent.setSourceGroup(group);
eventProducer.produce(remoteBundleEvent);
- } finally {
+ } catch (Exception e) {
+ LOGGER.error("CELLAR BUNDLE: failed to create
bundle event", e);
+ } finally {
Thread.currentThread().setContextClassLoader(originalClassLoader);
}
Modified:
karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL:
http://svn.apache.org/viewvc/karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1461350&r1=1461349&r2=1461350&view=diff
==============================================================================
---
karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
(original)
+++
karaf/cellar/trunk/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml
Tue Mar 26 22:27:06 2013
@@ -26,6 +26,7 @@
<property name="configurationAdmin" ref="configurationAdmin"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="eventProducer" ref="eventProducer"/>
+ <property name="featuresService" ref="featuresService"/>
</bean>
<!-- Bundle Synchronizer -->