com.sun.jmx.remote.generic
Class ProfileClientFactory

java.lang.Object
  extended by com.sun.jmx.remote.generic.ProfileClientFactory

public class ProfileClientFactory
extends Object

Factory to create profiles. There are no instances of this class.

Each profile is created by an instance of ProfileClientProvider. This instance is found as follows. Suppose the given profile looks like TLS. Then the factory will attempt to find the appropriate ProfileClientProvider for tls. Suppose the given profile looks like SASL/PLAIN. Then the factory will attempt to find the appropriate ProfileClientProvider for sasl. The profile string passed in to the factory is converted into lowercase and all the characters after the / character are discarded.

A provider package list is searched for as follows:

  1. If the environment parameter to createProfile contains the key jmx.remote.profile.provider.pkgs then the associated value is the provider package list.
  2. Otherwise, if the system property jmx.remote.profile.provider.pkgs exists, then its value is the provider package list.
  3. Otherwise, there is no provider package list.

The provider package list is a string that is interpreted as a list of non-empty Java package names separated by vertical bars (|). If the string is empty, then so is the provider package list. If the provider package list is not a String, or if it contains an element that is an empty string, a ProfileProviderException is thrown.

If the provider package list exists and is not empty, then for each element pkg of the list, the factory will attempt to load the class

pkg.profile.ClientProvider

If the environment parameter to createProfile contains the key jmx.remote.profile.provider.class.loader then the associated value is the class loader to use to load the provider. If the associated value is not an instance of ClassLoader, an IllegalArgumentException is thrown.

If the jmx.remote.profile.provider.class.loader key is not present in the environment parameter, the class loader that loaded the ProfileClientFactory class is used.

If the attempt to load this class produces a ClassNotFoundException, the search for a provider continues with the next element of the list.

Otherwise, a problem with the found provider is signalled by a ProfileProviderException whose cause indicates the underlying exception, as follows:

If no provider is found by the above steps, including the default case where there is no provider package list, then the implementation will use its own provider for profile, or it will throw a IllegalArgumentException if there is none.

Once a provider is found, the result of the createProfile method is the result of calling createProfile on the provider.

The Map parameter passed to the ProfileClientProvider is a new read-only copy of the environment parameter to ProfileClientFactory.createProfile, or an empty Map if that parameter is null. If the jmx.remote.profile.provider.class.loader key is not present in the environment parameter, it is added to the new read-only Map. The associated value is the class loader that loaded the ProfileClientFactory class.


Field Summary
static String PROFILE_PROVIDER_CLASS_LOADER
          Name of the attribute that specifies the class loader for loading profile providers.
static String PROFILE_PROVIDER_PACKAGES
          Name of the attribute that specifies the provider packages that are consulted when looking for the provider for a profile.
 
Method Summary
static ProfileClient createProfile(String profile, Map environment)
          Create a profile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROFILE_PROVIDER_PACKAGES

public static final String PROFILE_PROVIDER_PACKAGES

Name of the attribute that specifies the provider packages that are consulted when looking for the provider for a profile. The value associated with this attribute is a string with package names separated by vertical bars (|).

See Also:
Constant Field Values

PROFILE_PROVIDER_CLASS_LOADER

public static final String PROFILE_PROVIDER_CLASS_LOADER

Name of the attribute that specifies the class loader for loading profile providers. The value associated with this attribute is an instance of ClassLoader.

See Also:
Constant Field Values
Method Detail

createProfile

public static ProfileClient createProfile(String profile,
                                          Map environment)
                                   throws ProfileProviderException

Create a profile.

Parameters:
profile - the name of the profile to be created.
environment - a read-only Map containing named attributes to determine how the profile is created. Keys in this map must be Strings. The appropriate type of each associated value depends on the attribute.

Returns:
a ProfileClient representing the new profile. Each successful call to this method produces a different object.
Throws:
NullPointerException - if profile is null.
ProfileProviderException


Copyright © 2014 Terracotta, Inc.. All rights reserved.