private LimbusStaging(String deployName) { this.stage = new LimbusStage(); this.stage.setDeployName(deployName); }
/** * Grants a permission for the classpath of the deployment. * * @param permission * The permission to grant for the classpath. * @return Returns this object for method chainging. */ public LimbusStaging grantPermission(Permission permission) { stage.addPermission(permission); return this; }
private void addJavaArchiveAsURL(List<URL> urls, JavaArchive a, String archiveName) throws IOException, MalformedURLException { byte[] resource = archiveToBytes(a); String jarURLStr = null; if (Lang.isEmpty(archiveName)) { jarURLStr = createJarURL(a); } else { jarURLStr = createJarURL(archiveName); } URL jarURL = new URL(jarURLStr);// , resourceHandler); urls.add(jarURL); addResourceToStagingHandler(resource, jarURL); }
/** * Configures the {@link EngineLauncher} to start an embedded Limbus Environment. This instance of {@link LimbusStage} * needs to acquire exclusive access to the {@link EngineLauncher}. * * @throws Exception * Thrown on any bootstrapping error or if no exclusive access could be acquired. */ public void startStage() throws Exception { hasAccess = stageRunning.tryAcquire(); denyNoAccess(); EngineLauncher.skipSystemExit = true; try { EngineLauncher.bootstrapLimbusSystem(system); deploy(); } catch (Exception e) { stopStage(); throw e; } }
/** * Use this method to generate a dump of all dependencies of the current deployment. * * @return Returns this object for method chainging. */ public LimbusStaging dumpDeploymentDependencies() { List<JavaArchive> dependencies = stage.getDependencies(); if (dependencies.isEmpty()) { System.out.println("No deployment dependencies are defined yet."); } else { System.out.println("Printing out the deployment dependencies:"); for (JavaArchive d : dependencies) { System.out.printf("- Dependency %s\n", d.getName()); } } return this; }
/** * Grants a set of default permission for the classpath of the deployment. * * @return Returns this object for method chainging. */ public LimbusStaging grantDefaultPermissions() { stage.addAllPermission(getDefaultPermissions()); return this; }
private void deploy() throws LimbusException, IOException { LimbusEngine limbusEngine = system.getComponent(LimbusEngine.class); List<URL> urls = new LinkedList<>(); List<JavaArchive> archives = new LinkedList<>(dependencies); for (JavaArchive a : archives) { addJavaArchiveAsURL(urls, a, null); } addJavaArchiveAsURL(urls, deployment, null); this.classpath = Classpath.create(deployName) .add(urls); limbusEngine.deployPlugin(classpath, permissions); }
/** * Use this method to generate a dump of all files contained in the deployment's dependencies. The content of each * archive that is deployed to the Limbus Engine as a dependency of the plugin deployment is printed. * * @return Returns this object for method chainging. */ public LimbusStaging dumpDeploymentDependenciesContent() { List<JavaArchive> dependencies = stage.getDependencies(); if (dependencies.isEmpty()) { System.out.println("No deployment dependencies are defined yet."); } else { System.out.println("Printing out the deployment dependencies archive content:"); for (JavaArchive d : dependencies) { System.out.printf("Printing out the archive content of: %s\n", d.getName()); d.writeTo(System.out, Formatters.VERBOSE); } } return this; }