curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ioca...@apache.org
Subject git commit: [CURATOR-2] Add PathUtils as part of curator client utils. Add OSGi metadata to curator artifacts.
Date Wed, 31 Jul 2013 08:11:21 GMT
Updated Branches:
  refs/heads/CURATOR-2 [created] 8565fa7cb


[CURATOR-2] Add PathUtils as part of curator client utils. Add OSGi metadata to curator artifacts.


Project: http://git-wip-us.apache.org/repos/asf/incubator-curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-curator/commit/8565fa7c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-curator/tree/8565fa7c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-curator/diff/8565fa7c

Branch: refs/heads/CURATOR-2
Commit: 8565fa7cb353d2b58355f4228643453d52f0d303
Parents: d90677f
Author: Ioannis Canellos <iocanel@apache.org>
Authored: Wed Jul 31 11:10:09 2013 +0300
Committer: Ioannis Canellos <iocanel@apache.org>
Committed: Wed Jul 31 11:10:09 2013 +0300

----------------------------------------------------------------------
 curator-client/pom.xml                          | 10 ++
 .../org/apache/curator/utils/PathUtils.java     | 99 ++++++++++++++++++++
 .../java/org/apache/curator/utils/ZKPaths.java  |  1 -
 curator-framework/pom.xml                       | 10 ++
 .../curator/framework/imps/NamespaceImpl.java   |  2 +-
 curator-recipes/pom.xml                         | 10 ++
 .../framework/recipes/locks/LockInternals.java  |  2 +-
 curator-x-discovery-server/pom.xml              |  7 ++
 curator-x-discovery/pom.xml                     | 10 ++
 pom.xml                                         | 44 +++++++++
 10 files changed, 192 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-client/pom.xml
----------------------------------------------------------------------
diff --git a/curator-client/pom.xml b/curator-client/pom.xml
index 7b5069d..1ddbdfe 100644
--- a/curator-client/pom.xml
+++ b/curator-client/pom.xml
@@ -30,11 +30,21 @@
     <groupId>org.apache.curator</groupId>
     <artifactId>curator-client</artifactId>
     <version>2.1.1-incubating-SNAPSHOT</version>
+    <packaging>bundle</packaging>
 
     <name>Curator Client</name>
     <description>Low-level API</description>
     <inceptionYear>2011</inceptionYear>
 
