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 2015/04/30 10:02:12 UTC

[1/4] karaf git commit: [manual] small improvements

Repository: karaf
Updated Branches:
  refs/heads/master b3a2a1cba -> b1ed61d53


[manual] small improvements


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b1ed61d5
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b1ed61d5
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b1ed61d5

Branch: refs/heads/master
Commit: b1ed61d534406c7a54fbb9b53ebc521fe9940df6
Parents: 4aeed78
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Apr 30 09:50:04 2015 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Apr 30 09:50:17 2015 +0200

----------------------------------------------------------------------
 .../developers-guide/developer-commands.conf    |  2 +-
 .../developers-guide/security-framework.conf    |  2 +-
 manual/src/main/webapp/users-guide/console.conf | 63 ++++++++++++--------
 3 files changed, 40 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/b1ed61d5/manual/src/main/webapp/developers-guide/developer-commands.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/developers-guide/developer-commands.conf b/manual/src/main/webapp/developers-guide/developer-commands.conf
index 14ae266..bc1a688 100644
--- a/manual/src/main/webapp/developers-guide/developer-commands.conf
+++ b/manual/src/main/webapp/developers-guide/developer-commands.conf
@@ -224,4 +224,4 @@ The following command:
 karaf@root> dev:watch *
 {code}
 
-will monitore all bundles that have a location matching mvn:* and having '-SNAPSHOT' in their URL.
+will monitor all bundles that have a location matching mvn:* and '-SNAPSHOT' in their URL.

http://git-wip-us.apache.org/repos/asf/karaf/blob/b1ed61d5/manual/src/main/webapp/developers-guide/security-framework.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/developers-guide/security-framework.conf b/manual/src/main/webapp/developers-guide/security-framework.conf
index 1ef1b2e..d5da72b 100644
--- a/manual/src/main/webapp/developers-guide/security-framework.conf
+++ b/manual/src/main/webapp/developers-guide/security-framework.conf
@@ -20,7 +20,7 @@ h2. Schema
 To override or deploy a new realm, you can use the following XSD which is supported by a Spring namespace handler and can thus be defined in a Spring xml configuration file.
 
 Following is the XML Schema to use when defining Karaf realms:
