Search in sources :

Example 1 with Supervisor

use of aQute.remote.api.Supervisor in project bnd by bndtools.

the class AgentDispatcher method toAgent.

/**
	 * Create a new agent on an existing framework.
	 */
public static void toAgent(final Descriptor descriptor, DataInputStream in, DataOutputStream out) {
    // Check if the framework is active
    if (descriptor.framework.getState() != Bundle.ACTIVE) {
        throw new IllegalStateException("Framework " + descriptor.name + " is not active. (Stopped?)");
    }
    //
    // Get the bundle context
    //
    BundleContext context = descriptor.framework.getBundleContext();
    AgentServer as = new AgentServer(descriptor.name, context, descriptor.shaCache) {

        //
        // Override the close se we can remote it from the list
        //
        public void close() throws IOException {
            descriptor.servers.remove(this);
            super.close();
        }
    };
    //
    // Link up
    //
    Link<Agent, Supervisor> link = new Link<Agent, Supervisor>(Supervisor.class, as, in, out);
    as.setLink(link);
    link.open();
}
Also used : Supervisor(aQute.remote.api.Supervisor) Agent(aQute.remote.api.Agent) Link(aQute.remote.util.Link) BundleContext(org.osgi.framework.BundleContext)

Aggregations

Agent (aQute.remote.api.Agent)1 Supervisor (aQute.remote.api.Supervisor)1 Link (aQute.remote.util.Link)1 BundleContext (org.osgi.framework.BundleContext)1