Skip to content

Commit

Permalink
process-catalog: support px:content-type="calabash-config"
Browse files Browse the repository at this point in the history
  • Loading branch information
bertfrees committed Mar 14, 2019
1 parent f4667de commit 3f22e0a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 6 deletions.
6 changes: 4 additions & 2 deletions modules-build-helper/src/it/it-pipeline-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
org.daisy.pipeline.datatypes.impl.Datatype_foo_choice,
org.daisy.pipeline.datatypes.impl.Datatype_px_script_option_1,
org.daisy.pipeline.braille.liblouis.impl.LiblouisTablePath,
org.daisy.pipeline.modules.impl.Module_it_pipeline_module
org.daisy.pipeline.modules.impl.Module_it_pipeline_module,
org.daisy.common.xproc.calabash.impl.ConfigurationFileProvider_it_pipeline_module
</expose-services>
</properties>
<build>
Expand Down Expand Up @@ -135,7 +136,8 @@
org.daisy.pipeline.modules.impl;-split-package:=first,
org.daisy.pipeline.script.impl;-split-package:=first,
org.daisy.pipeline.datatypes.impl;-split-package:=first,
org.daisy.pipeline.braille.liblouis.impl;-split-package:=first
org.daisy.pipeline.braille.liblouis.impl;-split-package:=first,
org.daisy.common.xproc.calabash.impl;-split-package:=first
</Private-Package>
</instructions>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
<c:file name="META-INF/catalog.xml"/>
<c:file name="META-INF/services/org.daisy.Foo"/>
<c:file name="META-INF/services/org.daisy.common.spi.CreateOnStart"/>
<c:file name="META-INF/services/org.daisy.common.xproc.calabash.ConfigurationFileProvider"/>
<c:file name="META-INF/services/org.daisy.common.xproc.calabash.XProcStepProvider"/>
<c:file name="META-INF/services/org.daisy.pipeline.braille.liblouis.LiblouisTablePath"/>
<c:file name="META-INF/services/org.daisy.pipeline.datatypes.DatatypeService"/>
<c:file name="META-INF/services/org.daisy.pipeline.modules.ModuleRef"/>
<c:file name="META-INF/services/org.daisy.pipeline.script.XProcScriptService"/>
<c:file name="OSGI-INF/calabash-config-it-pipeline-module.xml"/>
<c:file name="OSGI-INF/foo-choice.xml"/>
<c:file name="OSGI-INF/foo-service.xml"/>
<c:file name="OSGI-INF/java-step.xml"/>
Expand All @@ -48,6 +50,8 @@
<c:file name="impl/JavaStep.class"/>
<c:file name="impl/JavaStep_Provider_SPI.class"/>
<c:file name="org/daisy/Foo.class"/>
<c:file name="org/daisy/common/xproc/calabash/impl/ConfigurationFileProvider_it_pipeline_module.class"/>
<c:file name="org/daisy/common/xproc/calabash/impl/ConfigurationFileProvider_it_pipeline_module_SPI.class"/>
<c:file name="org/daisy/impl/FooImpl.class"/>
<c:file name="org/daisy/impl/FooImpl_SPI.class"/>
<c:file name="org/daisy/pipeline/braille/liblouis/impl/LiblouisTablePath.class"/>
Expand Down Expand Up @@ -173,6 +177,20 @@
</scr:component>
</x:document>
</x:expect>
<x:context label="The OSGI-INF/calabash-config-it-pipeline-module.xml file">
<x:document type="file" href="${project.build.directory}/it-pipeline-module-${project.version}.jar!/OSGI-INF/calabash-config-it-pipeline-module.xml"/>
</x:context>
<x:expect label="The OSGI-INF/calabash-config-it-pipeline-module.xml file" type="compare">
<x:document type="inline">
<scr:component activate="activate" name="calabash-config-it-pipeline-module">
<implementation class="org.daisy.common.xproc.calabash.impl.ConfigurationFileProvider_it_pipeline_module"/>
<service>
<provide interface="org.daisy.common.xproc.calabash.ConfigurationFileProvider"/>
</service>
<property name="path" type="String" value="/calabash-config.xml"/>
</scr:component>
</x:document>
</x:expect>
<x:context label="The OSGI-INF/liblouis-tables.xml file">
<x:document type="file" href="${project.build.directory}/it-pipeline-module-${project.version}.jar!/OSGI-INF/liblouis-tables.xml"/>
</x:context>
Expand Down Expand Up @@ -203,6 +221,10 @@
<c:file name="src/main/java/impl/package-summary.html"/>
<c:file name="src/main/java/index.html"/>
<c:file name="src/main/java/org/daisy/Foo.html"/>
<c:file name="src/main/java/org/daisy/common/xproc/calabash/impl/ConfigurationFileProvider_it_pipeline_module.html"/>
<c:file name="src/main/java/org/daisy/common/xproc/calabash/impl/ConfigurationFileProvider_it_pipeline_module_SPI.html"/>
<c:file name="src/main/java/org/daisy/common/xproc/calabash/impl/package-frame.html"/>
<c:file name="src/main/java/org/daisy/common/xproc/calabash/impl/package-summary.html"/>
<c:file name="src/main/java/org/daisy/impl/FooImpl.html"/>
<c:file name="src/main/java/org/daisy/impl/FooImpl_SPI.html"/>
<c:file name="src/main/java/org/daisy/impl/package-frame.html"/>
Expand Down Expand Up @@ -275,8 +297,8 @@
<x:document type="inline">
<c:zipfile name="it-pipeline-module-${project.version}-xprocdoc.jar">
<c:file name="META-INF/MANIFEST.MF"/>
<c:file name="d192e5.html"/>
<c:file name="d192e56.html"/>
<c:file name="d193e5.html"/>
<c:file name="d193e56.html"/>
<c:file name="index.html"/>
<c:file name="libraries.html"/>
<c:file name="org/daisy/pipeline/modules/foo-utils/library.xpl.html"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.css" uri="../css/foo.css"/>
<uri uri="../data-types/type.xml" px:content-type="data-type" px:id="foo:choice"/>
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/liblouis/" uri="../liblouis/"
px:content-type="liblouis-tables" px:include="*"/>
px:content-type="liblouis-tables" px:include="*"/>
<uri uri="../calabash-config.xml" px:content-type="calabash-config"/>
</catalog>
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@ public class <xsl:value-of select="$className"/> implements ModuleRef {
</xsl:choose>
</xsl:template>

<xsl:template match="cat:uri[@px:content-type=('liblouis-tables',
<xsl:template match="cat:uri[@px:content-type=('calabash-config',
'liblouis-tables',
'libhyphen-tables')]|
cat:uri/@px:content-type[.=('script',
'data-type',
'calabash-config',
'liblouis-tables',
'libhyphen-tables')]|
cat:uri/@px:extends|
Expand Down Expand Up @@ -302,6 +304,45 @@ public class <xsl:value-of select="$className"/> extends UrlBasedDatatypeService
}</c:data></xsl:result-document>
</xsl:template>

