You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by dj...@apache.org on 2011/12/03 00:54:22 UTC
svn commit: r1209785 [1/3] - in /karaf/trunk: ./ assemblies/apache-karaf/
assemblies/features/enterprise/src/main/feature/
assemblies/features/framework/
assemblies/features/framework/src/main/feature/
assemblies/features/framework/src/main/filtered-re...
Author: djencks
Date: Fri Dec 2 23:54:19 2011
New Revision: 1209785
URL: http://svn.apache.org/viewvc?rev=1209785&view=rev
Log:
KARAF-1009 equinox Regions support including xml model and basic shell commands"
Added:
karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/regions-config.xml (with props)
karaf/trunk/itests/tests/src/test/resources/
karaf/trunk/itests/tests/src/test/resources/org/
karaf/trunk/itests/tests/src/test/resources/org/apache/
karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/
karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/
karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/startup.properties (with props)
karaf/trunk/region/
karaf/trunk/region/commands/
karaf/trunk/region/commands/pom.xml
- copied, changed from r1209193, karaf/trunk/features/core/pom.xml
karaf/trunk/region/commands/src/
karaf/trunk/region/commands/src/main/
karaf/trunk/region/commands/src/main/java/
karaf/trunk/region/commands/src/main/java/org/
karaf/trunk/region/commands/src/main/java/org/apache/
karaf/trunk/region/commands/src/main/java/org/apache/karaf/
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddBundleCommand.java (with props)
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddFilterCommand.java (with props)
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddRegionCommand.java
- copied, changed from r1209193, karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/InfoCommand.java (with props)
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/RegionCommandSupport.java (with props)
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/
karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/FileUtil.java (with props)
karaf/trunk/region/commands/src/main/resources/
karaf/trunk/region/commands/src/main/resources/OSGI-INF/
karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/
karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/region-commands.xml (with props)
karaf/trunk/region/commands/src/main/resources/OSGI-INF/bundle.info
karaf/trunk/region/persist/
karaf/trunk/region/persist/pom.xml
- copied, changed from r1209193, karaf/trunk/features/core/pom.xml
karaf/trunk/region/persist/src/
karaf/trunk/region/persist/src/main/
karaf/trunk/region/persist/src/main/java/
karaf/trunk/region/persist/src/main/java/org/
karaf/trunk/region/persist/src/main/java/org/apache/
karaf/trunk/region/persist/src/main/java/org/apache/karaf/
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/RegionsPersistence.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/SingleServiceTracker.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/FilterAttributeType.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/FilterBundleType.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/FilterNamespaceType.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/FilterPackageType.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/FilterType.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/ObjectFactory.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/RegionBundleType.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/RegionType.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/RegionsType.java (with props)
karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/model/package-info.java (with props)
karaf/trunk/region/persist/src/main/resources/
karaf/trunk/region/persist/src/main/resources/org/
karaf/trunk/region/persist/src/main/resources/org/apache/
karaf/trunk/region/persist/src/main/resources/org/apache/karaf/
karaf/trunk/region/persist/src/main/resources/org/apache/karaf/region/
karaf/trunk/region/persist/src/main/resources/org/apache/karaf/region/persist/
karaf/trunk/region/persist/src/main/resources/org/apache/karaf/region/persist/region.xsd (with props)
karaf/trunk/region/pom.xml (with props)
Modified:
karaf/trunk/assemblies/apache-karaf/pom.xml
karaf/trunk/assemblies/features/enterprise/src/main/feature/feature.xml
karaf/trunk/assemblies/features/framework/pom.xml
karaf/trunk/assemblies/features/framework/src/main/feature/feature.xml
karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml
karaf/trunk/features/core/pom.xml
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
karaf/trunk/features/core/src/main/resources/org/apache/karaf/features/karaf-features-1.0.0.xsd
karaf/trunk/features/core/src/test/resources/org/apache/karaf/features/repo1.xml
karaf/trunk/itests/kittests/src/test/java/org/apache/karaf/kittests/Helper.java
karaf/trunk/pom.xml
karaf/trunk/shell/config/src/test/java/org/apache/karaf/shell/config/EditCommandTest.java
karaf/trunk/shell/config/src/test/java/org/apache/karaf/shell/config/UpdateCommandTest.java
karaf/trunk/shell/console/src/main/java/org/apache/karaf/shell/console/OsgiCommandSupport.java
karaf/trunk/shell/services/src/main/java/org/apache/karaf/shell/services/ListServices.java
karaf/trunk/shell/services/src/test/java/org/apache/karaf/shell/services/ListServicesTest.java
karaf/trunk/webconsole/features/src/main/java/org/apache/karaf/webconsole/features/ExtendedFeature.java
Modified: karaf/trunk/assemblies/apache-karaf/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/apache-karaf/pom.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/assemblies/apache-karaf/pom.xml (original)
+++ karaf/trunk/assemblies/apache-karaf/pom.xml Fri Dec 2 23:54:19 2011
@@ -139,6 +139,7 @@
<feature>ssh</feature>
<feature>config</feature>
<feature>kar</feature>
+ <feature>region</feature>
</bootFeatures>
</configuration>
</plugin>
Modified: karaf/trunk/assemblies/features/enterprise/src/main/feature/feature.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/enterprise/src/main/feature/feature.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/enterprise/src/main/feature/feature.xml (original)
+++ karaf/trunk/assemblies/features/enterprise/src/main/feature/feature.xml Fri Dec 2 23:54:19 2011
@@ -30,7 +30,7 @@
<bundle start-level='30'>mvn:org.apache.aries.transaction/org.apache.aries.transaction.wrappers/${aries.transaction.version}</bundle>
</feature>
- <feature name='jpa' description='OSGi Persistence Container' version='${aries.jpa.version}' resolver='(obr)'>
+ <feature name='jpa' description='OSGi Persistence Container' version='${aries.jpa.version}' resolver='(obr)' region="org.apache.karaf.region.application">
<details>JPA implementation provided by Apache Aries JPA ${aries.jpa.version}. NB: this feature doesn't provide the JPA engine, you have to install one by yourself (OpenJPA for instance)</details>
<bundle dependency='true' start-level='30'>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/${geronimo.jta-spec.version}</bundle>
<bundle dependency='true' start-level='30'>mvn:org.apache.geronimo.specs/geronimo-jpa_2.0_spec/${geronimo.jpa-spec.version}</bundle>
@@ -41,7 +41,7 @@
<bundle start-level='30'>mvn:org.apache.aries.jpa/org.apache.aries.jpa.container.context/${aries.jpa.version}</bundle>
</feature>
- <feature name='jndi' description='OSGi Service Registry JNDI access' version='${aries.jndi.version}' resolver='(obr)'>
+ <feature name='jndi' description='OSGi Service Registry JNDI access' version='${aries.jndi.version}' resolver='(obr)' region="org.apache.karaf.region.application">
<details>JNDI support provided by Apache Aries JNDI ${aries.jndi.version}</details>
<bundle start-level='30'>mvn:org.apache.aries/org.apache.aries.util/${aries.util.version}</bundle>
<bundle start-level='30'>mvn:org.apache.aries.jndi/org.apache.aries.jndi.api/${aries.jndi.version}</bundle>
@@ -66,8 +66,6 @@
<bundle start-level='30'>mvn:org.apache.aries.application/org.apache.aries.application.utils/${aries.application.version}</bundle>
<bundle start-level='30'>mvn:org.apache.aries.application/org.apache.aries.application.modeller/${aries.application.version}</bundle>
<bundle start-level='30'>mvn:org.apache.aries.application/org.apache.aries.application.default.local.platform/${aries.application.version}</bundle>
- <bundle start-level='30'>mvn:org.apache.aries.application/org.apache.aries.application.noop.platform.repo/${aries.application.version}</bundle>
- <bundle start-level='30'>mvn:org.apache.aries.application/org.apache.aries.application.noop.postresolve.process/${aries.application.version}</bundle>
<bundle start-level='30'>mvn:org.apache.aries.application/org.apache.aries.application.deployment.management/${aries.application.version}</bundle>
<!-- without isolation -->
<bundle start-level='30'>mvn:org.apache.aries.application/org.apache.aries.application.runtime/${aries.application.version}</bundle>
Modified: karaf/trunk/assemblies/features/framework/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/framework/pom.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/framework/pom.xml (original)
+++ karaf/trunk/assemblies/features/framework/pom.xml Fri Dec 2 23:54:19 2011
@@ -198,7 +198,15 @@
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.asm</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>region</artifactId>
+ <version>1.0.0.v20110506</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.region</groupId>
+ <artifactId>org.apache.karaf.region.persist</artifactId>
+ </dependency>
</dependencies>
<build>
<resources>
Modified: karaf/trunk/assemblies/features/framework/src/main/feature/feature.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/framework/src/main/feature/feature.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/framework/src/main/feature/feature.xml (original)
+++ karaf/trunk/assemblies/features/framework/src/main/feature/feature.xml Fri Dec 2 23:54:19 2011
@@ -32,6 +32,8 @@
<bundle start="true" start-level="20">mvn:org.apache.aries/org.apache.aries.util/${aries.util.version}</bundle>
<bundle start="true" start-level="20">mvn:org.apache.aries.proxy/org.apache.aries.proxy/${aries.proxy.version}</bundle>
<bundle start="true" start-level="20">mvn:org.apache.aries.blueprint/org.apache.aries.blueprint/${aries.blueprint.version}</bundle>
+ <bundle start="true" start-level="30">mvn:org.eclipse.equinox/region/1.0.0.v20110506</bundle>
+ <bundle start="true" start-level="30">mvn:org.apache.karaf.region/org.apache.karaf.region.persist/${project.version}</bundle>
<bundle start="true" start-level="25">mvn:org.apache.karaf.features/org.apache.karaf.features.core/${project.version}</bundle>
<bundle start="true" start-level="30">mvn:org.apache.karaf.deployer/org.apache.karaf.deployer.spring/${project.version}</bundle>
<bundle start="true" start-level="30">mvn:org.apache.karaf.deployer/org.apache.karaf.deployer.blueprint/${project.version}</bundle>
Added: karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/regions-config.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/regions-config.xml?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/regions-config.xml (added)
+++ karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/regions-config.xml Fri Dec 2 23:54:19 2011
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<regions xmlns="http://karaf.apache.org/xmlns/region/v1.0.0">
+ <region name="org.apache.karaf.region.application"></region>
+
+ <filter to="org.eclipse.equinox.region.kernel" from="org.apache.karaf.region.application">
+ <package name="org.slf4j"/>
+ <package name="org.apache.aries.util"/>
+ <package name="org.apache.aries.util.io"/>
+ <package name="org.apache.aries.util.nls"/>
+ <package name="org.apache.aries.util.tracker"/>
+ <package name="org.apache.aries.util.service.registry"/>
+ <package name="org.apache.aries.proxy.weaving"/>
+ <package name="org.apache.aries.proxy"/>
+ <package name="org.apache.aries.blueprint"/>
+ <package name="org.apache.aries.blueprint.mutable"/>
+ <package name="org.osgi.service.blueprint"/>
+ <package name="org.osgi.service.blueprint.container"/>
+ <package name="org.osgi.service.blueprint.reflect"/>
+ </filter>
+</regions>
\ No newline at end of file
Propchange: karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/regions-config.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/regions-config.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/assemblies/features/framework/src/main/filtered-resources/resources/etc/regions-config.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml (original)
+++ karaf/trunk/assemblies/features/standard/src/main/feature/feature.xml Fri Dec 2 23:54:19 2011
@@ -135,6 +135,10 @@
<bundle start-level="30" start="true">mvn:org.apache.karaf.shell/org.apache.karaf.shell.config/${project.version}</bundle>
</feature>
+ <feature name="region" description="Provide Region commands" version="${project.version}">
+ <bundle start-level="30" start="true">mvn:org.apache.karaf.region/org.apache.karaf.region.commands/${project.version}</bundle>
+ </feature>
+
<feature name="jetty" description="Provide Jetty engine support" version="${jetty.version}" resolver="(obr)">
<bundle dependency="true" start-level="30">mvn:org.apache.geronimo.specs/geronimo-activation_1.1_spec/${geronimo.activation.version}</bundle>
<bundle dependency="true" start-level="30">mvn:org.apache.geronimo.specs/geronimo-servlet_2.5_spec/${geronimo.servlet.version}</bundle>
Modified: karaf/trunk/features/core/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/pom.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/pom.xml (original)
+++ karaf/trunk/features/core/pom.xml Fri Dec 2 23:54:19 2011
@@ -56,6 +56,11 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.apache.karaf.region</groupId>
+ <artifactId>org.apache.karaf.region.persist</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java Fri Dec 2 23:54:19 2011
@@ -49,4 +49,6 @@ public interface Feature {
List<ConfigFileInfo> getConfigurationFiles();
int getStartLevel();
+
+ String getRegion();
}
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/FeaturesServiceImpl.java Fri Dec 2 23:54:19 2011
@@ -66,6 +66,7 @@ import org.apache.karaf.features.Feature
import org.apache.karaf.features.Repository;
import org.apache.karaf.features.RepositoryEvent;
import org.apache.karaf.features.Resolver;
+import org.apache.karaf.region.persist.RegionsPersistence;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -101,6 +102,7 @@ public class FeaturesServiceImpl impleme
private BundleContext bundleContext;
private ConfigurationAdmin configAdmin;
+ private RegionsPersistence regionsPersistence;
private PackageAdmin packageAdmin;
private StartLevel startLevel;
private long resolverTimeout = 5000;
@@ -135,6 +137,14 @@ public class FeaturesServiceImpl impleme
this.configAdmin = configAdmin;
}
+ public RegionsPersistence getRegionsPersistence() {
+ return regionsPersistence;
+ }
+
+ public void setRegionsPersistence(RegionsPersistence regionsPersistence) {
+ this.regionsPersistence = regionsPersistence;
+ }
+
public PackageAdmin getPackageAdmin() {
return packageAdmin;
}
@@ -484,10 +494,15 @@ public class FeaturesServiceImpl impleme
,verbose);
}
Set<Long> bundles = new TreeSet<Long>();
+ String region = feature.getRegion();
+
for (BundleInfo bInfo : resolve(feature)) {
Bundle b = installBundleIfNeeded(state, bInfo, feature.getStartLevel(), verbose);
bundles.add(b.getBundleId());
state.bundleInfos.put(b.getBundleId(), bInfo);
+ if (region != null && state.installed.contains(b)) {
+ regionsPersistence.install(b, region);
+ }
}
state.features.put(feature, bundles);
}
Modified: karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java (original)
+++ karaf/trunk/features/core/src/main/java/org/apache/karaf/features/internal/model/Feature.java Fri Dec 2 23:54:19 2011
@@ -100,6 +100,8 @@ public class Feature implements org.apac
protected String install;
@XmlAttribute(name = "start-level")
protected Integer startLevel;
+ @XmlAttribute
+ protected String region;
public Feature() {
}
@@ -420,6 +422,15 @@ public class Feature implements org.apac
this.startLevel = value;
}
+
+ public String getRegion() {
+ return region;
+ }
+
+ public void setRegion(String region) {
+ this.region = region;
+ }
+
public String toString() {
String ret = getName() + SPLIT_FOR_NAME_AND_VERSION + getVersion();
return ret;
Modified: karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml (original)
+++ karaf/trunk/features/core/src/main/resources/OSGI-INF/blueprint/gshell-features.xml Fri Dec 2 23:54:19 2011
@@ -38,6 +38,7 @@
<property name="configAdmin" ref="configAdmin" />
<property name="packageAdmin" ref="packageAdmin" />
<property name="startLevel" ref="startLevel" />
+ <property name="regionsPersistence" ref="regionsPersistence" />
<property name="bundleContext" ref="blueprintBundleContext" />
</bean>
@@ -52,7 +53,9 @@
<reference id="packageAdmin" interface="org.osgi.service.packageadmin.PackageAdmin" />
<reference id="startLevel" interface="org.osgi.service.startlevel.StartLevel" />
-
+
+ <reference id="regionsPersistence" interface="org.apache.karaf.region.persist.RegionsPersistence" />
+
<service ref="featuresService" interface="org.apache.karaf.features.FeaturesService" />
</blueprint>
Modified: karaf/trunk/features/core/src/main/resources/org/apache/karaf/features/karaf-features-1.0.0.xsd
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/main/resources/org/apache/karaf/features/karaf-features-1.0.0.xsd?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/resources/org/apache/karaf/features/karaf-features-1.0.0.xsd (original)
+++ karaf/trunk/features/core/src/main/resources/org/apache/karaf/features/karaf-features-1.0.0.xsd Fri Dec 2 23:54:19 2011
@@ -103,6 +103,7 @@ from the default start level defined in
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute name="region" type="xs:string"/>
</xs:complexType>
<xs:complexType name="bundle">
Modified: karaf/trunk/features/core/src/test/resources/org/apache/karaf/features/repo1.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/features/core/src/test/resources/org/apache/karaf/features/repo1.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/src/test/resources/org/apache/karaf/features/repo1.xml (original)
+++ karaf/trunk/features/core/src/test/resources/org/apache/karaf/features/repo1.xml Fri Dec 2 23:54:19 2011
@@ -17,7 +17,7 @@
-->
<features name="test" xmlns="http://karaf.apache.org/xmlns/features/v1.0.0">
<repository>urn:r1</repository>
- <feature name="f1">
+ <feature name="f1" region="foo">
<config name="c1">
k=v
</config>
Modified: karaf/trunk/itests/kittests/src/test/java/org/apache/karaf/kittests/Helper.java
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/kittests/src/test/java/org/apache/karaf/kittests/Helper.java?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/itests/kittests/src/test/java/org/apache/karaf/kittests/Helper.java (original)
+++ karaf/trunk/itests/kittests/src/test/java/org/apache/karaf/kittests/Helper.java Fri Dec 2 23:54:19 2011
@@ -304,7 +304,7 @@ public final class Helper {
}
}
if (!Instance.STARTED.equals(karaf.getState())) {
- throw new Exception("Karaf did not start correctly");
+ throw new Exception("Karaf did not start correctly: state " + karaf.getState());
}
}
Added: karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/startup.properties
URL: http://svn.apache.org/viewvc/karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/startup.properties?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/startup.properties (added)
+++ karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/startup.properties Fri Dec 2 23:54:19 2011
@@ -0,0 +1,20 @@
+# Testing startup.properties
+mvn\:org.ops4j.pax.url/pax-url-aether/1.3.5 = 5
+mvn\:org.ops4j.pax.url/pax-url-wrap/1.3.5 = 5
+mvn\:org.ops4j.pax.logging/pax-logging-api/1.6.3 = 8
+mvn\:org.ops4j.pax.logging/pax-logging-service/1.6.3 = 8
+mvn\:org.apache.felix/org.apache.felix.configadmin/1.2.8 = 10
+mvn\:org.apache.felix/org.apache.felix.fileinstall/3.1.10 = 11
+mvn\:org.apache.servicemix.bundles/org.apache.servicemix.bundles.asm/3.3_2 = 20
+mvn\:org.apache.aries/org.apache.aries.util/0.4-SNAPSHOT = 20
+mvn\:org.apache.aries.proxy/org.apache.aries.proxy/0.4 = 20
+mvn\:org.apache.aries.blueprint/org.apache.aries.blueprint/0.4 = 20
+mvn\:org.apache.karaf.features/org.apache.karaf.features.core/3.0.0-SNAPSHOT = 25
+mvn\:org.apache.karaf.shell/org.apache.karaf.shell.console/3.0.0-SNAPSHOT = 30
+mvn\:org.apache.karaf.jaas/org.apache.karaf.jaas.modules/3.0.0-SNAPSHOT = 30
+mvn\:org.apache.karaf.jaas/org.apache.karaf.jaas.config/3.0.0-SNAPSHOT = 30
+mvn\:org.apache.karaf.shell/org.apache.karaf.shell.bundles/3.0.0-SNAPSHOT = 30
+mvn\:org.apache.karaf.shell/org.apache.karaf.shell.services/3.0.0-SNAPSHOT = 30
+mvn\:org.apache.karaf.shell/org.apache.karaf.shell.system/3.0.0-SNAPSHOT = 30
+mvn\:org.apache.karaf.shell/org.apache.karaf.shell.commands/3.0.0-SNAPSHOT = 30
+mvn\:org.apache.karaf.shell/org.apache.karaf.shell.log/3.0.0-SNAPSHOT = 30
\ No newline at end of file
Propchange: karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/startup.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/startup.properties
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/itests/tests/src/test/resources/org/apache/karaf/testing/startup.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: karaf/trunk/pom.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/pom.xml?rev=1209785&r1=1209784&r2=1209785&view=diff
==============================================================================
--- karaf/trunk/pom.xml (original)
+++ karaf/trunk/pom.xml Fri Dec 2 23:54:19 2011
@@ -38,6 +38,7 @@
<module>util</module>
<module>main</module>
<module>features</module>
+ <module>region</module>
<module>admin</module>
<module>deployer</module>
<module>shell</module>
@@ -141,14 +142,17 @@
<felix.eventadmin.version>1.2.12</felix.eventadmin.version>
<felix.eventadmin-plugin.version>1.0.2</felix.eventadmin-plugin.version>
<felix.obr.version>1.0.2</felix.obr.version>
- <aries.application.version>0.3</aries.application.version>
- <aries.blueprint.version>0.4.1-SNAPSHOT</aries.blueprint.version>
- <aries.jmx.version>0.3</aries.jmx.version>
- <aries.jpa.version>0.3</aries.jpa.version>
- <aries.jndi.version>0.3</aries.jndi.version>
- <aries.proxy.version>0.4.1-SNAPSHOT</aries.proxy.version>
- <aries.transaction.version>0.3</aries.transaction.version>
- <aries.util.version>0.4</aries.util.version>
+ <aries.application.version>0.3.1-SNAPSHOT</aries.application.version>
+ <aries.blueprint.version>0.4</aries.blueprint.version>
+ <aries.blueprint.annotation.version>0.3.2</aries.blueprint.annotation.version>
+ <aries.blueprint.cm.version>0.3.2</aries.blueprint.cm.version>
+ <aries.jmx.version>0.3.1-SNAPSHOT</aries.jmx.version>
+ <aries.jpa.version>0.3.1-SNAPSHOT</aries.jpa.version>
+ <aries.jndi.version>0.3.1-SNAPSHOT</aries.jndi.version>
+ <aries.proxy.version>0.4</aries.proxy.version>
+ <aries.quiesce.version>0.3.2</aries.quiesce.version>
+ <aries.transaction.version>0.3.1-SNAPSHOT</aries.transaction.version>
+ <aries.util.version>0.4-SNAPSHOT</aries.util.version>
<gemini.blueprint.version>1.0.0.RELEASE</gemini.blueprint.version>
<jansi.version>1.7</jansi.version>
<jline.version>2.6-SNAPSHOT</jline.version>
@@ -448,6 +452,16 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.karaf.region</groupId>
+ <artifactId>org.apache.karaf.region.commands</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.region</groupId>
+ <artifactId>org.apache.karaf.region.persist</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
<version>${project.version}</version>
Copied: karaf/trunk/region/commands/pom.xml (from r1209193, karaf/trunk/features/core/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/pom.xml?p2=karaf/trunk/region/commands/pom.xml&p1=karaf/trunk/features/core/pom.xml&r1=1209193&r2=1209785&rev=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/pom.xml (original)
+++ karaf/trunk/region/commands/pom.xml Fri Dec 2 23:54:19 2011
@@ -10,7 +10,7 @@
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,16 +22,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.karaf.features</groupId>
- <artifactId>features</artifactId>
+ <groupId>org.apache.karaf.region</groupId>
+ <artifactId>region</artifactId>
<version>3.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>org.apache.karaf.features.core</artifactId>
+ <artifactId>org.apache.karaf.region.commands</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Features :: Core</name>
- <description>This bundle is the core implementation of the Karaf features support.</description>
+ <name>Apache Karaf :: Shell :: Region Commands</name>
+ <description>This bundle provides Karaf shell commands to manipulate the Region service.</description>
<properties>
<appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
@@ -45,41 +44,25 @@
</dependency>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.utils</artifactId>
- <scope>provided</scope>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
+ <groupId>org.apache.aries</groupId>
+ <artifactId>org.apache.aries.util</artifactId>
</dependency>
-
- <!-- I think this is here only to get better attributes on the felix gogo/shell imports which appear to be unnecessary anyway ??? -->
<dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <scope>provided</scope>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>region</artifactId>
+ <version>1.0.0.v20110506</version>
</dependency>
<dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
- <!-- uncomment for more complete test log output -->
- <dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<scope>test</scope>
@@ -108,26 +91,11 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Export-Package>org.apache.karaf.features;version=${project.version}</Export-Package>
<Import-Package>
- !org.apache.karaf.features,
- javax.management,
- javax.management.loading,
- org.apache.aries.blueprint,
- org.osgi.service.blueprint.container,
- org.osgi.service.blueprint.reflect,
- org.apache.felix.service.command,
- org.apache.karaf.shell.commands,
- org.apache.karaf.shell.console,
- org.osgi.service.event*;resolution:=optional,
+ !${project.artifactId}*,
*
</Import-Package>
- <Private-Package>
- org.apache.karaf.features.internal,
- org.apache.karaf.features.internal.model,
- org.apache.felix.utils.version,
- org.apache.felix.utils.manifest
- </Private-Package>
+ <Private-Package>!*</Private-Package>
</instructions>
</configuration>
</plugin>
Added: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddBundleCommand.java
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddBundleCommand.java?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddBundleCommand.java (added)
+++ karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddBundleCommand.java Fri Dec 2 23:54:19 2011
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.region.commands;
+
+import java.util.List;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.osgi.framework.Bundle;
+
+@Command(scope = "region", name = "addBundle", description = "Adds a list of known bundles by id to a specified Region.")
+public class AddBundleCommand extends RegionCommandSupport {
+
+ @Argument(index = 0, name = "region", description = "Region to add the bundles to", required = true, multiValued = false)
+ String region;
+
+ @Argument(index = 1, name = "bundles", description = "Bundles by id to add to the region", required = true, multiValued = true)
+ List<Long> ids;
+
+ protected void doExecute(RegionDigraph regionDigraph) throws Exception {
+ Region r = getRegion(regionDigraph, region);
+ for (Long id : ids) {
+ for (Region existing: regionDigraph.getRegions()) {
+ if (existing.contains(id)) {
+ Bundle b = getBundleContext().getBundle(id);
+ System.out.println("Removing bundle " + id + " from region " + existing.getName());
+ existing.removeBundle(b);
+ break;
+ }
+ }
+ r.addBundle(id);
+ }
+ }
+}
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddBundleCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddBundleCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddBundleCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddFilterCommand.java
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddFilterCommand.java?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddFilterCommand.java (added)
+++ karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddFilterCommand.java Fri Dec 2 23:54:19 2011
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.region.commands;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.aries.util.VersionRange;
+import org.apache.aries.util.manifest.ManifestHeaderProcessor;
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionFilter;
+import org.eclipse.equinox.region.RegionFilterBuilder;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+@Command(scope = "region", name = "addFilter", description = "Adds a Filter between two regions")
+public class AddFilterCommand extends RegionCommandSupport {
+
+ @Argument(index = 0, name = "fromregion", description = "Region 1", required = true, multiValued = false)
+ String fromRegion;
+
+ @Argument(index = 1, name = "toregion", description = "Region 2", required = true, multiValued = false)
+ String toRegion;
+
+ @Argument(index = 2, name = "filteritems", description = "bundles by id and packages with version to allow", required = false, multiValued = true)
+ List<String> items;
+
+ protected void doExecute(RegionDigraph regionDigraph) throws Exception {
+ Region rFrom = getRegion(regionDigraph, fromRegion);
+ Region rTo = getRegion(regionDigraph, toRegion);
+ RegionFilterBuilder builder = regionDigraph.createRegionFilterBuilder();
+ BundleContext framework = getBundleContext().getBundle(0).getBundleContext();
+ if (items != null) {
+ for (String item : items) {
+ try {
+ long id = Long.parseLong(item);
+ Bundle b = framework.getBundle(id);
+ builder.allow("osgi.wiring.bundle", "(osgi.wiring.bundle=" + b.getSymbolicName() + ")");
+ } catch (NumberFormatException e) {
+ for (Map.Entry<String, Map<String, String>> parsed: ManifestHeaderProcessor.parseImportString(item).entrySet()) {
+ String packageName = parsed.getKey();
+ Map<String, String> attributes = new HashMap<String, String>(parsed.getValue());
+ attributes.put("osgi.wiring.package", packageName);
+ String filter = generateFilter(attributes);
+ System.out.println("adding filter " + filter);
+ builder.allow("osgi.wiring.package", filter);
+ }
+ }
+
+ }
+ }
+ RegionFilter f = builder.build();
+ regionDigraph.connect(rFrom, f, rTo);
+ }
+
+ //from aries util, with obr specific weirdness removed
+ public static String generateFilter(Map<String, String> attribs) {
+ StringBuilder filter = new StringBuilder("(&");
+ boolean realAttrib = false;
+ StringBuffer realAttribs = new StringBuffer();
+
+ if (attribs == null) {
+ attribs = new HashMap<String, String>();
+ }
+
+ for (Map.Entry<String, String> attrib : attribs.entrySet()) {
+ String attribName = attrib.getKey();
+
+ if (attribName.endsWith(":")) {
+ // skip all directives. It is used to affect the attribs on the
+ // filter xml.
+ } else if ((Constants.VERSION_ATTRIBUTE.equals(attribName))
+ || (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(attribName))) {
+ // version and bundle-version attrib requires special
+ // conversion.
+ realAttrib = true;
+
+ VersionRange vr = ManifestHeaderProcessor
+ .parseVersionRange(attrib.getValue());
+
+ filter.append("(" + attribName + ">=" + vr.getMinimumVersion());
+
+ if (vr.getMaximumVersion() != null) {
+ filter.append(")(" + attribName + "<=");
+ filter.append(vr.getMaximumVersion());
+ }
+
+ if (vr.getMaximumVersion() != null && vr.isMinimumExclusive()) {
+ filter.append(")(!(" + attribName + "=");
+ filter.append(vr.getMinimumVersion());
+ filter.append(")");
+ }
+
+ if (vr.getMaximumVersion() != null && vr.isMaximumExclusive()) {
+ filter.append(")(!(" + attribName + "=");
+ filter.append(vr.getMaximumVersion());
+ filter.append(")");
+ }
+ filter.append(")");
+
+ } else if (Constants.OBJECTCLASS.equals(attribName)) {
+ realAttrib = true;
+ // objectClass has a "," separated list of interfaces
+ String[] values = attrib.getValue().split(",");
+ for (String s : values)
+ filter.append("(" + Constants.OBJECTCLASS + "=" + s + ")");
+
+ } else {
+ // attribName was not version..
+ realAttrib = true;
+
+ filter.append("(" + attribName + "=" + attrib.getValue() + ")");
+ // store all attributes in order to build up the mandatory
+ // filter and separate them with ", "
+ // skip bundle-symbolic-name in the mandatory directive query
+ if (!!!Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE
+ .equals(attribName)) {
+ realAttribs.append(attribName);
+ realAttribs.append(", ");
+ }
+ }
+ }
+
+ // Prune (& off the front and ) off end
+ String filterString = filter.toString();
+ int openBraces = 0;
+ for (int i = 0; openBraces < 3; i++) {
+ i = filterString.indexOf('(', i);
+ if (i == -1) {
+ break;
+ } else {
+ openBraces++;
+ }
+ }
+ if (openBraces < 3 && filterString.length() > 2) {
+ filter.delete(0, 2);
+ } else {
+ filter.append(")");
+ }
+
+ String result = "";
+ if (realAttrib != false) {
+ result = filter.toString();
+ }
+ return result;
+ }
+
+}
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddFilterCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddFilterCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddFilterCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddRegionCommand.java (from r1209193, karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java)
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddRegionCommand.java?p2=karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddRegionCommand.java&p1=karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java&r1=1209193&r2=1209785&rev=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/src/main/java/org/apache/karaf/features/Feature.java (original)
+++ karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/AddRegionCommand.java Fri Dec 2 23:54:19 2011
@@ -14,39 +14,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.karaf.features;
+package org.apache.karaf.region.commands;
import java.util.List;
-import java.util.Map;
-/**
- * A feature is a list of bundles associated identified by its name.
- */
-public interface Feature {
-
- public static String DEFAULT_INSTALL_MODE = "auto";
-
- String getId();
-
- String getName();
-
- String getDescription();
-
- String getDetails();
-
- String getVersion();
-
- String getResolver();
-
- String getInstall();
-
- List<Dependency> getDependencies();
-
- List<BundleInfo> getBundles();
-
- Map<String, Map<String, String>> getConfigurations();
-
- List<ConfigFileInfo> getConfigurationFiles();
-
- int getStartLevel();
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.eclipse.equinox.region.RegionDigraph;
+
+@Command(scope = "region", name = "addRegion", description = "Adds a list of regions to the RegionDigraph service.")
+public class AddRegionCommand extends RegionCommandSupport {
+
+ @Argument(index = 0, name = "name", description = "Regions to add to the RegionDigraph service separated by whitespaces", required = true, multiValued = true)
+ List<String> regions;
+
+ protected void doExecute(RegionDigraph regionDigraph) throws Exception {
+ for (String region : regions) {
+ regionDigraph.createRegion(region);
+ }
+ }
}
Added: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/InfoCommand.java
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/InfoCommand.java?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/InfoCommand.java (added)
+++ karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/InfoCommand.java Fri Dec 2 23:54:19 2011
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.region.commands;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionFilter;
+import org.osgi.framework.Bundle;
+
+@Command(scope = "region", name = "info", description = "Prints information about region digraph.")
+public class InfoCommand extends RegionCommandSupport {
+
+ @Option(name = "-v", aliases = "--verbose", required = false, description = "Show all info")
+ boolean verbose;
+
+ @Option(name = "-b", aliases = "--bundles", required = false, description = "Show bundles in each region")
+ boolean bundles;
+
+ @Option(name = "-f", aliases = "--filters", required = false, description = "Show filters")
+ boolean filters;
+
+ @Option(name = "-n", aliases = "--namespaces", required = false, description = "Show namespaces in each filter")
+ boolean namespaces;
+
+ @Argument(index = 0, name = "regions", description = "Regions to provide detailed info for", required = false, multiValued = true)
+ List<String> regions;
+
+ protected void doExecute(RegionDigraph regionDigraph) throws Exception {
+ System.out.println("Regions");
+ if (regions == null) {
+ for (Region region : regionDigraph.getRegions()) {
+ showRegion(region);
+ }
+ } else {
+ bundles = true;
+ filters = true;
+ namespaces = true;
+ for (String regionName : regions) {
+ Region region = regionDigraph.getRegion(regionName);
+ if (region == null) {
+ System.out.println("No region " + regionName);
+ } else {
+ showRegion(region);
+ }
+ }
+ }
+ }
+
+ private void showRegion(Region region) {
+ System.out.println(region.getName());
+ if (verbose || bundles) {
+ for (Long id : region.getBundleIds()) {
+ Bundle b = getBundleContext().getBundle(id);
+ System.out.println(" " + id + " " + getStateString(b) + b);
+ }
+ }
+ if (verbose || filters || namespaces) {
+ for (RegionDigraph.FilteredRegion f : region.getEdges()) {
+ System.out.println(" filter to " + f.getRegion().getName());
+ if (verbose || namespaces) {
+ RegionFilter rf = f.getFilter();
+ for (Map.Entry<String, Collection<String>> policy : rf.getSharingPolicy().entrySet()) {
+ String namespace = policy.getKey();
+ System.out.println(" namespace: " + namespace);
+ for (String e : policy.getValue()) {
+ System.out.println(" " + e);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public String getStateString(Bundle bundle) {
+ if (bundle == null) {
+ return "Bundle null";
+ }
+ int state = bundle.getState();
+ if (state == Bundle.ACTIVE) {
+ return "Active ";
+ } else if (state == Bundle.INSTALLED) {
+ return "Installed ";
+ } else if (state == Bundle.RESOLVED) {
+ return "Resolved ";
+ } else if (state == Bundle.STARTING) {
+ return "Starting ";
+ } else if (state == Bundle.STOPPING) {
+ return "Stopping ";
+ } else {
+ return "Unknown ";
+ }
+ }
+
+}
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/InfoCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/InfoCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/InfoCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/RegionCommandSupport.java
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/RegionCommandSupport.java?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/RegionCommandSupport.java (added)
+++ karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/RegionCommandSupport.java Fri Dec 2 23:54:19 2011
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.region.commands;
+
+import java.io.PrintStream;
+
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+
+public abstract class RegionCommandSupport extends OsgiCommandSupport {
+
+ protected static final char VERSION_DELIM = ',';
+
+ protected Object doExecute() throws Exception {
+ // Get repository admin service.
+ ServiceReference ref = getBundleContext().getServiceReference(RegionDigraph.class.getName());
+ if (ref == null) {
+ System.out.println("RegionDigraph service is unavailable.");
+ return null;
+ }
+ try {
+ RegionDigraph admin = (RegionDigraph) getBundleContext().getService(ref);
+ if (admin == null) {
+ System.out.println("RegionDigraph service is unavailable.");
+ return null;
+ }
+
+ doExecute(admin);
+ }
+ finally {
+ getBundleContext().ungetService(ref);
+ }
+ return null;
+ }
+
+ abstract void doExecute(RegionDigraph admin) throws Exception;
+
+ protected void printUnderline(PrintStream out, int length)
+ {
+ for (int i = 0; i < length; i++)
+ {
+ out.print('-');
+ }
+ out.println("");
+ }
+
+
+ protected Region getRegion(RegionDigraph regionDigraph, String region) throws BundleException {
+ Region r = regionDigraph.getRegion(region);
+ if (r == null) {
+ System.out.println("No region: " + region + ", creating it");
+ r = regionDigraph.createRegion(region);
+ }
+ return r;
+ }
+}
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/RegionCommandSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/RegionCommandSupport.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/RegionCommandSupport.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/FileUtil.java
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/FileUtil.java?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/FileUtil.java (added)
+++ karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/FileUtil.java Fri Dec 2 23:54:19 2011
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.karaf.region.commands.util;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+public class FileUtil
+{
+ public static void downloadSource(
+ PrintStream out, PrintStream err,
+ URL srcURL, String dirStr, boolean extract)
+ {
+ // Get the file name from the URL.
+ String fileName = (srcURL.getFile().lastIndexOf('/') > 0)
+ ? srcURL.getFile().substring(srcURL.getFile().lastIndexOf('/') + 1)
+ : srcURL.getFile();
+
+ try
+ {
+ out.println("Connecting...");
+
+ File dir = new File(dirStr);
+ if (!dir.exists())
+ {
+ err.println("Destination directory does not exist.");
+ }
+ File file = new File(dir, fileName);
+
+ OutputStream os = new FileOutputStream(file);
+ URLConnection conn = srcURL.openConnection();
+ int total = conn.getContentLength();
+ InputStream is = conn.getInputStream();
+
+ if (total > 0)
+ {
+ out.println("Downloading " + fileName
+ + " ( " + total + " bytes ).");
+ }
+ else
+ {
+ out.println("Downloading " + fileName + ".");
+ }
+ byte[] buffer = new byte[4096];
+ int count = 0;
+ for (int len = is.read(buffer); len > 0; len = is.read(buffer))
+ {
+ count += len;
+ os.write(buffer, 0, len);
+ }
+
+ os.close();
+ is.close();
+
+ if (extract)
+ {
+ is = new FileInputStream(file);
+ JarInputStream jis = new JarInputStream(is);
+ out.println("Extracting...");
+ unjar(jis, dir);
+ jis.close();
+ file.delete();
+ }
+ }
+ catch (Exception ex)
+ {
+ err.println(ex);
+ }
+ }
+
+ public static void unjar(JarInputStream jis, File dir)
+ throws IOException
+ {
+ // Reusable buffer.
+ byte[] buffer = new byte[4096];
+
+ // Loop through JAR entries.
+ for (JarEntry je = jis.getNextJarEntry();
+ je != null;
+ je = jis.getNextJarEntry())
+ {
+ if (je.getName().startsWith("/"))
+ {
+ throw new IOException("JAR resource cannot contain absolute paths.");
+ }
+
+ File target = new File(dir, je.getName());
+
+ // Check to see if the JAR entry is a directory.
+ if (je.isDirectory())
+ {
+ if (!target.exists())
+ {
+ if (!target.mkdirs())
+ {
+ throw new IOException("Unable to create target directory: "
+ + target);
+ }
+ }
+ // Just continue since directories do not have content to copy.
+ continue;
+ }
+
+ int lastIndex = je.getName().lastIndexOf('/');
+ String name = (lastIndex >= 0) ?
+ je.getName().substring(lastIndex + 1) : je.getName();
+ String destination = (lastIndex >= 0) ?
+ je.getName().substring(0, lastIndex) : "";
+
+ // JAR files use '/', so convert it to platform separator.
+ destination = destination.replace('/', File.separatorChar);
+ copy(jis, dir, name, destination, buffer);
+ }
+ }
+
+ public static void copy(
+ InputStream is, File dir, String destName, String destDir, byte[] buffer)
+ throws IOException
+ {
+ if (destDir == null)
+ {
+ destDir = "";
+ }
+
+ // Make sure the target directory exists and
+ // that is actually a directory.
+ File targetDir = new File(dir, destDir);
+ if (!targetDir.exists())
+ {
+ if (!targetDir.mkdirs())
+ {
+ throw new IOException("Unable to create target directory: "
+ + targetDir);
+ }
+ }
+ else if (!targetDir.isDirectory())
+ {
+ throw new IOException("Target is not a directory: "
+ + targetDir);
+ }
+
+ BufferedOutputStream bos = new BufferedOutputStream(
+ new FileOutputStream(new File(targetDir, destName)));
+ int count = 0;
+ while ((count = is.read(buffer)) > 0)
+ {
+ bos.write(buffer, 0, count);
+ }
+ bos.close();
+ }
+}
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/FileUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/FileUtil.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/region/commands/src/main/java/org/apache/karaf/region/commands/util/FileUtil.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/region-commands.xml
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/region-commands.xml?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/region-commands.xml (added)
+++ karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/region-commands.xml Fri Dec 2 23:54:19 2011
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ default-activation="lazy">
+ <reference id="regionDigraph"
+ interface="org.eclipse.equinox.region.RegionDigraph"
+ availability="mandatory" />
+
+ <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+ <command name="region/addBundle">
+ <action class="org.apache.karaf.region.commands.AddBundleCommand" />
+ </command>
+ <command name="region/addFilter">
+ <action class="org.apache.karaf.region.commands.AddFilterCommand" />
+ </command>
+ <command name="region/addRegion">
+ <action class="org.apache.karaf.region.commands.AddRegionCommand" />
+ </command>
+ <command name="region/info">
+ <action class="org.apache.karaf.region.commands.InfoCommand" />
+ </command>
+ <!--<command name="region/list">-->
+ <!--<action class="org.apache.karaf.shell.region.ListCommand">-->
+ <!--<property name="repoAdmin" ref="repoAdmin" />-->
+ <!--</action>-->
+ <!--</command>-->
+ </command-bundle>
+
+</blueprint>
Propchange: karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/region-commands.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/region-commands.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/region/commands/src/main/resources/OSGI-INF/blueprint/region-commands.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: karaf/trunk/region/commands/src/main/resources/OSGI-INF/bundle.info
URL: http://svn.apache.org/viewvc/karaf/trunk/region/commands/src/main/resources/OSGI-INF/bundle.info?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/commands/src/main/resources/OSGI-INF/bundle.info (added)
+++ karaf/trunk/region/commands/src/main/resources/OSGI-INF/bundle.info Fri Dec 2 23:54:19 2011
@@ -0,0 +1,18 @@
+h1. Synopsis
+
+${project.name}
+
+${project.description}
+
+Maven URL:
+[mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+This bundle provides Karaf shell commands to manipulate the Karaf embedded Region service.
+
+The following commands are available:
+* region:addbundle - Adds specified bundles (by id) to a region.
+* region:addfilter - Adds a filter between two regions containing bundles (by id) and packages (with attributes including version).
+* region:addregion - adds regions.
+* region:info - Prints information about region digraph.
\ No newline at end of file
Copied: karaf/trunk/region/persist/pom.xml (from r1209193, karaf/trunk/features/core/pom.xml)
URL: http://svn.apache.org/viewvc/karaf/trunk/region/persist/pom.xml?p2=karaf/trunk/region/persist/pom.xml&p1=karaf/trunk/features/core/pom.xml&r1=1209193&r2=1209785&rev=1209785&view=diff
==============================================================================
--- karaf/trunk/features/core/pom.xml (original)
+++ karaf/trunk/region/persist/pom.xml Fri Dec 2 23:54:19 2011
@@ -10,7 +10,7 @@
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@@ -22,16 +22,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.karaf.features</groupId>
- <artifactId>features</artifactId>
+ <groupId>org.apache.karaf.region</groupId>
+ <artifactId>region</artifactId>
<version>3.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>org.apache.karaf.features.core</artifactId>
+ <artifactId>org.apache.karaf.region.persist</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Features :: Core</name>
- <description>This bundle is the core implementation of the Karaf features support.</description>
+ <name>Apache Karaf :: Region :: Persistence</name>
+ <description>This bundle provides an xml regions model and install/dump actions.</description>
<properties>
<appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
@@ -43,7 +42,6 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
-
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
@@ -51,35 +49,23 @@
</dependency>
<dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.utils</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
- <!-- I think this is here only to get better attributes on the felix gogo/shell imports which appear to be unnecessary anyway ??? -->
<dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <scope>provided</scope>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>region</artifactId>
+ <version>1.0.0.v20110506</version>
</dependency>
<dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
- <!-- uncomment for more complete test log output -->
- <dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<scope>test</scope>
@@ -108,30 +94,43 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Export-Package>org.apache.karaf.features;version=${project.version}</Export-Package>
+ <Bundle-Activator>org.apache.karaf.region.persist.internal.Activator</Bundle-Activator>
<Import-Package>
- !org.apache.karaf.features,
- javax.management,
- javax.management.loading,
- org.apache.aries.blueprint,
- org.osgi.service.blueprint.container,
- org.osgi.service.blueprint.reflect,
- org.apache.felix.service.command,
- org.apache.karaf.shell.commands,
- org.apache.karaf.shell.console,
- org.osgi.service.event*;resolution:=optional,
+ !${project.artifactId}*,
*
</Import-Package>
- <Private-Package>
- org.apache.karaf.features.internal,
- org.apache.karaf.features.internal.model,
- org.apache.felix.utils.version,
- org.apache.felix.utils.manifest
- </Private-Package>
+ <Private-Package>!*</Private-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>jaxb</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jaxb2-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>xjc</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <schemaDirectory>src/main/resources/org/apache/karaf/region/persist</schemaDirectory>
+ <packageName>org.apache.karaf.region.persist.model</packageName>
+ <extension>true</extension>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added: karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/RegionsPersistence.java
URL: http://svn.apache.org/viewvc/karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/RegionsPersistence.java?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/RegionsPersistence.java (added)
+++ karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/RegionsPersistence.java Fri Dec 2 23:54:19 2011
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.karaf.region.persist;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface RegionsPersistence {
+ void install(Bundle b, String regionName) throws BundleException;
+}
Propchange: karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/RegionsPersistence.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/RegionsPersistence.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/RegionsPersistence.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
URL: http://svn.apache.org/viewvc/karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java?rev=1209785&view=auto
==============================================================================
--- karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java (added)
+++ karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java Fri Dec 2 23:54:19 2011
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.karaf.region.persist.internal;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.karaf.region.persist.RegionsPersistence;
+import org.apache.karaf.region.persist.internal.util.SingleServiceTracker;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class Activator implements BundleActivator {
+
+ private static final Logger log = LoggerFactory.getLogger(Activator.class);
+
+ private SingleServiceTracker<RegionDigraph> tracker;
+ private final AtomicReference<RegionsPersistenceImpl> persistence = new AtomicReference<RegionsPersistenceImpl>();
+ private final AtomicReference<RegionsBundleTracker> bundleTracker = new AtomicReference<RegionsBundleTracker>();
+ private ServiceRegistration<RegionsPersistence> reg;
+
+ @Override
+ public void start(final BundleContext bundleContext) throws Exception {
+ tracker = new SingleServiceTracker<RegionDigraph>(bundleContext, RegionDigraph.class, new SingleServiceTracker.SingleServiceListener() {
+ public void serviceFound() {
+ log.debug("Found RegionDigraph service, initializing");
+ RegionDigraph regionDigraph = tracker.getService();
+ Bundle framework = bundleContext.getBundle(0);
+ RegionsPersistenceImpl persistence = null;
+ try {
+ persistence = new RegionsPersistenceImpl(regionDigraph, framework);
+ reg = bundleContext.registerService(RegionsPersistence.class, persistence, null);
+
+ RegionsBundleTracker bundleTracker = new RegionsBundleTracker();
+ bundleTracker.start(bundleContext, persistence);
+ Activator.this.bundleTracker.set(bundleTracker);
+ } catch (Exception e) {
+ log.info("Could not create RegionsPersistenceImpl", e);
+ }
+ Activator.this.persistence.set(persistence);
+ }
+
+ public void serviceLost() {
+ if (reg != null) {
+ reg.unregister();
+ reg = null;
+ }
+ Activator.this.persistence.set(null);
+ Activator.this.bundleTracker.set(null);
+ }
+
+ public void serviceReplaced() {
+ //??
+ }
+ });
+ tracker.open();
+ }
+
+ @Override
+ public void stop(BundleContext bundleContext) throws Exception {
+ tracker.close();
+ persistence.set(null);
+ bundleTracker.set(null);
+ }
+
+
+}
Propchange: karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: karaf/trunk/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain