jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r164977 - in /incubator/jackrabbit/trunk/contrib/examples: ./ src/java/org/apache/jackrabbit/examples/ src/repo/
Date Wed, 27 Apr 2005 13:07:17 GMT
Author: jukka
Date: Wed Apr 27 06:07:16 2005
New Revision: 164977

URL: http://svn.apache.org/viewcvs?rev=164977&view=rev
Log:
examples: Initial support for running the examples. Need to update the docs soon.

Added:
    incubator/jackrabbit/trunk/contrib/examples/maven.xml   (with props)
    incubator/jackrabbit/trunk/contrib/examples/project.properties   (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/Main.java
  (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/firststeps.xml
  (with props)
    incubator/jackrabbit/trunk/contrib/examples/src/repo/
    incubator/jackrabbit/trunk/contrib/examples/src/repo/jaas.config
    incubator/jackrabbit/trunk/contrib/examples/src/repo/repository.xml   (with props)
Modified:
    incubator/jackrabbit/trunk/contrib/examples/project.xml
    incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/FirstSteps.java

Added: incubator/jackrabbit/trunk/contrib/examples/maven.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/maven.xml?rev=164977&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/maven.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/maven.xml Wed Apr 27 06:07:16 2005
@@ -0,0 +1,34 @@
+<!--
+   Copyright 2004-2005 The Apache Software Foundation or its licensors,
+                       as applicable.
+
+   Licensed 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 default="run" xmlns:j="jelly:core" xmlns:ant="jelly:ant">
+
+  <goal name="run" prereqs="java:compile">
+    <ant:mkdir dir="${maven.build.dir}/repo"/>
+    <ant:copy todir="${maven.build.dir}/repo">
+      <ant:fileset dir="${maven.src.dir}/repo"/>
+    </ant:copy>
+    <ant:java classname="org.apache.jackrabbit.examples.Main" fork="true">
+      <ant:jvmarg value="-Djava.security.auth.login.config==${maven.build.dir}/repo/jaas.config"/>
+      <ant:classpath>
+        <ant:path refid="maven.dependency.classpath"/>
+        <ant:pathelement path="${maven.build.dest}"/>
+      </ant:classpath>
+    </ant:java>
+  </goal>
+
+</project>

Propchange: incubator/jackrabbit/trunk/contrib/examples/maven.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/project.properties?rev=164977&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/project.properties (added)
+++ incubator/jackrabbit/trunk/contrib/examples/project.properties Wed Apr 27 06:07:16 2005
@@ -0,0 +1 @@
+maven.jar.mainclass=org.apache.jackrabbit.examples.Main

Propchange: incubator/jackrabbit/trunk/contrib/examples/project.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/jackrabbit/trunk/contrib/examples/project.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/project.xml?rev=164977&r1=164976&r2=164977&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/project.xml (original)
+++ incubator/jackrabbit/trunk/contrib/examples/project.xml Wed Apr 27 06:07:16 2005
@@ -21,7 +21,7 @@
   <pomVersion>3</pomVersion>
   <id>jackrabbit-examples</id>
   <name>Jackrabbit Examples</name>
-  <currentVersion>0.16.2-dev</currentVersion>
+  <currentVersion>0.16.4</currentVersion>
   <organization>
     <name>The Apache Software Foundation</name>
     <url>http://incubator.apache.org/projects/jackrabbit.html</url>

Modified: incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/FirstSteps.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/FirstSteps.java?rev=164977&r1=164976&r2=164977&view=diff
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/FirstSteps.java
(original)
+++ incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/FirstSteps.java
Wed Apr 27 06:07:16 2005
@@ -16,7 +16,7 @@
  */
 package org.apache.jackrabbit.examples;
 
-import org.apache.jackrabbit.core.jndi.RegistryHelper;
+import java.io.InputStream;
 
 import javax.jcr.ImportUUIDBehavior;
 import javax.jcr.Node;
@@ -29,26 +29,27 @@
 import javax.jcr.SimpleCredentials;
 import javax.jcr.StringValue;
 import javax.jcr.Value;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Hashtable;
 
 /**
  * The First Steps example class.
  */
 public class FirstSteps {
 
+    private final Repository repository;
+
+    public FirstSteps(Repository repository) {
+        this.repository = repository;
+    }
+
     /**
      * Run the First Steps example.
      *
      * @param args command line arguments (ignored)
      */
-    public static void main(String[] args) {
+    public void run() {
         try {
-            Repository repository = getRepository();
-            SimpleCredentials creds = new SimpleCredentials("username", "password".toCharArray());
+            SimpleCredentials creds =
+                new SimpleCredentials("username", "password".toCharArray());
             Session session = repository.login(creds);
             Node root = session.getRootNode();
 
@@ -64,7 +65,9 @@
             if (!root.hasNode("importxml")) {
                 System.out.println("importing xml");
                 Node node = root.addNode("importxml", "nt:unstructured");
-                InputStream xml = new FileInputStream("repotest/test.xml");
+                InputStream xml =
+                    getClass().getClassLoader().getResourceAsStream(
+                            "org/apache/jackrabbit/examples/firststeps.xml");
                 session.importXML(
                         "/importxml", xml, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
                 session.save();
@@ -74,26 +77,6 @@
         } catch (Exception e) {
             System.err.println(e);
         }
-    }
-
-    /**
-     * Creates a Repository instance to be used by the example class.
-     *
-     * @return repository instance
-     * @throws Exception on errors
-     */
-    private static Repository getRepository() throws Exception {
-        String configFile = "repotest/repository.xml";
-        String repHomeDir = "repotest";
-
-        Hashtable env = new Hashtable();
-        env.put(Context.INITIAL_CONTEXT_FACTORY,
-                "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
-        env.put(Context.PROVIDER_URL, "localhost");
-        InitialContext ctx = new InitialContext(env);
-
-        RegistryHelper.registerRepository(ctx, "repo", configFile, repHomeDir, true);
-        return (Repository) ctx.lookup("repo");
     }
 
     /**

Added: incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/Main.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/Main.java?rev=164977&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/Main.java
(added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/Main.java
Wed Apr 27 06:07:16 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2004-2005 The Apache Software Foundation or its licensors,
+ *                     as applicable.
+ *
+ * Licensed 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.jackrabbit.examples;
+
+import java.util.Hashtable;
+
+import javax.jcr.Repository;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.jackrabbit.core.jndi.RegistryHelper;
+
+/**
+ * TODO
+ */
+public class Main {
+
+    /**
+     * Creates a Repository instance to be used by the example class.
+     *
+     * @return repository instance
+     * @throws Exception on errors
+     */
+    private static Repository getRepository() throws Exception {
+        String configFile = "target/repo/repository.xml";
+        String repHomeDir = "target/repo";
+
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");
+        env.put(Context.PROVIDER_URL, "localhost");
+        InitialContext ctx = new InitialContext(env);
+
+        RegistryHelper.registerRepository(ctx, "repo", configFile, repHomeDir, true);
+        return (Repository) ctx.lookup("repo");
+    }
+
+    public static void main(String[] args) {
+        try {
+            new FirstSteps(getRepository()).run();
+        } catch (Throwable e) {
+            e.printStackTrace();
+        }
+    }
+
+}

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/Main.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/firststeps.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/firststeps.xml?rev=164977&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/firststeps.xml
(added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/firststeps.xml
Wed Apr 27 06:07:16 2005
@@ -0,0 +1,50 @@
+<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
+            xmlns:mathml="http://www.w3.org/1998/Math/MathML">
+  <xhtml:head><xhtml:title>Three Namespaces</xhtml:title></xhtml:head>
+  <xhtml:body>
+    <xhtml:h1 align="center">An Ellipse and a Rectangle</xhtml:h1>
+    <svg:svg xmlns:svg="http://www.w3.org/2000/svg" 
+             width="12cm" height="10cm">
+      <svg:ellipse rx="110" ry="130" />
+      <svg:rect x="4cm" y="1cm" width="3cm" height="6cm" />
+    </svg:svg>
+    <xhtml:p>The equation for ellipses</xhtml:p>
+<mathml:math>
+  <mathml:apply>
+    <mathml:eq/>
+    <mathml:cn> 1 </mathml:cn>
+    <mathml:apply>
+      <mathml:plus/>
+      <mathml:apply>
+        <mathml:divide/>
+        <mathml:apply>
+          <mathml:power/>
+          <mathml:ci> x </mathml:ci>
+          <mathml:cn> 2 </mathml:cn>
+        </mathml:apply>
+        <mathml:apply>
+          <mathml:power/>
+          <mathml:ci> a </mathml:ci>
+          <mathml:cn> 2 </mathml:cn>
+        </mathml:apply>
+      </mathml:apply>
+      <mathml:apply>
+        <mathml:divide/>
+        <mathml:apply>
+          <mathml:power/>
+          <mathml:ci> y </mathml:ci>
+          <mathml:cn> 2 </mathml:cn>
+        </mathml:apply>
+        <mathml:apply>
+          <mathml:power/>
+          <mathml:ci> b </mathml:ci>
+          <mathml:cn> 2 </mathml:cn>
+        </mathml:apply>        
+      </mathml:apply>
+    </mathml:apply>
+ </mathml:apply>
+</mathml:math>
+    <xhtml:hr/>
+    <xhtml:p>Last Modified January 10, 2002</xhtml:p>    
+  </xhtml:body>
+</xhtml:html>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/java/org/apache/jackrabbit/examples/firststeps.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/jackrabbit/trunk/contrib/examples/src/repo/jaas.config
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/repo/jaas.config?rev=164977&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/repo/jaas.config (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/repo/jaas.config Wed Apr 27 06:07:16 2005
@@ -0,0 +1,3 @@
+Jackrabbit {
+org.apache.jackrabbit.core.security.SimpleLoginModule required anonymousId="anonymous";
+};

Added: incubator/jackrabbit/trunk/contrib/examples/src/repo/repository.xml
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/contrib/examples/src/repo/repository.xml?rev=164977&view=auto
==============================================================================
--- incubator/jackrabbit/trunk/contrib/examples/src/repo/repository.xml (added)
+++ incubator/jackrabbit/trunk/contrib/examples/src/repo/repository.xml Wed Apr 27 06:07:16
2005
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<Repository>
+    <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+        <param name="path" value="${rep.home}/repository"/>
+    </FileSystem>
+    <Security appName="Jackrabbit">
+        <AccessManager class="org.apache.jackrabbit.core.security.SimpleAccessManager"/>
+    </Security>
+    <Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default" />
+    <Workspace name="${wsp.name}">
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${wsp.home}"/>
+        </FileSystem>
+        <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager"
/>
+        <SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex">
+            <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+                <param name="path" value="${wsp.home}/index"/>
+            </FileSystem>
+        </SearchIndex>
+    </Workspace>
+    <Versioning rootPath="${rep.home}/versions">
+        <FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem">
+            <param name="path" value="${rep.home}/versions"/>
+        </FileSystem>
+        <PersistenceManager class="org.apache.jackrabbit.core.state.xml.XMLPersistenceManager"
/>
+    </Versioning>
+</Repository>

Propchange: incubator/jackrabbit/trunk/contrib/examples/src/repo/repository.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message