Search in sources :

Example 16 with ObjStore

use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.

the class ObjStoreDestAddDialog 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_DEST) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_NO_LOOKUP_NAME), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return;
    }
    /*
         * Destination Type
         */
    int type = ObjAdminEvent.QUEUE;
    AdministeredObject tempObj = null;
    if (queueButton.isSelected()) {
        type = ObjAdminEvent.QUEUE;
        tempObj = new com.sun.messaging.Queue();
    } else if (topicButton.isSelected()) {
        type = ObjAdminEvent.TOPIC;
        tempObj = new com.sun.messaging.Topic();
    }
    /*
         * Object Properties (dest name, ...);
         */
    int i = 0;
    Properties props = tempObj.getConfiguration();
    for (Enumeration e = tempObj.enumeratePropertyNames(); e.hasMoreElements(); i++) {
        String propName = (String) e.nextElement();
        String value = textItems[i].getText();
        value = value.trim();
        // so no need to set to "".
        if (!(value.trim()).equals("")) {
            props.put(propName, value);
        }
    }
    ObjAdminEvent oae = new ObjAdminEvent(this, ObjAdminEvent.ADD_DESTINATION);
    ObjStore os = osCObj.getObjStore();
    /*
         * Set values in the event.
         */
    oae.setLookupName(lookupName);
    oae.setObjStore(os);
    oae.setDestinationType(type);
    oae.setObjProperties(props);
    if (checkBox.isSelected()) {
        oae.setReadOnly(true);
    } else {
        oae.setReadOnly(false);
    }
    oae.setOKAction(true);
    fireAdminEventDispatched(oae);
}
Also used : AdministeredObject(com.sun.messaging.AdministeredObject) Enumeration(java.util.Enumeration) ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjAdminEvent(com.sun.messaging.jmq.admin.apps.console.event.ObjAdminEvent) Properties(java.util.Properties)

Example 17 with ObjStore

use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.

the class ConsoleObjStoreManager method writeObjStoresToFile.

/**
 * Writes ObjStores to files.
 */
public void writeObjStoresToFile() throws UserPropertiesException {
    // Must call ObjStoreAttrs.prepareToTerminate() prior to
    // storing
    Enumeration e = objStores.elements();
    ObjStoreListProperties oslProps = new ObjStoreListProperties();
    while (e.hasMoreElements()) {
        ObjStore os = (ObjStore) e.nextElement();
        ObjStoreAttrs osa = os.getObjStoreAttrs();
        osa.prepareToTerminate();
        oslProps.addObjStoreAttrs(osa);
    }
    writeToFile(oslProps);
}
Also used : Enumeration(java.util.Enumeration) ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)

Example 18 with ObjStore

use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.

the class ObjAdminHandler method loadObjStoreList.

/*
     * Load objstore list from property file. See ConsoleObjStoreManager and ObjStoreListProperties for details on the
     * actual file loading.
     */
private void loadObjStoreList() {
    ConsoleObjStoreManager osMgr;
    osMgr = (ConsoleObjStoreManager) app.getObjStoreListCObj().getObjStoreManager();
    try {
        osMgr.setFileName(OBJSTORELIST_FILENAME);
        osMgr.readObjStoresFromFile();
    } catch (Exception ex) {
        String errStr = acr.getString(acr.E_LOAD_OBJSTORE_LIST, ex.getMessage());
        /*
             * Show popup to indicate that the loading failed.
             */
        JOptionPane.showOptionDialog(app.getFrame(), errStr, acr.getString(acr.I_LOAD_OBJSTORE_LIST) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_LOAD_OBJSTORE_LIST), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
    /*
             * At this point, should we make sure the ConsoleObjStoreManager contains no obj stores ?
             */
    }
    Vector v = osMgr.getAllStores();
    for (int i = 0; i < v.size(); i++) {
        ObjStore os = (ObjStore) v.get(i);
        ConsoleObj osCObj = new ObjStoreCObj(os);
        if (os.isOpen()) {
            readObjStore(osCObj, os);
        }
        app.getExplorer().addObjStore(osCObj);
    }
    app.getInspector().refresh();
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) Vector(java.util.Vector) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)

Example 19 with ObjStore

use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.

the class ObjAdminHandler method handleDialogEvents.

/*
     * END INTERFACE AdminEventListener
     */
