}
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");
//
// Check if it already exists so we can confirm with user to
// overwrite.
//
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 (os != null) {
/*
* 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.hide();
}
}
}