Search in sources :

Example 21 with AdministeredObject

use of com.sun.messaging.AdministeredObject in project openmq by eclipse-ee4j.

the class ObjStoreConFactoryAddDialog method doReset.

@Override
public void doReset() {
    // Reset the look up name and factory type.
    lookupText.setText("");
    factoryCombo.setSelectedItem(acr.getString(acr.I_CF));
    checkBox.setSelected(false);
    // 
    // Go through each of the items, get the userData which is
    // the property name, then get the default value from a
    // temporary object.
    // 
    AdministeredObject tempObj = new com.sun.messaging.QueueConnectionFactory();
    // Properties props = tempObj.getConfiguration();
    String propName = null, propType = null;
    String defaultValue = null;
    for (int i = 0; i < cfProps.size(); i++) {
        LabelledComponent cfItem = (LabelledComponent) cfProps.elementAt(i);
        JComponent comp = cfItem.getComponent();
        propName = (String) cfItem.getClientData();
        if (propName != null) {
            try {
                // gets, InvalidPropertyException.
                if (comp.isEnabled()) {
                    propType = tempObj.getPropertyType(propName);
                    defaultValue = tempObj.getProperty(propName);
                    setValue(comp, propType, defaultValue);
                    // setting.
                    if (comp instanceof JComboBox) {
                        doComboBox((JComboBox) comp);
                    }
                }
            } catch (Exception e) {
                System.err.println(e.toString() + ": " + propName);
            }
        }
    }
    // XXX Bad
    AdministeredObject tempObj2 = new com.sun.messaging.QueueConnectionFactory();
    setOtherValues(tempObj2, false);
    lookupText.requestFocus();
}
Also used : AdministeredObject(com.sun.messaging.AdministeredObject) LabelledComponent(com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent)

Example 22 with AdministeredObject

use of com.sun.messaging.AdministeredObject in project openmq by eclipse-ee4j.

the class ObjStoreConFactoryAddDialog method doOK.

@Override
public void doOK() {
    /*
         * Lookup Name
         */
    String lookupName = lookupText.getText();
    lookupName = lookupName.trim();
    if (lookupName == null || lookupName.equals("")) {
        JOptionPane.showOptionDialog(this, acr.getString(acr.E_NO_LOOKUP_NAME), acr.getString(acr.I_ADD_OBJSTORE_CF) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_NO_LOOKUP_NAME), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return;
    }
    /*
         * Factory Type
         */
    int type = ObjAdminEvent.CF;
    AdministeredObject tempObj = null;
    String factory = (String) factoryCombo.getSelectedItem();
    if (factory.equals(acr.getString(acr.I_QCF))) {
        type = ObjAdminEvent.QCF;
        tempObj = new com.sun.messaging.QueueConnectionFactory();
    } else if (factory.equals(acr.getString(acr.I_TCF))) {
        type = ObjAdminEvent.TCF;
        tempObj = new com.sun.messaging.TopicConnectionFactory();
    } else if (factory.equals(acr.getString(acr.I_CF))) {
        type = ObjAdminEvent.CF;
        tempObj = new com.sun.messaging.ConnectionFactory();
    } else if (factory.equals(acr.getString(acr.I_XAQCF))) {
        type = ObjAdminEvent.XAQCF;
        tempObj = new com.sun.messaging.XAQueueConnectionFactory();
    } else if (factory.equals(acr.getString(acr.I_XATCF))) {
        type = ObjAdminEvent.XATCF;
        tempObj = new com.sun.messaging.XATopicConnectionFactory();
    } else if (factory.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;
        }
        if (!(cfItem.getComponent().isEnabled())) {
            props.remove(propName);
            continue;
        }
        // associated properties or exception will occur.
        try {
            propType = tempObj.getPropertyType(propName);
            propLabel = tempObj.getPropertyLabel(propName);
        } catch (jakarta.jms.JMSException jmsex) {
            JOptionPane.showOptionDialog(this, jmsex.toString(), acr.getString(acr.I_ADD_OBJSTORE_CF), 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);
            props.put(propName, propValue);
        } 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_ADD_OBJSTORE_CF) + ": " + 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_ADD_OBJSTORE_CF), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            }
            return;
        }
    }
    ObjAdminEvent oae = new ObjAdminEvent(this, ObjAdminEvent.ADD_CONN_FACTORY);
    ObjStore os = osCObj.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);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjAdminEvent(com.sun.messaging.jmq.admin.apps.console.event.ObjAdminEvent) Properties(java.util.Properties) AdministeredObject(com.sun.messaging.AdministeredObject) LabelledComponent(com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent)

Example 23 with AdministeredObject

use of com.sun.messaging.AdministeredObject in project openmq by eclipse-ee4j.

the class ObjStoreConFactoryPropsDialog method show.

