
com.sun.jmx.remote.protocol.jmxmp.EnvironmentProviderHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jppf-jmxremote_optional Show documentation
Show all versions of jppf-jmxremote_optional Show documentation
A modification of the OpenDMK JMX remote implementation. Licensed under the Apache Software License v2.0 as permitted by the original CDDL license
/*
* JPPF.
* Copyright (C) 2005-2016 JPPF Team.
* http://www.jppf.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sun.jmx.remote.protocol.jmxmp;
import java.util.*;
/**
* Instances of this class load and provide access to environment proivders.
* @param the type of the providers to load.
* @author Laurent Cohen
*/
class EnvironmentProviderHandler {
/**
* The client providers.
*/
private final List providers;
/**
* Initialize this handler witht he specified provider class.
* @param clazz the class of the providers to laod.
*/
EnvironmentProviderHandler(final Class clazz) {
providers = Collections.unmodifiableList(loadProviders(clazz));
}
/**
* Load the providers of specified type via SPI.
* @param clazz the class of the providers to load.
* @return a list of the loaded providers, possibly empty.
*/
private List loadProviders(final Class clazz) {
List list = new ArrayList<>();
ServiceLoader sl = ServiceLoader.load(clazz);
Iterator it = sl.iterator();
boolean end = false;
while (!end) {
// hasNext() and next() may throw a ServiceCOnfigurationError
try {
if (it.hasNext()) list.add(it.next());
else end = true;
} catch(Exception|ServiceConfigurationError e) {
end = true;
}
}
return list;
}
/**
* Get the client providers.
* @return a list of privder instances.
*/
List getProviders() {
return providers;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy