Repository: brooklyn-server
Updated Branches:
  refs/heads/master 0947608d0 -> 774d75e78


Delete support for `--app <groovy-file>` 

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/432c3bbe
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/432c3bbe
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/432c3bbe

Branch: refs/heads/master
Commit: 432c3bbe456ea54669747d4b6a47b1b260399c23
Parents: 15447e1
Author: Aled Sage <[email protected]>
Authored: Mon May 15 19:54:43 2017 +0100
Committer: Aled Sage <[email protected]>
Committed: Mon May 15 19:55:20 2017 +0100

----------------------------------------------------------------------
 .../brooklyn/launcher/common/BasicLauncher.java | 23 -------------
 .../main/java/org/apache/brooklyn/cli/Main.java | 34 ++++++--------------
 .../java/org/apache/brooklyn/cli/CliTest.java   |  8 -----
 .../src/test/resources/ExampleAppInFile.groovy  | 22 -------------
 4 files changed, 10 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/432c3bbe/launcher-common/src/main/java/org/apache/brooklyn/launcher/common/BasicLauncher.java
----------------------------------------------------------------------
diff --git 
a/launcher-common/src/main/java/org/apache/brooklyn/launcher/common/BasicLauncher.java
 
b/launcher-common/src/main/java/org/apache/brooklyn/launcher/common/BasicLauncher.java
index 2a7a924..12f6833 100644
--- 
a/launcher-common/src/main/java/org/apache/brooklyn/launcher/common/BasicLauncher.java
+++ 
b/launcher-common/src/main/java/org/apache/brooklyn/launcher/common/BasicLauncher.java
@@ -105,7 +105,6 @@ public class BasicLauncher<T extends BasicLauncher<T>> {
     private final List<String> locationSpecs = new ArrayList<String>();
     private final List<Location> locations = new ArrayList<Location>();
 
-    private final List<Application> appsToManage = new 
ArrayList<Application>();
     @SuppressWarnings("deprecation") // TODO convert to EntitySpec; should be 
easy when users not allowed to pass in a builder
     private final 
List<org.apache.brooklyn.core.entity.factory.ApplicationBuilder> 
appBuildersToManage = new 
ArrayList<org.apache.brooklyn.core.entity.factory.ApplicationBuilder>();
     private final List<String> yamlAppsToManage = new ArrayList<String>();
@@ -144,24 +143,6 @@ public class BasicLauncher<T extends BasicLauncher<T>> {
     }
 
     /** 
-     * Specifies that the launcher should manage the given Brooklyn 
application.
-     * The application must not yet be managed. 
-     * The application will not be started as part of this call (callers can
-     * subsequently call {@link #start()} or {@link #getApplications()}.
-     * 
-     * @see #application(ApplicationBuilder)
-     * 
-     * @deprecated since 0.9.0; instead use {@link #application(String)} for 
YAML apps, or {@link #application(EntitySpec)}.
-     *             Note that apps are now auto-managed on construction through 
EntitySpec/YAML.
-     */
-    @Deprecated
-    public T application(Application app) {
-        if (Entities.isManaged(app)) throw new 
IllegalArgumentException("Application must not already be managed");
-        appsToManage.add(checkNotNull(app, "app"));
-        return self();
-    }
-
-    /** 
      * Specifies that the launcher should build and manage the given Brooklyn 
application.
      * The application must not yet be managed. 
      * The application will not be started as part of this call (callers can
@@ -677,10 +658,6 @@ public class BasicLauncher<T extends BasicLauncher<T>> {
             StartableApplication app = appBuilder.manage(managementContext);
             apps.add(app);
         }
-        for (Application app : appsToManage) {
-            Entities.startManagement(app, managementContext);
-            apps.add(app);
-        }
         for (String blueprint : yamlAppsToManage) {
             Application app = 
EntityManagementUtils.createUnstarted(managementContext, blueprint);
             // Note: BrooklynAssemblyTemplateInstantiator automatically puts 
applications under management.

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/432c3bbe/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java
----------------------------------------------------------------------
diff --git a/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java 
b/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java
index 4634f7d..41c7e28 100644
--- a/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java
+++ b/server-cli/src/main/java/org/apache/brooklyn/cli/Main.java
@@ -61,6 +61,7 @@ import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.StartableApplication;
 import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
 import org.apache.brooklyn.core.entity.trait.Startable;
+import org.apache.brooklyn.core.mgmt.ShutdownHandler;
 import org.apache.brooklyn.core.mgmt.ha.OsgiManager;
 import org.apache.brooklyn.core.mgmt.persist.BrooklynPersistenceUtils;
 import org.apache.brooklyn.core.mgmt.persist.PersistMode;
@@ -70,7 +71,6 @@ import org.apache.brooklyn.launcher.BrooklynLauncher;
 import org.apache.brooklyn.launcher.BrooklynServerDetails;
 import org.apache.brooklyn.launcher.config.StopWhichAppsOnShutdown;
 import org.apache.brooklyn.rest.security.PasswordHasher;
-import org.apache.brooklyn.core.mgmt.ShutdownHandler;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.exceptions.FatalConfigurationRuntimeException;
@@ -207,8 +207,8 @@ public class Main extends AbstractMain {
 
         @Option(name = { "-a", "--app" }, title = "application class or file",
                 description = "The Application to start. " +
-                        "For example, my.AppName, file://my/app.yaml, or 
classpath://my/AppName.groovy " 
-                        + "(but passing groovy scripts is deprecated) -- note 
that a BROOKLYN_CLASSPATH "
+                        "For example, my.AppName or file://my/app.yaml" 
+                        + " -- note that a BROOKLYN_CLASSPATH "
                         + "environment variable may be required to load 
classes from other locations")
         public String app;
 
@@ -683,14 +683,8 @@ public class Main extends AbstractMain {
                     String content = utils.getResourceAsString(app);
                     launcher.application(content);
                 } else {
-                    Object loadedApp = 
loadApplicationFromClasspathOrParse(utils, loader, app);
-                    if (loadedApp instanceof ApplicationBuilder) {
-                        launcher.application((ApplicationBuilder)loadedApp);
-                    } else if (loadedApp instanceof Application) {
-                        launcher.application((AbstractApplication)loadedApp);
-                    } else {
-                        throw new 
FatalConfigurationRuntimeException("Unexpected application type 
"+(loadedApp==null ? null : loadedApp.getClass())+", for app "+loadedApp);
-                    }
+                    ApplicationBuilder loadedApp = 
loadApplicationFromClasspathOrParse(utils, loader, app);
+                    launcher.application(loadedApp);
                 }
             }
         }
@@ -741,7 +735,7 @@ public class Main extends AbstractMain {
          * Guaranteed to be non-null result of one of those types (throwing 
exception if app not appropriate).
          */
         @SuppressWarnings("unchecked")
-        protected Object loadApplicationFromClasspathOrParse(ResourceUtils 
utils, GroovyClassLoader loader, String app)
+        protected ApplicationBuilder 
loadApplicationFromClasspathOrParse(ResourceUtils utils, GroovyClassLoader 
loader, String app)
                 throws NoSuchMethodException, InvocationTargetException, 
IllegalAccessException, InstantiationException {
             
             Class<?> tempclazz;
@@ -749,17 +743,15 @@ public class Main extends AbstractMain {
             try {
                 tempclazz = loader.loadClass(app, true, false);
             } catch (ClassNotFoundException cnfe) { // Not a class on the 
classpath
-                log.debug("Loading \"{}\" as class on classpath failed, now 
trying as .groovy source file", app);
-                String content = utils.getResourceAsString(app);
-                tempclazz = loader.parseClass(content);
-                log.warn("Use of --app with a groovy source file is 
deprecated");
+                throw new IllegalStateException("Unable to load app class 
'"+app+"'", cnfe);
             }
             final Class<?> clazz = tempclazz;
             
-            // Instantiate an app builder (wrapping app class in 
ApplicationBuilder, if necessary)
+            // Instantiate an app builder (wrapping app/entity class in 
ApplicationBuilder)
+            // TODO Should change to use EntitySpec
             if (ApplicationBuilder.class.isAssignableFrom(clazz)) {
                 Constructor<?> constructor = clazz.getConstructor();
-                return constructor.newInstance();
+                return (ApplicationBuilder) constructor.newInstance();
             } else if (StartableApplication.class.isAssignableFrom(clazz)) {
                 EntitySpec<? extends StartableApplication> appSpec;
                 if (tempclazz.isInterface())
@@ -769,12 +761,6 @@ public class Main extends AbstractMain {
                 return new ApplicationBuilder(appSpec) {
                     @Override protected void doBuild() {
                     }};
-            } else if (AbstractApplication.class.isAssignableFrom(clazz)) {
-                // TODO If this application overrides init() then in trouble, 
as that won't get called!
-                // TODO grr; what to do about non-startable applications?
-                // without this we could return ApplicationBuilder rather than 
Object
-                Constructor<?> constructor = clazz.getConstructor();
-                return constructor.newInstance();
             } else if (AbstractEntity.class.isAssignableFrom(clazz)) {
                 // TODO Should we really accept any entity type, and just wrap 
it in an app? That's not documented!
                 return new ApplicationBuilder() {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/432c3bbe/server-cli/src/test/java/org/apache/brooklyn/cli/CliTest.java
----------------------------------------------------------------------
diff --git a/server-cli/src/test/java/org/apache/brooklyn/cli/CliTest.java 
b/server-cli/src/test/java/org/apache/brooklyn/cli/CliTest.java
index c85af6e..94d0742 100644
--- a/server-cli/src/test/java/org/apache/brooklyn/cli/CliTest.java
+++ b/server-cli/src/test/java/org/apache/brooklyn/cli/CliTest.java
@@ -172,14 +172,6 @@ public class CliTest {
         assertTrue(Iterables.getOnlyElement(entities) instanceof EntityProxy, 
"entities="+entities);
     }
 
-    @Test
-    public void testLoadApplicationByParsingGroovyFile() throws Exception {
-        String appName = "ExampleAppInFile.groovy"; // file found in 
src/test/resources (contains empty app)
-        Object appBuilder = loadApplicationFromClasspathOrParse(appName);
-        assertTrue(appBuilder instanceof ApplicationBuilder, 
"app="+appBuilder);
-        assertAppWrappedInBuilder((ApplicationBuilder)appBuilder, 
"ExampleAppInFile");
-    }
-    
     private Object loadApplicationFromClasspathOrParse(String appName) throws 
Exception {
         LaunchCommand launchCommand = new Main.LaunchCommand();
         ResourceUtils resourceUtils = ResourceUtils.create(this);

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/432c3bbe/server-cli/src/test/resources/ExampleAppInFile.groovy
----------------------------------------------------------------------
diff --git a/server-cli/src/test/resources/ExampleAppInFile.groovy 
b/server-cli/src/test/resources/ExampleAppInFile.groovy
deleted file mode 100644
index 813f22e..0000000
--- a/server-cli/src/test/resources/ExampleAppInFile.groovy
+++ /dev/null
@@ -1,22 +0,0 @@
-import org.apache.brooklyn.core.entity.AbstractApplication
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-class ExampleAppInFile extends AbstractApplication { }

Reply via email to