public void handleDialogEvents(DialogEvent de) {
    ConsoleObj selObj = app.getSelectedObj();
    int dialogType = de.getDialogType();
    switch(dialogType) {
        case DialogEvent.ADD_DIALOG:
            if (selObj instanceof ObjStoreListCObj) {
                if (objStoreAddDialog == null) {
                    objStoreAddDialog = new ObjStoreAddDialog(app.getFrame(), (ObjStoreListCObj) selObj);
                    objStoreAddDialog.addAdminEventListener(this);
                    objStoreAddDialog.setLocationRelativeTo(app.getFrame());
                }
                objStoreAddDialog.setVisible(true);
            } else if (selObj instanceof ObjStoreDestListCObj) {
                if (objStoreDestAddDialog == null) {
                    objStoreDestAddDialog = new ObjStoreDestAddDialog(app.getFrame());
                    objStoreDestAddDialog.addAdminEventListener(this);
                    objStoreDestAddDialog.setLocationRelativeTo(app.getFrame());
                }
                // This should't happen - menu item should be disabled.
                ObjStore os = ((ObjStoreDestListCObj) selObj).getObjStore();
                if (!os.isOpen()) {
                    JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OBJSTORE_NOT_CONNECTED, os.getID()), acr.getString(acr.I_ADD_OBJSTORE_DEST) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OBJSTORE_NOT_CONNECTED), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
                }
                objStoreDestAddDialog.show((ObjStoreDestListCObj) selObj);
            } else if (selObj instanceof ObjStoreConFactoryListCObj) {
                if (objStoreConFactoryAddDialog == null) {
                    objStoreConFactoryAddDialog = new ObjStoreConFactoryAddDialog(app.getFrame());
                    objStoreConFactoryAddDialog.addAdminEventListener(this);
                    objStoreConFactoryAddDialog.setLocationRelativeTo(app.getFrame());
                }
                // This should't happen - menu item should be disabled.
                ObjStore os = ((ObjStoreConFactoryListCObj) selObj).getObjStore();
                if (!os.isOpen()) {
                    JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OBJSTORE_NOT_CONNECTED, os.getID()), acr.getString(acr.I_ADD_OBJSTORE_CF) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OBJSTORE_NOT_CONNECTED), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
                    return;
                }
                objStoreConFactoryAddDialog.show((ObjStoreConFactoryListCObj) selObj);
            }
            break;
        case DialogEvent.DELETE_DIALOG:
            if (selObj instanceof ObjStoreCObj) {
                doDeleteObjStore(selObj);
            } else if (selObj instanceof ObjStoreDestCObj) {
                doDeleteDestination(selObj);
            } else if (selObj instanceof ObjStoreConFactoryCObj) {
                doDeleteConnFactory(selObj);
            }
            break;
        case DialogEvent.PROPS_DIALOG:
            if (selObj instanceof ObjStoreCObj) {
                if (objStorePropsDialog == null) {
                    ObjStoreCObj osCObj = (ObjStoreCObj) selObj;
                    ObjStoreListCObj oslCObj = (ObjStoreListCObj) osCObj.getParent();
                    objStorePropsDialog = new ObjStorePropsDialog(app.getFrame(), oslCObj);
                    objStorePropsDialog.addAdminEventListener(this);
                    objStorePropsDialog.setLocationRelativeTo(app.getFrame());
                }
                objStorePropsDialog.show((ObjStoreCObj) selObj);
            } else if (selObj instanceof ObjStoreDestCObj) {
                if (objStoreDestPropsDialog == null) {
                    objStoreDestPropsDialog = new ObjStoreDestPropsDialog(app.getFrame());
                    objStoreDestPropsDialog.addAdminEventListener(this);
                    objStoreDestPropsDialog.setLocationRelativeTo(app.getFrame());
                }
                // This should't happen - menu item should be disabled.
                ObjStore os = ((ObjStoreDestCObj) selObj).getObjStore();
                if (!os.isOpen()) {
                    JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OBJSTORE_NOT_CONNECTED, os.getID()), acr.getString(acr.I_OBJSTORE_DEST_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OBJSTORE_NOT_CONNECTED), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
                    return;
                }
                objStoreDestPropsDialog.show((ObjStoreDestCObj) selObj);
            } else if (selObj instanceof ObjStoreConFactoryCObj) {
                if (objStoreConFactoryPropsDialog == null) {
                    objStoreConFactoryPropsDialog = new ObjStoreConFactoryPropsDialog(app.getFrame());
                    objStoreConFactoryPropsDialog.addAdminEventListener(this);
                    objStoreConFactoryPropsDialog.setLocationRelativeTo(app.getFrame());
                }
                // This should't happen - menu item should be disabled.
                ObjStore os = ((ObjStoreConFactoryCObj) selObj).getObjStore();
                if (!os.isOpen()) {
                    JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OBJSTORE_NOT_CONNECTED, os.getID()), acr.getString(acr.I_OBJSTORE_CF_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OBJSTORE_NOT_CONNECTED), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
                    return;
                }
                objStoreConFactoryPropsDialog.show((ObjStoreConFactoryCObj) selObj);
            }
            break;
        case DialogEvent.CONNECT_DIALOG:
            if (selObj instanceof ObjStoreCObj) {
                doConnectObjStore(selObj);
            }
            break;
        case DialogEvent.DISCONNECT_DIALOG:
            if (selObj instanceof ObjStoreCObj) {
                doDisconnectObjStore(selObj);
            }
            break;
        case DialogEvent.HELP_DIALOG:
            JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.I_NO_HELP), acr.getString(acr.I_HELP_TEXT), JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, close, close[0]);
            break;
        case DialogEvent.SHUTDOWN_DIALOG:
        case DialogEvent.RESTART_DIALOG:
        case DialogEvent.PAUSE_DIALOG:
        case DialogEvent.RESUME_DIALOG:
            /*
             * No shutdown/restart/pause/resume for obj admin
             */
            break;
    }
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore)