public void show(ObjStoreConFactoryCObj osConFactoryCObj) {
    this.osConFactoryCObj = osConFactoryCObj;
    // 
    // Set fields to current object values.
    // 
    lookupLabel.setText(osConFactoryCObj.getLookupName());
    Object object = osConFactoryCObj.getObject();
    if (object instanceof com.sun.messaging.XAQueueConnectionFactory) {
        cfLabel.setText(acr.getString(acr.I_XAQCF));
    } else if (object instanceof com.sun.messaging.XATopicConnectionFactory) {
        cfLabel.setText(acr.getString(acr.I_XATCF));
    } else if (object instanceof com.sun.messaging.XAConnectionFactory) {
        cfLabel.setText(acr.getString(acr.I_XACF));
    } else if (object instanceof com.sun.messaging.QueueConnectionFactory) {
        cfLabel.setText(acr.getString(acr.I_QCF));
    } else if (object instanceof com.sun.messaging.TopicConnectionFactory) {
        cfLabel.setText(acr.getString(acr.I_TCF));
    } else if (object instanceof com.sun.messaging.ConnectionFactory) {
        cfLabel.setText(acr.getString(acr.I_CF));
    }
    // 
    // Go through each of the component items, get the clientData
    // which is the property name, then get the value of the
    // property from the current adminObj.
    // 
    String propName = null;
    String propType = null;
    String value = null;
    AdministeredObject adminObj = (AdministeredObject) object;
    for (int i = 0; i < cfProps.size(); i++) {
        LabelledComponent cfItem = (LabelledComponent) cfProps.elementAt(i);
        JComponent comp = cfItem.getComponent();
        propName = (String) cfItem.getClientData();
        if (propName == null) {
            continue;
        }
        try {
            if (comp.isEnabled()) {
                propType = adminObj.getPropertyType(propName);
                value = adminObj.getProperty(propName);
                setValue(comp, propType, value);
                // setting.
                if (comp instanceof JComboBox) {
                    doComboBox((JComboBox) comp);
                }
            }
        } catch (Exception e) {
            System.err.println(e.toString() + ": " + propName);
        }
    }
    // now we should be able to set values.
    AdministeredObject tempObj2 = new com.sun.messaging.QueueConnectionFactory();
    setOtherValues(tempObj2, true);
    // Set read-only box
    if (adminObj.isReadOnly()) {
        checkBox.setSelected(true);
    } else {
        checkBox.setSelected(false);
    }
    /*
         * Set focus to first text item. if (props.size() > 0) textItems[0].requestFocus();
         */
    // Go back to first tab.
    tabbedPane.setSelectedIndex(0);
    setVisible(true);
}
Also used : JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) AdministeredObject(com.sun.messaging.AdministeredObject) LabelledComponent(com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent) AdministeredObject(com.sun.messaging.AdministeredObject)

Example 24 with AdministeredObject

use of com.sun.messaging.AdministeredObject in project openmq by eclipse-ee4j.

the class JMSObjFactory method createQueueConnectionFactory.

/**
 * Create a JMS Queue Connection Factory.
 *
 * <P>
 * No verification of valid param values are needed at this point because the assumption is that valid values were
 * checked before this was called.
 *
 * @param objProps the set of Properties to be set when the JMS Queue Connection Factory is created.
 * @return the com.sun.messaging.QueueConnectionFactory
 */
public static Object createQueueConnectionFactory(Properties objProps) throws JMSException {
    AdministeredObject obj = null;
    obj = new com.sun.messaging.QueueConnectionFactory();
    setProperties(obj, objProps);
    return (obj);
}
Also used : AdministeredObject(com.sun.messaging.AdministeredObject)

Example 25 with AdministeredObject

use of com.sun.messaging.AdministeredObject in project openmq by eclipse-ee4j.

the class JMSObjFactory method updateConnectionFactory.

public static Object updateConnectionFactory(Object oldObj, Properties objProps, String readOnlyValue) throws JMSException {
    AdministeredObject newObj = null;
    newObj = new com.sun.messaging.ConnectionFactory();
    if (oldObj instanceof AdministeredObject) {
        updateAdministeredObject((AdministeredObject) oldObj, newObj, objProps, readOnlyValue);
    }
    return (newObj);
}
Also used : AdministeredObject(com.sun.messaging.AdministeredObject)

Aggregations

AdministeredObject (com.sun.messaging.AdministeredObject)32 Properties (java.util.Properties)9 ObjStore (com.sun.messaging.jmq.admin.objstore.ObjStore)6 Enumeration (java.util.Enumeration)6 LabelledComponent (com.sun.messaging.jmq.admin.apps.console.util.LabelledComponent)5 ObjAdminEvent (com.sun.messaging.jmq.admin.apps.console.event.ObjAdminEvent)4 InvalidPropertyException (com.sun.messaging.InvalidPropertyException)3 InvalidPropertyValueException (com.sun.messaging.InvalidPropertyValueException)3 ReadOnlyPropertyException (com.sun.messaging.ReadOnlyPropertyException)3 ObjStoreAttrs (com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)3 JComponent (javax.swing.JComponent)3 AuthenticationException (com.sun.messaging.jmq.admin.objstore.AuthenticationException)2 AuthenticationNotSupportedException (com.sun.messaging.jmq.admin.objstore.AuthenticationNotSupportedException)2 CommunicationException (com.sun.messaging.jmq.admin.objstore.CommunicationException)2 GeneralNamingException (com.sun.messaging.jmq.admin.objstore.GeneralNamingException)2 InitializationException (com.sun.messaging.jmq.admin.objstore.InitializationException)2 NameAlreadyExistsException (com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)2 NameNotFoundException (com.sun.messaging.jmq.admin.objstore.NameNotFoundException)2 NoPermissionException (com.sun.messaging.jmq.admin.objstore.NoPermissionException)2 ObjStoreException (com.sun.messaging.jmq.admin.objstore.ObjStoreException)2