Class PulsarConfigurationLoader
java.lang.Object
org.apache.pulsar.common.configuration.PulsarConfigurationLoader
Loads ServiceConfiguration with properties.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ServiceConfigurationstatic ServiceConfigurationconvertFrom(PulsarConfiguration conf, boolean ignoreNonExistMember) Converts a PulsarConfiguration object to a ServiceConfiguration object.static <T extends PulsarConfiguration>
Tcreate(InputStream inStream, Class<? extends PulsarConfiguration> clazz) Creates PulsarConfiguration and loads it with populated attribute values loaded from provided inputstream property file.static <T extends PulsarConfiguration>
Tcreate(String configFile, Class<? extends PulsarConfiguration> clazz) Creates PulsarConfiguration and loads it with populated attribute values loaded from provided property file.static <T extends PulsarConfiguration>
Tcreate(Properties properties, Class<? extends PulsarConfiguration> clazz) Creates PulsarConfiguration and loads it with populated attribute values from provided Properties object.static booleanisComplete(Object obj) ValidatesFieldContextannotation on each field of the class element.
-
Constructor Details
-
PulsarConfigurationLoader
public PulsarConfigurationLoader()
-
-
Method Details
-
create
public static <T extends PulsarConfiguration> T create(String configFile, Class<? extends PulsarConfiguration> clazz) throws IOException, IllegalArgumentException Creates PulsarConfiguration and loads it with populated attribute values loaded from provided property file.- Parameters:
configFile-- Throws:
IOExceptionIllegalArgumentException
-
create
public static <T extends PulsarConfiguration> T create(InputStream inStream, Class<? extends PulsarConfiguration> clazz) throws IOException, IllegalArgumentException Creates PulsarConfiguration and loads it with populated attribute values loaded from provided inputstream property file.- Parameters:
inStream-- Throws:
IOException- if an error occurred when reading from the input stream.IllegalArgumentException- if the input stream contains incorrect value type
-
create
public static <T extends PulsarConfiguration> T create(Properties properties, Class<? extends PulsarConfiguration> clazz) throws IOException, IllegalArgumentException Creates PulsarConfiguration and loads it with populated attribute values from provided Properties object.- Parameters:
properties- The properties to populate the attributed from- Throws:
IOExceptionIllegalArgumentException
-
isComplete
ValidatesFieldContextannotation on each field of the class element. If element is annotated required and value of the element is null or number value is not in a provided (min,max) range then consider as incomplete object and throws exception with incomplete parameters- Parameters:
obj-- Returns:
- Throws:
IllegalArgumentException- if object is field values are not completed according toFieldContextconstraints.IllegalAccessException
-
convertFrom
public static ServiceConfiguration convertFrom(PulsarConfiguration conf, boolean ignoreNonExistMember) throws RuntimeException Converts a PulsarConfiguration object to a ServiceConfiguration object.- Parameters:
conf-ignoreNonExistMember-- Returns:
- Throws:
IllegalArgumentException- if conf has the field whose name is not contained in ServiceConfiguration and ignoreNonExistMember is false.RuntimeException
-
convertFrom
- Throws:
RuntimeException
-