You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/03/28 18:33:22 UTC
[1/4] [KARAF-2859] Decouple features/core from persistent/core
Repository: karaf
Updated Branches:
refs/heads/master 5f5239abc -> 200bd9ba0
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterType.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterType.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterType.java
deleted file mode 100644
index f4d1352..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterType.java
+++ /dev/null
@@ -1,195 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for filterType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="filterType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="bundle" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterBundleType" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="package" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterPackageType" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="namespace" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterNamespaceType" maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * <attribute name="from" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="to" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "filterType", propOrder = {
- "bundle",
- "_package",
- "namespace"
-})
-public class FilterType {
-
- protected List<FilterBundleType> bundle;
- @XmlElement(name = "package")
- protected List<FilterPackageType> _package;
- protected List<FilterNamespaceType> namespace;
- @XmlAttribute(required = true)
- protected String from;
- @XmlAttribute(required = true)
- protected String to;
-
- /**
- * Gets the value of the bundle property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the bundle property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getBundle().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link FilterBundleType }
- *
- *
- */
- public List<FilterBundleType> getBundle() {
- if (bundle == null) {
- bundle = new ArrayList<FilterBundleType>();
- }
- return this.bundle;
- }
-
- /**
- * Gets the value of the package property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the package property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getPackage().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link FilterPackageType }
- *
- *
- */
- public List<FilterPackageType> getPackage() {
- if (_package == null) {
- _package = new ArrayList<FilterPackageType>();
- }
- return this._package;
- }
-
- /**
- * Gets the value of the namespace property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the namespace property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getNamespace().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link FilterNamespaceType }
- *
- *
- */
- public List<FilterNamespaceType> getNamespace() {
- if (namespace == null) {
- namespace = new ArrayList<FilterNamespaceType>();
- }
- return this.namespace;
- }
-
- /**
- * Gets the value of the from property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getFrom() {
- return from;
- }
-
- /**
- * Sets the value of the from property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setFrom(String value) {
- this.from = value;
- }
-
- /**
- * Gets the value of the to property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getTo() {
- return to;
- }
-
- /**
- * Sets the value of the to property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setTo(String value) {
- this.to = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/ObjectFactory.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/ObjectFactory.java
deleted file mode 100644
index 54f5f3c..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/ObjectFactory.java
+++ /dev/null
@@ -1,116 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.annotation.XmlElementDecl;
-import javax.xml.bind.annotation.XmlRegistry;
-import javax.xml.namespace.QName;
-
-
-/**
- * This object contains factory methods for each
- * Java content interface and Java element interface
- * generated in the org.apache.karaf.region.persist.internal.model package.
- * <p>An ObjectFactory allows you to programatically
- * construct new instances of the Java representation
- * for XML content. The Java representation of XML
- * content can consist of schema derived interfaces
- * and classes representing the binding of schema
- * type definitions, element declarations and model
- * groups. Factory methods for each of these are
- * provided in this class.
- *
- */
-@XmlRegistry
-public class ObjectFactory {
-
- private final static QName _Regions_QNAME = new QName("http://karaf.apache.org/xmlns/region/v1.0.0", "regions");
-
- /**
- * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.karaf.region.persist.internal.model
- *
- */
- public ObjectFactory() {
- }
-
- /**
- * Create an instance of {@link FilterNamespaceType }
- *
- */
- public FilterNamespaceType createFilterNamespaceType() {
- return new FilterNamespaceType();
- }
-
- /**
- * Create an instance of {@link FilterType }
- *
- */
- public FilterType createFilterType() {
- return new FilterType();
- }
-
- /**
- * Create an instance of {@link RegionBundleType }
- *
- */
- public RegionBundleType createRegionBundleType() {
- return new RegionBundleType();
- }
-
- /**
- * Create an instance of {@link FilterBundleType }
- *
- */
- public FilterBundleType createFilterBundleType() {
- return new FilterBundleType();
- }
-
- /**
- * Create an instance of {@link FilterPackageType }
- *
- */
- public FilterPackageType createFilterPackageType() {
- return new FilterPackageType();
- }
-
- /**
- * Create an instance of {@link FilterAttributeType }
- *
- */
- public FilterAttributeType createFilterAttributeType() {
- return new FilterAttributeType();
- }
-
- /**
- * Create an instance of {@link RegionType }
- *
- */
- public RegionType createRegionType() {
- return new RegionType();
- }
-
- /**
- * Create an instance of {@link RegionsType }
- *
- */
- public RegionsType createRegionsType() {
- return new RegionsType();
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link RegionsType }{@code >}}
- *
- */
- @XmlElementDecl(namespace = "http://karaf.apache.org/xmlns/region/v1.0.0", name = "regions")
- public JAXBElement<RegionsType> createRegions(RegionsType value) {
- return new JAXBElement<RegionsType>(_Regions_QNAME, RegionsType.class, null, value);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionBundleType.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionBundleType.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionBundleType.java
deleted file mode 100644
index 7ba3585..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionBundleType.java
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for regionBundleType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="regionBundleType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * </sequence>
- * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
- * <attribute name="location" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "regionBundleType")
-public class RegionBundleType {
-
- @XmlAttribute
- protected Long id;
- @XmlAttribute
- protected String location;
-
- /**
- * Gets the value of the id property.
- *
- * @return
- * possible object is
- * {@link Long }
- *
- */
- public Long getId() {
- return id;
- }
-
- /**
- * Sets the value of the id property.
- *
- * @param value
- * allowed object is
- * {@link Long }
- *
- */
- public void setId(Long value) {
- this.id = value;
- }
-
- /**
- * Gets the value of the location property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getLocation() {
- return location;
- }
-
- /**
- * Sets the value of the location property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setLocation(String value) {
- this.location = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionType.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionType.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionType.java
deleted file mode 100644
index f7a810d..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionType.java
+++ /dev/null
@@ -1,106 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- *
- * Regions element
- *
- *
- * <p>Java class for regionType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="regionType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="bundle" type="{http://karaf.apache.org/xmlns/region/v1.0.0}regionBundleType" maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "regionType", propOrder = {
- "bundle"
-})
-public class RegionType {
-
- protected List<RegionBundleType> bundle;
- @XmlAttribute(required = true)
- protected String name;
-
- /**
- * Gets the value of the bundle property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the bundle property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getBundle().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link RegionBundleType }
- *
- *
- */
- public List<RegionBundleType> getBundle() {
- if (bundle == null) {
- bundle = new ArrayList<RegionBundleType>();
- }
- return this.bundle;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setName(String value) {
- this.name = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionsType.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionsType.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionsType.java
deleted file mode 100644
index be172e4..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/RegionsType.java
+++ /dev/null
@@ -1,112 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- *
- * Regions element
- *
- *
- * <p>Java class for regionsType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="regionsType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="region" type="{http://karaf.apache.org/xmlns/region/v1.0.0}regionType" maxOccurs="unbounded" minOccurs="0"/>
- * <element name="filter" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterType" maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlRootElement(name = "regions")
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "regionsType", propOrder = {
- "region",
- "filter"
-})
-public class RegionsType {
-
- protected List<RegionType> region;
- protected List<FilterType> filter;
-
- /**
- * Gets the value of the region property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the region property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getRegion().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link RegionType }
- *
- *
- */
- public List<RegionType> getRegion() {
- if (region == null) {
- region = new ArrayList<RegionType>();
- }
- return this.region;
- }
-
- /**
- * Gets the value of the filter property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the filter property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getFilter().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link FilterType }
- *
- *
- */
- public List<FilterType> getFilter() {
- if (filter == null) {
- filter = new ArrayList<FilterType>();
- }
- return this.filter;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/package-info.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/package-info.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/package-info.java
deleted file mode 100644
index cae062c..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/package-info.java
+++ /dev/null
@@ -1,9 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://karaf.apache.org/xmlns/region/v1.0.0", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
-package org.apache.karaf.region.persist.internal.model;
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java
deleted file mode 100644
index 410121c..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java
+++ /dev/null
@@ -1,661 +0,0 @@
-/*
- * 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.util;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.osgi.framework.Constants;
-
-public class ManifestHeaderProcessor
-{
- public static final String NESTED_FILTER_ATTRIBUTE = "org.apache.aries.application.filter.attribute";
- private static final Pattern FILTER_ATTR = Pattern.compile("(\\(!)?\\((.*?)([<>]?=)(.*?)\\)\\)?");
- private static final String LESS_EQ_OP = "<=";
- private static final String GREATER_EQ_OP = ">=";
-
- /**
- * A simple class to associate two types.
- *
- */
- public static class NameValuePair {
- private String name;
- private Map<String,String> attributes;
-
- public NameValuePair(String name, Map<String,String> value)
- {
- this.name = name;
- this.attributes = value;
- }
- public String getName()
- {
- return name;
- }
- public void setName(String name)
- {
- this.name = name;
- }
-
- public Map<String,String> getAttributes()
- {
- return attributes;
- }
- public void setAttributes(Map<String,String> value)
- {
- this.attributes = value;
- }
-
- @Override
- public String toString(){
- return "{"+name.toString()+"::"+attributes.toString()+"}";
- }
- @Override
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((attributes == null) ? 0 : attributes.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
- final NameValuePair other = (NameValuePair) obj;
- if (name == null) {
- if (other.name != null) return false;
- } else if (!name.equals(other.name)) return false;
- if (attributes == null) {
- if (other.attributes != null) return false;
- } else if (!attributes.equals(other.attributes)) return false;
- return true;
- }
- }
-
- /**
- * Intended to provide a standard way to add Name/Value's to
- * aggregations of Name/Value's.
- *
- */
- public static interface NameValueCollection {
- /**
- * Add this Name & Value to the collection.
- * @param n
- * @param v
- */
- public void addToCollection(String n, Map<String,String> v);
- }
-
- /**
- * Map of Name -> Value.
- *
- */
- public static class NameValueMap extends HashMap<String, Map<String,String>> implements NameValueCollection, Map<String, Map<String,String>>{
- private static final long serialVersionUID = -6446338858542599141L;
-
- public void addToCollection(String n, Map<String,String> v){
- this.put(n,v);
- }
-
- @Override
- public String toString(){
- StringBuilder sb = new StringBuilder();
- sb.append("{");
- boolean first=true;
- for(Map.Entry<String, Map<String,String>> entry : this.entrySet()){
- if(!first)sb.append(",");
- first=false;
- sb.append(entry.getKey()+"->"+entry.getValue());
- }
- sb.append("}");
- return sb.toString();
- }
- }
-
- /**
- * List of Name/Value
- *
- */
- public static class NameValueList extends ArrayList<NameValuePair> implements NameValueCollection, List<NameValuePair> {
- private static final long serialVersionUID = 1808636823825029983L;
-
- public void addToCollection(String n, Map<String,String> v){
- this.add(new NameValuePair(n,v));
- }
- @Override
- public String toString(){
- StringBuffer sb = new StringBuffer();
- sb.append("{");
- boolean first = true;
- for(NameValuePair nvp : this){
- if(!first)sb.append(",");
- first=false;
- sb.append(nvp.toString());
- }
- sb.append("}");
- return sb.toString();
- }
- }
-
- /**
- *
- * Splits a delimiter separated string, tolerating presence of non separator commas
- * within double quoted segments.
- *
- * Eg.
- * com.ibm.ws.eba.helloWorldService;version="[1.0.0, 1.0.0]" &
- * com.ibm.ws.eba.helloWorldService;version="1.0.0"
- * com.ibm.ws.eba.helloWorld;version="2";bundle-version="[2,30)"
- * com.acme.foo;weirdAttr="one;two;three";weirdDir:="1;2;3"
- * @param value the value to be split
- * @param delimiter the delimiter string such as ',' etc.
- * @return List<String> the components of the split String in a list
- */
- public static List<String> split(String value, String delimiter)
- {
- return ManifestHeaderUtils.split(value, delimiter);
- }
-
-
- /**
- * Internal method to parse headers with the format<p>
- * [Name](;[Name])*(;[attribute-name]=[attribute-value])*<br>
- * Eg.<br>
- * rumplestiltskin;thing=value;other=something<br>
- * littleredridinghood
- * bundle1;bundle2;other=things
- * bundle1;bundle2
- *
- * @param s data to parse
- * @return a list of NameValuePair, with the Name being the name component,
- * and the Value being a NameValueMap of key->value mappings.
- */
- private static List<NameValuePair> genericNameWithNameValuePairProcess(String s){
- String name;
- Map<String,String> params = null;
- List<NameValuePair> nameValues = new ArrayList<NameValuePair>();
- List<String> pkgs = new ArrayList<String>();
- int index = s.indexOf(";");
- if(index==-1){
- name = s;
- params = new HashMap<String, String>();
- pkgs.add(name);
- }else{
- name = s.substring(0,index).trim();
- String tail = s.substring(index+1).trim();
-
- pkgs.add(name); // add the first package
- StringBuilder parameters = new StringBuilder();
-
-
- // take into consideration of multiple packages separated by ';'
- // while they share the same attributes or directives
- List<String> tailParts = split(tail, ";");
- boolean firstParameter =false;
-
- for (String part : tailParts) {
- // if it is not a parameter and no parameter appears in front of it, it must a package
- if (!!!(part.contains("="))) {
- // Need to make sure no parameter appears before the package, otherwise ignore this string
- // as this syntax is invalid
- if (!!!(firstParameter))
- pkgs.add(part);
- } else {
- if (!!!(firstParameter))
- firstParameter = true;
-
- parameters.append(part + ";");
- }
- }
-
- if (parameters.length() != 0) {
- //remove the final ';' if there is one
- if (parameters.toString().endsWith(";")) {
-
- parameters = parameters.deleteCharAt(parameters.length() -1);
- }
-
- params = genericNameValueProcess(parameters.toString());
- }
-
- }
- for (String pkg : pkgs) {
- nameValues.add(new NameValuePair(pkg,params));
- }
-
- return nameValues;
-
- }
-
- /**
- * Internal method to parse headers with the format<p>
- * [attribute-name]=[attribute-value](;[attribute-name]=[attribute-value])*<br>
- * Eg.<br>
- * thing=value;other=something<br>
- * <p>
- * Note. Directives (name:=value) are represented in the map with name suffixed by ':'
- *
- * @param s data to parse
- * @return a NameValueMap, with attribute-name -> attribute-value.
- */
- private static Map<String,String> genericNameValueProcess(String s){
- Map<String,String> params = new HashMap<String,String>();
- List<String> parameters = split(s, ";");
- for(String parameter : parameters) {
- List<String> parts = split(parameter,"=");
- // do a check, otherwise we might get NPE
- if (parts.size() ==2) {
- String second = parts.get(1).trim();
- if (second.startsWith("\"") && second.endsWith("\""))
- second = second.substring(1,second.length()-1);
-
- String first = parts.get(0).trim();
-
- // make sure for directives we clear out any space as in "directive :=value"
- if (first.endsWith(":")) {
- first = first.substring(0, first.length()-1).trim()+":";
- }
-
- params.put(first, second);
- }
- }
-
- return params;
- }
-
- /**
- * Processes an import/export style header.. <p>
- * pkg1;attrib=value;attrib=value,pkg2;attrib=value,pkg3;attrib=value
- *
- * @param out The collection to add each package name + attrib map to.
- * @param s The data to parse
- */
- private static void genericImportExportProcess(NameValueCollection out, String s){
- List<String> packages = split(s, ",");
- for(String pkg : packages){
- List<NameValuePair> ps = genericNameWithNameValuePairProcess(pkg);
- for (NameValuePair p : ps) {
- out.addToCollection(p.getName(), p.getAttributes());
- }
- }
- }
-
- /**
- * Parse an export style header.<p>
- * pkg1;attrib=value;attrib=value,pkg2;attrib=value,pkg3;attrib=value2
- * <p>
- * Result is returned as a list, as export does allow duplicate package exports.
- *
- * @param s The data to parse.
- * @return List of NameValuePairs, where each Name in the list is an exported package,
- * with its associated Value being a NameValueMap of any attributes declared.
- */
- public static List<NameValuePair> parseExportString(String s){
- NameValueList retval = new NameValueList();
- genericImportExportProcess(retval, s);
- return retval;
- }
-
- /**
- * Parse an export style header in a list.<p>
- * pkg1;attrib=value;attrib=value
- * pkg2;attrib=value
- * pkg3;attrib=value2
- * <p>
- * Result is returned as a list, as export does allow duplicate package exports.
- *
- * @param list The data to parse.
- * @return List of NameValuePairs, where each Name in the list is an exported package,
- * with its associated Value being a NameValueMap of any attributes declared.
- */
- public static List<NameValuePair> parseExportList(List<String> list){
- NameValueList retval = new NameValueList();
- for(String pkg : list){
- List<NameValuePair> ps = genericNameWithNameValuePairProcess(pkg);
- for (NameValuePair p : ps) {
- retval.addToCollection(p.getName(), p.getAttributes());
- }
- }
- return retval;
- }
-
- /**
- * Parse an import style header.<p>
- * pkg1;attrib=value;attrib=value,pkg2;attrib=value,pkg3;attrib=value
- * <p>
- * Result is returned as a set, as import does not allow duplicate package imports.
- *
- * @param s The data to parse.
- * @return Map of NameValuePairs, where each Key in the Map is an imported package,
- * with its associated Value being a NameValueMap of any attributes declared.
- */
- public static Map<String, Map<String, String>> parseImportString(String s){
- NameValueMap retval = new NameValueMap();
- genericImportExportProcess(retval, s);
- return retval;
- }
-
- /**
- * Parse a bundle symbolic name.<p>
- * bundlesymbolicname;attrib=value;attrib=value
- * <p>
- *
- * @param s The data to parse.
- * @return NameValuePair with Name being the BundleSymbolicName,
- * and Value being any attribs declared for the name.
- */
- public static NameValuePair parseBundleSymbolicName(String s){
- return genericNameWithNameValuePairProcess(s).get(0); // should just return the first one
- }
-
- /**
- * Parse a version range..
- *
- * @param s
- * @return VersionRange object.
- * @throws IllegalArgumentException if the String could not be parsed as a VersionRange
- */
- public static VersionRange parseVersionRange(String s) throws IllegalArgumentException{
- return new VersionRange(s);
- }
-
- /**
- * Parse a version range and indicate if the version is an exact version
- *
- * @param s
- * @param exactVersion
- * @return VersionRange object.
- * @throws IllegalArgumentException if the String could not be parsed as a VersionRange
- */
- public static VersionRange parseVersionRange(String s, boolean exactVersion) throws IllegalArgumentException{
- return new VersionRange(s, exactVersion);
- }
-
- /**
- * Generate a filter from a set of attributes. This filter will be suitable
- * for presentation to OBR This means that, due to the way OBR works, it
- * will include a stanza of the form, (mandatory:<*mandatoryAttribute)
- * Filter strings generated by this method will therefore tend to break the
- * standard OSGi Filter class. The OBR stanza can be stripped out later if
- * required.
- *
- * @param attribs
- * @return filter string
- */
- public static String generateFilter(Map<String, Object> attribs) {
- StringBuilder filter = new StringBuilder("(&");
- boolean realAttrib = false;
- StringBuffer realAttribs = new StringBuffer();
-
- if (attribs == null) {
- attribs = new HashMap<String, Object>();
- }
-
- for (Map.Entry<String, Object> 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().toString());
-
- 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 (NESTED_FILTER_ATTRIBUTE.equals(attribName)) {
- // Filters go in whole, no formatting needed
- realAttrib = true;
- filter.append(attrib.getValue());
-
- } else if (Constants.OBJECTCLASS.equals(attribName)) {
- realAttrib = true;
- // objectClass has a "," separated list of interfaces
- String[] values = attrib.getValue().toString().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(", ");
- }
- }
- }
-// /*
-// * The following is how OBR makes mandatory attributes work, we require
-// * that the set of mandatory attributes on the export is a subset of (or
-// * equal to) the set of the attributes we supply.
-// */
-//
-// if (realAttribs.length() > 0) {
-// String attribStr = (realAttribs.toString()).trim();
-// // remove the final ,
-// if ((attribStr.length() > 0) && (attribStr.endsWith(","))) {
-// attribStr = attribStr.substring(0, attribStr.length() - 1);
-// }
-// // build the mandatory filter, e.g.(mandatory:<*company, local)
-// filter.append("(" + Constants.MANDATORY_DIRECTIVE + ":" + "<*"
-// + attribStr + ")");
-// }
-
- // 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;
- }
-
- /**
- * Generate a filter from a set of attributes. This filter will be suitable
- * for presentation to OBR. This means that, due to the way OBR works, it will
- * include a stanza of the form, (mandatory:<*mandatoryAttribute) Filter
- * strings generated by this method will therefore tend to break the standard
- * OSGi Filter class. The OBR stanza can be stripped out later if required.
- *
- * We may wish to consider relocating this method since VersionRange has its
- * own top level class.
- *
- * @param type
- * @param name
- * @param attribs
- * @return filter string
- */
- public static String generateFilter(String type, String name,
- Map<String, Object> attribs) {
- StringBuffer filter = new StringBuffer();
- String result;
- // shortcut for the simple case with no attribs.
-
- if (attribs == null || attribs.isEmpty())
- filter.append("(" + type + "=" + name + ")");
- else {
- // process all the attribs passed.
- // find out whether there are attributes on the filter
-
- filter.append("(&(" + type + "=" + name + ")");
-
- String filterString = generateFilter(attribs);
-
- int start = 0;
- int end = filterString.length();
- if (filterString.startsWith("(&")) {
- start = 2;
- end--;
- }
-
- if ("".equals(filterString)) {
- filter.delete(0, 2);
- } else {
- filter.append(filterString, start, end);
- filter.append(")");
- }
- }
-
- result = filter.toString();
-
- return result;
- }
-
- private static Map<String, String> parseFilterList(String filter) {
-
- Map<String, String> result = new HashMap<String, String>();
- Set<String> negatedVersions = new HashSet<String>();
- Set<String> negatedBundleVersions = new HashSet<String>();
-
- String lowerVersion = null;
- String upperVersion = null;
- String lowerBundleVersion = null;
- String upperBundleVersion = null;
-
- Matcher m = FILTER_ATTR.matcher(filter);
- while (m.find()) {
- boolean negation = m.group(1) != null;
- String attr = m.group(2);
- String op = m.group(3);
- String value = m.group(4);
-
- if (Constants.VERSION_ATTRIBUTE.equals(attr)) {
- if (negation) {
- negatedVersions.add(value);
- } else {
- if (GREATER_EQ_OP.equals(op))
- lowerVersion = value;
- else if (LESS_EQ_OP.equals(op))
- upperVersion = value;
- else
- throw new IllegalArgumentException();
- }
- } else if (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(attr)) {
- // bundle-version is like version, but may be specified at the
- // same time
- // therefore we have similar code with separate variables
- if (negation) {
- negatedBundleVersions.add(value);
- } else {
- if (GREATER_EQ_OP.equals(op))
- lowerBundleVersion = value;
- else if (LESS_EQ_OP.equals(op))
- upperBundleVersion = value;
- else
- throw new IllegalArgumentException();
- }
- } else {
- result.put(attr, value);
- }
- }
-
- if (lowerVersion != null) {
- StringBuilder versionAttr = new StringBuilder(lowerVersion);
- if (upperVersion != null) {
- versionAttr.append(",").append(upperVersion).insert(0,
- negatedVersions.contains(lowerVersion) ? '(' : '[').append(
- negatedVersions.contains(upperVersion) ? ')' : ']');
- }
-
- result.put(Constants.VERSION_ATTRIBUTE, versionAttr.toString());
- }
- // Do it again for bundle-version
- if (lowerBundleVersion != null) {
- StringBuilder versionAttr = new StringBuilder(lowerBundleVersion);
- if (upperBundleVersion != null) {
- versionAttr.append(",").append(upperBundleVersion).insert(0,
- negatedBundleVersions.contains(lowerBundleVersion) ? '(' : '[')
- .append(
- negatedBundleVersions.contains(upperBundleVersion) ? ')' : ']');
- }
-
- result.put(Constants.BUNDLE_VERSION_ATTRIBUTE, versionAttr.toString());
- }
-
- return result;
- }
-
- public static Map<String,String> parseFilter(String filter)
- {
- Map<String,String> result;
- if (filter.startsWith("(&")) {
- result = parseFilterList(filter.substring(2, filter.length()-1));
- } else {
- result = parseFilterList(filter);
- }
- return result;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java
deleted file mode 100644
index 8c87616..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ManifestHeaderUtils {
-
- /**
- *
- * Splits a delimiter separated string, tolerating presence of non separator commas
- * within double quoted segments.
- *
- * Eg.
- * com.ibm.ws.eba.helloWorldService;version="[1.0.0, 1.0.0]" &
- * com.ibm.ws.eba.helloWorldService;version="1.0.0"
- * com.ibm.ws.eba.helloWorld;version="2";bundle-version="[2,30)"
- * com.acme.foo;weirdAttr="one;two;three";weirdDir:="1;2;3"
- * @param value the value to be split
- * @param delimiter the delimiter string such as ',' etc.
- * @return List<String> the components of the split String in a list
- */
- public static List<String> split(String value, String delimiter)
- {
- List<String> result = new ArrayList<String>();
- if (value != null) {
- String[] packages = value.split(delimiter);
-
- for (int i = 0; i < packages.length; ) {
- String tmp = packages[i++].trim();
- // if there is a odd number of " in a string, we need to append
- while (count(tmp, "\"") % 2 != 0) {
- // check to see if we need to append the next package[i++]
- if (i<packages.length)
- tmp = tmp + delimiter + packages[i++].trim();
- else
- // oops. The double quotes are not paired up. We have reached to the end of the string.
- throw new IllegalArgumentException("Unmatched double quotes: " + tmp);
- }
-
- result.add(tmp);
-
- }
- }
- return result;
- }
-
- /**
- * count the number of characters in a string
- * @param parent The string to be searched
- * @param subString The substring to be found
- * @return the number of occurrence of the subString
- */
- private static int count(String parent, String subString) {
-
- int count = 0 ;
- int i = parent.indexOf(subString);
- while (i > -1) {
- if (parent.length() >= i+1)
- parent = parent.substring(i+1);
- count ++;
- i = parent.indexOf(subString);
- }
- return count;
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java
deleted file mode 100644
index 19bbc77..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java
+++ /dev/null
@@ -1,456 +0,0 @@
-/*
- * 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.util;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.osgi.framework.Version;
-
-public final class VersionRange {
-
- /** A string representation of the version. */
- private String version;
-
- /** The minimum desired version for the bundle */
- private Version minimumVersion;
-
- /** The maximum desired version for the bundle */
- private Version maximumVersion;
-
- /** True if the match is exclusive of the minimum version */
- private boolean minimumExclusive;
-
- /** True if the match is exclusive of the maximum version */
- private boolean maximumExclusive;
-
- /** A regexp to select the version */
- private static final Pattern versionCapture = Pattern.compile("\"?(.*?)\"?$");
-
- /**
- *
- * @param version
- * version for the verioninfo
- */
- public VersionRange(String version) {
- this.version = version;
- processVersionAttribute(version);
- }
-
- /**
- * This method should be used to create a version range from a single
- * version string.
- * @param version
- * version for the versioninfo
- * @param exactVersion
- * whether this is an exact version {@code true} or goes to infinity
- * {@code false}
- */
- public VersionRange(String version, boolean exactVersion) {
-
- if (exactVersion) {
- // Do not store this string as it might be just a version, or a range!
- processExactVersionAttribute(version);
- } else {
- this.version = version;
- processVersionAttribute(this.version);
- }
-
- assertInvariants();
- }
-
- /**
- * Constructor designed for internal use only.
- *
- * @param maximumVersion
- * @param maximumExclusive
- * @param minimumVersion
- * @param minimumExclusive
- * @throws IllegalArgumentException
- * if parameters are not valid.
- */
- private VersionRange(Version maximumVersion,
- boolean maximumExclusive,
- Version minimumVersion,
- boolean minimumExclusive) {
- this.maximumVersion = maximumVersion;
- this.maximumExclusive = maximumExclusive;
- this.minimumVersion = minimumVersion;
- this.minimumExclusive = minimumExclusive;
-
- assertInvariants();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.aries.application.impl.VersionRange#toString()
- */
- @Override
- public String toString() {
- // Some constructors don't take in a string that we can return directly,
- // so construct one if needed
- if (version == null) {
- if (maximumVersion == null) {
- version = minimumVersion.toString();
- } else {
- version = (minimumExclusive ? "(" : "[") + minimumVersion + "," + maximumVersion
- + (maximumExclusive ? ")" : "]");
- }
- }
- return this.version;
- }
-
- @Override
- public int hashCode() {
- int result = 17;
- result = 31 * result + minimumVersion.hashCode();
- result = 31 * result + (minimumExclusive ? 1 : 0);
- result = 31 * result + (maximumVersion != null ? maximumVersion.hashCode() : 0);
- result = 31 * result + (maximumExclusive ? 1 : 0);
- return result;
- }
-
- @Override
- public boolean equals(Object other) {
- boolean result = false;
- if (this == other) {
- result = true;
- } else if (other instanceof VersionRange) {
- VersionRange vr = (VersionRange) other;
- result = minimumVersion.equals(vr.minimumVersion)
- && minimumExclusive == vr.minimumExclusive
- && (maximumVersion == null ? vr.maximumVersion == null : maximumVersion
- .equals(vr.maximumVersion)) && maximumExclusive == vr.maximumExclusive;
- }
-
- return result;
- }
-
- /**
- * this method returns the exact version from the versionInfo obj.
- * this is used for DeploymentContent only to return a valid exact version
- * otherwise, null is returned.
- * @return the exact version
- */
- public Version getExactVersion() {
- Version v = null;
- if (isExactVersion()) {
- v = getMinimumVersion();
- }
- return v;
- }
-
- /**
- * get the maximum version
- * @return the maximum version
- */
- public Version getMaximumVersion() {
- return maximumVersion;
- }
-
- /**
- * get the minimum version
- * @return the minimum version
- */
- public Version getMinimumVersion() {
- return minimumVersion;
- }
-
- /**
- * is the maximum version exclusive
- * @return is the max version in the range.
- */
- public boolean isMaximumExclusive() {
- return maximumExclusive;
- }
-
- /**
- * is the maximum version unbounded
- * @return true if no upper bound was specified.
- */
- public boolean isMaximumUnbounded() {
- boolean unbounded = maximumVersion == null;
- return unbounded;
- }
-
- /**
- * is the minimum version exclusive
- * @return true if the min version is in range.
- */
- public boolean isMinimumExclusive() {
- return minimumExclusive;
- }
-
- /**
- * this is designed for deployed-version as that is the exact version.
- *
- * @param version
- * @return
- * @throws IllegalArgumentException
- */
- private boolean processExactVersionAttribute(String version) throws IllegalArgumentException {
- boolean success = processVersionAttribute(version);
-
- if (maximumVersion == null) {
- maximumVersion = minimumVersion;
- }
-
- if (!minimumVersion.equals(maximumVersion)) {
- throw new IllegalArgumentException("Version is not exact: " + version);
- }
-
- if (!!!isExactVersion()) {
- throw new IllegalArgumentException("Version is not exact: " + version);
- }
-
- return success;
- }
-
- /**
- * process the version attribute,
- *
- * @param version
- * the value to be processed
- * @return
- * @throws IllegalArgumentException
- */
- private boolean processVersionAttribute(String version) throws IllegalArgumentException {
- boolean success = false;
-
- if (version == null) {
- throw new IllegalArgumentException("Version is null");
- }
-
- Matcher matches = versionCapture.matcher(version);
-
- if (matches.matches()) {
- String versions = matches.group(1);
-
- if ((versions.startsWith("[") || versions.startsWith("("))
- && (versions.endsWith("]") || versions.endsWith(")"))) {
- if (versions.startsWith("["))
- minimumExclusive = false;
- else if (versions.startsWith("("))
- minimumExclusive = true;
-
- if (versions.endsWith("]"))
- maximumExclusive = false;
- else if (versions.endsWith(")"))
- maximumExclusive = true;
-
- int index = versions.indexOf(',');
- String minVersion = versions.substring(1, index);
- String maxVersion = versions.substring(index + 1, versions.length() - 1);
-
- try {
- minimumVersion = new Version(minVersion.trim());
- maximumVersion = new Version(maxVersion.trim());
- success = true;
- } catch (NumberFormatException nfe) {
- throw new IllegalArgumentException("Version cannot be decoded: " + version, nfe);
- }
- } else {
- try {
- if (versions.trim().length() == 0)
- minimumVersion = new Version(0, 0, 0);
- else
- minimumVersion = new Version(versions.trim());
- success = true;
- } catch (NumberFormatException nfe) {
- throw new IllegalArgumentException("Version cannot be decoded: " + version, nfe);
- }
- }
- } else {
- throw new IllegalArgumentException("Version cannot be decoded: " + version);
- }
-
- return success;
- }
-
- /**
- * Assert object invariants. Called by constructors to verify that arguments
- * were valid.
- *
- * @throws IllegalArgumentException
- * if invariants are violated.
- */
- private void assertInvariants() {
- if (minimumVersion == null
- || !isRangeValid(minimumVersion, minimumExclusive, maximumVersion, maximumExclusive)) {
- IllegalArgumentException e = new IllegalArgumentException();
- throw e;
- }
- }
-
- /**
- * Check if the supplied parameters describe a valid version range.
- *
- * @param min
- * the minimum version.
- * @param minExclusive
- * whether the minimum version is exclusive.
- * @param max
- * the maximum version.
- * @param maxExclusive
- * whether the maximum version is exclusive.
- * @return true is the range is valid; otherwise false.
- */
- private boolean isRangeValid(Version min,
- boolean minExclusive,
- Version max,
- boolean maxExclusive) {
- boolean result;
-
- // A null maximum version is unbounded so means that minimum is smaller
- // than
- // maximum.
- int minMaxCompare = (max == null ? -1 : min.compareTo(max));
- if (minMaxCompare > 0) {
- // Minimum larger than maximum is invalid.
- result = false;
- } else if (minMaxCompare == 0 && (minExclusive || maxExclusive)) {
- // If min and max are the same, and either are exclusive, no valid
- // range
- // exists.
- result = false;
- } else {
- // Range is valid.
- result = true;
- }
-
- return result;
- }
-
- /**
- * This method checks that the provided version matches the desired version.
- *
- * @param version
- * the version.
- * @return true if the version matches, false otherwise.
- */
- public boolean matches(Version version) {
- boolean result;
- if (this.getMaximumVersion() == null) {
- result = this.getMinimumVersion().compareTo(version) <= 0;
- } else {
- int minN = this.isMinimumExclusive() ? 0 : 1;
- int maxN = this.isMaximumExclusive() ? 0 : 1;
-
- result = (this.getMinimumVersion().compareTo(version) < minN)
- && (version.compareTo(this.getMaximumVersion()) < maxN);
- }
- return result;
- }
-
- /**
- * check if the versioninfo is the exact version
- * @return true if the range will match 1 exact version.
- */
- public boolean isExactVersion() {
- return minimumVersion.equals(maximumVersion) && minimumExclusive == maximumExclusive
- && !!!minimumExclusive;
- }
-
- /**
- * Create a new version range that is the intersection of {@code this} and the argument.
- * In other words, the largest version range that lies within both {@code this} and
- * the parameter.
- * @param r a version range to be intersected with {@code this}.
- * @return a new version range, or {@code null} if no intersection is possible.
- */
- public VersionRange intersect(VersionRange r) {
- // Use the highest minimum version.
- final Version newMinimumVersion;
- final boolean newMinimumExclusive;
- int minCompare = minimumVersion.compareTo(r.getMinimumVersion());
- if (minCompare > 0) {
- newMinimumVersion = minimumVersion;
- newMinimumExclusive = minimumExclusive;
- } else if (minCompare < 0) {
- newMinimumVersion = r.getMinimumVersion();
- newMinimumExclusive = r.isMinimumExclusive();
- } else {
- newMinimumVersion = minimumVersion;
- newMinimumExclusive = (minimumExclusive || r.isMinimumExclusive());
- }
-
- // Use the lowest maximum version.
- final Version newMaximumVersion;
- final boolean newMaximumExclusive;
- // null maximum version means unbounded, so the highest possible value.
- if (maximumVersion == null) {
- newMaximumVersion = r.getMaximumVersion();
- newMaximumExclusive = r.isMaximumExclusive();
- } else if (r.getMaximumVersion() == null) {
- newMaximumVersion = maximumVersion;
- newMaximumExclusive = maximumExclusive;
- } else {
- int maxCompare = maximumVersion.compareTo(r.getMaximumVersion());
- if (maxCompare < 0) {
- newMaximumVersion = maximumVersion;
- newMaximumExclusive = maximumExclusive;
- } else if (maxCompare > 0) {
- newMaximumVersion = r.getMaximumVersion();
- newMaximumExclusive = r.isMaximumExclusive();
- } else {
- newMaximumVersion = maximumVersion;
- newMaximumExclusive = (maximumExclusive || r.isMaximumExclusive());
- }
- }
-
- VersionRange result;
- if (isRangeValid(newMinimumVersion, newMinimumExclusive, newMaximumVersion,
- newMaximumExclusive)) {
- result = new VersionRange(newMaximumVersion, newMaximumExclusive, newMinimumVersion,
- newMinimumExclusive);
- } else {
- result = null;
- }
- return result;
- }
-
- /**
- * Parse a version range..
- *
- * @param s
- * @return VersionRange object.
- * @throws IllegalArgumentException
- * if the String could not be parsed as a VersionRange
- */
- public static VersionRange parseVersionRange(String s) throws IllegalArgumentException {
- return new VersionRange(s);
- }
-
- /**
- * Parse a version range and indicate if the version is an exact version
- *
- * @param s
- * @param exactVersion
- * @return VersionRange object.
- * @throws IllegalArgumentException
- * if the String could not be parsed as a VersionRange
- */
- public static VersionRange parseVersionRange(String s, boolean exactVersion)
- throws IllegalArgumentException {
- return new VersionRange(s, exactVersion);
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/resources/org/apache/karaf/region/persist/region.xsd
----------------------------------------------------------------------
diff --git a/region/persist/src/main/resources/org/apache/karaf/region/persist/region.xsd b/region/persist/src/main/resources/org/apache/karaf/region/persist/region.xsd
deleted file mode 100644
index 8ca26e7..0000000
--- a/region/persist/src/main/resources/org/apache/karaf/region/persist/region.xsd
+++ /dev/null
@@ -1,109 +0,0 @@
-<?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.
--->
-
-<!-- $Rev$ $Date$ -->
-
-<xsd:schema xmlns="http://karaf.apache.org/xmlns/region/v1.0.0"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://karaf.apache.org/xmlns/region/v1.0.0"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified">
-
-
- <xsd:annotation>
- <xsd:documentation>
- Defines the configuration elements for Apache Karaf region xml configuration.
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:element name="regions" type="regionsType"/>
-
-
- <xsd:complexType name="regionsType">
- <xsd:annotation>
- <xsd:documentation>
- Regions element
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="region" type="regionType" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="filter" type="filterType" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="regionType">
- <xsd:annotation>
- <xsd:documentation>
- Region element
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="bundle" type="regionBundleType" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-
- <xsd:complexType name="regionBundleType">
- <xsd:sequence/>
- <xsd:attribute name="id" type="xsd:long"/>
- <xsd:attribute name="location" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="filterBundleType">
- <xsd:sequence>
- <xsd:element name="attribute" type="filterAttributeType" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="id" type="xsd:long"/>
- <xsd:attribute name="symbolic-name" type="xsd:string"/>
- <xsd:attribute name="version" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="filterType">
- <xsd:sequence>
- <xsd:element name="bundle" type="filterBundleType" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="package" type="filterPackageType" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="namespace" type="filterNamespaceType" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="from" type="xsd:string" use="required"/>
- <xsd:attribute name="to" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="filterPackageType">
- <xsd:sequence>
- <xsd:element name="attribute" type="filterAttributeType" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="version" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="filterAttributeType">
- <xsd:sequence/>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <xsd:complexType name="filterNamespaceType">
- <xsd:sequence>
- <xsd:element name="attribute" type="filterAttributeType" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-</xsd:schema>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/pom.xml
----------------------------------------------------------------------
diff --git a/region/pom.xml b/region/pom.xml
index 557e224..293c908 100644
--- a/region/pom.xml
+++ b/region/pom.xml
@@ -35,7 +35,6 @@
<modules>
<module>core</module>
<module>command</module>
- <module>persist</module>
</modules>
<profiles>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java
----------------------------------------------------------------------
diff --git a/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java b/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java
index 85c6caa..eca364f 100644
--- a/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java
+++ b/util/src/main/java/org/apache/karaf/util/tracker/SingleServiceTracker.java
@@ -66,6 +66,12 @@ public final class SingleServiceTracker<T> {
}
};
+ public SingleServiceTracker(BundleContext context, String className, SingleServiceListener sl) {
+ ctx = context;
+ this.className = className;
+ serviceListener = sl;
+ }
+
public SingleServiceTracker(BundleContext context, Class<T> clazz, SingleServiceListener sl) {
ctx = context;
this.className = clazz.getName();
[3/4] git commit: [KARAF-2859] Decouple features/core from
persistent/core
Posted by gn...@apache.org.
[KARAF-2859] Decouple features/core from persistent/core
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8bba2546
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8bba2546
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8bba2546
Branch: refs/heads/master
Commit: 8bba25467d56f96e5175863b386425c36b0ecfbe
Parents: 5f5239a
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Fri Mar 28 16:58:44 2014 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Fri Mar 28 16:58:44 2014 +0100
----------------------------------------------------------------------
assemblies/features/framework/pom.xml | 2 +
.../framework/src/main/feature/feature.xml | 1 -
.../standard/src/main/feature/feature.xml | 2 +-
features/core/pom.xml | 1 +
.../karaf/features/internal/BundleManager.java | 26 +-
.../internal/PersistentBundleManager.java | 59 ++
.../karaf/features/internal/osgi/Activator.java | 25 +-
.../internal/FeaturesServiceImplTest.java | 2 +-
region/core/pom.xml | 121 +++-
.../region/persist/internal/Activator.java | 89 +++
.../persist/internal/RegionsBundleTracker.java | 77 +++
.../internal/RegionsPersistenceImpl.java | 202 ++++++
.../internal/model/FilterAttributeType.java | 94 +++
.../internal/model/FilterBundleType.java | 156 +++++
.../internal/model/FilterNamespaceType.java | 102 +++
.../internal/model/FilterPackageType.java | 129 ++++
.../persist/internal/model/FilterType.java | 195 ++++++
.../persist/internal/model/ObjectFactory.java | 116 ++++
.../internal/model/RegionBundleType.java | 94 +++
.../persist/internal/model/RegionType.java | 106 +++
.../persist/internal/model/RegionsType.java | 112 ++++
.../persist/internal/model/package-info.java | 9 +
.../internal/util/ManifestHeaderProcessor.java | 661 +++++++++++++++++++
.../internal/util/ManifestHeaderUtils.java | 85 +++
.../persist/internal/util/VersionRange.java | 456 +++++++++++++
.../org/apache/karaf/region/persist/region.xsd | 109 +++
region/persist/NOTICE | 71 --
region/persist/pom.xml | 129 ----
.../region/persist/internal/Activator.java | 89 ---
.../persist/internal/RegionsBundleTracker.java | 77 ---
.../internal/RegionsPersistenceImpl.java | 202 ------
.../internal/model/FilterAttributeType.java | 94 ---
.../internal/model/FilterBundleType.java | 156 -----
.../internal/model/FilterNamespaceType.java | 102 ---
.../internal/model/FilterPackageType.java | 129 ----
.../persist/internal/model/FilterType.java | 195 ------
.../persist/internal/model/ObjectFactory.java | 116 ----
.../internal/model/RegionBundleType.java | 94 ---
.../persist/internal/model/RegionType.java | 106 ---
.../persist/internal/model/RegionsType.java | 112 ----
.../persist/internal/model/package-info.java | 9 -
.../internal/util/ManifestHeaderProcessor.java | 661 -------------------
.../internal/util/ManifestHeaderUtils.java | 85 ---
.../persist/internal/util/VersionRange.java | 456 -------------
.../org/apache/karaf/region/persist/region.xsd | 109 ---
region/pom.xml | 1 -
.../util/tracker/SingleServiceTracker.java | 6 +
47 files changed, 2971 insertions(+), 3059 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/assemblies/features/framework/pom.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/framework/pom.xml b/assemblies/features/framework/pom.xml
index 1b28a0d..4675b0a 100644
--- a/assemblies/features/framework/pom.xml
+++ b/assemblies/features/framework/pom.xml
@@ -361,6 +361,8 @@
<excludedArtifactId>sshd-core</excludedArtifactId>
<excludedArtifactId>jline</excludedArtifactId>
<excludedArtifactId>core</excludedArtifactId>
+ <excludedArtifactId>org.apache.karaf.region.core</excludedArtifactId>
+ <excludedArtifactId>region</excludedArtifactId>
</excludedArtifactIds>
</configuration>
</execution>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/assemblies/features/framework/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/framework/src/main/feature/feature.xml b/assemblies/features/framework/src/main/feature/feature.xml
index 70315fb..51b97e5 100644
--- a/assemblies/features/framework/src/main/feature/feature.xml
+++ b/assemblies/features/framework/src/main/feature/feature.xml
@@ -33,7 +33,6 @@
<!-- file install -->
<bundle start="true" start-level="11">mvn:org.apache.felix/org.apache.felix.fileinstall/${felix.fileinstall.version}</bundle>
<!-- features service -->
- <bundle start="true" start-level="15">mvn:org.apache.karaf.region/org.apache.karaf.region.core/${project.version}</bundle>
<bundle start="true" start-level="15">mvn:org.apache.karaf.features/org.apache.karaf.features.core/${project.version}</bundle>
</feature>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/assemblies/features/standard/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/standard/src/main/feature/feature.xml b/assemblies/features/standard/src/main/feature/feature.xml
index 932fa72..6371ce3 100644
--- a/assemblies/features/standard/src/main/feature/feature.xml
+++ b/assemblies/features/standard/src/main/feature/feature.xml
@@ -151,7 +151,7 @@
<feature name="region" description="Provide Region Support" version="${project.version}">
<bundle start-level="30">mvn:org.eclipse.equinox/region/${equinox.region.version}</bundle>
- <bundle start-level="30">mvn:org.apache.karaf.region/org.apache.karaf.region.persist/${project.version}</bundle>
+ <bundle start-level="30">mvn:org.apache.karaf.region/org.apache.karaf.region.core/${project.version}</bundle>
<bundle start-level="30">mvn:org.apache.karaf.region/org.apache.karaf.region.command/${project.version}</bundle>
</feature>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/features/core/pom.xml
----------------------------------------------------------------------
diff --git a/features/core/pom.xml b/features/core/pom.xml
index e5f36db..b7efe10 100644
--- a/features/core/pom.xml
+++ b/features/core/pom.xml
@@ -113,6 +113,7 @@
-noimport:=true
</Export-Package>
<Import-Package>
+ org.apache.karaf.region.persist;resolution:=optional,
*
</Import-Package>
<Private-Package>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java b/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java
index 04a5f5b..647fbb9 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/BundleManager.java
@@ -65,30 +65,18 @@ public class BundleManager {
private static final Logger LOGGER = LoggerFactory.getLogger(BundleManager.class);
private final BundleContext bundleContext;
- private final RegionsPersistence regionsPersistence;
private final long refreshTimeout;
public BundleManager(BundleContext bundleContext) {
- this(bundleContext, null);
+ this(bundleContext, 5000);
}
- public BundleManager(BundleContext bundleContext, RegionsPersistence regionsPersistence) {
- this(bundleContext, regionsPersistence, 5000);
- }
-
- public BundleManager(BundleContext bundleContext, RegionsPersistence regionsPersistence, long refreshTimeout) {
+ public BundleManager(BundleContext bundleContext, long refreshTimeout) {
this.bundleContext = bundleContext;
- this.regionsPersistence = regionsPersistence;
this.refreshTimeout = refreshTimeout;
}
public BundleInstallerResult installBundleIfNeeded(String bundleLocation, int startLevel, String regionName) throws IOException, BundleException {
- BundleInstallerResult result = doInstallBundleIfNeeded(bundleLocation, startLevel);
- installToRegion(regionName, result.bundle, result.isNew);
- return result;
- }
-
- private BundleInstallerResult doInstallBundleIfNeeded(String bundleLocation, int startLevel) throws IOException, BundleException {
InputStream is = getInputStreamForBundle(bundleLocation);
try {
is.mark(256 * 1024);
@@ -178,16 +166,6 @@ public class BundleManager {
return is;
}
- private void installToRegion(String region, Bundle b, boolean isNew) throws BundleException {
- if (region != null && isNew) {
- if (regionsPersistence != null) {
- regionsPersistence.install(b, region);
- } else {
- throw new RuntimeException("Unable to find RegionsPersistence service, while installing " + region);
- }
- }
- }
-
/**
* Will wait for the {@link URLStreamHandlerService} service for the
* specified protocol to be registered.
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/features/core/src/main/java/org/apache/karaf/features/internal/PersistentBundleManager.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/PersistentBundleManager.java b/features/core/src/main/java/org/apache/karaf/features/internal/PersistentBundleManager.java
new file mode 100644
index 0000000..30ff446
--- /dev/null
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/PersistentBundleManager.java
@@ -0,0 +1,59 @@
+/*
+ * 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.features.internal;
+
+import java.io.IOException;
+
+import org.apache.karaf.region.persist.RegionsPersistence;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+
+public class PersistentBundleManager extends BundleManager {
+
+ private final RegionsPersistence regionsPersistence;
+
+ public PersistentBundleManager(BundleContext bundleContext, RegionsPersistence regionsPersistence) {
+ super(bundleContext);
+ this.regionsPersistence = regionsPersistence;
+ }
+
+ public PersistentBundleManager(BundleContext bundleContext, long refreshTimeout, RegionsPersistence regionsPersistence) {
+ super(bundleContext, refreshTimeout);
+ this.regionsPersistence = regionsPersistence;
+ }
+
+ @Override
+ public BundleInstallerResult installBundleIfNeeded(String bundleLocation, int startLevel, String regionName) throws IOException, BundleException {
+ BundleInstallerResult result = super.installBundleIfNeeded(bundleLocation, startLevel, regionName);
+ installToRegion(regionName, result.bundle, result.isNew);
+ return result;
+ }
+
+ private void installToRegion(String region, Bundle bundle, boolean isNew) throws BundleException {
+ if (region != null && isNew) {
+ if (regionsPersistence != null) {
+ regionsPersistence.install(bundle, region);
+ } else {
+ throw new RuntimeException("Unable to find RegionsPersistence service, while installing " + region);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
index c6abdb4..36e83ba 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
import java.util.Properties;
+import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -36,8 +37,10 @@ import org.apache.karaf.features.internal.BundleManager;
import org.apache.karaf.features.internal.FeatureConfigInstaller;
import org.apache.karaf.features.internal.FeatureFinder;
import org.apache.karaf.features.internal.FeaturesServiceImpl;
+import org.apache.karaf.features.internal.PersistentBundleManager;
import org.apache.karaf.features.management.internal.FeaturesServiceMBeanImpl;
import org.apache.karaf.region.persist.RegionsPersistence;
+import org.apache.karaf.util.locks.FileLockUtils;
import org.apache.karaf.util.tracker.SingleServiceTracker;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -58,7 +61,7 @@ public class Activator implements BundleActivator, SingleServiceTracker.SingleSe
private ExecutorService executor = Executors.newSingleThreadExecutor();
private BundleContext bundleContext;
- private SingleServiceTracker<RegionsPersistence> regionsPersistenceTracker;
+ private SingleServiceTracker regionsPersistenceTracker;
private SingleServiceTracker<URLStreamHandlerService> mvnUrlHandlerTracker;
private SingleServiceTracker<ConfigurationAdmin> configurationAdminTracker;
private ServiceTracker<FeaturesListener, FeaturesListener> featuresListenerTracker;
@@ -71,8 +74,8 @@ public class Activator implements BundleActivator, SingleServiceTracker.SingleSe
@Override
public void start(BundleContext context) throws Exception {
bundleContext = context;
- regionsPersistenceTracker = new SingleServiceTracker<RegionsPersistence>(
- bundleContext, RegionsPersistence.class, this
+ regionsPersistenceTracker = new SingleServiceTracker(
+ bundleContext, "org.apache.karaf.region.persist.RegionsPersistence", this
);
mvnUrlHandlerTracker = new SingleServiceTracker<URLStreamHandlerService>(
bundleContext, URLStreamHandlerService.class, "(url.handler.protocol=mvn)", this
@@ -96,7 +99,7 @@ public class Activator implements BundleActivator, SingleServiceTracker.SingleSe
protected void doStart() {
ConfigurationAdmin configurationAdmin = configurationAdminTracker.getService();
- RegionsPersistence regionsPersistence = regionsPersistenceTracker.getService();
+ Object regionsPersistence = regionsPersistenceTracker.getService();
URLStreamHandlerService mvnUrlHandler = mvnUrlHandlerTracker.getService();
if (configurationAdmin == null || mvnUrlHandler == null) {
@@ -118,7 +121,19 @@ public class Activator implements BundleActivator, SingleServiceTracker.SingleSe
props.put(Constants.SERVICE_PID, "org.apache.karaf.features.repos");
featureFinderRegistration = bundleContext.registerService(ManagedService.class, featureFinder, props);
- BundleManager bundleManager = new BundleManager(bundleContext, regionsPersistence);
+ BundleManager bundleManager;
+ if (regionsPersistence != null) {
+ final Object rg = regionsPersistence;
+ // Use an inner class to isolate from the region persistence package
+ bundleManager = new Callable<BundleManager>() {
+ @Override
+ public BundleManager call() {
+ return new PersistentBundleManager(bundleContext, (RegionsPersistence) rg);
+ }
+ }.call();
+ } else {
+ bundleManager = new BundleManager(bundleContext);
+ }
FeatureConfigInstaller configInstaller = new FeatureConfigInstaller(configurationAdmin);
String featuresRepositories = getString(configuration, "featuresRepositories", "");
boolean respectStartLvlDuringFeatureStartup = getBoolean(configuration, "respectStartLvlDuringFeatureStartup", true);
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/features/core/src/test/java/org/apache/karaf/features/internal/FeaturesServiceImplTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/FeaturesServiceImplTest.java b/features/core/src/test/java/org/apache/karaf/features/internal/FeaturesServiceImplTest.java
index 120588b..4776bf4 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/FeaturesServiceImplTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/FeaturesServiceImplTest.java
@@ -165,7 +165,7 @@ public class FeaturesServiceImplTest extends TestBase {
@Test
public void testGetOptionalImportsOnly() {
- BundleManager bundleManager = new BundleManager(null, null, 0l);
+ BundleManager bundleManager = new BundleManager(null, 0l);
List<Clause> result = bundleManager.getOptionalImports("org.apache.karaf,org.apache.karaf.optional;resolution:=optional");
assertEquals("One optional import expected", 1, result.size());
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/pom.xml
----------------------------------------------------------------------
diff --git a/region/core/pom.xml b/region/core/pom.xml
index 8882747..8e9fe95 100644
--- a/region/core/pom.xml
+++ b/region/core/pom.xml
@@ -1,24 +1,25 @@
<?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.
- -->
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.karaf.region</groupId>
@@ -28,10 +29,57 @@
<artifactId>org.apache.karaf.region.core</artifactId>
<packaging>bundle</packaging>
- <name>Apache Karaf :: Region :: Core</name>
- <description>This bundle provides an API for interacting with Regions.</description>
+ <name>Apache Karaf :: Region :: Persistence</name>
+ <description>This bundle provides an xml regions model and install/dump actions.</description>
- <build>
+ <properties>
+ <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.util</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.equinox</groupId>
+ <artifactId>region</artifactId>
+ <version>1.0.0.v20110506</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
@@ -39,6 +87,13 @@
<include>**/*</include>
</includes>
</resource>
+ <resource>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.info</include>
+ </includes>
+ </resource>
</resources>
<plugins>
<plugin>
@@ -46,22 +101,20 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>
- *
- </Import-Package>
- <Export-Package>org.apache.karaf.region.persist;version="${project.version}"</Export-Package>
+ <Bundle-Activator>
+ org.apache.karaf.region.persist.internal.Activator
+ </Bundle-Activator>
+ <Export-Package>
+ org.apache.karaf.region.persist;version="${project.version}"
+ </Export-Package>
+ <Private-Package>
+ org.apache.karaf.region.persist.internal.*,
+ org.apache.karaf.util.tracker
+ </Private-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
+</project>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/Activator.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
new file mode 100644
index 0000000..4705818
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
@@ -0,0 +1,89 @@
+/*
+ * 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.util.tracker.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;
+
+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);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java
new file mode 100644
index 0000000..890fb58
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java
@@ -0,0 +1,77 @@
+/*
+ * 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 org.apache.karaf.region.persist.RegionsPersistence;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RegionsBundleTracker {
+ private static final Logger log = LoggerFactory.getLogger(RegionsBundleTracker.class);
+
+ private BundleTracker bundleTracker;
+ private RegionsPersistence regionsPersistence;
+
+ void start(BundleContext bundleContext, RegionsPersistence regionsPersistence) {
+ this.regionsPersistence = regionsPersistence;
+ int stateMask = Bundle.INSTALLED;
+ bundleTracker = new BundleTracker(bundleContext, stateMask, new BundleTrackerCustomizer() {
+ @Override
+ public Object addingBundle(Bundle bundle, BundleEvent bundleEvent) {
+ return RegionsBundleTracker.this.addingBundle(bundle);
+ }
+
+ @Override
+ public void modifiedBundle(Bundle bundle, BundleEvent bundleEvent, Object o) {
+ }
+
+ @Override
+ public void removedBundle(Bundle bundle, BundleEvent bundleEvent, Object o) {
+ }
+ });
+ bundleTracker.open();
+ }
+
+ private Object addingBundle(Bundle bundle) {
+ String region = bundle.getHeaders().get("Region");
+ if (region != null) {
+ try {
+ regionsPersistence.install(bundle, region);
+ log.debug("Installed bundle " + bundle + " in region " + region);
+ return bundle;
+ } catch (BundleException e) {
+ log.info("Could not install bundle " + bundle + " in region " + region, e);
+ }
+ }
+ return null;
+ }
+
+ void stop() {
+ bundleTracker.close();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java
new file mode 100644
index 0000000..9cfda9f
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java
@@ -0,0 +1,202 @@
+/*
+ * 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.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import org.apache.karaf.region.persist.RegionsPersistence;
+import org.apache.karaf.region.persist.internal.model.FilterAttributeType;
+import org.apache.karaf.region.persist.internal.model.FilterBundleType;
+import org.apache.karaf.region.persist.internal.model.FilterNamespaceType;
+import org.apache.karaf.region.persist.internal.model.FilterPackageType;
+import org.apache.karaf.region.persist.internal.model.FilterType;
+import org.apache.karaf.region.persist.internal.model.RegionBundleType;
+import org.apache.karaf.region.persist.internal.model.RegionType;
+import org.apache.karaf.region.persist.internal.model.RegionsType;
+import org.apache.karaf.region.persist.internal.util.ManifestHeaderProcessor;
+import org.eclipse.equinox.region.Region;
+import org.eclipse.equinox.region.RegionDigraph;
+import org.eclipse.equinox.region.RegionFilterBuilder;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRevision;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class RegionsPersistenceImpl implements RegionsPersistence {
+
+ private static final Logger log = LoggerFactory.getLogger(RegionsPersistenceImpl.class);
+
+ private JAXBContext jaxbContext;
+ private RegionDigraph regionDigraph;
+ private Region kernel;
+ private Bundle framework;
+
+ public RegionsPersistenceImpl(RegionDigraph regionDigraph, Bundle framework) throws JAXBException, BundleException, IOException, InvalidSyntaxException {
+ log.info("Loading region digraph persistence");
+ this.framework = framework;
+ this.regionDigraph = regionDigraph;
+ kernel = regionDigraph.getRegion(0);
+ jaxbContext = JAXBContext.newInstance(RegionsType.class);
+ load();
+ }
+
+ @Override
+ public void install(Bundle b, String regionName) throws BundleException {
+ Region region = regionDigraph.getRegion(regionName);
+ if (region == null) {
+ region = regionDigraph.createRegion(regionName);
+ }
+ kernel.removeBundle(b);
+ region.addBundle(b);
+ }
+
+ void save(RegionsType regionsType, Writer out) throws JAXBException {
+ Marshaller marshaller = jaxbContext.createMarshaller();
+ marshaller.marshal(regionsType, out);
+ }
+
+ void load() throws IOException, BundleException, JAXBException, InvalidSyntaxException {
+ if (this.regionDigraph.getRegions().size() <= 1) {
+ File etc = new File(System.getProperty("karaf.etc"));
+ File regionsConfig = new File(etc, "regions-config.xml");
+ if (regionsConfig.exists()) {
+ log.info("initializing region digraph from etc/regions-config.xml");
+ Reader in = new FileReader(regionsConfig);
+ try {
+ load(this.regionDigraph, in);
+ } finally {
+ in.close();
+ }
+ } else {
+ log.info("no regions config file");
+ }
+ }
+
+ }
+
+ void load(RegionDigraph regionDigraph, Reader in) throws JAXBException, BundleException, InvalidSyntaxException {
+ RegionsType regionsType = load(in);
+ load(regionsType, regionDigraph);
+ }
+
+ RegionsType load(Reader in) throws JAXBException {
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ return (RegionsType) unmarshaller.unmarshal(in);
+ }
+
+ void load(RegionsType regionsType, RegionDigraph regionDigraph) throws BundleException, InvalidSyntaxException {
+ BundleContext frameworkContext = framework.getBundleContext();
+ for (RegionType regionType: regionsType.getRegion()) {
+ String name = regionType.getName();
+ log.debug("Creating region: " + name);
+ Region region = regionDigraph.createRegion(name);
+ for (RegionBundleType bundleType: regionType.getBundle()) {
+ if (bundleType.getId() != null) {
+ region.addBundle(bundleType.getId());
+ } else {
+ Bundle b = frameworkContext.getBundle(bundleType.getLocation());
+ region.addBundle(b);
+ }
+ }
+ }
+ for (FilterType filterType: regionsType.getFilter()) {
+ Region from = regionDigraph.getRegion(filterType.getFrom());
+ Region to = regionDigraph.getRegion(filterType.getTo());
+ log.debug("Creating filter between " + from.getName() + " to " + to.getName());
+ RegionFilterBuilder builder = regionDigraph.createRegionFilterBuilder();
+ for (FilterBundleType bundleType: filterType.getBundle()) {
+ String symbolicName = bundleType.getSymbolicName();
+ String version = bundleType.getVersion();
+ if (bundleType.getId() != null) {
+ Bundle b = frameworkContext.getBundle(bundleType.getId());
+ symbolicName = b.getSymbolicName();
+ version = b.getVersion().toString();
+ }
+ String namespace = BundleRevision.BUNDLE_NAMESPACE;
+ List<FilterAttributeType> attributeTypes = bundleType.getAttribute();
+ buildFilter(symbolicName, version, namespace, attributeTypes, builder);
+ }
+ for (FilterPackageType packageType: filterType.getPackage()) {
+ String packageName = packageType.getName();
+ String version = packageType.getVersion();
+ String namespace = BundleRevision.PACKAGE_NAMESPACE;
+ List<FilterAttributeType> attributeTypes = packageType.getAttribute();
+ buildFilter(packageName, version, namespace, attributeTypes, builder);
+ }
+ if (to == kernel) {
+ //add framework exports
+ BundleRevision rev = framework.adapt(BundleRevision.class);
+ List<BundleCapability> caps = rev.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
+ for (BundleCapability cap : caps) {
+ String filter = ManifestHeaderProcessor.generateFilter(filter(cap.getAttributes()));
+ builder.allow(BundleRevision.PACKAGE_NAMESPACE, filter);
+ }
+ }
+ //TODO explicit services?
+ for (FilterNamespaceType namespaceType: filterType.getNamespace()) {
+ String namespace = namespaceType.getName();
+ HashMap<String, Object> attributes = new HashMap<String, Object>();
+ for (FilterAttributeType attributeType: namespaceType.getAttribute()) {
+ attributes.put(attributeType.getName(), attributeType.getValue());
+ }
+ String filter = ManifestHeaderProcessor.generateFilter(attributes);
+ builder.allow(namespace, filter);
+ }
+ regionDigraph.connect(from, builder.build(), to);
+ }
+ }
+
+ private Map<String, Object> filter(Map<String, Object> attributes) {
+ Map<String, Object> result = new HashMap<String, Object>(attributes);
+ result.remove("bundle-version");
+ result.remove("bundle-symbolic-name");
+ return result;
+ }
+
+ private void buildFilter(String packageName, String version, String namespace, List<FilterAttributeType> attributeTypes, RegionFilterBuilder builder) throws InvalidSyntaxException {
+ HashMap<String, Object> attributes = new HashMap<String, Object>();
+ if (namespace != null) {
+ attributes.put(namespace, packageName);
+ }
+ if (version != null) {
+ attributes.put("version", version);
+ }
+ for (FilterAttributeType attributeType: attributeTypes) {
+ attributes.put(attributeType.getName(), attributeType.getValue());
+ }
+ String filter = ManifestHeaderProcessor.generateFilter(attributes);
+ builder.allow(namespace, filter);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterAttributeType.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterAttributeType.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterAttributeType.java
new file mode 100644
index 0000000..857c2b3
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterAttributeType.java
@@ -0,0 +1,94 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for filterAttributeType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="filterAttributeType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "filterAttributeType")
+public class FilterAttributeType {
+
+ @XmlAttribute(required = true)
+ protected String name;
+ @XmlAttribute(required = true)
+ protected String value;
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterBundleType.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterBundleType.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterBundleType.java
new file mode 100644
index 0000000..a9a9fbb
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterBundleType.java
@@ -0,0 +1,156 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for filterBundleType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="filterBundleType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="attribute" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterAttributeType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * <attribute name="symbolic-name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "filterBundleType", propOrder = {
+ "attribute"
+})
+public class FilterBundleType {
+
+ protected List<FilterAttributeType> attribute;
+ @XmlAttribute
+ protected Long id;
+ @XmlAttribute(name = "symbolic-name")
+ protected String symbolicName;
+ @XmlAttribute
+ protected String version;
+
+ /**
+ * Gets the value of the attribute property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the attribute property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAttribute().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link FilterAttributeType }
+ *
+ *
+ */
+ public List<FilterAttributeType> getAttribute() {
+ if (attribute == null) {
+ attribute = new ArrayList<FilterAttributeType>();
+ }
+ return this.attribute;
+ }
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link Long }
+ *
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Long }
+ *
+ */
+ public void setId(Long value) {
+ this.id = value;
+ }
+
+ /**
+ * Gets the value of the symbolicName property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getSymbolicName() {
+ return symbolicName;
+ }
+
+ /**
+ * Sets the value of the symbolicName property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setSymbolicName(String value) {
+ this.symbolicName = value;
+ }
+
+ /**
+ * Gets the value of the version property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets the value of the version property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVersion(String value) {
+ this.version = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterNamespaceType.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterNamespaceType.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterNamespaceType.java
new file mode 100644
index 0000000..52b937a
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterNamespaceType.java
@@ -0,0 +1,102 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for filterNamespaceType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="filterNamespaceType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="attribute" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterAttributeType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "filterNamespaceType", propOrder = {
+ "attribute"
+})
+public class FilterNamespaceType {
+
+ protected List<FilterAttributeType> attribute;
+ @XmlAttribute(required = true)
+ protected String name;
+
+ /**
+ * Gets the value of the attribute property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the attribute property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAttribute().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link FilterAttributeType }
+ *
+ *
+ */
+ public List<FilterAttributeType> getAttribute() {
+ if (attribute == null) {
+ attribute = new ArrayList<FilterAttributeType>();
+ }
+ return this.attribute;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterPackageType.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterPackageType.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterPackageType.java
new file mode 100644
index 0000000..b4216ee
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterPackageType.java
@@ -0,0 +1,129 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for filterPackageType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="filterPackageType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="attribute" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterAttributeType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "filterPackageType", propOrder = {
+ "attribute"
+})
+public class FilterPackageType {
+
+ protected List<FilterAttributeType> attribute;
+ @XmlAttribute
+ protected String name;
+ @XmlAttribute
+ protected String version;
+
+ /**
+ * Gets the value of the attribute property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the attribute property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getAttribute().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link FilterAttributeType }
+ *
+ *
+ */
+ public List<FilterAttributeType> getAttribute() {
+ if (attribute == null) {
+ attribute = new ArrayList<FilterAttributeType>();
+ }
+ return this.attribute;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+ /**
+ * Gets the value of the version property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets the value of the version property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setVersion(String value) {
+ this.version = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterType.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterType.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterType.java
new file mode 100644
index 0000000..f4d1352
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/FilterType.java
@@ -0,0 +1,195 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for filterType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="filterType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="bundle" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterBundleType" maxOccurs="unbounded" minOccurs="0"/>
+ * <element name="package" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterPackageType" maxOccurs="unbounded" minOccurs="0"/>
+ * <element name="namespace" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterNamespaceType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="from" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * <attribute name="to" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "filterType", propOrder = {
+ "bundle",
+ "_package",
+ "namespace"
+})
+public class FilterType {
+
+ protected List<FilterBundleType> bundle;
+ @XmlElement(name = "package")
+ protected List<FilterPackageType> _package;
+ protected List<FilterNamespaceType> namespace;
+ @XmlAttribute(required = true)
+ protected String from;
+ @XmlAttribute(required = true)
+ protected String to;
+
+ /**
+ * Gets the value of the bundle property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the bundle property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getBundle().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link FilterBundleType }
+ *
+ *
+ */
+ public List<FilterBundleType> getBundle() {
+ if (bundle == null) {
+ bundle = new ArrayList<FilterBundleType>();
+ }
+ return this.bundle;
+ }
+
+ /**
+ * Gets the value of the package property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the package property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getPackage().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link FilterPackageType }
+ *
+ *
+ */
+ public List<FilterPackageType> getPackage() {
+ if (_package == null) {
+ _package = new ArrayList<FilterPackageType>();
+ }
+ return this._package;
+ }
+
+ /**
+ * Gets the value of the namespace property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the namespace property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getNamespace().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link FilterNamespaceType }
+ *
+ *
+ */
+ public List<FilterNamespaceType> getNamespace() {
+ if (namespace == null) {
+ namespace = new ArrayList<FilterNamespaceType>();
+ }
+ return this.namespace;
+ }
+
+ /**
+ * Gets the value of the from property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getFrom() {
+ return from;
+ }
+
+ /**
+ * Sets the value of the from property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setFrom(String value) {
+ this.from = value;
+ }
+
+ /**
+ * Gets the value of the to property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getTo() {
+ return to;
+ }
+
+ /**
+ * Sets the value of the to property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setTo(String value) {
+ this.to = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/ObjectFactory.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/ObjectFactory.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/ObjectFactory.java
new file mode 100644
index 0000000..54f5f3c
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/ObjectFactory.java
@@ -0,0 +1,116 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.apache.karaf.region.persist.internal.model package.
+ * <p>An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ *
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _Regions_QNAME = new QName("http://karaf.apache.org/xmlns/region/v1.0.0", "regions");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.apache.karaf.region.persist.internal.model
+ *
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link FilterNamespaceType }
+ *
+ */
+ public FilterNamespaceType createFilterNamespaceType() {
+ return new FilterNamespaceType();
+ }
+
+ /**
+ * Create an instance of {@link FilterType }
+ *
+ */
+ public FilterType createFilterType() {
+ return new FilterType();
+ }
+
+ /**
+ * Create an instance of {@link RegionBundleType }
+ *
+ */
+ public RegionBundleType createRegionBundleType() {
+ return new RegionBundleType();
+ }
+
+ /**
+ * Create an instance of {@link FilterBundleType }
+ *
+ */
+ public FilterBundleType createFilterBundleType() {
+ return new FilterBundleType();
+ }
+
+ /**
+ * Create an instance of {@link FilterPackageType }
+ *
+ */
+ public FilterPackageType createFilterPackageType() {
+ return new FilterPackageType();
+ }
+
+ /**
+ * Create an instance of {@link FilterAttributeType }
+ *
+ */
+ public FilterAttributeType createFilterAttributeType() {
+ return new FilterAttributeType();
+ }
+
+ /**
+ * Create an instance of {@link RegionType }
+ *
+ */
+ public RegionType createRegionType() {
+ return new RegionType();
+ }
+
+ /**
+ * Create an instance of {@link RegionsType }
+ *
+ */
+ public RegionsType createRegionsType() {
+ return new RegionsType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link RegionsType }{@code >}}
+ *
+ */
+ @XmlElementDecl(namespace = "http://karaf.apache.org/xmlns/region/v1.0.0", name = "regions")
+ public JAXBElement<RegionsType> createRegions(RegionsType value) {
+ return new JAXBElement<RegionsType>(_Regions_QNAME, RegionsType.class, null, value);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionBundleType.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionBundleType.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionBundleType.java
new file mode 100644
index 0000000..7ba3585
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionBundleType.java
@@ -0,0 +1,94 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for regionBundleType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="regionBundleType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * </sequence>
+ * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
+ * <attribute name="location" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "regionBundleType")
+public class RegionBundleType {
+
+ @XmlAttribute
+ protected Long id;
+ @XmlAttribute
+ protected String location;
+
+ /**
+ * Gets the value of the id property.
+ *
+ * @return
+ * possible object is
+ * {@link Long }
+ *
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of the id property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Long }
+ *
+ */
+ public void setId(Long value) {
+ this.id = value;
+ }
+
+ /**
+ * Gets the value of the location property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getLocation() {
+ return location;
+ }
+
+ /**
+ * Sets the value of the location property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setLocation(String value) {
+ this.location = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionType.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionType.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionType.java
new file mode 100644
index 0000000..f7a810d
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionType.java
@@ -0,0 +1,106 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ *
+ * Regions element
+ *
+ *
+ * <p>Java class for regionType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="regionType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="bundle" type="{http://karaf.apache.org/xmlns/region/v1.0.0}regionBundleType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "regionType", propOrder = {
+ "bundle"
+})
+public class RegionType {
+
+ protected List<RegionBundleType> bundle;
+ @XmlAttribute(required = true)
+ protected String name;
+
+ /**
+ * Gets the value of the bundle property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the bundle property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getBundle().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link RegionBundleType }
+ *
+ *
+ */
+ public List<RegionBundleType> getBundle() {
+ if (bundle == null) {
+ bundle = new ArrayList<RegionBundleType>();
+ }
+ return this.bundle;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionsType.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionsType.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionsType.java
new file mode 100644
index 0000000..be172e4
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/RegionsType.java
@@ -0,0 +1,112 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+
+package org.apache.karaf.region.persist.internal.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ *
+ * Regions element
+ *
+ *
+ * <p>Java class for regionsType complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * <complexType name="regionsType">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="region" type="{http://karaf.apache.org/xmlns/region/v1.0.0}regionType" maxOccurs="unbounded" minOccurs="0"/>
+ * <element name="filter" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterType" maxOccurs="unbounded" minOccurs="0"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlRootElement(name = "regions")
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "regionsType", propOrder = {
+ "region",
+ "filter"
+})
+public class RegionsType {
+
+ protected List<RegionType> region;
+ protected List<FilterType> filter;
+
+ /**
+ * Gets the value of the region property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the region property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getRegion().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link RegionType }
+ *
+ *
+ */
+ public List<RegionType> getRegion() {
+ if (region == null) {
+ region = new ArrayList<RegionType>();
+ }
+ return this.region;
+ }
+
+ /**
+ * Gets the value of the filter property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the filter property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getFilter().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link FilterType }
+ *
+ *
+ */
+ public List<FilterType> getFilter() {
+ if (filter == null) {
+ filter = new ArrayList<FilterType>();
+ }
+ return this.filter;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/package-info.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/package-info.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/package-info.java
new file mode 100644
index 0000000..cae062c
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/model/package-info.java
@@ -0,0 +1,9 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2011.10.28 at 03:20:55 PM PDT
+//
+
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://karaf.apache.org/xmlns/region/v1.0.0", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+package org.apache.karaf.region.persist.internal.model;
[2/4] [KARAF-2859] Decouple features/core from persistent/core
Posted by gn...@apache.org.
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java
new file mode 100644
index 0000000..410121c
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderProcessor.java
@@ -0,0 +1,661 @@
+/*
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.osgi.framework.Constants;
+
+public class ManifestHeaderProcessor
+{
+ public static final String NESTED_FILTER_ATTRIBUTE = "org.apache.aries.application.filter.attribute";
+ private static final Pattern FILTER_ATTR = Pattern.compile("(\\(!)?\\((.*?)([<>]?=)(.*?)\\)\\)?");
+ private static final String LESS_EQ_OP = "<=";
+ private static final String GREATER_EQ_OP = ">=";
+
+ /**
+ * A simple class to associate two types.
+ *
+ */
+ public static class NameValuePair {
+ private String name;
+ private Map<String,String> attributes;
+
+ public NameValuePair(String name, Map<String,String> value)
+ {
+ this.name = name;
+ this.attributes = value;
+ }
+ public String getName()
+ {
+ return name;
+ }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Map<String,String> getAttributes()
+ {
+ return attributes;
+ }
+ public void setAttributes(Map<String,String> value)
+ {
+ this.attributes = value;
+ }
+
+ @Override
+ public String toString(){
+ return "{"+name.toString()+"::"+attributes.toString()+"}";
+ }
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((attributes == null) ? 0 : attributes.hashCode());
+ return result;
+ }
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+ final NameValuePair other = (NameValuePair) obj;
+ if (name == null) {
+ if (other.name != null) return false;
+ } else if (!name.equals(other.name)) return false;
+ if (attributes == null) {
+ if (other.attributes != null) return false;
+ } else if (!attributes.equals(other.attributes)) return false;
+ return true;
+ }
+ }
+
+ /**
+ * Intended to provide a standard way to add Name/Value's to
+ * aggregations of Name/Value's.
+ *
+ */
+ public static interface NameValueCollection {
+ /**
+ * Add this Name & Value to the collection.
+ * @param n
+ * @param v
+ */
+ public void addToCollection(String n, Map<String,String> v);
+ }
+
+ /**
+ * Map of Name -> Value.
+ *
+ */
+ public static class NameValueMap extends HashMap<String, Map<String,String>> implements NameValueCollection, Map<String, Map<String,String>>{
+ private static final long serialVersionUID = -6446338858542599141L;
+
+ public void addToCollection(String n, Map<String,String> v){
+ this.put(n,v);
+ }
+
+ @Override
+ public String toString(){
+ StringBuilder sb = new StringBuilder();
+ sb.append("{");
+ boolean first=true;
+ for(Map.Entry<String, Map<String,String>> entry : this.entrySet()){
+ if(!first)sb.append(",");
+ first=false;
+ sb.append(entry.getKey()+"->"+entry.getValue());
+ }
+ sb.append("}");
+ return sb.toString();
+ }
+ }
+
+ /**
+ * List of Name/Value
+ *
+ */
+ public static class NameValueList extends ArrayList<NameValuePair> implements NameValueCollection, List<NameValuePair> {
+ private static final long serialVersionUID = 1808636823825029983L;
+
+ public void addToCollection(String n, Map<String,String> v){
+ this.add(new NameValuePair(n,v));
+ }
+ @Override
+ public String toString(){
+ StringBuffer sb = new StringBuffer();
+ sb.append("{");
+ boolean first = true;
+ for(NameValuePair nvp : this){
+ if(!first)sb.append(",");
+ first=false;
+ sb.append(nvp.toString());
+ }
+ sb.append("}");
+ return sb.toString();
+ }
+ }
+
+ /**
+ *
+ * Splits a delimiter separated string, tolerating presence of non separator commas
+ * within double quoted segments.
+ *
+ * Eg.
+ * com.ibm.ws.eba.helloWorldService;version="[1.0.0, 1.0.0]" &
+ * com.ibm.ws.eba.helloWorldService;version="1.0.0"
+ * com.ibm.ws.eba.helloWorld;version="2";bundle-version="[2,30)"
+ * com.acme.foo;weirdAttr="one;two;three";weirdDir:="1;2;3"
+ * @param value the value to be split
+ * @param delimiter the delimiter string such as ',' etc.
+ * @return List<String> the components of the split String in a list
+ */
+ public static List<String> split(String value, String delimiter)
+ {
+ return ManifestHeaderUtils.split(value, delimiter);
+ }
+
+
+ /**
+ * Internal method to parse headers with the format<p>
+ * [Name](;[Name])*(;[attribute-name]=[attribute-value])*<br>
+ * Eg.<br>
+ * rumplestiltskin;thing=value;other=something<br>
+ * littleredridinghood
+ * bundle1;bundle2;other=things
+ * bundle1;bundle2
+ *
+ * @param s data to parse
+ * @return a list of NameValuePair, with the Name being the name component,
+ * and the Value being a NameValueMap of key->value mappings.
+ */
+ private static List<NameValuePair> genericNameWithNameValuePairProcess(String s){
+ String name;
+ Map<String,String> params = null;
+ List<NameValuePair> nameValues = new ArrayList<NameValuePair>();
+ List<String> pkgs = new ArrayList<String>();
+ int index = s.indexOf(";");
+ if(index==-1){
+ name = s;
+ params = new HashMap<String, String>();
+ pkgs.add(name);
+ }else{
+ name = s.substring(0,index).trim();
+ String tail = s.substring(index+1).trim();
+
+ pkgs.add(name); // add the first package
+ StringBuilder parameters = new StringBuilder();
+
+
+ // take into consideration of multiple packages separated by ';'
+ // while they share the same attributes or directives
+ List<String> tailParts = split(tail, ";");
+ boolean firstParameter =false;
+
+ for (String part : tailParts) {
+ // if it is not a parameter and no parameter appears in front of it, it must a package
+ if (!!!(part.contains("="))) {
+ // Need to make sure no parameter appears before the package, otherwise ignore this string
+ // as this syntax is invalid
+ if (!!!(firstParameter))
+ pkgs.add(part);
+ } else {
+ if (!!!(firstParameter))
+ firstParameter = true;
+
+ parameters.append(part + ";");
+ }
+ }
+
+ if (parameters.length() != 0) {
+ //remove the final ';' if there is one
+ if (parameters.toString().endsWith(";")) {
+
+ parameters = parameters.deleteCharAt(parameters.length() -1);
+ }
+
+ params = genericNameValueProcess(parameters.toString());
+ }
+
+ }
+ for (String pkg : pkgs) {
+ nameValues.add(new NameValuePair(pkg,params));
+ }
+
+ return nameValues;
+
+ }
+
+ /**
+ * Internal method to parse headers with the format<p>
+ * [attribute-name]=[attribute-value](;[attribute-name]=[attribute-value])*<br>
+ * Eg.<br>
+ * thing=value;other=something<br>
+ * <p>
+ * Note. Directives (name:=value) are represented in the map with name suffixed by ':'
+ *
+ * @param s data to parse
+ * @return a NameValueMap, with attribute-name -> attribute-value.
+ */
+ private static Map<String,String> genericNameValueProcess(String s){
+ Map<String,String> params = new HashMap<String,String>();
+ List<String> parameters = split(s, ";");
+ for(String parameter : parameters) {
+ List<String> parts = split(parameter,"=");
+ // do a check, otherwise we might get NPE
+ if (parts.size() ==2) {
+ String second = parts.get(1).trim();
+ if (second.startsWith("\"") && second.endsWith("\""))
+ second = second.substring(1,second.length()-1);
+
+ String first = parts.get(0).trim();
+
+ // make sure for directives we clear out any space as in "directive :=value"
+ if (first.endsWith(":")) {
+ first = first.substring(0, first.length()-1).trim()+":";
+ }
+
+ params.put(first, second);
+ }
+ }
+
+ return params;
+ }
+
+ /**
+ * Processes an import/export style header.. <p>
+ * pkg1;attrib=value;attrib=value,pkg2;attrib=value,pkg3;attrib=value
+ *
+ * @param out The collection to add each package name + attrib map to.
+ * @param s The data to parse
+ */
+ private static void genericImportExportProcess(NameValueCollection out, String s){
+ List<String> packages = split(s, ",");
+ for(String pkg : packages){
+ List<NameValuePair> ps = genericNameWithNameValuePairProcess(pkg);
+ for (NameValuePair p : ps) {
+ out.addToCollection(p.getName(), p.getAttributes());
+ }
+ }
+ }
+
+ /**
+ * Parse an export style header.<p>
+ * pkg1;attrib=value;attrib=value,pkg2;attrib=value,pkg3;attrib=value2
+ * <p>
+ * Result is returned as a list, as export does allow duplicate package exports.
+ *
+ * @param s The data to parse.
+ * @return List of NameValuePairs, where each Name in the list is an exported package,
+ * with its associated Value being a NameValueMap of any attributes declared.
+ */
+ public static List<NameValuePair> parseExportString(String s){
+ NameValueList retval = new NameValueList();
+ genericImportExportProcess(retval, s);
+ return retval;
+ }
+
+ /**
+ * Parse an export style header in a list.<p>
+ * pkg1;attrib=value;attrib=value
+ * pkg2;attrib=value
+ * pkg3;attrib=value2
+ * <p>
+ * Result is returned as a list, as export does allow duplicate package exports.
+ *
+ * @param list The data to parse.
+ * @return List of NameValuePairs, where each Name in the list is an exported package,
+ * with its associated Value being a NameValueMap of any attributes declared.
+ */
+ public static List<NameValuePair> parseExportList(List<String> list){
+ NameValueList retval = new NameValueList();
+ for(String pkg : list){
+ List<NameValuePair> ps = genericNameWithNameValuePairProcess(pkg);
+ for (NameValuePair p : ps) {
+ retval.addToCollection(p.getName(), p.getAttributes());
+ }
+ }
+ return retval;
+ }
+
+ /**
+ * Parse an import style header.<p>
+ * pkg1;attrib=value;attrib=value,pkg2;attrib=value,pkg3;attrib=value
+ * <p>
+ * Result is returned as a set, as import does not allow duplicate package imports.
+ *
+ * @param s The data to parse.
+ * @return Map of NameValuePairs, where each Key in the Map is an imported package,
+ * with its associated Value being a NameValueMap of any attributes declared.
+ */
+ public static Map<String, Map<String, String>> parseImportString(String s){
+ NameValueMap retval = new NameValueMap();
+ genericImportExportProcess(retval, s);
+ return retval;
+ }
+
+ /**
+ * Parse a bundle symbolic name.<p>
+ * bundlesymbolicname;attrib=value;attrib=value
+ * <p>
+ *
+ * @param s The data to parse.
+ * @return NameValuePair with Name being the BundleSymbolicName,
+ * and Value being any attribs declared for the name.
+ */
+ public static NameValuePair parseBundleSymbolicName(String s){
+ return genericNameWithNameValuePairProcess(s).get(0); // should just return the first one
+ }
+
+ /**
+ * Parse a version range..
+ *
+ * @param s
+ * @return VersionRange object.
+ * @throws IllegalArgumentException if the String could not be parsed as a VersionRange
+ */
+ public static VersionRange parseVersionRange(String s) throws IllegalArgumentException{
+ return new VersionRange(s);
+ }
+
+ /**
+ * Parse a version range and indicate if the version is an exact version
+ *
+ * @param s
+ * @param exactVersion
+ * @return VersionRange object.
+ * @throws IllegalArgumentException if the String could not be parsed as a VersionRange
+ */
+ public static VersionRange parseVersionRange(String s, boolean exactVersion) throws IllegalArgumentException{
+ return new VersionRange(s, exactVersion);
+ }
+
+ /**
+ * Generate a filter from a set of attributes. This filter will be suitable
+ * for presentation to OBR This means that, due to the way OBR works, it
+ * will include a stanza of the form, (mandatory:<*mandatoryAttribute)
+ * Filter strings generated by this method will therefore tend to break the
+ * standard OSGi Filter class. The OBR stanza can be stripped out later if
+ * required.
+ *
+ * @param attribs
+ * @return filter string
+ */
+ public static String generateFilter(Map<String, Object> attribs) {
+ StringBuilder filter = new StringBuilder("(&");
+ boolean realAttrib = false;
+ StringBuffer realAttribs = new StringBuffer();
+
+ if (attribs == null) {
+ attribs = new HashMap<String, Object>();
+ }
+
+ for (Map.Entry<String, Object> 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().toString());
+
+ 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 (NESTED_FILTER_ATTRIBUTE.equals(attribName)) {
+ // Filters go in whole, no formatting needed
+ realAttrib = true;
+ filter.append(attrib.getValue());
+
+ } else if (Constants.OBJECTCLASS.equals(attribName)) {
+ realAttrib = true;
+ // objectClass has a "," separated list of interfaces
+ String[] values = attrib.getValue().toString().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(", ");
+ }
+ }
+ }
+// /*
+// * The following is how OBR makes mandatory attributes work, we require
+// * that the set of mandatory attributes on the export is a subset of (or
+// * equal to) the set of the attributes we supply.
+// */
+//
+// if (realAttribs.length() > 0) {
+// String attribStr = (realAttribs.toString()).trim();
+// // remove the final ,
+// if ((attribStr.length() > 0) && (attribStr.endsWith(","))) {
+// attribStr = attribStr.substring(0, attribStr.length() - 1);
+// }
+// // build the mandatory filter, e.g.(mandatory:<*company, local)
+// filter.append("(" + Constants.MANDATORY_DIRECTIVE + ":" + "<*"
+// + attribStr + ")");
+// }
+
+ // 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;
+ }
+
+ /**
+ * Generate a filter from a set of attributes. This filter will be suitable
+ * for presentation to OBR. This means that, due to the way OBR works, it will
+ * include a stanza of the form, (mandatory:<*mandatoryAttribute) Filter
+ * strings generated by this method will therefore tend to break the standard
+ * OSGi Filter class. The OBR stanza can be stripped out later if required.
+ *
+ * We may wish to consider relocating this method since VersionRange has its
+ * own top level class.
+ *
+ * @param type
+ * @param name
+ * @param attribs
+ * @return filter string
+ */
+ public static String generateFilter(String type, String name,
+ Map<String, Object> attribs) {
+ StringBuffer filter = new StringBuffer();
+ String result;
+ // shortcut for the simple case with no attribs.
+
+ if (attribs == null || attribs.isEmpty())
+ filter.append("(" + type + "=" + name + ")");
+ else {
+ // process all the attribs passed.
+ // find out whether there are attributes on the filter
+
+ filter.append("(&(" + type + "=" + name + ")");
+
+ String filterString = generateFilter(attribs);
+
+ int start = 0;
+ int end = filterString.length();
+ if (filterString.startsWith("(&")) {
+ start = 2;
+ end--;
+ }
+
+ if ("".equals(filterString)) {
+ filter.delete(0, 2);
+ } else {
+ filter.append(filterString, start, end);
+ filter.append(")");
+ }
+ }
+
+ result = filter.toString();
+
+ return result;
+ }
+
+ private static Map<String, String> parseFilterList(String filter) {
+
+ Map<String, String> result = new HashMap<String, String>();
+ Set<String> negatedVersions = new HashSet<String>();
+ Set<String> negatedBundleVersions = new HashSet<String>();
+
+ String lowerVersion = null;
+ String upperVersion = null;
+ String lowerBundleVersion = null;
+ String upperBundleVersion = null;
+
+ Matcher m = FILTER_ATTR.matcher(filter);
+ while (m.find()) {
+ boolean negation = m.group(1) != null;
+ String attr = m.group(2);
+ String op = m.group(3);
+ String value = m.group(4);
+
+ if (Constants.VERSION_ATTRIBUTE.equals(attr)) {
+ if (negation) {
+ negatedVersions.add(value);
+ } else {
+ if (GREATER_EQ_OP.equals(op))
+ lowerVersion = value;
+ else if (LESS_EQ_OP.equals(op))
+ upperVersion = value;
+ else
+ throw new IllegalArgumentException();
+ }
+ } else if (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(attr)) {
+ // bundle-version is like version, but may be specified at the
+ // same time
+ // therefore we have similar code with separate variables
+ if (negation) {
+ negatedBundleVersions.add(value);
+ } else {
+ if (GREATER_EQ_OP.equals(op))
+ lowerBundleVersion = value;
+ else if (LESS_EQ_OP.equals(op))
+ upperBundleVersion = value;
+ else
+ throw new IllegalArgumentException();
+ }
+ } else {
+ result.put(attr, value);
+ }
+ }
+
+ if (lowerVersion != null) {
+ StringBuilder versionAttr = new StringBuilder(lowerVersion);
+ if (upperVersion != null) {
+ versionAttr.append(",").append(upperVersion).insert(0,
+ negatedVersions.contains(lowerVersion) ? '(' : '[').append(
+ negatedVersions.contains(upperVersion) ? ')' : ']');
+ }
+
+ result.put(Constants.VERSION_ATTRIBUTE, versionAttr.toString());
+ }
+ // Do it again for bundle-version
+ if (lowerBundleVersion != null) {
+ StringBuilder versionAttr = new StringBuilder(lowerBundleVersion);
+ if (upperBundleVersion != null) {
+ versionAttr.append(",").append(upperBundleVersion).insert(0,
+ negatedBundleVersions.contains(lowerBundleVersion) ? '(' : '[')
+ .append(
+ negatedBundleVersions.contains(upperBundleVersion) ? ')' : ']');
+ }
+
+ result.put(Constants.BUNDLE_VERSION_ATTRIBUTE, versionAttr.toString());
+ }
+
+ return result;
+ }
+
+ public static Map<String,String> parseFilter(String filter)
+ {
+ Map<String,String> result;
+ if (filter.startsWith("(&")) {
+ result = parseFilterList(filter.substring(2, filter.length()-1));
+ } else {
+ result = parseFilterList(filter);
+ }
+ return result;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java
new file mode 100644
index 0000000..8c87616
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/ManifestHeaderUtils.java
@@ -0,0 +1,85 @@
+/*
+ * 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.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ManifestHeaderUtils {
+
+ /**
+ *
+ * Splits a delimiter separated string, tolerating presence of non separator commas
+ * within double quoted segments.
+ *
+ * Eg.
+ * com.ibm.ws.eba.helloWorldService;version="[1.0.0, 1.0.0]" &
+ * com.ibm.ws.eba.helloWorldService;version="1.0.0"
+ * com.ibm.ws.eba.helloWorld;version="2";bundle-version="[2,30)"
+ * com.acme.foo;weirdAttr="one;two;three";weirdDir:="1;2;3"
+ * @param value the value to be split
+ * @param delimiter the delimiter string such as ',' etc.
+ * @return List<String> the components of the split String in a list
+ */
+ public static List<String> split(String value, String delimiter)
+ {
+ List<String> result = new ArrayList<String>();
+ if (value != null) {
+ String[] packages = value.split(delimiter);
+
+ for (int i = 0; i < packages.length; ) {
+ String tmp = packages[i++].trim();
+ // if there is a odd number of " in a string, we need to append
+ while (count(tmp, "\"") % 2 != 0) {
+ // check to see if we need to append the next package[i++]
+ if (i<packages.length)
+ tmp = tmp + delimiter + packages[i++].trim();
+ else
+ // oops. The double quotes are not paired up. We have reached to the end of the string.
+ throw new IllegalArgumentException("Unmatched double quotes: " + tmp);
+ }
+
+ result.add(tmp);
+
+ }
+ }
+ return result;
+ }
+
+ /**
+ * count the number of characters in a string
+ * @param parent The string to be searched
+ * @param subString The substring to be found
+ * @return the number of occurrence of the subString
+ */
+ private static int count(String parent, String subString) {
+
+ int count = 0 ;
+ int i = parent.indexOf(subString);
+ while (i > -1) {
+ if (parent.length() >= i+1)
+ parent = parent.substring(i+1);
+ count ++;
+ i = parent.indexOf(subString);
+ }
+ return count;
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java
----------------------------------------------------------------------
diff --git a/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java b/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java
new file mode 100644
index 0000000..19bbc77
--- /dev/null
+++ b/region/core/src/main/java/org/apache/karaf/region/persist/internal/util/VersionRange.java
@@ -0,0 +1,456 @@
+/*
+ * 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.util;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.osgi.framework.Version;
+
+public final class VersionRange {
+
+ /** A string representation of the version. */
+ private String version;
+
+ /** The minimum desired version for the bundle */
+ private Version minimumVersion;
+
+ /** The maximum desired version for the bundle */
+ private Version maximumVersion;
+
+ /** True if the match is exclusive of the minimum version */
+ private boolean minimumExclusive;
+
+ /** True if the match is exclusive of the maximum version */
+ private boolean maximumExclusive;
+
+ /** A regexp to select the version */
+ private static final Pattern versionCapture = Pattern.compile("\"?(.*?)\"?$");
+
+ /**
+ *
+ * @param version
+ * version for the verioninfo
+ */
+ public VersionRange(String version) {
+ this.version = version;
+ processVersionAttribute(version);
+ }
+
+ /**
+ * This method should be used to create a version range from a single
+ * version string.
+ * @param version
+ * version for the versioninfo
+ * @param exactVersion
+ * whether this is an exact version {@code true} or goes to infinity
+ * {@code false}
+ */
+ public VersionRange(String version, boolean exactVersion) {
+
+ if (exactVersion) {
+ // Do not store this string as it might be just a version, or a range!
+ processExactVersionAttribute(version);
+ } else {
+ this.version = version;
+ processVersionAttribute(this.version);
+ }
+
+ assertInvariants();
+ }
+
+ /**
+ * Constructor designed for internal use only.
+ *
+ * @param maximumVersion
+ * @param maximumExclusive
+ * @param minimumVersion
+ * @param minimumExclusive
+ * @throws IllegalArgumentException
+ * if parameters are not valid.
+ */
+ private VersionRange(Version maximumVersion,
+ boolean maximumExclusive,
+ Version minimumVersion,
+ boolean minimumExclusive) {
+ this.maximumVersion = maximumVersion;
+ this.maximumExclusive = maximumExclusive;
+ this.minimumVersion = minimumVersion;
+ this.minimumExclusive = minimumExclusive;
+
+ assertInvariants();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.aries.application.impl.VersionRange#toString()
+ */
+ @Override
+ public String toString() {
+ // Some constructors don't take in a string that we can return directly,
+ // so construct one if needed
+ if (version == null) {
+ if (maximumVersion == null) {
+ version = minimumVersion.toString();
+ } else {
+ version = (minimumExclusive ? "(" : "[") + minimumVersion + "," + maximumVersion
+ + (maximumExclusive ? ")" : "]");
+ }
+ }
+ return this.version;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 17;
+ result = 31 * result + minimumVersion.hashCode();
+ result = 31 * result + (minimumExclusive ? 1 : 0);
+ result = 31 * result + (maximumVersion != null ? maximumVersion.hashCode() : 0);
+ result = 31 * result + (maximumExclusive ? 1 : 0);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ boolean result = false;
+ if (this == other) {
+ result = true;
+ } else if (other instanceof VersionRange) {
+ VersionRange vr = (VersionRange) other;
+ result = minimumVersion.equals(vr.minimumVersion)
+ && minimumExclusive == vr.minimumExclusive
+ && (maximumVersion == null ? vr.maximumVersion == null : maximumVersion
+ .equals(vr.maximumVersion)) && maximumExclusive == vr.maximumExclusive;
+ }
+
+ return result;
+ }
+
+ /**
+ * this method returns the exact version from the versionInfo obj.
+ * this is used for DeploymentContent only to return a valid exact version
+ * otherwise, null is returned.
+ * @return the exact version
+ */
+ public Version getExactVersion() {
+ Version v = null;
+ if (isExactVersion()) {
+ v = getMinimumVersion();
+ }
+ return v;
+ }
+
+ /**
+ * get the maximum version
+ * @return the maximum version
+ */
+ public Version getMaximumVersion() {
+ return maximumVersion;
+ }
+
+ /**
+ * get the minimum version
+ * @return the minimum version
+ */
+ public Version getMinimumVersion() {
+ return minimumVersion;
+ }
+
+ /**
+ * is the maximum version exclusive
+ * @return is the max version in the range.
+ */
+ public boolean isMaximumExclusive() {
+ return maximumExclusive;
+ }
+
+ /**
+ * is the maximum version unbounded
+ * @return true if no upper bound was specified.
+ */
+ public boolean isMaximumUnbounded() {
+ boolean unbounded = maximumVersion == null;
+ return unbounded;
+ }
+
+ /**
+ * is the minimum version exclusive
+ * @return true if the min version is in range.
+ */
+ public boolean isMinimumExclusive() {
+ return minimumExclusive;
+ }
+
+ /**
+ * this is designed for deployed-version as that is the exact version.
+ *
+ * @param version
+ * @return
+ * @throws IllegalArgumentException
+ */
+ private boolean processExactVersionAttribute(String version) throws IllegalArgumentException {
+ boolean success = processVersionAttribute(version);
+
+ if (maximumVersion == null) {
+ maximumVersion = minimumVersion;
+ }
+
+ if (!minimumVersion.equals(maximumVersion)) {
+ throw new IllegalArgumentException("Version is not exact: " + version);
+ }
+
+ if (!!!isExactVersion()) {
+ throw new IllegalArgumentException("Version is not exact: " + version);
+ }
+
+ return success;
+ }
+
+ /**
+ * process the version attribute,
+ *
+ * @param version
+ * the value to be processed
+ * @return
+ * @throws IllegalArgumentException
+ */
+ private boolean processVersionAttribute(String version) throws IllegalArgumentException {
+ boolean success = false;
+
+ if (version == null) {
+ throw new IllegalArgumentException("Version is null");
+ }
+
+ Matcher matches = versionCapture.matcher(version);
+
+ if (matches.matches()) {
+ String versions = matches.group(1);
+
+ if ((versions.startsWith("[") || versions.startsWith("("))
+ && (versions.endsWith("]") || versions.endsWith(")"))) {
+ if (versions.startsWith("["))
+ minimumExclusive = false;
+ else if (versions.startsWith("("))
+ minimumExclusive = true;
+
+ if (versions.endsWith("]"))
+ maximumExclusive = false;
+ else if (versions.endsWith(")"))
+ maximumExclusive = true;
+
+ int index = versions.indexOf(',');
+ String minVersion = versions.substring(1, index);
+ String maxVersion = versions.substring(index + 1, versions.length() - 1);
+
+ try {
+ minimumVersion = new Version(minVersion.trim());
+ maximumVersion = new Version(maxVersion.trim());
+ success = true;
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException("Version cannot be decoded: " + version, nfe);
+ }
+ } else {
+ try {
+ if (versions.trim().length() == 0)
+ minimumVersion = new Version(0, 0, 0);
+ else
+ minimumVersion = new Version(versions.trim());
+ success = true;
+ } catch (NumberFormatException nfe) {
+ throw new IllegalArgumentException("Version cannot be decoded: " + version, nfe);
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("Version cannot be decoded: " + version);
+ }
+
+ return success;
+ }
+
+ /**
+ * Assert object invariants. Called by constructors to verify that arguments
+ * were valid.
+ *
+ * @throws IllegalArgumentException
+ * if invariants are violated.
+ */
+ private void assertInvariants() {
+ if (minimumVersion == null
+ || !isRangeValid(minimumVersion, minimumExclusive, maximumVersion, maximumExclusive)) {
+ IllegalArgumentException e = new IllegalArgumentException();
+ throw e;
+ }
+ }
+
+ /**
+ * Check if the supplied parameters describe a valid version range.
+ *
+ * @param min
+ * the minimum version.
+ * @param minExclusive
+ * whether the minimum version is exclusive.
+ * @param max
+ * the maximum version.
+ * @param maxExclusive
+ * whether the maximum version is exclusive.
+ * @return true is the range is valid; otherwise false.
+ */
+ private boolean isRangeValid(Version min,
+ boolean minExclusive,
+ Version max,
+ boolean maxExclusive) {
+ boolean result;
+
+ // A null maximum version is unbounded so means that minimum is smaller
+ // than
+ // maximum.
+ int minMaxCompare = (max == null ? -1 : min.compareTo(max));
+ if (minMaxCompare > 0) {
+ // Minimum larger than maximum is invalid.
+ result = false;
+ } else if (minMaxCompare == 0 && (minExclusive || maxExclusive)) {
+ // If min and max are the same, and either are exclusive, no valid
+ // range
+ // exists.
+ result = false;
+ } else {
+ // Range is valid.
+ result = true;
+ }
+
+ return result;
+ }
+
+ /**
+ * This method checks that the provided version matches the desired version.
+ *
+ * @param version
+ * the version.
+ * @return true if the version matches, false otherwise.
+ */
+ public boolean matches(Version version) {
+ boolean result;
+ if (this.getMaximumVersion() == null) {
+ result = this.getMinimumVersion().compareTo(version) <= 0;
+ } else {
+ int minN = this.isMinimumExclusive() ? 0 : 1;
+ int maxN = this.isMaximumExclusive() ? 0 : 1;
+
+ result = (this.getMinimumVersion().compareTo(version) < minN)
+ && (version.compareTo(this.getMaximumVersion()) < maxN);
+ }
+ return result;
+ }
+
+ /**
+ * check if the versioninfo is the exact version
+ * @return true if the range will match 1 exact version.
+ */
+ public boolean isExactVersion() {
+ return minimumVersion.equals(maximumVersion) && minimumExclusive == maximumExclusive
+ && !!!minimumExclusive;
+ }
+
+ /**
+ * Create a new version range that is the intersection of {@code this} and the argument.
+ * In other words, the largest version range that lies within both {@code this} and
+ * the parameter.
+ * @param r a version range to be intersected with {@code this}.
+ * @return a new version range, or {@code null} if no intersection is possible.
+ */
+ public VersionRange intersect(VersionRange r) {
+ // Use the highest minimum version.
+ final Version newMinimumVersion;
+ final boolean newMinimumExclusive;
+ int minCompare = minimumVersion.compareTo(r.getMinimumVersion());
+ if (minCompare > 0) {
+ newMinimumVersion = minimumVersion;
+ newMinimumExclusive = minimumExclusive;
+ } else if (minCompare < 0) {
+ newMinimumVersion = r.getMinimumVersion();
+ newMinimumExclusive = r.isMinimumExclusive();
+ } else {
+ newMinimumVersion = minimumVersion;
+ newMinimumExclusive = (minimumExclusive || r.isMinimumExclusive());
+ }
+
+ // Use the lowest maximum version.
+ final Version newMaximumVersion;
+ final boolean newMaximumExclusive;
+ // null maximum version means unbounded, so the highest possible value.
+ if (maximumVersion == null) {
+ newMaximumVersion = r.getMaximumVersion();
+ newMaximumExclusive = r.isMaximumExclusive();
+ } else if (r.getMaximumVersion() == null) {
+ newMaximumVersion = maximumVersion;
+ newMaximumExclusive = maximumExclusive;
+ } else {
+ int maxCompare = maximumVersion.compareTo(r.getMaximumVersion());
+ if (maxCompare < 0) {
+ newMaximumVersion = maximumVersion;
+ newMaximumExclusive = maximumExclusive;
+ } else if (maxCompare > 0) {
+ newMaximumVersion = r.getMaximumVersion();
+ newMaximumExclusive = r.isMaximumExclusive();
+ } else {
+ newMaximumVersion = maximumVersion;
+ newMaximumExclusive = (maximumExclusive || r.isMaximumExclusive());
+ }
+ }
+
+ VersionRange result;
+ if (isRangeValid(newMinimumVersion, newMinimumExclusive, newMaximumVersion,
+ newMaximumExclusive)) {
+ result = new VersionRange(newMaximumVersion, newMaximumExclusive, newMinimumVersion,
+ newMinimumExclusive);
+ } else {
+ result = null;
+ }
+ return result;
+ }
+
+ /**
+ * Parse a version range..
+ *
+ * @param s
+ * @return VersionRange object.
+ * @throws IllegalArgumentException
+ * if the String could not be parsed as a VersionRange
+ */
+ public static VersionRange parseVersionRange(String s) throws IllegalArgumentException {
+ return new VersionRange(s);
+ }
+
+ /**
+ * Parse a version range and indicate if the version is an exact version
+ *
+ * @param s
+ * @param exactVersion
+ * @return VersionRange object.
+ * @throws IllegalArgumentException
+ * if the String could not be parsed as a VersionRange
+ */
+ public static VersionRange parseVersionRange(String s, boolean exactVersion)
+ throws IllegalArgumentException {
+ return new VersionRange(s, exactVersion);
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/core/src/main/resources/org/apache/karaf/region/persist/region.xsd
----------------------------------------------------------------------
diff --git a/region/core/src/main/resources/org/apache/karaf/region/persist/region.xsd b/region/core/src/main/resources/org/apache/karaf/region/persist/region.xsd
new file mode 100644
index 0000000..8ca26e7
--- /dev/null
+++ b/region/core/src/main/resources/org/apache/karaf/region/persist/region.xsd
@@ -0,0 +1,109 @@
+<?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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<xsd:schema xmlns="http://karaf.apache.org/xmlns/region/v1.0.0"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://karaf.apache.org/xmlns/region/v1.0.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines the configuration elements for Apache Karaf region xml configuration.
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:element name="regions" type="regionsType"/>
+
+
+ <xsd:complexType name="regionsType">
+ <xsd:annotation>
+ <xsd:documentation>
+ Regions element
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="region" type="regionType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="filter" type="filterType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="regionType">
+ <xsd:annotation>
+ <xsd:documentation>
+ Region element
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="bundle" type="regionBundleType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="regionBundleType">
+ <xsd:sequence/>
+ <xsd:attribute name="id" type="xsd:long"/>
+ <xsd:attribute name="location" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="filterBundleType">
+ <xsd:sequence>
+ <xsd:element name="attribute" type="filterAttributeType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="xsd:long"/>
+ <xsd:attribute name="symbolic-name" type="xsd:string"/>
+ <xsd:attribute name="version" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="filterType">
+ <xsd:sequence>
+ <xsd:element name="bundle" type="filterBundleType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="package" type="filterPackageType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element name="namespace" type="filterNamespaceType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="from" type="xsd:string" use="required"/>
+ <xsd:attribute name="to" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="filterPackageType">
+ <xsd:sequence>
+ <xsd:element name="attribute" type="filterAttributeType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="version" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="filterAttributeType">
+ <xsd:sequence/>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="filterNamespaceType">
+ <xsd:sequence>
+ <xsd:element name="attribute" type="filterAttributeType" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ </xsd:complexType>
+</xsd:schema>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/NOTICE
----------------------------------------------------------------------
diff --git a/region/persist/NOTICE b/region/persist/NOTICE
deleted file mode 100644
index b70f1f9..0000000
--- a/region/persist/NOTICE
+++ /dev/null
@@ -1,71 +0,0 @@
-Apache Karaf
-Copyright 2010-2014 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-OW2 (http://www.ow2.org/).
-Licensed under the BSD License.
-
-This product includes software developed at
-OPS4J (http://www.ops4j.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-Eclipse Foundation (http://www.eclipse.org/).
-Licensed under the EPL.
-
-This product includes software written by
-Antony Lesuisse.
-Licensed under Public Domain.
-
-
-II. Used Software
-
-This product uses software developed at
-FUSE Source (http://www.fusesource.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-AOP Alliance (http://aopalliance.sourceforge.net/).
-Licensed under the Public Domain.
-
-This product uses software developed at
-Tanuki Software (http://www.tanukisoftware.com/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-Jasypt (http://jasypt.sourceforge.net/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-JLine (http://jline.sourceforge.net).
-Licensed under the BSD License.
-
-This product uses software developed at
-SLF4J (http://www.slf4j.org/).
-Licensed under the MIT License.
-
-This product uses software developed at
-SpringSource (http://www.springsource.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-
-III. License Summary
-- Apache License 2.0
-- BSD License
-- EPL License
-- MIT License
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/pom.xml
----------------------------------------------------------------------
diff --git a/region/persist/pom.xml b/region/persist/pom.xml
deleted file mode 100644
index c401dc5..0000000
--- a/region/persist/pom.xml
+++ /dev/null
@@ -1,129 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.region</groupId>
- <artifactId>region</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>org.apache.karaf.region.persist</artifactId>
- <packaging>bundle</packaging>
- <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>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.region</groupId>
- <artifactId>org.apache.karaf.region.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.karaf.features</groupId>
- <artifactId>org.apache.karaf.features.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.karaf</groupId>
- <artifactId>org.apache.karaf.util</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.equinox</groupId>
- <artifactId>region</artifactId>
- <version>1.0.0.v20110506</version>
- </dependency>
-
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <resources>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>${project.basedir}/src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.info</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-Activator>
- org.apache.karaf.region.persist.internal.Activator
- </Bundle-Activator>
- <Private-Package>
- org.apache.karaf.region.persist.internal.*,
- org.apache.karaf.util.tracker
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
deleted file mode 100644
index 4705818..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/Activator.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.util.tracker.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;
-
-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);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java
deleted file mode 100644
index 890fb58..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsBundleTracker.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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 org.apache.karaf.region.persist.RegionsPersistence;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.util.tracker.BundleTracker;
-import org.osgi.util.tracker.BundleTrackerCustomizer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RegionsBundleTracker {
- private static final Logger log = LoggerFactory.getLogger(RegionsBundleTracker.class);
-
- private BundleTracker bundleTracker;
- private RegionsPersistence regionsPersistence;
-
- void start(BundleContext bundleContext, RegionsPersistence regionsPersistence) {
- this.regionsPersistence = regionsPersistence;
- int stateMask = Bundle.INSTALLED;
- bundleTracker = new BundleTracker(bundleContext, stateMask, new BundleTrackerCustomizer() {
- @Override
- public Object addingBundle(Bundle bundle, BundleEvent bundleEvent) {
- return RegionsBundleTracker.this.addingBundle(bundle);
- }
-
- @Override
- public void modifiedBundle(Bundle bundle, BundleEvent bundleEvent, Object o) {
- }
-
- @Override
- public void removedBundle(Bundle bundle, BundleEvent bundleEvent, Object o) {
- }
- });
- bundleTracker.open();
- }
-
- private Object addingBundle(Bundle bundle) {
- String region = bundle.getHeaders().get("Region");
- if (region != null) {
- try {
- regionsPersistence.install(bundle, region);
- log.debug("Installed bundle " + bundle + " in region " + region);
- return bundle;
- } catch (BundleException e) {
- log.info("Could not install bundle " + bundle + " in region " + region, e);
- }
- }
- return null;
- }
-
- void stop() {
- bundleTracker.close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java
deleted file mode 100644
index 9cfda9f..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/RegionsPersistenceImpl.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * 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.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import org.apache.karaf.region.persist.RegionsPersistence;
-import org.apache.karaf.region.persist.internal.model.FilterAttributeType;
-import org.apache.karaf.region.persist.internal.model.FilterBundleType;
-import org.apache.karaf.region.persist.internal.model.FilterNamespaceType;
-import org.apache.karaf.region.persist.internal.model.FilterPackageType;
-import org.apache.karaf.region.persist.internal.model.FilterType;
-import org.apache.karaf.region.persist.internal.model.RegionBundleType;
-import org.apache.karaf.region.persist.internal.model.RegionType;
-import org.apache.karaf.region.persist.internal.model.RegionsType;
-import org.apache.karaf.region.persist.internal.util.ManifestHeaderProcessor;
-import org.eclipse.equinox.region.Region;
-import org.eclipse.equinox.region.RegionDigraph;
-import org.eclipse.equinox.region.RegionFilterBuilder;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.BundleRevision;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RegionsPersistenceImpl implements RegionsPersistence {
-
- private static final Logger log = LoggerFactory.getLogger(RegionsPersistenceImpl.class);
-
- private JAXBContext jaxbContext;
- private RegionDigraph regionDigraph;
- private Region kernel;
- private Bundle framework;
-
- public RegionsPersistenceImpl(RegionDigraph regionDigraph, Bundle framework) throws JAXBException, BundleException, IOException, InvalidSyntaxException {
- log.info("Loading region digraph persistence");
- this.framework = framework;
- this.regionDigraph = regionDigraph;
- kernel = regionDigraph.getRegion(0);
- jaxbContext = JAXBContext.newInstance(RegionsType.class);
- load();
- }
-
- @Override
- public void install(Bundle b, String regionName) throws BundleException {
- Region region = regionDigraph.getRegion(regionName);
- if (region == null) {
- region = regionDigraph.createRegion(regionName);
- }
- kernel.removeBundle(b);
- region.addBundle(b);
- }
-
- void save(RegionsType regionsType, Writer out) throws JAXBException {
- Marshaller marshaller = jaxbContext.createMarshaller();
- marshaller.marshal(regionsType, out);
- }
-
- void load() throws IOException, BundleException, JAXBException, InvalidSyntaxException {
- if (this.regionDigraph.getRegions().size() <= 1) {
- File etc = new File(System.getProperty("karaf.etc"));
- File regionsConfig = new File(etc, "regions-config.xml");
- if (regionsConfig.exists()) {
- log.info("initializing region digraph from etc/regions-config.xml");
- Reader in = new FileReader(regionsConfig);
- try {
- load(this.regionDigraph, in);
- } finally {
- in.close();
- }
- } else {
- log.info("no regions config file");
- }
- }
-
- }
-
- void load(RegionDigraph regionDigraph, Reader in) throws JAXBException, BundleException, InvalidSyntaxException {
- RegionsType regionsType = load(in);
- load(regionsType, regionDigraph);
- }
-
- RegionsType load(Reader in) throws JAXBException {
- Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
- return (RegionsType) unmarshaller.unmarshal(in);
- }
-
- void load(RegionsType regionsType, RegionDigraph regionDigraph) throws BundleException, InvalidSyntaxException {
- BundleContext frameworkContext = framework.getBundleContext();
- for (RegionType regionType: regionsType.getRegion()) {
- String name = regionType.getName();
- log.debug("Creating region: " + name);
- Region region = regionDigraph.createRegion(name);
- for (RegionBundleType bundleType: regionType.getBundle()) {
- if (bundleType.getId() != null) {
- region.addBundle(bundleType.getId());
- } else {
- Bundle b = frameworkContext.getBundle(bundleType.getLocation());
- region.addBundle(b);
- }
- }
- }
- for (FilterType filterType: regionsType.getFilter()) {
- Region from = regionDigraph.getRegion(filterType.getFrom());
- Region to = regionDigraph.getRegion(filterType.getTo());
- log.debug("Creating filter between " + from.getName() + " to " + to.getName());
- RegionFilterBuilder builder = regionDigraph.createRegionFilterBuilder();
- for (FilterBundleType bundleType: filterType.getBundle()) {
- String symbolicName = bundleType.getSymbolicName();
- String version = bundleType.getVersion();
- if (bundleType.getId() != null) {
- Bundle b = frameworkContext.getBundle(bundleType.getId());
- symbolicName = b.getSymbolicName();
- version = b.getVersion().toString();
- }
- String namespace = BundleRevision.BUNDLE_NAMESPACE;
- List<FilterAttributeType> attributeTypes = bundleType.getAttribute();
- buildFilter(symbolicName, version, namespace, attributeTypes, builder);
- }
- for (FilterPackageType packageType: filterType.getPackage()) {
- String packageName = packageType.getName();
- String version = packageType.getVersion();
- String namespace = BundleRevision.PACKAGE_NAMESPACE;
- List<FilterAttributeType> attributeTypes = packageType.getAttribute();
- buildFilter(packageName, version, namespace, attributeTypes, builder);
- }
- if (to == kernel) {
- //add framework exports
- BundleRevision rev = framework.adapt(BundleRevision.class);
- List<BundleCapability> caps = rev.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
- for (BundleCapability cap : caps) {
- String filter = ManifestHeaderProcessor.generateFilter(filter(cap.getAttributes()));
- builder.allow(BundleRevision.PACKAGE_NAMESPACE, filter);
- }
- }
- //TODO explicit services?
- for (FilterNamespaceType namespaceType: filterType.getNamespace()) {
- String namespace = namespaceType.getName();
- HashMap<String, Object> attributes = new HashMap<String, Object>();
- for (FilterAttributeType attributeType: namespaceType.getAttribute()) {
- attributes.put(attributeType.getName(), attributeType.getValue());
- }
- String filter = ManifestHeaderProcessor.generateFilter(attributes);
- builder.allow(namespace, filter);
- }
- regionDigraph.connect(from, builder.build(), to);
- }
- }
-
- private Map<String, Object> filter(Map<String, Object> attributes) {
- Map<String, Object> result = new HashMap<String, Object>(attributes);
- result.remove("bundle-version");
- result.remove("bundle-symbolic-name");
- return result;
- }
-
- private void buildFilter(String packageName, String version, String namespace, List<FilterAttributeType> attributeTypes, RegionFilterBuilder builder) throws InvalidSyntaxException {
- HashMap<String, Object> attributes = new HashMap<String, Object>();
- if (namespace != null) {
- attributes.put(namespace, packageName);
- }
- if (version != null) {
- attributes.put("version", version);
- }
- for (FilterAttributeType attributeType: attributeTypes) {
- attributes.put(attributeType.getName(), attributeType.getValue());
- }
- String filter = ManifestHeaderProcessor.generateFilter(attributes);
- builder.allow(namespace, filter);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterAttributeType.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterAttributeType.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterAttributeType.java
deleted file mode 100644
index 857c2b3..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterAttributeType.java
+++ /dev/null
@@ -1,94 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for filterAttributeType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="filterAttributeType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * </sequence>
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="value" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "filterAttributeType")
-public class FilterAttributeType {
-
- @XmlAttribute(required = true)
- protected String name;
- @XmlAttribute(required = true)
- protected String value;
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setName(String value) {
- this.name = value;
- }
-
- /**
- * Gets the value of the value property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setValue(String value) {
- this.value = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterBundleType.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterBundleType.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterBundleType.java
deleted file mode 100644
index a9a9fbb..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterBundleType.java
+++ /dev/null
@@ -1,156 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for filterBundleType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="filterBundleType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="attribute" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterAttributeType" maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}long" />
- * <attribute name="symbolic-name" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "filterBundleType", propOrder = {
- "attribute"
-})
-public class FilterBundleType {
-
- protected List<FilterAttributeType> attribute;
- @XmlAttribute
- protected Long id;
- @XmlAttribute(name = "symbolic-name")
- protected String symbolicName;
- @XmlAttribute
- protected String version;
-
- /**
- * Gets the value of the attribute property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the attribute property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getAttribute().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link FilterAttributeType }
- *
- *
- */
- public List<FilterAttributeType> getAttribute() {
- if (attribute == null) {
- attribute = new ArrayList<FilterAttributeType>();
- }
- return this.attribute;
- }
-
- /**
- * Gets the value of the id property.
- *
- * @return
- * possible object is
- * {@link Long }
- *
- */
- public Long getId() {
- return id;
- }
-
- /**
- * Sets the value of the id property.
- *
- * @param value
- * allowed object is
- * {@link Long }
- *
- */
- public void setId(Long value) {
- this.id = value;
- }
-
- /**
- * Gets the value of the symbolicName property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getSymbolicName() {
- return symbolicName;
- }
-
- /**
- * Sets the value of the symbolicName property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setSymbolicName(String value) {
- this.symbolicName = value;
- }
-
- /**
- * Gets the value of the version property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * Sets the value of the version property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setVersion(String value) {
- this.version = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterNamespaceType.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterNamespaceType.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterNamespaceType.java
deleted file mode 100644
index 52b937a..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterNamespaceType.java
+++ /dev/null
@@ -1,102 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for filterNamespaceType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="filterNamespaceType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="attribute" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterAttributeType" maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * <attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "filterNamespaceType", propOrder = {
- "attribute"
-})
-public class FilterNamespaceType {
-
- protected List<FilterAttributeType> attribute;
- @XmlAttribute(required = true)
- protected String name;
-
- /**
- * Gets the value of the attribute property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the attribute property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getAttribute().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link FilterAttributeType }
- *
- *
- */
- public List<FilterAttributeType> getAttribute() {
- if (attribute == null) {
- attribute = new ArrayList<FilterAttributeType>();
- }
- return this.attribute;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setName(String value) {
- this.name = value;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/8bba2546/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterPackageType.java
----------------------------------------------------------------------
diff --git a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterPackageType.java b/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterPackageType.java
deleted file mode 100644
index b4216ee..0000000
--- a/region/persist/src/main/java/org/apache/karaf/region/persist/internal/model/FilterPackageType.java
+++ /dev/null
@@ -1,129 +0,0 @@
-//
-// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833
-// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
-// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.10.28 at 03:20:55 PM PDT
-//
-
-
-package org.apache.karaf.region.persist.internal.model;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * <p>Java class for filterPackageType complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType name="filterPackageType">
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="attribute" type="{http://karaf.apache.org/xmlns/region/v1.0.0}filterAttributeType" maxOccurs="unbounded" minOccurs="0"/>
- * </sequence>
- * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
-@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "filterPackageType", propOrder = {
- "attribute"
-})
-public class FilterPackageType {
-
- protected List<FilterAttributeType> attribute;
- @XmlAttribute
- protected String name;
- @XmlAttribute
- protected String version;
-
- /**
- * Gets the value of the attribute property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the attribute property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getAttribute().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link FilterAttributeType }
- *
- *
- */
- public List<FilterAttributeType> getAttribute() {
- if (attribute == null) {
- attribute = new ArrayList<FilterAttributeType>();
- }
- return this.attribute;
- }
-
- /**
- * Gets the value of the name property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getName() {
- return name;
- }
-
- /**
- * Sets the value of the name property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setName(String value) {
- this.name = value;
- }
-
- /**
- * Gets the value of the version property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * Sets the value of the version property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setVersion(String value) {
- this.version = value;
- }
-
-}
[4/4] git commit: Fix integration tests broken when changing version
to 4.0.0-SNAPSHOT
Posted by gn...@apache.org.
Fix integration tests broken when changing version to 4.0.0-SNAPSHOT
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/200bd9ba
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/200bd9ba
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/200bd9ba
Branch: refs/heads/master
Commit: 200bd9ba08c096f2da10410c996678d4c966525b
Parents: 8bba254
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Fri Mar 28 18:23:34 2014 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Fri Mar 28 18:23:34 2014 +0100
----------------------------------------------------------------------
itests/src/test/java/org/apache/karaf/itests/SystemTest.java | 2 +-
.../org/apache/karaf/itests/features/EnterpriseFeaturesTest.java | 3 +++
pom.xml | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/200bd9ba/itests/src/test/java/org/apache/karaf/itests/SystemTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/SystemTest.java b/itests/src/test/java/org/apache/karaf/itests/SystemTest.java
index 671624e..9582106 100644
--- a/itests/src/test/java/org/apache/karaf/itests/SystemTest.java
+++ b/itests/src/test/java/org/apache/karaf/itests/SystemTest.java
@@ -30,7 +30,7 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
@ExamReactorStrategy(PerClass.class)
public class SystemTest extends KarafTestSupport {
- private static final String KARAF_VERSION = "3";
+ private static final String KARAF_VERSION = "4";
@Test
public void nameCommand() throws Exception {
http://git-wip-us.apache.org/repos/asf/karaf/blob/200bd9ba/itests/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java b/itests/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java
index ccb7eb1..f304278 100644
--- a/itests/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java
+++ b/itests/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java
@@ -14,6 +14,7 @@
package org.apache.karaf.itests.features;
import org.apache.karaf.itests.KarafTestSupport;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.junit.PaxExam;
@@ -70,11 +71,13 @@ public class EnterpriseFeaturesTest extends KarafTestSupport {
}
@Test
+ @Ignore("Pax-cdi depends on scr feature [2.3,3.5) so it does not work with 4.0")
public void installOpenWebBeansFeature() throws Exception {
installAssertAndUninstallFeature("openwebbeans");
}
@Test
+ @Ignore("Pax-cdi depends on scr feature [2.3,3.5) so it does not work with 4.0")
public void installWeldFeature() throws Exception {
installAssertAndUninstallFeature("weld");
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/200bd9ba/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9e2caca..f7f0149 100644
--- a/pom.xml
+++ b/pom.xml
@@ -249,7 +249,7 @@
<xbean.version>3.16</xbean.version>
<xerces.version>2.11.0</xerces.version>
<javax.mail.version>1.4.5</javax.mail.version>
- <http.feature.version>[3,4)</http.feature.version>
+ <http.feature.version>[4,5)</http.feature.version>
<weld.version>2.1.1.Final</weld.version>
<!-- Furter used maven plugin versions; e.g. in the docs -->