Package com.sun.messaging.bridge.service

Examples of com.sun.messaging.bridge.service.Bridge


    public static Object getExportedService(String className, String bridgeType, Properties props) throws Exception {
        if (className == null) throw new IllegalArgumentException("null class name");
        if (bridgeType == null) throw new IllegalArgumentException("null bridge type");

        Bridge b = null;
        if (bridgeType.toUpperCase().equals(Bridge.JMS_TYPE)) {
            b = (Bridge)Class.forName("com.sun.messaging.bridge.service.jms.BridgeImpl").newInstance();
        } else if (bridgeType.toUpperCase().equals(Bridge.STOMP_TYPE)) {
            b = (Bridge)Class.forName("com.sun.messaging.bridge.service.stomp.StompBridge").newInstance();
        } else {
            throw new IllegalArgumentException("Invalid bridge type: "+bridgeType);
        }

        return  b.getExportedService(className, props);
    }
View Full Code Here


        Properties props = _bc.getBridgeConfig();

        try {

        Bridge b = null;
        String name = null;
        for (Map.Entry<String, Bridge> pair: _bridges.entrySet()) {
            b = pair.getValue();
            name = b.getName();
            String autostart = props.getProperty(
                               props.getProperty(
                               BridgeBaseContext.PROP_PREFIX)+"."+name+".autostart", "true");
            boolean doautostart = Boolean.valueOf(autostart);
            try {
View Full Code Here

     *
     */
    public synchronized void loadBridge(String name) throws Exception {
        _bc.logInfo("Loading bridge "+name, null);

        Bridge b = _bridges.get(name);
        if (b != null) {
            _bc.logInfo("Bridge "+name+" is already loaded.", null);
           throw new BridgeException(_bmr.getString(_bmr.I_BRIDGE_ALREADY_LOADED, name), Status.NOT_MODIFIED);
        }

        Properties props = _bc.getBridgeConfig();

        /*
        String activekey = props.getProperty(
                                  BridgeBaseContext.PROP_PREFIX)+".activelist";
        List<String> alist = BridgeUtil.getListProperty(activekey, props);
       
        String tmpn = null;
        boolean found = false;
        Iterator<String> itr = alist.iterator();
        while (itr.hasNext()) {
            tmpn = itr.next();
            if (tmpn.equals(name)) {
                found = true;
                break;
            }
        }
        if (!found) {
            String oldactives = props.getProperty(activekey);
            String newactives = oldactives+","+name;
            Properties p = new Properties();
            p.setProperty(activekey, newactives);
            _bc.updateBridgeConfig(p);
        }
        */

        props = _bc.getBridgeConfig();
        String type = props.getProperty(
                      props.getProperty(
                      BridgeBaseContext.PROP_PREFIX)+"."+name+".type");
        if (type == null) {
            String emsg = _bmr.getKString(_bmr.E_LOAD_BRIDGE_NO_TYPE, name);
            _bc.logError(emsg, null);
            throw new BridgeException(emsg);
        }
        type = type.toLowerCase();

        String classn = props.getProperty(
                        props.getProperty(
                        BridgeBaseContext.PROP_PREFIX)+"."+type+".class");

        if (classn == null) {
            String emsg = _bmr.getKString(_bmr.E_LOAD_BRIDGE_NO_CLASS, name);
            _bc.logError(emsg, null);
            throw new BridgeException(emsg);
        }


        b = (Bridge)Class.forName(classn).newInstance();

        if (!b.isMultipliable() && !b.getType().toLowerCase().equals(name.toLowerCase())) {
            String emsg =  _bmr.getKString(_bmr.E_BRIDGE_NAME_TYPE_NOT_SAME, name, b.getType());
            _bc.logError(emsg, null);
            throw new BridgeException(emsg);
        }

        if (DEBUG) {
            _bc.logInfo("Loaded brigde "+name+" by classloader "+
                        b.getClass().getClassLoader()+
                        "(parent:"+this.getClass().getClassLoader()+")", null);
        }

        b.setName(name);
        _bridges.put(name, b);

        _bc.logInfo("Loaded bridge "+name, null);

    }
View Full Code Here

        if (type != null &&
            !type.equals(Bridge.JMS_TYPE) && !type.equals(Bridge.STOMP_TYPE)) {
            throw new IllegalArgumentException(_bmr.getKString(_bmr.X_BRIDGE_INVALID_TYPE, type));
        }
        Bridge b = null;
        if (name != null) {
            b = _bridges.get(name);
            if (b == null) {
                throw new BridgeException(_bmr.getKString(_bmr.X_BRIDGE_NAME_NOT_FOUND, name));
            }
            if (type != null && !type.equals(b.getType())) {
                String[] eparam = new String[] {name, b.getType(), type};
                throw new  BridgeException(_bmr.getKString(_bmr.X_BRIDGE_TYPE_MISMATCH, eparam));
            }
            return startBridge(b, args);
        }

        boolean async = false;
        for (Map.Entry<String, Bridge> pair: _bridges.entrySet()) {
            b = pair.getValue();
            if (type != null && !b.getType().equals(type)) continue;

            if (!startBridge(b, args)) {
                async = true;
            }
        }
View Full Code Here

        if (type != null &&
            !type.equals(Bridge.JMS_TYPE) && !type.equals(Bridge.STOMP_TYPE)) {
            throw new IllegalArgumentException(_bmr.getKString(_bmr.X_BRIDGE_INVALID_TYPE, type));
        }
        Bridge b = null;
        if (name != null) {
            b = _bridges.get(name);
            if (b == null) {
                throw new BridgeException(_bmr.getKString(_bmr.X_BRIDGE_NAME_NOT_FOUND, name));
            }
            if (type != null && !type.equals(b.getType())) {
                String[] eparam = new String[] {name, b.getType(), type};
                throw new BridgeException(_bmr.getKString(_bmr.X_BRIDGE_TYPE_MISMATCH, eparam));
            }
            stopBridge(b, args);
            return;
        }

        for (Map.Entry<String, Bridge> pair: _bridges.entrySet()) {
             b = pair.getValue();
             if (type != null && !b.getType().equals(type)) continue;

             stopBridge(b, args);
        }
    }
View Full Code Here

            throw new IllegalArgumentException(_bmr.getKString(_bmr.X_BRIDGE_INVALID_TYPE, type));
        }
        if (name == null && type == null) {
            throw new UnsupportedOperationException(_bmr.getKString(_bmr.X_BRIDGE_PAUSE_NO_TYPE));
        }
        Bridge b = null;
        if (name != null) {
            b = _bridges.get(name);
            if (b == null) {
                throw new BridgeException(_bmr.getKString(_bmr.X_BRIDGE_NAME_NOT_FOUND, name));
            }
            if (type != null && !type.equals(b.getType())) {
                String[] eparam = new String[] {name, b.getType(), type};
                throw new BridgeException(_bmr.getKString(_bmr.X_BRIDGE_TYPE_MISMATCH, eparam));
            }
            pauseBridge(b, args);
            return;
        }

        for (Map.Entry<String, Bridge> pair: _bridges.entrySet()) {
             b = pair.getValue();
             if (type != null && !b.getType().equals(type)) continue;

             pauseBridge(b, args);
        }
    }
