1   /***************************************************************/
2   /* This class was generated by ds-to-spi-annotations-processor */
3   /***************************************************************/
4   
5   package org.daisy.pipeline.tts.calabash.impl;
6   
7   public class SynthesizeProvider_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(SynthesizeProvider_SPI.class);
13  	
14  	private final java.util.Map spi_props;
15  	private boolean spi_deactivated = false;
16  	
17  	private final org.daisy.pipeline.tts.calabash.impl.SynthesizeProvider delegate;
18  
19  	public SynthesizeProvider_SPI() {
20  		delegate = new org.daisy.pipeline.tts.calabash.impl.SynthesizeProvider();
21  		spi_log.trace("Creating SynthesizeProvider");
22  		spi_props = new java.util.HashMap();
23  		spi_props.put("component.name", "ssml-to-audio");
24  		spi_props.put("type", "{http://www.daisy.org/ns/pipeline/xproc}ssml-to-audio");
25  		{
26  			spi_log.trace("Binding org.daisy.pipeline.tts.TTSRegistry services...");
27  			// cardinality: 1..1
28  			int minRef = 1;
29  			int maxRef = 1;
30  			int refCount = 0;
31  			try {
32  				java.util.Iterator<org.daisy.pipeline.tts.TTSRegistry> services
33  					= org.daisy.common.spi.ServiceLoader.load(org.daisy.pipeline.tts.TTSRegistry.class).iterator();
34  				while (services.hasNext()) {
35  					try {
36  						org.daisy.pipeline.tts.TTSRegistry service = services.next();
37  						delegate.setTTSRegistry(service);
38  						spi_log.trace("Bound org.daisy.pipeline.tts.TTSRegistry 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.pipeline.tts.TTSRegistry service", e);
46  					}
47  				}
48  			} catch (Throwable e) {
49  				spi_log.error("Error while binding org.daisy.pipeline.tts.TTSRegistry services", e);
50  			}
51  			if (refCount < minRef) {
52  				spi_log.warn("No org.daisy.pipeline.tts.TTSRegistry found");
53  				throw new RuntimeException("No org.daisy.pipeline.tts.TTSRegistry found");
54  			} else {
55  				spi_log.trace("Bound " + refCount + " org.daisy.pipeline.tts.TTSRegistry services.");
56  			}
57  		}
58  		{
59  			spi_log.trace("Binding org.daisy.pipeline.audio.AudioServices services...");
60  			// cardinality: 0..1
61  			int minRef = 0;
62  			int maxRef = 1;
63  			int refCount = 0;
64  			try {
65  				java.util.Iterator<org.daisy.pipeline.audio.AudioServices> services
66  					= org.daisy.common.spi.ServiceLoader.load(org.daisy.pipeline.audio.AudioServices.class).iterator();
67  				while (services.hasNext()) {
68  					try {
69  						org.daisy.pipeline.audio.AudioServices service = services.next();
70  						delegate.setAudioServices(service);
71  						spi_log.trace("Bound org.daisy.pipeline.audio.AudioServices service: "
72  						              + service.getClass().getName() + "@"
73  						              + Integer.toHexString(System.identityHashCode(service)));
74  						refCount++;
75  						if (maxRef > 0 && refCount == maxRef)
76  							break;
77  					} catch (Throwable e) {
78  						spi_log.error("Error while binding org.daisy.pipeline.audio.AudioServices service", e);
79  					}
80  				}
81  			} catch (Throwable e) {
82  				spi_log.error("Error while binding org.daisy.pipeline.audio.AudioServices services", e);
83  			}
84  			if (refCount < minRef) {
85  				spi_log.warn("No org.daisy.pipeline.audio.AudioServices found");
86  				throw new RuntimeException("No org.daisy.pipeline.audio.AudioServices found");
87  			} else {
88  				spi_log.trace("Bound " + refCount + " org.daisy.pipeline.audio.AudioServices services.");
89  			}
90  		}
91  	}
92  	
93  	public void spi_deactivate() {
94  	}
95  	
96  	public java.util.Map spi_getProperties() {
97  		return spi_props;
98  	}
99  
100 	@Override
101 	public org.daisy.common.xproc.calabash.XProcStep newStep(
102 		com.xmlcalabash.core.XProcRuntime arg1,
103 		com.xmlcalabash.runtime.XAtomicStep arg2,
104 		org.daisy.common.xproc.XProcMonitor arg3,
105 		java.util.Map<java.lang.String,java.lang.String> arg4
106 	) {
107 		return delegate.newStep(
108 			arg1,
109 			arg2,
110 			arg3,
111 			arg4
112 		);
113 	}
114 
115 	@Override
116 	public String toString() {
117 		return delegate.toString();
118 	}
119 
120 	@Override
121 	public int hashCode() {
122 		return delegate.hashCode();
123 	}
124 
125 	@Override
126 	public boolean equals(Object o) {
127 		return delegate.equals(o);
128 	}
129 }