1 /*
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 package org.apache.commons.discovery.resource.names;
18
19 import org.apache.commons.discovery.ResourceDiscover;
20 import org.apache.commons.discovery.ResourceNameDiscover;
21 import org.apache.commons.discovery.resource.ClassLoaders;
22
23 /**
24 * Provide JDK 1.3 style service discovery...
25 *
26 * The caller will first configure the discoverer by creating a
27 * root Discoverer for the files.
28 */
29 public class DiscoverServiceNames extends DiscoverNamesInFile implements ResourceNameDiscover {
30
31 protected static final String SERVICE_HOME = "META-INF/services/";
32
33 /**
34 * Construct a new service discoverer.
35 */
36 public DiscoverServiceNames() {
37 super(SERVICE_HOME, null);
38 }
39
40 /**
41 * Construct a new resource discoverer.
42 *
43 * @param prefix The resource name prefix
44 * @param suffix The resource name suffix
45 */
46 public DiscoverServiceNames(String prefix, String suffix) {
47 super((prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
48 }
49
50 /**
51 * Construct a new resource discoverer.
52 *
53 * @param loaders The class loaders holder
54 */
55 public DiscoverServiceNames(ClassLoaders loaders) {
56 super(loaders, SERVICE_HOME, null);
57 }
58
59 /**
60 * Construct a new resource discoverer.
61 *
62 * @param loaders The class loaders holder
63 * @param prefix The resource name prefix
64 * @param suffix The resource name suffix
65 */
66 public DiscoverServiceNames(ClassLoaders loaders, String prefix, String suffix) {
67 super(loaders, (prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
68 }
69
70 /**
71 * Construct a new service discoverer.
72 *
73 * @param discoverer The discoverer to resolve resources
74 */
75 public DiscoverServiceNames(ResourceDiscover discoverer) {
76 super(discoverer, SERVICE_HOME, null);
77 }
78
79 /**
80 * Construct a new service discoverer.
81 *
82 * @param discoverer The discoverer to resolve resources
83 * @param prefix The resource name prefix
84 * @param suffix The resource name suffix
85 */
86 public DiscoverServiceNames(ResourceDiscover discoverer, String prefix, String suffix) {
87 super(discoverer, (prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
88 }
89
90 }