-{snippet:url=../jaas/config/src/main/resources/org/apache/karaf/jaas/config/karaf-jaas-1.1.0.xsd|lang=xml|pygmentize=true}
+{snippet:url=../jaas/blueprint/config/src/main/resources/org/apache/karaf/jaas/blueprint/config/karaf-jaas-1.1.0.xsd|lang=xml|pygmentize=true}
 {snippet}
 
 You can find the schema at the following [location|http://karaf.apache.org/xmlns/jaas/v1.1.0].

http://git-wip-us.apache.org/repos/asf/karaf/blob/b1ed61d5/manual/src/main/webapp/users-guide/console.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/users-guide/console.conf b/manual/src/main/webapp/users-guide/console.conf
index d386b78..40b40e6 100644
--- a/manual/src/main/webapp/users-guide/console.conf
+++ b/manual/src/main/webapp/users-guide/console.conf
@@ -207,15 +207,23 @@ The {{shell:alias}} command creates a new alias. For instance, to create the {{l
 {code}
 karaf@root()> alias "list-features-installed = { feature:list -i }"
 karaf@root()> list-features-installed 
-Name       | Version  | Installed | Repository     | Description
----------------------------------------------------------------------------------------------------------
-standard   | 3.0.0    | x         | standard-3.0.0 | Karaf standard feature
-config     | 3.0.0    | x         | standard-3.0.0 | Provide OSGi ConfigAdmin support
-region     | 3.0.0    | x         | standard-3.0.0 | Provide Region Support
-package    | 3.0.0    | x         | standard-3.0.0 | Package commands and mbeans
-kar        | 3.0.0    | x         | standard-3.0.0 | Provide KAR (KARaf archive) support
-ssh        | 3.0.0    | x         | standard-3.0.0 | Provide a SSHd server on Karaf
-management | 3.0.0    | x         | standard-3.0.0 | Provide a JMX MBeanServer and a set of MBeans in K
+Name       | Version | Required | State   | Repository     | Description
+------------------------------------------------------------------------------------------------------------------------------
+feature    | 4.0.0   | x        | Started | standard-4.0.0 | Features Support
+shell      | 4.0.0   | x        | Started | standard-4.0.0 | Karaf Shell
+deployer   | 4.0.0   | x        | Started | standard-4.0.0 | Karaf Deployer
+bundle     | 4.0.0   | x        | Started | standard-4.0.0 | Provide Bundle support
+config     | 4.0.0   | x        | Started | standard-4.0.0 | Provide OSGi ConfigAdmin support
+diagnostic | 4.0.0   | x        | Started | standard-4.0.0 | Provide Diagnostic support
+instance   | 4.0.0   | x        | Started | standard-4.0.0 | Provide Instance support
+jaas       | 4.0.0   | x        | Started | standard-4.0.0 | Provide JAAS support
+log        | 4.0.0   | x        | Started | standard-4.0.0 | Provide Log support
+package    | 4.0.0   | x        | Started | standard-4.0.0 | Package commands and mbeans
+service    | 4.0.0   | x        | Started | standard-4.0.0 | Provide Service support
+system     | 4.0.0   | x        | Started | standard-4.0.0 | Provide System support
+kar        | 4.0.0   | x        | Started | standard-4.0.0 | Provide KAR (KARaf archive) support
+ssh        | 4.0.0   | x        | Started | standard-4.0.0 | Provide a SSHd server on Karaf
+management | 4.0.0   | x        | Started | standard-4.0.0 | Provide a JMX MBeanServer and a set of MBeans in
 {code}
 
 At login, the Apache Karaf console reads the {{etc/shell.init.script}} file where you can create your aliases.
@@ -262,40 +270,45 @@ You can pipe the output of one command as input to another one. It's a pipe, usi
 
 {code}
 karaf@root()> feature:list | grep -i war
-war                           | 3.0.0  |           | standard-3.0.0          | Turn Karaf as a full WebContainer
+war                           | 4.0.0  |           | standard-4.0.0          | Turn Karaf as a full WebContainer
 {code}
 
 h3. Grep, more, find, ...
 
 Karaf console provides some core commands similar to Unix environment:
 
-* {{shell:head}} displays the first line of the input
-* {{shell:source}} executes commands contained in a script
 * {{shell:alias}} creates an alias to an existing command
-* {{shell:history}} prints the commands history
 * {{shell:cat}} displays the content of a file or URL
-* {{shell:if}} allows you to use conditions (if, then, else blocks) in script
-* {{shell:tac}} captures stdin and returns it as a string
 * {{shell:clear}} clears the current console display
-* {{shell:info}} prints various information about the current Karaf instance
-* {{shell:tail}} displays the last lines of the input
 * {{shell:completion}} displays or change the current completion mode
-* {{shell:java}} executes a Java application
-* {{shell:threads}} prints the current thread
 * {{shell:date}} displays the current date (optionally using a format)
-* {{shell:watch}} periodically executes a command and refresh the output
 * {{shell:each}} executes a closure on a list of arguments
+* {{shell:echo}} echoes and prints arguments to stdout
+* {{shell:edit}} calls a text editor on the current file or URL
 * {{shell:env}} displays or sets the value of a shell session variable
+* {{shell:exec}} executes a system command
+* {{shell:grep}} prints lines matching the given pattern
+* {{shell:head}} displays the first line of the input
+* {{shell:history}} prints the commands history
+* {{shell:if}} allows you to use conditions (if, then, else blocks) in script
+* {{shell:info}} prints various information about the current Karaf instance
+* {{shell:java}} executes a Java application
+* {{shell:less}} file pager
+* {{shell:logout}} disconnects shell from current session
 * {{shell:more}} is a file pager
-* {{shell:wc}} prints newline, words, and byte counts for each file
-* {{shell:echo}} echoes and prints arguments to stdout
 * {{shell:new}} creates a new Java object
-* {{shell:edit}} calls a text editor on the current file or URL
 * {{shell:printf}} formats and prints arguments
-* {{shell:exec}} executes a system command
+* {{shell:tac}} captures stdin and returns it as a string
 * {{shell:sleep}} sleeps for a bit then wakes up
-* {{shell:grep}} prints lines matching the given pattern
 * {{shell:sort}} writes sorted concatenation of all files to stdout
+* {{shell:source}} executes commands contained in a script
+* {{shell:stack-traces-print}} prints the full stack trace in the console when the execution of a command throws an exception
+* {{shell:tac}} captures the STDIN and returns it as a string
+* {{shell:tail}} displays the last lines of the input
+* {{shell:threads}} prints the current thread
+* {{shell:watch}} periodically executes a command and refresh the output
+* {{shell:wc}} prints newline, words, and byte counts for each file
+* {{shell:while}} loop while the condition is true
 
 You don't have to use the fully qualified name of the command, you can directly use the command name as long as it is unique.
 So you can use 'head' instead of 'shell:head'


[4/4] karaf git commit: [KARAF-3633] Fix commands list not displaying commands descriptions

Posted by gn...@apache.org.
[KARAF-3633] Fix commands list not displaying commands descriptions


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/4cd9307c
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/4cd9307c
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/4cd9307c

Branch: refs/heads/master
Commit: 4cd9307cbb680fa8ead3fbd93b3a4d5e0b7c8364
Parents: b3a2a1c
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Wed Apr 29 10:38:29 2015 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Apr 30 09:50:17 2015 +0200

----------------------------------------------------------------------
 .../console/commands/help/CommandListHelpProvider.java    | 10 +++++++---
 .../impl/console/commands/help/ShellHelpProvider.java     |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/4cd9307c/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/CommandListHelpProvider.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/CommandListHelpProvider.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/CommandListHelpProvider.java
index 6612402..857f56e 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/CommandListHelpProvider.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/CommandListHelpProvider.java
@@ -129,9 +129,9 @@ public class CommandListHelpProvider implements HelpProvider {
             } else if (mode.equals("cyan")) {
                 cyan = true;
             } else if (mode.equals("indent")) {
-                indent = 4;
+                indent = 3;
             } else if (mode.startsWith("indent=")) {
-                indent = Integer.parseInt(mode.substring("indent=".length()));
+                indent = Integer.parseInt(mode.substring("indent=".length())) - 1;
             }
         }
 
@@ -158,7 +158,11 @@ public class CommandListHelpProvider implements HelpProvider {
             if (list) {
                 prefix += " *";
             }
-            table.addRow().addContent(prefix, key, entry.getValue());
+            if (indent > 0 || list) {
+                table.addRow().addContent(prefix, key, entry.getValue());
+            } else {
+                table.addRow().addContent(key, entry.getValue());
+            }
         }
         table.print(out, true);
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/4cd9307c/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/ShellHelpProvider.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/ShellHelpProvider.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/ShellHelpProvider.java
index 8285c3e..ab45585 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/ShellHelpProvider.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/commands/help/ShellHelpProvider.java
@@ -138,7 +138,7 @@ public class ShellHelpProvider implements HelpProvider {
         out.println("\t" + SimpleAnsi.INTENSITY_BOLD + path + SimpleAnsi.INTENSITY_NORMAL);
         out.println();
         out.println(SimpleAnsi.INTENSITY_BOLD + "COMMANDS" + SimpleAnsi.INTENSITY_NORMAL);
-        out.println("${command-list|" + path + "|embedded}");
+        out.println("${command-list|" + path + "|indent}");
     }
 
 }
\ No newline at end of file


[2/4] karaf git commit: [KARAF-3712] Small improvements to the xml repositories, add a method to serialise repositories as xml

Posted by gn...@apache.org.
[KARAF-3712] Small improvements to the xml repositories, add a method to serialise repositories as xml


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/9b65560a
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/9b65560a
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/9b65560a

Branch: refs/heads/master
Commit: 9b65560a9b4832bff2a09b3a932e6321488c95c8
Parents: 4cd9307
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Apr 30 09:49:03 2015 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Apr 30 09:50:17 2015 +0200

----------------------------------------------------------------------
 .../internal/repository/StaxParser.java         | 131 +++++++++++++++++--
 .../features/internal/repository/UrlLoader.java |   2 +-
 .../internal/repository/XmlRepository.java      |  25 +++-
 3 files changed, 139 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/9b65560a/features/core/src/main/java/org/apache/karaf/features/internal/repository/StaxParser.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/repository/StaxParser.java b/features/core/src/main/java/org/apache/karaf/features/internal/repository/StaxParser.java
index fccdb58..a7e8622 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/repository/StaxParser.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/repository/StaxParser.java
@@ -17,6 +17,7 @@
 package org.apache.karaf.features.internal.repository;
 
 import java.io.InputStream;
+import java.io.OutputStreamWriter;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -24,14 +25,18 @@ import java.util.Map;
 
 import javax.xml.stream.Location;
 import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.felix.utils.version.VersionTable;
 import org.apache.karaf.features.internal.resolver.CapabilityImpl;
 import org.apache.karaf.features.internal.resolver.RequirementImpl;
 import org.apache.karaf.features.internal.resolver.ResourceImpl;
 import org.osgi.framework.Version;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
 
 import static javax.xml.stream.XMLStreamConstants.CHARACTERS;
@@ -59,21 +64,116 @@ public final class StaxParser {
     public static final String VALUE = "value";
     public static final String TYPE = "type";
 
-    static XMLInputFactory factory;
+    public static final String REPOSITORY_NAMESPACE = "http://www.osgi.org/xmlns/repository/v1.0.0";
+
+    static XMLInputFactory inputFactory;
+    static XMLOutputFactory outputFactory;
 
     private StaxParser() {
     }
 
     public static class Referral {
-        String url;
-        int depth = Integer.MAX_VALUE;
+        public String url;
+        public int depth = Integer.MAX_VALUE;
     }
 
     public static class XmlRepository {
-        String name;
-        long increment;
-        List<Referral> referrals = new ArrayList<>();
-        List<Resource> resources = new ArrayList<>();
+        public String name;
+        public long increment;
+        public List<Referral> referrals = new ArrayList<>();
+        public List<Resource> resources = new ArrayList<>();
+    }
+
+    public static void write(XmlRepository repository, OutputStreamWriter os) throws XMLStreamException {
+        XMLStreamWriter writer = getOutputFactory().createXMLStreamWriter(os);
+        writer.writeStartDocument();
+        writer.setDefaultNamespace(REPOSITORY_NAMESPACE);
+        // repository element
+        writer.writeStartElement(REPOSITORY_NAMESPACE, REPOSITORY);
+        writer.writeAttribute("xmlns", REPOSITORY_NAMESPACE);
+        writer.writeAttribute(REPO_NAME, repository.name);
+        writer.writeAttribute(INCREMENT, Long.toString(repository.increment));
+        // referrals
+        for (Referral referral : repository.referrals) {
+            writer.writeStartElement(REPOSITORY_NAMESPACE, REFERRAL);
+            writer.writeAttribute(DEPTH, Integer.toString(referral.depth));
+            writer.writeAttribute(URL, referral.url);
+            writer.writeEndElement();
+        }
+        // resources
+        for (Resource resource : repository.resources) {
+            writer.writeStartElement(REPOSITORY_NAMESPACE, RESOURCE);
+            for (Capability cap : resource.getCapabilities(null)) {
+                writeClause(writer, CAPABILITY, cap.getNamespace(), cap.getDirectives(), cap.getAttributes());
+            }
+            for (Requirement req : resource.getRequirements(null)) {
+                writeClause(writer, REQUIREMENT, req.getNamespace(), req.getDirectives(), req.getAttributes());
+            }
+            writer.writeEndElement();
+        }
+        writer.writeEndDocument();
+        writer.flush();
+    }
+
+    private static void writeClause(XMLStreamWriter writer, String element, String namespace, Map<String, String> directives, Map<String, Object> attributes) throws XMLStreamException {
+        writer.writeStartElement(REPOSITORY_NAMESPACE, element);
+        writer.writeAttribute(NAMESPACE, namespace);
+        for (Map.Entry<String, String> dir : directives.entrySet()) {
+            writer.writeStartElement(REPOSITORY_NAMESPACE, DIRECTIVE);
+            writer.writeAttribute(NAME, dir.getKey());
+            writer.writeAttribute(VALUE, dir.getValue());
+            writer.writeEndElement();
+        }
+        for (Map.Entry<String, Object> att : attributes.entrySet()) {
+            String key = att.getKey();
+            Object val = att.getValue();
+            writer.writeStartElement(REPOSITORY_NAMESPACE, DIRECTIVE);
+            writer.writeAttribute(NAME, key);
+            if (val instanceof Version) {
+                writer.writeAttribute(TYPE, "Version");
+            } else if (val instanceof Long) {
+                writer.writeAttribute(TYPE, "Long");
+            } else if (val instanceof Double) {
+                writer.writeAttribute(TYPE, "Double");
+            } else if (val instanceof Iterable) {
+                Iterable it = (Iterable) att.getValue();
+                String scalar = null;
+                for (Object o : it) {
+                    String ts;
+                    if (o instanceof String) {
+                        ts = "String";
+                    } else if (o instanceof Long) {
+                        ts = "Long";
+                    } else if (o instanceof Double) {
+                        ts = "Double";
+                    } else if (o instanceof Version) {
+                        ts = "Version";
+                    } else {
+                        throw new IllegalArgumentException("Unsupported scalar type: " + o);
+                    }
+                    if (scalar == null) {
+                        scalar = ts;
+                    } else if (!scalar.equals(ts)) {
+                        throw new IllegalArgumentException("Unconsistent list type for attribute " + key);
+                    }
+                }
+                writer.writeAttribute(TYPE, "List<" + scalar + ">");
+                StringBuilder sb = new StringBuilder();
+                boolean first = true;
+                for (Object o : it) {
+                    if (first) {
+                        first = false;
+                    } else {
+                        sb.append(",");
+                    }
+                    sb.append(o.toString().replace(",", "\\,"));
+                }
+                val = sb.toString();
+            }
+            writer.writeAttribute(VALUE, val.toString());
+            writer.writeEndElement();
+        }
+        writer.writeEndElement();
     }
 
     public static XmlRepository parse(InputStream is) throws XMLStreamException {
@@ -81,7 +181,7 @@ public final class StaxParser {
     }
 
     public static XmlRepository parse(InputStream is, XmlRepository previous) throws XMLStreamException {
-        XMLStreamReader reader = getFactory().createXMLStreamReader(is);
+        XMLStreamReader reader = getInputFactory().createXMLStreamReader(is);
         int event = reader.nextTag();
         if (event != START_ELEMENT || !REPOSITORY.equals(reader.getLocalName())) {
             throw new IllegalStateException("Expected element 'repository' at the root of the document");
@@ -304,13 +404,20 @@ public final class StaxParser {
         }
     }
 
-    private static synchronized XMLInputFactory getFactory() {
-        if (StaxParser.factory == null) {
+    private static synchronized XMLInputFactory getInputFactory() {
+        if (StaxParser.inputFactory == null) {
             XMLInputFactory factory = XMLInputFactory.newInstance();
             factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
-            StaxParser.factory = factory;
+            StaxParser.inputFactory = factory;
+        }
+        return StaxParser.inputFactory;
+    }
+
+    private static synchronized XMLOutputFactory getOutputFactory() {
+        if (StaxParser.outputFactory == null) {
+            StaxParser.outputFactory = XMLOutputFactory.newInstance();
         }
-        return StaxParser.factory;
+        return StaxParser.outputFactory;
     }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/9b65560a/features/core/src/main/java/org/apache/karaf/features/internal/repository/UrlLoader.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/repository/UrlLoader.java b/features/core/src/main/java/org/apache/karaf/features/internal/repository/UrlLoader.java
index 640837a..123451c 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/repository/UrlLoader.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/repository/UrlLoader.java
@@ -58,7 +58,7 @@ public abstract class UrlLoader {
                 }
             }
             long lm = connection.getLastModified();
-            if (lm <= lastModified) {
+            if (lm > 0 && lm <= lastModified) {
                 return false;
             }
             try (

http://git-wip-us.apache.org/repos/asf/karaf/blob/9b65560a/features/core/src/main/java/org/apache/karaf/features/internal/repository/XmlRepository.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/repository/XmlRepository.java b/features/core/src/main/java/org/apache/karaf/features/internal/repository/XmlRepository.java
index 6661fb1..0cd3f9d 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/repository/XmlRepository.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/repository/XmlRepository.java
@@ -44,9 +44,9 @@ import static org.osgi.framework.namespace.IdentityNamespace.IDENTITY_NAMESPACE;
  */
 public class XmlRepository extends BaseRepository {
 
-    private final String url;
-    private final Map<String, XmlLoader> loaders = new HashMap<String, XmlLoader>();
-    private final ReadWriteLock lock = new ReentrantReadWriteLock();
+    final String url;
+    final Map<String, XmlLoader> loaders = new HashMap<String, XmlLoader>();
+    final ReadWriteLock lock = new ReentrantReadWriteLock();
 
     public XmlRepository(String url) {
         this.url = url;
@@ -64,6 +64,14 @@ public class XmlRepository extends BaseRepository {
         return super.findProviders(requirements);
     }
 
+    public String getUrl() {
+        return url;
+    }
+
+    protected Map<String, XmlLoader> getLoaders() {
+        return loaders;
+    }
+
     @Override
     protected void addResource(Resource resource) {
         List<Capability> identities = resource.getCapabilities(IDENTITY_NAMESPACE);
@@ -140,12 +148,17 @@ public class XmlRepository extends BaseRepository {
         return modified;
     }
 
-    static class XmlLoader extends UrlLoader {
+    protected static class XmlLoader extends UrlLoader {
 
-        StaxParser.XmlRepository xml;
+        protected StaxParser.XmlRepository xml;
+
+        public XmlLoader(String url) {
+            super(url);
+        }
 
-        XmlLoader(String url) {
+        public XmlLoader(String url, StaxParser.XmlRepository xml) {
             super(url);
+            this.xml = xml;
         }
 
         @Override


[3/4] karaf git commit: [manual] add doc about expressions in the shell

Posted by gn...@apache.org.
[manual] add doc about expressions in the shell


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/4aeed786
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/4aeed786
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/4aeed786

Branch: refs/heads/master
Commit: 4aeed7861244fb9d0548f7ad3987968d47fdf491
Parents: 9b65560
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Apr 30 09:49:50 2015 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Apr 30 09:50:17 2015 +0200

----------------------------------------------------------------------
 .../main/webapp/developers-guide/scripting.conf | 75 ++++++++++++++++++++
 manual/src/main/webapp/users-guide/console.conf | 11 +++
 2 files changed, 86 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/4aeed786/manual/src/main/webapp/developers-guide/scripting.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/developers-guide/scripting.conf b/manual/src/main/webapp/developers-guide/scripting.conf
index afe2135..9fce440 100644
--- a/manual/src/main/webapp/developers-guide/scripting.conf
+++ b/manual/src/main/webapp/developers-guide/scripting.conf
@@ -36,6 +36,79 @@ The {{$.context}} access the context variables in the current session.
 We access to the {{bundle}} variable (an array containing all bundles), and we want to display the bundle location for
 the bundle at the index 1 in the bundle array.
 
+h2. Expressions
+
+The shell has a built-in expression parser.  Expressions must be enclosed with the {{%(...)}} syntax.
+
+Examples:
+{code}
+karaf@root()> %(1+2)
+3
+karaf@root()> a = 0
+0
+karaf@root()> %(a+=1)
+1
+karaf@root()> %(a+=1)
+2
+karaf@root()> b=1
+1
+karaf@root()> %(SQRT(a^2 + b^2))
+1.7320508
+{code}
+
+h3. Mathematical Operators
+|| Operator || Description ||
+| + | Additive operator |
+| - | Subtraction operator |
+| * | Multiplication operator |
+| / | Division operator |
+| % | Remainder operator (Modulo) |
+| ^ | Power operator |
+
+h3. Boolean Operators
+|| Operator || Description ||
+| =    | Equals |
+| ==   | Equals |
+| !=   | Not equals |
+| <>   | Not equals |
+| <    | Less than |
+| <=   | Less than or equal to |
+| >    | Greater than |
+| >=   | Greater than or equal to |
+| &&   | Boolean and |
+| \|\| | Boolean or |
+
+h3. Supported Functions
+|| Function || Description ||
+| NOT(_expression_)             | Boolean negation, 1 (means true) if the expression is not zero |
+| IF(_condition_,_value_if_true_,_value_if_false_) | Returns one value if the condition evaluates to true or the other if it evaluates to false |
+| RANDOM()                      | Produces a random number between 0 and 1 |
+| MIN(_e1_,_e2_)                | Returns the smaller of both expressions |
+| MAX(_e1_,_e2_)                | Returns the bigger of both expressions |
+| ABS(_expression_)             | Returns the absolute (non-negative) value of the expression |
+| ROUND(_expression_,precision) | Rounds a value to a certain number of digits, uses the current rounding mode |
+| FLOOR(_expression_)           | Rounds the value down to the nearest integer |
+| CEILING(_expression_)         | Rounds the value up to the nearest integer |
+| LOG(_expression_)             | Returns the natural logarithm (base e) of an expression |
+| SQRT(_expression_)            | Returns the square root of an expression |
+| SIN(_expression_)             | Returns the trigonometric sine of an angle (in degrees) |
+| COS(_expression_)             | Returns the trigonometric cosine of an angle (in degrees) |
+| TAN(_expression_)             | Returns the trigonometric tangens of an angle (in degrees) |
+| SINH(_expression_)            | Returns the hyperbolic sine of a value |
+| COSH(_expression_)            | Returns the hyperbolic cosine of a value |
+| TANH(_expression_)            | Returns the hyperbolic tangens of a value |
+| RAD(_expression_)             | Converts an angle measured in degrees to an approximately equivalent angle measured in radians |
+| DEG(_expression_)             | Converts an angle measured in radians to an approximately equivalent angle measured in degrees |
+
+Functions names are case insensitive.
+
+h3. Supported Constants
+
+|| Constant || Description ||
+| PI        | The value of _PI_, exact to 100 digits |
+| TRUE      | The value one |
+| FALSE     | The value zero |
+
 h2. List, maps, pipes and closures
 
 Using [], you can define array variable:
@@ -119,6 +192,8 @@ Apache Karaf console provides commands for scripting:
 * {{shell:each}}
 * ...
 
+See the [full list of {{shell}} commands|/commands/commands].
+
 h2. Leveraging existing Java capabilities (via reflection)
 
 Apache Karaf console supports loading and execution of Java classes.

http://git-wip-us.apache.org/repos/asf/karaf/blob/4aeed786/manual/src/main/webapp/users-guide/console.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/users-guide/console.conf b/manual/src/main/webapp/users-guide/console.conf
index 5191a5e..d386b78 100644
--- a/manual/src/main/webapp/users-guide/console.conf
+++ b/manual/src/main/webapp/users-guide/console.conf
@@ -315,6 +315,17 @@ karaf@root()> list = [1 2 3]; each ($list) { echo $it }
 3
 {code}
 
+{tip}
+The same loop could be written with the {{shell:while}} command:
+
+{code}
+karaf@root()> a = 0 ; while { %((a+=1) <= 3) } { echo $a } 
+1
+2
+3
+{code}
+{tip}
+
 You can create the list yourself (as in the previous example), or some commands can return a list too.
 
 We can note that the console created a "session" variable with the name {{list}} that you can access with {{$list}}.