Hibernate SVN: r11701 - in trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook: gen and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-22 16:55:40 -0400 (Fri, 22 Jun 2007)
New Revision: 11701
Added:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/RenderingException.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/XSLTException.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/BasicFormatHandler.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/FormatHandler.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/FormatHandlerFactory.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/PdfFormatHandler.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/util/Formatting.java
Removed:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/render/
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/XSLTException.java
Modified:
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/TransformerFactory.java
trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/resolve/ExplicitUrnResolver.java
Log:
worked out install/deploy issues + attached artifacts
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/AbstractDocBookMojo.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -16,27 +16,37 @@
package org.jboss.maven.plugin.docbook;
import java.io.File;
+import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectHelper;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
-import org.jboss.maven.plugin.docbook.gen.render.Formatting;
-import org.jboss.maven.plugin.docbook.gen.render.RenderingException;
+import org.jboss.maven.plugin.docbook.gen.RenderingException;
+import org.jboss.maven.plugin.docbook.gen.XSLTException;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
import org.jboss.maven.plugin.docbook.gen.util.StandardDocBookFormatSpecification;
-import org.jboss.maven.plugin.docbook.gen.xslt.XSLTException;
/**
* Basic support for the various DocBook mojos in this package. Mainly, we are
* defining common configuration attributes of the packaging.
- *
+ * <p/>
+ * todo : I'd much prefer to see the "partial artifact coord" stuff go away
+ * and use custom package types to convey this information. This frees the
+ * user from duplicate entry of the information.
+ *
* @author Steve Ebersole
*/
public abstract class AbstractDocBookMojo extends AbstractMojo {
- /**
+ public static final String PLUGIN_NAME = "jboss-docbook";
+
+ /**
* INTERNAL : The project being built
*
* @parameter expression="${project}"
@@ -75,6 +85,24 @@
protected ArchiverManager archiverManager;
/**
+ * INTERNAL : used in the translation diff report
+ *
+ * @parameter expression="${component.org.apache.maven.doxia.siterenderer.Renderer}"
+ * @required
+ * @readonly
+ */
+ protected Renderer siteRenderer;
+
+ /**
+ * INTERNAL : used during packaging to attach produced artifacts
+ *
+ * @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}"
+ * @required
+ * @readonly
+ */
+ protected MavenProjectHelper projectHelper;
+
+ /**
* The name of the document (relative to sourceDirectory) which is the
* document to be rendered.
*
@@ -91,6 +119,27 @@
protected File sourceDirectory;
/**
+ * The directory containing local images
+ *
+ * @parameter expression="${basedir}/src/main/images"
+ */
+ protected File imagesDirectory;
+
+ /**
+ * The directory containing local css
+ *
+ * @parameter expression="${basedir}/src/main/css"
+ */
+ protected File cssDirectory;
+
+ /**
+ * The directory containing local fonts
+ *
+ * @parameter expression="${basedir}/src/main/fonts"
+ */
+ protected File fontsDirectory;
+
+ /**
* The directory where the output will be written.
*
* @parameter expression="${basedir}/target/docbook"
@@ -113,23 +162,49 @@
* The formats in which to perform rendering.
*
* @parameter
- * @required
+ * @required
*/
protected Format[] formats;
/**
+ * The artifactId of the master translation (unless, of course, this is the
+ * master translation). It is assumed that the master translation:<ol>
+ * <li>is part of the same groupId</li>
+ * <li>has its source defined as a dependency (classifier = source)</li>
+ * </ol>
+ *
+ * @parameter
+ */
+ protected String masterTranslationArtifactId;
+
+ /**
+ * Local path to the master translation to use for diff reporting.
+ *
+ * @parameter
+ */
+ protected File masterTranslationFile;
+
+ /**
+ * The relative path font configuration to use.
+ *
+ * @parameter
+ */
+ protected String fontConfig;
+
+ /**
* Configurable options
*
* @parameter
*/
protected Options options;
+
/**
* The override method to perform the actual processing of the
* mojo.
*
* @param formattings The fomattings configured for render
- * @throws RenderingException
+ * @throws org.jboss.maven.plugin.docbook.gen.RenderingException
* @throws XSLTException
*/
protected abstract void process(Formatting[] formattings) throws RenderingException, XSLTException;
@@ -153,4 +228,28 @@
}
return formattings;
}
+
+ protected static interface ArtifactProcessor {
+ public void process(org.apache.maven.artifact.Artifact artifact);
+ }
+
+ protected void processArtifacts(ArtifactProcessor processor) {
+ processProjectArtifacts( processor );
+ processPluginArtifacts( processor );
+ }
+
+ protected void processProjectArtifacts(ArtifactProcessor processor) {
+ processArtifacts( processor, projectArtifacts );
+ }
+
+ protected void processPluginArtifacts(ArtifactProcessor processor) {
+ processArtifacts( processor, pluginArtifacts );
+ }
+
+ private void processArtifacts(ArtifactProcessor processor, Collection artifacts) {
+ Iterator itr = artifacts.iterator();
+ while ( itr.hasNext() ) {
+ processor.process( ( org.apache.maven.artifact.Artifact ) itr.next() );
+ }
+ }
}
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/GenerationMojo.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -18,10 +18,11 @@
import java.io.File;
import org.codehaus.plexus.util.FileUtils;
-import org.jboss.maven.plugin.docbook.gen.render.Formatting;
-import org.jboss.maven.plugin.docbook.gen.render.RendererFactory;
-import org.jboss.maven.plugin.docbook.gen.render.RenderingException;
-import org.jboss.maven.plugin.docbook.gen.xslt.XSLTException;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
+import org.jboss.maven.plugin.docbook.gen.format.FormatHandlerFactory;
+import org.jboss.maven.plugin.docbook.gen.RenderingException;
+import org.jboss.maven.plugin.docbook.gen.XSLTException;
+import org.apache.maven.artifact.Artifact;
/**
* A DocBook plugin based on the excellent docbkx-maven-plugin, but which
@@ -50,17 +51,47 @@
FileUtils.mkdir( targetDirectory.getAbsolutePath() );
}
- RendererFactory rendererFactory = new RendererFactory(
+ if ( options.getDocbookVersion() == null ) {
+ processArtifacts(
+ new ArtifactProcessor() {
+ public void process(Artifact artifact) {
+ if ( "net.sf.docbook".equals( artifact.getGroupId() ) &&
+ "docbook".equals( artifact.getArtifactId() ) ) {
+ getLog().debug( "Found docbook version : " + artifact.getVersion() );
+ if ( options.getDocbookVersion() != null ) {
+ getLog().warn( "found multiple docbook versions" );
+ }
+ options.setDocbookVersion( artifact.getVersion() );
+ }
+ }
+ }
+ );
+ }
+
+ File fontConfigFile = null;
+ if ( fontConfig != null ) {
+ getLog().debug( "checking for fontConfig existence [" + fontConfig + "]" );
+ if ( stagingDirectory != null ) {
+ File tmp = new File( stagingDirectory, fontConfig );
+ if ( tmp.exists() ) {
+ getLog().info( "using font configuration : " + tmp.getAbsolutePath() );
+ fontConfigFile = tmp;
+ }
+ }
+ }
+
+ FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
options,
source,
targetDirectory,
stagingDirectory,
+ fontConfigFile,
project,
getLog()
);
for ( int i = 0; i < formattings.length; i++ ) {
- rendererFactory.buildRenderer( formattings[i] ).render( source );
+ formatHandlerFactory.buildFormatHandler( formattings[i] ).render( source );
}
}
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/Options.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -28,12 +28,6 @@
private String xmlTransformerType;
private Properties transformerParameters;
private boolean useRelativeImageUris = true;
- // TODO : try as hard as I possibly can to remove this :(
- // this is gettable either from (1) VERSION (fm:project/fm:Version) or
- // (2) the dependencies making up the execution classpath
- //
- // In #1, it would require hand parsing :(, and #2 I've yet to actually
- // find a wsay to do this...
private String docbookVersion;
public Options() {
@@ -77,4 +71,8 @@
public String getDocbookVersion() {
return docbookVersion;
}
+
+ void setDocbookVersion(String docbookVersion) {
+ this.docbookVersion = docbookVersion;
+ }
}
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/PackageMojo.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -15,13 +15,16 @@
*/
package org.jboss.maven.plugin.docbook;
-import org.jboss.maven.plugin.docbook.gen.render.Formatting;
-import org.jboss.maven.plugin.docbook.gen.render.RenderingException;
+import java.io.File;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
+import org.jboss.maven.plugin.docbook.gen.RenderingException;
+import org.jboss.maven.plugin.docbook.gen.format.FormatHandlerFactory;
+
/**
* This mojo's purpose within the plugin/packaging is to bundle the individual
- * formats into deployable bundles. Note that some formats (PDF, e.g.) are
- * already in a deployable bundle.
+ * formats into deployable formats. Note that some formats (PDF, e.g.) are
+ * already deployable.
* <p/>
* After bundling, each bundle is then attached to the project
*
@@ -33,5 +36,21 @@
*/
public class PackageMojo extends AbstractDocBookMojo {
protected void process(Formatting[] formattings) throws RenderingException {
+ File source = new File( sourceDirectory, sourceDocumentName );
+ FormatHandlerFactory formatHandlerFactory = new FormatHandlerFactory(
+ options,
+ source,
+ targetDirectory,
+ stagingDirectory,
+ null,
+ project,
+ getLog()
+ );
+
+ project.getArtifact().setFile( project.getFile() );
+
+ for ( int i = 0; i < formattings.length; i++ ) {
+ formatHandlerFactory.buildFormatHandler( formattings[i] ).attachOutput( source, projectHelper );
+ }
}
}
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/ResourceMojo.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -17,21 +17,18 @@
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.List;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.resources.ResourcesMojo;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
-import org.jboss.maven.plugin.docbook.gen.render.Formatting;
-import org.jboss.maven.plugin.docbook.gen.render.RenderingException;
-import org.jboss.maven.plugin.docbook.gen.xslt.XSLTException;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
+import org.jboss.maven.plugin.docbook.gen.RenderingException;
+import org.jboss.maven.plugin.docbook.gen.XSLTException;
/**
* This mojo's purpose within the plugin/packaging is to process resources
@@ -49,78 +46,76 @@
protected void process(Formatting[] formattings) throws RenderingException, XSLTException {
processProjectResources();
- processDependencyResources( collectDocBookResourceDependentArtifacts() );
+ processDependencySupportArtifacts( collectDocBookSupportDependentArtifacts() );
}
- private Artifact[] collectDocBookResourceDependentArtifacts() {
- List artifacts = new ArrayList();
- addDocBookResourceArtifacts( artifacts, projectArtifacts );
- addDocBookResourceArtifacts( artifacts, pluginArtifacts );
- return ( Artifact[] ) artifacts.toArray( new Artifact[ artifacts.size() ] );
- }
+ // project local resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- private void addDocBookResourceArtifacts(Collection target, Collection source) {
- Iterator itr = source.iterator();
- while ( itr.hasNext() ) {
- final Artifact artifact = ( Artifact ) itr.next();
- if ( "docbook-xslt".equals( artifact.getType() ) ||
- "docbook-resources".equals( artifact.getType() ) ) {
- target.add( artifact );
- }
- // temp...
- else if ( "docbook-xslt".equals( artifact.getArtifactId() ) ) {
- target.add( artifact );
- }
- }
+ private void processProjectResources() throws RenderingException {
+ copySource( imagesDirectory, new File( stagingDirectory, "images" ) );
+ copySource( cssDirectory, new File( stagingDirectory, "css" ) );
+ copySource( fontsDirectory, new File( stagingDirectory, "fonts" ) );
}
- private void processProjectResources() throws RenderingException {
- ResourcesMojo mavenResourcesMojo = new ResourcesMojo();
- injectMojoValue( mavenResourcesMojo, "outputDirectory", stagingDirectory.getAbsolutePath() );
- injectMojoValue( mavenResourcesMojo, "resources", project.getResources() );
- injectMojoValue( mavenResourcesMojo, "project", project );
- injectMojoValue( mavenResourcesMojo, "filters", project.getBuild().getFilters() );
- mavenResourcesMojo.setLog( getLog() );
- try {
- mavenResourcesMojo.execute();
+ private void copySource(File sourceDirectory, File targetDirectory)
+ throws RenderingException {
+ getLog().info( "attempting to copy directory : " + sourceDirectory.getAbsolutePath() );
+ if ( !sourceDirectory.exists() ) {
+ return;
}
- catch ( MojoExecutionException e ) {
- throw new RenderingException( "unable to process project resources" );
+ String[] list = sourceDirectory.list();
+ if ( list == null || list.length == 0 ) {
+ return;
}
- }
- private void injectMojoValue(ResourcesMojo mavenResourcesMojo, String name, Object value) throws RenderingException {
+ if ( !targetDirectory.exists() ) {
+ targetDirectory.mkdirs();
+ }
+
try {
- Field field = ResourcesMojo.class.getDeclaredField( name );
- if ( !field.isAccessible() ) {
- field.setAccessible( true );
- }
- field.set( mavenResourcesMojo, value );
+ FileUtils.copyDirectoryStructure( sourceDirectory, targetDirectory );
}
- catch ( NoSuchFieldException e ) {
- throw new RenderingException( "unable to locate mojo property field [" + name + "]", e );
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy source directory [" + sourceDirectory.getAbsolutePath() + "]", e );
}
- catch ( IllegalAccessException e ) {
- throw new RenderingException( "unable to access property field to set value", e );
- }
}
- private void processDependencyResources(Artifact[] resources)
- throws RenderingException {
- for ( int i = 0; i < resources.length; i++ ) {
- processDependencyResource( resources[i].getFile(), stagingDirectory );
+
+ // dependency support resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private List collectDocBookSupportDependentArtifacts() {
+ final ArrayList rtn = new ArrayList();
+ processArtifacts(
+ new ArtifactProcessor() {
+ public void process(Artifact artifact) {
+ if ( "docbook-support".equals( artifact.getType() ) ) {
+ rtn.add( artifact );
+ }
+ }
+ }
+ );
+ return rtn;
+ }
+
+ private void processDependencySupportArtifacts(List artifacts) throws RenderingException {
+ Iterator itr = artifacts.iterator();
+ while ( itr.hasNext() ) {
+ final Artifact supportArtifact = ( Artifact ) itr.next();
+ processDependencySupportArtifact( supportArtifact.getFile(), stagingDirectory );
}
}
- protected void processDependencyResource(File file, File target) throws RenderingException {
+ protected void processDependencySupportArtifact(File file, File target) throws RenderingException {
getLog().info( "unpacking dependency resource [" + file.getAbsolutePath() + "] to staging-dir [" + target.getAbsolutePath() + "]" );
try {
target.mkdirs();
- UnArchiver unArchiver = archiverManager.getUnArchiver( file );
+// :(
+// UnArchiver unArchiver = archiverManager.getUnArchiver( file );
+ UnArchiver unArchiver = archiverManager.getUnArchiver( "jar" );
unArchiver.setSourceFile( file );
unArchiver.setDestDirectory( target );
- unArchiver.extract();
- }
+ unArchiver.extract();
+ }
catch ( NoSuchArchiverException e ) {
throw new RenderingException( "Unknown archiver type", e );
}
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/TranslationDiffReport.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -17,22 +17,18 @@
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
-import org.apache.maven.doxia.siterenderer.Renderer;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.reporting.MavenReport;
import org.apache.maven.reporting.MavenReportException;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.jboss.maven.plugin.docbook.revdiff.IndexReportGenerator;
-import org.jboss.maven.plugin.docbook.revdiff.DiffCreator;
-import org.jboss.maven.plugin.docbook.revdiff.TranslationReportGenerator;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
+import org.jboss.maven.plugin.docbook.gen.RenderingException;
import org.jboss.maven.plugin.docbook.revdiff.Diff;
+import org.jboss.maven.plugin.docbook.revdiff.DiffCreator;
import org.jboss.maven.plugin.docbook.revdiff.GenerationException;
+import org.jboss.maven.plugin.docbook.revdiff.TranslationReportGenerator;
/**
* A plugin for generating a "translation diff" report across different
@@ -43,103 +39,46 @@
* forward if it is decided to move to the xliff format for translations.
*
* @goal diff
+ * @phase site
+ * @requiresDependencyResolution
*
* @author Christian Bauer
* @author Steve Ebersole
*/
-public class TranslationDiffReport extends AbstractMavenReport {
+public class TranslationDiffReport extends AbstractDocBookMojo implements MavenReport {
- // todo : this is currently hosed; it has not been updated for the new packaging-based scheme...
-
public static final String NAME = "translation-diff-report";
+ private File reportOutputDirectory;
- /**
- * The directory containing the translated DocBook sources.
- *
- * @parameter expression="${basedir}/src/main/docbook/translations"
- * @required
- */
- private File translationsDirectory;
+ private ResourceBundle getBundle(Locale locale) {
+ return ResourceBundle.getBundle( NAME, locale, this.getClass().getClassLoader() );
+ }
- /**
- * Directory where reports will go.
- *
- * @parameter expression="${project.reporting.outputDirectory}"
- * @required
- * @readonly
- */
- private File reportingDirectory;
+ private String buildReportFileName() {
+ return getOutputName() + ".html";
+ }
- /**
- * Which translation is considered the master.
- *
- * @parameter default-value="en"
- */
- private String masterTranslation;
+ // AbstractDocBookMojo impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
- * (non master) translations to be included in the report.
+ * Copied nearly verbatim from {@link org.apache.maven.reporting.AbstractMavenReport#execute()}
*
- * @parameter
+ * {@inheritDoc}
*/
- private String[] translationIncludes;
-
- /**
- * Patternsets of sources (relative to translationsDirectory) to include
- * in reporting.
- *
- * @parameter
- */
- private String[] sourceIncludes;
-
- /**
- * A boolean, indicating if XInclude should be supported.
- *
- * @parameter default-value="false"
- */
- private boolean xincludeSupported;
-
- /**
- * Whether to build an aggregated report at the root, or build individual reports.
- *
- * @parameter expression="${aggregate}" default-value="false"
- */
- protected boolean aggregate;
-
- /**
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- private File reportOutputDirectory;
-
- /**
- * @parameter expression="${component.org.apache.maven.doxia.siterenderer.Renderer}"
- * @required
- * @readonly
- */
- private Renderer siteRenderer;
-
- protected Renderer getSiteRenderer() {
- return siteRenderer;
+ protected void process(Formatting[] formattings) throws RenderingException {
+ try {
+ generateReport( Locale.getDefault() );
+ }
+ catch (GenerationException t) {
+ throw new RenderingException( "An error has occurred in " + NAME + " report generation.", t );
+ }
}
- protected MavenProject getProject() {
- return project;
- }
- public String getCategoryName() {
- return CATEGORY_PROJECT_REPORTS;
- }
+ // MavenReport impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- protected String getOutputDirectory() {
- return getReportOutputDirectory().getAbsolutePath();
- }
-
public String getOutputName() {
- return "index";
+ return NAME;
}
public String getName(Locale locale) {
@@ -150,22 +89,17 @@
return getBundle( locale ).getString( "report.description" );
}
- private ResourceBundle getBundle(Locale locale) {
- return ResourceBundle.getBundle( NAME, locale, this.getClass().getClassLoader() );
+ public String getCategoryName() {
+ return CATEGORY_PROJECT_REPORTS;
}
public void setReportOutputDirectory(File dir) {
- if ( NAME.equals( dir.getName() ) ) {
- this.reportOutputDirectory = dir;
- }
- else {
- this.reportOutputDirectory = new File( dir, NAME );
- }
+ this.reportOutputDirectory = dir;
}
public File getReportOutputDirectory() {
if ( reportOutputDirectory == null ) {
- reportOutputDirectory = new File( reportingDirectory, NAME );
+ reportOutputDirectory = new File( project.getReporting().getOutputDirectory() );
}
return reportOutputDirectory;
}
@@ -175,62 +109,69 @@
}
public boolean canGenerateReport() {
- return true;
+ return masterTranslationArtifactId != null ||
+ ( masterTranslationFile != null && masterTranslationFile.exists() );
}
- protected void executeReport(Locale locale) throws MavenReportException {
- getLog().debug( "starting docbook:diff goal execution [masterTranslation=" + masterTranslation + "]" );
-
- if ( ! translationsDirectory.exists() ) {
- getLog().debug( "translations directory [" + translationsDirectory.getAbsolutePath() + "] did not exist" );
- return;
+ public void generate(org.codehaus.doxia.sink.Sink sink, Locale locale) throws MavenReportException {
+ try {
+ generateReport( locale );
}
+ catch ( GenerationException e ) {
+ throw new MavenReportException( "error generating report", e );
+ }
+ }
- File masterTranslationDirectory = new File( translationsDirectory, masterTranslation );
- if ( ! masterTranslationDirectory.exists() ) {
- getLog().info( "master translation directory [" + masterTranslationDirectory.getAbsolutePath() + "] did not exist" );
+
+ // report generation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ private void generateReport(Locale locale) throws GenerationException {
+ getLog().debug( "starting " + PLUGIN_NAME + ":diff goal execution" );
+
+ if ( !canGenerateReport() ) {
+ getLog().info( "project is documentation master (or no master defined)" );
return;
}
- if ( translationIncludes == null || translationIncludes.length == 0 ) {
- // use all translations...
- ArrayList includes = new ArrayList();
- File[] subdirs = translationsDirectory.listFiles();
- for ( int i = 0; i < subdirs.length; i++ ) {
- includes.add( subdirs[i].getName() );
- }
- translationIncludes = ( String[] ) includes.toArray( new String[ includes.size() ] );
+ File master = masterTranslationFile;
+ if ( master == null ) {
+ MasterTranslationLocator locator = new MasterTranslationLocator();
+ processArtifacts( locator );
+ master = locator.located.getFile();
}
-
- if ( sourceIncludes == null || sourceIncludes.length == 0 ) {
- sourceIncludes = new String[] { "*.xml" };
+ if ( master == null ) {
+ throw new GenerationException( "unable to locate master source" );
}
- List reports = new ArrayList();
- for ( int i = 0; i < translationIncludes.length; i++ ) {
- if ( masterTranslation.equals( translationIncludes[i] ) ) {
- continue;
- }
- final File translationDirectory = new File( translationsDirectory, translationIncludes[i] );
- if ( ! translationDirectory.exists() ) {
- getLog().info( "translation directory [" + translationDirectory.getAbsolutePath() + "] did not exist" );
- continue;
- }
+ File translation = new File( sourceDirectory, sourceDocumentName );
- if ( generateTranslationReport( masterTranslationDirectory, translationDirectory, translationIncludes[i] ) ) {
- reports.add(
- new IndexReportGenerator.TranslationReportDescriptor(
- new Locale( translationIncludes[i] ),
- NAME + "/" + buildTranslationReportName( translationIncludes[i] )
- )
- );
+ getLog().debug( " master : " + master.getAbsolutePath() );
+ getLog().debug( " translation : " + translation.getAbsolutePath() );
+
+ File output = new File( getReportOutputDirectory(), buildReportFileName() );
+ prepReportFile( output );
+
+ DiffCreator diffCreator = new DiffCreator( options.isXincludeSupported(), getLog() );
+ Diff diff = diffCreator.findDiff( master, translation );
+
+ TranslationReportGenerator generator = new TranslationReportGenerator( sourceDirectory, getBundle( locale ), getLog() );
+ generator.generate( diff, output, locale.toString() );
+ }
+
+ class MasterTranslationLocator implements ArtifactProcessor {
+ private final String groupId = project.getGroupId();
+ private Artifact located;
+ public void process(Artifact artifact) {
+ if ( groupId.equals( artifact.getGroupId() ) && masterTranslationArtifactId.equals( artifact.getArtifactId() ) ) {
+ if ( located != null ) {
+ getLog().warn( "duplicate matching master found" );
+ }
+ located = artifact;
}
}
-
- new IndexReportGenerator( getBundle( locale ), getSink(), getLog() ).generate( reports );
}
- private void prepReportFile(File reportFile) throws MavenReportException {
+ private void prepReportFile(File reportFile) throws GenerationException {
if ( reportFile.exists() ) {
reportFile.delete();
}
@@ -239,58 +180,8 @@
reportFile.createNewFile();
}
catch ( IOException e ) {
- throw new MavenReportException( "unable to prep report file [" + reportFile.getAbsolutePath() + "]" );
+ throw new GenerationException( "unable to prep report file [" + reportFile.getAbsolutePath() + "]" );
}
}
}
-
- private String buildTranslationReportName(String translationName) {
- return "report-" + translationName + ".html";
- }
-
- private boolean generateTranslationReport(
- File masterTranslationDirectory,
- File translationDirectory,
- String translationName) throws MavenReportException {
- getLog().debug( "starting docbook:diff processing [translation=" + translationName + "]" );
-
- DirectoryScanner scanner = new DirectoryScanner();
- scanner.setBasedir( masterTranslationDirectory );
- scanner.setIncludes( sourceIncludes );
- scanner.scan();
- String[] masterSources = scanner.getIncludedFiles();
-
- scanner = new DirectoryScanner();
- scanner.setBasedir( translationDirectory );
- scanner.setIncludes( sourceIncludes );
- scanner.scan();
- String[] translationSources = scanner.getIncludedFiles();
-
- if ( ! Arrays.equals( masterSources, translationSources ) ) {
- getLog().warn( "includes returned different master and translation sets" );
- return false;
- }
-
- Locale locale = new Locale( translationName );
- File output = new File( getReportOutputDirectory(), buildTranslationReportName( translationName ) );
- prepReportFile( output );
-
- try {
- DiffCreator diffCreator = new DiffCreator( xincludeSupported, getLog() );
- TranslationReportGenerator generator = new TranslationReportGenerator( translationsDirectory, getBundle( locale ), getLog() );
-
- for ( int i = 0; i < masterSources.length; i++ ) {
- getLog().debug( "processing source [" + masterSources[i] + "]" );
- final File master = new File( masterTranslationDirectory, masterSources[i] );
- final File translation = new File( translationDirectory, translationSources[i] );
- final Diff diff = diffCreator.findDiff( master, translation );
- generator.generate( diff, output, locale.toString() );
- }
- }
- catch ( GenerationException e ) {
- throw new MavenReportException( "unable to generate report", e );
- }
- return true;
- }
-
}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/RenderingException.java (from rev 11694, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/render/RenderingException.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/RenderingException.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/RenderingException.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugin.docbook.gen;
+
+/**
+ * Indicates issues performing rendering.
+ *
+ * @author Steve Ebersole
+ */
+public class RenderingException extends Exception {
+
+ public RenderingException(String message) {
+ super( message );
+ }
+
+ public RenderingException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/XSLTException.java (from rev 11694, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/XSLTException.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/XSLTException.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/XSLTException.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugin.docbook.gen;
+
+/**
+ * Indicates problems either building XSLT transformers or performing
+ * transformations.
+ *
+ * @author Steve Ebersole
+ */
+public class XSLTException extends Exception {
+
+ public XSLTException(String message) {
+ super( message );
+ }
+
+ public XSLTException(String message, Throwable cause) {
+ super( message, cause );
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/BasicFormatHandler.java (from rev 11694, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/render/BasicRenderer.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/BasicFormatHandler.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/BasicFormatHandler.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -0,0 +1,215 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugin.docbook.gen.format;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stream.StreamResult;
+
+import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProjectHelper;
+import org.codehaus.plexus.archiver.ArchiverException;
+import org.codehaus.plexus.archiver.jar.JarArchiver;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.docbook.gen.RenderingException;
+import org.jboss.maven.plugin.docbook.gen.XSLTException;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
+import org.jboss.maven.plugin.docbook.gen.util.ResourceHelper;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+/**
+ * Provides basic support for renderers, mainly in the form of templating.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicFormatHandler implements FormatHandler {
+ public static final String DTD_VALIDATION_FEATURE = "http://xml.org/sax/features/validation";
+ public static final String DTD_LOADING_FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd";
+
+ protected final FormatHandlerFactory factory;
+ protected final Formatting formatting;
+
+ public BasicFormatHandler(FormatHandlerFactory factory, Formatting formatting) {
+ this.factory = factory;
+ this.formatting = formatting;
+ }
+
+ public File prepareDirectory() throws RenderingException {
+ File target = new File( factory.getTargetDirectory(), formatting.getFormatName() );
+ if ( ! target.exists() ) {
+ FileUtils.mkdir( target.getAbsolutePath() );
+ }
+ if ( formatting.isImageCopyingRequired() ) {
+ if ( factory.getStagingDirectory().exists() ) {
+ File imageBase = new File( factory.getStagingDirectory(), "images" );
+ if ( imageBase.exists() ) {
+ try {
+ FileUtils.copyDirectoryStructure( imageBase, target );
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to copy images", e );
+ }
+ }
+ }
+ }
+ return target;
+ }
+
+ public void attachOutput(File sourceFile, MavenProjectHelper projectHelper) throws RenderingException {
+ File rawOutputDir = new File( factory.getTargetDirectory(), formatting.getFormatName() );
+
+ String warName = factory.getMavenProject().getBuild().getFinalName() +
+ "-" + formatting.getFormatName() + ".war";
+ File war = new File( factory.getTargetDirectory(), warName );
+
+ JarArchiver archiver = new JarArchiver();
+ archiver.setDestFile( war );
+ try {
+ archiver.addDirectory( rawOutputDir );
+ archiver.createArchive();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "Unable to create archive [" + war.getAbsolutePath() + "]", e );
+ }
+ catch ( ArchiverException e ) {
+ throw new RenderingException( "Unable to populate archive [" + war.getAbsolutePath() + "]", e );
+ }
+
+ projectHelper.attachArtifact( factory.getMavenProject(), "war", formatting.getFormatName(), war );
+ }
+
+ public final void render(File sourceFile) throws RenderingException, XSLTException {
+ getLog().debug( "starting formatting [" + formatting.getFormatName() + "]" );
+
+ File target = prepareTarget( prepareDirectory(), sourceFile );
+
+ Transformer transformer = buildTransformer( target );
+ Source transformationSource = buildSource( sourceFile );
+ Result transformationResult = buildResult( target );
+ try {
+ transformer.transform( transformationSource, transformationResult );
+ }
+ catch ( TransformerException e ) {
+ throw new XSLTException( "unable to perform transformation", e );
+ }
+ finally {
+ releaseResult( transformationResult );
+ }
+ }
+
+ private File prepareTarget(File directory, File sourceFile) throws RenderingException {
+ String targetFileName = deduceTargetFileName( sourceFile );
+ getLog().debug( "preparing target file [" + targetFileName + "]" );
+ File target = new File( directory, targetFileName );
+ if ( target.exists() ) {
+ if ( !target.delete() ) {
+ getLog().warn( "unable to clean up previous output file [" + target.getAbsolutePath() + "]" );
+ }
+ }
+ if ( !target.exists() ) {
+ try {
+ target.createNewFile();
+ }
+ catch ( IOException e ) {
+ throw new RenderingException( "unable to create output file [" + target.getAbsolutePath() + "]", e );
+ }
+ }
+ return target;
+ }
+
+ private String deduceTargetFileName(File source) {
+ return formatting.getNamingStrategy().deduceTargetFileName( source );
+ }
+
+ protected Transformer buildTransformer(File targetFile) throws RenderingException, XSLTException {
+ final URL transformationStylesheet = resolveTransformationStylesheet();
+ Transformer transformer = factory.getTransformerFactory()
+ .buildTransformer( formatting, transformationStylesheet );
+ if ( formatting.isImagePathSettingRequired() ) {
+ String imgSrcPath = factory.getStagingDirectory().getAbsolutePath() + "/images/";
+ getLog().debug( "setting 'img.src.path' [" + imgSrcPath + "]" );
+ transformer.setParameter( "img.src.path", imgSrcPath );
+ }
+ if ( factory.getOptions().isUseRelativeImageUris() ) {
+ getLog().debug( "enforcing retention of relative image URIs" );
+ transformer.setParameter( "keep.relative.image.uris", "0" );
+ }
+ if ( formatting.isDoingChunking() ) {
+ getLog().debug( "Chunking output." );
+ String rootFilename = targetFile.getName();
+ rootFilename = rootFilename.substring( 0, rootFilename.lastIndexOf( '.' ) );
+ transformer.setParameter( "root.filename", rootFilename );
+ transformer.setParameter( "base.dir", targetFile.getParent() + File.separator );
+ transformer.setParameter( "manifest.in.base.dir", "1" );
+ }
+ return transformer;
+ }
+
+ protected final URL resolveTransformationStylesheet() throws RenderingException {
+ return ResourceHelper.requireResource( formatting.getStylesheetResource() );
+ }
+
+ private Source buildSource(File sourceFile) throws RenderingException {
+ try {
+ EntityResolver resolver = factory.getCatalogResolver();
+ SAXParserFactory factory = createParserFactory();
+ XMLReader reader = factory.newSAXParser().getXMLReader();
+ reader.setEntityResolver( resolver );
+
+ // Disable DTD loading and validation
+ reader.setFeature( DTD_LOADING_FEATURE, false );
+ reader.setFeature( DTD_VALIDATION_FEATURE, false );
+
+ return new SAXSource( reader, new InputSource( sourceFile.getAbsolutePath() ) );
+ }
+ catch ( ParserConfigurationException e ) {
+ throw new RenderingException( "unable to build SAX Parser", e );
+ }
+ catch ( SAXException e ) {
+ throw new RenderingException( "unable to build SAX Parser", e );
+ }
+ }
+
+ protected final SAXParserFactory createParserFactory() {
+ SAXParserFactory parserFactory = new SAXParserFactoryImpl();
+ parserFactory.setXIncludeAware( factory.getOptions().isXincludeSupported() );
+ return parserFactory;
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException, XSLTException {
+ return new StreamResult( targetFile );
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ // typically nothing to do...
+ }
+
+ protected Log getLog() {
+ return factory.getLog();
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/FormatHandler.java (from rev 11694, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/render/Renderer.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/FormatHandler.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/FormatHandler.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugin.docbook.gen.format;
+
+import java.io.File;
+
+import org.apache.maven.project.MavenProjectHelper;
+import org.jboss.maven.plugin.docbook.gen.RenderingException;
+import org.jboss.maven.plugin.docbook.gen.XSLTException;
+
+/**
+ * Handles format-specific processing steps.
+ *
+ * @author Steve Ebersole
+ */
+public interface FormatHandler {
+ /**
+ * This is used during the prepare-resources phase to create and prepare
+ * the format specific output directory for rendering. Generally,
+ * preparation might mean copying any format-specific resources to the
+ * format output directory.
+ *
+ * @return The format output directory
+ * @throws RenderingException
+ */
+ public File prepareDirectory() throws RenderingException;
+
+ /**
+ * Performs the actual rendering or transforming of the DocBook sources into
+ * the respective output format.
+ *
+ * @param source The source DocBook file.
+ * @throws RenderingException Problem writing the output file(s).
+ * @throws XSLTException Problem performing XSL transformation.
+ */
+ public void render(File source) throws RenderingException, XSLTException;
+
+ /**
+ * Attaches the formatting output (after possibly bundling it into an archive)
+ * to the maven project.
+ *
+ * @param sourceFile The source DocBook file.
+ * @param projectHelper The project helper (used to attach produced artifact)
+ * @throws RenderingException
+ */
+ public void attachOutput(File sourceFile, MavenProjectHelper projectHelper) throws RenderingException;
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/FormatHandlerFactory.java (from rev 11694, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/render/RendererFactory.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/FormatHandlerFactory.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/FormatHandlerFactory.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -0,0 +1,132 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugin.docbook.gen.format;
+
+import java.io.File;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.apache.xml.resolver.CatalogManager;
+import org.apache.xml.resolver.tools.CatalogResolver;
+import org.jboss.maven.plugin.docbook.Options;
+import org.jboss.maven.plugin.docbook.gen.util.StandardDocBookFormatSpecification;
+import org.jboss.maven.plugin.docbook.gen.util.TransformerType;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
+import org.jboss.maven.plugin.docbook.gen.xslt.TransformerFactory;
+import org.jboss.maven.plugin.docbook.gen.XSLTException;
+import org.jboss.maven.plugin.docbook.gen.xslt.catalog.ExplicitCatalogManager;
+import org.jboss.maven.plugin.docbook.gen.xslt.catalog.ImplicitCatalogManager;
+import org.jboss.maven.plugin.docbook.gen.format.FormatHandler;
+import org.jboss.maven.plugin.docbook.gen.format.BasicFormatHandler;
+import org.jboss.maven.plugin.docbook.gen.format.PdfFormatHandler;
+
+/**
+ * Builds a renderer for the given format
+ *
+ * @author Steve Ebersole
+ */
+public class FormatHandlerFactory {
+ private final Options options;
+ private final File source;
+ private final File targetDirectory;
+ private final File stagingDirectory;
+ private final File fontConfig;
+ private final MavenProject mavenProject;
+ private final Log log;
+
+ private CatalogResolver catalogResolver;
+ private TransformerFactory transformerFactory;
+
+ public FormatHandlerFactory(
+ Options options,
+ File source,
+ File targetDirectory,
+ File stagingDirectory,
+ File fontConfig,
+ MavenProject mavenProject,
+ Log log) {
+ this.options = options;
+ this.source = source;
+ this.targetDirectory = targetDirectory;
+ this.stagingDirectory = stagingDirectory;
+ this.fontConfig = fontConfig;
+ this.mavenProject = mavenProject;
+ this.log = log;
+ }
+
+ public Options getOptions() {
+ return options;
+ }
+
+ public File getSource() {
+ return source;
+ }
+
+ public File getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ public File getStagingDirectory() {
+ return stagingDirectory;
+ }
+
+ public File getFontConfig() {
+ return fontConfig;
+ }
+
+ public MavenProject getMavenProject() {
+ return mavenProject;
+ }
+
+ public Log getLog() {
+ return log;
+ }
+
+ public CatalogResolver getCatalogResolver() {
+ if ( catalogResolver == null ) {
+ CatalogManager catalogManager;
+ if ( options.getCatalogs() == null || options.getCatalogs().length == 0 ) {
+ catalogManager = new ImplicitCatalogManager();
+ }
+ else {
+ catalogManager = new ExplicitCatalogManager( options.getCatalogs() );
+ }
+ catalogResolver = new CatalogResolver( catalogManager );
+ }
+ return catalogResolver;
+ }
+
+ public TransformerFactory getTransformerFactory() {
+ if ( transformerFactory == null ) {
+ transformerFactory = new TransformerFactory(
+ TransformerType.parse( options.getXmlTransformerType() ),
+ options.getTransformerParameters(),
+ getCatalogResolver(),
+ options.getDocbookVersion()
+ );
+ }
+ return transformerFactory;
+ }
+
+ public FormatHandler buildFormatHandler(Formatting formatting) {
+ if ( formatting.getFormatName().equals( StandardDocBookFormatSpecification.PDF.getName() ) ) {
+ return new PdfFormatHandler( this, formatting );
+ }
+ else {
+ return new BasicFormatHandler( this, formatting );
+ }
+ }
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/PdfFormatHandler.java (from rev 11694, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/render/PdfRenderer.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/PdfFormatHandler.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/format/PdfFormatHandler.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -0,0 +1,176 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugin.docbook.gen.format;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import javax.xml.transform.Result;
+import javax.xml.transform.sax.SAXResult;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.fop.apps.Driver;
+import org.apache.fop.apps.FOPException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProjectHelper;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
+import org.jboss.maven.plugin.docbook.gen.RenderingException;
+
+/**
+ * Special handling for pdf rendering
+ *
+ * @author Steve Ebersole
+ */
+public class PdfFormatHandler extends BasicFormatHandler {
+
+ public PdfFormatHandler(FormatHandlerFactory factory, Formatting formatting) {
+ super( factory, formatting );
+ }
+
+ protected Result buildResult(File targetFile) throws RenderingException {
+ getLog().info( "building formatting result [" + targetFile.getAbsolutePath() + "]" );
+ prepareFonts();
+ return new ResultImpl( targetFile );
+ }
+
+ private void prepareFonts() throws RenderingException {
+ // if fonts were specified, then prepare the FOP font metrics configuration
+ // : this is the piece that improved dramatically after fop-0.25,
+ // which unfortunately we are stuck with for other reasons :(
+ if ( factory.getFontConfig() != null ) {
+ org.apache.fop.configuration.Configuration.put( "fontBaseDir", new File( factory.getStagingDirectory(), "fonts" ) );
+ try {
+ new org.apache.fop.apps.Options( factory.getFontConfig() );
+ }
+ catch ( FOPException e ) {
+ throw new RenderingException( "unable to properly prepare FOP fonts", e );
+ }
+ org.apache.fop.configuration.Configuration.put( "fontBaseDir", new File( factory.getStagingDirectory(), "fonts" ) );
+ }
+ }
+
+ protected void releaseResult(Result transformationResult) {
+ ( ( ResultImpl ) transformationResult ).release();
+ }
+
+ private class ResultImpl extends SAXResult {
+ private OutputStream outputStream;
+
+ public ResultImpl(File targetFile) throws RenderingException {
+ Driver driver = new Driver();
+ driver.setLogger( new LoggingBridge( getLog() ) );
+ driver.setRenderer( Driver.RENDER_PDF );
+
+ try {
+ outputStream = new BufferedOutputStream( new FileOutputStream( targetFile ) );
+ driver.setOutputStream( outputStream );
+ setHandler( driver.getContentHandler() );
+ }
+ catch ( Throwable t ) {
+ throw new RenderingException( "error building transformation result [" + targetFile.getAbsolutePath() + "]", t );
+ }
+ }
+
+ private void release() {
+ try {
+ outputStream.flush();
+ outputStream.close();
+ }
+ catch ( IOException e ) {
+ getLog().warn( "error releasing I/O resources", e );
+ }
+ }
+ }
+
+ private static class LoggingBridge implements Logger {
+
+ private Log mavenLog;
+
+ public LoggingBridge(Log mavenLog) {
+ this.mavenLog = mavenLog;
+ }
+
+ public Logger getChildLogger(String arg0) {
+ return null;
+ }
+
+ public void debug(String arg0) {
+ mavenLog.debug( arg0 );
+ }
+
+ public void debug(String arg0, Throwable arg1) {
+ mavenLog.debug( arg0, arg1 );
+ }
+
+ // todo : info logging from FOP is excessively verbose...
+
+ public void info(String arg0) {
+ mavenLog.info( arg0 );
+ }
+
+ public void info(String arg0, Throwable arg1) {
+ mavenLog.info( arg0, arg1 );
+ }
+
+ public void warn(String arg0) {
+ mavenLog.warn( arg0 );
+ }
+
+ public void warn(String arg0, Throwable arg1) {
+ mavenLog.warn( arg0, arg1 );
+ }
+
+ public void error(String arg0) {
+ mavenLog.error( arg0 );
+ }
+
+ public void error(String arg0, Throwable arg1) {
+ mavenLog.error( arg0, arg1 );
+ }
+
+ public void fatalError(String arg0) {
+ mavenLog.error( arg0 );
+ }
+
+ public void fatalError(String arg0, Throwable arg1) {
+ mavenLog.error( arg0, arg1 );
+ }
+
+ public boolean isDebugEnabled() {
+ return mavenLog.isDebugEnabled();
+ }
+
+ public boolean isErrorEnabled() {
+ return mavenLog.isErrorEnabled();
+ }
+
+ public boolean isFatalErrorEnabled() {
+ return mavenLog.isErrorEnabled();
+ }
+
+ public boolean isInfoEnabled() {
+ return mavenLog.isInfoEnabled();
+ }
+
+ public boolean isWarnEnabled() {
+ return mavenLog.isWarnEnabled();
+ }
+
+ }
+
+}
Copied: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/util/Formatting.java (from rev 11694, trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/render/Formatting.java)
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/util/Formatting.java (rev 0)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/util/Formatting.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -0,0 +1,118 @@
+/*
+ * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.jboss.maven.plugin.docbook.gen.util;
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.docbook.Format;
+import org.jboss.maven.plugin.docbook.gen.util.StandardDocBookFormatSpecification;
+
+/**
+ * Defined formatting information. Basically stuff to either pass into the xsl
+ * transformer or stuff needed to prepare for transformation.
+ *
+ * @author Steve Ebersole
+ */
+public class Formatting {
+ private final String formatName;
+ private final String stylesheetResource;
+ private final boolean imagePathSettingRequired;
+ private final boolean imageCopyingRequired;
+ private final boolean doingChunking;
+ private final StandardDocBookFormatSpecification standardDocBookSpec;
+ private final TargetNamingStrategy namingStrategy;
+
+ public Formatting(StandardDocBookFormatSpecification standardDocBookSpec, Format userSpec) {
+ // todo : there may not be a matching standard docbook format spec...
+ if ( ! standardDocBookSpec.getName().equals( userSpec.getFormatName() ) ) {
+ throw new IllegalArgumentException( "formatting type mismatch" );
+ }
+
+ this.standardDocBookSpec = standardDocBookSpec;
+ this.formatName = userSpec.getFormatName();
+
+ this.stylesheetResource = userSpec.getStylesheetResource() == null
+ ? standardDocBookSpec.getStylesheetResource()
+ : "/styles" + userSpec.getStylesheetResource();
+
+ this.imageCopyingRequired = userSpec.getImageCopyingRequired() == null
+ ? standardDocBookSpec.isImageCopyingRequired()
+ : userSpec.getImageCopyingRequired().booleanValue();
+
+ this.imagePathSettingRequired = userSpec.getImagePathSettingRequired() == null
+ ? standardDocBookSpec.isImagePathSettingRequired()
+ : userSpec.getImagePathSettingRequired().booleanValue();
+
+ this.doingChunking =userSpec.getDoingChunking() == null
+ ? standardDocBookSpec.isDoingChunking()
+ : userSpec.getDoingChunking().booleanValue();
+
+ this.namingStrategy = new TargetNamingStrategy( standardDocBookSpec, userSpec );
+ }
+
+ public String getFormatName() {
+ return formatName;
+ }
+
+ public StandardDocBookFormatSpecification getStandardDocBookSpec() {
+ return standardDocBookSpec;
+ }
+
+ public String getStylesheetResource() {
+ return stylesheetResource;
+ }
+
+ public boolean isImagePathSettingRequired() {
+ return imagePathSettingRequired;
+ }
+
+ public boolean isImageCopyingRequired() {
+ return imageCopyingRequired;
+ }
+
+ public boolean isDoingChunking() {
+ return doingChunking;
+ }
+
+ public TargetNamingStrategy getNamingStrategy() {
+ return namingStrategy;
+ }
+
+ public static class TargetNamingStrategy {
+ private String targetFileExtension;
+ private String finalName;
+
+ public TargetNamingStrategy(StandardDocBookFormatSpecification standardDocBookSpec, Format userSpec) {
+ if ( userSpec.getFinalName() != null ) {
+ this.targetFileExtension = null;
+ this.finalName = userSpec.getFinalName();
+ }
+ else {
+ this.targetFileExtension = userSpec.getTargetFileExtension() == null
+ ? standardDocBookSpec.getStandardFileExtension()
+ : userSpec.getTargetFileExtension();
+ this.finalName = null;
+ }
+ }
+
+ public String deduceTargetFileName(File source) {
+ return finalName == null
+ ? FileUtils.basename( source.getAbsolutePath() ) + targetFileExtension
+ : finalName;
+ }
+ }
+}
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/TransformerFactory.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/TransformerFactory.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/TransformerFactory.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -29,7 +29,7 @@
import com.icl.saxon.Controller;
import org.apache.xml.resolver.tools.CatalogResolver;
-import org.jboss.maven.plugin.docbook.gen.render.Formatting;
+import org.jboss.maven.plugin.docbook.gen.util.Formatting;
import org.jboss.maven.plugin.docbook.gen.util.StandardDocBookFormatSpecification;
import org.jboss.maven.plugin.docbook.gen.util.NoOpWriter;
import org.jboss.maven.plugin.docbook.gen.util.ResourceHelper;
@@ -39,6 +39,7 @@
import org.jboss.maven.plugin.docbook.gen.xslt.resolve.RelativeJarUriResolver;
import org.jboss.maven.plugin.docbook.gen.xslt.resolve.ResolverChain;
import org.jboss.maven.plugin.docbook.gen.xslt.resolve.VersionResolver;
+import org.jboss.maven.plugin.docbook.gen.XSLTException;
/**
* A factory for {@link javax.xml.transform.Transformer} instances, configurable
Deleted: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/XSLTException.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/XSLTException.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/XSLTException.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -1,33 +0,0 @@
-/*
- * Copyright © 2007 Red Hat Middleware, LLC. All rights reserved.
- *
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, v. 2.1. This program is distributed in the
- * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
- * distribution; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Red Hat Author(s): Steve Ebersole
- */
-package org.jboss.maven.plugin.docbook.gen.xslt;
-
-/**
- * Indicates problems either building XSLT transformers or performing
- * transformations.
- *
- * @author Steve Ebersole
- */
-public class XSLTException extends Exception {
-
- public XSLTException(String message) {
- super( message );
- }
-
- public XSLTException(String message, Throwable cause) {
- super( message, cause );
- }
-}
Modified: trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/resolve/ExplicitUrnResolver.java
===================================================================
--- trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/resolve/ExplicitUrnResolver.java 2007-06-22 19:39:47 UTC (rev 11700)
+++ trunk/sandbox/maven-poc/plugins/maven-jboss-docbook-plugin/src/main/java/org/jboss/maven/plugin/docbook/gen/xslt/resolve/ExplicitUrnResolver.java 2007-06-22 20:55:40 UTC (rev 11701)
@@ -22,7 +22,7 @@
import org.jboss.maven.plugin.docbook.gen.util.StandardDocBookFormatSpecification;
import org.jboss.maven.plugin.docbook.gen.util.ResourceHelper;
-import org.jboss.maven.plugin.docbook.gen.xslt.XSLTException;
+import org.jboss.maven.plugin.docbook.gen.XSLTException;
/**
* Resolves an explicit <tt>urn:docbook:stylesheet</tt> URN against the standard
17 years, 5 months
Hibernate SVN: r11700 - in trunk/HibernateExt/search/src: test/org/hibernate/search/test/worker and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-06-22 15:39:47 -0400 (Fri, 22 Jun 2007)
New Revision: 11700
Added:
trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/ConcurrencyTest.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/Drink.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/Food.java
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java
Log:
HSEARCH-88 rework the hasCode algorithm to handle multiple entities per index
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java 2007-06-22 02:59:19 UTC (rev 11699)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneBackendQueueProcessor.java 2007-06-22 19:39:47 UTC (rev 11700)
@@ -10,6 +10,7 @@
import org.hibernate.search.backend.Workspace;
import org.hibernate.search.backend.OptimizeLuceneWork;
import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.store.DirectoryProvider;
/**
* Apply the operations to Lucene directories
@@ -32,7 +33,7 @@
workspace = new Workspace( searchFactoryImplementor );
worker = new LuceneWorker( workspace );
try {
- deadlockFreeQueue(queue, workspace);
+ deadlockFreeQueue(queue, workspace, searchFactoryImplementor);
for ( LuceneWork luceneWork : queue ) {
worker.performWork( luceneWork );
}
@@ -48,11 +49,11 @@
* dead lock between concurrent threads or processes
* To achieve that, the work will be done per directory provider
*/
- private void deadlockFreeQueue(List<LuceneWork> queue, final Workspace workspace) {
+ private void deadlockFreeQueue(List<LuceneWork> queue, final Workspace workspace, final SearchFactoryImplementor searchFactoryImplementor) {
Collections.sort( queue, new Comparator<LuceneWork>() {
public int compare(LuceneWork o1, LuceneWork o2) {
- long h1 = getWorkHashCode( o1, workspace );
- long h2 = getWorkHashCode( o2, workspace );
+ long h1 = getWorkHashCode( o1, searchFactoryImplementor );
+ long h2 = getWorkHashCode( o2, searchFactoryImplementor );
return h1 < h2 ?
-1 :
h1 == h2 ?
@@ -62,10 +63,14 @@
} );
}
- private long getWorkHashCode(LuceneWork luceneWork, Workspace workspace) {
- long h = workspace.getDocumentBuilder( luceneWork.getEntityClass() ).hashCode() * 2;
- if ( luceneWork instanceof AddLuceneWork ) h+=1; //addwork after deleteWork
- if ( luceneWork instanceof OptimizeLuceneWork ) h+=2; //optimize after everything
- return h;
+ private long getWorkHashCode(LuceneWork luceneWork, SearchFactoryImplementor searchFactoryImplementor) {
+ Class entity = luceneWork.getEntityClass();
+ DirectoryProvider provider = searchFactoryImplementor.getDirectoryProvider( entity );
+ int h = provider.getClass().hashCode();
+ h = 31 * h + provider.hashCode();
+ long extendedHash = h; //to be sure extendedHash + 1 < extendedHash + 2 is always true
+ if ( luceneWork instanceof AddLuceneWork ) extendedHash+=1; //addwork after deleteWork
+ if ( luceneWork instanceof OptimizeLuceneWork ) extendedHash+=2; //optimize after everything
+ return extendedHash;
}
}
Added: trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/ConcurrencyTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/ConcurrencyTest.java (rev 0)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/ConcurrencyTest.java 2007-06-22 19:39:47 UTC (rev 11700)
@@ -0,0 +1,56 @@
+//$Id$
+package org.hibernate.search.test.worker;
+
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.Session;
+import org.hibernate.annotations.common.AssertionFailure;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class ConcurrencyTest extends SearchTestCase {
+
+ public void testMultipleEntitiesInSameIndex() throws Exception {
+ Session s = openSession( );
+ s.getTransaction().begin();
+ Drink d = new Drink();
+ d.setName( "Water" );
+ Food f = new Food();
+ f.setName( "Bread" );
+ s.persist( d );
+ s.persist( f );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession( );
+ s.getTransaction().begin();
+ d = (Drink) s.get( Drink.class, d.getId() );
+ d.setName( "Coke" );
+ f = (Food) s.get( Food.class, f.getId() );
+ f.setName( "Cake" );
+ try {
+ s.getTransaction().commit();
+ }
+ catch (Exception e) {
+ //Check for error logs from JDBCTransaction
+ }
+ s.close();
+
+ s = openSession( );
+ s.getTransaction().begin();
+ d = (Drink) s.get( Drink.class, d.getId() );
+ s.delete( d );
+ f = (Food) s.get( Food.class, f.getId() );
+ s.delete( f );
+ s.getTransaction().commit();
+ s.close();
+
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Drink.class,
+ Food.class
+ };
+ }
+}
Added: trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/Drink.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/Drink.java (rev 0)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/Drink.java 2007-06-22 19:39:47 UTC (rev 11700)
@@ -0,0 +1,43 @@
+//$Id$
+package org.hibernate.search.test.worker;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index = "consumable")
+public class Drink {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private Integer id;
+
+ @Field(index = Index.TOKENIZED )
+ private String name;
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Added: trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/Food.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/Food.java (rev 0)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/worker/Food.java 2007-06-22 19:39:47 UTC (rev 11700)
@@ -0,0 +1,43 @@
+//$Id$
+package org.hibernate.search.test.worker;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed(index = "consumable")
+public class Food {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private Integer id;
+
+ @Field(index = Index.TOKENIZED )
+ private String name;
+
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
17 years, 5 months
Hibernate SVN: r11699 - trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-06-21 22:59:19 -0400 (Thu, 21 Jun 2007)
New Revision: 11699
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/OptimizerStrategy.java
Log:
style
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/OptimizerStrategy.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/OptimizerStrategy.java 2007-06-20 14:55:23 UTC (rev 11698)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/OptimizerStrategy.java 2007-06-22 02:59:19 UTC (rev 11699)
@@ -3,8 +3,8 @@
import java.util.Properties;
+import org.hibernate.search.backend.Workspace;
import org.hibernate.search.engine.SearchFactoryImplementor;
-import org.hibernate.search.backend.Workspace;
import org.hibernate.search.store.DirectoryProvider;
/**
17 years, 5 months
Hibernate SVN: r11697 - trunk/HibernateExt/search/lib.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-06-19 18:09:52 -0400 (Tue, 19 Jun 2007)
New Revision: 11697
Added:
trunk/HibernateExt/search/lib/lucene-core-2.2.0.jar
Removed:
trunk/HibernateExt/search/lib/lucene-core-2.1.0.jar
Log:
HSEARCH-84 lucene 2.2 migration
Deleted: trunk/HibernateExt/search/lib/lucene-core-2.1.0.jar
===================================================================
(Binary files differ)
Added: trunk/HibernateExt/search/lib/lucene-core-2.2.0.jar
===================================================================
(Binary files differ)
Property changes on: trunk/HibernateExt/search/lib/lucene-core-2.2.0.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
17 years, 5 months
Hibernate SVN: r11696 - trunk/HibernateExt/search/src/java/org/hibernate/search/store.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-06-19 18:08:29 -0400 (Tue, 19 Jun 2007)
New Revision: 11696
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/store/FSDirectoryProvider.java
Log:
Get rid of deprecated Lucene API use
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/store/FSDirectoryProvider.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/FSDirectoryProvider.java 2007-06-19 22:07:51 UTC (rev 11695)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/FSDirectoryProvider.java 2007-06-19 22:08:29 UTC (rev 11696)
@@ -32,7 +32,7 @@
try {
boolean create = !indexDir.exists();
indexName = indexDir.getCanonicalPath();
- directory = FSDirectory.getDirectory( indexName, create );
+ directory = FSDirectory.getDirectory( indexName );
if ( create ) {
IndexWriter iw = new IndexWriter( directory, new StandardAnalyzer(), create );
iw.close();
17 years, 5 months
Hibernate SVN: r11695 - in trunk/HibernateExt/search/src: java/org/hibernate/search/backend and 8 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-06-19 18:07:51 -0400 (Tue, 19 Jun 2007)
New Revision: 11695
Added:
trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/
trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/IncrementalOptimizerStrategy.java
trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/NoOpOptimizerStrategy.java
trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/OptimizerStrategy.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/
trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/Construction.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/Worker.java
Modified:
trunk/HibernateExt/search/src/java/org/hibernate/search/Version.java
trunk/HibernateExt/search/src/java/org/hibernate/search/backend/Workspace.java
trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneWorker.java
trunk/HibernateExt/search/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java
trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
trunk/HibernateExt/search/src/test/log4j.properties
Log:
HSEARCH-73 HSEARCH-83 OptimizerStrategy and incremental optimizer implementation
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/Version.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/Version.java 2007-06-19 05:44:02 UTC (rev 11694)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/Version.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -10,7 +10,7 @@
* @author Emmanuel Bernard
*/
public class Version {
- public static final String VERSION = "3.0.0.Beta3"; //SNAPSHOT" + new Date();
+ public static final String VERSION = "3.0.0.Beta4SNAPSHOT" + new Date();
private static Log log = LogFactory.getLog( Version.class );
static {
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/backend/Workspace.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/backend/Workspace.java 2007-06-19 05:44:02 UTC (rev 11694)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/backend/Workspace.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -2,20 +2,23 @@
package org.hibernate.search.backend;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.SimpleAnalyzer;
import org.hibernate.search.engine.DocumentBuilder;
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.hibernate.search.SearchException;
import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.optimization.OptimizerStrategy;
import org.hibernate.annotations.common.AssertionFailure;
/**
@@ -35,7 +38,9 @@
private Map<DirectoryProvider, IndexReader> readers = new HashMap<DirectoryProvider, IndexReader>();
private Map<DirectoryProvider, IndexWriter> writers = new HashMap<DirectoryProvider, IndexWriter>();
private List<DirectoryProvider> lockedProviders = new ArrayList<DirectoryProvider>();
+ private Map<DirectoryProvider, DPStatistics> dpStatistics = new HashMap<DirectoryProvider, DPStatistics>();
private SearchFactoryImplementor searchFactoryImplementor;
+
public Workspace(SearchFactoryImplementor searchFactoryImplementor) {
this.searchFactoryImplementor = searchFactoryImplementor;
@@ -46,7 +51,14 @@
return searchFactoryImplementor.getDocumentBuilders().get( entity );
}
- public IndexReader getIndexReader(Class entity) {
+ /**
+ * Retrieve an IndexWriter for a given entity
+ *
+ * @param entity entity processed
+ * @param modificationOperation true if the modification is expected to be an idnex state change
+ * @return appropriate indexWriter
+ */
+ public IndexReader getIndexReader(Class entity, boolean modificationOperation) {
//TODO NPEs
DirectoryProvider provider = searchFactoryImplementor.getDirectoryProvider( entity );
//one cannot access a reader for update after a writer has been accessed
@@ -55,6 +67,7 @@
IndexReader reader = readers.get( provider );
if ( reader != null ) return reader;
lockProvider( provider );
+ dpStatistics.get(provider).operations++;
try {
reader = IndexReader.open( provider.getDirectory() );
readers.put( provider, reader );
@@ -65,8 +78,24 @@
return reader;
}
- public IndexWriter getIndexWriter(Class entity) {
+ /**
+ * Retrieve an IndexWriter for a given entity
+ *
+ * @param entity entity processed
+ * @param modificationOperation true if the modification is expected to be an idnex state change
+ * @return appropriate indexWriter
+ */
+ public IndexWriter getIndexWriter(Class entity, boolean modificationOperation) {
DirectoryProvider provider = searchFactoryImplementor.getDirectoryProvider( entity );
+ return getIndexWriter( provider, entity, modificationOperation );
+ }
+
+ //for optimization
+ public IndexWriter getIndexWriter(DirectoryProvider provider) {
+ return getIndexWriter( provider, null, false );
+ }
+
+ private IndexWriter getIndexWriter(DirectoryProvider provider, Class entity, boolean modificationOperation) {
//one has to close a reader for update before a writer is accessed
IndexReader reader = readers.get( provider );
if ( reader != null ) {
@@ -81,14 +110,18 @@
IndexWriter writer = writers.get( provider );
if ( writer != null ) return writer;
lockProvider( provider );
+ dpStatistics.get(provider).operations++;
try {
- writer = new IndexWriter(
- provider.getDirectory(), searchFactoryImplementor.getDocumentBuilders().get( entity ).getAnalyzer(), false
- ); //have been created at init time
+ Analyzer analyzer = entity != null ?
+ searchFactoryImplementor.getDocumentBuilders().get( entity ).getAnalyzer() :
+ new SimpleAnalyzer(); //never used
+ writer = new IndexWriter( provider.getDirectory(), analyzer, false ); //have been created at init time
writers.put( provider, writer );
}
catch (IOException e) {
- cleanUp( new SearchException( "Unable to open IndexWriter for " + entity, e ) );
+ cleanUp(
+ new SearchException( "Unable to open IndexWriter" + ( entity != null ? " for " + entity : "" ), e )
+ );
}
return writer;
}
@@ -100,6 +133,7 @@
if ( !lock.isHeldByCurrentThread() ) {
lock.lock();
lockedProviders.add( provider );
+ dpStatistics.put( provider, new DPStatistics() );
}
}
@@ -119,6 +153,26 @@
}
}
}
+ readers.clear();
+ //TODO release lock of all indexes that do not need optimization early
+ //don't optimze if there is a failure
+ if (raisedException == null) {
+ for ( DirectoryProvider provider : lockedProviders ) {
+ Workspace.DPStatistics stats = dpStatistics.get(provider);
+ if (!stats.optimizationForced) {
+ OptimizerStrategy optimizerStrategy = searchFactoryImplementor.getOptimizerStrategy( provider );
+ optimizerStrategy.addTransaction( stats.operations );
+ try {
+ optimizerStrategy.optimize( this );
+ }
+ catch( SearchException e ) {
+ raisedException = new SearchException( "Exception while optimizing directoryProvider: "
+ + provider.getDirectory().toString(), e );
+ break; //no point in continuing
+ }
+ }
+ }
+ }
for ( IndexWriter writer : writers.values() ) {
try {
writer.close();
@@ -135,9 +189,9 @@
for ( DirectoryProvider provider : lockedProviders ) {
searchFactoryImplementor.getLockableDirectoryProviders().get( provider ).unlock();
}
- readers.clear();
writers.clear();
lockedProviders.clear();
+ dpStatistics.clear();
if ( raisedException != null ) throw raisedException;
}
@@ -147,4 +201,17 @@
public void clean() {
cleanUp( null );
}
+
+ public void optimize(Class entity) {
+ DirectoryProvider provider = searchFactoryImplementor.getDirectoryProvider( entity );
+ OptimizerStrategy optimizerStrategy = searchFactoryImplementor.getOptimizerStrategy( provider );
+ dpStatistics.get(provider).optimizationForced = true;
+ optimizerStrategy.optimizationForced();
+ }
+
+ private class DPStatistics {
+ boolean optimizationForced = false;
+ public long operations;
+ }
+
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneWorker.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneWorker.java 2007-06-19 05:44:02 UTC (rev 11694)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/backend/impl/lucene/LuceneWorker.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -58,7 +58,7 @@
private void add(Class entity, Serializable id, Document document) {
if ( log.isTraceEnabled() )
log.trace( "add to Lucene index: " + entity + "#" + id + ": " + document );
- IndexWriter writer = workspace.getIndexWriter( entity );
+ IndexWriter writer = workspace.getIndexWriter( entity, true );
try {
writer.addDocument( document );
}
@@ -82,7 +82,7 @@
log.trace( "remove from Lucene index: " + entity + "#" + id );
DocumentBuilder builder = workspace.getDocumentBuilder( entity );
Term term = builder.getTerm( id );
- IndexReader reader = workspace.getIndexReader( entity );
+ IndexReader reader = workspace.getIndexReader( entity, true );
TermDocs termDocs = null;
try {
//TODO is there a faster way?
@@ -117,9 +117,10 @@
log.trace( "optimize Lucene index: " + entity );
//TODO get a batchIndexWriter of some kind that deals with different merge factors and all
//TODO this one should not compete with a regular IndexWriter (ie exception from the workspace)
- IndexWriter writer = workspace.getIndexWriter( entity );
+ IndexWriter writer = workspace.getIndexWriter( entity, false );
try {
writer.optimize();
+ workspace.optimize(entity);
}
catch (IOException e) {
throw new SearchException( "Unable to optimize Lucene index: " + entity, e );
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2007-06-19 05:44:02 UTC (rev 11694)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/engine/SearchFactoryImplementor.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -6,6 +6,7 @@
import org.hibernate.search.SearchFactory;
import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.store.optimization.OptimizerStrategy;
import org.hibernate.search.backend.BackendQueueProcessorFactory;
import org.hibernate.search.backend.Worker;
@@ -22,4 +23,8 @@
Map<DirectoryProvider, ReentrantLock> getLockableDirectoryProviders();
Worker getWorker();
+
+ void addOptimizerStrategy(DirectoryProvider<?> provider, OptimizerStrategy optimizerStrategy);
+
+ public OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider);
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2007-06-19 05:44:02 UTC (rev 11694)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/impl/SearchFactoryImpl.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -32,6 +32,7 @@
import org.hibernate.search.reader.ReaderProviderFactory;
import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.search.store.DirectoryProviderFactory;
+import org.hibernate.search.store.optimization.OptimizerStrategy;
import org.hibernate.util.ReflectHelper;
/**
@@ -49,6 +50,8 @@
//keep track of the index modifiers per DirectoryProvider since multiple entity can use the same directory provider
private Map<DirectoryProvider, ReentrantLock> lockableDirectoryProviders =
new HashMap<DirectoryProvider, ReentrantLock>();
+ private Map<DirectoryProvider, OptimizerStrategy> dirProviderOptimizerStrategies =
+ new HashMap<DirectoryProvider, OptimizerStrategy>();
private Worker worker;
private ReaderProvider readerProvider;
private BackendQueueProcessorFactory backendQueueProcessorFactory;
@@ -104,6 +107,7 @@
XClass mappedXClass = reflectionManager.toXClass( mappedClass );
if ( mappedXClass != null && mappedXClass.isAnnotationPresent( Indexed.class ) ) {
DirectoryProvider provider = factory.createDirectoryProvider( mappedXClass, cfg, this );
+ //TODO move that into DirectoryProviderFactory
if ( !lockableDirectoryProviders.containsKey( provider ) ) {
lockableDirectoryProviders.put( provider, new ReentrantLock() );
}
@@ -154,6 +158,14 @@
return worker;
}
+ public void addOptimizerStrategy(DirectoryProvider<?> provider, OptimizerStrategy optimizerStrategy) {
+ dirProviderOptimizerStrategies.put( provider, optimizerStrategy );
+ }
+
+ public OptimizerStrategy getOptimizerStrategy(DirectoryProvider<?> provider) {
+ return dirProviderOptimizerStrategies.get( provider );
+ }
+
public ReaderProvider getReaderProvider() {
return readerProvider;
}
Modified: trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2007-06-19 05:44:02 UTC (rev 11694)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -11,6 +11,9 @@
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.impl.SearchFactoryImpl;
import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.store.optimization.OptimizerStrategy;
+import org.hibernate.search.store.optimization.IncrementalOptimizerStrategy;
+import org.hibernate.search.store.optimization.NoOpOptimizerStrategy;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
@@ -74,6 +77,17 @@
return providers.get( index );
}
else {
+ boolean incremental = indexProps.containsKey( "optimizer.operation_limit.max" )
+ || indexProps.containsKey( "optimizer.transaction_limit.max" );
+ OptimizerStrategy optimizerStrategy;
+ if (incremental) {
+ optimizerStrategy = new IncrementalOptimizerStrategy();
+ optimizerStrategy.initialize( provider, indexProps, searchFactoryImplementor);
+ }
+ else {
+ optimizerStrategy = new NoOpOptimizerStrategy();
+ }
+ searchFactoryImplementor.addOptimizerStrategy(provider, optimizerStrategy);
providers.add( provider );
return provider;
}
Added: trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/IncrementalOptimizerStrategy.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/IncrementalOptimizerStrategy.java (rev 0)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/IncrementalOptimizerStrategy.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -0,0 +1,75 @@
+//$Id$
+package org.hibernate.search.store.optimization;
+
+import java.util.Properties;
+import java.io.IOException;
+
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.backend.Workspace;
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.SearchException;
+import org.hibernate.annotations.common.util.StringHelper;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Optimization strategy triggered after a certain amount of operations
+ *
+ * @author Emmanuel Bernard
+ */
+public class IncrementalOptimizerStrategy implements OptimizerStrategy {
+ private int operationMax = -1;
+ private int transactionMax = -1;
+ private long operations = 0;
+ private long transactions = 0;
+ private DirectoryProvider directoryProvider;
+ private Log log = LogFactory.getLog( IncrementalOptimizerStrategy.class );
+
+ public void initialize(DirectoryProvider directoryProvider, Properties indexProperties, SearchFactoryImplementor searchFactoryImplementor) {
+ this.directoryProvider = directoryProvider;
+ String maxString = indexProperties.getProperty( "optimizer.operation_limit.max" );
+ if ( StringHelper.isNotEmpty( maxString ) ) {
+ operationMax = Integer.parseInt( maxString );
+ }
+
+ maxString = indexProperties.getProperty( "optimizer.transaction_limit.max" );
+ if ( StringHelper.isNotEmpty( maxString ) ) {
+ transactionMax = Integer.parseInt( maxString );
+ }
+ }
+
+ public void optimizationForced() {
+ operations = 0;
+ transactions = 0;
+ }
+
+ public boolean needOptimization() {
+ return (operationMax != -1 && operations >= operationMax)
+ || (transactionMax != -1 && transactions >= transactionMax);
+ }
+
+ public void addTransaction(long operations) {
+ this.operations += operations;
+ this.transactions++;
+ }
+
+ public void optimize(Workspace workspace) {
+ if ( needOptimization() ) {
+ if ( log.isDebugEnabled() ) {
+ log.debug( "Optimize "
+ + directoryProvider.getDirectory().toString()
+ +" after " + operations + " operations and " + transactions + " transactions");
+ }
+ IndexWriter writer = workspace.getIndexWriter( directoryProvider );
+ try {
+ writer.optimize();
+ }
+ catch (IOException e) {
+ throw new SearchException( "Unable to optimize directoryProvider: "
+ + directoryProvider.getDirectory().toString(), e );
+ }
+ optimizationForced();
+ }
+ }
+}
Added: trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/NoOpOptimizerStrategy.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/NoOpOptimizerStrategy.java (rev 0)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/NoOpOptimizerStrategy.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -0,0 +1,29 @@
+//$Id$
+package org.hibernate.search.store.optimization;
+
+import java.util.Properties;
+
+import org.hibernate.search.store.DirectoryProvider;
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.backend.Workspace;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class NoOpOptimizerStrategy implements OptimizerStrategy {
+ public void initialize(DirectoryProvider directoryProvider, Properties indexProperties, SearchFactoryImplementor searchFactoryImplementor) {
+ }
+
+ public void optimizationForced() {
+ }
+
+ public boolean needOptimization() {
+ return false;
+ }
+
+ public void addTransaction(long operations) {
+ }
+
+ public void optimize(Workspace workspace) {
+ }
+}
Added: trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/OptimizerStrategy.java
===================================================================
--- trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/OptimizerStrategy.java (rev 0)
+++ trunk/HibernateExt/search/src/java/org/hibernate/search/store/optimization/OptimizerStrategy.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -0,0 +1,36 @@
+//$Id$
+package org.hibernate.search.store.optimization;
+
+import java.util.Properties;
+
+import org.hibernate.search.engine.SearchFactoryImplementor;
+import org.hibernate.search.backend.Workspace;
+import org.hibernate.search.store.DirectoryProvider;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public interface OptimizerStrategy {
+ public void initialize(DirectoryProvider directoryProvider, Properties indexProperties, SearchFactoryImplementor searchFactoryImplementor);
+
+ /**
+ * has to be called in a thread safe way
+ */
+ void optimizationForced();
+
+ /**
+ * has to be called in a thread safe way
+ */
+ boolean needOptimization();
+
+ /**
+ * has to be called in a thread safe way
+ */
+ public void addTransaction(long operations);
+
+ /**
+ * has to be called in a thread safe way
+ */
+ void optimize(Workspace workspace);
+
+}
Modified: trunk/HibernateExt/search/src/test/log4j.properties
===================================================================
--- trunk/HibernateExt/search/src/test/log4j.properties 2007-06-19 05:44:02 UTC (rev 11694)
+++ trunk/HibernateExt/search/src/test/log4j.properties 2007-06-19 22:07:51 UTC (rev 11695)
@@ -18,11 +18,11 @@
log4j.logger.org.hibernate=info
-log4j.logger.org.hibernate.search=debug
+#log4j.logger.org.hibernate.search=debug
### log just the SQL
-log4j.logger.org.hibernate.SQL=debug
+#log4j.logger.org.hibernate.SQL=debug
#log4j.logger.org.hibernate.engine.CascadingAction=debug
Added: trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/Construction.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/Construction.java (rev 0)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/Construction.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -0,0 +1,60 @@
+//$Id$
+package org.hibernate.search.test.optimizer;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Construction {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private Integer id;
+ @Field(index = Index.TOKENIZED)
+ private String name;
+ @Field(index = Index.TOKENIZED)
+ private String address;
+
+
+ public Construction() {
+ }
+
+ public Construction(String name, String address) {
+ this.name = name;
+ this.address = address;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+}
Added: trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java (rev 0)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/IncrementalOptimizerStrategyTest.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -0,0 +1,18 @@
+//$Id$
+package org.hibernate.search.test.optimizer;
+
+import java.io.File;
+
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.Environment;
+import org.apache.lucene.analysis.StopAnalyzer;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class IncrementalOptimizerStrategyTest extends OptimizerTestCase {
+ protected void configure(org.hibernate.cfg.Configuration cfg) {
+ super.configure( cfg );
+ cfg.setProperty( "hibernate.search.default.optimizer.transaction_limit.max", "10" );
+ }
+}
Added: trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java (rev 0)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -0,0 +1,204 @@
+//$Id$
+package org.hibernate.search.test.optimizer;
+
+import java.io.File;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.Date;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.impl.FullTextSessionImpl;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class OptimizerTestCase extends SearchTestCase {
+ protected void setUp() throws Exception {
+ File sub = getBaseIndexDir();
+ delete( sub );
+ sub.mkdir();
+ File[] files = sub.listFiles();
+ for (File file : files) {
+ if ( file.isDirectory() ) {
+ delete( file );
+ }
+ }
+ //super.setUp(); //we need a fresh session factory each time for index set up
+ buildSessionFactory( getMappings(), getAnnotatedPackages(), getXmlFiles() );
+ }
+
+ private File getBaseIndexDir() {
+ File current = new File( "." );
+ File sub = new File( current, "indextemp" );
+ return sub;
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ File sub = getBaseIndexDir();
+ delete( sub );
+ }
+
+ private void delete(File sub) {
+ if ( sub.isDirectory() ) {
+ for (File file : sub.listFiles()) {
+ delete( file );
+ }
+ sub.delete();
+ }
+ else {
+ sub.delete();
+ }
+ }
+
+ public void testConcurrency() throws Exception {
+ int nThreads = 15;
+ ExecutorService es = Executors.newFixedThreadPool( nThreads );
+ Work work = new Work( getSessions() );
+ ReverseWork reverseWork = new ReverseWork( getSessions() );
+ long start = System.currentTimeMillis();
+ int iteration = 100;
+ for (int i = 0; i < iteration; i++) {
+ es.execute( work );
+ es.execute( reverseWork );
+ }
+ while ( work.count < iteration - 1 ) {
+ Thread.sleep( 20 );
+ }
+ System.out.println( iteration + " iterations (8 tx per iteration) in " + nThreads + " threads: " + ( System
+ .currentTimeMillis() - start ) );
+ }
+
+ protected class Work implements Runnable {
+ private SessionFactory sf;
+ public volatile int count = 0;
+
+ public Work(SessionFactory sf) {
+ this.sf = sf;
+ }
+
+ public void run() {
+ try {
+ Session s = sf.openSession();
+ Transaction tx = s.beginTransaction();
+ Worker w = new Worker( "Emmanuel", 65 );
+ s.persist( w );
+ Construction c = new Construction( "Bellagio", "Las Vagas Nevada" );
+ s.persist( c );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ w = (Worker) s.get( Worker.class, w.getId() );
+ w.setName( "Gavin" );
+ c = (Construction) s.get( Construction.class, c.getId() );
+ c.setName( "W Hotel" );
+ tx.commit();
+ s.close();
+
+ try {
+ Thread.sleep( 50 );
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ FullTextSession fts = new FullTextSessionImpl( s );
+ QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
+ Query query;
+ try {
+ query = parser.parse( "name:Gavin" );
+ }
+ catch (ParseException e) {
+ throw new RuntimeException( e );
+ }
+ boolean results = fts.createFullTextQuery( query ).list().size() > 0;
+ //don't test because in case of async, it query happens before actual saving
+ //if ( !results ) throw new RuntimeException( "No results!" );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ w = (Worker) s.get( Worker.class, w.getId() );
+ s.delete( w );
+ c = (Construction) s.get( Construction.class, c.getId() );
+ s.delete( c );
+ tx.commit();
+ s.close();
+ count++;
+ } catch (Throwable t) {
+ t.printStackTrace( );
+ }
+ }
+ }
+
+ protected class ReverseWork implements Runnable {
+ private SessionFactory sf;
+
+ public ReverseWork(SessionFactory sf) {
+ this.sf = sf;
+ }
+
+ public void run() {
+ try {
+ Session s = sf.openSession();
+ Transaction tx = s.beginTransaction();
+ Worker w = new Worker( "Mladen", 70 );
+ s.persist( w );
+ Construction c = new Construction( "Hover Dam", "Croatia" );
+ s.persist( c );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ w = (Worker) s.get( Worker.class, w.getId() );
+ w.setName( "Remi" );
+ c = (Construction) s.get( Construction.class, c.getId() );
+ c.setName( "Palais des festivals" );
+ tx.commit();
+ s.close();
+
+ s = sf.openSession();
+ tx = s.beginTransaction();
+ w = (Worker) s.get( Worker.class, w.getId() );
+ s.delete( w );
+ c = (Construction) s.get( Construction.class, c.getId() );
+ s.delete( c );
+ tx.commit();
+ s.close();
+ } catch (Throwable t) {
+ t.printStackTrace( );
+ }
+ }
+ }
+
+ protected void configure(org.hibernate.cfg.Configuration cfg) {
+ super.configure( cfg );
+ File sub = getBaseIndexDir();
+ cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath() );
+ cfg.setProperty( "hibernate.search.default.directory_provider", FSDirectoryProvider.class.getName() );
+ cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+ }
+
+ protected Class[] getMappings() {
+ return new Class[] {
+ Worker.class,
+ Construction.class
+ };
+ }
+}
Added: trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/Worker.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/Worker.java (rev 0)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/optimizer/Worker.java 2007-06-19 22:07:51 UTC (rev 11695)
@@ -0,0 +1,60 @@
+//$Id$
+package org.hibernate.search.test.optimizer;
+
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Entity;
+
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity
+@Indexed
+public class Worker {
+ @Id
+ @GeneratedValue
+ @DocumentId
+ private Integer id;
+ @Field(index = Index.TOKENIZED)
+ private String name;
+ @Field(index = Index.UN_TOKENIZED)
+ private int workhours;
+
+
+ public Worker() {
+ }
+
+ public Worker(String name, int workhours) {
+ this.name = name;
+ this.workhours = workhours;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getWorkhours() {
+ return workhours;
+ }
+
+ public void setWorkhours(int workhours) {
+ this.workhours = workhours;
+ }
+}
17 years, 5 months
Hibernate SVN: r11748 - core/branches/Branch_3_2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-19 13:00:29 -0400 (Tue, 19 Jun 2007)
New Revision: 11748
Added:
core/branches/Branch_3_2/readme.txt
Removed:
branches/Branch_3_2/Hibernate3/readme.txt
Log:
starting svn layout migration testing
Deleted: branches/Branch_3_2/Hibernate3/readme.txt
===================================================================
--- branches/Branch_3_2/Hibernate3/readme.txt 2007-06-19 17:00:22 UTC (rev 11747)
+++ branches/Branch_3_2/Hibernate3/readme.txt 2007-06-19 17:00:29 UTC (rev 11748)
@@ -1,54 +0,0 @@
-Hibernate - Relational Persistence for Idiomatic Java
-=====================================================
-version 3.2.4.sp1, May 18, 2007
-
-Instructions
-------------
-Unzip to installation directory.
-
-See index.html in the doc/reference directory.
-
-Required jars are distributed in the lib subdirectory.
-
-Latest Documentation:
-
- http://hibernate.org
-
-Bug Reports:
-
- Hibernate JIRA (preferred)
- hibernate-devel(a)lists.sourceforge.net
-
-Free Technical Support:
-
- http://forum.hibernate.org
-
-Commercial Support and Training:
-
- http://hibernate.org/SupportTraining
-
-
-Get Up And Running Quick
-------------------------
-Demo:
-
- (1) copy your JDBC driver to the lib directory
- (2) edit etc/hibernate.properties
- (3) run "ant eg" or "build eg"
- (4) browse the sourcecode in eg/org/hibernate/auction
-
-Tests:
-
- (1) copy your JDBC driver to the lib directory
- (2) edit etc/hibernate.properties
- (3) run "ant junitreport" or "build junitreport"
- (4) see build/test-reports/index.html
-
-
-Other Stuff
------------
-This software is distributed under the terms of the FSF Lesser Gnu
-Public License (see lgpl.txt).
-
-This product includes software developed by the Apache Software
-Foundation (http://www.apache.org/).
Copied: core/branches/Branch_3_2/readme.txt (from rev 11747, branches/Branch_3_2/Hibernate3/readme.txt)
===================================================================
--- core/branches/Branch_3_2/readme.txt (rev 0)
+++ core/branches/Branch_3_2/readme.txt 2007-06-19 17:00:29 UTC (rev 11748)
@@ -0,0 +1,54 @@
+Hibernate - Relational Persistence for Idiomatic Java
+=====================================================
+version 3.2.4.sp1, May 18, 2007
+
+Instructions
+------------
+Unzip to installation directory.
+
+See index.html in the doc/reference directory.
+
+Required jars are distributed in the lib subdirectory.
+
+Latest Documentation:
+
+ http://hibernate.org
+
+Bug Reports:
+
+ Hibernate JIRA (preferred)
+ hibernate-devel(a)lists.sourceforge.net
+
+Free Technical Support:
+
+ http://forum.hibernate.org
+
+Commercial Support and Training:
+
+ http://hibernate.org/SupportTraining
+
+
+Get Up And Running Quick
+------------------------
+Demo:
+
+ (1) copy your JDBC driver to the lib directory
+ (2) edit etc/hibernate.properties
+ (3) run "ant eg" or "build eg"
+ (4) browse the sourcecode in eg/org/hibernate/auction
+
+Tests:
+
+ (1) copy your JDBC driver to the lib directory
+ (2) edit etc/hibernate.properties
+ (3) run "ant junitreport" or "build junitreport"
+ (4) see build/test-reports/index.html
+
+
+Other Stuff
+-----------
+This software is distributed under the terms of the FSF Lesser Gnu
+Public License (see lgpl.txt).
+
+This product includes software developed by the Apache Software
+Foundation (http://www.apache.org/).
17 years, 5 months
Hibernate SVN: r11747 - core/branches/Branch_3_2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-19 13:00:22 -0400 (Tue, 19 Jun 2007)
New Revision: 11747
Added:
core/branches/Branch_3_2/lgpl.txt
Removed:
branches/Branch_3_2/Hibernate3/lgpl.txt
Log:
starting svn layout migration testing
Deleted: branches/Branch_3_2/Hibernate3/lgpl.txt
===================================================================
--- branches/Branch_3_2/Hibernate3/lgpl.txt 2007-06-19 17:00:15 UTC (rev 11746)
+++ branches/Branch_3_2/Hibernate3/lgpl.txt 2007-06-19 17:00:22 UTC (rev 11747)
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it 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.
-
- This library 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 library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
Copied: core/branches/Branch_3_2/lgpl.txt (from rev 11746, branches/Branch_3_2/Hibernate3/lgpl.txt)
===================================================================
--- core/branches/Branch_3_2/lgpl.txt (rev 0)
+++ core/branches/Branch_3_2/lgpl.txt 2007-06-19 17:00:22 UTC (rev 11747)
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it 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.
+
+ This library 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 library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
17 years, 5 months
Hibernate SVN: r11746 - core/branches/Branch_3_2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-19 13:00:15 -0400 (Tue, 19 Jun 2007)
New Revision: 11746
Added:
core/branches/Branch_3_2/indent.py
Removed:
branches/Branch_3_2/Hibernate3/indent.py
Log:
starting svn layout migration testing
Deleted: branches/Branch_3_2/Hibernate3/indent.py
===================================================================
--- branches/Branch_3_2/Hibernate3/indent.py 2007-06-19 17:00:08 UTC (rev 11745)
+++ branches/Branch_3_2/Hibernate3/indent.py 2007-06-19 17:00:15 UTC (rev 11746)
@@ -1,45 +0,0 @@
-import re
-import sys
-sys.argv.pop(0)
-for fname in sys.argv:
- file = open(fname)
- inlines = file.read().split('\n')
- file.close()
- out= []
- tabcount = 0
- extratab=0
- for ln in inlines:
- code = ln.lstrip('\t ').rstrip('\t ')
- clen = len(code)
- javadoc = clen > 0 and code[0]=='*'
- if javadoc:
- code = ' ' + code
- else:
- begincb = clen > 0 and ( code[0]=='}' or code[0]==')' )
- tabcount -= begincb
-
- extratab = extratab or ( len(code)>0 and code[0]=='.' )
-
- tabs = '\t' * (tabcount + extratab)
-
- extratab = clen>0 and ( code[clen-1]==':' or code[clen-1]=='?' )
-
- if clen>5 and code[0:6] == '} else':
- code = '}\n' + tabs + 'else' + code[6:]
- if clen>6 and code[0:7] == '} catch':
- code = '}\n' + tabs + 'catch' + code[7:]
-
- out.append( tabs + code + '\n' )
-
- if not javadoc:
- uncommented = code.split('//')[0].rstrip()
- clen = len(uncommented)
- endob = clen > 0 and ( code[clen-1]=='{' or code[clen-1]=='(' )
- tabcount += endob
-
- file = open( fname, 'w' )
- for ln in out:
- file.write(ln)
- file.close()
-
-
Copied: core/branches/Branch_3_2/indent.py (from rev 11745, branches/Branch_3_2/Hibernate3/indent.py)
===================================================================
--- core/branches/Branch_3_2/indent.py (rev 0)
+++ core/branches/Branch_3_2/indent.py 2007-06-19 17:00:15 UTC (rev 11746)
@@ -0,0 +1,45 @@
+import re
+import sys
+sys.argv.pop(0)
+for fname in sys.argv:
+ file = open(fname)
+ inlines = file.read().split('\n')
+ file.close()
+ out= []
+ tabcount = 0
+ extratab=0
+ for ln in inlines:
+ code = ln.lstrip('\t ').rstrip('\t ')
+ clen = len(code)
+ javadoc = clen > 0 and code[0]=='*'
+ if javadoc:
+ code = ' ' + code
+ else:
+ begincb = clen > 0 and ( code[0]=='}' or code[0]==')' )
+ tabcount -= begincb
+
+ extratab = extratab or ( len(code)>0 and code[0]=='.' )
+
+ tabs = '\t' * (tabcount + extratab)
+
+ extratab = clen>0 and ( code[clen-1]==':' or code[clen-1]=='?' )
+
+ if clen>5 and code[0:6] == '} else':
+ code = '}\n' + tabs + 'else' + code[6:]
+ if clen>6 and code[0:7] == '} catch':
+ code = '}\n' + tabs + 'catch' + code[7:]
+
+ out.append( tabs + code + '\n' )
+
+ if not javadoc:
+ uncommented = code.split('//')[0].rstrip()
+ clen = len(uncommented)
+ endob = clen > 0 and ( code[clen-1]=='{' or code[clen-1]=='(' )
+ tabcount += endob
+
+ file = open( fname, 'w' )
+ for ln in out:
+ file.write(ln)
+ file.close()
+
+
17 years, 5 months
Hibernate SVN: r11745 - core/branches/Branch_3_2 and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-06-19 13:00:08 -0400 (Tue, 19 Jun 2007)
New Revision: 11745
Added:
core/branches/Branch_3_2/hibernate_logo.gif
Removed:
branches/Branch_3_2/Hibernate3/hibernate_logo.gif
Log:
starting svn layout migration testing
Deleted: branches/Branch_3_2/Hibernate3/hibernate_logo.gif
===================================================================
(Binary files differ)
Copied: core/branches/Branch_3_2/hibernate_logo.gif (from rev 11744, branches/Branch_3_2/Hibernate3/hibernate_logo.gif)
===================================================================
(Binary files differ)
17 years, 5 months