Design of agent-based middleware for flexible connection control