Delete EntityFactory
diff --git a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.java b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.java
index 4e55780..4b3a46e 100644
--- a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.java
+++ b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppCluster.java
@@ -27,7 +27,6 @@
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.ConfigKeys;
import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.factory.ConfigurableEntityFactory;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.trait.MemberReplaceable;
import org.apache.brooklyn.core.entity.trait.Resizable;
@@ -78,12 +77,6 @@
public static BasicAttributeSensorAndConfigKey<EntitySpec<? extends LoadBalancer>> CONTROLLER_SPEC = new BasicAttributeSensorAndConfigKey(
EntitySpec.class, "controlleddynamicwebappcluster.controllerSpec", "Spec for creating the controller (if one not supplied explicitly); if null an NGINX instance will be created");
- @SuppressWarnings({ "unchecked", "rawtypes", "deprecation" })
- /** factory (or closure) to create the web server, given flags */
- @SetFromFlag("factory")
- public static BasicAttributeSensorAndConfigKey<ConfigurableEntityFactory<? extends WebAppService>> FACTORY = new BasicAttributeSensorAndConfigKey(
- ConfigurableEntityFactory.class, DynamicCluster.FACTORY.getName(), "factory (or closure) to create the web server");
-
@SuppressWarnings({ "unchecked", "rawtypes" })
/** Spec for web server entiites to be created */
@SetFromFlag("memberSpec")
@@ -105,8 +98,6 @@
public LoadBalancer getController();
- public ConfigurableEntityFactory<WebAppService> getFactory();
-
public DynamicWebAppCluster getCluster();
public Group getControlledGroup();
diff --git a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java
index 6ac61ce..dd658e0 100644
--- a/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java
+++ b/software/webapp/src/main/java/org/apache/brooklyn/entity/webapp/ControlledDynamicWebAppClusterImpl.java
@@ -32,7 +32,6 @@
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.entity.EntityPredicates;
-import org.apache.brooklyn.core.entity.factory.ConfigurableEntityFactory;
import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
import org.apache.brooklyn.core.entity.trait.Startable;
@@ -79,16 +78,14 @@
public void init() {
super.init();
- ConfigToAttributes.apply(this, FACTORY);
ConfigToAttributes.apply(this, MEMBER_SPEC);
ConfigToAttributes.apply(this, CONTROLLER);
ConfigToAttributes.apply(this, CONTROLLER_SPEC);
ConfigToAttributes.apply(this, WEB_CLUSTER_SPEC);
ConfigToAttributes.apply(this, CONTROLLED_GROUP);
- ConfigurableEntityFactory<? extends WebAppService> webServerFactory = getAttribute(FACTORY);
EntitySpec<? extends WebAppService> webServerSpec = getAttribute(MEMBER_SPEC);
- if (webServerFactory == null && webServerSpec == null) {
+ if (webServerSpec == null) {
log.debug("creating default web server spec for {}", this);
webServerSpec = EntitySpec.create(TomcatServer.class);
sensors().set(MEMBER_SPEC, webServerSpec);
@@ -97,20 +94,14 @@
log.debug("creating cluster child for {}", this);
// Note relies on initial_size being inherited by DynamicWebAppCluster, because key id is identical
EntitySpec<? extends DynamicWebAppCluster> webClusterSpec = getAttribute(WEB_CLUSTER_SPEC);
- Map<String,Object> webClusterFlags;
- if (webServerSpec != null) {
- webClusterFlags = MutableMap.<String,Object>of("memberSpec", webServerSpec);
- } else {
- webClusterFlags = MutableMap.<String,Object>of("factory", webServerFactory);
- }
+ Map<String,Object> webClusterFlags = MutableMap.<String,Object>of("memberSpec", webServerSpec);
+
if (webClusterSpec == null) {
log.debug("creating default web cluster spec for {}", this);
webClusterSpec = EntitySpec.create(DynamicWebAppCluster.class);
}
boolean hasMemberSpec = webClusterSpec.getConfig().containsKey(DynamicWebAppCluster.MEMBER_SPEC) || webClusterSpec.getFlags().containsKey("memberSpec");
- @SuppressWarnings("deprecation")
- boolean hasMemberFactory = webClusterSpec.getConfig().containsKey(DynamicWebAppCluster.FACTORY) || webClusterSpec.getFlags().containsKey("factory");
- if (!(hasMemberSpec || hasMemberFactory)) {
+ if (!hasMemberSpec) {
webClusterSpec.configure(webClusterFlags);
} else {
log.warn("In {}, not setting cluster's {} because already set on webClusterSpec", new Object[] {this, webClusterFlags.keySet()});
@@ -182,12 +173,6 @@
return getAttribute(CONTROLLER);
}
- @SuppressWarnings("unchecked")
- @Override
- public ConfigurableEntityFactory<WebAppService> getFactory() {
- return (ConfigurableEntityFactory<WebAppService>) getAttribute(FACTORY);
- }
-
// TODO convert to an entity reference which is serializable
@Override
public DynamicWebAppCluster getCluster() {
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java
index 831df4c..94221c4 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/AbstractControllerTest.java
@@ -40,9 +40,9 @@
import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.EntityAsserts;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
import org.apache.brooklyn.core.entity.trait.Startable;
import org.apache.brooklyn.core.location.HasSubnetHostname;
+import org.apache.brooklyn.core.location.Machines;
import org.apache.brooklyn.core.location.PortRanges;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
import org.apache.brooklyn.core.test.entity.TestEntity;
@@ -56,6 +56,7 @@
import org.apache.brooklyn.util.collections.MutableSet;
import org.apache.brooklyn.util.core.flags.SetFromFlag;
import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.guava.Maybe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeMethod;
@@ -80,7 +81,7 @@
super.setUp();
List<SshMachineLocation> machines = new ArrayList<SshMachineLocation>();
- for (int i=1; i<=10; i++) {
+ for (int i = 1; i <= 10; i++) {
SshMachineLocation machine = mgmt.getLocationManager().createLocation(LocationSpec.create(SshMachineLocation.class)
.configure("address", Inet4Address.getByName("1.1.1."+i)));
machines.add(machine);
@@ -88,13 +89,13 @@
loc = mgmt.getLocationManager().createLocation(LocationSpec.create(FixedListMachineProvisioningLocation.class)
.configure("machines", machines));
- cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
+ cluster = app.addChild(EntitySpec.create(DynamicCluster.class)
.configure("initialSize", 0)
- .configure("factory", new ClusteredEntity.Factory()));
+ .configure("memberSpec", EntitySpec.create(TestEntity.class).impl(WebServerEntity.class)));
- controller = app.createAndManageChild(EntitySpec.create(TrackingAbstractController.class)
+ controller = app.addChild(EntitySpec.create(TrackingAbstractController.class)
.configure("serverPool", cluster)
- .configure("portNumberSensor", ClusteredEntity.HTTP_PORT)
+ .configure("portNumberSensor", WebServerEntity.HTTP_PORT)
.configure("domain", "mydomain"));
app.start(ImmutableList.of(loc));
@@ -117,9 +118,9 @@
// above may trigger error logged about no hostname, but should update again with the settings below
log.info("setting mymachine:1234");
- child.sensors().set(ClusteredEntity.HOSTNAME, "mymachine");
+ child.sensors().set(WebServerEntity.HOSTNAME, "mymachine");
child.sensors().set(Attributes.SUBNET_HOSTNAME, "mymachine");
- child.sensors().set(ClusteredEntity.HTTP_PORT, 1234);
+ child.sensors().set(WebServerEntity.HTTP_PORT, 1234);
assertEventuallyExplicitAddressesMatch(ImmutableList.of("mymachine:1234"));
/* a race failure has been observed, https://issues.apache.org/jira/browse/BROOKLYN-206
@@ -137,16 +138,16 @@
*/
log.info("setting mymachine2:1234");
- child.sensors().set(ClusteredEntity.HOSTNAME, "mymachine2");
+ child.sensors().set(WebServerEntity.HOSTNAME, "mymachine2");
child.sensors().set(Attributes.SUBNET_HOSTNAME, "mymachine2");
assertEventuallyExplicitAddressesMatch(ImmutableList.of("mymachine2:1234"));
log.info("setting mymachine2:1235");
- child.sensors().set(ClusteredEntity.HTTP_PORT, 1235);
+ child.sensors().set(WebServerEntity.HTTP_PORT, 1235);
assertEventuallyExplicitAddressesMatch(ImmutableList.of("mymachine2:1235"));
log.info("clearing");
- child.sensors().set(ClusteredEntity.HOSTNAME, null);
+ child.sensors().set(WebServerEntity.HOSTNAME, null);
child.sensors().set(Attributes.SUBNET_HOSTNAME, null);
assertEventuallyExplicitAddressesMatch(ImmutableList.<String>of());
}
@@ -160,7 +161,7 @@
List<Collection<String>> u = Lists.newArrayList(controller.getUpdates());
assertTrue(u.isEmpty(), "expected empty list but got "+u);
- child.sensors().set(ClusteredEntity.HTTP_PORT, 1234);
+ child.sensors().set(WebServerEntity.HTTP_PORT, 1234);
child.sensors().set(Startable.SERVICE_UP, true);
assertEventuallyAddressesMatchCluster();
@@ -173,7 +174,7 @@
}});
Entity child2 = Iterables.getOnlyElement(MutableSet.<Entity>builder().addAll(cluster.getMembers()).remove(child).build());
- child2.sensors().set(ClusteredEntity.HTTP_PORT, 1234);
+ child2.sensors().set(WebServerEntity.HTTP_PORT, 1234);
child2.sensors().set(Startable.SERVICE_UP, true);
assertEventuallyAddressesMatchCluster();
@@ -192,7 +193,7 @@
// Get some children, so we can remove one...
cluster.resize(2);
for (Entity it: cluster.getMembers()) {
- it.sensors().set(ClusteredEntity.HTTP_PORT, 1234);
+ it.sensors().set(WebServerEntity.HTTP_PORT, 1234);
it.sensors().set(Startable.SERVICE_UP, true);
}
assertEventuallyAddressesMatchCluster();
@@ -208,7 +209,7 @@
// Get some children, so we can remove one...
cluster.resize(2);
for (Entity it: cluster.getMembers()) {
- it.sensors().set(ClusteredEntity.HTTP_PORT, 1234);
+ it.sensors().set(WebServerEntity.HTTP_PORT, 1234);
it.sensors().set(Startable.SERVICE_UP, true);
}
assertEventuallyAddressesMatchCluster();
@@ -216,8 +217,8 @@
// Now unset host/port, and remove children
// Note the unsetting of hostname is done in SoftwareProcessImpl.stop(), so this is realistic
for (Entity it : cluster.getMembers()) {
- it.sensors().set(ClusteredEntity.HTTP_PORT, null);
- it.sensors().set(ClusteredEntity.HOSTNAME, null);
+ it.sensors().set(WebServerEntity.HTTP_PORT, null);
+ it.sensors().set(WebServerEntity.HOSTNAME, null);
it.sensors().set(Startable.SERVICE_UP, false);
}
assertEventuallyAddressesMatch(ImmutableList.<Entity>of());
@@ -227,7 +228,7 @@
public void testUsesHostAndPortSensor() throws Exception {
controller = app.createAndManageChild(EntitySpec.create(TrackingAbstractController.class)
.configure("serverPool", cluster)
- .configure("hostAndPortSensor", ClusteredEntity.HOST_AND_PORT)
+ .configure("hostAndPortSensor", WebServerEntity.HOST_AND_PORT)
.configure("domain", "mydomain"));
controller.start(Arrays.asList(loc));
@@ -242,7 +243,7 @@
// TODO Ugly sleep to allow AbstractController to detect node having been added
Thread.sleep(100);
- child.sensors().set(ClusteredEntity.HOST_AND_PORT, "mymachine:1234");
+ child.sensors().set(WebServerEntity.HOST_AND_PORT, "mymachine:1234");
assertEventuallyExplicitAddressesMatch(ImmutableList.of("mymachine:1234"));
}
@@ -251,8 +252,8 @@
try {
TrackingAbstractController controller2 = app.createAndManageChild(EntitySpec.create(TrackingAbstractController.class)
.configure("serverPool", cluster)
- .configure("hostAndPortSensor", ClusteredEntity.HOST_AND_PORT)
- .configure("hostnameSensor", ClusteredEntity.HOSTNAME)
+ .configure("hostAndPortSensor", WebServerEntity.HOST_AND_PORT)
+ .configure("hostnameSensor", WebServerEntity.HOSTNAME)
.configure("domain", "mydomain"));
controller2.start(Arrays.asList(loc));
} catch (Exception e) {
@@ -267,8 +268,8 @@
try {
TrackingAbstractController controller3 = app.createAndManageChild(EntitySpec.create(TrackingAbstractController.class)
.configure("serverPool", cluster)
- .configure("hostAndPortSensor", ClusteredEntity.HOST_AND_PORT)
- .configure("portNumberSensor", ClusteredEntity.HTTP_PORT)
+ .configure("hostAndPortSensor", WebServerEntity.HOST_AND_PORT)
+ .configure("portNumberSensor", WebServerEntity.HTTP_PORT)
.configure("domain", "mydomain"));
controller3.start(Arrays.asList(loc));
} catch (Exception e) {
@@ -347,14 +348,14 @@
}
private void assertEventuallyAddressesMatch(final Collection<Entity> expectedMembers) {
- Asserts.succeedsEventually(MutableMap.of("timeout", 15000), new Runnable() {
+ Asserts.succeedsEventually(new Runnable() {
@Override public void run() {
assertAddressesMatch(locationsToAddresses(1234, expectedMembers));
}} );
}
private void assertEventuallyExplicitAddressesMatch(final Collection<String> expectedAddresses) {
- Asserts.succeedsEventually(MutableMap.of("timeout", 15000), new Runnable() {
+ Asserts.succeedsEventually(new Runnable() {
@Override public void run() {
assertAddressesMatch(expectedAddresses);
}} );
@@ -371,24 +372,14 @@
private Collection<String> locationsToAddresses(int port, Collection<Entity> entities) {
Set<String> result = MutableSet.of();
- for (Entity e: entities) {
- result.add( ((SshMachineLocation) e.getLocations().iterator().next()) .getAddress().getHostName()+":"+port);
+ for (Entity e : entities) {
+ SshMachineLocation machine = Machines.findUniqueMachineLocation(e.getLocations(), SshMachineLocation.class).get();
+ result.add(machine.getAddress().getHostName()+":"+port);
}
return result;
}
- public static class ClusteredEntity extends TestEntityImpl {
- public static class Factory implements EntityFactory<ClusteredEntity> {
- @Override
- public ClusteredEntity newEntity(Map flags, Entity parent) {
- return new ClusteredEntity(flags, parent);
- }
- }
- public ClusteredEntity(Map flags, Entity parent) { super(flags,parent); }
- public ClusteredEntity(Entity parent) { super(MutableMap.of(),parent); }
- public ClusteredEntity(Map flags) { super(flags,null); }
- public ClusteredEntity() { super(MutableMap.of(),null); }
-
+ public static class WebServerEntity extends TestEntityImpl {
@SetFromFlag("hostname")
public static final AttributeSensor<String> HOSTNAME = Attributes.HOSTNAME;
@@ -400,6 +391,7 @@
MachineProvisioningLocation<MachineLocation> provisioner;
+ @Override
public void start(Collection<? extends Location> locs) {
provisioner = (MachineProvisioningLocation<MachineLocation>) locs.iterator().next();
MachineLocation machine;
@@ -414,8 +406,13 @@
sensors().set(Attributes.MAIN_URI_MAPPED_SUBNET, URI.create(machine.getAddress().getHostName()));
sensors().set(Attributes.MAIN_URI_MAPPED_PUBLIC, URI.create("http://8.8.8.8:" + sensors().get(HTTP_PORT)));
}
+
+ @Override
public void stop() {
- if (provisioner!=null) provisioner.release((MachineLocation) firstLocation());
+ Maybe<MachineLocation> machine = Machines.findUniqueMachineLocation(getLocations(), MachineLocation.class);
+ if (provisioner != null) {
+ provisioner.release(machine.get());
+ }
}
}
}
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/StubAppServer.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/StubAppServer.java
index 7d18021..717c5d9 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/StubAppServer.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/StubAppServer.java
@@ -18,69 +18,15 @@
*/
package org.apache.brooklyn.entity.proxy;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.location.MachineLocation;
-import org.apache.brooklyn.api.location.MachineProvisioningLocation;
-import org.apache.brooklyn.api.location.NoMachinesAvailableException;
+import org.apache.brooklyn.api.entity.ImplementedBy;
import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.core.entity.AbstractEntity;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.trait.Startable;
import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
-import org.apache.brooklyn.util.collections.MutableMap;
-import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-public class StubAppServer extends AbstractEntity implements Startable {
+@ImplementedBy(StubAppServerImpl.class)
+public interface StubAppServer extends Entity, Startable {
public static final AttributeSensor<String> HOSTNAME = Attributes.HOSTNAME;
public static final PortAttributeSensorAndConfigKey HTTP_PORT = Attributes.HTTP_PORT;
- public static AtomicInteger nextPort = new AtomicInteger(1234);
-
- public StubAppServer(Map flags) {
- super(flags);
- }
-
- public StubAppServer(Map flags, Entity parent) {
- super(flags, parent);
- }
-
- @Override
- public void start(Collection<? extends Location> locations) {
- Location location = Iterables.getOnlyElement(locations);
- if (location instanceof MachineProvisioningLocation) {
- startInLocation((MachineProvisioningLocation)location);
- } else {
- startInLocation((MachineLocation)location);
- }
- }
-
- private void startInLocation(MachineProvisioningLocation loc) {
- try {
- startInLocation(loc.obtain(MutableMap.of()));
- } catch (NoMachinesAvailableException e) {
- throw Throwables.propagate(e);
- }
- }
-
- private void startInLocation(MachineLocation loc) {
- addLocations(ImmutableList.of((Location)loc));
- sensors().set(HOSTNAME, loc.getAddress().getHostName());
- sensors().set(HTTP_PORT, nextPort.getAndIncrement());
- sensors().set(SERVICE_UP, true);
- }
-
- public void stop() {
- sensors().set(SERVICE_UP, false);
- }
-
- @Override
- public void restart() {
- }
-}
\ No newline at end of file
+}
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/StubAppServerImpl.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/StubAppServerImpl.java
new file mode 100644
index 0000000..7a51432
--- /dev/null
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/StubAppServerImpl.java
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+package org.apache.brooklyn.entity.proxy;
+
+import java.util.Collection;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.api.location.MachineLocation;
+import org.apache.brooklyn.api.location.MachineProvisioningLocation;
+import org.apache.brooklyn.api.location.NoMachinesAvailableException;
+import org.apache.brooklyn.core.entity.AbstractEntity;
+import org.apache.brooklyn.util.collections.MutableMap;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+public class StubAppServerImpl extends AbstractEntity implements StubAppServer {
+ public static AtomicInteger nextPort = new AtomicInteger(1234);
+
+ @Override
+ public void start(Collection<? extends Location> locations) {
+ Location location = Iterables.getOnlyElement(locations);
+ if (location instanceof MachineProvisioningLocation) {
+ startInLocation((MachineProvisioningLocation)location);
+ } else {
+ startInLocation((MachineLocation)location);
+ }
+ }
+
+ private void startInLocation(MachineProvisioningLocation loc) {
+ try {
+ startInLocation(loc.obtain(MutableMap.of()));
+ } catch (NoMachinesAvailableException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ private void startInLocation(MachineLocation loc) {
+ addLocations(ImmutableList.of((Location)loc));
+ sensors().set(HOSTNAME, loc.getAddress().getHostName());
+ sensors().set(HTTP_PORT, nextPort.getAndIncrement());
+ sensors().set(SERVICE_UP, true);
+ }
+
+ public void stop() {
+ sensors().set(SERVICE_UP, false);
+ }
+
+ @Override
+ public void restart() {
+ }
+}
\ No newline at end of file
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/UrlMappingTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/UrlMappingTest.java
index a571627..65a6b4e 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/UrlMappingTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/UrlMappingTest.java
@@ -32,8 +32,6 @@
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.entity.EntityInternal;
import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
-import org.apache.brooklyn.core.entity.factory.BasicConfigurableEntityFactory;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
import org.apache.brooklyn.core.mgmt.rebind.RebindTestUtils;
import org.apache.brooklyn.core.test.entity.TestApplication;
@@ -79,10 +77,10 @@
app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
- EntityFactory<StubAppServer> serverFactory = new BasicConfigurableEntityFactory<StubAppServer>(StubAppServer.class);
+ EntitySpec<StubAppServer> serverSpec = EntitySpec.create(StubAppServer.class);
cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
- .configure("initialSize", initialClusterSize)
- .configure("factory", serverFactory));
+ .configure(DynamicCluster.INITIAL_SIZE, initialClusterSize)
+ .configure(DynamicCluster.MEMBER_SPEC, serverSpec));
urlMapping = app.createAndManageChild(EntitySpec.create(UrlMapping.class)
.configure("domain", "localhost")
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java
index f2c25d2..c533b8d 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxIntegrationTest.java
@@ -30,8 +30,8 @@
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.core.entity.EntityAsserts;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
+import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.entity.group.DynamicCluster;
import org.apache.brooklyn.entity.software.base.SoftwareProcess;
import org.apache.brooklyn.entity.webapp.JavaWebAppService;
@@ -79,10 +79,7 @@
public void testWhenNoServersReturns404() {
serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
.configure("initialSize", 0)
- .configure(DynamicCluster.FACTORY, new EntityFactory<Entity>() {
- @Override public Entity newEntity(Map flags, Entity parent) {
- throw new UnsupportedOperationException();
- }}));
+ .configure("memberSpec", EntitySpec.create(TestEntity.class)));
nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
.configure("serverPool", serverPool)
@@ -98,10 +95,7 @@
public void testRestart() {
serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
.configure("initialSize", 0)
- .configure(DynamicCluster.FACTORY, new EntityFactory<Entity>() {
- @Override public Entity newEntity(Map flags, Entity parent) {
- throw new UnsupportedOperationException();
- }}));
+ .configure("memberSpec", EntitySpec.create(TestEntity.class)));
nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
.configure("serverPool", serverPool)
@@ -244,10 +238,7 @@
public void testTwoNginxesGetDifferentPorts() {
serverPool = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
.configure("initialSize", 0)
- .configure(DynamicCluster.FACTORY, new EntityFactory<Entity>() {
- @Override public Entity newEntity(Map flags, Entity parent) {
- throw new UnsupportedOperationException();
- }}));
+ .configure("memberSpec", EntitySpec.create(TestEntity.class)));
NginxController nginx1 = app.createAndManageChild(EntitySpec.create(NginxController.class)
.configure("serverPool", serverPool)
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java
index 4f80698..78759af 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxLightIntegrationTest.java
@@ -25,8 +25,6 @@
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.factory.BasicConfigurableEntityFactory;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
import org.apache.brooklyn.entity.group.DynamicCluster;
import org.apache.brooklyn.entity.proxy.StubAppServer;
@@ -39,20 +37,17 @@
public class NginxLightIntegrationTest extends BrooklynAppUnitTestSupport {
- private NginxController nginx;
- private DynamicCluster cluster;
-
// FIXME Fails because getting addEntity callback for group members while nginx is still starting,
// so important nginx fields are still null. Therefore get NPE for cluster members, and thus targets
// is of size zero.
@Test(groups = {"Integration", "WIP"})
public void testNginxTargetsMatchesClusterMembers() {
- EntityFactory<StubAppServer> serverFactory = new BasicConfigurableEntityFactory<StubAppServer>(StubAppServer.class);
+ EntitySpec<StubAppServer> serverSpec = EntitySpec.create(StubAppServer.class);
final DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
.configure("initialSize", 2)
- .configure("factory", serverFactory));
+ .configure(DynamicCluster.MEMBER_SPEC, serverSpec));
- nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
+ final NginxController nginx = app.createAndManageChild(EntitySpec.create(NginxController.class)
.configure("serverPool", cluster)
.configure("domain", "localhost"));
diff --git a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
index 1aee752..9f40dd0 100644
--- a/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
+++ b/software/webapp/src/test/java/org/apache/brooklyn/entity/proxy/nginx/NginxUrlMappingIntegrationTest.java
@@ -27,7 +27,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.apache.brooklyn.api.entity.Entity;
@@ -36,16 +35,14 @@
import org.apache.brooklyn.api.mgmt.EntityManager;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.factory.EntityFactory;
import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
+import org.apache.brooklyn.core.test.entity.TestEntity;
import org.apache.brooklyn.entity.group.BasicGroup;
import org.apache.brooklyn.entity.group.DynamicCluster;
-import org.apache.brooklyn.entity.proxy.nginx.NginxController;
-import org.apache.brooklyn.entity.proxy.nginx.UrlMapping;
-import org.apache.brooklyn.entity.proxy.nginx.UrlRewriteRule;
import org.apache.brooklyn.entity.webapp.JavaWebAppService;
import org.apache.brooklyn.entity.webapp.WebAppService;
import org.apache.brooklyn.entity.webapp.tomcat.Tomcat8Server;
+import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
import org.apache.brooklyn.test.Asserts;
import org.apache.brooklyn.test.HttpTestUtils;
import org.apache.brooklyn.test.support.TestResourceUnavailableException;
@@ -53,7 +50,6 @@
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -429,10 +425,7 @@
public void testUrlMappingWithEmptyCoreCluster() throws Exception {
DynamicCluster nullCluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
.configure("initialSize", 0)
- .configure("factory", new EntityFactory<Entity>() {
- public Entity newEntity(Map flags, Entity parent) {
- throw new UnsupportedOperationException();
- }}));
+ .configure("membeSpec", EntitySpec.create(TestEntity.class)));
DynamicCluster c0 = app.createAndManageChild(EntitySpec.create(DynamicCluster.class)
.configure("initialSize", 1)