|
22 | 22 |
|
23 | 23 | import org.apache.brooklyn.api.entity.Entity; |
24 | 24 | import org.apache.brooklyn.api.entity.EntityLocal; |
| 25 | +import org.apache.brooklyn.api.location.Location; |
25 | 26 | import org.apache.brooklyn.api.location.MachineLocation; |
26 | 27 | import org.apache.brooklyn.api.sensor.AttributeSensor; |
27 | 28 | import org.apache.brooklyn.api.sensor.EnricherSpec; |
28 | 29 | import org.apache.brooklyn.api.sensor.SensorEvent; |
| 30 | +import org.apache.brooklyn.api.sensor.SensorEventListener; |
29 | 31 | import org.apache.brooklyn.config.ConfigKey; |
30 | 32 | import org.apache.brooklyn.core.config.ConfigKeys; |
| 33 | +import org.apache.brooklyn.core.entity.AbstractEntity; |
31 | 34 | import org.apache.brooklyn.core.entity.EntityAndAttribute; |
32 | 35 | import org.apache.brooklyn.core.location.Machines; |
33 | 36 | import org.apache.brooklyn.core.location.access.PortForwardManager; |
@@ -124,6 +127,15 @@ public void onAssociationDeleted(PortForwardManager.AssociationMetadata metadata |
124 | 127 | } |
125 | 128 | }; |
126 | 129 | getConfig(SUBNET_TIER).getPortForwardManager().addAssociationListener(listener, Predicates.alwaysTrue()); |
| 130 | + |
| 131 | + subscriptions().subscribe(producer, AbstractEntity.LOCATION_ADDED, new SensorEventListener<Location>() { |
| 132 | + @Override public void onEvent(SensorEvent<Location> event) { |
| 133 | + T sensorVal = producer.getAttribute((AttributeSensor<T>)sourceSensor); |
| 134 | + if (sensorVal != null) { |
| 135 | + log.debug("Simulating sensor-event on new location-added {}, to trigger transformation by {}", new Object[] {event.getValue(), AbstractNatTransformingEnricher.this}); |
| 136 | + AbstractNatTransformingEnricher.this.onEvent(new BasicSensorEvent<T>(sourceSensor, producer, sensorVal)); |
| 137 | + } |
| 138 | + }}); |
127 | 139 | } |
128 | 140 |
|
129 | 141 | @Override |
|
0 commit comments