application.configure(configurer, new DefaultApplicationContext<>(configObject)); String applicationId = configurer.getName(); return new RemoteApplicationManager(namespace.app(applicationId), clientConfig, restClient);
new CombineClassLoader(null, app.getClass().getClassLoader(), getClass().getClassLoader())); try { app.configure(configurer, new DefaultApplicationContext<>(appConfig)); } finally { ClassLoaders.setContextClassLoader(oldClassLoader);
@Override public ApplicationManager deployApplication(NamespaceId namespace, Class<? extends Application> applicationClz, @Nullable Config configObject, File... bundleEmbeddedJars) { Preconditions.checkNotNull(applicationClz, "Application class cannot be null."); Type configType = Artifacts.getConfigType(applicationClz); try { ArtifactId artifactId = new ArtifactId(namespace.getNamespace(), applicationClz.getSimpleName(), "1.0-SNAPSHOT"); addAppArtifact(artifactId, applicationClz, new Manifest(), bundleEmbeddedJars); if (configObject == null) { configObject = (Config) TypeToken.of(configType).getRawType().newInstance(); } Application app = applicationClz.newInstance(); MockAppConfigurer configurer = new MockAppConfigurer(app); app.configure(configurer, new DefaultApplicationContext<>(configObject)); ApplicationId applicationId = new ApplicationId(namespace.getNamespace(), configurer.getName()); ArtifactSummary artifactSummary = new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()); appFabricClient.deployApplication(Id.Application.fromEntityId(applicationId), new AppRequest(artifactSummary, configObject)); return appManagerFactory.create(applicationId); } catch (Exception e) { throw Throwables.propagate(e); } }
@Override public ApplicationManager deployApplication(NamespaceId namespace, Class<? extends Application> applicationClz, @Nullable Config configObject, File... bundleEmbeddedJars) { Preconditions.checkNotNull(applicationClz, "Application class cannot be null."); Type configType = Artifacts.getConfigType(applicationClz); try { ArtifactId artifactId = new ArtifactId(namespace.getNamespace(), applicationClz.getSimpleName(), "1.0-SNAPSHOT"); addAppArtifact(artifactId, applicationClz, new Manifest(), bundleEmbeddedJars); if (configObject == null) { configObject = (Config) TypeToken.of(configType).getRawType().newInstance(); } Application app = applicationClz.newInstance(); MockAppConfigurer configurer = new MockAppConfigurer(app); app.configure(configurer, new DefaultApplicationContext<>(configObject)); ApplicationId applicationId = new ApplicationId(namespace.getNamespace(), configurer.getName()); ArtifactSummary artifactSummary = new ArtifactSummary(artifactId.getArtifact(), artifactId.getVersion()); appFabricClient.deployApplication(Id.Application.fromEntityId(applicationId), new AppRequest(artifactSummary, configObject)); return appManagerFactory.create(applicationId); } catch (Exception e) { throw Throwables.propagate(e); } }
new CombineClassLoader(null, app.getClass().getClassLoader(), getClass().getClassLoader())); try { app.configure(configurer, new DefaultApplicationContext<>(appConfig)); } finally { ClassLoaders.setContextClassLoader(oldClassLoader);
public static ApplicationSpecification from(Application app) { DefaultAppConfigurer appConfigurer = new DefaultAppConfigurer(Id.Namespace.fromEntityId(DefaultId.NAMESPACE), Id.Artifact.fromEntityId(DefaultId.ARTIFACT), app); app.configure(appConfigurer, new DefaultApplicationContext()); return appConfigurer.createSpecification(null); } }