@@ -0,0 +1,2132 @@
+package org.rocket.dist;%0A%0Aimport com.google.inject.Module;%0Aimport com.typesafe.config.Config;%0Aimport com.typesafe.config.ConfigFactory;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0Aimport java.net.URL;%0Aimport java.net.URLClassLoader;%0Aimport java.util.jar.Attributes;%0Aimport java.util.jar.JarEntry;%0Aimport java.util.jar.JarFile;%0A%0A/**%0A * JarRocket loads resource from a JAR file.%0A */%0Apublic class JarRocket extends Rocket %7B%0A    private final JarFile file;%0A%0A    public JarRocket(JarFile file) %7B%0A        this.file = file;%0A    %7D%0A%0A    @Override%0A    public Config getConfig() %7B%0A        try %7B%0A            JarEntry entry = file.getJarEntry(%22application.conf%22);%0A            InputStream is = file.getInputStream(entry);%0A            return ConfigFactory.parseReader(new InputStreamReader(is));%0A        %7D catch (IOException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public Module getModule() %7B%0A        try %7B%0A            URLClassLoader loader = new URLClassLoader(new URL%5B%5D%7B%0A                    new URL(file.getName())%7D);%0A%0A            Attributes main = file.getManifest().getMainAttributes();%0A            String moduleClassName = (String) main.get(%22Module-Class%22);%0A%0A            Class%3C?%3E moduleClass = loader.loadClass(moduleClassName);%0A            if (!Module.class.isAssignableFrom(moduleClass)) %7B%0A                throw new IllegalStateException(String.format(%0A                    %22%25s from %25s is not a module%22,%0A                        moduleClass,%0A                        file.getName()));%0A            %7D%0A%0A            return (Module) moduleClass.newInstance();%0A        %7D catch (IOException e) %7B%0A            throw new RuntimeException(e);%0A        %7D catch (ClassNotFoundException e) %7B%0A            throw new IllegalStateException(String.format(%0A                %22Could not find module of %25s%22,%0A                    file.getName()));%0A        %7D catch (InstantiationException%7CIllegalAccessException e) %7B%0A            throw new IllegalStateException(String.format(%0A                %22Could not create module of %25s%22,%0A                    file.getName()));%0A        %7D%0A    %7D%0A%7D%0A

Create a Rocket loading its resources from a JAR file