@SuppressWarnings({"unchecked"}) public void disconnect(PhysicalChannelConnection physicalConnection) { PhysicalConnectionSource source = physicalConnection.getSource(); PhysicalConnectionTarget target = physicalConnection.getTarget(); Key key = new Key(source.getSourceId(), target.getTargetId()); Holder holder = cachedConnections.get(key); if (holder == null) { return; } if (holder.count.decrementAndGet() == 0) { cachedConnections.remove(key); } else { return; } SourceConnectionAttacher sourceAttacher = sourceAttachers.get(source.getClass()); if (sourceAttacher == null) { throw new Fabric3Exception("Attacher not found for type: " + source.getClass().getName()); } TargetConnectionAttacher targetAttacher = targetAttachers.get(target.getClass()); if (targetAttacher == null) { throw new Fabric3Exception("Attacher not found for type: " + target.getClass().getName()); } sourceAttacher.detach(source, target); targetAttacher.detach(source, target); }
@SuppressWarnings({"unchecked"}) public void disconnect(PhysicalChannelConnection physicalConnection) { PhysicalConnectionSource source = physicalConnection.getSource(); PhysicalConnectionTarget target = physicalConnection.getTarget(); Key key = new Key(source.getSourceId(), target.getTargetId()); Holder holder = cachedConnections.get(key); if (holder == null) { return; } if (holder.count.decrementAndGet() == 0) { cachedConnections.remove(key); } else { return; } SourceConnectionAttacher sourceAttacher = sourceAttachers.get(source.getClass()); if (sourceAttacher == null) { throw new Fabric3Exception("Attacher not found for type: " + source.getClass().getName()); } TargetConnectionAttacher targetAttacher = targetAttachers.get(target.getClass()); if (targetAttacher == null) { throw new Fabric3Exception("Attacher not found for type: " + target.getClass().getName()); } sourceAttacher.detach(source, target); targetAttacher.detach(source, target); }
@SuppressWarnings({"unchecked"}) public ChannelConnection connect(PhysicalChannelConnection physicalConnection) { PhysicalConnectionSource source = physicalConnection.getSource(); PhysicalConnectionTarget target = physicalConnection.getTarget(); Key key = new Key(source.getSourceId(), target.getTargetId()); Holder holder = cachedConnections.get(key); if (holder != null) { // connection is cached; don't engage a second one holder.count.incrementAndGet(); return holder.connection; } SourceConnectionAttacher sourceAttacher = sourceAttachers.get(source.getClass()); if (sourceAttacher == null) { throw new Fabric3Exception("Attacher not found for type: " + source.getClass().getName()); } TargetConnectionAttacher targetAttacher = targetAttachers.get(target.getClass()); if (targetAttacher == null) { throw new Fabric3Exception("Attacher not found for type: " + target.getClass().getName()); } ChannelConnection connection = createConnection(physicalConnection); sourceAttacher.attach(source, target, connection); targetAttacher.attach(source, target, connection); cachedConnections.put(key, new Holder(connection)); return connection; }
@SuppressWarnings({"unchecked"}) public ChannelConnection connect(PhysicalChannelConnection physicalConnection) { PhysicalConnectionSource source = physicalConnection.getSource(); PhysicalConnectionTarget target = physicalConnection.getTarget(); Key key = new Key(source.getSourceId(), target.getTargetId()); Holder holder = cachedConnections.get(key); if (holder != null) { // connection is cached; don't engage a second one holder.count.incrementAndGet(); return holder.connection; } SourceConnectionAttacher sourceAttacher = sourceAttachers.get(source.getClass()); if (sourceAttacher == null) { throw new Fabric3Exception("Attacher not found for type: " + source.getClass().getName()); } TargetConnectionAttacher targetAttacher = targetAttachers.get(target.getClass()); if (targetAttacher == null) { throw new Fabric3Exception("Attacher not found for type: " + target.getClass().getName()); } ChannelConnection connection = createConnection(physicalConnection); sourceAttacher.attach(source, target, connection); targetAttacher.attach(source, target, connection); cachedConnections.put(key, new Holder(connection)); return connection; }