blob: 3c1c989db3403f0f8a7eb3324b8c085edec34566 [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * 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 */
21package javax.imageio.spi;
22
23import java.util.Arrays;
24
25import org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageReaderSpi;
26import org.apache.harmony.x.imageio.plugins.jpeg.JPEGImageWriterSpi;
27import org.apache.harmony.x.imageio.plugins.png.PNGImageReaderSpi;
28import org.apache.harmony.x.imageio.plugins.png.PNGImageWriterSpi;
29import org.apache.harmony.x.imageio.spi.FileIISSpi;
30import org.apache.harmony.x.imageio.spi.FileIOSSpi;
31import org.apache.harmony.x.imageio.spi.InputStreamIISSpi;
32import org.apache.harmony.x.imageio.spi.OutputStreamIOSSpi;
33import org.apache.harmony.x.imageio.spi.RAFIISSpi;
34import org.apache.harmony.x.imageio.spi.RAFIOSSpi;
35
36/*
37 * @author Rustem V. Rafikov, Viskov Nikolay
38 * @version $Revision: 1.3 $
39 */
40
41/**
42 * The IIORegistry class registers service provider instances
43 * (SPI). Service provider instances are recognized by specific
44 * meta-information in the JAR files containing them. The JAR
45 * files with SPI classes are loaded from the application class
46 * path.
47 */
48public final class IIORegistry extends ServiceRegistry {
49
50 /** The instance. */
51 private static IIORegistry instance;
52
53 /** The Constant CATEGORIES. */
54 private static final Class[] CATEGORIES = new Class[] {
55 javax.imageio.spi.ImageWriterSpi.class,
56 javax.imageio.spi.ImageReaderSpi.class,
57 javax.imageio.spi.ImageInputStreamSpi.class,
58 //javax.imageio.spi.ImageTranscoderSpi.class,
59 javax.imageio.spi.ImageOutputStreamSpi.class
60 };
61
62 /**
63 * Instantiates a new iIO registry.
64 */
65 private IIORegistry() {
66 super(Arrays.<Class<?>>asList(CATEGORIES).iterator());
67 registerBuiltinSpis();
68 registerApplicationClasspathSpis();
69 }
70
71 /**
72 * Register builtin spis.
73 */
74 private void registerBuiltinSpis() {
75 registerServiceProvider(new JPEGImageWriterSpi());
76 registerServiceProvider(new JPEGImageReaderSpi());
77 registerServiceProvider(new PNGImageReaderSpi());
78 registerServiceProvider(new PNGImageWriterSpi());
79 registerServiceProvider(new FileIOSSpi());
80 registerServiceProvider(new FileIISSpi());
81 registerServiceProvider(new RAFIOSSpi());
82 registerServiceProvider(new RAFIISSpi());
83 registerServiceProvider(new OutputStreamIOSSpi());
84 registerServiceProvider(new InputStreamIISSpi());
85 //-- TODO implement
86 }
87
88 /**
89 * Gets the default IIORegistry instance.
90 *
91 * @return the default IIORegistry instance.
92 */
93 public static IIORegistry getDefaultInstance() {
94 // TODO implement own instance for each ThreadGroup (see also ThreadLocal)
95 synchronized (IIORegistry.class) {
96 if (instance == null) {
97 instance = new IIORegistry();
98 }
99 return instance;
100 }
101 }
102
103 /**
104 * Registers all service providers from the application class
105 * path.
106 */
107 public void registerApplicationClasspathSpis() {
108 //-- TODO implement for non-builtin plugins
109 }
110}