<xsl:template match="cat:uri[@px:content-type='calabash-config']" mode="java">
<!--
assuming catalog.xml is placed in META-INF
-->
<xsl:variable name="path" select="pf:normalize-path(concat('/META-INF/',@uri))"/>
<xsl:call-template name="calabash-config-class">
<xsl:with-param name="path" select="$path"/>
</xsl:call-template>
</xsl:template>

<xsl:template name="calabash-config-class">
<xsl:param name="path" as="xs:string" required="yes"/>
<xsl:variable name="className" select="concat('ConfigurationFileProvider_',replace($moduleName,'-','_'))"/>
<xsl:result-document href="{$generatedSourcesDirectory}/org/daisy/common/xproc/calabash/impl/{$className}.java"
method="text" xml:space="preserve"><c:data>package org.daisy.common.xproc.calabash.impl;

import java.util.Map;

import org.daisy.common.xproc.calabash.BundledConfigurationFileProvider;
import org.daisy.common.xproc.calabash.ConfigurationFileProvider;

import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;

@Component(
name = "calabash-config-<xsl:value-of select="$moduleName"/>",
service = { ConfigurationFileProvider.class },
property = {
"path:String=<xsl:value-of select="$path"/>",
}
)
public class <xsl:value-of select="$className"/> extends BundledConfigurationFileProvider {
@Activate
public void activate(Map&lt;?,?&gt; properties) {
super.activate(properties, <xsl:value-of select="$className"/>.class);
}
}</c:data></xsl:result-document>
</xsl:template>

<xsl:template match="cat:uri[@px:content-type='liblouis-tables']" mode="java">
<!--
assuming catalog.xml is placed in META-INF
Expand Down

0 comments on commit 3f22e0a

Please sign in to comment.