Author: spagop
Date: 2009-07-13 02:40:00 -0400 (Mon, 13 Jul 2009)
New Revision: 1096
Added:
trunk/utils/
trunk/utils/dna-jcr-gen/
trunk/utils/dna-jcr-gen/benerator-0.5.9-SR1.xsd
trunk/utils/dna-jcr-gen/pom.xml
trunk/utils/dna-jcr-gen/readme.txt
trunk/utils/dna-jcr-gen/src/
trunk/utils/dna-jcr-gen/src/main/
trunk/utils/dna-jcr-gen/src/main/java/
trunk/utils/dna-jcr-gen/src/main/java/org/
trunk/utils/dna-jcr-gen/src/main/java/org/jboss/
trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/
trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/
trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/
trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/JCRDataMassGen.java
trunk/utils/dna-jcr-gen/src/main/resources/
trunk/utils/dna-jcr-gen/src/main/resources/log4j.properties
trunk/utils/dna-jcr-gen/src/test/
trunk/utils/dna-jcr-gen/src/test/java/
trunk/utils/dna-jcr-gen/src/test/java/org/
trunk/utils/dna-jcr-gen/src/test/java/org/jboss/
trunk/utils/dna-jcr-gen/src/test/java/org/jboss/dna/
trunk/utils/dna-jcr-gen/src/test/java/org/jboss/dna/jcr/
trunk/utils/dna-jcr-gen/src/test/resources/
trunk/utils/dna-jcr-gen/src/test/resources/benerator/
trunk/utils/dna-jcr-gen/src/test/resources/benerator/bank.properties
trunk/utils/dna-jcr-gen/src/test/resources/benerator/benerator.xml
Log:
dna jcr gen project initial
Added: trunk/utils/dna-jcr-gen/benerator-0.5.9-SR1.xsd
===================================================================
--- trunk/utils/dna-jcr-gen/benerator-0.5.9-SR1.xsd (rev 0)
+++ trunk/utils/dna-jcr-gen/benerator-0.5.9-SR1.xsd 2009-07-13 06:40:00 UTC (rev 1096)
@@ -0,0 +1,372 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
+
targetNamespace="http://databene.org/benerator/0.5.9-SR1"
+
xmlns="http://databene.org/benerator/0.5.9-SR1"
+ elementFormDefault="qualified">
+
+ <xs:annotation>
+ <xs:documentation>The benerator schema describes the generation setup for
benerator.</xs:documentation>
+ <xs:appinfo/>
+ </xs:annotation>
+
+ <xs:simpleType name="script-expression-type">
+ <xs:restriction base="xs:string">
+ <xs:pattern value="\{.*\}"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:simpleType name="errorhandler-type">
+ <xs:union>
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="fatal"/>
+ <xs:enumeration value="error"/>
+ <xs:enumeration value="warn"/>
+ <xs:enumeration value="info"/>
+ <xs:enumeration value="debug"/>
+ <xs:enumeration value="trace"/>
+ <xs:enumeration value="ignore"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType>
+ <xs:restriction base="script-expression-type"/>
+ </xs:simpleType>
+ </xs:union>
+ </xs:simpleType>
+
+
+ <!-- The document root, it can list beans, create-entities and run-tasks in arbitrary
order. -->
+ <xs:element name="setup">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="comment" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="import" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="include" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="property" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="database" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="bean" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="defaultAttributes" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="create-entities" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="update-entities" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="run-task" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="execute" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="evaluate" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="echo" minOccurs="0"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="default-script" type="xs:string"/>
<!-- deprecated -->
+ <xs:attribute name="default-null" type="xs:string"/>
<!-- deprecated -->
+ <xs:attribute name="defaultScript"
type="xs:string"/>
+ <xs:attribute name="defaultNull"
type="xs:string"/>
+ <xs:attribute name="defaultEncoding"
type="xs:string"/>
+ <xs:attribute name="defaultLineSeparator"
type="xs:string"/>
+ <xs:attribute name="defaultLocale"
type="xs:string"/>
+ <xs:attribute name="defaultDataset"
type="xs:string"/>
+ <xs:attribute name="defaultPagesize"
type="xs:string"/>
+ <xs:attribute name="defaultSeparator"
type="xs:string"/>
+ <xs:attribute name="defaultErrorHandler"
type="errorhandler-type"/>
+ <xs:attribute name="maxCount"
type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="comment" type="xs:string" />
+
+ <!-- Imports classes. -->
+ <xs:element name="import">
+ <xs:complexType>
+ <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="domain" type="xs:string"/>
+ <xs:attribute name="defaults" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Includes a properties file. -->
+ <xs:element name="include">
+ <xs:complexType>
+ <xs:attribute name="uri" type="xs:string"
use="required"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Outputs a message to the console. -->
+ <xs:element name="echo">
+ <xs:complexType>
+ <xs:attribute name="message" type="xs:string"
use="required"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Instantiates a JavaBean of the given class.
+ If the 'id' is set, the bean is put into the context with that name.
+ If the JavaBean itself has a property named 'id', this one is set to the
value specified here. -->
+ <xs:element name="bean">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="comment" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="property" minOccurs="0"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:string"
use="required"/>
+ <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="spec" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- connects to a database -->
+ <xs:element name="database">
+ <xs:complexType>
+ <xs:attribute name="id" type="xs:string"
use="required"/>
+ <xs:attribute name="url" type="xs:string"/>
+ <xs:attribute name="driver" type="xs:string"/>
+ <xs:attribute name="user" type="xs:string"/>
+ <xs:attribute name="schema" type="xs:string"/>
+ <xs:attribute name="password" type="xs:string"/>
+ <xs:attribute name="batch" type="xs:string"/>
+ <xs:attribute name="fetchSize" type="xs:string"/>
+ <xs:attribute name="readOnly" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:complexType name="execute-type">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="uri"
type="xs:string"/>
+ <xs:attribute name="encoding"
type="xs:string"/>
+ <xs:attribute name="target"
type="xs:string"/>
+ <xs:attribute name="type"
type="xs:string"/>
+ <xs:attribute name="onError"
type="errorhandler-type"/>
+ <xs:attribute name="optimize"
type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <!-- executes a script, e.g. SQL -->
+ <xs:element name="execute" />
+
+ <!-- evaluates a script, e.g. SQL -->
+ <xs:element name="evaluate">
+ <xs:complexType>
+ <xs:simpleContent>
+ <xs:extension base="execute-type">
+ <xs:attribute name="assert"
type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Declares a JavaBean to be used as consumer, either by referencing an object from
the context (ref)
+ or by instantiating a JavaBean like with the <bean> tag. -->
+ <xs:element name="consumer">
+ <xs:complexType>
+ <xs:sequence minOccurs="1" maxOccurs="unbounded">
+ <xs:element ref="comment" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="property" minOccurs="0"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="id" type="xs:string"/>
+ <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="ref" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Sets a JavaBean's property to the simple property specified as
'value' attribute
+ or to the object stored in the context with the 'ref'. -->
+ <xs:element name="property">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="comment" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="bean" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="idref" minOccurs="0"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="value" type="xs:string"/>
+ <xs:attribute name="ref" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Represents a reference to a JavaBean (of the name specified by the
'bean' attribute) from the context. -->
+ <xs:element name="idref">
+ <xs:complexType>
+ <xs:attribute name="bean" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Instantiates and executes a JavaBean that implements the Task interface.
+ Properties are handled like in the <bean> tag.
+ The task is executed 'count' times in a number of 'threads'
parallel threads.
+ Invocations are executed in groups of size 'pagesize'. -->
+ <xs:element name="run-task">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="comment" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="property" minOccurs="0"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="class" type="xs:string"/>
+ <xs:attribute name="count" type="xs:string"/>
+ <xs:attribute name="pagesize" type="xs:string"/>
+ <xs:attribute name="threads" type="xs:string"/>
+ <xs:attribute name="pager" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="defaultAttributes">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="comment" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="id" minOccurs="0"
maxOccurs="1"/>
+ <xs:element ref="attribute" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="reference" minOccurs="0"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="count" type="xs:string"/>
+ <xs:attribute name="pagesize" type="xs:string"/>
+ <xs:attribute name="threads" type="xs:string"/>
+ <xs:attribute name="source" type="xs:string"/>
+ <xs:attribute name="encoding" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Creates entities. If a 'count' is provided the corresponding number
of entities is created.
+ If no count is provided, entities are created as long as each involved generator
is available. -->
+ <xs:element name="create-entities">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="comment" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="id" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="attribute" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="reference" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="variable" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="consumer" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="create-entities" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="update-entities" minOccurs="0"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="count" type="xs:string"/>
+ <xs:attribute name="minCount" type="xs:string"/>
+ <xs:attribute name="maxCount" type="xs:string"/>
+ <xs:attribute name="pagesize" type="xs:string"/>
+ <xs:attribute name="threads" type="xs:string"/>
+ <xs:attribute name="source" type="xs:string"/>
+ <xs:attribute name="selector" type="xs:string"/>
+ <xs:attribute name="encoding" type="xs:string"/>
+ <xs:attribute name="consumer" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Updates entities. -->
+ <xs:element name="update-entities">
+ <xs:complexType>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element ref="comment" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="id" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="attribute" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="reference" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="variable" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="consumer" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="create-entities" minOccurs="0"
maxOccurs="unbounded"/>
+ <xs:element ref="update-entities" minOccurs="0"
maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="count" type="xs:string"/>
+ <xs:attribute name="pagesize" type="xs:string"/>
+ <xs:attribute name="threads" type="xs:string"/>
+ <xs:attribute name="source" type="xs:string"/>
+ <xs:attribute name="selector" type="xs:string"/>
+ <xs:attribute name="encoding" type="xs:string"/>
+ <xs:attribute name="consumer" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Defines an ID generator that can be reused in different scopes. -->
+ <xs:element name="id">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="type" type="xs:string"/>
+ <xs:attribute name="source" type="xs:string"/>
+ <xs:attribute name="strategy" type="xs:string"/>
+ <xs:attribute name="scope" type="xs:string"/>
+ <xs:attribute name="param" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Defines a reference generator. -->
+ <xs:element name="reference">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string"/>
+ <xs:attribute name="type" type="xs:string"/>
+ <xs:attribute name="nullable" type="xs:string"/>
+ <xs:attribute name="nullQuota" type="xs:string"/>
+ <xs:attribute name="source" type="xs:string"/>
+ <xs:attribute name="targetType" type="xs:string"/>
+ <xs:attribute name="selector" type="xs:string"/>
+ <xs:attribute name="distribution" type="xs:string"/>
+ <xs:attribute name="mode" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- Defines a variable that is recreated by a generator on each entity creation
-->
+ <xs:element name="variable" type="generator-setup"/>
+
+ <xs:complexType name="generator-setup">
+ <xs:attribute name="name" type="xs:string"
use="required"/>
+ <xs:attribute name="type" type="xs:string"/>
+ <xs:attribute name="generator" type="xs:string"/>
+ <xs:attribute name="validator" type="xs:string"/>
+ <xs:attribute name="values" type="xs:string"/>
+ <xs:attribute name="source" type="xs:string"/>
+ <xs:attribute name="encoding" type="xs:string"/>
+ <xs:attribute name="selector" type="xs:string"/>
+ <xs:attribute name="pattern" type="xs:string"/>
+ <xs:attribute name="nullQuota" type="xs:string"/>
+ <xs:attribute name="converter" type="xs:string"/>
+ <xs:attribute name="dataset" type="xs:string"/>
+ <xs:attribute name="nesting" type="xs:string"/>
+ <xs:attribute name="locale" type="xs:string"/>
+ <xs:attribute name="unique" type="xs:string"/>
+ <xs:attribute name="distribution" type="xs:string"/>
+ <xs:attribute name="variation1" type="xs:string"/>
+ <xs:attribute name="variation2" type="xs:string"/>
+ <xs:attribute name="cyclic" type="xs:string"/>
+ <xs:attribute name="proxy">
+ <xs:simpleType>
+ <xs:union>
+ <xs:simpleType> <!-- (skip | repeat) -->
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="skip"/>
+ <xs:enumeration value="repeat"/>
+ </xs:restriction>
+ </xs:simpleType>
+ <xs:simpleType>
+ <xs:restriction base="script-expression-type"/>
+ </xs:simpleType>
+ </xs:union>
+ </xs:simpleType>
+ </xs:attribute>
+ <xs:attribute name="proxy-param1" type="xs:string"/>
+ <xs:attribute name="proxy-param2" type="xs:string"/>
+ </xs:complexType>
+
+ <xs:element name="attribute"
type="attribute-generator-setup"/>
+
+ <xs:complexType name="attribute-generator-setup">
+ <xs:complexContent>
+ <xs:extension base="generator-setup">
+
+ <xs:attribute name="nullable" type="xs:string"/>
+ <xs:attribute name="mode" type="xs:string"/>
+
+ <!-- boolean generator setup -->
+ <xs:attribute name="trueQuota" type="xs:string"/>
+
+ <!-- number generator setup -->
+ <xs:attribute name="min" type="xs:string"/>
+ <xs:attribute name="minExclusive" type="xs:string"/>
+ <xs:attribute name="max" type="xs:string"/>
+ <xs:attribute name="maxExclusive" type="xs:string"/>
+ <xs:attribute name="precision" type="xs:string"/>
+
+ <!-- String generator setup -->
+ <xs:attribute name="script" type="xs:string"/>
+ <xs:attribute name="minLength" type="xs:string"/>
+ <xs:attribute name="maxLength" type="xs:string"/>
+
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+
+</xs:schema>
Added: trunk/utils/dna-jcr-gen/pom.xml
===================================================================
--- trunk/utils/dna-jcr-gen/pom.xml (rev 0)
+++ trunk/utils/dna-jcr-gen/pom.xml 2009-07-13 06:40:00 UTC (rev 1096)
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna</artifactId>
+ <version>0.6-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-jcr-gen</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss DNA JCR data mass generator</name>
+ <description>
+ A Utilty to generate mass of data for a jcr repository
+ and then write them into the source. For Performance testing,
+ for dummy daten for a start up project.
+ </description>
+ <
url>http://labs.jboss.org/dna</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.databene</groupId>
+ <artifactId>maven-benerator-plugin</artifactId>
+ <version>0.5.9-SR1</version>
+ <configuration>
+ <descriptor>
+ src/test/resources/benerator/benerator.xml
+ </descriptor>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!--
+ Define the dependencies. Note that all version and scopes default to those
+ defined in the dependencyManagement section of the parent pom.
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>org.databene</groupId>
+ <artifactId>databene-benerator</artifactId>
+ <version>0.5.9-SR1</version>
+ </dependency>
+ <!--
+ Java Content Repository API
+ -->
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <version>1.0.1</version>
+ <scope>compile</scope>
+ </dependency>
+ <!--
+ JBoss DNA JCR (JCR Implementation) for repository implementation
+ -->
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-jcr</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-repository</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!--
+ Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding for
testing)
+ -->
+ <!-- Logging (require SLF4J API for compiling, but use Log4J and its SLF4J binding
for testing) -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.4.3</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.3</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.google-collections</groupId>
+ <artifactId>google-collect</artifactId>
+ <version>snapshot-20080530</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-idtrust</artifactId>
+ <version>2.0.2.CR1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-security-spi-bare</artifactId>
+ <version>2.0.2.SP6</version>
+ <scope>test</scope>
+ </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>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/utils/dna-jcr-gen/readme.txt
===================================================================
--- trunk/utils/dna-jcr-gen/readme.txt (rev 0)
+++ trunk/utils/dna-jcr-gen/readme.txt 2009-07-13 06:40:00 UTC (rev 1096)
@@ -0,0 +1 @@
+Note: you need JDK6
\ No newline at end of file
Added: trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/JCRDataMassGen.java
===================================================================
--- trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/JCRDataMassGen.java
(rev 0)
+++
trunk/utils/dna-jcr-gen/src/main/java/org/jboss/dna/jcr/gen/JCRDataMassGen.java 2009-07-13
06:40:00 UTC (rev 1096)
@@ -0,0 +1,219 @@
+/*
+ * 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.
+ */
+
+package org.jboss.dna.jcr.gen;
+
+import java.io.InputStream;
+import java.util.Calendar;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+import org.databene.model.consumer.AbstractConsumer;
+import org.databene.model.data.Entity;
+import org.jboss.dna.graph.SecurityContext;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.jcr.JcrConfiguration;
+import org.jboss.dna.jcr.JcrEngine;
+import org.jboss.dna.jcr.SecurityContextCredentials;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Utility that writes the generated content as nodes to a DNA JCR
repository.<br/>
+ *
+ * @author Serge Pagop
+ */
+
+public class JCRDataMassGen extends AbstractConsumer<Entity> {
+
+ private static final Logger log = LoggerFactory.getLogger(JCRDataMassGen.class);
+ // attributes
------------------------------------------------------------------------------------------------------
+
+ private Session session;
+ private Node currentNode;
+ private boolean printContent;
+
+ private JcrConfiguration configuration;
+ private JcrEngine engine;
+ private Repository repository;
+
+ // Constructor
-----------------------------------------------------------------------------------------------------
+
+ public JCRDataMassGen( String username,
+ String sourceName,
+ String sourceDescription,
+ String repositoryName,
+ String workspaceName,
+ boolean printContent ) throws RepositoryException {
+ this.printContent = printContent;
+
+ // setting up the JcrConfiguration
+ configuration = new JcrConfiguration();
+
configuration.repositorySource(sourceName).usingClass(InMemoryRepositorySource.class).setDescription(sourceDescription).setProperty("defaultWorkspaceName",workspaceName);
+ // repository
+ configuration.repository(repositoryName).setSource(sourceName);
+
+ // Start the engine
+ engine = configuration.build();
+ engine.start();
+
+
+ // Obtain a JCR Repository instance by name
+ repository = engine.getRepository(repositoryName);
+ SecurityContext securityContext = new MyCustomSecurityContext(username);
+ SecurityContextCredentials credentials = new
SecurityContextCredentials(securityContext);
+ this.session = repository.login(credentials, workspaceName);
+
+ this.currentNode = session.getRootNode();
+ }
+
+ // consumer interface implementation
-------------------------------------------------------------------------------
+
+ public void startConsuming( Entity entity ) {
+ Node newNode;
+ try {
+ String n = entity.get("nodeName").toString();
+ newNode = currentNode.addNode(n, "nt:unstructured");
+ for (Map.Entry<String, Object> component :
entity.getComponents().entrySet()) {
+ String key = component.getKey();
+ Object value = component.getValue();
+ if (!"nodeName".equals(key)) setNodeProperty(newNode, key,
value);
+ }
+ currentNode = newNode;
+ } catch (Exception e) {
+ throw new RuntimeException("Exception whe trying to store " +
entity, e);
+ }
+ }
+
+ @Override
+ public void finishConsuming( Entity object ) {
+ try {
+ session.save();
+ currentNode = currentNode.getParent();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void close() {
+ try {
+ if (printContent) printNode(session.getRootNode(), "");
+ } catch (RepositoryException e) {
+ throw new RuntimeException(e);
+
+ } finally {
+ session.logout();
+
+ // Shutdown the engine
+ if (engine != null) {
+ engine.shutdown();
+ try {
+ engine.awaitTermination(3, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+ }
+
+ public void setPrintContent( boolean printContent ) {
+ this.printContent = printContent;
+ }
+
+ // private helpers
-------------------------------------------------------------------------------------------------
+
+ private void setNodeProperty( Node node,
+ String propertyName,
+ Object propertyValue )
+ throws ValueFormatException, VersionException, LockException,
ConstraintViolationException, RepositoryException {
+ if (propertyValue instanceof Long) node.setProperty(propertyName,
(Long)propertyValue);
+ else if (propertyValue instanceof Double) node.setProperty(propertyName,
(Double)propertyValue);
+ else if (propertyValue instanceof Boolean) node.setProperty(propertyName,
(Boolean)propertyValue);
+ else if (propertyValue instanceof Calendar) node.setProperty(propertyName,
(Calendar)propertyValue);
+ else if (propertyValue instanceof String[]) node.setProperty(propertyName,
(String[])propertyValue);
+ else if (propertyValue instanceof InputStream) node.setProperty(propertyName,
(InputStream)propertyValue);
+ else if (propertyValue instanceof Node) node.setProperty(propertyName,
(Node)propertyValue);
+ else if (propertyValue instanceof Value) node.setProperty(propertyName,
(Value)propertyValue);
+ else if (propertyValue instanceof Value[]) node.setProperty(propertyName,
(Value[])propertyValue);
+ else node.setProperty(propertyName, propertyValue.toString());
+ }
+
+ private void printNode( Node node,
+ String indent ) throws RepositoryException {
+ log.info(indent + "Node: " + node.getName() + " " +
node.getPrimaryNodeType().getName());
+ PropertyIterator propIt = node.getProperties();
+ while (propIt.hasNext()) {
+ Property property = (Property)propIt.next();
+ log.info(indent + '\t' + '\t' + property.getName());
+ Value value = property.getValue();
+ log.info(indent + '\t' + '\t' + '\t' +
value.getString());
+
+ }
+ NodeIterator iterator = node.getNodes();
+ while (iterator.hasNext())
+ printNode(iterator.nextNode(), indent + '\t');
+ }
+
+ protected class MyCustomSecurityContext implements SecurityContext {
+ private String username;
+ public MyCustomSecurityContext( String username ) {
+ this.username = username;
+ }
+ /**
+ * @see org.jboss.dna.graph.SecurityContext#getUserName()
+ */
+ public String getUserName() {
+ return this.username;
+ }
+
+ /**
+ * @see org.jboss.dna.graph.SecurityContext#hasRole(java.lang.String)
+ */
+
+ public boolean hasRole( String roleName ) {
+ return true;
+ }
+
+ /**
+ * @see org.jboss.dna.graph.SecurityContext#logout()
+ */
+ public void logout() {
+ // do something
+ }
+ }
+
+}
Added: trunk/utils/dna-jcr-gen/src/main/resources/log4j.properties
===================================================================
--- trunk/utils/dna-jcr-gen/src/main/resources/log4j.properties
(rev 0)
+++ trunk/utils/dna-jcr-gen/src/main/resources/log4j.properties 2009-07-13 06:40:00 UTC
(rev 1096)
@@ -0,0 +1,13 @@
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
+
+# Root logger option
+log4j.rootLogger=INFO, stdout
+
+# Set up the default logging to be INFO level, then override specific units
+log4j.logger.org.jboss.dna=INFO
+log4j.logger.org.jboss.example.dna=INFO
+
Added: trunk/utils/dna-jcr-gen/src/test/resources/benerator/bank.properties
===================================================================
--- trunk/utils/dna-jcr-gen/src/test/resources/benerator/bank.properties
(rev 0)
+++ trunk/utils/dna-jcr-gen/src/test/resources/benerator/bank.properties 2009-07-13
06:40:00 UTC (rev 1096)
@@ -0,0 +1,5 @@
+bankCount=20
+minProd=3
+maxProd=20
+minCont=4
+maxCont=20
Added: trunk/utils/dna-jcr-gen/src/test/resources/benerator/benerator.xml
===================================================================
--- trunk/utils/dna-jcr-gen/src/test/resources/benerator/benerator.xml
(rev 0)
+++ trunk/utils/dna-jcr-gen/src/test/resources/benerator/benerator.xml 2009-07-13 06:40:00
UTC (rev 1096)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<setup
xmlns="http://databene.org/benerator/0.5.9-SR1"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://databene.org/benerator/0.5.9-SR1
benerator-0.5.9-SR1.xsd">
+
+ <!-- Already existed generator -->
+ <import domain="person" />
+ <import domain="address" />
+
+ <!-- My consumer for my InMmemery repos. source -->
+ <bean id="dnaJcrConsumer"
spec="org.jboss.dna.jcr.gen.JCRDataMassGen('toto', 'firstSource',
+ 'this is only my first jcr repos source with some
test data',
+ 'test repository',
+ 'WS1',true)"/>
+
+ <!-- Some extras data -->
+ <include uri="bank.properties"/>
+
+ <!-- My Model -->
+ <create-entities name="Bank" consumer="dnaJcrConsumer"
count="{${bankCount}}">
+ <attribute name="nodeName" type="string" pattern="[A-Z]{3}
Bank" unique="true"/>
+
+ <create-entities name="Product" consumer="dnaJcrConsumer"
minCount="{${minProd}}" maxCount="{${maxProd}}">
+ <attribute name="nodeName" type="string" pattern="[A-Z]{3}
Credit" unique="true"/>
+
+ <create-entities name="Contract" consumer="dnaJcrConsumer"
minCount="{${minCont}}" maxCount="{${maxCont}}">
+ <id name="id" strategy="increment(100000)"/>
+ <attribute name="nodeName" script="{Contract
#${Contract.id}}"/>
+ <attribute name="amount" type="float" min="1000"
max="20000" distribution="cumulated"/>
+ <attribute name="interest" type="big_decimal"
min="7" max="12" precision="0.05"/>
+
+ <create-entities name="Person" consumer="dnaJcrConsumer"
count="1">
+ <variable name="person" generator="PersonGenerator"
dataset="US" locale="en"/>
+ <attribute name="nodeName" script="{${person.givenName}
${person.familyName}}"/>
+ <attribute name="salutation"
script="{${person.salutation}}"/>
+ <attribute name="firstName"
script="{${person.givenName}}"/>
+ <attribute name="surname"
script="{${person.familyName}}"/>
+ <attribute name="birthDate" type="date"
source="person.birthDate"/>
+ </create-entities>
+
+ <create-entities name="Address" consumer="dnaJcrConsumer"
count="1">
+ <variable name="address" generator="AddressGenerator"
dataset="US"/>
+ <id name="id" strategy="increment(100000)"/>
+ <attribute name="nodeName" script="{Address
#${Address.id}}"/>
+ <attribute name="street" script="{${address.street}
${address.houseNumber}}"/>
+ <attribute name="zipCode" script="{${address.zipCode}}"/>
+ <attribute name="city" script="{${address.city}}"/>
+ <attribute name="country" script="{${address.country}}"/>
+ </create-entities>
+ </create-entities>
+ </create-entities>
+ </create-entities>
+
+</setup>
\ No newline at end of file