1 /*
2 (C) Copyright IBM Corp. 2007, 2009
3
4 THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
5 ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
6 CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
7
8 You can obtain a current copy of the Eclipse Public License from
9 http://www.opensource.org/licenses/eclipse-1.0.php
10
11 @author : Alexander Wolf-Reber, IBM, a.wolf-reber@de.ibm.com
12 *
13 * Change History
14 * Flag Date Prog Description
15 *-------------------------------------------------------------------------------
16 * 1678915 2007-03-12 lupusalex Integrated WBEM service discovery via SLP
17 * 2003590 2008-06-30 blaschke-oss Change licensing from CPL to EPL
18 * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1)
19 */
20
21 package org.metricshub.wbem.sblim.cimclient.discovery;
22
23 /*-
24 * ╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲
25 * WBEM Java Client
26 * ჻჻჻჻჻჻
27 * Copyright 2023 - 2025 MetricsHub
28 * ჻჻჻჻჻჻
29 * Licensed under the Apache License, Version 2.0 (the "License");
30 * you may not use this file except in compliance with the License.
31 * You may obtain a copy of the License at
32 *
33 * http://www.apache.org/licenses/LICENSE-2.0
34 *
35 * Unless required by applicable law or agreed to in writing, software
36 * distributed under the License is distributed on an "AS IS" BASIS,
37 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38 * See the License for the specific language governing permissions and
39 * limitations under the License.
40 * ╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱╲╱
41 */
42
43 import java.util.Locale;
44 import org.metricshub.wbem.sblim.cimclient.discovery.Discoverer;
45 import org.metricshub.wbem.sblim.cimclient.internal.discovery.slp.DiscovererSLP;
46
47 /**
48 * Class DiscovererFactory is responsible for creating concrete instances of the
49 * Discoverer interface.
50 *
51 * This class is thread-safe.
52 *
53 * @since 2.0.2
54 */
55 public class DiscovererFactory {
56 /**
57 * The Service Location Protocol (SLP)
58 */
59 public static final String SLP = "SLP";
60
61 private static final String[] cProtocols = new String[] { SLP };
62
63 /**
64 * Returns the concrete Discoverer for a given discovery protocol.
65 *
66 * @param pProtocol The discovery protocol, e.g. "SLP"
67 * @return The corresponding discoverer
68 * @throws IllegalArgumentException On unsupported protocols
69 * Factory Method
70 */
71 public static Discoverer getDiscoverer(String pProtocol) throws IllegalArgumentException {
72 if (SLP.equalsIgnoreCase(pProtocol)) {
73 return new DiscovererSLP(Locale.US);
74 }
75 throw new IllegalArgumentException("Protocol " + pProtocol + " not supported.");
76 }
77
78 /**
79 * Return an array of all supported discovery protocols
80 *
81 * @return The supported protocols
82 */
83 public static String[] getSupportedProtocols() {
84 return cProtocols;
85 }
86
87 private DiscovererFactory() {
88 /**/
89 }
90 }