01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Rustem V. Rafikov
19: * @version $Revision: 1.3 $
20: */package javax.imageio.spi;
21:
22: import java.util.Arrays;
23:
24: import org.apache.harmony.x.imageio.plugins.gif.GIFImageReaderSpi;
25: import org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageReaderSpi;
26: import org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriterSpi;
27: import org.apache.harmony.x.imageio.plugins.png.PNGImageReaderSpi;
28: import org.apache.harmony.x.imageio.plugins.png.PNGImageWriterSpi;
29: import org.apache.harmony.x.imageio.spi.FileIISSpi;
30: import org.apache.harmony.x.imageio.spi.FileIOSSpi;
31: import org.apache.harmony.x.imageio.spi.InputStreamIISSpi;
32: import org.apache.harmony.x.imageio.spi.OutputStreamIOSSpi;
33: import org.apache.harmony.x.imageio.spi.RAFIISSpi;
34: import org.apache.harmony.x.imageio.spi.RAFIOSSpi;
35:
36: public final class IIORegistry extends ServiceRegistry {
37:
38: private static IIORegistry instance;
39:
40: private static final Class[] CATEGORIES = new Class[] {
41: javax.imageio.spi.ImageWriterSpi.class,
42: javax.imageio.spi.ImageReaderSpi.class,
43: javax.imageio.spi.ImageInputStreamSpi.class,
44: // javax.imageio.spi.ImageTranscoderSpi.class,
45: javax.imageio.spi.ImageOutputStreamSpi.class };
46:
47: private IIORegistry() {
48: super (Arrays.<Class<?>> asList(CATEGORIES).iterator());
49: registerBuiltinSpis();
50: registerApplicationClasspathSpis();
51: }
52:
53: private void registerBuiltinSpis() {
54: registerServiceProvider(new JPEGImageWriterSpi());
55: registerServiceProvider(new JPEGImageReaderSpi());
56: registerServiceProvider(new PNGImageReaderSpi());
57: registerServiceProvider(new PNGImageWriterSpi());
58: registerServiceProvider(new GIFImageReaderSpi());
59: registerServiceProvider(new FileIOSSpi());
60: registerServiceProvider(new FileIISSpi());
61: registerServiceProvider(new RAFIOSSpi());
62: registerServiceProvider(new RAFIISSpi());
63: registerServiceProvider(new OutputStreamIOSSpi());
64: registerServiceProvider(new InputStreamIISSpi());
65: }
66:
67: public static IIORegistry getDefaultInstance() {
68: // TODO implement own instance for each ThreadGroup (see also
69: // ThreadLocal)
70: synchronized (IIORegistry.class) {
71: if (instance == null) {
72: instance = new IIORegistry();
73: }
74: return instance;
75: }
76: }
77:
78: public void registerApplicationClasspathSpis() {
79: // -- TODO implement for non-builtin plugins
80: }
81: }
|