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