/** * Obtains an {@link Application} in this group with the given name. If * no such {@link Application} exists in the group, <code>null</code> will * be returned. If multiple {@link Application}s in the group have the * given name, an arbitary {@link Application} of the name will be returned * * @param name the name of the application to get * @return the application in this group with the given name or null * if no application has been realized with the given name */ public A getApplication(String name) { for (A application : applications) { if (application.getName().equals(name)) { return application; } } return null; }
@Override public void close() { if (isClosed.compareAndSet(false, true)) { for (A application : applications) { if (application != null) { try { application.close(); } catch (Exception e) { // skip: we always ignore } } } // now remove the applications applications.clear(); } }
for (LifecycleEventInterceptor<A> interceptor : application.getLifecycleInterceptors())
/** * Execute the application defined by the specified {@link SimpleApplicationSchema}. * * @param schema the {@link SimpleApplicationSchema} defining the application to execute */ protected void execute(SimpleApplicationSchema schema) { LocalPlatform platform = LocalPlatform.getInstance(); try (Application application = platform.realize("Vagrant", schema, new SystemApplicationConsole())) { application.waitFor(); } catch (Exception e) { throw new RuntimeException("Error executing Vagrant command", e); } }
/** * Obtains the {@link Application}s in this group where by their * {@link Application#getName()} starts with the specified prefix. * * @param prefix the prefix of application names to return * @return the application in this group with the given name or null * if no application has been realized with the given name */ public Iterable<A> getApplications(String prefix) { LinkedList<A> list = new LinkedList<A>(); for (A application : applications) { if (application.getName().startsWith(prefix)) { list.add(application); } } return list; }