-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e93670
commit d326851
Showing
10 changed files
with
131 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...e/core/runtime/src/main/java/org/apache/camel/quarkus/core/CamelQuarkusClassResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package org.apache.camel.quarkus.core; | ||
|
||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.util.Enumeration; | ||
|
||
import org.apache.camel.spi.ClassResolver; | ||
import org.apache.camel.util.CastUtils; | ||
import org.apache.camel.util.ObjectHelper; | ||
|
||
public class CamelQuarkusClassResolver implements ClassResolver { | ||
|
||
private final ClassLoader applicationContextClassLoader; | ||
|
||
public CamelQuarkusClassResolver(ClassLoader applicationContextClassLoader) { | ||
this.applicationContextClassLoader = applicationContextClassLoader; | ||
} | ||
|
||
@Override | ||
public Class<?> resolveClass(String name) { | ||
return loadClass(name, applicationContextClassLoader); | ||
} | ||
|
||
@Override | ||
public <T> Class<T> resolveClass(String name, Class<T> type) { | ||
return CastUtils.cast(loadClass(name, applicationContextClassLoader)); | ||
} | ||
|
||
@Override | ||
public Class<?> resolveClass(String name, ClassLoader loader) { | ||
return loadClass(name, loader); | ||
} | ||
|
||
@Override | ||
public <T> Class<T> resolveClass(String name, Class<T> type, ClassLoader loader) { | ||
return CastUtils.cast(loadClass(name, loader)); | ||
} | ||
|
||
@Override | ||
public Class<?> resolveMandatoryClass(String name) throws ClassNotFoundException { | ||
Class<?> answer = resolveClass(name); | ||
if (answer == null) { | ||
throw new ClassNotFoundException(name); | ||
} | ||
return answer; | ||
} | ||
|
||
@Override | ||
public <T> Class<T> resolveMandatoryClass(String name, Class<T> type) throws ClassNotFoundException { | ||
Class<T> answer = resolveClass(name, type); | ||
if (answer == null) { | ||
throw new ClassNotFoundException(name); | ||
} | ||
return answer; | ||
} | ||
|
||
@Override | ||
public Class<?> resolveMandatoryClass(String name, ClassLoader loader) throws ClassNotFoundException { | ||
Class<?> answer = resolveClass(name, loader); | ||
if (answer == null) { | ||
throw new ClassNotFoundException(name); | ||
} | ||
return answer; | ||
} | ||
|
||
@Override | ||
public <T> Class<T> resolveMandatoryClass(String name, Class<T> type, ClassLoader loader) throws ClassNotFoundException { | ||
Class<T> answer = resolveClass(name, type, loader); | ||
if (answer == null) { | ||
throw new ClassNotFoundException(name); | ||
} | ||
return answer; | ||
} | ||
|
||
@Override | ||
public InputStream loadResourceAsStream(String uri) { | ||
return ObjectHelper.loadResourceAsStream(uri, applicationContextClassLoader); | ||
} | ||
|
||
@Override | ||
public URL loadResourceAsURL(String uri) { | ||
return ObjectHelper.loadResourceAsURL(uri, applicationContextClassLoader); | ||
} | ||
|
||
@Override | ||
public Enumeration<URL> loadResourcesAsURL(String uri) { | ||
return loadAllResourcesAsURL(uri); | ||
} | ||
|
||
@Override | ||
public Enumeration<URL> loadAllResourcesAsURL(String uri) { | ||
return ObjectHelper.loadResourcesAsURL(uri); | ||
} | ||
|
||
protected Class<?> loadClass(String name, ClassLoader loader) { | ||
return ObjectHelper.loadClass(name, loader); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters