001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.discovery.resource.names;
018
019 import org.apache.commons.discovery.ResourceDiscover;
020 import org.apache.commons.discovery.ResourceNameDiscover;
021 import org.apache.commons.discovery.resource.ClassLoaders;
022
023
024 /**
025 * Provide JDK 1.3 style service discovery...
026 *
027 * The caller will first configure the discoverer by creating a
028 * root Discoverer for the files.
029 *
030 * @author Richard A. Sitze
031 * @author Craig R. McClanahan
032 * @author Costin Manolache
033 * @author James Strachan
034 */
035 public class DiscoverServiceNames
036 extends DiscoverNamesInFile
037 implements ResourceNameDiscover
038 {
039 protected static final String SERVICE_HOME = "META-INF/services/";
040
041 /** Construct a new service discoverer
042 */
043 public DiscoverServiceNames() {
044 super(SERVICE_HOME, null);
045 }
046
047 /**
048 * Construct a new resource discoverer
049 */
050 public DiscoverServiceNames(String prefix, String suffix) {
051 super((prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
052 }
053
054 /**
055 * Construct a new resource discoverer
056 */
057 public DiscoverServiceNames(ClassLoaders loaders) {
058 super(loaders, SERVICE_HOME, null);
059 }
060
061 /**
062 * Construct a new resource discoverer
063 */
064 public DiscoverServiceNames(ClassLoaders loaders, String prefix, String suffix) {
065 super(loaders, (prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
066 }
067
068 /** Construct a new service discoverer
069 */
070 public DiscoverServiceNames(ResourceDiscover discoverer) {
071 super(discoverer, SERVICE_HOME, null);
072 }
073
074 /** Construct a new service discoverer
075 */
076 public DiscoverServiceNames(ResourceDiscover discoverer, String prefix, String suffix) {
077 super(discoverer, (prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
078 }
079 }