[dna-commits] DNA SVN: r979 - in trunk: dna-repository/src/main/java/org/jboss/dna/repository and 5 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Jun 4 22:20:41 EDT 2009


Author: rhauch
Date: 2009-06-04 22:20:41 -0400 (Thu, 04 Jun 2009)
New Revision: 979

Added:
   trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/
   trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/jaas.conf.xml
   trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/roles.properties
   trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/users.properties
   trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd
Modified:
   trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
   trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
   trunk/docs/examples/gettingstarted/repositories/pom.xml
   trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/ConsoleInput.java
   trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java
   trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/UserInterface.java
   trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.cnd
   trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
   trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
Log:
DNA-389 Changed the repository example to use the new configuration.  It's not quite complete.

Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrEngine.java	2009-06-05 02:20:41 UTC (rev 979)
@@ -23,8 +23,11 @@
  */
 package org.jboss.dna.jcr;
 
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 import javax.jcr.Repository;
@@ -93,6 +96,21 @@
         }
     }
 
+    /**
+     * Get the names of the JCR repositories.
+     * 
+     * @return the immutable names of the repositories that exist at the time this method is called
+     */
+    public Set<String> getRepositoryNames() {
+        checkRunning();
+        try {
+            repositoriesLock.lock();
+            return Collections.unmodifiableSet(new HashSet<String>(repositories.keySet()));
+        } finally {
+            repositoriesLock.unlock();
+        }
+    }
+
     protected JcrRepository doCreateJcrRepository( String repositoryName ) throws RepositoryException, PathNotFoundException {
         RepositoryConnectionFactory connectionFactory = getRepositoryConnectionFactory();
         Map<String, String> descriptors = null;

Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/DnaEngine.java	2009-06-05 02:20:41 UTC (rev 979)
@@ -194,8 +194,26 @@
      */
     public final Graph getGraph( String sourceName ) {
         CheckArg.isNotNull(sourceName, "sourceName");
+        return getGraph(getExecutionContext(), sourceName);
+    }
+
+    /**
+     * Get a graph to the underlying source, using the supplied context. Note that the supplied context should be a derivative of
+     * the engine's {@link #getExecutionContext() context}.
+     * 
+     * @param context the context of execution for this graph; may not be null
+     * @param sourceName the name of the source
+     * @return the graph
+     * @throws IllegalArgumentException if the context or source name are null
+     * @throws RepositorySourceException if a source with the supplied name does not exist
+     * @throws IllegalStateException if this engine was not {@link #start() started}
+     */
+    public final Graph getGraph( ExecutionContext context,
+                                 String sourceName ) {
+        CheckArg.isNotNull(context, "context");
+        CheckArg.isNotNull(sourceName, "sourceName");
         checkRunning();
-        Graph graph = Graph.create(sourceName, getRepositoryService().getRepositoryLibrary(), getExecutionContext());
+        Graph graph = Graph.create(sourceName, getRepositoryService().getRepositoryLibrary(), context);
         if (configuration.getRepositorySource().getName().equals(sourceName) && configuration.getWorkspace() != null) {
             // set the workspace ...
             graph.useWorkspace(configuration.getWorkspace());

Modified: trunk/docs/examples/gettingstarted/repositories/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/pom.xml	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/docs/examples/gettingstarted/repositories/pom.xml	2009-06-05 02:20:41 UTC (rev 979)
@@ -30,22 +30,10 @@
     </dependency>
     <dependency>
       <groupId>org.jboss.dna</groupId>
-      <artifactId>dna-common</artifactId>
-      <version>${pom.version}</version>
-      <scope>compile</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.dna</groupId>
       <artifactId>dna-connector-jbosscache</artifactId>
       <version>${pom.version}</version>
       <scope>runtime</scope>
     </dependency>
-    <dependency>
-      <groupId>org.jboss.dna</groupId>
-      <artifactId>dna-connector-federation</artifactId>
-      <version>${pom.version}</version>
-      <scope>runtime</scope>
-    </dependency>
     <!-- 
     Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for testing) 
     -->
@@ -69,6 +57,34 @@
       <artifactId>jcr</artifactId>
     </dependency>
     <!-- 
+      JAAS implementation (and dependencies)
+    -->
+    <dependency>
+        <groupId>org.jboss.security</groupId>
+        <artifactId>jboss-idtrust</artifactId>
+        <version>2.0.2.CR1</version>
+    </dependency>
+    <dependency>
+        <groupId>org.jboss.security</groupId>
+        <artifactId>jboss-security-spi-bare</artifactId>
+        <version>2.0.2.SP6</version>
+    </dependency>
+    <dependency>
+        <groupId>org.jboss.security</groupId>
+        <artifactId>jbosssx-bare</artifactId>
+        <version>2.0.2.SP6</version>
+        <exclusions>
+            <exclusion>
+                <groupId>apache-xalan</groupId>
+                <artifactId>xalan</artifactId>
+            </exclusion>
+            <exclusion>
+                <groupId>apache-xalan</groupId>
+                <artifactId>serializer</artifactId>
+            </exclusion>
+        </exclusions>
+    </dependency>
+    <!-- 
       Test cases use JUnit
     -->
     <dependency>

Modified: trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/ConsoleInput.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/ConsoleInput.java	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/ConsoleInput.java	2009-06-05 02:20:41 UTC (rev 979)
@@ -274,8 +274,8 @@
      * @param activity the activity; may not be null but may be empty
      * @param t the exception; may not be null
      */
-    protected void displayError( String activity,
-                                 Throwable t ) {
+    public void displayError( String activity,
+                              Throwable t ) {
         assert activity != null;
         assert t != null;
         System.err.println();
@@ -303,6 +303,24 @@
     /**
      * {@inheritDoc}
      * 
+     * @see org.jboss.example.dna.repository.UserInterface#getRepositoryConfiguration()
+     */
+    public File getRepositoryConfiguration() {
+        return new File("configRepository.xml");
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.jboss.example.dna.repository.UserInterface#getLocationOfCndFiles()
+     */
+    public String getLocationOfCndFiles() {
+        return new File("").getAbsolutePath();
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
      * @see org.jboss.example.dna.repository.UserInterface#getCallbackHandler()
      */
     public CallbackHandler getCallbackHandler() {

Modified: trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/RepositoryClient.java	2009-06-05 02:20:41 UTC (rev 979)
@@ -37,7 +37,6 @@
 import javax.jcr.PropertyIterator;
 import javax.jcr.Session;
 import javax.jcr.Value;
-import javax.naming.NamingException;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 import net.jcip.annotations.Immutable;
@@ -46,14 +45,14 @@
 import org.jboss.dna.graph.ExecutionContext;
 import org.jboss.dna.graph.Graph;
 import org.jboss.dna.graph.Location;
-import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
 import org.jboss.dna.graph.property.Path;
 import org.jboss.dna.graph.property.PathFactory;
 import org.jboss.dna.graph.property.PathNotFoundException;
 import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.jcr.JcrConfiguration;
+import org.jboss.dna.jcr.JcrEngine;
 import org.jboss.dna.jcr.JcrRepository;
-import org.jboss.dna.repository.RepositoryLibrary;
-import org.jboss.dna.repository.RepositoryService;
+import org.jboss.security.config.IDTrustConfiguration;
 import org.xml.sax.SAXException;
 
 /**
@@ -68,6 +67,15 @@
      * @param args
      */
     public static void main( String[] args ) {
+        // Set up the JAAS provider (IDTrust) and a policy file (which defines the "dna-jcr" login config name)
+        IDTrustConfiguration idtrustConfig = new IDTrustConfiguration();
+        try {
+            idtrustConfig.config("security/jaas.conf.xml");
+        } catch (Exception ex) {
+            throw new IllegalStateException(ex);
+        }
+
+        // Now configure the repository client component ...
         RepositoryClient client = new RepositoryClient();
         for (String arg : args) {
             arg = arg.trim();
@@ -76,6 +84,8 @@
             if (arg.equals("--jaas")) client.setJaasContextName(JAAS_LOGIN_CONTEXT_NAME);
             if (arg.startsWith("--jaas=") && arg.length() > 7) client.setJaasContextName(arg.substring(7).trim());
         }
+
+        // And have it use a ConsoleInput user interface ...
         client.setUserInterface(new ConsoleInput(client, args));
     }
 
@@ -84,13 +94,12 @@
         DNA;
     }
 
-    private RepositoryLibrary sources;
-    private RepositoryService repositoryService;
     private Api api = Api.JCR;
     private String jaasContextName;
     private UserInterface userInterface;
     private LoginContext loginContext;
     private ExecutionContext context;
+    private JcrEngine engine;
 
     /**
      * @param userInterface Sets userInterface to the specified value.
@@ -118,65 +127,51 @@
     }
 
     /**
-     * Start up the repositories. This method creates the necessary components and services, and initializes the in-memory
-     * repositories.
+     * Start up the repositories. This method loads the configuration, then creates the engine and starts it.
      * 
      * @throws IOException if there is a problem initializing the repositories from the files.
      * @throws SAXException if there is a problem with the SAX Parser
-     * @throws NamingException if there is a problem registering or looking up objects in JNDI
      */
-    public void startRepositories() throws IOException, SAXException, NamingException {
-        if (repositoryService != null) return; // already started
+    public void startRepositories() throws IOException, SAXException {
+        if (engine != null) return; // already started
 
-        // Create the execution context that we'll use for the services. If we'd want to use JAAS, we'd create the context
-        // by supplying LoginContext, AccessControlContext, or even Subject with CallbackHandlers. But no JAAS in this example.
-        context = new ExecutionContext();
+        // Load the configuration from a file, as provided by the user interface ...
+        JcrConfiguration configuration = new JcrConfiguration();
+        configuration.loadFrom(userInterface.getRepositoryConfiguration());
 
-        // Create the library for the RepositorySource instances ...
-        sources = new RepositoryLibrary(context);
+        // Load the node types for each JCR repository, via a CND file. These could have been defined
+        // in the configuration file, but this approach is easy and allows us to define the node types
+        // using the CND format in one or multiple files.
+        String locationOfCndFiles = userInterface.getLocationOfCndFiles();
+        configuration.repository("aircraft repository").addNodeTypes(locationOfCndFiles + "/aircraft.cnd");
+        configuration.repository("car repository").addNodeTypes(locationOfCndFiles + "/cars.cnd");
+        configuration.repository("virtual").addNodeTypes(locationOfCndFiles + "/virtual.cnd");
 
-        // Load into the source manager the repository source for the configuration repository ...
-        InMemoryRepositorySource configSource = new InMemoryRepositorySource();
-        configSource.setName("Configuration");
-        configSource.setDefaultWorkspaceName("default");
-        sources.addSource(configSource);
+        // Now create the JCR engine ...
+        engine = configuration.build();
+        engine.start();
 
         // For this example, we're using a couple of in-memory repositories (including one for the configuration repository).
         // Normally, these would exist already and would simply be accessed. But in this example, we're going to
         // populate these repositories here by importing from files. First do the configuration repository ...
         String location = this.userInterface.getLocationOfRepositoryFiles();
-        Graph config = Graph.create("Configuration", sources, context);
-        config.useWorkspace("default");
-        config.importXmlFrom(location + "/configRepository.xml").into("/");
 
-        // Now instantiate the Repository Service ...
-        Path configRoot = context.getValueFactories().getPathFactory().create("/jcr:system");
-        repositoryService = new RepositoryService(sources, configSource.getName(), "default", configRoot, context);
-        repositoryService.getAdministrator().start();
-
-        // Now import the conten for two of the other in-memory repositories ...
-        Graph cars = Graph.create("Cars", sources, context);
+        // Now import the content for the two in-memory repositories ...
+        Graph cars = engine.getGraph("Cars");
         cars.importXmlFrom(location + "/cars.xml").into("/");
-
-        Graph aircraft = Graph.create("Aircraft", sources, context);
+        Graph aircraft = engine.getGraph("Aircraft");
         aircraft.importXmlFrom(location + "/aircraft.xml").into("/");
-
-        Graph vehicles = Graph.create("Vehicles", sources, context);
-        vehicles.create("/Vehicles");
-        vehicles.importXmlFrom(location + "/cars.xml").into("/Vehicles");
-        vehicles.importXmlFrom(location + "/aircraft.xml").into("/Vehicles");
-    
     }
 
     /**
      * Get the names of the repositories.
      * 
-     * @return the repository names
+     * @return the sorted but immutable list of repository names; never null
      */
     public List<String> getNamesOfRepositories() {
-        List<String> names = new ArrayList<String>(sources.getSourceNames());
+        List<String> names = new ArrayList<String>(engine.getRepositoryNames());
         Collections.sort(names);
-        return names;
+        return Collections.unmodifiableList(names);
     }
 
     /**
@@ -187,17 +182,13 @@
      */
     public void shutdown() throws InterruptedException, LoginException {
         logout();
-        if (repositoryService == null) return;
+        if (engine == null) return;
         try {
-            // Shut down the various services ...
-            repositoryService.getAdministrator().shutdown();
-
-            // Shut down the manager of the RepositorySource instances, waiting until all connections are closed
-            sources.getAdministrator().shutdown();
-            sources.getAdministrator().awaitTermination(1, TimeUnit.SECONDS);
+            // Tell the engine to shut down, and then wait up to 5 seconds for it to complete...
+            engine.shutdown();
+            engine.awaitTermination(5, TimeUnit.SECONDS);
         } finally {
-            repositoryService = null;
-            sources = null;
+            engine = null;
         }
     }
 
@@ -251,13 +242,14 @@
         LoginContext loginContext = getLoginContext(); // will ask user to authenticate if needed
         switch (api) {
             case JCR: {
-                JcrRepository jcrRepository = new JcrRepository(context, sources, sourceName);
+                JcrRepository jcrRepository = engine.getRepository(sourceName);
                 Session session = null;
                 if (loginContext != null) {
+                    // Could also use SimpleCredentials(username,password) too
                     Credentials credentials = new JaasCredentials(loginContext);
-                    session = jcrRepository.login(credentials, "default");
+                    session = jcrRepository.login(credentials);
                 } else {
-                    session = jcrRepository.login("default");
+                    session = jcrRepository.login();
                 }
                 try {
                     // Make the path relative to the root by removing the leading slash(es) ...
@@ -315,7 +307,7 @@
                 try {
                     // Use the DNA Graph API to read the properties and children of the node ...
                     ExecutionContext context = loginContext != null ? this.context.create(loginContext) : this.context;
-                    Graph graph = Graph.create(sourceName, sources, context);
+                    Graph graph = engine.getGraph(context, sourceName);
                     graph.useWorkspace("default");
                     org.jboss.dna.graph.Node node = graph.getNodeAt(pathToNode);
 
@@ -350,8 +342,8 @@
      * @param input the input path
      * @return the resulting full and normalized path
      */
-    protected String buildPath( String current,
-                                String input ) {
+    public String buildPath( String current,
+                             String input ) {
         if (current == null) current = "/";
         if (input == null || input.length() == 0) return current;
         PathFactory factory = context.getValueFactories().getPathFactory();

Modified: trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/UserInterface.java
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/UserInterface.java	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/java/org/jboss/example/dna/repository/UserInterface.java	2009-06-05 02:20:41 UTC (rev 979)
@@ -23,6 +23,7 @@
  */
 package org.jboss.example.dna.repository;
 
+import java.io.File;
 import javax.security.auth.callback.CallbackHandler;
 
 /**
@@ -32,6 +33,13 @@
 
     String getLocationOfRepositoryFiles();
 
+    File getRepositoryConfiguration();
+
+    String getLocationOfCndFiles();
+
     CallbackHandler getCallbackHandler();
 
+    void displayError( String activity,
+                       Throwable t );
+
 }

Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.cnd
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.cnd	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/cars.cnd	2009-06-05 02:20:41 UTC (rev 979)
@@ -47,4 +47,3 @@
   - car:lengthInInches (double) < '(0,]'                   // any value greater than 0
   - car:wheelbaseInInches (double) < '(0,]'                // any value greater than 0
   - car:engine (string)
-

Modified: trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/configRepository.xml	2009-06-05 02:20:41 UTC (rev 979)
@@ -25,44 +25,128 @@
   ~ Boston, MA  02110-1301  USA
   -->
 <configuration xmlns="http://www.jboss.org/dna/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
-    <!-- Define the sources from which content is made available -->
-    <sources jcr:primaryType="nt:unstructured">
-        <source jcr:name="Cars" classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource" retryLimit="3" defaultWorkspaceName="default"/>
-        <source jcr:name="Aircraft" classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource">
-            <defaultWorkspaceName>default</defaultWorkspaceName>
-        </source>
-        <source jcr:name="Vehicles">
-            <classname>org.jboss.dna.graph.connector.federated.FederatedRepositorySource</classname>
-            <workspaces>
-                <workspace jcr:name="default">
-                    <projections>
-                        <projection jcr:name="Main projection" source="Cars" workspace="default">
-                            <projectionRules>/Vehicles => /</projectionRules>
-                        </projection>
-                    </projections>
-                </workspace>
-            </workspaces>
-        </source>
-        <source jcr:name="Cache" classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource">
-            <defaultWorkspaceName>default</defaultWorkspaceName>
-        </source>
-    </sources>
-    <!-- Define the JCR repositories -->
-    <repositories>
-        <repository jcr:name="cars">
+    <!-- 
+    Define the sources for the content.  These sources are directly accessible using the DNA-specific Graph API.
+    In fact, this is how the DNA JCR implementation works.  You can think of these as being similar to
+    JDBC DataSource objects, except that they expose graph content via the Graph API instead of records via SQL or JDBC. 
+    -->
+    <dna:sources jcr:primaryType="nt:unstructured">
+        <!-- 
+        The 'Cars' repository is an in-memory source with a single default workspace (though others could be created, too).
+        -->
+        <dna:source jcr:name="Cars" dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource" dna:retryLimit="3" dna:defaultWorkspaceName="workspace1"/>
+        <!-- 
+        The 'Aircraft' repository is also an in-memory source with a single default workspace.
+        By defining a default workspace, the clients using the Graph API will by default use that workspace,
+        but can easily say to use other workspaces (or create, clone, or destroy workspaces).
+        -->
+        <dna:source jcr:name="Aircraft" dna:classname="org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource">
+            <!-- Define the name of the workspace used by default.  Optional, but convenient. -->
+            <defaultWorkspaceName>workspace2</defaultWorkspaceName>
+        </dna:source>
+        <!-- 
+        The 'Vehicles' repository is a federated source that owns none of its own content, but instead
+        projects (in this case) all of the content from the 'Cars' source as if it appears
+        under '/Vehicles/Cars', while all the 'Aircraft' content appears under '/Vehicles/Aircraft'.
+        -->
+        <dna:source jcr:name="Vehicles">
+            <dna:classname>org.jboss.dna.graph.connector.federated.FederatedRepositorySource</dna:classname>
+            <dna:workspaces>
+                <!-- 
+                Unlike some other repository sources, federated sources have to define all of their workspaces,
+                including how and where the content is projected.  So, we only need a single workspace,
+                but we could actually define additional workspaces that expose various combinations or portions
+                of 'Cars' and/or 'Aircraft' content.
+                -->
+                <dna:workspace jcr:name="virtual">
+                    <dna:projections>
+                        <!-- Project the 'Cars' content, starting with the '/Cars' node. -->
+                        <dna:projection jcr:name="Cars projection" dna:source="Cars" dna:workspace="workspace1">
+                            <dna:projectionRules>/Vehicles/Cars => /Cars</dna:projectionRules>
+                        </dna:projection>
+                        <!-- Project the 'Aicraft' content, starting with the '/Aircraft' node. -->
+                        <dna:projection jcr:name="Aircarft projection" dna:source="Aircraft" dna:workspace="workspace2">
+                            <dna:projectionRules>/Vehicles/Aircraft => /Aircraft</dna:projectionRules>
+                        </dna:projection>
+                    </dna:projections>
+                </dna:workspace>
+            </dna:workspaces>
+        </dna:source>
+    </dna:sources>
+    <!-- 
+    Define the sequencers. This is an optional section. For this example, we're not using any sequencers. 
+    -->
+    <dna:sequencers>
+        <!--dna:sequencer jcr:name="Image Sequencer" dna:classname="org.jboss.dna.sequencer.image.ImageMetadataSequencer">
+            <dna:description>Image metadata sequencer</dna:description>        
+            <dna:pathExpression>/foo/source => /foo/target</dna:pathExpression>
+            <dna:pathExpression>/bar/source => /bar/target</dna:pathExpression>
+        </dna:sequencer-->
+    </dna:sequencers>
+    <!-- 
+    Define the mime type detectors. This is an optional section.  By default, each engine will use the 
+    MIME type detector that uses filename extensions.  So we wouldn't need to define the same detector again,
+    but this is how you'd define another extension.
+    -->
+    <dna:mimeTypeDetectors>
+        <dna:mimeTypeDetector jcr:name="Detector">
+            <dna:description>Standard extension-based MIME type detector</dna:description>        
+            <!-- 
+            Specify the implementation class (required), as a child element or attribute on parent element.
+            -->
+            <dna:classname>org.jboss.dna.graph.mimetype.ExtensionBasedMimeTypeDetector</dna:classname>
+            <!-- 
+            Specify the classpath (optional) as an ordered list of 'names', where each name is significant to 
+            the classpath factory.  For example, a name could be an OSGI identifier or a Maven coordinate,
+            depending upon the classpath factory being used.  If there is only one 'name' in the classpath,
+            it may be specified as an attribute on the 'mimeTypeDetector' element.  If there is more than one
+            'name', then they must be specified as child 'classpath' elements. Blank or empty values are ignored. 
+             -->
+            <dna:classpath></dna:classpath>
+            <dna:classpath></dna:classpath>
+        </dna:mimeTypeDetector>
+    </dna:mimeTypeDetectors>
+    <!-- 
+    Define the JCR repositories 
+    -->
+    <dna:repositories>
+        <!-- 
+        Define a JCR repository that accesses the 'Cars' source directly.
+        This of course is optional, since we could access the same content through 'vehicles'.
+        -->
+        <dna:repository jcr:name="car repository">
             <!-- Specify the source that should be used for the repository -->
             <source>Cars</source>
             <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
             <options jcr:primaryType="dna:options"/>
+                <jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
+            </options>
             <!-- Define any custom node types. Importing CND files via JcrConfiguration is equivalent to specifying here. -->
             <nodeTypes jcr:primaryType="dna:nodeTypes"/>
             <!-- Define any namespaces for this repository, other than those already defined by JCR or DNA -->
             <namespaces jcr:primaryType="dna:namespaces">
                 <car jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/cars/1.0"/>
             </namespaces>
-        </repository>
-        <repository jcr:name="vehicles">
+        </dna:repository>
+        <!-- 
+        Define a JCR repository that accesses the 'Aircraft' source directly.
+        This of course isn't really necessary for this example, since we could access the same content through 'vehicles'.
+        -->
+        <dna:repository jcr:name="aircraft repository">
             <!-- Specify the source that should be used for the repository -->
+            <source>Aircraft</source>
+            <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
+            <options jcr:primaryType="dna:options"/>
+                <jaasLoginConfigName jcr:primaryType="dna:option" dna:value="dna-jcr"/>
+            </options>
+        </dna:repository>
+        <!-- 
+        Define a JCR repository that accesses the 'Vehicles' federated source directly,
+        which is defined in the sources to be a projection of the 'Cars' and 'Vehicles' content.
+        -->
+        <!-- Define a JCR repository that accesses the 'Vehicles' federated source directly -->
+        <dna:repository jcr:name="vehicles">
+            <!-- Specify the source that should be used for the repository -->
             <source>Vehicles</source>
             <!-- Define the options for the JCR repository, using camelcase version of JcrRepository.Option names -->
             <options jcr:primaryType="dna:options">
@@ -76,6 +160,6 @@
                 <car jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/cars/1.0"/>
                 <air jcr:primaryType="dna:namespace" dna:uri="http://jboss.org/dna/examples/aircraft/1.0"/>
             </namespaces>
-        </repository>
-    </repositories>
+        </dna:repository>
+    </dna:repositories>
 </configuration>
\ No newline at end of file

Added: trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/jaas.conf.xml
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/jaas.conf.xml	                        (rev 0)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/jaas.conf.xml	2009-06-05 02:20:41 UTC (rev 979)
@@ -0,0 +1,24 @@
+<?xml version='1.0'?>
+
+<policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="urn:jboss:security-config:5.0" xmlns="urn:jboss:security-config:5.0"
+	xmlns:jbxb="urn:jboss:security-config:5.0">
+	<application-policy name="dna-jcr">
+		<authentication>
+			<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
+                <module-option name="usersProperties">security/users.properties</module-option>
+                <module-option name="rolesProperties">security/roles.properties</module-option>
+				<module-option name="name">1.1</module-option>
+				<module-option name="succeed">true</module-option>
+				<module-option name="throwEx">false</module-option>
+			</login-module>
+		</authentication>
+<!-- 		
+		<authorization>
+			<policy-module code="org.jboss.security.idtrust.impl.plugins.authorization.IDTrustAuthorizationModule">
+				<module-option name="roles">validuser</module-option>
+			</policy-module>
+		</authorization>
+-->		
+	</application-policy>
+</policy>


Property changes on: trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/jaas.conf.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/roles.properties
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/roles.properties	                        (rev 0)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/roles.properties	2009-06-05 02:20:41 UTC (rev 979)
@@ -0,0 +1,2 @@
+#<userName>=[readonly[.<workspaceName>] | readwrite[.<workspaceName>]][, [readonly[.<workspaceName>] | readwrite[.<workspaceName>]]]*
+jsmith=readwrite

Added: trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/users.properties
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/users.properties	                        (rev 0)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/security/users.properties	2009-06-05 02:20:41 UTC (rev 979)
@@ -0,0 +1,2 @@
+# <username>=<password>
+jsmith=secret

Added: trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd
===================================================================
--- trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd	                        (rev 0)
+++ trunk/docs/examples/gettingstarted/repositories/src/main/resources/virtual.cnd	2009-06-05 02:20:41 UTC (rev 979)
@@ -0,0 +1,79 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors. 
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+ 
+//------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<air='http://jboss.org/dna/examples/aircraft/1.0'>
+<car='http://jboss.org/dna/examples/cars/1.0'>
+
+//------------------------------------------------------------------------------
+// N O D E T Y P E S
+//------------------------------------------------------------------------------
+
+[car:Car] > nt:unstructured
+  - car:maker (string)
+  - car:model (string)
+  - car:year (string) < '(19|20)\d{2}'                     // any 4 digit number starting with '19' or '20'
+  - car:msrp (string) < '[$]\d{1,3}[,]?\d{3}([.]\d{2})?'   // of the form "$X,XXX.ZZ", "$XX,XXX.ZZ" or "$XXX,XXX.ZZ" 
+                                                           // where '.ZZ' is optional
+  - car:userRating (long) < '[1,5]'                        // any value from 1 to 5 (inclusive)
+  - car:valueRating (long) < '[1,5]'                       // any value from 1 to 5 (inclusive)
+  - car:mpgCity (long) < '(0,]'                            // any value greater than 0
+  - car:mpgHighway (long) < '(0,]'                         // any value greater than 0
+  - car:lengthInInches (double) < '(0,]'                   // any value greater than 0
+  - car:wheelbaseInInches (double) < '(0,]'                // any value greater than 0
+  - car:engine (string)
+
+[air:Aircraft] > nt:unstructured
+  - air:maker (string)
+  - air:model (string)
+  - air:designedBy (string)
+  - air:introduced (string) < '(19|20)\d{2}'                // any 4 digit number starting with '19' or '20'
+  - air:range (string)                                      // any integer (with optional ',' every 1000s place)
+     < '\d{1,3}(,?\d{3})*\s*(nm|m|km|mi|ft)'                // followed by 'nm', 'm', 'km', 'mi', or 'ft'
+  - air:maxSpeed (string)                                   // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)'              // followed by 'kt', 'mph', 'km/h' or 'kmph'
+  - air:takeoffSpeed (string)                               // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)'              // followed by 'kt', 'mph', 'km/h' or 'kmph'
+  - air:cruiseSpeed (string)                                // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*(kt|mph|km/h|kmph)'              // followed by 'kt', 'mph', 'km/h' or 'kmph'
+  - air:emptyWeight (string)                                // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*(lb|kg)'                         // followed by 'lb' or 'kg'
+  - air:maxWeight (string)                                  // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*(lb|kg)'                         // followed by 'lb' or 'kg'
+  - air:rateOfClimb (string)                                // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*(ft|km|m)/(s|min)'               // followed by 'ft/s', 'ft/min', 'km/s', 'km/min', 'm/s', or 'm/min'
+  - air:serviceCeiling (string)                             // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*(nm|m|km|mi|ft)'                 // followed by 'nm', 'm', 'km', 'mi', or 'ft'
+  - air:fuelCapacity (string)                               // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*(lb|kg|gal|L)'                   // followed by 'lb', 'kg', 'gal', or 'L'
+  - air:crew (long) < '[0,)'                                // any non-negative value
+  - air:numberBuilt (string)                                // any integer (with optional ',' every 1000s place)
+    < '\d{1,3}(,?\d{3})*\s*[+]?' ,                          // optionally followed by '+'
+      '([<>]\s*)?\d{1,3}(,?\d{3})*'                         // or prefixed by '<' or '>'
+  - air:url (string)

Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java	2009-06-04 23:36:27 UTC (rev 978)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java	2009-06-05 02:20:41 UTC (rev 979)
@@ -61,10 +61,9 @@
 
     public static void main( String[] args ) {
         // Set up the JAAS provider (IDTrust) and a policy file (which defines the "dna-jcr" login config name)
-        String configFile = "security/jaas.conf.xml";
         IDTrustConfiguration idtrustConfig = new IDTrustConfiguration();
         try {
-            idtrustConfig.config(configFile);
+            idtrustConfig.config("security/jaas.conf.xml");
         } catch (Exception ex) {
             throw new IllegalStateException(ex);
         }




More information about the dna-commits mailing list