1   /***************************************************************/
2   /* This class was generated by ds-to-spi-annotations-processor */
3   /***************************************************************/
4   
5   package org.daisy.pipeline.file.calabash.impl;
6   
7   public class LoadProvider_SPI
8          implements org.daisy.common.spi.ServiceWithProperties
9                   , org.daisy.common.xproc.calabash.XProcStepProvider
10  {
11  	
12  	private static final org.slf4j.Logger spi_log = org.slf4j.LoggerFactory.getLogger(LoadProvider_SPI.class);
13  	
14  	private final java.util.Map spi_props;
15  	private boolean spi_deactivated = false;
16  	
17  	private final org.daisy.pipeline.file.calabash.impl.LoadProvider delegate;
18  
19  	public LoadProvider_SPI() {
20  		delegate = new org.daisy.pipeline.file.calabash.impl.LoadProvider();
21  		spi_log.trace("Creating LoadProvider");
22  		spi_props = new java.util.HashMap();
23  		spi_props.put("component.name", "px:load");
24  		spi_props.put("type", "{http://www.daisy.org/ns/pipeline/xproc}load");
25  		{
26  			spi_log.trace("Binding org.daisy.common.xml.DocumentBuilder services...");
27  			// cardinality: 0..n
28  			int minRef = 0;
29  			int maxRef = -1;
30  			int refCount = 0;
31  			try {
32  				java.util.Iterator<org.daisy.common.xml.DocumentBuilder> services
33  					= org.daisy.common.spi.ServiceLoader.load(org.daisy.common.xml.DocumentBuilder.class).iterator();
34  				while (services.hasNext()) {
35  					try {
36  						org.daisy.common.xml.DocumentBuilder service = services.next();
37  						delegate.addInputParser(service);
38  						spi_log.trace("Bound org.daisy.common.xml.DocumentBuilder service: "
39  						              + service.getClass().getName() + "@"
40  						              + Integer.toHexString(System.identityHashCode(service)));
41  						refCount++;
42  						if (maxRef > 0 && refCount == maxRef)
43  							break;
44  					} catch (Throwable e) {
45  						spi_log.error("Error while binding org.daisy.common.xml.DocumentBuilder service", e);
46  					}
47  				}
48  			} catch (Throwable e) {
49  				spi_log.error("Error while binding org.daisy.common.xml.DocumentBuilder services", e);
50  			}
51  			if (refCount < minRef) {
52  				spi_log.warn("No org.daisy.common.xml.DocumentBuilder found");
53  				throw new RuntimeException("No org.daisy.common.xml.DocumentBuilder found");
54  			} else {
55  				spi_log.trace("Bound " + refCount + " org.daisy.common.xml.DocumentBuilder services.");
56  			}
57  		}
58  	}
59  	
60  	public void spi_deactivate() {
61  	}
62  	
63  	public java.util.Map spi_getProperties() {
64  		return spi_props;
65  	}
66  
67  	@Override
68  	public org.daisy.common.xproc.calabash.XProcStep newStep(
69  		com.xmlcalabash.core.XProcRuntime arg1,
70  		com.xmlcalabash.runtime.XAtomicStep arg2,
71  		org.daisy.common.xproc.XProcMonitor arg3,
72  		java.util.Map<java.lang.String,java.lang.String> arg4
73  	) {
74  		return delegate.newStep(
75  			arg1,
76  			arg2,
77  			arg3,
78  			arg4
79  		);
80  	}
81  
82  	@Override
83  	public String toString() {
84  		return delegate.toString();
85  	}
86  
87  	@Override
88  	public int hashCode() {
89  		return delegate.hashCode();
90  	}
91  
92  	@Override
93  	public boolean equals(Object o) {
94  		return delegate.equals(o);
95  	}
96  }