use of com.sun.messaging.bridge.api.Bridge in project openmq by eclipse-ee4j.
the class BridgeServiceManagerImpl method resumeBridge.
public synchronized void resumeBridge(String name, String[] args, String type) throws Exception {
if (type != null && !type.equals(Bridge.JMS_TYPE) && !type.equals(Bridge.STOMP_TYPE)) {
throw new IllegalArgumentException(_bmr.getKString(_bmr.X_BRIDGE_INVALID_TYPE, type));
}
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);
}
}
use of com.sun.messaging.bridge.api.Bridge in project openmq by eclipse-ee4j.
the class BridgeServiceManagerImpl method listBridge.
public synchronized ArrayList<BridgeCmdSharedReplyData> listBridge(String name, String[] args, String type, BridgeManagerResources bmr) throws Exception {
if (type != null && !type.equals(Bridge.JMS_TYPE) && !type.equals(Bridge.STOMP_TYPE)) {
throw new IllegalArgumentException(_bmr.getString(_bmr.X_BRIDGE_INVALID_TYPE, type));
}
if (name == null) {
_bc.logDebug("Listing all bridges (type=" + type + ")", null);
BridgeCmdSharedReplyData reply = new BridgeCmdSharedReplyData(3, 4, "-");
String[] oneRow = new String[3];
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<>();
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, BridgeUtil.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 BridgeContextImpl(_bc, b.getName());
return b.list(bc, args, bmr);
}
use of com.sun.messaging.bridge.api.Bridge in project openmq by eclipse-ee4j.
the class BridgeServiceManagerImpl method startBridge.
/**
* @return true if started successful, false if asynchronously started
*
* @throws Exception if start failed
*/
public synchronized boolean startBridge(String name, String[] args, String type) throws Exception {
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;
}
}
return !async;
}
use of com.sun.messaging.bridge.api.Bridge in project openmq by eclipse-ee4j.
the class BridgeServiceManagerImpl method unloadBridge.
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);
String tmpn = null;
StringBuilder sbuf = new StringBuilder();
Iterator<String> itr = alist.iterator();
while (itr.hasNext()) {
tmpn = itr.next();
if (!tmpn.equals(name)) {
if (sbuf.length() > 0) {
sbuf.append(',');
}
sbuf.append(tmpn);
}
}
Properties p = new Properties();
p.setProperty(props.getProperty(BridgeBaseContext.PROP_PREFIX) + ".activelist", sbuf.toString());
_bc.updateBridgeConfig(p);
_bc.logInfo("Unloaded bridge " + name, null);
}
use of com.sun.messaging.bridge.api.Bridge in project openmq by eclipse-ee4j.
the class BridgeServiceManagerImpl method loadBridge.
/**
*/
public synchronized void loadBridge(String name) throws Exception {
_bc.logInfo("Loading bridge " + name, null);
Locale loc = _bmr.getLocale();
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); }
*/
Properties 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(loc);
if (!type.toUpperCase(loc).equals(Bridge.JMS_TYPE) && !type.toUpperCase(loc).equals(Bridge.STOMP_TYPE)) {
String emsg = _bmr.getKString(_bmr.X_BRIDGE_TYPE_NOSUPPORT, name, type);
_bc.logError(emsg, null);
throw new BridgeException(emsg);
}
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);
}
if (_bc.isRunningOnNucleus()) {
b = habitat.getService(Bridge.class, type.toUpperCase(loc));
} else {
b = (Bridge) Class.forName(classn).getDeclaredConstructor().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);
}
Aggregations