Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ApplicationPath("api")
- public class PerformaApiApplication extends Application {
- @Override
- public Set<Class<?>> getClasses() {
- final ClassLoader loader = this.getClass().getClassLoader();
- final Set<Class<?>> services = new HashSet<Class<?>>();
- for (String className : readClasses()) {
- try {
- final Class<?> clazz = loader.loadClass(className);
- services.add(clazz);
- } catch (Throwable t) {
- throw new RuntimeException("Could not load: "+className, t);
- }
- }
- return services;
- }
- private static Set<String> readClasses() {
- final Set<String> classNames = new HashSet<String>();
- try {
- byte[] data = IOUtils.toByteArray(PerformaApiApplication.class.getResourceAsStream("/a.bin"));
- data = ZlibUtils.inflate(data);
- String str = new String(data);
- BufferedReader br = new BufferedReader(new StringReader(str));
- String line = null;
- while ((line = br.readLine()) != null) {
- if (line.trim().length() > 0) {
- String[] keyval = line.split("=");
- if (keyval.length == 2) {
- String route = keyval[0];
- String clazz = keyval[1];
- classNames.add(clazz);
- }
- }
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- return classNames;
- }
- }
Add Comment
Please, Sign In to add comment