Example 20 with ObjStore

use of com.sun.messaging.jmq.admin.objstore.ObjStore in project openmq by eclipse-ee4j.

the class ObjAdminHandler method updateStore.

private ObjStore updateStore(ObjStore prevOs, String newName, ObjStoreManager osMgr, ObjStoreAttrs osa, boolean attemptToConnect) {
    ObjStore os = null;
    boolean created = false;
    if (osMgr == null || osa == null) {
        JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_PROCESS), acr.getString(acr.I_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_PROCESS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return (null);
    }
    /*
         * Update ObjStore
         */
    ObjStoreAttrs prevAttrs = prevOs.getObjStoreAttrs();
    os = osMgr.getStore(prevOs.getID());
    if (os == null) {
        JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_OS_PROCESS), acr.getString(acr.I_OBJSTORE) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_OS_PROCESS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
    }
    // 
    try {
        if (newName != null && os != null && !newName.equals(os.getID())) {
            os = osMgr.createStore(osa);
            created = true;
        } else if (os != null) {
            os.setObjStoreAttrs(osa);
        }
    } catch (Exception ex) {
        JOptionPane.showOptionDialog(app.getFrame(), ex.toString(), acr.getString(acr.I_OBJSTORE_PROPS), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
        return null;
    }
    /*
         * Now try connecting to it (if they want to try). Then read in the objects from the store.
         */
    if (attemptToConnect) {
        try {
            if (os != null) {
                os.open();
            }
        } catch (Exception e) {
            JOptionPane.showOptionDialog(app.getFrame(), acr.getString(acr.E_INSUFFICIENT_INFO, e.toString()), acr.getString(acr.I_OBJSTORE_PROPS) + ": " + acr.getString(acr.I_ERROR_CODE, AdminConsoleResources.E_INSUFFICIENT_INFO), JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, close, close[0]);
            // Don't update it, undo everything
            try {
                if (created) {
                    osMgr.destroyStore(osa.getID());
                } else {
                    // Reset old attrs back
                    os.setObjStoreAttrs(prevAttrs);
                }
            } catch (Exception ex) {
            }
            return null;
        }
    }
    // 
    if (os != null && created) {
        try {
            if (prevOs.isOpen()) {
                prevOs.close();
            }
            osMgr.destroyStore(prevOs.getID());
            if (!attemptToConnect && os.isOpen()) {
                os.close();
            }
        } catch (Exception ex) {
        }
    }
    // 
    if (os != null && !attemptToConnect && os.isOpen()) {
        try {
            os.close();
        } catch (Exception ex) {
        }
    }
    return (os);
}
Also used : ObjStore(com.sun.messaging.jmq.admin.objstore.ObjStore) ObjStoreAttrs(com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs) InvalidPropertyException(com.sun.messaging.InvalidPropertyException) InvalidPropertyValueException(com.sun.messaging.InvalidPropertyValueException) ObjStoreException(com.sun.messaging.jmq.admin.objstore.ObjStoreException) AuthenticationException(com.sun.messaging.jmq.admin.objstore.AuthenticationException) NameNotFoundException(com.sun.messaging.jmq.admin.objstore.NameNotFoundException) NameAlreadyExistsException(com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)

Aggregations

ObjStore (com.sun.messaging.jmq.admin.objstore.ObjStore)29 ObjStoreException (com.sun.messaging.jmq.admin.objstore.ObjStoreException)17 NameNotFoundException (com.sun.messaging.jmq.admin.objstore.NameNotFoundException)16 InvalidPropertyException (com.sun.messaging.InvalidPropertyException)15 InvalidPropertyValueException (com.sun.messaging.InvalidPropertyValueException)15 AuthenticationException (com.sun.messaging.jmq.admin.objstore.AuthenticationException)15 NameAlreadyExistsException (com.sun.messaging.jmq.admin.objstore.NameAlreadyExistsException)15 ObjStoreAttrs (com.sun.messaging.jmq.admin.objstore.ObjStoreAttrs)13 AdministeredObject (com.sun.messaging.AdministeredObject)8 Properties (java.util.Properties)8 ReadOnlyPropertyException (com.sun.messaging.ReadOnlyPropertyException)5 AuthenticationNotSupportedException (com.sun.messaging.jmq.admin.objstore.AuthenticationNotSupportedException)5 CommunicationException (com.sun.messaging.jmq.admin.objstore.CommunicationException)5 GeneralNamingException (com.sun.messaging.jmq.admin.objstore.GeneralNamingException)5 InitializationException (com.sun.messaging.jmq.admin.objstore.InitializationException)5 NoPermissionException (com.sun.messaging.jmq.admin.objstore.NoPermissionException)5 SchemaViolationException (com.sun.messaging.jmq.admin.objstore.SchemaViolationException)5 MissingVersionNumberException (com.sun.messaging.naming.MissingVersionNumberException)5 UnsupportedVersionNumberException (com.sun.messaging.naming.UnsupportedVersionNumberException)5 ObjAdminEvent (com.sun.messaging.jmq.admin.apps.console.event.ObjAdminEvent)4