use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.
the class ObjAdminHandler method doAddConnFactory.
private void doAddConnFactory(ObjAdminEvent oae, ConsoleObj selObj) {
Object object = null;
ObjStore os = oae.getObjStore();
int factoryType = oae.getFactoryType();
String lookupName = oae.getLookupName();
Properties objProps = oae.getObjProperties();
boolean readOnly = oae.isReadOnly();
boolean overwrite = false;
if (os.isOpen()) {
Object newObj = null;
try {
if (factoryType == ObjAdminEvent.QCF) {
newObj = JMSObjFactory.createQueueConnectionFactory(objProps);
} else if (factoryType == ObjAdminEvent.TCF) {
newObj = JMSObjFactory.createTopicConnectionFactory(objProps);
} else if (factoryType == ObjAdminEvent.CF) {
newObj = JMSObjFactory.createConnectionFactory(objProps);
} else if (factoryType == ObjAdminEvent.XAQCF) {
newObj = JMSObjFactory.createXAQueueConnectionFactory(objProps);
} else if (factoryType == ObjAdminEvent.XATCF) {
newObj = JMSObjFactory.createXATopicConnectionFactory(objProps);
} else if (factoryType == ObjAdminEvent.XACF) {
newObj = JMSObjFactory.createXAConnectionFactory(objProps);
}
} catch (Exception e) {
handleExceptions(e, acr.I_ADD_OBJSTORE_CF);
return;
}
/*
* Set this newly created obj to read-only if specified.
*/
if (readOnly) {
JMSObjFactory.doReadOnlyForAdd(newObj, "true");
} else {
JMSObjFactory.doReadOnlyForAdd(newObj, "false");
}
//
try {
object = os.retrieve(lookupName);
} catch (NameNotFoundException nnfe) {
// Make sure that this exception is NOT treated as an error for add
} catch (Exception ex) {
JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
// Object already exists so confirm with user.
if (object != null) {
int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_LOOKUP_NAME_EXISTS, lookupName), acr.getString(acr.I_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION) {
return;
} else {
overwrite = true;
}
}
try {
os.add(lookupName, newObj, true);
} catch (Exception ex) {
JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
/*
* If already exists, the delete old tree node before adding.
*/
if (overwrite) {
removeChild(selObj, lookupName);
removeChild((ConsoleObj) selObj.getParent().getChildAt(0), lookupName);
}
ObjStoreConFactoryCObj conFacCObj = new ObjStoreConFactoryCObj((ObjStoreCObj) selObj.getParent(), lookupName, newObj);
app.getExplorer().addToParent(selObj, conFacCObj);
app.getInspector().refresh();
app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_ADD_CF, lookupName, os.getID()));
if (oae.isOKAction()) {
objStoreConFactoryAddDialog.setVisible(false);
}
}
}
use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.
the class ObjStoreConFactoryPropsDialog method doOK.
@Override
public void doOK() {
String lookupName = lookupLabel.getText();
lookupName = lookupName.trim();
if (lookupName == null || lookupName.equals("")) {
JOptionPane.showOptionDialog(this, acr.getString(acr.E_NO_LOOKUP_NAME), acr.getString(acr.I_OBJSTORE_CF_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_NO_LOOKUP_NAME), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
int type = ObjAdminEvent.QCF;
AdministeredObject tempObj = null;
if (cfLabel.getText().equals(acr.getString(acr.I_QCF))) {
type = ObjAdminEvent.QCF;
tempObj = new com.sun.messaging.QueueConnectionFactory();
} else if (cfLabel.getText().equals(acr.getString(acr.I_TCF))) {
type = ObjAdminEvent.TCF;
tempObj = new com.sun.messaging.TopicConnectionFactory();
} else if (cfLabel.getText().equals(acr.getString(acr.I_CF))) {
type = ObjAdminEvent.CF;
tempObj = new com.sun.messaging.ConnectionFactory();
} else if (cfLabel.getText().equals(acr.getString(acr.I_XAQCF))) {
type = ObjAdminEvent.XAQCF;
tempObj = new com.sun.messaging.XAQueueConnectionFactory();
} else if (cfLabel.getText().equals(acr.getString(acr.I_XATCF))) {
type = ObjAdminEvent.XATCF;
tempObj = new com.sun.messaging.XATopicConnectionFactory();
} else if (cfLabel.getText().equals(acr.getString(acr.I_XACF))) {
type = ObjAdminEvent.XACF;
tempObj = new com.sun.messaging.XAConnectionFactory();
}
/*
* Conn Factory Object Properties. Go through each of the cfProps, get the userdata which is the property name, get the
* value, set it in props.
*/
Properties props = tempObj.getConfiguration();
String propName, propValue, propType = null, propLabel = null;
for (int i = 0; i < cfProps.size(); i++) {
LabelledComponent cfItem = (LabelledComponent) cfProps.elementAt(i);
propName = (String) cfItem.getClientData();
if (propName == null) {
continue;
}
// Remove this propName from the props, no longer applies.
if (!(cfItem.getComponent().isEnabled())) {
props.remove(propName);
continue;
}
try {
propType = tempObj.getPropertyType(propName);
propLabel = tempObj.getPropertyLabel(propName);
} catch (jakarta.jms.JMSException jmsex) {
JOptionPane.showOptionDialog(this, jmsex.toString(), acr.getString(acr.I_OBJSTORE_CF_PROPS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
if (propType == null) {
continue;
}
propValue = getValue(cfItem.getComponent(), propType).trim();
// so no need to set to "".
if (propValue.equals("")) {
continue;
}
try {
// Calling setProperty() will verify if this value is valid.
tempObj.setProperty(propName, propValue.trim());
props.put(propName, propValue.trim());
} catch (jakarta.jms.JMSException jmsex) {
if (jmsex instanceof com.sun.messaging.InvalidPropertyValueException) {
JOptionPane.showOptionDialog(this, acr.getString(acr.E_INVALID_VALUE, propLabel), acr.getString(acr.I_OBJSTORE_CF_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_INVALID_VALUE), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
} else {
JOptionPane.showOptionDialog(this, jmsex.toString(), acr.getString(acr.I_OBJSTORE_CF_PROPS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
}
return;
}
}
ObjAdminEvent oae = new ObjAdminEvent(this, ObjAdminEvent.UPDATE_CONN_FACTORY);
ObjStore os = osConFactoryCObj.getObjStore();
/*
* Set values in the event.
*/
oae.setLookupName(lookupName);
oae.setObjStore(os);
oae.setFactoryType(type);
oae.setObjProperties(props);
if (checkBox.isSelected()) {
oae.setReadOnly(true);
} else {
oae.setReadOnly(false);
}
oae.setOKAction(true);
fireAdminEventDispatched(oae);
}
use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.
the class ObjAdminHandler method doDisconnectObjStore.
private void doDisconnectObjStore(ConsoleObj selObj) {
ObjStore os = ((ObjStoreCObj) selObj).getObjStore();
if (!os.isOpen()) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_ALREADY_DISCONNECTED, selObj.toString()), acr.getString(acr.I_DISCONNECT_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_ALREADY_DISCONNECTED), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
try {
os.close();
} catch (Exception e) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_UNABLE_DISCONNECT, selObj.toString()), acr.getString(acr.I_DISCONNECT_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_UNABLE_DISCONNECT), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
/*
* Remove all destination/connection factory objects from this object store node hierarchy
*/
clearStore(selObj);
app.getExplorer().nodeChanged(selObj);
app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_DISCONNECT, selObj.toString()));
// XXX This causes selection to go away if selected in inspector
app.getInspector().refresh();
app.getInspector().selectedObjectUpdated();
// Update menu items, buttons.
controller.setActions(selObj);
}
use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.
the class ObjAdminHandler method doConnectObjStore.
private void doConnectObjStore(ConsoleObj selObj) {
ObjStore os = ((ObjStoreCObj) selObj).getObjStore();
if (os.isOpen()) {
JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_ALREADY_CONNECTED, selObj.toString()), acr.getString(acr.I_CONNECT_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_ALREADY_CONNECTED), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
/*
* Retrieve the original ObjStoreAttrs that the user input. This DOES NOT read any jndi property files processed by jndi
* since this is done PRIOR to creating the initialContext.
*/
ObjStoreAttrs osa = os.getObjStoreAttrs();
Vector missingAuthInfo = os.checkAuthentication(osa);
int missingAuthInfoSize = missingAuthInfo.size();
if (missingAuthInfoSize > 0) {
if (objStorePasswdDialog == null && missingAuthInfoSize > 0) {
objStorePasswdDialog = new ObjStorePasswdDialog(app.getFrame());
objStorePasswdDialog.addAdminEventListener(this);
objStorePasswdDialog.setLocationRelativeTo(app.getFrame());
}
if (missingAuthInfoSize > 0) {
objStorePasswdDialog.show(os, missingAuthInfo);
}
} else {
boolean success = finishDoConnectObjStore(selObj, os);
if (success) {
app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_CONNECT, selObj.toString()));
}
}
}
use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.
the class ObjAdminHandler method doAddDestination.
private void doAddDestination(ObjAdminEvent oae, ConsoleObj selObj) {
Object object = null;
ObjStore os = oae.getObjStore();
int destType = oae.getDestinationType();
String lookupName = oae.getLookupName();
Properties objProps = oae.getObjProperties();
boolean readOnly = oae.isReadOnly();
boolean overwrite = false;
if (os.isOpen()) {
Object newObj = null;
try {
if (destType == ObjAdminEvent.TOPIC) {
newObj = JMSObjFactory.createTopic(objProps);
} else if (destType == ObjAdminEvent.QUEUE) {
newObj = JMSObjFactory.createQueue(objProps);
}
} catch (Exception e) {
handleExceptions(e, acr.I_ADD_OBJSTORE_DEST);
return;
}
/*
* Set this newly created obj to read-only if specified.
*/
if (readOnly) {
JMSObjFactory.doReadOnlyForAdd(newObj, "true");
} else {
JMSObjFactory.doReadOnlyForAdd(newObj, "false");
}
//
try {
object = os.retrieve(lookupName);
} catch (NameNotFoundException nnfe) {
// Make sure that this exception is NOT treated as an error for add
} catch (Exception ex) {
JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_ADD_OBJSTORE_DEST), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
// Object already exists so confirm with user.
if (object != null) {
int result = JOptionPane.showConfirmDialog(app.getFrame(), acr.getString(acr.Q_LOOKUP_NAME_EXISTS, lookupName), acr.getString(acr.I_ADD_OBJSTORE_DEST), JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION) {
return;
} else {
overwrite = true;
}
}
try {
os.add(lookupName, newObj, true);
} catch (Exception ex) {
JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_ADD_OBJSTORE_DEST), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
}
/*
* If already exists, the delete old tree node before adding.
*/
if (overwrite) {
removeChild(selObj, lookupName);
removeChild((ConsoleObj) selObj.getParent().getChildAt(1), lookupName);
}
ObjStoreDestCObj destCObj = new ObjStoreDestCObj((ObjStoreCObj) selObj.getParent(), lookupName, newObj);
app.getExplorer().addToParent(selObj, destCObj);
app.getInspector().refresh();
app.getStatusArea().appendText(acr.getString(acr.S_OBJSTORE_ADD_DEST, lookupName, os.getID()));
if (oae.isOKAction()) {
objStoreDestAddDialog.setVisible(false);
}
}
}
Aggregations