Search in sources :

Example 1 with BridgeManagerResources

use of com.sun.messaging.bridge.admin.resources.BridgeManagerResources in project openmq by eclipse-ee4j.

the class BridgeServiceManagerImpl method getBridgeManagerResources.

public static BridgeManagerResources getBridgeManagerResources(Locale l) {
    if (l == null) {
        return getBridgeManagerResources();
    }
    BridgeManagerResources bmr = _bmrs.get(l);
    if (bmr != null) {
        return bmr;
    }
    synchronized (_bmrs) {
        bmr = _bmrs.get(l);
        if (bmr == null) {
            bmr = BridgeManagerResources.getResources(l);
            _bmrs.put(l, bmr);
        }
        return bmr;
    }
}
Also used : BridgeManagerResources(com.sun.messaging.bridge.admin.resources.BridgeManagerResources)

Example 2 with BridgeManagerResources

use of com.sun.messaging.bridge.admin.resources.BridgeManagerResources in project openmq by eclipse-ee4j.

the class AdminMessageHandler method handle.

public void handle(Session session, ObjectMessage msg) {
    BridgeManagerResources bmr = _br;
    ObjectMessage reply = null;
    int msgType = AdminMessageType.Type.LAST;
    try {
        reply = session.createObjectMessage();
        if (DEBUG) {
            _bc.logInfo("BridgeAdminMessageHandler.handle:\n<<<<****" + msg, null);
        }
        try {
            String lang = msg.getStringProperty(AdminMessageType.PropName.LOCALE_LANG);
            String country = msg.getStringProperty(AdminMessageType.PropName.LOCALE_COUNTRY);
            String variant = msg.getStringProperty(AdminMessageType.PropName.LOCALE_VARIANT);
            Locale locale = new Locale(lang, country, variant);
            bmr = _bsm.getBridgeManagerResources(locale);
        } catch (Exception e) {
            bmr = _br;
            String emsg = _br.getKString(_br.E_GET_LOCALE_FAILED, e.toString(), msg.toString());
            _bc.logWarn(emsg, null);
        }
        Destination dest = msg.getJMSDestination();
        if (!(dest instanceof Queue)) {
            throw new BridgeException(_br.getKString(_br.X_ADMIN_MSG_NOT_QUEUE, dest));
        }
        if (!((Queue) dest).getQueueName().equals(_bsm.getAdminDestinationName())) {
            throw new BridgeException(_br.getKString(_br.X_ADMIN_MSG_UNEXPECTED_DEST, dest));
        }
        try {
            msgType = msg.getIntProperty(AdminMessageType.PropName.MESSAGE_TYPE);
        } catch (Exception e) {
            msgType = AdminMessageType.Type.LAST;
            String emsg = _br.getKString(_br.X_EXCEPTION_PROCESSING_ADMIN_MSG, msg.toString());
            _bc.logError(emsg, e);
            throw new BridgeException(emsg, e);
        }
        AdminCmdHandler ach = null;
        try {
            ach = _handlers[msgType];
        } catch (IndexOutOfBoundsException e) {
            String emsg = _br.getKString(_br.X_UNEXPECTED_ADMIN_MSG_TYPE, AdminMessageType.getString(msgType));
            throw new BridgeException(emsg);
        }
        if (ach == null) {
            String emsg = "No bridge admin handler for message type " + AdminMessageType.getString(msgType);
            throw new BridgeException(emsg);
        }
        reply.setIntProperty(AdminMessageType.PropName.MESSAGE_TYPE, ++msgType);
        ach.handle(session, msg, reply, bmr);
    } catch (Throwable t) {
        int status = Status.ERROR;
        if (t instanceof BridgeException) {
            BridgeException be = (BridgeException) t;
            status = be.getStatus();
            if (be.getCause() == null) {
                // else should already logged
                _bc.logError(t.getMessage(), null);
            }
        } else {
            _bc.logError(t.getMessage(), t);
        }
        if (DEBUG) {
            _bc.logInfo("BridgeAdminMessageHandler exception: " + t.getMessage() + (reply == null ? "no reply created" : "sending error reply"), t);
        }
        if (reply != null) {
            sendReply(session, msg, reply, status, AdminCmdHandler.getMessageFromThrowable(t), bmr);
        }
    }
}
Also used : Locale(java.util.Locale) BridgeException(com.sun.messaging.bridge.api.BridgeException) Destination(jakarta.jms.Destination) ObjectMessage(jakarta.jms.ObjectMessage) BridgeManagerResources(com.sun.messaging.bridge.admin.resources.BridgeManagerResources) Queue(jakarta.jms.Queue) BridgeException(com.sun.messaging.bridge.api.BridgeException)

Aggregations

BridgeManagerResources (com.sun.messaging.bridge.admin.resources.BridgeManagerResources)2 BridgeException (com.sun.messaging.bridge.api.BridgeException)1 Destination (jakarta.jms.Destination)1 ObjectMessage (jakarta.jms.ObjectMessage)1 Queue (jakarta.jms.Queue)1 Locale (java.util.Locale)1