/** * This constructor is package private since only MessageBus is supposed to instantiate it. * * @param mbus The message bus that created this instance. * @param params The parameter object for this session. */ DestinationSession(MessageBus mbus, DestinationSessionParams params) { this.mbus = mbus; this.name = params.getName(); this.broadcastName = params.getBroadcastName(); this.msgHandler = params.getMessageHandler(); }
/** * <p>Creates a destination session on top of this message bus using the * given handlers and parameter object.</p> * * @param params The parameters to control the session. * @return The created session. */ public synchronized DestinationSession createDestinationSession(DestinationSessionParams params) { if (destroyed.get()) { throw new IllegalStateException("Object is destroyed."); } if (sessions.containsKey(params.getName())) { throw new IllegalArgumentException("Name '" + params.getName() + "' is not unique."); } DestinationSession session = new DestinationSession(this, params); sessions.put(params.getName(), session); if (params.getBroadcastName()) { net.registerSession(params.getName()); } return session; }