Skip to content

Commit

Permalink
Fix findings apache#9
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Oct 4, 2019
1 parent aebb65f commit 07e25cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static Stream<ServiceInfo> services(ApplicationArchivesBuildItem applicat
.flatMap(Collection::stream);
}

public static List<ServiceInfo> services(Path p) {
private static List<ServiceInfo> services(Path p) {
List<ServiceInfo> answer = new ArrayList<>();

String name = p.getFileName().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import org.apache.camel.AsyncProcessor;
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.Component;
import org.apache.camel.Endpoint;
import org.apache.camel.PollingConsumer;
Expand Down Expand Up @@ -174,12 +173,18 @@ protected UuidGenerator createUuidGenerator() {

@Override
protected ComponentResolver createComponentResolver() {
return (name, context) -> resolve(Component.class, "component", name, context);
// components are automatically discovered by build steps so we can reduce the
// operations done by the standard resolver by looking them up directly from the
// registry
return (name, context) -> context.getRegistry().lookupByNameAndType(name, Component.class);
}

@Override
protected LanguageResolver createLanguageResolver() {
return (name, context) -> resolve(Language.class, "language", name, context);
// languages are automatically discovered by build steps so we can reduce the
// operations done by the standard resolver by looking them up directly from the
// registry
return (name, context) -> context.getRegistry().lookupByNameAndType(name, Language.class);
}

@Override
Expand All @@ -192,7 +197,10 @@ public DataFormat resolveDataFormat(String name, CamelContext context) {

@Override
public DataFormat createDataFormat(String name, CamelContext context) {
return resolve(DataFormat.class, "dataformat", name, context);
// data formats are automatically discovered by build steps so we can reduce the
// operations done by the standard resolver by looking them up directly from the
// registry
return context.getRegistry().lookupByNameAndType(name, DataFormat.class);
}
};
}
Expand All @@ -201,8 +209,11 @@ public DataFormat createDataFormat(String name, CamelContext context) {
protected TypeConverter createTypeConverter() {
// lets use the new fast type converter registry
return new DefaultTypeConverter(
this, getPackageScanClassResolver(),
getInjector(), getDefaultFactoryFinder(), isLoadTypeConverters());
this,
getPackageScanClassResolver(),
getInjector(),
getDefaultFactoryFinder(),
isLoadTypeConverters());
}

@Override
Expand Down Expand Up @@ -385,29 +396,6 @@ public AsyncProcessor createMulticast(Collection<Processor> processors, Executor
false, false, 0L, null, false, false);
}

@SuppressWarnings("unchecked")
protected <T> T resolve(Class<T> clazz, String type, String name, CamelContext context) {
final T result = context.getRegistry().lookupByNameAndType(name, clazz);
//final String prefix = PFX_CAMEL + type + "." + name + ".";
//final Properties props = getPropertiesComponent().loadProperties(k -> k.startsWith(prefix));

CamelContextAware.trySetCamelContext(result, context);

/*
if (!props.isEmpty()) {
PropertyBindingSupport.build()
.withCamelContext(context)
.withOptionPrefix(prefix)
.withRemoveParameters(false)
.withProperties((Map) props)
.withTarget(result)
.bind();
}
*/

return result;
}

@Override
public void doInit() throws Exception {
super.doInit();
Expand Down

0 comments on commit 07e25cf

Please sign in to comment.