entity.relations().add(DockerContainer.RUNNING.getInverseRelationshipType(), this);
@Override public void connect(DockerContainer container, VirtualNetwork network) { synchronized (network) { MutableSet<Entity> connected = MutableSet.copyOf(network.sensors().get(VirtualNetwork.CONNECTED_CONTAINERS)); connected.add(container); network.sensors().set(VirtualNetwork.CONNECTED_CONTAINERS, connected.asImmutableCopy()); } network.relations().add(VirtualNetwork.ATTACHED, container); container.relations().add(VirtualNetwork.CONNECTED, network); }
/** * As {@link RelationSupport#add(RelationshipType, BrooklynObject)} for the given object. Callers can use either method. * See {@link AbstractBasicRelationSupport} for a discussion of why double dispatch is used and both methods are present. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public static <T extends BrooklynObject,U extends BrooklynObject> void add(T source, RelationshipType<? super T,? super U> relationship, U target) { ((BrooklynObjectInternal)source).relations().getLocalBackingStore().add((RelationshipType)relationship, target); if (relationship.getInverseRelationshipType()!=null) ((BrooklynObjectInternal)target).relations().getLocalBackingStore().add((RelationshipType)relationship.getInverseRelationshipType(), source); }