Search in sources :

Example 1 with ConnectionEvent

use of com.swiftmq.impl.routing.single.manager.event.ConnectionEvent in project swiftmq-ce by iitsoftware.

the class ConnectionManager method visit.

public void visit(PORemoveObject por) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/visitConnectionRemove...");
    RoutingConnection rc = por.getConnection();
    removeConnection(rc, true);
    por.setSuccess(true);
    if (por.getCallback() != null)
        por.getCallback().onSuccess(por);
    if (por.getSemaphore() != null)
        por.getSemaphore().notifySingleWaiter();
    fireConnectionRemoved(new ConnectionEvent(rc));
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/visitConnectionRemove done");
}
Also used : RoutingConnection(com.swiftmq.impl.routing.single.connection.RoutingConnection) ConnectionEvent(com.swiftmq.impl.routing.single.manager.event.ConnectionEvent)

Example 2 with ConnectionEvent

use of com.swiftmq.impl.routing.single.manager.event.ConnectionEvent in project swiftmq-ce by iitsoftware.

the class ConnectionManager method removeAll.

private void removeAll() {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/removeAll...");
    for (Iterator iter = connections.entrySet().iterator(); iter.hasNext(); ) {
        RoutingConnection rc = (RoutingConnection) ((Map.Entry) iter.next()).getValue();
        removeConnection(rc, false);
        iter.remove();
        fireConnectionRemoved(new ConnectionEvent(rc));
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/removeAll done");
}
Also used : RoutingConnection(com.swiftmq.impl.routing.single.connection.RoutingConnection) ConnectionEvent(com.swiftmq.impl.routing.single.manager.event.ConnectionEvent)

Example 3 with ConnectionEvent

use of com.swiftmq.impl.routing.single.manager.event.ConnectionEvent in project swiftmq-ce by iitsoftware.

the class ConnectionManager method visit.

public void visit(POAddObject poa) {
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/visitConnectionAdd...");
    RoutingConnection rc = poa.getConnection();
    String exception = null;
    if (isLicenseLimit())
        exception = "License limit reached. Connection REJECTED!";
    else if (rc.getRouterName().equals(ctx.routerName) || connections.containsKey(rc.getRouterName()))
        exception = "Router '" + rc.getRouterName() + "' is already connected. Connection REJECTED!";
    if (exception != null) {
        poa.setSuccess(false);
        poa.setException(exception);
        if (poa.getCallback() != null)
            poa.getCallback().onException(poa);
    } else {
        connections.put(rc.getRouterName(), rc);
        try {
            Entity ce = connectionEntity.createEntity();
            ce.setName(rc.getConnectionId());
            ce.setDynamicObject(rc);
            ce.createCommands();
            Property prop = ce.getProperty("routername");
            prop.setReadOnly(false);
            prop.setValue(rc.getRouterName());
            prop.setReadOnly(true);
            prop = ce.getProperty("connecttime");
            prop.setValue(new Date().toString());
            prop.setReadOnly(true);
            connectionEntity.addEntity(ce);
            rc.setUsageEntity(ce);
        } catch (Exception e) {
        }
        rc.setActivationListener(ctx.routeExchanger);
        poa.setSuccess(true);
        if (poa.getCallback() != null)
            poa.getCallback().onSuccess(poa);
    }
    if (poa.getSemaphore() != null)
        poa.getSemaphore().notifySingleWaiter();
    if (poa.isSuccess())
        fireConnectionAdded(new ConnectionEvent(rc));
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(ctx.routingSwiftlet.getName(), "ConnectionManager/visitConnectionAdd done");
}
Also used : Entity(com.swiftmq.mgmt.Entity) RoutingConnection(com.swiftmq.impl.routing.single.connection.RoutingConnection) ConnectionEvent(com.swiftmq.impl.routing.single.manager.event.ConnectionEvent) Property(com.swiftmq.mgmt.Property)

Aggregations

RoutingConnection (com.swiftmq.impl.routing.single.connection.RoutingConnection)3 ConnectionEvent (com.swiftmq.impl.routing.single.manager.event.ConnectionEvent)3 Entity (com.swiftmq.mgmt.Entity)1 Property (com.swiftmq.mgmt.Property)1