On Tue, Oct 4, 2016 at 2:53 PM,  <[email protected]> wrote:
> +        public Set<Types.JobType> getJobTypes(Map<Object, Object> 
> properties) {
> +            Object types = properties.get(JobConsumer.JOB_TYPES);
> +            if (types instanceof String) {
> +                return Types.jobType(new String[]{(String) types});
> +
> +            } else if (types instanceof String[]) {
> +                return Types.jobType((String[]) types);
> +
> +            } else if (types instanceof Iterable) {
> +                List<String> l = new ArrayList<String>();
> +                for (Object o : (Iterable<?>) types) {
> +                    l.add(String.valueOf(o));
> +                }
> +                return Types.jobType((String[]) l.toArray(new 
> String[l.size()]));
> +            }
> +            throw new IllegalArgumentException("For the JobConsumer to work, 
> the job consumer must either " +
> +                    "implement a JobTypeValve or define a list of JobTypes, 
> neither were specified. " +
> +                    "Please check the implementation or OSGi configuration, 
> was expecting " +
> +                    JobConsumer.JOB_TYPES + " property to be set to a 
> String[]");
> +        }

Another way to avoid runtime dependency is inline just the
PropertiesUtils class. It does not have any dependency. That way you
get to do code reuse and avoid runtime dependency. See [1] for example

<Embed-Dependency>
org.apache.sling.commons.osgi;inline=
org/apache/sling/commons/osgi/PropertiesUtil*.class
</Embed-Dependency>

Chetan Mehrotra
[1] https://github.com/apache/felix/blob/trunk/jaas/pom.xml#L115

Reply via email to