View Javadoc

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  /***
25   * Provide JDK 1.3 style service discovery...
26   * 
27   * The caller will first configure the discoverer by creating a
28   * root Discoverer for the files.
29   *
30   * @author Richard A. Sitze
31   * @author Craig R. McClanahan
32   * @author Costin Manolache
33   * @author James Strachan
34   */
35  public class DiscoverServiceNames
36      extends DiscoverNamesInFile
37      implements ResourceNameDiscover
38  {
39      protected static final String SERVICE_HOME = "META-INF/services/";
40      
41      /*** Construct a new service discoverer
42       */
43      public DiscoverServiceNames() {
44          super(SERVICE_HOME, null);
45      }
46          
47      /***
48       *  Construct a new resource discoverer
49       */
50      public DiscoverServiceNames(String prefix, String suffix) {
51          super((prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
52      }
53      
54      /***
55       *  Construct a new resource discoverer
56       */
57      public DiscoverServiceNames(ClassLoaders loaders) {
58          super(loaders, SERVICE_HOME, null);
59      }
60      
61      /***
62       *  Construct a new resource discoverer
63       */
64      public DiscoverServiceNames(ClassLoaders loaders, String prefix, String suffix) {
65          super(loaders, (prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
66      }
67      
68      /*** Construct a new service discoverer
69       */
70      public DiscoverServiceNames(ResourceDiscover discoverer) {
71          super(discoverer, SERVICE_HOME, null);
72      }
73      
74      /*** Construct a new service discoverer
75       */
76      public DiscoverServiceNames(ResourceDiscover discoverer, String prefix, String suffix) {
77          super(discoverer, (prefix == null) ? SERVICE_HOME : SERVICE_HOME + prefix, suffix);
78      }
79  }