View Full Code Here

        }
        if (name == null && type == null) {
            throw new UnsupportedOperationException(_bmr.getKString(_bmr.X_BRIDGE_RESUME_NO_TYPE));
        }

        Bridge b = null;
        if (name != null) {
            b = _bridges.get(name);
            if (b == null) {
                throw new BridgeException(_bmr.getKString(_bmr.X_BRIDGE_NAME_NOT_FOUND, name));
            }
            if (type != null && !type.equals(b.getType())) {
                String[] eparam = new String[] {name, b.getType(), type};
                throw new BridgeException(_bmr.getKString(_bmr.X_BRIDGE_TYPE_MISMATCH, eparam));
            }
            resumeBridge(b, args);
            return;
        }

        for (Map.Entry<String, Bridge> pair: _bridges.entrySet()) {
             b = pair.getValue();
             if (type != null && !b.getType().equals(type)) continue;

             resumeBridge(b, args);
        }
    }
View Full Code Here

     *
     */
    public synchronized void unloadBridge(String name) throws Exception {
        _bc.logInfo("Unloading bridge "+name, null);

        Bridge b = _bridges.get(name);
        if (b == null) {
            _bc.logInfo("Bridge "+name+" is not loaded."null);
            throw new BridgeException("Bridge "+name+" is not loaded.", Status.NOT_MODIFIED);
        }
        stopBridge(name, null, null);
        _bridges.remove(name);
        b.setName(null);

        Properties props = _bc.getBridgeConfig();
        List<String> alist = BridgeUtil.getListProperty(
                                props.getProperty(
                                BridgeBaseContext.PROP_PREFIX)+".activelist", props);
View Full Code Here

            oneRow[0] =  bmr.getString(BridgeCmdSharedResources.I_BGMGR_TITLE_BRIDGE_NAME);
            oneRow[1] =  bmr.getString(BridgeCmdSharedResources.I_BGMGR_TITLE_BRIDGE_TYPE);
            oneRow[2] =  bmr.getString(BridgeCmdSharedResources.I_BGMGR_TITLE_BRIDGE_STATE);
            reply.addTitle(oneRow);

            Bridge b = null;
            for (Map.Entry<String, Bridge> pair: _bridges.entrySet()) {
                b = pair.getValue();
                if (type != null && !b.getType().equals(type)) continue;
                oneRow[0] = b.getName();
                oneRow[1] = b.getType();
                oneRow[2] = b.getState().toString(bmr);
                reply.add(oneRow);
            }
            _bc.logDebug("Listed all bridges (type="+type+")", null);
            ArrayList<BridgeCmdSharedReplyData> replys = new ArrayList<BridgeCmdSharedReplyData>();
            replys.add(reply);
            return replys;
        }                

        if (args == null) {
            _bc.logInfo(_bmr.getString(_bmr.I_LISTING_BRIDGE, name), null);
        } else {
            _bc.logInfo(_bmr.getString(_bmr.I_LISTING_BRIDGE_WITH, name, BridgeContext.toString(args)), null);
        }

        Bridge b = _bridges.get(name);
        if (b == null) {
            String emsg = _bmr.getKString(_bmr.X_BRIDGE_NAME_NOT_FOUND, name);
            _bc.logError(emsg, null);
            throw new BridgeException(emsg);
        }

        BridgeContext bc = new BridgeContext(_bc, b.getName());
        return b.list(bc, args, bmr);
    }
View Full Code Here

    /**
     *
     */
    public Bridge getBridge(String name) throws Exception {
        Bridge b = _bridges.get(name);
        if (b == null) {
            throw new BridgeException(_bmr.getKString(_bmr.X_BRIDGE_NAME_NOT_FOUND, name));
        }
        return b;
    }
View Full Code Here

TOP

Related Classes of com.sun.messaging.bridge.service.Bridge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.