use of com.sun.messaging.AdministeredObject in project openmq by eclipse-ee4j.
the class ObjStoreConFactoryDialog method createWorkPanel.
@Override
public JPanel createWorkPanel() {
boolean propsDlg = false;
if (getTitle().equals(acr.getString(acr.I_OBJSTORE_CF_PROPS))) {
propsDlg = true;
}
JPanel workPanel = new JPanel();
JPanel topPanel = makeTopPanel(propsDlg);
AdministeredObject aobj = new com.sun.messaging.QueueConnectionFactory();
// Get the groups for this admin obj.
String groupString = aobj.getPropertyGroups();
String[] groups = stringToArray(groupString, "|");
if (groups == null) {
return workPanel;
}
GridBagLayout gridbag = new GridBagLayout();
workPanel.setLayout(gridbag);
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(topPanel, c);
workPanel.add(topPanel);
tabbedPane = new JTabbedPane();
cfProps = new Vector();
// Then create a separate panel of properties for each group.
for (int i = 0; i < groups.length; i++) {
String groupName = aobj.getLabelForGroup(groups[i]);
String groupPropsString = aobj.getPropertiesForGroup(groups[i]);
String[] props = stringToArray(groupPropsString, "|");
JPanel groupPanel = layoutGroupProperties(props, aobj);
// Add to tabbed pane.
if (groupPanel != null) {
tabbedPane.addTab(groupName, groupPanel);
}
}
// Add the Tabbed Pane.
c.gridx = 0;
c.gridy = 1;
c.anchor = GridBagConstraints.NORTHWEST;
c.insets = new Insets(0, 0, 0, 0);
gridbag.setConstraints(tabbedPane, c);
workPanel.add(tabbedPane);
// in case it's very long.
if (propsDlg) {
int maxWidth = tabbedPane.getPreferredSize().width;
Dimension dim = new Dimension(maxWidth - lookupItem.getLabelWidth() - 40, lookupLabel.getPreferredSize().height);
lookupItem.getComponent().setPreferredSize(dim);
}
return (workPanel);
}
use of com.sun.messaging.AdministeredObject 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.AdministeredObject in project openmq by eclipse-ee4j.
the class ObjStoreDestAddDialog method resetValues.
/*
* Reset back to default values.
*/
private void resetValues() {
//
// Reset fields for an Add
//
lookupText.setText("");
queueButton.setSelected(true);
checkBox.setSelected(false);
//
// Create a temp object and set its default values in the
// text fields.
//
AdministeredObject tempObj = new com.sun.messaging.Queue();
int i = 0;
for (Enumeration e = tempObj.enumeratePropertyNames(); e.hasMoreElements(); i++) {
String propName = (String) e.nextElement();
try {
textItems[i].setText(tempObj.getProperty(propName));
} catch (Exception ex) {
textItems[i].setText("");
}
}
lookupText.requestFocus();
}
use of com.sun.messaging.AdministeredObject in project openmq by eclipse-ee4j.
the class AdministeredObjectFactory method getObjectInstance.
/**
* Creates an instance of the object represented by a Reference object.
*
* @param obj The Reference object.
*
* @return an instance of the class named in the Reference object <code>obj</code>,
* null if <code>obj</code> is not an instance of a Reference object.
*
* @throws MissingVersionNumberException if either <code>obj</code> references an object that is not an instance of a
* <code>com.sun.messaging.AdministeredObject</code> object or the version number is missing from the Reference object.
* @throws UnsupportedVersionNumberException if an unsupported version number is present in the Reference.
* @throws CorruptedConfigurationPropertiesException if <code>obj</code> does not have the minimum information
* neccessary to recreate an instance of a a valid <code>com.sun.messaging.AdministeredObject</code>.
*/
@Override
public Object getObjectInstance(Object obj, Name name, Context ctx, Hashtable env) throws Exception {
if (obj instanceof Reference) {
Reference ref = (Reference) obj;
String version = null;
boolean readOnly = false;
// Construct the desired AdministeredObject
Object newobj = Class.forName(ref.getClassName()).getDeclaredConstructor().newInstance();
// version number MUST exist and it MUST be this version or a supported version
RefAddr versionAddr = ref.get(REF_VERSION);
// Support reading previous object versions here (2.0, 2.1 etc.). Floor is 2.0
if (versionAddr == null || !(newobj instanceof com.sun.messaging.AdministeredObject)) {
// if version number does not exist or it is not an AdministeredObject
throw new MissingVersionNumberException();
} else {
version = (String) versionAddr.getContent();
// Support reading previous object versions here (2.0, 2.1 etc.). Floor is 2.0
if (!(AO_VERSION_STR.equals(version) || AO_VERSION_STR_JMQ3B.equals(version) || AO_VERSION_STR_JMQ2.equals(version))) {
// Reference contains a bad version number
throw new UnsupportedVersionNumberException(version);
}
if (ref.size() < 2) {
// Reference is corrupted
throw new CorruptedConfigurationPropertiesException();
}
RefAddr readOnlyAddr = ref.get(REF_READONLY);
if ("true".equals(readOnlyAddr.getContent())) {
// Reference has readOnly set
readOnly = true;
}
((AdministeredObject) newobj).setStoredVersion(version);
}
RefAddr refaddr;
String refContent;
// System.out.println("AOtoString="+ newobj.toString());
for (int i = 2; i < ref.size(); i++) {
refaddr = ref.get(i);
refContent = (String) refaddr.getContent();
// Some service-providers will return `null'; others will return "" (empty string)
if (refContent == null) {
refContent = "";
}
// If property fails to set then ignore since we may have looked up a newer object
try {
// XXX RFE:tharakan
// Need to add support migrating 2.x properties to 3.x
// System.out.println("gOI:settingProp");
// System.out.println("gOI:propName="+refaddr.getType());
((AdministeredObject) newobj).setProperty(refaddr.getType(), refContent);
// System.out.println("gOI:propName="+refaddr.getType()+" set successfully");
} catch (Exception bpe) {
// Ignore exception
// System.out.println("gOI:propName="+refaddr.getType()+" exception; "+bpe.getMessage());
// bpe.printStackTrace();
}
}
// Set the readOnly flag
if (readOnly) {
((AdministeredObject) newobj).setReadOnly();
}
return newobj;
}
return null;
}
use of com.sun.messaging.AdministeredObject in project openmq by eclipse-ee4j.
the class JMSAdminImpl method createXAConnectionFactoryObject.
/**
* Create a XAConnectionFactory administered object
*
* @param type Either QUEUE or TOPIC.
* @param properties Connection specific properties.
* @return New created JMSXAConnectionFactory administered object. ^^^^^
* @exception JMSException thrown if XAConnectionFactory could not be created.
*/
@Override
public Object createXAConnectionFactoryObject(int type, java.util.Map properties) throws JMSException {
Object xcf = null;
Properties tmpProps = getProperties(properties);
fillDefaultConnectionFactoryProperties(tmpProps);
if (type == TOPIC) {
xcf = new com.sun.messaging.jmq.jmsclient.JMSXATopicConnectionFactoryImpl();
setProperties((AdministeredObject) xcf, tmpProps);
} else if (type == QUEUE) {
xcf = new com.sun.messaging.jmq.jmsclient.JMSXAQueueConnectionFactoryImpl();
setProperties((AdministeredObject) xcf, tmpProps);
} else {
throw new jakarta.jms.JMSException(ar.getKString(ar.X_JMSSPI_INVALID_DOMAIN_TYPE));
}
return xcf;
}
Aggregations