+    <properties>
+        <osgi.import.package>
+            *
+        </osgi.import.package>
+        <osgi.export.package>
+            org.apache.curator*;version="${project.version}";-noimport:=true
+        </osgi.export.package>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.slf4j</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java b/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java
new file mode 100644
index 0000000..0009518
--- /dev/null
+++ b/curator-client/src/main/java/org/apache/curator/utils/PathUtils.java
@@ -0,0 +1,99 @@
+/**
+ * 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.curator.utils;
+
+public class PathUtils {
+
+    /** validate the provided znode path string
+     * @param path znode path string
+     * @param isSequential if the path is being created
+     * with a sequential flag
+     * @throws IllegalArgumentException if the path is invalid
+     */
+    public static void validatePath(String path, boolean isSequential)
+            throws IllegalArgumentException {
+        validatePath(isSequential? path + "1": path);
+    }
+
+    /**
+     * Validate the provided znode path string
+     * @param path znode path string
+     * @throws IllegalArgumentException if the path is invalid
+     */
+    public static void validatePath(String path) throws IllegalArgumentException {
+        if (path == null) {
+            throw new IllegalArgumentException("Path cannot be null");
+        }
+        if (path.length() == 0) {
+            throw new IllegalArgumentException("Path length must be > 0");
+        }
+        if (path.charAt(0) != '/') {
+            throw new IllegalArgumentException(
+                    "Path must start with / character");
+        }
+        if (path.length() == 1) { // done checking - it's the root
+            return;
+        }
+        if (path.charAt(path.length() - 1) == '/') {
+            throw new IllegalArgumentException(
+                    "Path must not end with / character");
+        }
+
+        String reason = null;
+        char lastc = '/';
+        char chars[] = path.toCharArray();
+        char c;
+        for (int i = 1; i < chars.length; lastc = chars[i], i++) {
+            c = chars[i];
+
+            if (c == 0) {
+                reason = "null character not allowed @" + i;
+                break;
+            } else if (c == '/' && lastc == '/') {
+                reason = "empty node name specified @" + i;
+                break;
+            } else if (c == '.' && lastc == '.') {
+                if (chars[i-2] == '/' &&
+                        ((i + 1 == chars.length)
+                                || chars[i+1] == '/')) {
+                    reason = "relative paths not allowed @" + i;
+                    break;
+                }
+            } else if (c == '.') {
+                if (chars[i-1] == '/' &&
+                        ((i + 1 == chars.length)
+                                || chars[i+1] == '/')) {
+                    reason = "relative paths not allowed @" + i;
+                    break;
+                }
+            } else if (c > '\u0000' && c < '\u001f'
+                    || c > '\u007f' && c < '\u009F'
+                    || c > '\ud800' && c < '\uf8ff'
+                    || c > '\ufff0' && c < '\uffff') {
+                reason = "invalid charater @" + i;
+                break;
+            }
+        }
+
+        if (reason != null) {
+            throw new IllegalArgumentException(
+                    "Invalid path string \"" + path + "\" caused by " + reason);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
index 40c5bd7..5f688fd 100644
--- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
+++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
@@ -23,7 +23,6 @@ import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.common.PathUtils;
 import java.util.Collections;
 import java.util.List;
 

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-framework/pom.xml
----------------------------------------------------------------------
diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml
index dbbaabd..1ceacb2 100644
--- a/curator-framework/pom.xml
+++ b/curator-framework/pom.xml
@@ -30,11 +30,21 @@
     <groupId>org.apache.curator</groupId>
     <artifactId>curator-framework</artifactId>
     <version>2.1.1-incubating-SNAPSHOT</version>
+    <packaging>bundle</packaging>
 
     <name>Curator Framework</name>
     <description>High-level API that greatly simplifies using ZooKeeper.</description>
     <inceptionYear>2011</inceptionYear>
 
+    <properties>
+        <osgi.import.package>
+            *
+        </osgi.import.package>
+        <osgi.export.package>
+            org.apache.curator.framework*;version="${project.version}";-noimport:=true
+        </osgi.export.package>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.curator</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
index 23ea516..169ded5 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/NamespaceImpl.java
@@ -20,7 +20,7 @@ package org.apache.curator.framework.imps;
 
 import org.apache.curator.utils.EnsurePath;
 import org.apache.curator.utils.ZKPaths;
-import org.apache.zookeeper.common.PathUtils;
+import org.apache.curator.utils.PathUtils;
 
 class NamespaceImpl
 {

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-recipes/pom.xml
----------------------------------------------------------------------
diff --git a/curator-recipes/pom.xml b/curator-recipes/pom.xml
index b4a9a21..6b5fef9 100644
--- a/curator-recipes/pom.xml
+++ b/curator-recipes/pom.xml
@@ -30,11 +30,21 @@
     <groupId>org.apache.curator</groupId>
     <artifactId>curator-recipes</artifactId>
     <version>2.1.1-incubating-SNAPSHOT</version>
+    <packaging>bundle</packaging>
 
     <name>Curator Recipes</name>
     <description>All of the recipes listed on the ZooKeeper recipes doc (except two
phase commit).</description>
     <inceptionYear>2011</inceptionYear>
 
+    <properties>
+        <osgi.import.package>
+            *
+        </osgi.import.package>
+        <osgi.export.package>
+            org.apache.curator.framework.recipes*;version="${project.version}";-noimport:=true
+        </osgi.export.package>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.curator</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
index 310701c..06a1f6b 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/locks/LockInternals.java
@@ -31,7 +31,7 @@ import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.common.PathUtils;
+import org.apache.curator.utils.PathUtils;
 import org.apache.zookeeper.data.Stat;
 import java.util.Arrays;
 import java.util.Collection;

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-x-discovery-server/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-discovery-server/pom.xml b/curator-x-discovery-server/pom.xml
index bffc3a1..fae8c86 100644
--- a/curator-x-discovery-server/pom.xml
+++ b/curator-x-discovery-server/pom.xml
@@ -30,6 +30,7 @@
     <groupId>org.apache.curator</groupId>
     <artifactId>curator-x-discovery-server</artifactId>
     <version>2.1.1-incubating-SNAPSHOT</version>
+    <packaging>bundle</packaging>
 
     <name>Curator Service Discovery Server</name>
     <description>Bridges non-Java or legacy applications with the Curator Service Discovery.</description>
@@ -37,6 +38,12 @@
 
     <properties>
         <jersey.version>1.11</jersey.version>
+        <osgi.import.package>
+            *
+        </osgi.import.package>
+        <osgi.export.package>
+            org.apache.curator.x.discovery.server*;version="${project.version}";-noimport:=true
+        </osgi.export.package>
     </properties>
 
     <dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/curator-x-discovery/pom.xml
----------------------------------------------------------------------
diff --git a/curator-x-discovery/pom.xml b/curator-x-discovery/pom.xml
index 0286c80..4eb3e2b 100644
--- a/curator-x-discovery/pom.xml
+++ b/curator-x-discovery/pom.xml
@@ -30,11 +30,21 @@
     <groupId>org.apache.curator</groupId>
     <artifactId>curator-x-discovery</artifactId>
     <version>2.1.1-incubating-SNAPSHOT</version>
+    <packaging>bundle</packaging>
 
     <name>Curator Service Discovery</name>
     <description>A service discovery recipe.</description>
     <inceptionYear>2011</inceptionYear>
 
+    <properties>
+        <osgi.import.package>
+            *
+        </osgi.import.package>
+        <osgi.export.package>
+            org.apache.curator.x.discovery*;version="${project.version}";-noimport:=true
+        </osgi.export.package>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.curator</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-curator/blob/8565fa7c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 53c0a7a..ef7ca38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,6 +56,15 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+
+        <!-- OSGi Properties -->
+        <osgi.export.package/>
+        <osgi.import.package/>
+        <osgi.private.package/>
+        <osgi.dynamic.import/>
+        <osgi.require.bundle/>
+        <osgi.export.service/>
+        <osgi.activator/>
     </properties>
 
     <scm>
@@ -364,6 +373,41 @@
                     <target>1.6</target>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>2.3.7</version>
+                <extensions>true</extensions>
+                <inherited>true</inherited>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>${project.name}</Bundle-Name>
+                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        <Export-Package>${osgi.export.package}</Export-Package>
+                        <Import-Package>${osgi.import.package}</Import-Package>
+                        <DynamicImport-Package>${osgi.dynamic.import}</DynamicImport-Package>
+                        <Private-Package>${osgi.private.package}</Private-Package>
+                        <Require-Bundle>${osgi.require.bundle}</Require-Bundle>
+                        <Bundle-Activator>${osgi.activator}</Bundle-Activator>
+                        <Export-Service>${osgi.export.service}</Export-Service>
+                    </instructions>
+                    <supportedProjectTypes>
+                        <supportedProjectType>jar</supportedProjectType>
+                        <supportedProjectType>war</supportedProjectType>
+                        <supportedProjectType>bundle</supportedProjectType>
+                    </supportedProjectTypes>
+                    <unpackBundle>true</unpackBundle>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>bundle-manifest</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>manifest</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
 
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>


Mime
View raw message