teiid SVN: r689 - in trunk: console/src/main/java/com/metamatrix/console/ui/dialog and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-01 17:41:45 -0400 (Wed, 01 Apr 2009)
New Revision: 689
Removed:
trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleRuntimeException.java
trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/ErrorDialog.java
Modified:
trunk/console/src/main/java/com/metamatrix/console/ui/dialog/ErrorDialog.java
trunk/console/src/main/java/com/metamatrix/console/util/ExceptionUtility.java
trunk/console/src/main/java/com/metamatrix/toolbox/ui/…
[View More]widget/tree/DefaultTreeModel.java
Log:
removing multiple runtime exception
Deleted: trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleRuntimeException.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleRuntimeException.java 2009-04-01 21:08:15 UTC (rev 688)
+++ trunk/common-core/src/main/java/com/metamatrix/api/exception/MultipleRuntimeException.java 2009-04-01 21:41:45 UTC (rev 689)
@@ -1,235 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.api.exception;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * MultipleRuntimeException is intended for situations where multiple, unrelated Throwables need to be thrown as a single
- * RuntimeException. This is useful, for example, when an Exception is thrown in both the try and finally portions of a try-
- * finally block. The Throwables are maintained within a list to allow them to be ordered by level of importance, with the first
- * Throwable having the highest importance.
- * @since 2.1
- */
-public class MultipleRuntimeException extends RuntimeException
-implements Serializable {
- //############################################################################################################################
- //# Variables #
- //############################################################################################################################
-
- private List throwables;
- private String code;
-
- //############################################################################################################################
- //# Constructors #
- //############################################################################################################################
-
- /**
- * Constructs an instance of this class with no message, a zero error code, and no Throwables.
- * @since 2.1
- */
- public MultipleRuntimeException() {
- this(null, null, (List)null);
- }
-
- /**
- Constructs an instance of this class with the specified message, a zero error code, and no Throwables.
- @param message The message describing this Exception
- @since 2.1
- */
- public MultipleRuntimeException(final String message) {
- this(message, null, (List)null);
- }
-
- /**
- Constructs an instance of this class with no message, a zero error code, and the specified set of Throwables.
- @param throwables The list of Throwables that comprise this Exception
- @since 2.1
- */
- public MultipleRuntimeException(final List throwables) {
- this(null, null, throwables);
- }
-
- /**
- Constructs an instance of this class with no message, a zero error code, and the specified set of Throwables.
- @param throwables The list of Throwables that comprise this Exception
- @since 2.1
- */
- public MultipleRuntimeException(final Throwable[] throwables) {
- this(null, null, Arrays.asList(throwables));
- }
-
- /**
- Constructs an instance of this class with the specified message, the specified error code, and no Throwables.
- @param message The message describing this Exception
- @param code The error code associated with this Exception
- @since 2.1
- */
- public MultipleRuntimeException(final String message, final String code) {
- this(message, code, (List)null);
- }
-
- /**
- Constructs an instance of this class with the specified message, a zero error code, and the specified set of Throwables.
- @param message The message describing this Exception
- @param throwables The list of Throwables that comprise this Exception
- @since 2.1
- */
- public MultipleRuntimeException(final String message, final List throwables) {
- this(message, null, throwables);
- }
-
- /**
- Constructs an instance of this class with the specified message, a zero error code, and the specified set of Throwables.
- @param message The message describing this Exception
- @param throwables The list of Throwables that comprise this Exception
- @since 2.1
- */
- public MultipleRuntimeException(final String message, final Throwable[] throwables) {
- this(message, null, Arrays.asList(throwables));
- }
-
- /**
- Constructs an instance of this class with the specified message, the specified error code, and the specified set of
- Throwables.
- @param message The message describing this Exception
- @param code The error code associated with this Exception
- @param throwables The list of Throwables that comprise this Exception
- @since 2.1
- */
- public MultipleRuntimeException(final String message, final String code, final Throwable[] throwables) {
- this(message, code, Arrays.asList(throwables));
- }
-
- /**
- Constructs an instance of this class with the specified message, the specified error code, and the specified set of
- Throwables.
- @param message The message describing this Exception
- @param code The error code associated with this Exception
- @param throwables The list of Throwables that comprise this Exception
- @since 2.1
- */
- public MultipleRuntimeException(final String message, final String code, final List throwables) {
- super(message);
- constructMultipleRuntimeException(code, throwables);
- }
-
- //############################################################################################################################
- //# Methods #
- //############################################################################################################################
-
- /**
- Adds the specified Throwable to the list of Throwables that comprise this Exception.
- @param throwable The Throwable
- @since 2.1
- */
- public void addThrowable(final Throwable throwable) {
- addThrowable(throwable, throwables.size());
- }
-
- /**
- Adds the specified Throwable to the list of Throwables that comprise this Exception at the specified index.
- @param throwable The Throwable
- @param index The index within the list of Throwables at which the Throwable should be added
- @since 2.1
- */
- public void addThrowable(final Throwable throwable, final int index) {
- if (throwable == null) {
- throw new IllegalArgumentException("throwable param cannot be null"); //$NON-NLS-1$
- }
- if (index < 0) {
- throw new IllegalArgumentException("index cannot be negative"); //$NON-NLS-1$
- }
- throwables.add(index, throwable);
- }
-
- /**
- Constructs an instance of this class with the specified error code and the specified set of Throwables.
- @param code The error code associated with this Exception
- @param throwables The list of Throwables that comprise this Exception
- @since 2.1
- */
- protected void constructMultipleRuntimeException(final String code, final List throwables) {
- setCode(code);
- setThrowables(throwables);
- }
-
- /**
- Returns the error code associated with this Exception.
- @return The error code
- @since 2.1
- */
- public String getCode() {
- return code;
- }
-
- /**
- Returns the list of Throwables that comprise this Exception (Guaranteed not to be null).
- @return The list of Throwables
- @since 2.1
- */
- public List getThrowables() {
- return throwables;
- }
-
- /**
- Sets the error code associated with this Exception.
- @param code The error code associated with this Exception
- @since 2.1
- */
- public void setCode(final String code) {
- this.code = code;
- }
-
- /**
- Sets the list of Throwables that comprise this Exception.
- @param throwables The list of Throwables that comprise this Exception
- @since 2.1
- */
- public void setThrowables(final List throwables) {
- // Could iterate through the list to assert each entry is a Throwable...?
- if (throwables == null) {
- this.throwables = new ArrayList();
- } else {
- this.throwables = throwables;
- }
- }
-
- /**
- Overridden to return the concatentation of the toString() results from each of the Throwables within this Exception.
- @since 2.1
- @return the string representation
- */
- public String toString() {
- final StringBuffer buf = new StringBuffer();
- final Iterator iter = throwables.iterator();
- while (iter.hasNext()) {
- buf.append(iter.next().toString());
- }
- return buf.toString();
- }
-}
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/dialog/ErrorDialog.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/dialog/ErrorDialog.java 2009-04-01 21:08:15 UTC (rev 688)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/dialog/ErrorDialog.java 2009-04-01 21:41:45 UTC (rev 689)
@@ -61,7 +61,6 @@
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MultipleException;
-import com.metamatrix.api.exception.MultipleRuntimeException;
import com.metamatrix.common.tree.TreeNode;
import com.metamatrix.common.tree.directory.FileSystemFilter;
import com.metamatrix.common.tree.directory.FileSystemView;
@@ -547,10 +546,6 @@
for (Iterator iter = ((MultipleException)throwable).getExceptions().iterator(); iter.hasNext();) {
result = parseThrowable((Throwable)iter.next(), depth+1);
}
- } else if (throwable instanceof MultipleRuntimeException) {
- for (Iterator iter = ((MultipleRuntimeException)throwable).getThrowables().iterator(); iter.hasNext();) {
- result = parseThrowable((Throwable)iter.next(), depth+1);
- }
} else if (throwable instanceof InvocationTargetException) {
result = parseThrowable(((InvocationTargetException)throwable).getTargetException(), depth+1);
}
Modified: trunk/console/src/main/java/com/metamatrix/console/util/ExceptionUtility.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/util/ExceptionUtility.java 2009-04-01 21:08:15 UTC (rev 688)
+++ trunk/console/src/main/java/com/metamatrix/console/util/ExceptionUtility.java 2009-04-01 21:41:45 UTC (rev 689)
@@ -32,11 +32,10 @@
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MultipleException;
-import com.metamatrix.api.exception.MultipleRuntimeException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.api.exception.security.LogonException;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.console.ConsolePlugin;
+import com.metamatrix.console.ConsolePlugin;
import com.metamatrix.console.ui.ViewManager;
import com.metamatrix.console.ui.dialog.ErrorDialog;
import com.metamatrix.core.MetaMatrixCoreException;
@@ -553,10 +552,6 @@
for (Iterator iter = ((MultipleException)throwable).getExceptions().iterator(); iter.hasNext();) {
result = unRollException((Throwable)iter.next());
}
- } else if (throwable instanceof MultipleRuntimeException) {
- for (Iterator iter = ((MultipleRuntimeException)throwable).getThrowables().iterator(); iter.hasNext();) {
- result = unRollException((Throwable)iter.next());
- }
} else if (throwable instanceof InvocationTargetException) {
result = unRollException(((InvocationTargetException)throwable).getTargetException());
}
Deleted: trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/ErrorDialog.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/ErrorDialog.java 2009-04-01 21:08:15 UTC (rev 688)
+++ trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/ErrorDialog.java 2009-04-01 21:41:45 UTC (rev 689)
@@ -1,720 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-//################################################################################################################################
-package com.metamatrix.toolbox.ui.widget;
-
-import java.awt.BorderLayout;
-import java.awt.Dialog;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Font;
-import java.awt.Frame;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Insets;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.swing.*;
-
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MultipleException;
-import com.metamatrix.api.exception.MultipleRuntimeException;
-
-import com.metamatrix.common.tree.TreeNode;
-import com.metamatrix.common.tree.directory.FileSystemFilter;
-import com.metamatrix.common.tree.directory.FileSystemView;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-
-/**
- * @since 2.0
- * @version 2.1
- */
-public class ErrorDialog extends JDialog {
-
-// private static String sDirectoryName = null;
- private static boolean displayLastException = false;
-
-// private static final int MAX_EXCEPTION_MSG_LENGTH = 200;
-// private static final int MAX_EXCEPTION_TYPE_LENGTH = 35;
-// private static final String OUT_LOG_FILE_PROP_NAME = "metamatrix.stdout.file";
-
- /**
- * sets a static property that controls how ErrorDialogs generated henceforth will
- * default to showing either the first or last exception in a chain of exceptions.
- * The default is to show the first.
- * @param showLast if true, ErrorDialog will initialize to show the last exception
- * in a chain.
- */
- public static void setDisplayLastException(boolean showLast) {
- displayLastException = showLast;
- }
-
- private final int ERROR_DIALOG_WIDTH = 400;
- private final int ERROR_DIALOG_HEIGHT_H = 150;
- private final int WHOLE_DIALOG_HEIGHT_H = 500;
- private int WHOLE_DIALOG_HEIGHT_W;
-// private final int LINE_BREAK_MEASURE = 270;
- private boolean detailsPressed = false;
- private ButtonWidget detailsButton = new ButtonWidget("Show Details");
- private ButtonWidget okButton = new ButtonWidget("OK");
-// private Hashtable severityTable = new Hashtable(4);
-// private JScrollPane jScrollPane;
- private JPanel upperPanel;
- private JPanel outerPanel;
- private JPanel lowerPanel;
- private String detailsText;
- private JPanel buttonPanel;
-// private JPanel bPositionPanel;
- private ButtonWidget saveButton = new ButtonWidget("Save Details to File");
-// private Dimension minimumSize = new Dimension(300, 180);
- private LabelWidget msgLabel;
- private JTextArea msgArea ;
- private JPanel linePanel;
- private JPanel excMsgPanel;
- private GridBagLayout excMsgLayout;
- private int rowCount;
- private LabelWidget detailLabel;
- private JTextArea detailArea;
- private JScrollPane scrollPane;
- private Font font;
- private LabelWidget excepLabel;
- private JComboBox excepField;
- private GridBagLayout lowerPanelLayout;
- private GridBagLayout outerPanelLayout;
- private LabelWidget statementArea;
- private JPanel stateReasonPanel;
- private JTextArea reasonArea;
- private JPanel outterButtonPanel;
- private boolean savesLastFileLoc;
-
- private List throwables;
- private List throwableNames;
-
- public ErrorDialog(Frame owner,
- String title,
- String statement,
- String reason)
- {
- super(owner, MessagePanel.ERROR_TITLE, true);
- detailsButton.setEnabled(false);
- createComponent(title, statement, reason, null, null, null);
- setLocationRelativeTo(owner);
- }
-
- public ErrorDialog(Frame owner,
- String title,
- String statement,
- String reason,
- Throwable exception)
- {
- super(owner, MessagePanel.ERROR_TITLE, true);
- createComponent(title, statement, reason, exception,
- null, null);
- setLocationRelativeTo(owner);
- }
-
- public ErrorDialog(Frame owner,
- String title,
- String statement,
- String reason,
- String detailedMessage,
- String details)
- {
- super(owner, MessagePanel.ERROR_TITLE, true);
- createComponent(title, statement, reason, null, detailedMessage,
- details);
- setLocationRelativeTo(owner);
- }
-
- public ErrorDialog(Dialog owner,
- String title,
- String statement,
- String reason)
- {
- super(owner, MessagePanel.ERROR_TITLE, true);
- detailsButton.setEnabled(false);
- createComponent(title, statement, reason, null, null, null);
- setLocationRelativeTo(owner);
- }
-
- public ErrorDialog(Dialog owner,
- String title,
- String statement,
- String reason,
- Throwable exception)
- {
- super(owner, MessagePanel.ERROR_TITLE, true);
- createComponent(title, statement, reason, exception,
- null, null);
- setLocationRelativeTo(owner);
- }
-
- public ErrorDialog(Dialog owner,
- String title,
- String statement,
- String reason,
- String detailedMessage,
- String details)
- {
- super(owner, MessagePanel.ERROR_TITLE, true);
- createComponent(title, statement, reason, null, detailedMessage,
- details);
- setLocationRelativeTo(owner);
- }
-
- private void createComponent(String title,
- String statement,
- String reason,
- final Throwable exception,
- String detailedMessage,
- String details)
- {
- outerPanel = new JPanel();
- Dimension edDimension = Toolkit.getDefaultToolkit().getScreenSize();
- Double edDimensionW = new Double (edDimension.getWidth()*3/4);
-
- WHOLE_DIALOG_HEIGHT_W = edDimensionW.intValue();
-
- outerPanelLayout = new GridBagLayout();
- outerPanel.setLayout(outerPanelLayout);
- getContentPane().setLayout(new BorderLayout());
- upperPanel = new JPanel();
- upperPanel.setLayout(new BoxLayout(upperPanel,BoxLayout.Y_AXIS));
-
- //lowerPanel consists of exception, exception message, detail about exception ,save .
- // If detail button is clicked once, the lowPanel is shown
-
- lowerPanel = new JPanel();
- lowerPanelLayout = new GridBagLayout();
- lowerPanel.setLayout(lowerPanelLayout);
- excMsgPanel = new JPanel();
- excMsgLayout = new GridBagLayout();
- excMsgPanel.setLayout(excMsgLayout);
- detailLabel = new LabelWidget("Details");
- detailLabel.setBorder(BorderFactory.createEmptyBorder(15,0,0,0));
-
- detailArea = new JTextArea();
- detailArea.setLineWrap(true);
- detailArea.setWrapStyleWord(true);
- if ( details != null ) {
- detailArea.setText(convertLineFeeds(details));
- // save off text in case user hits Save To File
- detailsText = "Exception:\n\t" + title + "\n\t\t" + statement +
- "\nreason:\n\t" + reason + "\nMessage:\n\t" +
- detailedMessage + "Details\n\t" + details;
- detailsText = convertLineFeeds(detailsText);
- }
-
- scrollPane = new JScrollPane(detailArea);
- scrollPane.setPreferredSize(new Dimension(180, 100));
- detailArea.setCaretPosition(0);
-
- if (exception != null){
- throwables = new ArrayList();
- throwableNames = new ArrayList();
- Throwable lastException = parseThrowable(exception);
-
- ByteArrayOutputStream bas = new ByteArrayOutputStream();
- PrintWriter pw = new PrintWriter(bas);
- if ( displayLastException ) {
- lastException.printStackTrace(pw);
- } else {
- exception.printStackTrace(pw);
- }
- pw.close();
- detailArea.setText(convertLineFeeds(bas.toString()));
-
-
- excepLabel = new LabelWidget("Error:");
- excepField = new JComboBox(throwableNames.toArray());
- msgArea = new JTextArea();
- if ( displayLastException ) {
- msgArea.setText(parseMessage(lastException.getMessage()));
- } else {
- msgArea.setText(parseMessage(exception.getMessage()));
- }
- excepField.addItemListener(new ItemListener(){
- public void itemStateChanged(ItemEvent e){
- final int ndx = excepField.getSelectedIndex();
- if (ndx < 0) {
- return;
- }
- final Throwable throwable = (Throwable)throwables.get(ndx);
- msgArea.setText(parseMessage(throwable.getMessage()));
- final ByteArrayOutputStream bas = new ByteArrayOutputStream();
- final PrintWriter pw = new PrintWriter(bas);
- throwable.printStackTrace(pw);
- pw.close();
- detailArea.setText(convertLineFeeds(bas.toString()));
- detailArea.setCaretPosition(0);
- }
- });
- if ( displayLastException ) {
- excepField.setSelectedIndex(throwableNames.size() - 1);
- }
-
- excepLabel.setLabelFor(excepField);
- msgLabel = new LabelWidget("Message:");
-
- msgArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
- BorderFactory.createEmptyBorder(2,0,2,0)));
- msgArea.setBackground(excMsgPanel.getBackground());
- msgArea.setLineWrap(true);
- msgArea.setWrapStyleWord(true);
- msgArea.setEditable(false);
- msgLabel.setLabelFor(msgArea);
- final JScrollPane msgScroller = new JScrollPane(msgArea);
- excMsgLayout.setConstraints(excepLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
- GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(1, 1, 5, 5), 0, 0));
-
- excMsgLayout.setConstraints(excepField, new GridBagConstraints(1, 0, 1, 1, 0, 1.0,
- GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 1, 5, 1), 0, 0));
-
- excMsgLayout.setConstraints(msgLabel , new GridBagConstraints(0, 1, 1, 1, 0 , 0,
- GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(1, 1, 1, 5), 0, 0));
-
- excMsgLayout.setConstraints(msgScroller, new GridBagConstraints(1, 1, 1, 1, 1, 1,
- GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0));
-
- excMsgPanel.add(excepLabel);
- excMsgPanel.add(excepField);
- excMsgPanel.add(msgLabel);
- excMsgPanel.add(msgScroller);
- lowerPanel.add(excMsgPanel);
-
- // save off exception message in case user hits Save To File
- bas = new ByteArrayOutputStream();
- pw = new PrintWriter(bas);
- Iterator iter = throwables.iterator();
- while ( iter.hasNext() ) {
- Throwable t = (Throwable) iter.next();
- String message = parseMessage(t.getMessage());
- if ( message != null ) {
- pw.write(message);
- }
- t.printStackTrace(pw);
- pw.write('\n');
- }
- pw.flush();
- detailsText = "Exception\n\t" + title + "\n\t\t" + statement +
- " \nreason:\n\t" + reason + "\nExceptionType:\n\t" +
- lastException.getClass().getName() + "\nDetails\n\t" +
- convertLineFeeds(bas.toString());
- detailsText = convertLineFeeds(detailsText);
-
- }
- else {
- if(details !=null){
- msgLabel = new LabelWidget("Message: " + detailedMessage);
- excMsgLayout.setConstraints(msgLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
- GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
- excMsgPanel.add(msgLabel);
- lowerPanel.add(excMsgPanel);
- }
- }
-
- linePanel = new JPanel();
- linePanel.setBorder(BorderFactory.createEtchedBorder());
- linePanel.setPreferredSize(new Dimension(100,2));
- lowerPanel.add(linePanel);
- lowerPanel.add(detailLabel);
- lowerPanel.add(scrollPane);
-
- lowerPanelLayout.setConstraints(linePanel , new GridBagConstraints(0, 0, 1, 1, 0 , 0,
- GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
-
- lowerPanelLayout.setConstraints(excMsgPanel , new GridBagConstraints(0, 1, 1, 1, 1.0 , 0,
- GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 0, 0), 0, 0));
-
- lowerPanelLayout.setConstraints(detailLabel, new GridBagConstraints(0, 2, 1, 1, 0, 0,
- GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
-
- lowerPanelLayout.setConstraints(scrollPane, new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
- GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(1, 1, 5, 1), 5, 5));
-
- lowerPanelLayout.setConstraints(saveButton, new GridBagConstraints(0, 4, 1, 1, 0, 0,
- GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
-
- lowerPanel.add(saveButton);
-
-// following is upperPanel. it consists of stateReasonPanel, outterButtonPanel.
-
- statementArea = new LabelWidget(statement);
- stateReasonPanel = new JPanel();
- stateReasonPanel.setLayout(new BorderLayout());
- stateReasonPanel.add(statementArea, BorderLayout.NORTH);
- reasonArea = new JTextArea(reason);
- reasonArea.setLineWrap(true);
- reasonArea.setWrapStyleWord(true);
- font = reasonArea.getFont();
- rowCount = getRowCount(reason);
- reasonArea.setBackground(stateReasonPanel.getBackground());
- reasonArea.setEditable(false);
- TitledBorder tBorder;
- tBorder = new TitledBorder("Reason");
- reasonArea.setName("Reason");
- final JScrollPane scroller = new JScrollPane(reasonArea);
- scroller.setBorder(tBorder);
- stateReasonPanel.add(scroller, BorderLayout.CENTER);
- upperPanel.add(stateReasonPanel);
-
- outterButtonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
- buttonPanel = new JPanel();
- buttonPanel.setLayout(new GridLayout(1,2,30,0));
- buttonPanel.add(okButton);
- buttonPanel.add(detailsButton);
- outterButtonPanel.add(buttonPanel);
- upperPanel.add(outterButtonPanel);
- outerPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
- outerPanel.add(upperPanel);
- outerPanelLayout.setConstraints(upperPanel, new GridBagConstraints(0, 0, 1, 1, 1.0,0.1,
- GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- getContentPane().add(outerPanel);
- this.setSize(ERROR_DIALOG_WIDTH , ERROR_DIALOG_HEIGHT_H+ (int)(1.5*font.getSize()*(rowCount)));
- // set minimumSize for dialog
- addComponentListener(new ComponentAdapter(){
- public void componentResized(ComponentEvent e){
- if (detailsPressed ){
- if (getSize().width < WHOLE_DIALOG_HEIGHT_W || getSize().height < WHOLE_DIALOG_HEIGHT_H )
-
- setSize( WHOLE_DIALOG_HEIGHT_W, WHOLE_DIALOG_HEIGHT_H);
- setLocationRelativeTo(getOwner());
- }
- else{
- if(getSize().width < ERROR_DIALOG_WIDTH || getSize().height < ERROR_DIALOG_HEIGHT_H)
- setSize(ERROR_DIALOG_WIDTH , ERROR_DIALOG_HEIGHT_H + (int)(1.5*font.getSize()*(rowCount)));
- }
- }
- });
-
- okButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e){
-
- okClicked();
- }
- });
- getRootPane().setDefaultButton(okButton);
- detailsButton.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
-
- detailsClicked();
- }
- });
- saveButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- saveClicked();
- }
- });
- }
-
- private void detailsClicked(){
- if(!detailsPressed){
- detailsPressed = true;
- detailsButton.setText("Hide Details");
- outerPanelLayout.setConstraints(lowerPanel, new GridBagConstraints(0, 1, 1, 1, 1.0,1.0,
- GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
-
- outerPanel.add(lowerPanel);
- ErrorDialog.this.pack();
- ErrorDialog.this.validate();
-
- }
- else {
- detailsPressed = false;
- detailsButton.setText("Show Details");
- outerPanel.remove(lowerPanel);
- ErrorDialog.this.validate();
- ErrorDialog.this.pack();
- }
- }
-
- /**
- * Obtain number of rows needed to display the text in reasonArea in order to adjust the height of the dialog
- * @since 3.0
- */
- protected int getRowCount(final String text){
- if (text == null) {
- return 0;
- }
- return new StringTokenizer(text, "\n").countTokens();
- }
-
- private void okClicked(){
- dispose();
- }
-
- /**
- * @since 2.1
- */
- protected String parseMessage(final String message) {
- if (message == null) {
- return null;
- }
- final int ndx = message.indexOf('\n');
- if (ndx >= 0) {
- return message.substring(0, ndx);
- }
- return message;
- }
-
- /**
- * @since 2.1
- */
- protected Throwable parseThrowable(final Throwable throwable) {
- Throwable result = throwable;
-
- if (throwable == null) {
- return result;
- }
- throwables.add(throwable);
- throwableNames.add(throwable.getClass().getName());
- if (throwable instanceof MetaMatrixException) {
- result = parseThrowable(((MetaMatrixException)throwable).getChild());
- } else if (throwable instanceof MetaMatrixRuntimeException) {
- result = parseThrowable(((MetaMatrixRuntimeException)throwable).getChild());
- } else if (throwable instanceof MultipleException) {
- for (Iterator iter = ((MultipleException)throwable).getExceptions().iterator(); iter.hasNext();) {
- result = parseThrowable((Throwable)iter.next());
- }
- } else if (throwable instanceof MultipleRuntimeException) {
- for (Iterator iter = ((MultipleRuntimeException)throwable).getThrowables().iterator(); iter.hasNext();) {
- result = parseThrowable((Throwable)iter.next());
- }
- } else if (throwable instanceof InvocationTargetException) {
- result = parseThrowable(((InvocationTargetException)throwable).getTargetException());
- }
-
- // if one of the chained exceptions did not produce a child exception, then return the input
- if ( result == null ) {
- return result = throwable;
- }
- return result;
- }
-
- private void saveClicked() {
- //User wants to save the details on a file. Put up a file chooser.
-
- String sSelectedFileName = getFileName();
- if ( sSelectedFileName != null ) {
- File file = new File( sSelectedFileName );
-
- boolean fileOK = false;
- if (file.exists()) {
- //Make sure we can write to file.
- if (file.canWrite()) {
- fileOK = true;
- }
- } else {
- try {
- file.createNewFile();
- fileOK = true;
- } catch (Exception e) {}
-
- }
- if (!fileOK) {
- String msg = "Error in opening or writing to file.";
- JOptionPane.showMessageDialog(this, msg, "File Error",
- JOptionPane.PLAIN_MESSAGE);
- } else {
- FileWriter writer = null;
- try {
- writer = new FileWriter(file);
- writer.write(detailsText);
- } catch (Exception ex) {
- String msg = "Error in opening or writing to file.";
- JOptionPane.showMessageDialog(this, msg, "File Error",
- JOptionPane.PLAIN_MESSAGE);
- }
- if (writer != null) {
- try {
- writer.flush();
- writer.close();
- } catch (Exception ex) {}
-
- }
-
- }
- }
- }
-
-
- public static String convertLineFeeds(String str) {
-
- StringBuffer buf = new StringBuffer();
- char b[] = str.toCharArray();
- char p = '?';
-
- for ( int i=0; i < b.length; ++i ) {
- if ( (p != '\r' ) && (b[i]=='\n')) buf.append('\r');
- p = b[i];
- buf.append(p);
- }
-
- return buf.toString();
- }
-
-
- /**
- * @since 3.0
- */
- protected String getFileName() {
- final FileSystemView view = new FileSystemView();
- final FileSystemFilter filter = new FileSystemFilter(view, new String[] {"txt"}, "Text documents (*.txt)");
- final DirectoryChooserPanel dirPanel
- = new DirectoryChooserPanel( view,
- DirectoryChooserPanel.TYPE_SAVE,
- new FileSystemFilter[] {filter} );
-
- DialogWindow.show(this, "Save Details", dirPanel);
- if (dirPanel.getSelectedButton() != dirPanel.getAcceptButton()) {
- return null;
- }
- final TreeNode node = dirPanel.getSelectedTreeNode();
- if (node == null) {
- return dirPanel.getParentDirectoryEntry().getFullName() + File.separatorChar + dirPanel.getNameFieldText();
- }
- return node.getFullName();
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- @since 2.0
- */
- public boolean savesLastFileLocation() {
- return savesLastFileLoc;
- }
-
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /**
- @since 2.0
- */
- public void setSavesLastFileLocation(final boolean saves) {
- savesLastFileLoc = saves;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- /**
- * @since 3.1
- */
- public AbstractButton getOKButton() {
- return okButton;
- }
-
- //############################################################################################################################
- //# Main #
- //############################################################################################################################
-
- /**
- * @since 2.0
- */
- public static void main(final String[] arguments) {
- final MetaMatrixException err = new MetaMatrixException("Really big message line 1, "
- + "Really big message line 2, "
- + "Really big message line 3, "
- + "Really big message line 4, "
- + "Really big message line 5, "
- + "Really big message line 6, "
- + "Really big message line 7, "
- + "Really big message line 8, "
- + "Really big message line 9, "
- + "Really big message line 10, "
- + "Really big message line 11, "
- + "Really big message line 12, "
- + "Really big message line 13, "
- + "Really big message line 14, "
- + "Really big message line 15, "
- + "Really big message line 16, "
- + "Really big message line 17, "
- + "Really big message line 18, "
- + "Really big message line 19, "
- + "Really big message line 20, "
- + "Really big message line 21, "
- + "Really big message line 22, "
- + "Really big message line 23, "
- + "Really big message line 24, "
- + "Really big message line 25, "
- + "Really big message line 26, "
- + "Really big message line 27, "
- + "Really big message line 28, "
- + "Really big message line 29, "
- + "Really big message line 30, "
- + "Really big message line 31, "
- + "Really big message line 32, "
- + "Really big message line 33, "
- + "Really big message line 34, "
- + "Really big message line 35, "
- + "Really big message line 36, "
- + "Really big message line 37, "
- + "Really big message line 38, "
- + "Really big message line 39, "
- + "Really big message line 40, ");
- final MultipleException multErr = new MultipleException();
- multErr.setExceptions(java.util.Arrays.asList(new Throwable[] {new java.awt.AWTError("AWT error"), new NullPointerException(), new RuntimeException("Runtime error")}));
-// err.setChild(multErr);
- final ErrorDialog dlg = new ErrorDialog((Frame)null, "test Dialog", "statement", "1 reason for statement\n" +
- "2 reason for statement\n" +
- "3 reason for statement\n" +
- "4 reason for statement\n" +
- "5 reason for statement\n" +
- "6 reason for statement\n" +
- "7 reason for statement\n" +
- "8 reason for statement\n" +
- "9 reason for statement\n" +
- "10 reason for statement\n" +
- "11 reason for statement\n" +
- "12 reason for statement\n" +
- "13 reason for statement\n" +
- "14 reason for statement\n" +
- "15 reason for statement\n" +
- "16 reason for statement\n" +
- "17 reason for statement\n" +
- "18 reason for statement\n" +
- "19 reason for statement\n" +
- "20 reason for statement\n" +
- "21 reason for statement\n" +
- "22 reason for statement\n",
- err);
- dlg.setVisible(true);
- new ErrorDialog((Frame)null, "test Dialog","statement","reason for statement", new NullPointerException()).setVisible(true);
- new ErrorDialog((Frame)null, "test Dialog","statement","reason for statement", "detailed message", "details").setVisible(true);
- new ErrorDialog((Frame)null, "test Dialog","statement","reason for statement", new InvocationTargetException(new IllegalArgumentException("Illegal argument"))).setVisible(true);
- System.exit(0);
- }
-
-}
Modified: trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/tree/DefaultTreeModel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/tree/DefaultTreeModel.java 2009-04-01 21:08:15 UTC (rev 688)
+++ trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/tree/DefaultTreeModel.java 2009-04-01 21:41:45 UTC (rev 689)
@@ -27,14 +27,12 @@
import java.util.Iterator;
import java.util.List;
+import javax.swing.SwingUtilities;
import javax.swing.event.TreeModelEvent;
import javax.swing.event.TreeModelListener;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
-import javax.swing.SwingUtilities;
-import com.metamatrix.api.exception.MultipleRuntimeException;
-
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.transaction.TransactionException;
import com.metamatrix.common.transaction.UserTransaction;
@@ -43,7 +41,6 @@
import com.metamatrix.common.tree.TreeView;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.Assertion;
-
import com.metamatrix.toolbox.property.VetoedChangeEvent;
import com.metamatrix.toolbox.property.VetoedChangeListener;
import com.metamatrix.toolbox.ui.widget.TreeWidget;
@@ -207,9 +204,7 @@
} catch (final TransactionException err) {
if (delayedErr == null) {
delayedErr = err;
- } else {
- delayedErr = new MultipleRuntimeException(new Throwable[] {delayedErr, err});
- }
+ }
} finally {
if (delayedErr != null) {
if (!(delayedErr instanceof RuntimeException)) {
[View Less]
16 years
teiid SVN: r688 - trunk/common-internal/src/main/java/com/metamatrix/common/config.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-01 17:08:15 -0400 (Wed, 01 Apr 2009)
New Revision: 688
Removed:
trunk/common-internal/src/main/java/com/metamatrix/common/config/StartupStateController.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/StartupStateException.java
Log:
TEIID-453, TEIID-442, TEIID-441, TEIID-136 simplifies configuration to only a current configuration.
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/config/StartupStateController.java
====…
[View More]===============================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/StartupStateController.java 2009-04-01 20:57:00 UTC (rev 687)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/StartupStateController.java 2009-04-01 21:08:15 UTC (rev 688)
@@ -1,151 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config;
-
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-
-/**
- * <p>This tool, which is to be used <i>only</i> by the
- * {@link com.metamatrix.platform.util.MetaMatrixController} during
- * system startup, works with {@link CurrentConfiguration} to
- * initialize system state, and also the system configurations, in the
- * configuration database.</p>
- *
- * <p>All {@link com.metamatrix.platform.util.MetaMatrixController MetaMatrixControllers}
- * will call {@link #beginSystemInitialization},
- * in an attempt to be the first one to start system initialization.
- * System startup state ensures that initialization happens
- * <i>exactly</i> once.</p>
- *
- * <p>The {@link #beginSystemInitialization} method will attempt to simultaneously
- * read, then set, the system startup state as a transaction. The state will
- * be set to {@link #STATE_STARTING} by this method, but only under the
- * following conditions:
- * <ul>
- * <li>The boolean "forceInitialization" parameter is false, and the
- * system startup state is currently {@link #STATE_STOPPED}.</li>
- * <li>The boolean "forceInitialization" parameter is true (the
- * system startup state can be any state).</li>
- * </ul>
- * </p>
- * <p>If the {@link #beginSystemInitialization} method executes without
- * an exception, the client should call {@link #finishSystemInitialization}
- * after doing any startup work. This will put the system into a
- * state of {@link #STATE_STARTED}. MetaMatrixController should <i>only</i>
- * call this method if the {@link #beginSystemInitialization} method
- * executed without exception.</p>
- */
-final public class StartupStateController {
-
- /**
- * This state indicates the system is stopped, and ready to
- * be started.
- */
- public final static int STATE_STOPPED = 0;
-
- /**
- * descriptive label for {@link #STATE_STOPPED} state
- */
- public final static String STATE_STOPPED_LABEL = "STOPPED"; //$NON-NLS-1$
-
- /**
- * This state indicates the system is in the process of starting.
- * If a MetaMatrixController encounters this state, it is because
- * another MetaMatrixController is in the process of starting the
- * system. However, this state also may be stored this way in the
- * database because the system crashed and did not reset it.
- * At the discretion of the system administrator, he can choose
- * to force a system start even if the system is in this state,
- * if he believes it is because the system crashed.
- */
- public final static int STATE_STARTING = 1;
-
- /**
- * descriptive label for {@link #STATE_STARTING} state
- */
- public final static String STATE_STARTING_LABEL = "STARTING"; //$NON-NLS-1$
-
- /**
- * This state indicates that either the system is successfully
- * started, or this state also may be stored this way in the
- * database because the system crashed and did not reset it.
- * At the discretion of the system administrator, he can choose
- * to force a system start even if the system is in this state,
- * if he believes it is because the system crashed.
- */
- public final static int STATE_STARTED = 2;
-
- /**
- * descriptive label for {@link #STATE_STARTED} state
- */
- public final static String STATE_STARTED_LABEL = "STARTED"; //$NON-NLS-1$
-
-
- public final static String getStateLabel(int state) {
- switch(state) {
- case STATE_STARTED:
- return STATE_STARTED_LABEL;
- case STATE_STARTING:
- return STATE_STARTING_LABEL;
- case STATE_STOPPED:
- return STATE_STOPPED_LABEL;
- default: return "InvalidServerState " + state; //$NON-NLS-1$
- }
- }
-
- /**
- * This method should be called <i>only</i> by
- * {@link com.metamatrix.platform.util.MetaMatrixController}
- * to initialize the system configurations during bootstrapping.
- * This method will attempt to put the system state into
- * {@link StartupStateController#STATE_STARTING}, and then
- * commence with initialization. If the state is already
- * {@link StartupStateController#STATE_STARTING}, then another
- * MetaMatrixController is already currently in the process of
- * starting the system, and a {@link StartupStateException}
- * will be thrown. If this method returns without an
- * exception, then the system state will be in state
- * {@link StartupStateController#STATE_STARTING}, and the calling
- * code should proceed with startup.
- * @param forceInitialization if the system is in a state other than
- * {@link StartupStateController#STATE_STOPPED}, and the
- * administrator thinks the system actually crashed and is
- * not really running, he can choose to force the
- * initialization. Otherwise, if the system is in one of these states,
- * an exception will be thrown.
- * @throws StartupStateException if the system is
- * not in a state in which initialization can proceed. This
- * exception will indicate the current system state.
- * @throws ConfigurationException if the current configuration and/or
- * bootstrap properties could not be obtained
- *
- * NOTE: This method replaces the begin... and finish.. SystemInitialization methods
- * for the new configuration implementations.
- */
-
- public final static void performSystemInitialization(boolean forceInitialization) throws StartupStateException, ConfigurationException{
- CurrentConfiguration.getInstance().performSystemInitialization(forceInitialization);
- }
-
-}
-
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/config/StartupStateException.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/StartupStateException.java 2009-04-01 20:57:00 UTC (rev 687)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/StartupStateException.java 2009-04-01 21:08:15 UTC (rev 688)
@@ -1,122 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-import com.metamatrix.api.exception.MetaMatrixException;
-
-/**
- * <p>This exception is thrown by {@link StartupStateController}, to
- * indicate to a calling MetaMatrixController that the system is
- * not in a state in which initialization can proceed.</p>
- */
-public final class StartupStateException extends MetaMatrixException {
-
- private int startupState;
-
- private static final String DEFAULT_MESSAGE_BEGIN = "Current startup state "; //$NON-NLS-1$
- private static final String DEFAULT_MESSAGE_MIDDLE = " could not be changed to "; //$NON-NLS-1$
-
- /**
- * No-arg costructor required by Externalizable semantics
- */
- public StartupStateException() {
- super();
- }
-
- /**
- * Construct this exception with a message, and the system state.
- */
- public StartupStateException( String message, int startupState ) {
- super( message );
- this.startupState = startupState;
- }
-
- /**
- * Construct this exception with a default message, which will
- * include the current startup state and the desired startup state
- * parameters, explaining that the desired state cannot be reached.
- */
- public StartupStateException( int desiredStartupState, int startupState ) {
- super( generateDefaultMessage(desiredStartupState, startupState) );
- this.startupState = startupState;
- }
-
-
- /**
- * Use the constants in {@link StartupStateController} to interpret the
- * system state from the returned int.
- * @return int indicating system startup state
- */
- public int getStartupState(){
- return this.startupState;
- }
-
- private static final String generateDefaultMessage(int desiredStartupState, int startupState ) {
- StringBuffer s = new StringBuffer(DEFAULT_MESSAGE_BEGIN);
- switch (startupState){
- case StartupStateController.STATE_STOPPED:
- s.append(StartupStateController.STATE_STOPPED_LABEL);
- break;
- case StartupStateController.STATE_STARTING:
- s.append(StartupStateController.STATE_STARTING_LABEL);
- break;
- case StartupStateController.STATE_STARTED:
- s.append(StartupStateController.STATE_STARTED_LABEL);
- }
- s.append(DEFAULT_MESSAGE_MIDDLE);
- switch (desiredStartupState){
- case StartupStateController.STATE_STOPPED:
- s.append(StartupStateController.STATE_STOPPED_LABEL);
- break;
- case StartupStateController.STATE_STARTING:
- s.append(StartupStateController.STATE_STARTING_LABEL);
- break;
- case StartupStateController.STATE_STARTED:
- s.append(StartupStateController.STATE_STARTED_LABEL);
- }
- s.append("."); //$NON-NLS-1$
- return s.toString();
- }
-
- /**
- * @see java.io.Externalizable#readExternal(java.io.ObjectInput)
- */
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- super.readExternal(in);
- startupState = in.readInt();
- }
-
- /**
- * @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
- */
- public void writeExternal(ObjectOutput out) throws IOException {
- super.writeExternal(out);
- out.writeInt(startupState);
- }
-
-}
-
[View Less]
16 years
teiid SVN: r686 - in trunk: client/src/main/java/com/metamatrix/admin/objects and 71 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-04-01 16:56:55 -0400 (Wed, 01 Apr 2009)
New Revision: 686
Added:
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java
trunk/server/src/main/java/com/metamatrix/platform/config/util/
trunk/server/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java
Removed:
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/exceptions/ConfigurationLockException.java
trunk/common-…
[View More]internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
trunk/common-internal/src/main/java/com/metamatrix/common/util/VMNaming.java
trunk/server-installer/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java
trunk/server/src/main/java/com/metamatrix/common/messaging/MessageBusConstants.java
trunk/server/src/main/java/com/metamatrix/common/messaging/VMMessageBus.java
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServicePropertyNames.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/ConfigurationTransaction.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/SystemConfigurationNames.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransaction.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigUserTransaction.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigUserTransactionFactory.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnectorFactory.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationReader.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationTransaction.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationWriter.java
trunk/server/src/test/java/com/metamatrix/platform/config/CurrentConfigHelper.java
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestConfigTransactions.java
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestCurrentConfigurationShutdown.java
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMServerConnection.java
trunk/client/src/main/java/com/metamatrix/admin/api/objects/PropertyDefinition.java
trunk/client/src/main/java/com/metamatrix/admin/objects/MMPropertyDefinition.java
trunk/common-core/src/main/java/com/metamatrix/common/jdbc/SimplePooledConnectionSource.java
trunk/common-core/src/main/java/com/metamatrix/core/log/FileLimitSizeLogWriter.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ComponentTypePropDefn.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/Configuration.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/Host.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfiguration.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicHost.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/reader/CurrentConfigurationReader.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/reader/PropertiesConfigurationReader.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java
trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyDefinition.java
trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyDefinitionImpl.java
trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java
trunk/common-internal/src/main/resources/com/metamatrix/common/i18n.properties
trunk/common-internal/src/test/java/com/metamatrix/common/config/model/TestComponentCryptoUtil.java
trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml
trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java
trunk/console/src/main/java/com/metamatrix/console/main/AdminConsoleMain.java
trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationManager.java
trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationPropertiedObjectEditor.java
trunk/console/src/main/java/com/metamatrix/console/models/PropertiesManager.java
trunk/console/src/main/java/com/metamatrix/console/models/ResourceManager.java
trunk/console/src/main/java/com/metamatrix/console/models/ServerLogManager.java
trunk/console/src/main/java/com/metamatrix/console/ui/layout/ConsoleAboutPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/authorization/SummaryMain.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/ConfigurationTreeCellRenderer.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/DetailPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/ServiceDefinitionPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/logsetup/SystemLogSetUpPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/ConsolePropertiedEditor.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/NextStartupPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/PropertiesMasterPanel.java
trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/PropertyFilterPanel.java
trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/AboutPanel.java
trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/property/PropertyDefinitionLabel.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/SocketVMController.java
trunk/server/src/main/java/com/metamatrix/common/config/JDBCConnectionPoolHelper.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/ExtensionModuleTransaction.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTransaction.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java
trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java
trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
trunk/server/src/main/java/com/metamatrix/common/log/reader/DBLogReader.java
trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/JGroupsMessageBus.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java
trunk/server/src/main/java/com/metamatrix/platform/config/event/ConfigurationChangeEvent.java
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/PersistentConnection.java
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/PersistentConnectionFactory.java
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/impl/file/FilePersistentConnection.java
trunk/server/src/main/java/com/metamatrix/platform/config/persistence/impl/file/FilePersistentUtil.java
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransactionException.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnector.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationMgr.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLCurrentConfigurationReader.java
trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessRegistryBinding.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/vm/api/controller/ProcessManagement.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
trunk/server/src/main/java/com/metamatrix/server/HostController.java
trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java
trunk/server/src/main/java/com/metamatrix/server/JGroupsProvider.java
trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java
trunk/server/src/main/java/com/metamatrix/server/Main.java
trunk/server/src/main/java/com/metamatrix/server/ResourceFinder.java
trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
trunk/server/src/main/java/com/metamatrix/server/ServiceManager.java
trunk/server/src/main/java/com/metamatrix/server/ServiceManagerGuiceModule.java
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/tracker/TransactionLogWriter.java
trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java
trunk/server/src/main/sqlrepository/data/data_clear.sql
trunk/server/src/main/sqlrepository/data/data_insert.sql
trunk/server/src/main/sqlrepository/schema/db2/mm_create.sql
trunk/server/src/main/sqlrepository/schema/db2/mm_drop.sql
trunk/server/src/main/sqlrepository/schema/derby/mm_create.sql
trunk/server/src/main/sqlrepository/schema/derby/mm_drop.sql
trunk/server/src/main/sqlrepository/schema/mysql/mm_create.sql
trunk/server/src/main/sqlrepository/schema/mysql/mm_drop.sql
trunk/server/src/main/sqlrepository/schema/oracle/mm_create.sql
trunk/server/src/main/sqlrepository/schema/oracle/mm_drop.sql
trunk/server/src/main/sqlrepository/schema/postgres/mm_create.sql
trunk/server/src/main/sqlrepository/schema/postgres/mm_drop.sql
trunk/server/src/main/sqlrepository/schema/sqlserver/mm_create.sql
trunk/server/src/main/sqlrepository/schema/sqlserver/mm_drop.sql
trunk/server/src/main/sqlrepository/schema/sybase/mm_create.sql
trunk/server/src/main/sqlrepository/schema/sybase/mm_drop.sql
trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java
trunk/server/src/test/java/com/metamatrix/admin/server/FakeExtensionModuleManager.java
trunk/server/src/test/java/com/metamatrix/admin/server/FakeRuntimeStateAdminAPIHelper.java
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
trunk/server/src/test/java/com/metamatrix/common/extensionmodule/TestExtensionModuleManager.java
trunk/server/src/test/java/com/metamatrix/platform/config/BaseTest.java
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestCurrentConfiguration.java
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestInitialConfigurationRead.java
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigImportExport.java
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigReader.java
trunk/server/src/test/java/com/metamatrix/platform/registry/FakeRegistryUtil.java
trunk/server/src/test/java/com/metamatrix/platform/registry/TestServiceRegistryBinding.java
Log:
TEIID-453, TEIID-442, TEIID-441, TEIID-136 simplifies configuration to only a current configuration.
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/objects/PropertyDefinition.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/objects/PropertyDefinition.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/objects/PropertyDefinition.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -29,7 +29,13 @@
*/
public interface PropertyDefinition extends AdminObject {
-
+ public enum RestartType {
+ NONE,
+ SERVICE,
+ PROCESS,
+ ALL_PROCESSES,
+ CLUSTER
+ }
/**
* The value of the maximum multiplicity if the multiplicity is considered unbounded.
*/
@@ -90,7 +96,7 @@
* Get whether this property requires the system to be restarted before it takes effect.
* @return true if this property requires the system to be restarted before it takes effect.
*/
- public boolean getRequiresRestart();
+ public RestartType getRequiresRestart();
/**
* The modifiable flag is used to identify features that may not be changed once
Modified: trunk/client/src/main/java/com/metamatrix/admin/objects/MMPropertyDefinition.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/objects/MMPropertyDefinition.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/client/src/main/java/com/metamatrix/admin/objects/MMPropertyDefinition.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -43,7 +43,7 @@
private int maximumMultiplicity = PropertyDefinition.UNBOUNDED_VALUE;
private String propertyType = "String"; //$NON-NLS-1$
private String propertyTypeClassName = String.class.getName();
- private boolean requiresRestart = false;
+ private RestartType requiresRestart = RestartType.NONE;
private String valueDelimiter = null;
private boolean constrainedToAllowedValues = false;
private boolean expert = false;
@@ -175,7 +175,7 @@
* @see com.metamatrix.admin.api.objects.PropertyDefinition#getRequiresRestart()
* @since 4.3
*/
- public boolean getRequiresRestart() {
+ public RestartType getRequiresRestart() {
return requiresRestart;
}
@@ -376,7 +376,7 @@
* @param requiresRestart The value of requiresRestart to set.
* @since 4.3
*/
- public void setRequiresRestart(boolean requiresRestart) {
+ public void setRequiresRestart(RestartType requiresRestart) {
this.requiresRestart = requiresRestart;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMServerConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMServerConnection.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMServerConnection.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -38,7 +38,7 @@
public class MMServerConnection extends MMConnection {
// constant value giving product name
- private final static String SERVER_NAME = "MetaMatrix Enterprise"; //$NON-NLS-1$
+ private final static String SERVER_NAME = "Teiid Server"; //$NON-NLS-1$
private ServerAdmin serverAdmin;
Modified: trunk/common-core/src/main/java/com/metamatrix/common/jdbc/SimplePooledConnectionSource.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/jdbc/SimplePooledConnectionSource.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-core/src/main/java/com/metamatrix/common/jdbc/SimplePooledConnectionSource.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -12,6 +12,7 @@
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+import java.util.logging.Logger;
import javax.sql.DataSource;
@@ -67,11 +68,28 @@
try {
if (method.getName().equals("close")) { //$NON-NLS-1$
boolean isShutdown = shutdown;
- if (!isShutdown) {
- connections.add((Connection)proxy);
+ boolean success = false;
+ try {
+ if (!isShutdown) {
+ if (!c.getAutoCommit()) {
+ Logger.getLogger("org.teiid.common.jdbc").warning("Uncommitted connection returned to the pool"); //$NON-NLS-1$ //$NON-NLS-2$
+ c.rollback();
+ c.setAutoCommit(true);
+ }
+ if (c.isReadOnly()) {
+ c.setReadOnly(false);
+ }
+ connections.add((Connection)proxy);
+ success = true;
+ }
+ } finally {
+ connectionLock.release();
+ if (!success) {
+ c.close();
+ return null;
+ }
}
- connectionLock.release();
- if (!isShutdown) {
+ if (success) {
return null;
}
} else if (method.getName().equals("isValid")) { //$NON-NLS-1$
Modified: trunk/common-core/src/main/java/com/metamatrix/core/log/FileLimitSizeLogWriter.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/FileLimitSizeLogWriter.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/FileLimitSizeLogWriter.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -356,7 +356,7 @@
return fileName.toString();
}
- protected static String getDate( ) {
+ public synchronized static String getDate( ) {
try {
Date d = Calendar.getInstance().getTime();
return DATE_FORMATTER.format(d);
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Collection;
import java.util.Properties;
@@ -35,14 +37,18 @@
import com.metamatrix.common.config.api.HostID;
import com.metamatrix.common.config.api.ResourceModel;
import com.metamatrix.common.config.api.SharedResource;
+import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.config.model.BasicHost;
import com.metamatrix.common.config.reader.CurrentConfigurationReader;
import com.metamatrix.common.config.reader.PropertiesConfigurationReader;
import com.metamatrix.common.properties.UnmodifiableProperties;
+import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.ErrorMessageKeys;
+import com.metamatrix.common.util.NetUtils;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.util.ReflectionHelper;
/**
* <p>
@@ -64,8 +70,6 @@
* information will restart the framework, requiring another eventual
* shutdown.
* </p>
- *
- * NOTE: This class should NOT use LogManager because it can cause recursive behavior.
*/
public final class CurrentConfiguration {
@@ -77,6 +81,10 @@
private CurrentConfigurationReader reader;
private Properties bootstrapProperties;
private Properties systemBootstrapProperties;
+ private String bindAddress;
+ private InetAddress hostAddress;
+ private String configurationName;
+ private String processName;
private static CurrentConfiguration INSTANCE = new CurrentConfiguration();
@@ -88,8 +96,95 @@
* Private constructor that prevents instantiation.
*/
private CurrentConfiguration() {
+ setHostProperties(null);
}
+ private void setHostProperties(String bind) {
+ Host host = getDefaultHost();
+ this.configurationName = host.getFullName();
+ String hostName = host.getHostAddress();
+ if (bind == null) {
+ bind = host.getBindAddress();
+ }
+
+ boolean bindAddressDefined = (bind != null && bind.length() > 0);
+ boolean hostNameDefined = (hostName != null && hostName.length() > 0);
+
+ try {
+ if (hostNameDefined) {
+ this.hostAddress = NetUtils.resolveHostByName(hostName);
+ }
+
+ if (bindAddressDefined) {
+ this.bindAddress = bind;
+
+ if (!hostNameDefined) {
+ this.hostAddress = InetAddress.getByName(bindAddress);
+ }
+ }
+ else {
+ if (!hostNameDefined) {
+ this.hostAddress = NetUtils.getInstance().getInetAddress();
+ }
+ this.bindAddress = this.hostAddress.getHostAddress();
+ }
+ } catch (UnknownHostException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean isAvailable() {
+ return this.reader != null;
+ }
+
+ /**
+ * Return the stringified representation of this application information object.
+ * @return the string form of this object; never null
+ */
+ public String getHostInfo() {
+ StringBuffer sb = new StringBuffer("Host Information"); //$NON-NLS-1$
+ sb.append('\n');
+ sb.append(" VM Name: " + processName ); //$NON-NLS-1$
+ sb.append('\n');
+ sb.append(" Hostname: " + hostAddress.getCanonicalHostName() ); //$NON-NLS-1$
+ sb.append('\n');
+ sb.append(" Version: ").append(ApplicationInfo.getInstance().getReleaseNumber()); //$NON-NLS-1$
+ sb.append('\n');
+ sb.append(" Build Date: ").append(ApplicationInfo.getInstance().getBuildDate()); //$NON-NLS-1$
+ return sb.toString();
+ }
+
+ public void setProcessName(String name) {
+ VMComponentDefn deployedVM;
+ try {
+ deployedVM = getConfiguration().getVMForHost(getDefaultHost().getName(), name);
+ } catch (ConfigurationException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+
+ if (deployedVM == null) {
+ throw new MetaMatrixRuntimeException(CommonPlugin.Util.getString("CurrentConfiguration.unknown_process", name)); //$NON-NLS-1$
+ }
+ this.processName = name;
+ setHostProperties(deployedVM.getBindAddress());
+ }
+
+ public String getBindAddress() {
+ return bindAddress;
+ }
+
+ public InetAddress getHostAddress() {
+ return hostAddress;
+ }
+
+ public String getConfigurationName() {
+ return configurationName;
+ }
+
+ public String getProcessName() {
+ return processName;
+ }
+
public String getClusterName() throws ConfigurationException {
Properties props = getResourceProperties(ResourceNames.JGROUPS);
return props.getProperty(CLUSTER_NAME, "Teiid-Cluster"); //$NON-NLS-1$
@@ -213,8 +308,8 @@
* communication with the Configuration Service, or if there is no object
* for the given ID.
*/
- public Host getDefaultHost() throws ConfigurationException {
- String name = getBootStrapProperties().getProperty(CONFIGURATION_NAME);
+ public Host getDefaultHost() {
+ String name = getBootStrapProperties().getProperty(CONFIGURATION_NAME, "embedded"); //$NON-NLS-1$
BasicHost host = new BasicHost(new ConfigurationID(name), new HostID(name), Host.HOST_COMPONENT_TYPE_ID);
Properties props = new Properties();
@@ -233,64 +328,11 @@
* Reset causes not just a refresh, but the bootstrapping process
* to occur again.
*/
- public synchronized final void reset() throws ConfigurationException {
- reader = null;
- bootstrapProperties = null;
- systemBootstrapProperties = null;
+ public static void reset() {
+ INSTANCE = new CurrentConfiguration();
}
-
- /**
- * This method should be called <i>only</i> by
- * {@link StartupStateController}, which is used by
- * MetaMatrixController to initialize the system configurations during bootstrapping.
- * Once bootstrap properties are verified, this method will use
- * the {@link #reader} to attempt to put the system state into
- * {@link StartupStateController#STATE_STARTING}, and then
- * commence with initialization. If the state is already
- * {@link StartupStateController#STATE_STARTING}, then another
- * MetaMatrixController is already currently in the process of
- * starting the system, and a {@link StartupStateException}
- * will be thrown. If this method returns without an
- * exception, then the system state will be in state
- * {@link StartupStateController#STATE_STARTING}, and the calling
- * code should proceed with startup.
-
-
- * @param forceInitialization if the system is in a state other than
- * {@link StartupStateController#STATE_STOPPED}, and the
- * administrator thinks the system actually crashed and is
- * not really running, he can choose to force the
- * initialization. Otherwise, if the system is in one of these states,
- * an exception will be thrown. This method is package-level so
- * that only StartupStateController can access it.
- * @throws StartupStateException if the system is
- * not in a state in which initialization can proceed. This
- * exception will indicate the current system state.
- * @throws ConfigurationException if the current configuration and/or
- * bootstrap properties could not be obtained
- */
-//JBoss fix - method made public to get around a AccessDenied problem with Jboss30
- public final void performSystemInitialization(boolean forceInitialization) throws StartupStateException, ConfigurationException {
-
- // this only initializes the persistence of the configuration
- // (i.e., copying NEXTSTARTUP to OPERATIONAL, etc)
- getReader().performSystemInitialization(forceInitialization);
-
- // perform reset to reload configuration information
- reset();
- }
-
- /**
- * This will put the system into a state of {@link #STATE_STOPPED}.
- * @throws ConfigurationException if the current configuration and/or
- * bootstrap properties could not be obtained
- */
-//JBoss fix - method made public to get around a AccessDenied problem with Jboss30
- public final void indicateSystemShutdown() throws ConfigurationException {
- getReader().indicateSystemShutdown();
- }
-
- public synchronized Properties getBootStrapProperties() throws ConfigurationException {
+
+ public synchronized Properties getBootStrapProperties() {
if (bootstrapProperties == null) {
Properties systemBootStrapProps = getSystemBootStrapProperties();
Properties bootstrapProps = new Properties(systemBootStrapProps);
@@ -301,7 +343,7 @@
bootstrapProps.load(bootstrapPropStream);
}
} catch (IOException e) {
- throw new ConfigurationException(ErrorMessageKeys.CONFIG_ERR_0069, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0069, BOOTSTRAP_FILE_NAME));
+ throw new MetaMatrixRuntimeException(ErrorMessageKeys.CONFIG_ERR_0069, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0069, BOOTSTRAP_FILE_NAME));
} finally {
try {
if (bootstrapPropStream != null) {
@@ -322,16 +364,6 @@
return systemBootstrapProperties;
}
- /**
- * Returns the instance of <code>CofigurationBootMgr</code> to use to
- * get configuration information.
- * @throws ConfigurationException if the current configuration and/or
- * bootstrap properties could not be obtained
- */
- public final void verifyBootstrapProperties() throws ConfigurationException {
- getReader();
- }
-
synchronized CurrentConfigurationReader getReader() throws ConfigurationException {
if (reader == null) {
// Get the default bootstrap properties from the System properties ...
@@ -339,15 +371,11 @@
String readerClassName = bootstrap.getProperty( CONFIGURATION_READER_CLASS_PROPERTY_NAME, PropertiesConfigurationReader.class.getName() );
- CurrentConfigurationReader tempReader;
try {
- Class readerClass = Class.forName(readerClassName);
- tempReader = (CurrentConfigurationReader) readerClass.newInstance();
+ reader = (CurrentConfigurationReader)ReflectionHelper.create(readerClassName, null, Thread.currentThread().getContextClassLoader());
} catch (Exception e) {
throw new ConfigurationException(e);
}
- tempReader.connect(bootstrap);
- reader = tempReader;
}
return reader;
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ComponentTypePropDefn.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ComponentTypePropDefn.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ComponentTypePropDefn.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -25,6 +25,7 @@
import java.io.Serializable;
import java.util.List;
+import com.metamatrix.admin.api.objects.PropertyDefinition.RestartType;
import com.metamatrix.common.object.Multiplicity;
import com.metamatrix.common.object.PropertyDefinition;
import com.metamatrix.common.object.PropertyDefinitionImpl;
@@ -136,7 +137,7 @@
* @see com.metamatrix.common.object.PropertyDefinition#getRequiresRestart()
* @since 4.3
*/
- public boolean getRequiresRestart() {
+ public RestartType getRequiresRestart() {
return origPropertyDefinition.getRequiresRestart();
}
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/api/Configuration.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/api/Configuration.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/api/Configuration.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -43,14 +43,12 @@
* configuration object represents.
*/
static final String NEXT_STARTUP = "Next Startup"; //$NON-NLS-1$
- static final String STARTUP = "Startup"; //$NON-NLS-1$
/**
* These configuration ID's can be used to determine which Configuration a
* ConfigurationID represents using equals.
*/
static final ConfigurationID NEXT_STARTUP_ID = new ConfigurationID(NEXT_STARTUP);
- static final ConfigurationID STARTUP_ID = new ConfigurationID(STARTUP);
static final String COMPONENT_TYPE_NAME = "Configuration"; //$NON-NLS-1$
static final ComponentTypeID CONFIG_COMPONENT_TYPE_ID = new ComponentTypeID(COMPONENT_TYPE_NAME);
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/api/Host.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/api/Host.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/api/Host.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -69,7 +69,9 @@
* @return
* @since 4.3
*/
- String getHostAddress();
+ String getHostAddress();
+ String getConfigDirectory();
+
}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/config/api/exceptions/ConfigurationLockException.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/api/exceptions/ConfigurationLockException.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/api/exceptions/ConfigurationLockException.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.api.exceptions;
-
-public class ConfigurationLockException extends ConfigurationException {
-
-
- /**
- * No-Arg Constructor
- */
- public ConfigurationLockException( ) {
- super( );
- }
- /**
- * Constructs an instance of the exception with the specified detail message. A detail
- * message is a String that describes this particular exception.
- * @param message the detail message
- */
- public ConfigurationLockException(String message) {
- super(message);
- }
-
- /**
- * Constructs an instance of the exception with no detail message but with a
- * single exception.
- * @param e the exception that is encapsulated by this exception
- */
- public ConfigurationLockException(Throwable e) {
- super(e);
- }
-
- /**
- * Constructs an instance of the exception with the specified detail message
- * and a single exception. A detail message is a String that describes this
- * particular exception.
- * @param message the detail message
- * @param e the exception that is encapsulated by this exception
- */
- public ConfigurationLockException(Throwable e, String message) {
- super(e, message);
- }
-
- /**
- * Construct an instance with an error code and message specified.
- *
- * @param message The error message
- * @param code The error code
- */
- public ConfigurationLockException(String code, String message) {
- super(message);
- setCode(code);
- }
-
- /**
- * Construct an instance with a linked exception, and an error code and
- * message, specified.
- *
- * @param e An exception to chain to this exception
- * @param message The error message
- * @param code The error code
- */
- public ConfigurationLockException(Throwable e, String code, String message) {
- super(e, code, message);
- }
-}
-
-
-
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfiguration.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfiguration.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfiguration.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,7 +22,6 @@
package com.metamatrix.common.config.model;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -75,7 +74,7 @@
* it cannot be changed. The configuration must be versioned, and then changes can be made to the
* new versioned copy.
*/
-public class BasicConfiguration extends BasicComponentObject implements Configuration, Serializable {
+public class BasicConfiguration extends BasicComponentObject implements Configuration {
/**
@@ -133,15 +132,6 @@
return info.getID().equals(NEXT_STARTUP_ID);
}
-
- /**
- * Does this config represent the Startup config?
- * @return true if it does, false otherwise.
- */
- public boolean isStartUp() {
- return info.getID().equals(STARTUP_ID);
- }
-
public ConfigurationInfo getInfo() {
return info;
}
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicHost.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicHost.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicHost.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -24,7 +24,6 @@
import java.io.File;
-import java.io.Serializable;
import java.util.Properties;
import com.metamatrix.common.config.api.ComponentTypeID;
@@ -34,7 +33,7 @@
import com.metamatrix.common.config.api.HostType;
import com.metamatrix.core.util.FileUtils;
-public class BasicHost extends BasicComponentDefn implements Host, Serializable {
+public class BasicHost extends BasicComponentDefn implements Host {
public BasicHost(ConfigurationID configID, HostID hostID, ComponentTypeID typeID) {
@@ -53,6 +52,11 @@
public String getDataDirectory() {
return getProperty(HostType.HOST_DIRECTORY)+File.separator+ "data"; //$NON-NLS-1$
}
+
+ public String getConfigDirectory() {
+ return getProperty(HostType.HOST_DIRECTORY)+File.separator+ "config"; //$NON-NLS-1$
+ }
+
/**
* @see com.metamatrix.common.config.api.Host#getLogDirectory()
* @since 4.3
@@ -68,7 +72,6 @@
public String getTempDirectory() {
String datadir = getDataDirectory();
return FileUtils.buildDirectoryPath(new String[] {datadir, "temp"}); //$NON-NLS-1$
-
}
/**
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/model/ConfigurationModelContainerImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -56,10 +56,8 @@
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.VMComponentDefnID;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.namedobject.BaseID;
import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.core.MetaMatrixRuntimeException;
public class ConfigurationModelContainerImpl implements ConfigurationModelContainer, Serializable {
@@ -410,7 +408,7 @@
}
- public void setComponentTypes(Map newCompTypes) throws ConfigurationLockException {
+ public void setComponentTypes(Map newCompTypes) {
this.compTypes = Collections.synchronizedMap(new HashMap(newCompTypes.size()));
Iterator it = newCompTypes.values().iterator();
@@ -419,7 +417,7 @@
}
}
- public void setProductTypes(Collection newProdTypes) throws ConfigurationLockException {
+ public void setProductTypes(Collection newProdTypes) {
this.prodTypes = Collections.synchronizedMap(new HashMap(newProdTypes.size()));
Iterator it = newProdTypes.iterator();
@@ -745,12 +743,8 @@
Configuration config = (Configuration) configuration.clone();
ConfigurationModelContainerImpl newConfig = new ConfigurationModelContainerImpl(config);
- try {
- newConfig.setComponentTypes(this.compTypes);
- newConfig.setProductTypes(this.prodTypes.values());
- } catch (ConfigurationLockException e) {
- throw new MetaMatrixRuntimeException(e);
- }
+ newConfig.setComponentTypes(this.compTypes);
+ newConfig.setProductTypes(this.prodTypes.values());
newConfig.setResources(this.resources);
return newConfig;
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/reader/CurrentConfigurationReader.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/reader/CurrentConfigurationReader.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/reader/CurrentConfigurationReader.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,12 +22,7 @@
package com.metamatrix.common.config.reader;
-import java.util.Properties;
-
-import com.metamatrix.common.config.StartupStateController;
-import com.metamatrix.common.config.StartupStateException;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.common.config.api.exceptions.ConfigurationConnectionException;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
/**
@@ -44,24 +39,6 @@
*/
public interface CurrentConfigurationReader {
- /**
- * This method should connect to the repository that holds the current
- * configuration, using the specified properties. The implementation
- * may <i>not</i> use logging but instead should rely upon returning
- * an exception in the case of any errors.
- * @param env the environment properties that define the information
- * @throws ConfigurationConnectionException if there is an error establishing the connection.
- */
- void connect( Properties env ) throws ConfigurationConnectionException;
-
- /**
- * This method should close the connection to the repository that holds the current
- * configuration. The implementation may <i>not</i> use logging but
- * instead should rely upon returning an exception in the case of any errors.
- * @throws Exception if there is an error establishing the connection.
- */
- void close() throws Exception;
-
// ------------------------------------------------------------------------------------
// C O N F I G U R A T I O N I N F O R M A T I O N
// ------------------------------------------------------------------------------------
@@ -76,45 +53,5 @@
*/
ConfigurationModelContainer getConfigurationModel() throws ConfigurationException;
- /**
- * This method should be called <i>only</i> by
- * {@link com.metamatrix.platform.util.MetaMatrixController}
- * to initialize the system configurations during bootstrapping.
- * This method will attempt to put the system state into
- * {@link StartupStateController#STATE_STARTING}, and then
- * commence with initialization. If the state is already
- * {@link StartupStateController#STATE_STARTING}, then another
- * MetaMatrixController is already currently in the process of
- * starting the system, and a {@link StartupStateException}
- * will be thrown. If this method returns without an
- * exception, then the system state will be in state
- * {@link StartupStateController#STATE_STARTING}, and the calling
- * code should proceed with startup.
- * @param forceInitialization if the system is in a state other than
- * {@link StartupStateController#STATE_STOPPED}, and the
- * administrator thinks the system actually crashed and is
- * not really running, he can choose to force the
- * initialization. Otherwise, if the system is in one of these states,
- * an exception will be thrown.
- * @throws StartupStateException if the system is
- * not in a state in which initialization can proceed. This
- * exception will indicate the current system state.
- * @throws ConfigurationException if the current configuration and/or
- * bootstrap properties could not be obtained
- *
- * NOTE: This method replaces the begin... and finish.. SystemInitialization methods
- * for the new configuration implementations.
- */
- void performSystemInitialization(boolean forceInitialization) throws StartupStateException, ConfigurationException;
-
-
- /**
- * This will put the system into a state of
- * {@link com.metamatrix.common.config.StartupStateController#STATE_STOPPED}.
- * @throws ConfigurationException if an error occurred in communication
- * with the configuration data source
- */
- void indicateSystemShutdown() throws ConfigurationException;
-
}
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/reader/PropertiesConfigurationReader.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/reader/PropertiesConfigurationReader.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/reader/PropertiesConfigurationReader.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -29,7 +29,7 @@
import java.util.Properties;
import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.config.StartupStateException;
+import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.ConfigurationObjectEditor;
@@ -62,20 +62,12 @@
/**
* Default, no-arg constructor
+ * @throws ConfigurationException
+ * @throws ConfigurationConnectionException
*/
- public PropertiesConfigurationReader(){
- }
-
- /**
- * This method should connect to the repository that holds the current
- * configuration, using the specified properties. The implementation
- * may <i>not</i> use logging but instead should rely upon returning
- * an exception in the case of any errors.
- * @param env the environment properties that define the information
- * @throws ConfigurationConnectionException if there is an error establishing the connection.
- */
- public void connect( Properties env ) throws ConfigurationConnectionException{
- String filename = env.getProperty(FILENAME);
+ public PropertiesConfigurationReader() throws ConfigurationConnectionException, ConfigurationException{
+ Properties env = CurrentConfiguration.getInstance().getBootStrapProperties();
+ String filename = env.getProperty(FILENAME);
Properties p = null;
if (filename != null) {
File f = new File(filename);
@@ -112,15 +104,6 @@
c = new ConfigurationModelContainerImpl(currentConfiguration);
}
- /**
- * This method should close the connection to the repository that holds the current
- * configuration. The implementation may <i>not</i> use logging but
- * instead should rely upon returning an exception in the case of any errors.
- * @throws Exception if there is an error establishing the connection.
- */
- public void close() throws Exception{
- }
-
// ------------------------------------------------------------------------------------
// C O N F I G U R A T I O N I N F O R M A T I O N
// ------------------------------------------------------------------------------------
@@ -137,16 +120,5 @@
return c;
}
- @Override
- public void indicateSystemShutdown() throws ConfigurationException {
-
- }
-
- @Override
- public void performSystemInitialization(boolean forceInitialization)
- throws StartupStateException, ConfigurationException {
-
- }
-
}
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_42_HelperImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -35,6 +35,7 @@
import org.jdom.Element;
+import com.metamatrix.admin.api.objects.PropertyDefinition.RestartType;
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.api.AuthenticationProvider;
import com.metamatrix.common.config.api.ComponentDefn;
@@ -474,9 +475,9 @@
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_PREFERRED,
defn.isPreferred(), PropertyDefinitionImpl.DEFAULT_IS_PREFERRED);
- setAttributeBoolean(element,
+ setAttributeString(element,
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.REQUIRES_RESTART,
- defn.getRequiresRestart(), PropertyDefinitionImpl.DEFAULT_REQUIRES_RESTART);
+ defn.getRequiresRestart().toString(), PropertyDefinitionImpl.DEFAULT_REQUIRES_RESTART.toString());
List allowedValues = defn.getAllowedValues();
@@ -2291,12 +2292,19 @@
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_PREFERRED,
PropertyDefinitionImpl.DEFAULT_IS_PREFERRED);
- boolean requiresRestart = getAttributeBoolean(element,
+ String requiresRestart = getAttributeString(element,
XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.REQUIRES_RESTART,
- PropertyDefinitionImpl.DEFAULT_REQUIRES_RESTART);
+ PropertyDefinitionImpl.DEFAULT_REQUIRES_RESTART.toString());
+
+ RestartType restartType = null;
+
+ if ("true".equalsIgnoreCase(requiresRestart)) { //$NON-NLS-1$
+ restartType = RestartType.PROCESS;
+ } else {
+ restartType = RestartType.valueOf(requiresRestart.toUpperCase());
+ }
+
-
-
// we must retrieve all of the allowed values from the PropertyDefinition
// element
Collection allowedValuesElements = element.getChildren(XMLConfig_42_ElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.AllowedValue.ELEMENT);
@@ -2315,7 +2323,7 @@
defn.setMasked(isMasked);
defn.setConstrainedToAllowedValues(isConstrainedToAllowedValues);
- defn.setRequiresRestart(requiresRestart);
+ defn.setRequiresRestart(restartType);
return defn;
}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,2209 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.config.xml;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jdom.Element;
-
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.config.api.ComponentDefn;
-import com.metamatrix.common.config.api.ComponentObject;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeDefn;
-import com.metamatrix.common.config.api.ComponentTypeID;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConfigurationInfo;
-import com.metamatrix.common.config.api.ConfigurationObjectEditor;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.ConnectorBindingID;
-import com.metamatrix.common.config.api.ConnectorBindingType;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.config.api.Host;
-import com.metamatrix.common.config.api.HostID;
-import com.metamatrix.common.config.api.ProductServiceConfig;
-import com.metamatrix.common.config.api.ProductServiceConfigID;
-import com.metamatrix.common.config.api.ProductType;
-import com.metamatrix.common.config.api.ProductTypeID;
-import com.metamatrix.common.config.api.ResourceDescriptor;
-import com.metamatrix.common.config.api.ServiceComponentDefn;
-import com.metamatrix.common.config.api.ServiceComponentDefnID;
-import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.config.api.VMComponentDefn;
-import com.metamatrix.common.config.api.VMComponentDefnID;
-import com.metamatrix.common.config.model.BasicComponentObject;
-import com.metamatrix.common.config.model.BasicComponentType;
-import com.metamatrix.common.config.model.BasicUtil;
-import com.metamatrix.common.config.util.ConfigurationPropertyNames;
-import com.metamatrix.common.config.util.InvalidConfigurationElementException;
-import com.metamatrix.common.namedobject.BaseID;
-import com.metamatrix.common.object.Multiplicity;
-import com.metamatrix.common.object.MultiplicityExpressionException;
-import com.metamatrix.common.object.PropertyDefinition;
-import com.metamatrix.common.object.PropertyDefinitionImpl;
-import com.metamatrix.common.object.PropertyType;
-import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.MetaMatrixProductVersion;
-//import com.metamatrix.common.util.LogCommonConstants;
-/**
-* This helper class is used to create JDOM XML Elements from configuration objects
-* and to create Configuration objects from JDOM XML Elements.
-*
-*
-* NOTE - The helper cannot have any calls to LogManager because the bootstrapping of
-* the CurrentConfiguration
-* uses this class and the CurrentConfiguration has to come up before
-* logging is available.
-*
-*/
-public class XMLHelperImpl implements XMLHelper, ConfigurationPropertyNames{
-
-
-
- /**
- * This method is used to create a Configuration JDOM Element from a
- * Configuration object.
- *
- * @param configuration the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createConfigurationElement(Configuration configuration) {
- // first we set up the organizational structure of a configuration
- Assertion.isNotNull(configuration);
- Element productServiceConfigsElement = new Element(XMLElementNames.Configurations.Configuration.ProductServiceConfigs.ELEMENT);
- Element serviceDefnsElement = createServiceComponentDefnsElement();
- Element deployedComponentsElement = new Element(XMLElementNames.Configurations.Configuration.DeployedComponents.ELEMENT);
- Element vmComponentDefnsElement = new Element(XMLElementNames.Configurations.Configuration.VMComponentDefns.ELEMENT);
- Element resourcePoolsElement = new Element(XMLElementNames.Configurations.Configuration.ResourcePools.ELEMENT);
-
-
- Element configElement = createComponentObjectElement(XMLElementNames.Configurations.Configuration.ELEMENT, configuration);
-
-// Element logConfigurationElement = createLogConfigurationElement(configuration.getLogConfiguration());
-
- configElement.addContent(productServiceConfigsElement);
- configElement.addContent(serviceDefnsElement);
- configElement.addContent(deployedComponentsElement);
- configElement.addContent(vmComponentDefnsElement);
-// configElement.addContent(logConfigurationElement);
- configElement.addContent(resourcePoolsElement);
-
- return configElement;
- }
-
- /**
- * This method is used to create a LogConfiguration JDOM Element from a
- * LogConfiguration object.
- *
- * @param info the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-// public Element createLogConfigurationElement(LogConfiguration logConfiguration) {
-// Assertion.isNotNull(logConfiguration);
-//
-//
-// Element logConfigurationElement = new Element(XMLElementNames.Configurations.Configuration.LogConfiguration.ELEMENT);
-// Element propertiesElement = null;
-// try {
-// propertiesElement = createPropertiesElement(BasicLogConfiguration.getLogConfigurationProperties(logConfiguration));
-// logConfigurationElement.addContent(propertiesElement);
-//
-// }catch(LogConfigurationException e) {
-// String msg = CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0031);
-// System.out.println(msg);
-// }
-//
-//
-// return logConfigurationElement;
-// return null;
-// }
-
-
- /**
- * This method is used to create a ConfigurationInfo JDOM Element from a
- * ConfigurationInfo object.
- *
- * @param info the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createConfigurationInfoElement(ConfigurationInfo info) {
- Assertion.isNotNull(info);
-
- Element configurationInfoElement = new Element(XMLElementNames.Configurations.Configuration.ConfigurationInfo.ELEMENT);
-
- Date date = info.getLastChangedDate();
- if (date != null) {
- configurationInfoElement.setAttribute(XMLElementNames.Configurations.Configuration.ConfigurationInfo.Attributes.LAST_CHANGED_DATE, date.toString());
- }
-
- date = info.getCreationDate();
- if (date !=null) {
- configurationInfoElement.setAttribute(XMLElementNames.Configurations.Configuration.ConfigurationInfo.Attributes.CREATION_DATE, date.toString());
- }
- return configurationInfoElement;
- }
-
-// public DeployedComponent createDeployedVMComponentDefnx(Element element,
-// ConfigurationID configID,
-// HostID hostID,
-// // VMComponentDefnID vmID,
-// // ProductServiceConfigID pscID,
-// ComponentTypeID typeID,
-// ConfigurationObjectEditor editor)
-// throws InvalidConfigurationElementException{
-// Assertion.isNotNull(element);
-// Assertion.isNotNull(editor);
-// Assertion.isNotNull(configID);
-// Assertion.isNotNull(hostID);
-// // Assertion.isNotNull(vmID);
-//
-// DeployedComponent component=null;
-//
-// if (!element.getName().equals(XMLConfig_42_ElementNames.Configuration.Process.ELEMENT)) {
-// throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()), element);
-// }
-//
-// String name = element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.Process.Attributes.NAME);
-//// checkElementValue(name, "NAME", ErrorMessageKeys.CONFIG_ERR_0048);
-//
-// String componentTypeIDString = element.getAttributeValue(XMLConfig_42_ElementNames.Configuration.DeployedComponent.Attributes.COMPONENT_TYPE);
-//
-// checkElementValue(componentTypeIDString, name, ErrorMessageKeys.CONFIG_ERR_0049);
-//
-//
-//// ComponentType type = null;
-//// Iterator it = componentTypeMap.keySet().iterator();
-//// while (it.hasNext() ) {
-//// ComponentTypeID id = (ComponentTypeID) it.next();
-//// if (id.getFullName().equals(componentTypeIDString)) {
-//// type = (ComponentType) componentTypeMap.get(id);
-//// break;
-//// }
-//// }
-//
-//// if (type == null) {
-//// throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[] {componentTypeIDString, name} ), element);
-//// }
-//
-// VMComponentDefnID vmID = new VMComponentDefnID(configID, hostID, name);
-// // component = editor.createDeployedVMComponent(name, configID, hostID, vmID, typeID);
-//// createDeployedServiceComponent(name, configID, hostID,vmID, svcid, pscID, (ComponentTypeID) type.getID());
-//
-//
-// return component;
-// }
-
-
- /**
- * This method is used to create a DeployedComponent JDOM Element from a
- * DeployedComponent object.
- *
- * @param deployedComponent the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-// public Element createDeployedComponentElement(DeployedComponent deployedComponent) {
-// Assertion.isNotNull(deployedComponent);
-//
-// String vmComponentName = null;
-// String productConfigName = null;
-//
-// VMComponentDefnID vmComponentID = deployedComponent.getVMComponentDefnID();
-// ProductServiceConfigID productConfigID = deployedComponent.getProductServiceConfigID();
-//
-// Element deployedComponentElement = createComponentObjectElement(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.ELEMENT, deployedComponent);
-//
-// // we treat these IDs specially because they are optional for Deployed
-// // Components that are VM's
-// if (vmComponentID!=null) {
-// vmComponentName = vmComponentID.getName();
-// deployedComponentElement.setAttribute(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.VM_COMPONENT_DEFN_ID, vmComponentName);
-// }
-//
-// if (productConfigID!=null) {
-// productConfigName = productConfigID.getName();
-// deployedComponentElement.setAttribute(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.PRODUCT_SERVICE_CONFIG_ID, productConfigName);
-// }
-//
-// BaseID id = deployedComponent.getServiceComponentDefnID();
-// if (id!=null) {
-// deployedComponentElement.setAttribute(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.SERVICE_COMPONENT_DEFN_ID, id.getName());
-// }
-//
-// id = deployedComponent.getHostID();
-// if (id!=null) {
-// deployedComponentElement.setAttribute(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.HOST_ID, id.getName());
-// }
-//
-// return deployedComponentElement;
-// }
-//
- /**
- * This method is used to create a VMComponentDefn JDOM Element from a
- * VMComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createVMComponentDefnElement(VMComponentDefn defn) {
- Assertion.isNotNull(defn);
-
- Element vmComponentDefnElement = createComponentObjectElement(XMLElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.ELEMENT, defn);
- return vmComponentDefnElement;
- }
-
- /**
- * This method is used to create a ServiceComponentDefn JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createServiceComponentDefnElement(ServiceComponentDefn defn) {
- Assertion.isNotNull(defn);
-
- Element serviceComponentDefnElement = createComponentObjectElement(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.ELEMENT, defn);
- serviceComponentDefnElement.setAttribute(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.Attributes.QUEUED_SERVICE, new Boolean(defn.isQueuedService()).toString());
- serviceComponentDefnElement.setAttribute(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.Attributes.ROUTING_UUID, defn.getRoutingUUID());
- return serviceComponentDefnElement;
- }
-
- /**
- * This method is used to create a ServiceComponentDefn JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
-// public Element createServiceComponentDefnElement(ResourceDescriptor defn) {
-// Assertion.isNotNull(defn);
-//
-// Element serviceComponentDefnElement = createComponentObjectElement(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.ELEMENT, defn);
-// return serviceComponentDefnElement;
-// }
-
- /**
- * This method is used to create a ProductServiceConfig JDOM Element from a
- * ProductServiceConfig object.
- *
- * @param config the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createProductServiceConfigElement(ProductServiceConfig config) {
- Assertion.isNotNull(config);
-
- Element productServiceConfigElement = createComponentObjectElement(XMLElementNames.Configurations.Configuration.ProductServiceConfigs.ProductServiceConfig.ELEMENT, config);
-
- Iterator iterator = config.getServiceComponentDefnIDs().iterator();
- while (iterator.hasNext()) {
- ServiceComponentDefnID id = (ServiceComponentDefnID)iterator.next();
- boolean isEnabled = config.isServiceEnabled(id);
-
- Element idElement = createIDElement(XMLElementNames.Configurations.Configuration.ServiceComponentDefnID.ELEMENT, id.getName());
-
- idElement.setAttribute(XMLElementNames.Configurations.Configuration.ProductServiceConfigs.ProductServiceConfig.Attributes.IS_ENABLED, (new Boolean(isEnabled)).toString());
-
- productServiceConfigElement.addContent(idElement);
- }
- return productServiceConfigElement;
- }
-
- /**
- * This method is used to create a ComponentType JDOM Element from a
- * ComponentType object.
- *
- * @param type the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createComponentTypeElement(ComponentType type) {
- Assertion.isNotNull(type);
-
- Element componentTypeElement = new Element(XMLElementNames.ComponentTypes.ComponentType.ELEMENT);
- Iterator iterator = type.getComponentTypeDefinitions().iterator();
- while (iterator.hasNext()) {
- ComponentTypeDefn defn = (ComponentTypeDefn)iterator.next();
- Element componentTypeDefnElement = createComponentTypeDefnElement(defn);
- Element propertyDefinitionElement = createPropertyDefinitionElement(defn.getPropertyDefinition());
- componentTypeDefnElement.addContent(propertyDefinitionElement);
- componentTypeElement.addContent(componentTypeDefnElement);
- }
- componentTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.NAME, type.getName());
- componentTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE, new Integer(type.getComponentTypeCode()).toString());
- componentTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE, (new Boolean(type.isDeployable())).toString());
- componentTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.DEPRECATED, (new Boolean(type.isDeprecated())).toString());
- componentTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE, (new Boolean(type.isMonitored())).toString());
-
- // we only add these if they are not null
- BaseID superID = type.getSuperComponentTypeID();
- String superIDString;
- if (superID != null) {
- superIDString = superID.getName();
- componentTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE, superIDString);
-
- }
-
- BaseID parentID = type.getParentComponentTypeID();
- String parentIDString;
- if (parentID!=null) {
- parentIDString = parentID.getName();
- componentTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.PARENT_COMPONENT_TYPE, parentIDString);
-
- }
-
- Element chgHistoryElement = createChangeHistoryElement(type);
- componentTypeElement.addContent(chgHistoryElement);
-
-
- return componentTypeElement;
- }
-
- /**
- * This method is used to create a PropertyDefinition JDOM Element from a
- * PropertyDefinition object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createPropertyDefinitionElement(PropertyDefinition defn) {
- Assertion.isNotNull(defn);
-
-
- Element propertyDefinitionElement = new Element(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT);
-
- String name = defn.getName();
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.NAME, name);
-
- String displayName = defn.getDisplayName();
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DISPLAY_NAME,displayName);
-
- String shortDescription = defn.getShortDescription();
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.SHORT_DESCRIPTION, shortDescription);
-
-
- String defaultValue;
- Object value = defn.getDefaultValue();
- if (value!=null) {
-
- defaultValue = value.toString();
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DEFAULT_VALUE, defaultValue);
-
- }
-
- String multiplicity;
- Multiplicity mult = defn.getMultiplicity();
- if (mult!=null) {
- multiplicity = mult.toString();
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.MULTIPLICITY, multiplicity);
- }
-
- String propertyType;
- PropertyType type = defn.getPropertyType();
- if (type != null) {
- propertyType = type.getDisplayName();
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.PROPERTY_TYPE, propertyType);
- }
-
- String valueDelimiter = defn.getValueDelimiter();
- if (valueDelimiter == null) {
- valueDelimiter = PropertyDefinitionImpl.DEFAULT_DELIMITER;
- }
-
- String isConstrainedToAllowedValues = (new Boolean(defn.isConstrainedToAllowedValues())).toString();
- String isExpert = (new Boolean(defn.isExpert())).toString();
- String isHidden = (new Boolean(defn.isHidden())).toString();
- String isMasked = (new Boolean(defn.isMasked())).toString();
- String isModifiable =(new Boolean(defn.isModifiable())).toString();
- String isPreferred = (new Boolean(defn.isPreferred())).toString();
-
-
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.VALUE_DELIMITER, valueDelimiter);
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_CONSTRAINED_TO_ALLOWED_VALUES, isConstrainedToAllowedValues);
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_EXPERT, isExpert);
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_HIDDEN, isHidden);
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MASKED, isMasked);
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MODIFIABLE, isModifiable);
- propertyDefinitionElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_PREFERRED, isPreferred);
-
- List allowedValues = defn.getAllowedValues();
- Iterator iterator = allowedValues.iterator();
- while (iterator.hasNext()) {
- Element allowedValueElement = new Element(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.AllowedValue.ELEMENT);
- allowedValueElement.addContent((iterator.next()).toString());
- propertyDefinitionElement.addContent(allowedValueElement);
- }
-
- return propertyDefinitionElement;
-
- }
-
- /**
- * This method is used to create a ComponentTypeDefn JDOM Element from a
- * ComponentTypeDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createComponentTypeDefnElement(ComponentTypeDefn defn) {
- Assertion.isNotNull(defn);
-
- Element componentTypeDefnElement = new Element(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
- componentTypeDefnElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.Attributes.DEPRECATED, (new Boolean(defn.isDeprecated())).toString());
- return componentTypeDefnElement;
- }
-
- /**
- * This method is used to create a ProductType JDOM Element from a
- * ProductType object.
- *
- * @param type the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createProductTypeElement(ProductType type) {
- Assertion.isNotNull(type);
-
- Element productTypeElement = new Element(XMLElementNames.ProductTypes.ProductType.ELEMENT);
-
-
- Iterator iterator = type.getComponentTypeIDs().iterator();
- while (iterator.hasNext()) {
- ComponentTypeID id = (ComponentTypeID)iterator.next();
- Element componentTypeIDElement = createIDElement(XMLElementNames.ComponentTypeID.ELEMENT, id.getName());
- productTypeElement.addContent(componentTypeIDElement);
- }
-
- productTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.NAME, type.getName());
- productTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE, new Integer(type.getComponentTypeCode()).toString());
- productTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE, (new Boolean(type.isDeployable())).toString());
- productTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.DEPRECATED, (new Boolean(type.isDeprecated())).toString());
- productTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE, (new Boolean(type.isMonitored())).toString());
-
- // we only add these if they are not null
- BaseID superID = type.getSuperComponentTypeID();
- String superIDString;
- if (superID != null) {
- superIDString = superID.getName();
- productTypeElement.setAttribute(XMLElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE, superIDString);
-
- }
-
-
- Element chgHistoryElement = createChangeHistoryElement(type);
- productTypeElement.addContent(chgHistoryElement);
-
-
- return productTypeElement;
-
- }
-
- /**
- * This method is used to create a Host JDOM Element from a
- * Host object.
- *
- * @param host the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createHostElement(Host host) {
- Assertion.isNotNull(host);
-
- Element hostElement = createComponentObjectElement(XMLElementNames.Hosts.Host.ELEMENT, host);
- return hostElement;
- }
-
-
- public Properties getHeaderProperties(Element element) throws InvalidConfigurationElementException{
-// Properties props=new Properties();
-
- if (!element.getName().equals(XMLElementNames.Header.ELEMENT)) {
- throw new InvalidConfigurationElementException("This is not the header element: " + element.getName() + ".", element); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return XMLHelperUtil.getHeaderProperties(element);
-// List elements = element.getChildren();
-// Iterator it = elements.iterator();
-// while(it.hasNext()) {
-// final Element e = (Element) it.next();
-// props.setProperty(e.getName(), e.getText());
-// }
-
-// Element appElement = element.getChild(XMLElementNames.Header.ApplicationCreatedBy.ELEMENT);
-// if (appElement != null) {
-// props.setProperty(XMLElementNames.Header.ApplicationCreatedBy.ELEMENT, appElement.getText());
-// }
-//
-// Element appVElement = element.getChild(XMLElementNames.Header.ApplicationVersionCreatedBy.ELEMENT);
-// if (appVElement != null) {
-// props.setProperty(XMLElementNames.Header.ApplicationVersionCreatedBy.ELEMENT, appVElement.getText());
-// } else {
-// throw new InvalidConfigurationElementException("The header section in the configuration does not contain the Application Version Property", element); //$NON-NLS-1$ //$NON-NLS-2$
-//
-// }
-//
-// Element ucElement = element.getChild(XMLElementNames.Header.UserCreatedBy.ELEMENT);
-// if (ucElement != null) {
-// props.setProperty(XMLElementNames.Header.UserCreatedBy.ELEMENT, ucElement.getText());
-// }
-//
-// Element svElement = element.getChild(XMLElementNames.Header.MetaMatrixSystemVersion.ELEMENT);
-// if (svElement != null) {
-// props.setProperty(XMLElementNames.Header.MetaMatrixSystemVersion.ELEMENT, svElement.getText());
-// } else {
-// throw new InvalidConfigurationElementException("The header section in the configuration does not contain the MetaMatrix Server Version Element", element); //$NON-NLS-1$ //$NON-NLS-2$
-// }
-//
-// Element tElement = element.getChild(XMLElementNames.Header.Time.ELEMENT);
-// if (tElement != null) {
-// props.setProperty(XMLElementNames.Header.Time.ELEMENT, tElement.getText());
-// }
-
-
-// return props;
- }
-
-
- /**
- * <p>This method is used to create a Header JDOM Element from a
- * Properties object. The properties object can contain any of the
- * following properties that will be included in the header:<p>
- * <pre>
- * XMLElementNames.Header.ApplicationCreatedDate.ELEMENT
- * XMLElementNames.Header.ApplicationVersionCreatedBy.ELEMENT
- * XMLElementNames.Header.UserName.ELEMENT
- * XMLElementNames.Header.DocumentTypeVersion.ELEMENT
- * XMLElementNames.Header.MetaMatrixServerVersion.ELEMENT
- * XMLElementNames.Header.Time.ELEMENT
- * <pre>
- * <p>Any of these properties that are not included in the properties object
- * will not be included in the header Element that is returned.
- *
- * @param props the properties object that contains the values for the Header
- * @return a JDOM XML Element
- */
- public Element createHeaderElement(Properties props) {
- Assertion.isNotNull(props);
-
- Element headerElement = new Element(XMLElementNames.Header.ELEMENT);
- String applicationCreatedByContent = props.getProperty(XMLElementNames.Header.ApplicationCreatedBy.ELEMENT);
- String applicationVersionCreatedByContent = props.getProperty(XMLElementNames.Header.ApplicationVersionCreatedBy.ELEMENT);
- String userNameContent = props.getProperty(XMLElementNames.Header.UserCreatedBy.ELEMENT);
- String configVersionContent = props.getProperty(XMLElementNames.Header.ConfigurationVersion.ELEMENT);
- String serverVersionContent = props.getProperty(XMLElementNames.Header.MetaMatrixSystemVersion.ELEMENT);
- String timeContent = props.getProperty(XMLElementNames.Header.Time.ELEMENT);
-
-
- if (configVersionContent !=null) {
- Element configurationVersion = new Element(XMLElementNames.Header.ConfigurationVersion.ELEMENT);
- configurationVersion.addContent(configVersionContent);
- headerElement.addContent(configurationVersion);
- }
-
- if (applicationCreatedByContent !=null) {
- Element applicationCreatedBy = new Element(XMLElementNames.Header.ApplicationCreatedBy.ELEMENT);
- applicationCreatedBy.addContent(applicationCreatedByContent);
- headerElement.addContent(applicationCreatedBy);
- }
-
- if (applicationVersionCreatedByContent != null) {
- Element applicationVersionCreatedBy = new Element(XMLElementNames.Header.ApplicationVersionCreatedBy.ELEMENT);
- applicationVersionCreatedBy.addContent(applicationVersionCreatedByContent);
- headerElement.addContent(applicationVersionCreatedBy);
- }
-
- if (userNameContent != null) {
- Element userName = new Element(XMLElementNames.Header.UserCreatedBy.ELEMENT);
- userName.addContent(userNameContent);
- headerElement.addContent(userName);
- }
-
-// if (documentTypeVersionContent != null) {
-// Element documentTypeVersion = new Element(XMLElementNames.Header.DocumentTypeVersion.ELEMENT);
-// documentTypeVersion.addContent(documentTypeVersionContent);
-// headerElement.addContent(documentTypeVersion);
-// }
-
- if (serverVersionContent != null) {
- Element serverVersion = new Element(XMLElementNames.Header.MetaMatrixSystemVersion.ELEMENT);
- serverVersion.addContent(serverVersionContent);
- headerElement.addContent(serverVersion);
- }
-
- if (timeContent != null) {
- Element time = new Element(XMLElementNames.Header.Time.ELEMENT);
- time.addContent(timeContent);
- headerElement.addContent(time);
- }
- return headerElement;
-
- }
-
- private ComponentObject setDateHistory(ComponentObject defn, Element element, ConfigurationObjectEditor editor) {
-
- String lastChangedBy=null;
- String lastChangedDate=null;
- String createdDate=null;
- String createdBy=null;
-
- Properties props = getChangeHistoryFromElement(element);
-
- lastChangedBy = props.getProperty(XMLElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
- lastChangedDate = props.getProperty(XMLElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
- createdBy = props.getProperty(XMLElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
- createdDate = props.getProperty(XMLElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
-
- defn = editor.setCreationChangedHistory(defn, createdBy, createdDate);
- defn = editor.setLastChangedHistory(defn, lastChangedBy, lastChangedDate);
-
- return defn;
-
- }
-
- private ComponentType setDateHistory(ComponentType type, Element element, ConfigurationObjectEditor editor) {
- String lastChangedBy=null;
- String lastChangedDate=null;
- String createdDate=null;
- String createdBy=null;
-
- Properties props = getChangeHistoryFromElement(element);
-
- lastChangedBy = props.getProperty(XMLElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY);
- lastChangedDate = props.getProperty(XMLElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE);
- createdBy = props.getProperty(XMLElementNames.ChangeHistory.Property.NAMES.CREATED_BY);
- createdDate = props.getProperty(XMLElementNames.ChangeHistory.Property.NAMES.CREATION_DATE);
-
-
- type = editor.setCreationChangedHistory(type, createdBy, createdDate);
- type = editor.setLastChangedHistory(type, lastChangedBy, lastChangedDate);
-
- return type;
-
- }
-
-
- private Properties getChangeHistoryFromElement(Element parentElement) {
-
- Element propertiesElement = parentElement.getChild(XMLElementNames.ChangeHistory.ELEMENT);
-
- if (propertiesElement == null ) {
- return new Properties();
- }
-
- Properties props = new Properties();
-
- List properties = propertiesElement.getChildren(XMLElementNames.ChangeHistory.Property.ELEMENT);
- if (properties == null) {
- return new Properties();
- }
- Iterator iterator = properties.iterator();
- while (iterator.hasNext()) {
- Element propertyElement = (Element)iterator.next();
- String propertyName = propertyElement.getAttributeValue(XMLElementNames.ChangeHistory.Property.Attributes.NAME);
- String propertyValue = propertyElement.getText();
-
- props.setProperty(propertyName, (propertyValue!=null?propertyValue:"")); //$NON-NLS-1$
-
- }
- return props;
-
- }
-
-
- private Element createChangeHistoryElement(ComponentType obj) {
-
-// call to create the structure for the properties
- Element changeHistoryElement = new Element(XMLElementNames.ChangeHistory.ELEMENT);
-
- String lastChangedBy=null;
- String lastChangedDate=null;
- String createdDate=null;
- String createdBy=null;
-
- lastChangedBy = obj.getLastChangedBy();
- lastChangedDate = ((BasicComponentType) obj).getLastChangedDateString();
-
- createdBy = obj.getCreatedBy();
- createdDate = ((BasicComponentType) obj).getCreatedDateString();
-
-
- if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
-
- } else {
-
- changeHistoryElement = addPropertyElement(changeHistoryElement, XMLElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY, lastChangedBy);
- }
-
- if (lastChangedDate == null) {
- } else {
-
- changeHistoryElement = addPropertyElement(changeHistoryElement, XMLElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE, lastChangedDate);
- }
-
- if (createdBy == null || createdBy.trim().length() == 0) {
- } else {
-
- changeHistoryElement = addPropertyElement(changeHistoryElement, XMLElementNames.ChangeHistory.Property.NAMES.CREATED_BY, createdBy);
- }
-
- if (createdDate == null) {
- } else {
- changeHistoryElement = addPropertyElement(changeHistoryElement, XMLElementNames.ChangeHistory.Property.NAMES.CREATION_DATE,createdDate);
- }
-
- return changeHistoryElement;
-
-
- }
-
- private Element createChangeHistoryElement(ComponentObject obj) {
-
- Element changeHistoryElement = new Element(XMLElementNames.ChangeHistory.ELEMENT);
-
- String lastChangedBy=null;
- String lastChangedDate=null;
- String createdDate=null;
- String createdBy=null;
-
- lastChangedBy = obj.getLastChangedBy();
- lastChangedDate = ((BasicComponentObject) obj).getLastChangedDateString();
-
- createdBy = obj.getCreatedBy();
- createdDate = ((BasicComponentObject) obj).getCreatedDateString();
-
-
- if (lastChangedBy == null || lastChangedBy.trim().length() == 0) {
-
- } else {
-
- changeHistoryElement = addPropertyElement(changeHistoryElement, XMLElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_BY, lastChangedBy);
- }
-
- if (lastChangedDate == null) {
-
- } else {
-
- changeHistoryElement = addPropertyElement(changeHistoryElement, XMLElementNames.ChangeHistory.Property.NAMES.LAST_CHANGED_DATE, lastChangedDate);
-
- }
-
- if (createdBy == null || createdBy.trim().length() == 0) {
- } else {
-
- changeHistoryElement = addPropertyElement(changeHistoryElement, XMLElementNames.ChangeHistory.Property.NAMES.CREATED_BY, createdBy);
- }
-
- if (createdDate == null) {
- } else {
- changeHistoryElement = addPropertyElement(changeHistoryElement, XMLElementNames.ChangeHistory.Property.NAMES.CREATION_DATE, createdDate);
- }
-
- return changeHistoryElement;
- }
-
-
- /**
- * This method is used to create a Properties JDOM Element from a
- * Properties object.
- *
- * @param props the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createPropertiesElement(Properties props) {
- Assertion.isNotNull(props);
-
- Properties sortprops = PropertiesUtils.sort(props);
- Element propertiesElement = new Element(XMLElementNames.Properties.ELEMENT);
- Enumeration enumeration = sortprops.propertyNames();
- while (enumeration.hasMoreElements()) {
- String propName = (String)enumeration.nextElement();
- propertiesElement = addPropertyElement(propertiesElement, propName, props.getProperty(propName));
- }
-
- return propertiesElement;
- }
-
-
- private Element addPropertyElement(Element propertiesElement, String propName, String propValue) {
- Element property = new Element(XMLElementNames.Properties.Property.ELEMENT);
- property.setAttribute(XMLElementNames.Properties.Property.Attributes.NAME, propName);
- property.addContent(propValue);
- propertiesElement.addContent(property);
- return propertiesElement;
-
- }
-
-
-
- /**
- * This method is used to create a Configuration ID JDOM Element from a
- * Configuration ID object.
- *
- * @param type the ID type to be created. @see XMLElementNames.Configurations.Configuration.XXXID.ELEMENT for valid values
- * @param name the calue of the name attribute of the ID element to create.
- * @return a JDOM XML Element
- */
- public Element createIDElement(String type, String name) {
-
- Element idElement = new Element(type);
- idElement.setAttribute(XMLElementNames.ID.Attributes.NAME, name);
- return idElement;
- }
-
- /**
- * This method is used to create a Configurations JDOM Element from a
- * Configuration ID object. This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createConfigurationsElement() {
- return new Element(XMLElementNames.Configurations.ELEMENT);
- }
-
- /**
- * This method is used to create a Hosts JDOM Element from a
- * Configuration ID object. This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createHostsElement() {
- return new Element(XMLElementNames.Hosts.ELEMENT);
- }
-
- /**
- * This method is used to create a ServiceComponentDefns JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createServiceComponentDefnsElement() {
- return new Element(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ELEMENT);
- }
-
- /**
- * This method is used to create a ComponentTypes JDOM Element from a
- * Configuration ID object. This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createComponentTypesElement() {
- return new Element(XMLElementNames.ComponentTypes.ELEMENT);
- }
-
- public Element createProductTypesElement() {
- return new Element(XMLElementNames.ProductTypes.ELEMENT);
- }
-
- public Element createProductServiceConfigsElement() {
- throw new UnsupportedOperationException("createProductServiceConfigsElement is unsupported in the 3.0 version of configuration"); //$NON-NLS-1$
-
- }
-
-
- public Element createConnectorBindingsElement() {
- return new Element(XMLElementNames.ConnectorComponents.ELEMENT);
- }
-
-
- /**
- * This method is used to create a root JDOM Element.
- * This element is for structural organization
- * only and does not represent any real configuration object.
- *
- * @return a JDOM XML Element
- */
- public Element createRootConfigurationDocumentElement() {
- return new Element(XMLElementNames.ELEMENT);
- }
-
-
- /**
- * This method is used to create a ComponentObject JDOM Element from a
- * ComponentObject object.
- *
- * @param type The subclass type of the configuration object to be created.
- * @see XMLElementNames.Configurations.Configuration.XXXX.ELEMENT
- * @param componentObject the object to create the Element for.
- * @return a JDOM XML Element
- */
- private Element createComponentObjectElement(String type, ComponentObject componentObject) {
- Element componentObjectElement = new Element(type);
- componentObjectElement.setAttribute(XMLElementNames.ComponentObject.Attributes.NAME, componentObject.getName());
- BaseID id = componentObject.getComponentTypeID();
- if (id !=null) {
- componentObjectElement.setAttribute(XMLElementNames.ComponentObject.Attributes.COMPONENT_TYPE, id.getName());
- }
-
- // this will add the changed history information
- Element properties = createPropertiesElement( componentObject.getProperties());
- componentObjectElement.addContent(properties);
-
- Element chgHistoryElement = createChangeHistoryElement(componentObject);
- componentObjectElement.addContent(chgHistoryElement);
-
-
- return componentObjectElement;
- }
-
-
-
-// ##############################################################################
-//
-// Configuration Object Creation Methods
-//
-// ##############################################################################
-
-
- /**
- * This method will create a Host configuration object from an XML element
- * that represents a Host.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the Host configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public Host createHost(Element element, ConfigurationID configID, ConfigurationObjectEditor editor, String name) throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if (!element.getName().equals(XMLElementNames.Hosts.Host.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0032, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0032, element.getName()), element);
- }
- if (name == null) {
- name = element.getAttributeValue(XMLElementNames.Hosts.Host.Attributes.NAME);
- }
-
- Host host = editor.createHost(configID, name);
-
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
-
- host = (Host) setDateHistory(host, element, editor);
-
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- host = (Host)addProperties(propertiesElement, host, editor);
-
- return host;
- }
-
- return host;
- }
-
- //
- /**
- * This method is used to create a ResourceDescriptor JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createResourcePoolElement(ResourceDescriptor resource) {
- Assertion.isNotNull(resource);
-
- Element resourceElement = createComponentObjectElement(XMLElementNames.Configurations.Configuration.ResourcePools.ResourcePool.ELEMENT, resource);
- return resourceElement;
- }
-
-
- /**
- * This method will create a Resource configuration object from an XML element
- * that represents a Resource.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the SharedResource configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ResourceDescriptor createResourcePool(Element element, ConfigurationID configID, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if (!element.getName().equals(XMLElementNames.Configurations.Configuration.ResourcePools.ResourcePool.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0033, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0033, element.getName()), element);
- }
-
- String name = element.getAttributeValue(XMLElementNames.Configurations.Configuration.ResourcePools.ResourcePool.Attributes.NAME);
-
- checkElementValue(name, null, ErrorMessageKeys.CONFIG_ERR_0053);
-
- String type = element.getAttributeValue(XMLElementNames.Configurations.Configuration.ResourcePools.ResourcePool.Attributes.COMPONENT_TYPE);
-
- checkElementValue(type, name, ErrorMessageKeys.CONFIG_ERR_0054);
-
- ComponentTypeID id = new ComponentTypeID(type);
-
- // create the descriptor used to get the resource
- ResourceDescriptor descriptor = editor.createResourceDescriptor(configID, id, name);
-
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
-
- descriptor = (ResourceDescriptor) setDateHistory(descriptor, element, editor);
-
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- descriptor = (ResourceDescriptor)addProperties(propertiesElement, descriptor, editor);
-
- }
-
-
- return descriptor;
- }
-
- public Element createResourcePoolsElement() {
- return new Element(XMLElementNames.Configurations.Configuration.ResourcePools.ELEMENT);
- }
-
-
- //
- /**
- * This method is used to create a ServiceComponentDefn JDOM Element from a
- * ServiceComponentDefn object.
- *
- * @param defn the Object to be converted to a JDOM XML Element
- * @return a JDOM XML Element
- */
- public Element createSharedResourceElement(SharedResource resource) {
- Assertion.isNotNull(resource);
-
- Element resourceElement = createComponentObjectElement(XMLElementNames.Resources.Resource.ELEMENT, resource);
- return resourceElement;
- }
-
-
- /**
- * This method will create a Resource configuration object from an XML element
- * that represents a Resource.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the SharedResource configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public SharedResource createSharedResource(Element element, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if (!element.getName().equals(XMLElementNames.Resources.Resource.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0034, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0034, element.getName()), element);
- }
-
- String name = element.getAttributeValue(XMLElementNames.Resources.Resource.Attributes.NAME);
-
- checkElementValue(name, null, ErrorMessageKeys.CONFIG_ERR_0055);
-
- String type = element.getAttributeValue(XMLElementNames.Resources.Resource.Attributes.COMPONENT_TYPE);
-
- checkElementValue(type, name, ErrorMessageKeys.CONFIG_ERR_0056);
-
- ComponentTypeID id = new ComponentTypeID(type);
-
- // create the descriptor used to get the resource
- SharedResource descriptor = editor.createSharedResource(
- id,
- name);
-
-
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
-
- descriptor = (SharedResource) setDateHistory(descriptor, element, editor);
-
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- descriptor = (SharedResource)addProperties(propertiesElement, descriptor, editor);
- }
-
- return descriptor;
- }
-
- public Element createSharedResourcesElement() {
- return new Element(XMLElementNames.Resources.ELEMENT);
- }
-
- /**
- * This method will create a ComponentType configuration object from an XML element
- * that represents a ComponentType.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ComponentType configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ComponentType createComponentType(Element element, ConfigurationObjectEditor editor, String name, boolean maintainParentID) throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if (!element.getName().equals(XMLElementNames.ComponentTypes.ComponentType.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0035, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0035, element.getName()), element);
- }
-
- // retreive the attributes of this ComponentType from the JDOM element
- String parentType = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.Attributes.PARENT_COMPONENT_TYPE);
- String superType = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE);
- String componentTypeCode = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.Attributes.COMPONENT_TYPE_CODE);
- String deployable = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.Attributes.DEPLOYABLE);
- String monitorable = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.Attributes.MONITORABLE);
-
- // we will use the passed in name unless it is null...
- if (name == null) {
- name = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.Attributes.NAME);
- }
-
- // convert them into their proper data types
- int typeCode = Integer.parseInt(componentTypeCode);
-
- ComponentTypeID parentTypeID = null;
- ComponentTypeID superTypeID = null;
-
- if (parentType != null && parentType.length() > 0) {
- parentTypeID = new ProductTypeID(parentType);
- }
-
- if (superType !=null && superType.length() > 0) {
- superTypeID = new ComponentTypeID(superType);
- }
-
- boolean isDeployable = (Boolean.valueOf(deployable)).booleanValue();
- boolean isMonitorable = (Boolean.valueOf(monitorable)).booleanValue();
-
- // create the ComponentTypeObject
- ComponentType type = editor.createComponentType(typeCode, name, parentTypeID, superTypeID, isDeployable, isMonitorable);
-
- // get the ComponentTypeDefn sub-Elements of this ComponentType
- // and create them also.
- List componentTypeDefnElements = element.getChildren(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
-
-
- type = setDateHistory(type, element, editor);
-
- return addComponentTypeDefns(componentTypeDefnElements, type, editor);
-
- }
-
-
-
- /**
- * This method will create a ProductType configuration object from an XML element
- * that represents a ProductType.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @param componentTypeMap this is a map of ComponentTypeID--->ComponentType
- * it must contain all of the Component types that the ProductType
- * that is represented by the passed in XML element references.
- * @return the ProductType configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ProductType createProductType(Element element, ConfigurationObjectEditor editor, Map componentTypeMap, String name)throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if (!element.getName().equals(XMLElementNames.ProductTypes.ProductType.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0036, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0036, element.getName()), element);
- }
-
- // retreive the attributes of this ComponentType from the JDOM element
- String deployable = element.getAttributeValue(XMLElementNames.ProductTypes.ProductType.Attributes.DEPLOYABLE);
-// String monitorable = element.getAttributeValue(XMLElementNames.ProductTypes.ProductType.Attributes.MONITORABLE);
-
- // we will use the passed in name unless it is null...
- if (name == null) {
- name = element.getAttributeValue(XMLElementNames.ProductTypes.ProductType.Attributes.NAME);
- }
-
- boolean isDeployable = (Boolean.valueOf(deployable)).booleanValue();
- // boolean isMonitorable = (Boolean.valueOf(monitorable)).booleanValue();
-
- List componentTypeIDs = element.getChildren(XMLElementNames.ComponentTypeID.ELEMENT);
- List componentTypes = new ArrayList();
- Iterator iter = componentTypeIDs.iterator();
- while (iter.hasNext()) {
- Element componentTypeIDElement = (Element)iter.next();
- String componentTypeIDName = componentTypeIDElement.getAttributeValue(XMLElementNames.ComponentTypeID.Attributes.NAME);
- ComponentTypeID componentTypeID = new ComponentTypeID(componentTypeIDName);
- ComponentType componentType = (ComponentType)componentTypeMap.get(componentTypeID);
- if (componentType == null) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0037, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0037, new Object[] {componentTypeID, name}), element);
- }
- componentTypes.add(componentType);
- }
-
- // create the ComponentTypeObject
- ProductType type = editor.createProductType(name, componentTypes, isDeployable, false);
-
- return type;
-// // get the ComponentTypeDefn sub-Elements of this ComponentType
-// // and create them also.
-// Collection componentTypeDefnElements = element.getChildren(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.ELEMENT);
-//
-// type = (ProductType) setDateHistory(type, element, editor);
-//
-// return (ProductType)addComponentTypeDefns(componentTypeDefnElements, type, editor);
- }
-
- /**
- * This method will create a Configuration configuration object from an XML element
- * that represents a Configuration.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the Configuration configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public Configuration createConfiguration(Element element, ConfigurationObjectEditor editor, String name) throws InvalidConfigurationElementException{
-
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if (!element.getName().equals(XMLElementNames.Configurations.Configuration.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0038, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0038, element.getName()), element);
- }
-
- if (name==null) {
- name = element.getAttributeValue(XMLElementNames.Configurations.Configuration.Attributes.NAME);
- }
-
- Configuration config = editor.createConfiguration(name);
-
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
-
- config = (Configuration) setDateHistory(config, element, editor);
-
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- config = (Configuration)addProperties(propertiesElement, config, editor);
-
- return config;
- }
-
- return config;
- }
-
- /**
- * This method will create a LogConfiguration configuration object from an XML element
- * that represents a LogConfiguration.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the LogConfiguration configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
-// public LogConfiguration createLogConfiguration(Element element) throws InvalidConfigurationElementException{
-// Assertion.isNotNull(element);
-//
-// if (!element.getName().equals(XMLElementNames.Configurations.Configuration.LogConfiguration.ELEMENT)) {
-// throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0039, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0039, element.getName()), element);
-// }
-//
-// Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
-// Properties properties = new Properties();
-//
-//
-// List props = propertiesElement.getChildren(XMLElementNames.Properties.Property.ELEMENT);
-// Iterator iterator = props.iterator();
-// while (iterator.hasNext()) {
-// Element propertyElement = (Element)iterator.next();
-// String propertyName = propertyElement.getAttributeValue(XMLElementNames.Properties.Property.Attributes.NAME);
-// String propertyValue = propertyElement.getText();
-// properties.setProperty(propertyName, propertyValue);
-// }
-//
-// LogConfiguration config = null;
-//
-// try {
-// config = BasicLogConfiguration.createLogConfiguration(properties);
-// }catch(LogConfigurationException e) {
-// throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0040, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0040,e.getMessage()), element);
-//
-// }
-//
-// return config;
-// return null;
-//
-// }
-
- public Element createConnectorBindingElement(ConnectorBinding connector, boolean isExportConfig) {
-
- Assertion.isNotNull(connector);
-
- Element connectorElement = createComponentObjectElement(XMLElementNames.ConnectorComponents.ConnectorComponent.ELEMENT, connector);
-
- connectorElement.setAttribute(XMLElementNames.ConnectorComponents.ConnectorComponent.Attributes.QUEUED_SERVICE, new Boolean(connector.isQueuedService()).toString());
- // vah - 09-24-2003
- // when exporting a configuration, export the routing uuid to
- // otherwise do not export it so that upon import
- // the routingUUID to be regenerated.
- // This is done to help ensure there are no duplicate UUIDs
- if (isExportConfig) {
- connectorElement.setAttribute(XMLElementNames.ConnectorComponents.ConnectorComponent.Attributes.ROUTING_UUID, connector.getRoutingUUID());
- }
-
- return connectorElement;
-
- }
-
-
- public ConnectorBinding createConnectorBinding(ConfigurationID configurationID, Element element, ConfigurationObjectEditor editor, String name, boolean isImportConfig)throws InvalidConfigurationElementException {
-
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
-
- if (!element.getName().equals(XMLElementNames.ConnectorComponents.ConnectorComponent.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0041, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0041,element.getName()), element);
- }
-
- if (name==null) {
- name = element.getAttributeValue(XMLElementNames.ConnectorComponents.ConnectorComponent.Attributes.NAME);
- }
-
- String componentType = element.getAttributeValue(XMLElementNames.ConnectorComponents.ConnectorComponent.Attributes.COMPONENT_TYPE);
-
- checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0057);
-
- ComponentTypeID id = new ComponentTypeID(componentType);
-
-// element.getAttributeValue(XMLElementNames.ConnectorComponents.ConnectorComponent.Attributes.QUEUED_SERVICE);
-
- String routingUUID = null;
- // vah - 09-24-2003
- // when importing a configuration use the routing uuid,
- // otherwise do not use it (which will cause the routingUUID to be regenerated)
- // This is done to help ensure there are no duplicate UUIDs
- if (isImportConfig) {
- routingUUID = element.getAttributeValue(XMLElementNames.ConnectorComponents.ConnectorComponent.Attributes.ROUTING_UUID);
- }
-
- ConnectorBinding defn = null;
- defn = editor.createConnectorComponent(configurationID, id, name, routingUUID);
-
- defn = (ConnectorBinding) setDateHistory(defn, element, editor);
-
- // add the properties to this ComponentObject...
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- return (ConnectorBinding)addProperties(propertiesElement, defn, editor);
- }
-
- return defn;
- }
-
-
- /**
- * This method will create a ServiceComponentDefn configuration object from an XML element
- * that represents a ServiceComponentDefn.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ServiceComponentDefn configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ComponentDefn createServiceComponentDefn(Element element, Configuration config, ConfigurationObjectEditor editor, String name) throws InvalidConfigurationElementException{
- ConfigurationID configID = null;
- if (config != null) {
- configID = (ConfigurationID) config.getID();
- }
- return createServiceComponentDefn(element, configID, editor, name);
-
- }
-
- public ComponentDefn createServiceComponentDefn(Element element, ConfigurationID configID, ConfigurationObjectEditor editor, String name)throws InvalidConfigurationElementException {
-
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
- Assertion.isNotNull(configID);
-
- if (!element.getName().equals(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0042, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0042,element.getName()), element);
- }
-
- if (name==null) {
- name = element.getAttributeValue(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.Attributes.NAME);
- }
-
- String componentType = element.getAttributeValue(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.Attributes.COMPONENT_TYPE);
-
- checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0058);
-
- ComponentTypeID id = new ComponentTypeID(componentType);
-
-// element.getAttributeValue(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.Attributes.QUEUED_SERVICE);
-
- String routingUUID = element.getAttributeValue(XMLElementNames.Configurations.Configuration.ServiceComponentDefns.ServiceComponentDefn.Attributes.ROUTING_UUID);
-
- ComponentDefn defn = null;
- boolean isResourcePool = isResourcePool(componentType);
-
- if (configID == null) {
-/*
- if (!isResourcePool) {
- if (routingUUID == null){
- //allow the object editor to generate a UUID
- defn = (ComponentDefn) editor.createServiceComponentDefn(id, name);
- } else {
- //use the UUID specified in the XML file
- defn = (ComponentDefn) editor.createServiceComponentDefn(id, name, routingUUID);
- }
-
- editor.setEnabled((ServiceComponentDefn) defn, isEnabled);
- } else {
- defn = editor.createResourceDescriptor(id, name);
-
-
- }
-*/
- }else {
- if (!isResourcePool) {
-
- if (routingUUID == null){
- //allow the object editor to generate a UUID
- defn = editor.createServiceComponentDefn(configID, id, name);
- } else {
- //use the UUID specified in the XML file
- defn = editor.createServiceComponentDefn(configID, id, name, routingUUID);
- }
-
- } else {
-
- defn = editor.createResourceDescriptor(configID, id, name);
-
- }
-
- }
-
- defn = (ComponentDefn) setDateHistory(defn, element, editor);
-
- // add the properties to this ComponentObject...
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- return (ComponentDefn)addProperties(propertiesElement, defn, editor);
- }
-
- return defn;
-
- }
-
- private boolean isResourcePool(String componentTypeName) {
- boolean result = false;
-
- if (componentTypeName.equals(SharedResource.JDBC_COMPONENT_TYPE_NAME) ||
- componentTypeName.equals(SharedResource.JMS_COMPONENT_TYPE_NAME) ||
- componentTypeName.equals(SharedResource.MISC_COMPONENT_TYPE_NAME) ||
- componentTypeName.equals(SharedResource.SEARCHBASE_COMPONENT_TYPE_NAME) ) {
- return true;
- }
-
-
- return result;
-
- }
-
- public boolean is42ConfigurationCompatible(Element element) throws InvalidConfigurationElementException {
- return XMLHelperUtil.is42ConfigurationCompatible(element);
- }
-
-
- /**
- * This method will create a ProductServiceConfig configuration object from an XML element
- * that represents a ProductServiceConfig.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ProductServiceConfig configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ProductServiceConfig createProductServiceConfig(Element element, ConfigurationID configID, ConfigurationObjectEditor editor, String name)throws InvalidConfigurationElementException {
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
- Assertion.isNotNull(configID);
-
- if (!element.getName().equals(XMLElementNames.Configurations.Configuration.ProductServiceConfigs.ProductServiceConfig.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0043, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0043,element.getName()), element);
- }
-
- if (name==null) {
- name = element.getAttributeValue(XMLElementNames.Configurations.Configuration.ProductServiceConfigs.ProductServiceConfig.Attributes.NAME);
- }
-
- String componentType = element.getAttributeValue(XMLElementNames.Configurations.Configuration.ProductServiceConfigs.ProductServiceConfig.Attributes.COMPONENT_TYPE);
- checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0059);
-
-
- // ConfigurationID configID = (ConfigurationID)config.getID();
- ProductTypeID id = new ProductTypeID(componentType);
-
- // this new editor is used only as a way to create a product service config
- // the passed in editor is then used to add the PSC to the configuration
- // as passed in.
- // we dont want to add the actions again to the passed in editor.
- ProductServiceConfig productServiceConfig = editor.createProductServiceConfig(configID, id, name);
-
- Collection serviceComponentDefnIDs = element.getChildren(XMLElementNames.Configurations.Configuration.ServiceComponentDefnID.ELEMENT);
-
- if (id.getFullName().equals(MetaMatrixProductVersion.CONNECTOR_PRODUCT_TYPE_NAME)) {
- Iterator iterator = serviceComponentDefnIDs.iterator();
- while (iterator.hasNext()) {
- Element serviceComponentDefnIDElement = (Element)iterator.next();
- String serviceComponentDefnName = serviceComponentDefnIDElement.getAttributeValue(XMLElementNames.ID.Attributes.NAME);
-
- String enabled = serviceComponentDefnIDElement.getAttributeValue(XMLElementNames.Configurations.Configuration.ProductServiceConfigs.ProductServiceConfig.Attributes.IS_ENABLED);
-
- if (enabled == null) {
- enabled = Boolean.TRUE.toString();
- }
-
- ConnectorBindingID serviceComponentDefnID = new ConnectorBindingID(configID, serviceComponentDefnName);
- productServiceConfig = editor.addServiceComponentDefn(productServiceConfig, serviceComponentDefnID);
- editor.setEnabled(serviceComponentDefnID, productServiceConfig, new Boolean(enabled).booleanValue());
-
- }
-
-
- } else {
-
- Iterator iterator = serviceComponentDefnIDs.iterator();
- while (iterator.hasNext()) {
- Element serviceComponentDefnIDElement = (Element)iterator.next();
- String serviceComponentDefnName = serviceComponentDefnIDElement.getAttributeValue(XMLElementNames.ID.Attributes.NAME);
-
- String enabled = serviceComponentDefnIDElement.getAttributeValue(XMLElementNames.Configurations.Configuration.ProductServiceConfigs.ProductServiceConfig.Attributes.IS_ENABLED);
-
- if (enabled == null) {
- enabled = Boolean.TRUE.toString();
- }
-
- ServiceComponentDefnID serviceComponentDefnID = new ServiceComponentDefnID(configID, serviceComponentDefnName);
- productServiceConfig = editor.addServiceComponentDefn(productServiceConfig, serviceComponentDefnID);
-
- editor.setEnabled(serviceComponentDefnID, productServiceConfig, new Boolean(enabled).booleanValue());
-
- }
-
- }
-
- productServiceConfig = (ProductServiceConfig) setDateHistory(productServiceConfig, element, editor);
-
- // add the properties to this ComponentObject...
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- productServiceConfig = (ProductServiceConfig)addProperties(propertiesElement, productServiceConfig, editor);
- return productServiceConfig;
- }
-
- return productServiceConfig;
- }
-
- public Element createDeployedProductServiceConfigElement(ProductServiceConfig config) {
- throw new UnsupportedOperationException("createDeployedProductServiceConfigElement method is not supported in the 3.0 version of configuration"); //$NON-NLS-1$
- }
-
-
-
- public DeployedComponent createDeployedComponent(Element element,
- ConfigurationID configID,
- HostID hostID,
- VMComponentDefnID vmID,
- ProductServiceConfigID pscID,
- Map componentTypeMap,
- ConfigurationObjectEditor editor)
- throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
- Assertion.isNotNull(configID);
- Assertion.isNotNull(hostID);
- Assertion.isNotNull(vmID);
-
- DeployedComponent component;
-
- if (!element.getName().equals(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()), element);
- }
-
- String name = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.NAME);
-// checkElementValue(name, "NAME", ErrorMessageKeys.CONFIG_ERR_0048);
-
- String componentTypeIDString = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.COMPONENT_TYPE);
- String serviceComponentDefnIDString = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.SERVICE_COMPONENT_DEFN_ID);
-
- checkElementValue(componentTypeIDString, name, ErrorMessageKeys.CONFIG_ERR_0049);
- checkElementValue(serviceComponentDefnIDString, name, ErrorMessageKeys.CONFIG_ERR_0049);
-
-
- ComponentType type = null;
- Iterator it = componentTypeMap.keySet().iterator();
- while (it.hasNext() ) {
- ComponentTypeID id = (ComponentTypeID) it.next();
- if (id.getFullName().equals(componentTypeIDString)) {
- type = (ComponentType) componentTypeMap.get(id);
- break;
- }
- }
-
- if (type == null) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[] {componentTypeIDString, serviceComponentDefnIDString} ), element);
- }
-
- ServiceComponentDefnID svcid = null;
- if (type.getComponentTypeCode() == ComponentType.CONNECTOR_COMPONENT_TYPE_CODE) {
-
- svcid = new ConnectorBindingID(configID, serviceComponentDefnIDString);
-
- } else {
-
-
- svcid = new ServiceComponentDefnID(configID, serviceComponentDefnIDString);
-
- }
-
- component = editor.createDeployedServiceComponent(name, configID, hostID,vmID, svcid, pscID, (ComponentTypeID) type.getID());
-
-
- return component;
- }
-
-
- /**
- * This method will create a DeployedComponent configuration object from an XML element
- * that represents a DeployedComponent.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @param serviceComponentDefnMap a map of ServiceComponentDefnID-->ServiceComponentDefn
- * this map must contain at the very least the ServiceComponentDefn that
- * is the service definition of the deployed component that the XML element
- * references. This is used if the deployedComponent is a Service. Otherwise
- * it is ignored.
- * @param vmComponentDefnMap a map of vmComponentDefnID-->vmComponentDefn
- * this map must contain at the very least the vmComponentDefn that
- * is the VM definition of the deployed component that the XML element
- * references. This is used if the deployedComponent is a VM. Otherwise
- * it is ignored.
- * @return the DeployedComponent configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public DeployedComponent createDeployedComponent(Element element,
- Configuration config, ConfigurationObjectEditor editor,
- Map serviceComponentDefnMap, Map vmComponentDefnMap, Map componentTypeMap, String name)
- throws InvalidConfigurationElementException{
-
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
- Assertion.isNotNull(config);
-
- DeployedComponent component;
-
- if (!element.getName().equals(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.ELEMENT)) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0044, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0044,element.getName()), element);
- }
-
- if (name == null) {
- name = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.NAME);
- }
-
- String productServiceConfigIDString = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.PRODUCT_SERVICE_CONFIG_ID);
- String vmComponentDefnIDString = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.VM_COMPONENT_DEFN_ID);
- String serviceComponentDefnIDString = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.SERVICE_COMPONENT_DEFN_ID);
- String HostIDString = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.HOST_ID);
-
- checkElementValue(vmComponentDefnIDString, name, ErrorMessageKeys.CONFIG_ERR_0045);
- checkElementValue(HostIDString, name, ErrorMessageKeys.CONFIG_ERR_0046);
-
- ConfigurationID configID = (ConfigurationID)config.getID();
-
- HostID hostID = new HostID(HostIDString);
-
- VMComponentDefnID vmComponentDefnID = new VMComponentDefnID(configID, hostID, vmComponentDefnIDString);
- // this will check to see if this is actually a DeployedVMServiceComponent
- // these special deployed components dont have values for these ID's
- String componentTypeIDString = element.getAttributeValue(XMLElementNames.Configurations.Configuration.DeployedComponents.DeployedComponent.Attributes.COMPONENT_TYPE);
-
- if (serviceComponentDefnIDString == null && productServiceConfigIDString == null) {
- Element vmelement = (Element)vmComponentDefnMap.get(vmComponentDefnIDString);
-
- VMComponentDefn defn = createVMComponentDefn(vmelement, configID, hostID, editor, null);
-
-// VMComponentDefn vmComponentDefn =
-// xmlHelper.createVMComponentDefn(vmComponentDefnElement, (ConfigurationID) config.getID() , editor, null);
-
-// VMComponentDefn defn = (VMComponentDefn)vmComponentDefnMap.get(vmComponentDefnIDString);
- if (defn==null) {
- ComponentType type = null;
- Iterator it = componentTypeMap.keySet().iterator();
- while (it.hasNext() ) {
- ComponentTypeID id = (ComponentTypeID) it.next();
- if (id.getFullName().equals(componentTypeIDString)) {
- type = (ComponentType) componentTypeMap.get(id);
- break;
- }
- }
-
- defn = (VMComponentDefn) BasicUtil.createComponentDefn(ComponentType.VM_COMPONENT_TYPE_CODE, configID, hostID, (ComponentTypeID) type.getID(), name);
-
-// throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0047, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0047, new Object[] {name, vmComponentDefnID} ), element);
-
- }
-
-// DeployedComponentID id = new DeployedComponentID(name, configID, hostId, (VMComponentDefnID) vmComponentDefn.getID());
-
-
- component = BasicUtil.createDeployedVMComponent(name, configID, defn.getHostID(), (VMComponentDefnID) defn.getID(), defn.getComponentTypeID());
-
-
-// component = editor.createDeployedVMComponent(name, config, defn);
-
- // else this element represents a normal ServiceComponentDefn object
- }else {
- checkElementValue(productServiceConfigIDString, name, ErrorMessageKeys.CONFIG_ERR_0048);
- checkElementValue(serviceComponentDefnIDString, name, ErrorMessageKeys.CONFIG_ERR_0049);
-
- ComponentType type = null;
- Iterator it = componentTypeMap.keySet().iterator();
- while (it.hasNext() ) {
- ComponentTypeID id = (ComponentTypeID) it.next();
- if (id.getFullName().equals(componentTypeIDString)) {
- type = (ComponentType) componentTypeMap.get(id);
- break;
- }
- }
-
- if (type == null) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0050, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0050, new Object[] {componentTypeIDString, serviceComponentDefnIDString} ), element);
- }
- ProductServiceConfigID productServiceConfigID = null;
- if (type instanceof ConnectorBindingType) {
-
- productServiceConfigID = new ProductServiceConfigID(configID, productServiceConfigIDString);
-
- ConnectorBindingID bindingID = new ConnectorBindingID(configID, serviceComponentDefnIDString);
- ConnectorBinding bdefn = (ConnectorBinding)serviceComponentDefnMap.get(bindingID);
-
- if (bdefn==null) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0051, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0051, new Object[] {name, serviceComponentDefnIDString} ), element);
- }
- component =editor.createDeployedServiceComponent(name, config, hostID, vmComponentDefnID, bdefn, productServiceConfigID);
-
- } else {
-
- productServiceConfigID = new ProductServiceConfigID(configID, productServiceConfigIDString);
-
- ServiceComponentDefnID serviceComponentDefnID = new ServiceComponentDefnID(configID, serviceComponentDefnIDString);
- ServiceComponentDefn defn = (ServiceComponentDefn)serviceComponentDefnMap.get(serviceComponentDefnID);
-
- if (defn==null) {
- throw new InvalidConfigurationElementException(ErrorMessageKeys.CONFIG_ERR_0052, CommonPlugin.Util.getString(ErrorMessageKeys.CONFIG_ERR_0052, new Object[] {name, serviceComponentDefnIDString} ), element);
- }
- component = editor.createDeployedServiceComponent(name, config, hostID, vmComponentDefnID, defn, productServiceConfigID);
-
- }
-
- }
-
- component = (DeployedComponent) setDateHistory(component, element, editor);
-
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- return (DeployedComponent)addProperties(propertiesElement, component, editor);
- }
-
- return component;
- }
-
- /**
- * This method will create a VMComponentDefn configuration object from an XML element
- * that represents a VMComponentDefn.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the VMComponentDefn configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public VMComponentDefn createVMComponentDefn(Element element, ConfigurationID configID, HostID hostID, ConfigurationObjectEditor editor, String name) throws InvalidConfigurationElementException{
- Assertion.isNotNull(element);
- Assertion.isNotNull(editor);
- Assertion.isNotNull(configID);
-
- if (!element.getName().equals(XMLElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.ELEMENT)) {
- throw new InvalidConfigurationElementException("A Configuration object cannot be created from a JDOM Element type: " + element.getName() + ".", element); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (name==null) {
- name = element.getAttributeValue(XMLElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.Attributes.NAME);
- }
-
- String componentType = element.getAttributeValue(XMLElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.Attributes.COMPONENT_TYPE);
-
- checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0060);
-
- ComponentTypeID id = new ComponentTypeID(componentType);
-
- VMComponentDefn defn = editor.createVMComponentDefn(configID, hostID, id, name);
-
- defn = (VMComponentDefn) setDateHistory(defn, element, editor);
-
- // add the properties to this ComponentObject...
- Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
- if (propertiesElement != null) {
- // now we add the system properties to the configuration object
- return (VMComponentDefn)addProperties(propertiesElement, defn, editor);
- }
-
- return defn;
- }
-
-// public VMComponentDefn createVMComponentDefn(Element element, ConfigurationID configID, ConfigurationObjectEditor editor, String name)throws InvalidConfigurationElementException {
-//
-// Assertion.isNotNull(element);
-// Assertion.isNotNull(editor);
-// Assertion.isNotNull(configID);
-//
-// if (!element.getName().equals(XMLElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.ELEMENT)) {
-// throw new InvalidConfigurationElementException("A Configuration object cannot be created from a JDOM Element type: " + element.getName() + ".", element); //$NON-NLS-1$ //$NON-NLS-2$
-// }
-//
-// if (name==null) {
-// name = element.getAttributeValue(XMLElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.Attributes.NAME);
-// }
-//
-// String componentType = element.getAttributeValue(XMLElementNames.Configurations.Configuration.VMComponentDefns.VMComponentDefn.Attributes.COMPONENT_TYPE);
-//
-// checkElementValue(componentType, name, ErrorMessageKeys.CONFIG_ERR_0060);
-//
-// ComponentTypeID id = new ComponentTypeID(componentType);
-//
-// VMComponentDefn defn = editor.createVMComponentDefn(configID, null, id, name);
-//
-// defn = (VMComponentDefn) setDateHistory(defn, element, editor);
-//
-// // add the properties to this ComponentObject...
-// Element propertiesElement = element.getChild(XMLElementNames.Properties.ELEMENT);
-// if (propertiesElement != null) {
-// // now we add the system properties to the configuration object
-// return (VMComponentDefn)addProperties(propertiesElement, defn, editor);
-// }
-//
-// return defn;
-//
-//
-// }
-
-
- /**
- * This method is a helper method to create a PropertyDefinition object from
- * an XML element that represents same.
- *
- * @param element the XML element that represents a PropertyDefinition object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public PropertyDefinition createPropertyDefinition(Element element) throws InvalidConfigurationElementException{
-
- if (!element.getName().equals(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT)) {
- throw new InvalidConfigurationElementException("A Configuration object cannot be created from a JDOM Element type: " + element.getName() + ".", element); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- String nameString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.NAME);
- String displayNameString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DISPLAY_NAME);
- String shortDescriptionString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.SHORT_DESCRIPTION);
- String defaultValueString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.DEFAULT_VALUE);
- String multiplicityString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.MULTIPLICITY);
- String propertyTypeString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.PROPERTY_TYPE);
- String valueDelimiterString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.VALUE_DELIMITER);
- String isConstrainedToAllowedValuesString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_CONSTRAINED_TO_ALLOWED_VALUES);
- String isExpertString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_EXPERT);
- String isHiddenString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_HIDDEN);
- String isMaskedString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MASKED);
- String isModifiableString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_MODIFIABLE);
- String isPreferredString = element.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.Attributes.IS_PREFERRED);
-
- Multiplicity mult = null;
- try {
- mult = Multiplicity.getInstance(multiplicityString);
- }catch(MultiplicityExpressionException e) {
- throw new InvalidConfigurationElementException(e, "The PropertyDefinition object: " + nameString + " could not be created because the multiplicity definition: '" + multiplicityString + " is not a valid multiplicity definition.", element); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- PropertyType type = PropertyType.getInstance(propertyTypeString);
-
- boolean isConstrainedToAllowedValues = (Boolean.valueOf(isConstrainedToAllowedValuesString)).booleanValue();
- boolean isExpert = (Boolean.valueOf(isExpertString)).booleanValue();
- boolean isHidden = (Boolean.valueOf(isHiddenString)).booleanValue();
- boolean isMasked = (Boolean.valueOf(isMaskedString)).booleanValue();
- boolean isModifiable = (Boolean.valueOf(isModifiableString)).booleanValue();
- boolean isPreferred = (Boolean.valueOf(isPreferredString)).booleanValue();
-
- // we must retrieve all of the allowed values from the PropertyDefinition
- // element
- Collection allowedValuesElements = element.getChildren(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.AllowedValue.ELEMENT);
- ArrayList allowedValues = new ArrayList(allowedValuesElements.size());
-
- Iterator iterator = allowedValuesElements.iterator();
- while (iterator.hasNext()) {
- Element allowedValueElement = (Element)iterator.next();
- allowedValues.add(allowedValueElement.getText());
- }
-
- PropertyDefinitionImpl defn = new PropertyDefinitionImpl(nameString, displayNameString, type,
- mult, shortDescriptionString, defaultValueString,
- allowedValues, valueDelimiterString,
- isHidden, isPreferred, isExpert, isModifiable);
-
- defn.setMasked(isMasked);
- defn.setConstrainedToAllowedValues(isConstrainedToAllowedValues);
- return defn;
-
- }
-
-
- /**
- * This method will create a ComponentObject configuration object from an XML element
- * that represents a ComponentObject.
- *
- * @param element the JDOM element to convert to a configuration object
- * @param editor the editor to use to create the configuration object
- * @param name the name of the returned configuration object. Note this
- * name will override the name in the JDOM element. If the name parameter
- * is null, the name of the object in the JDOM element will be used as
- * the name of the object.
- * @return the ComponentObject configuration object
- * @throws InvalidConfigurationElementException if the element passed in
- * or its XML structure do not conform to the XML structure specfied in
- * the XMLElementNames class.
- */
- public ComponentObject addProperties(Element propertiesElement, ComponentObject object, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
-
- if (!propertiesElement.getName().equals(XMLElementNames.Properties.ELEMENT)) {
- throw new InvalidConfigurationElementException("A Properties object cannot be created from a JDOM Element type: " + propertiesElement.getName() + ".", propertiesElement); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- Properties props = getProperties(propertiesElement);
-
- object = editor.modifyProperties(object, props, ConfigurationObjectEditor.ADD);
- return object;
- }
-
-
-
- private Properties getProperties(Element propertiesElement) {
- Properties props = new Properties();
-
- List properties = propertiesElement.getChildren(XMLElementNames.Properties.Property.ELEMENT);
- Iterator iterator = properties.iterator();
- while (iterator.hasNext()) {
- Element propertyElement = (Element)iterator.next();
- String propertyName = propertyElement.getAttributeValue(XMLElementNames.Properties.Property.Attributes.NAME);
- String propertyValue = propertyElement.getText();
-
- props.setProperty(propertyName, propertyValue);
-
- }
- return props;
- }
-
- /**
- * This is a helper method for ProductTypes and ComponentTypes. this method
- * will add a list of Component Type Definitions to a ComponentType using
- * the passed in editor. The Collection of XML elements passed in are
- * translated into ComponentTypeDefn objects and then set on the passed in
- * ComponentType.
- *
- * @param componentTypeDefnElements a collection of JDOM elements that
- * each represent a ComponentTypeDefn object.
- * @param type the ComponentType object to add the ComponentTypeDefns to
- * @param editor the editor to use to both create the ComponentTypeDefns
- * and to set them on the passed in ComponentType.
- * @return the ComponentType reference that now has the CompoenentTypeDefns
- * set on it.
- * @throws InvalidConfigurationElementException if the ComponentTypeDefn
- * JDOM elements do not adhere to the proper XML structure as defined by the
- * XMLElementNames class.
- */
- private ComponentType addComponentTypeDefns(Collection componentTypeDefnElements, ComponentType type, ConfigurationObjectEditor editor) throws InvalidConfigurationElementException{
- ArrayList componentTypeDefns = new ArrayList(componentTypeDefnElements.size());
-
- Iterator iterator = componentTypeDefnElements.iterator();
- while (iterator.hasNext()) {
- Element componentTypeDefnElement = (Element)iterator.next();
- Element propertyDefinitionElement = componentTypeDefnElement.getChild(XMLElementNames.ComponentTypes.ComponentType.ComponentTypeDefn.PropertyDefinition.ELEMENT);
- PropertyDefinition propDefn = createPropertyDefinition(propertyDefinitionElement);
- componentTypeDefns.add(editor.createComponentTypeDefn(type, propDefn, false));
- }
- return editor.setComponentTypeDefinitions(type, componentTypeDefns);
- }
-
- public void orderComponentTypeElementList(List componentTypeElements) {
- ComponentTypeElementComparator comparator = new ComponentTypeElementComparator();
- Collections.sort(componentTypeElements, comparator);
- }
-
-
- class ComponentTypeElementComparator implements Comparator{
-
- /**
- * This compare to will determine whether the ComponentType element
- * represented by 'this' has a superComponentType that is the
- * passed in ComponentType element representation to be compared to. if so, the 'this' element
- * is considered to be greater than the passed in element. If it is
- * determined that 'this' is the superCompoentType of the passed in
- * object then 'greater than' will be returned. If it is determined
- * that the two ComponentTypeObjects are unrelated, then equals is
- * returned...Note that this is inconsistent with the equals() method.
- */
- public int compare(Object thisObject, Object thatObject) {
- if (thisObject instanceof Element) {
- Element thisElement = (Element)thisObject;
- if (thatObject instanceof Element) {
- Element thatElement = (Element)thatObject;
- String thatSuperID = getElementSuperID(thatElement);
- String thisSuperID = getElementSuperID(thisElement);
- String thatID = getElementID(thatElement);
- String thisID = getElementID(thisElement);
-
- if(thisSuperID!=null && thisSuperID.equals(thatID)) {
- return 1;
- }else if(thatSuperID!=null && thatSuperID.equals(thisID)) {
- return -1;
- }else {
- return 0;
- }
- }
- }
- return 0;
- }
-
-
- private String getElementSuperID(Element componentTypeElement) {
- return componentTypeElement.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.Attributes.SUPER_COMPONENT_TYPE);
- }
-
- private String getElementID(Element componentTypeElement) {
- return componentTypeElement.getAttributeValue(XMLElementNames.ComponentTypes.ComponentType.Attributes.NAME);
- }
- }
-
- // helper class to check that an element is not null and length is greater than zero
- // this should be used instead of Assertion when checking that
- // component ID's exist
- private void checkElementValue(String value, String name, String errorKey) throws InvalidConfigurationElementException {
- if (value == null || value.trim().length() > 0) {
- if (name != null) {
- if(value == null){
- Assertion.isNotNull(value, CommonPlugin.Util.getString(errorKey, name));
- }
- } else {
- if(value == null){
- Assertion.isNotNull(value, CommonPlugin.Util.getString(errorKey));
- }
- }
-
- }
-
- }
-
-
-
-// private static final String NOT_ASSIGNED = "NotAssigned";
-
-}
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyDefinition.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyDefinition.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyDefinition.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -24,6 +24,8 @@
import java.util.List;
+import com.metamatrix.admin.api.objects.PropertyDefinition.RestartType;
+
/**
* Defines the type of property that will be placed in a detail panel or table
*/
@@ -56,7 +58,7 @@
* Get whether this property requires the system to be restarted before it takes effect.
* @return true if this property requires the system to be restarted before it takes effect.
*/
- public boolean getRequiresRestart();
+ public RestartType getRequiresRestart();
/**
* The modifiable flag is used to identify features that may not be changed once
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyDefinitionImpl.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyDefinitionImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/object/PropertyDefinitionImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -27,6 +27,7 @@
import java.util.Collections;
import java.util.List;
+import com.metamatrix.admin.api.objects.PropertyDefinition.RestartType;
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.core.util.ArgCheck;
@@ -48,7 +49,7 @@
public static final boolean DEFAULT_IS_MASKED = false;
public static final boolean DEFAULT_IS_CONSTRAINED = true;
public static final boolean DEFAULT_IS_MODIFIABLE = true;
- public static final boolean DEFAULT_REQUIRES_RESTART = false;
+ public static final RestartType DEFAULT_REQUIRES_RESTART = RestartType.SERVICE;
public static final String DEFAULT_MULTIPLICITY = "0..1"; //$NON-NLS-1$
public static final String DEFAULT_DEFAULT_VALUE = null;
public static final String DEFAULT_DISPLAY_NAME = null;
@@ -60,7 +61,7 @@
private boolean preferred = DEFAULT_IS_PREFERRED;
private boolean expert = DEFAULT_IS_EXPERT;
private boolean masked = DEFAULT_IS_MASKED;
- private boolean requiresRestart = DEFAULT_REQUIRES_RESTART;
+ private RestartType requiresRestart = RestartType.SERVICE;
private Object defaultValue = DEFAULT_VALUE;
private List allowedValues = new ArrayList();
@@ -199,14 +200,14 @@
* @see com.metamatrix.common.object.PropertyDefinition#getRequiresRestart()
* @since 4.3
*/
- public boolean getRequiresRestart () {
+ public RestartType getRequiresRestart () {
return this.requiresRestart;
}
/**
* Set whether this property requires the system to be restarted before it takes effect.
*/
- public void setRequiresRestart(boolean flag) {
+ public void setRequiresRestart(RestartType flag) {
this.requiresRestart = flag;
}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/util/VMNaming.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/util/VMNaming.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/util/VMNaming.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,129 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.util;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-
-public final class VMNaming {
- private static final String HOSTNAME = "HOSTNAME"; //$NON-NLS-1$
-
- /*
- * CONFIG_NAME refers to the name used to look up the host in the configuration
- */
- private static String CONFIG_NAME = "";//$NON-NLS-1$
-
- /*
- * HOST_ADDRESS refers to to the host-name/ip, that is given to clients to connect where
- * the server is.
- */
- private static InetAddress HOST_ADDRESS = null;
-
- /*
- * BIND_ADDRESS refers to the address used by listeners. This would include
- * the socket listeners and JGroups.
- */
- private static String BIND_ADDRESS = "";//$NON-NLS-1$
-
- /*
- * Process Name refers to the name of the process that is currently running.
- */
- private static String PROCESS_NAME = "";//$NON-NLS-1$
-
-
- public static String getProcessName() {
- return PROCESS_NAME;
- }
-
- public static void setProcessName(String processName) {
- PROCESS_NAME = processName;
- }
-
- public static String getConfigName() {
- return CONFIG_NAME;
- }
-
- public static InetAddress getHostAddress() {
- return HOST_ADDRESS;
- }
-
- public static String getBindAddress() {
- return BIND_ADDRESS;
- }
-
- public static void setup(String configName, String hostName, String bindAddress) throws UnknownHostException {
- CONFIG_NAME = configName;
-
- boolean bindAddressDefined = (bindAddress != null && bindAddress.length() > 0);
- boolean hostNameDefined = (hostName != null && hostName.length() > 0);
-
- if (hostNameDefined) {
- HOST_ADDRESS = NetUtils.resolveHostByName(hostName);
- }
-
- if (bindAddressDefined) {
- BIND_ADDRESS = bindAddress;
-
- if (!hostNameDefined) {
- HOST_ADDRESS = InetAddress.getByName(bindAddress);
- }
- }
- else {
- if (!hostNameDefined) {
- HOST_ADDRESS = NetUtils.getInstance().getInetAddress();
- }
- BIND_ADDRESS = HOST_ADDRESS.getHostAddress();
- }
- }
-
- /**
- * Return the stringified representation of this application information object.
- * @return the string form of this object; never null
- */
- public static String getHostInfo() {
- StringBuffer sb = new StringBuffer("Host Information"); //$NON-NLS-1$
- sb.append('\n');
- sb.append(" VM Name: " + PROCESS_NAME ); //$NON-NLS-1$
- sb.append('\n');
- sb.append(" Hostname: " + HOST_ADDRESS.getCanonicalHostName() ); //$NON-NLS-1$
- sb.append('\n');
- sb.append(" Version: ").append(ApplicationInfo.getInstance().getReleaseNumber()); //$NON-NLS-1$
- sb.append('\n');
- sb.append(" Build Date: ").append(ApplicationInfo.getInstance().getBuildDate()); //$NON-NLS-1$
- return sb.toString();
- }
-
- public static String getDefaultConfigName() {
- String nvalue;
- nvalue = System.getenv(HOSTNAME);
- if (nvalue == null) {
- try {
- nvalue = InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- nvalue = "teiid-system"; //$NON-NLS-1$
- }
- }
- return nvalue;
- }
-}
Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/ConfigurationAdminAPI.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -44,7 +44,6 @@
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.HostID;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
@@ -61,17 +60,6 @@
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Returns the <code>ConfigurationID</code> for the current configuration.
- * @return ConfigurationID for current configuration
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException if there is not a valid administrative session
- * @throws AuthorizationException if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException if a general remote system problem occurred
- */
- ConfigurationID getCurrentConfigurationID()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
* Returns the ID of the next startup <code>Configuration</code>, which should reflect
* the desired runtime state of the system.
* @return ID of next startup configuration
@@ -84,18 +72,6 @@
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Returns the ID of the startup <code>Configuration</code>, which should reflect
- * the desired runtime state of the system.
- * @return ID of startup configuration
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException if there is not a valid administrative session
- * @throws AuthorizationException if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException if a general remote system problem occurred
- */
- ConfigurationID getStartupConfigurationID()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
* Returns the current deployed <code>Configuration</code>. Note, this configuration
* may not match the actual configuration the system is currently executing under due
* to administrative task that can be done to tune the system. Those administrative
@@ -120,28 +96,6 @@
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Returns the current deployed <code>Configuration</code>. Note, this configuration
- * may not match the actual configuration the system is currently executing under due
- * to administrative task that can be done to tune the system. Those administrative
- * task <b>do not</b> change the actual <code>Configuration</code> stored in the
- * <code>ConfigurationService</code>.
- * @return Configuration that is currently in use
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Configuration getStartupConfiguration()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Returns the named <code>Configuration</code>.
- * @param configName is the name of the Configuration to obtain
- * @return Configuration
- * @throws InvalidConfigurationException if the specified name does not exist
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Configuration getConfiguration(String configName)
- throws InvalidConfigurationException, ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
* Returns the current <code>ConfigurationModelContainer</code>. Note, this configuration
* may not match the actual configuration the system is currently executing under due
* to administrative task that can be done to tune the system. Those administrative
@@ -204,54 +158,6 @@
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * <p>This method will return a Collection of objects that represent the
- * set of global configuration objects currently represented in the
- * configuration database. This method will generally be used when
- * attempting to import a configuration into the database as the 'Next Startup'
- * configuration. This information is important when importing a new configuration
- * so that any global type configuration objects that are to be imported can
- * be resolved against the global objects that currently exist in the
- * database.</p>
- *
- * <pre>
- * The Collection of objects will contain the following configuration
- * object types:
- *
- * ComponentTypes
- * ProductTypes
- * Hosts
- * </pre>
- *
- * @return a Collection of all of the global configuration objects as they
- * exist in the database.
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException if there is not a valid administrative session
- * @throws AuthorizationException if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException if a general remote system problem occurred
- */
- public Collection getAllGlobalConfigObjects()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Baselines the realtime portion of the current (operational) configuration into the
- * next-startup configuration.
- */
- void baselineCurrentConfiguration()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Returns a Map of component type definitions for each <code>ComponentTypeID</code>
- * that is contained in the passed <code>Collection</code>. This does not
- * return the dependent definitions for service type components.
- * @param componentIDs is a Collection
- * @return Map of a Map of component type difinitions keyed by <code>ComponentTypeID</code>
- *
- * @see getDependentComponentTypeDefintions(Collection)
- */
- Map getComponentTypeDefinitions(Collection componentIDs)
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
* Returns the component type definitions for the specified <code>ComponentTypeID</code>.
* This does not return the dependent definitions for service type components.
* @param componentTypeID is a ComponentTypeID
@@ -275,20 +181,6 @@
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Returns a <code>List</code> of type <code>ComponentType</code> .
- * that are flagged as being monitored. A component of this type is considered
- * to be available for monitoring statistics.
- * @param includeDeprecated true if class names that have been deprecated should be
- * included in the returned list, or false if only non-deprecated constants should be returned.
- * @return Collection of type <code>ComponentType</code>
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- *
- * @see #ComponentType
- */
- Collection getMonitoredComponentTypes(boolean includeDeprecated)
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
* Returns a <code>ComponentType</code> for the specified <code>ComponentTypeID</code>
* @param id is for the requested component type.
* @return ComponentType based on the id
@@ -312,18 +204,6 @@
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Returns a <code>List</code> of type <code>ProductType</code> that represents
- * all the ProductTypes defined.
- * @param includeDeprecated true if class names that have been deprecated should be
- * included in the returned list, or false if only non-deprecated constants should be returned.
- * @return Collection of type <code>ProductType</code>
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @see #ProductType
- */
- Collection getAllProductTypes(boolean includeDeprecated)
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
* Returns a <code>Host</code> for the specified <code>HostID</code>.
* </br>
* @return Host
@@ -333,36 +213,6 @@
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Returns a <code>Collection</code> of currently defined hosts. This method does not cache, it reretrieves the data everytime.
- * </br>
- * @return Collection of type Host
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Collection getHosts()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Returns a collection of <code>ComponentDefn</code>s
- * for the specified collection of <code>ComponentDefnID</code>s
- * and <code>ConfigurationID</code>. If the configuration is
- * null the parent name from the componentID will be used.
- * </br>
- * The reason for adding the option to specify the configurationID
- * is so that the same collection of componentIDs can be used
- * to obtain the componentDefns from the different configurations.
- * Otherwise, the requestor would have to create a new set
- * of componetDefnIDs for each configuration.
- * <br>
- * @param componentDefnIDs contains all the ids for which componet defns to be returned
- * @param configurationID is the configuration from which the component defns are to
- * be derived; optional, nullalble
- * @return Collection of ComponentDefn objects
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Collection getComponentDefns(Collection componentDefnIDs, ConfigurationID configurationID)
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
* Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
* for all internal resources defined to the system. The internal resources are not managed with
* the other configuration related information. They are not dictated based on which configuration
@@ -375,18 +225,6 @@
throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
- * that are of the specified resource type.
- * @param componentTypeID that identifies the type of resources to be returned
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- Collection getResources(ComponentTypeID componentTypeID)
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
-
- /**
* Save the resource changes based on each {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
* in the collection.
* @param resourceDescriptors for the resources to be changed *
@@ -429,7 +267,7 @@
* communication with the Metadata Service.
*/
Set executeTransaction(ActionDefinition action)
- throws ModificationException, ConfigurationLockException, ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
+ throws ModificationException, ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
* Execute a list of actions, and optionally
@@ -445,94 +283,9 @@
* communication with the Metadata Service.
*/
Set executeTransaction(List actions)
- throws ModificationException, ConfigurationLockException, ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
+ throws ModificationException, ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
/**
- * Execute a list of insert actions and for actions on objects of type ComponentDefn or
- * DeployedComponent object,
- * it will have its configuration id resassigned, and optionally return the set of objects
- * or object IDs that were affected/modified by the action. Only insert actions can be performed
- * here because changing a configuration id on a modify action has larger consiquences.
- * @param assignConfigurationID the configuration for which any action for a component object will
- * have its configurationID set to this.
- * @param actions the ordered list of actions that are to be performed on data within
- * the repository.
- * @return the set of objects that were affected by this transaction.
- * @throws ModificationException if the target of any of the actions is invalid, or
- * an action that is not an insert, or
- * if the target object is not a supported class of targets.
- * @throws IllegalArgumentException if the action is null
- * or if the result specification is invalid
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Metadata Service.
- */
- Set executeInsertTransaction(ConfigurationID assignConfigurationID, List actions)
- throws ModificationException, ConfigurationLockException, ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Undo the specified number of previously-committed transactions.
- * @param numberOfActions the number of actions in the history that are to be undone.
- * @return the set of objects that were affected by undoing these actions.
- * @throws IllegalArgumentException if the number is negative.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Metadata Service.
- */
- Set undoActionsAsTransaction(int numberOfActions)
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Get the history of actions executed in transactions by this editor.
- * The actions at the front of the list will be those most recently executed.
- * @return the ordered list of actions in the history.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Metadata Service.
- */
- List getHistory()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Clear the history of all actions without undoing any of them.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Metadata Service.
- */
- void clearHistory()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Get the number of actions that are currently in the history.
- * @return the number of actions in the history.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Metadata Service.
- */
- int getHistorySize()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Set the limit on the number of actions in the history. Note that the
- * history may at times be greater than this limit, because when actions
- * are removed from the history, all actions for a transactions are
- * removed at the same time. If doing so would make the history size
- * smaller than the limit, no actions are removed.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Metadata Service.
- */
- int getHistoryLimit()
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
- /**
- * Set the limit on the number of actions in the history. Note that the
- * history may at times be greater than this limit, because when actions
- * are removed from the history, all actions for a transactions are
- * removed at the same time. If doing so would make the history size
- * smaller than the limit, no actions are removed.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Metadata Service.
- */
- void setHistoryLimit(int maximumHistoryCount)
- throws ConfigurationException, InvalidSessionException, AuthorizationException, MetaMatrixComponentException;
-
-
- /**
* Add a host to the Configuration
*
* @param hostName String name of Host to add to Configuration
Modified: trunk/common-internal/src/main/resources/com/metamatrix/common/i18n.properties
===================================================================
--- trunk/common-internal/src/main/resources/com/metamatrix/common/i18n.properties 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/main/resources/com/metamatrix/common/i18n.properties 2009-04-01 20:56:55 UTC (rev 686)
@@ -3101,4 +3101,6 @@
WorkerPool.uncaughtException=Uncaught exception in worker pool
WorkerPool.New_thread=New work thread created with name {0}
-WorkerPool.Max_thread=Reached maximum thread count "{0}" for worker pool "{1}" with a queue size of "{2}".
\ No newline at end of file
+WorkerPool.Max_thread=Reached maximum thread count "{0}" for worker pool "{1}" with a queue size of "{2}".
+
+CurrentConfiguration.unknown_process=Unknown process name {0}
\ No newline at end of file
Modified: trunk/common-internal/src/test/java/com/metamatrix/common/config/model/TestComponentCryptoUtil.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/config/model/TestComponentCryptoUtil.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/config/model/TestComponentCryptoUtil.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -30,9 +30,11 @@
import junit.framework.TestCase;
+import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.ComponentTypeDefn;
import com.metamatrix.common.config.api.ComponentTypeDefnID;
import com.metamatrix.common.config.api.ConnectorBindingID;
+import com.metamatrix.common.config.reader.PropertiesConfigurationReader;
import com.metamatrix.common.object.PropertyDefinitionImpl;
import com.metamatrix.common.util.crypto.CryptoUtil;
@@ -50,9 +52,7 @@
public void setUp() throws Exception {
- System.setProperty("metamatrix.config.none", "true"); //$NON-NLS-1$//$NON-NLS-2$
- System.setProperty("metamatrix.config.reader", "com.metamatrix.common.config.reader.SystemCurrentConfigurationReader"); //$NON-NLS-1$//$NON-NLS-2$
-
+ System.setProperty(CurrentConfiguration.CONFIGURATION_READER_CLASS_PROPERTY_NAME, PropertiesConfigurationReader.class.getName());
ENCRYPTED = new String(CryptoUtil.stringEncrypt("password")); //$NON-NLS-1$
}
Modified: trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml
===================================================================
--- trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/connectors/connector-jdbc/src/main/resources/connector-jdbc.xml 2009-04-01 20:56:55 UTC (rev 686)
@@ -5,7 +5,13 @@
<PropertyDefinition Name="ExtensionCapabilityClass" DisplayName="Extension Capability Class" ShortDescription="" IsExpert="true" />
<PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.JDBCConnector" Multiplicity="1" IsExpert="true" />
<PropertyDefinition Name="DatabaseTimeZone" DisplayName="Database time zone" ShortDescription="Time zone of the database, if different than Integration Server" IsExpert="true" />
- <PropertyDefinition Name="TransactionIsolationLevel" DisplayName="Transaction Isolation Level" ShortDescription="Set the data source transaction isolation level" DefaultValue="" IsExpert="true" />
+ <PropertyDefinition Name="TransactionIsolationLevel" DisplayName="Transaction Isolation Level" ShortDescription="Set the data source transaction isolation level" DefaultValue="" IsExpert="true" IsConstrainedToAllowedValues="true">
+ <AllowedValue>TRANSACTION_READ_UNCOMMITTED</AllowedValue>
+ <AllowedValue>TRANSACTION_READ_COMMITTED</AllowedValue>
+ <AllowedValue>TRANSACTION_SERIALIZABLE</AllowedValue>
+ <AllowedValue>TRANSACTION_NONE</AllowedValue>
+ <AllowedValue></AllowedValue>
+ </PropertyDefinition>
<PropertyDefinition Name="Password" DisplayName="Password" ShortDescription="" Multiplicity="0" IsConstrainedToAllowedValues="false" IsMasked="true" IsPreferred="true" />
<PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:<protocol>:<url>" Multiplicity="1" IsConstrainedToAllowedValues="false" IsPreferred="true" />
<PropertyDefinition Name="ExtensionTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="org.teiid.connector.jdbc.translator.Translator" IsExpert="true" />
Modified: trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java
===================================================================
--- trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -67,7 +67,7 @@
List results = host.executeCommand(command); //$NON-NLS-1$
if (results != null && !results.isEmpty()) {
for (Iterator it=results.iterator(); it.hasNext();) {
- System.out.println(it.next());
+ it.next();
}
}
@@ -134,10 +134,8 @@
execution.cancel();
} catch (ConnectorException e) {
e.printStackTrace();
- fail(e.getMessage());
} catch (InterruptedException e) {
e.printStackTrace();
- fail(e.getMessage());
}
}
}
Modified: trunk/console/src/main/java/com/metamatrix/console/main/AdminConsoleMain.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/main/AdminConsoleMain.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/main/AdminConsoleMain.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -59,9 +59,7 @@
//# Static variables
//############################################################################################################################
public final static String DEFAULT_LOG_FILE =
- "../log/console_%VM_NAME%.log"; //$NON-NLS-1$
- public final static String VM_STRING = "%VM_NAME%"; //$NON-NLS-1$
- public final static int VM_STRING_LEN = VM_STRING.length();
+ "../log/console.log"; //$NON-NLS-1$
public final static String DEFAULT_ICON = "console.ico"; //$NON-NLS-1$
static {
@@ -222,10 +220,10 @@
String logFile = System.getProperty(logFileProp);
File tmpFile = null;
if (logFile == null) {
- logFile = substituteVMName(DEFAULT_LOG_FILE);
+ logFile = DEFAULT_LOG_FILE;
} else {
try {
- tmpFile = new File(substituteVMName(logFile));
+ tmpFile = new File(logFile);
} catch (Exception ex) {
logFile = DEFAULT_LOG_FILE;
}
@@ -264,15 +262,4 @@
StaticProperties.setLogDirectory(tmpFile.getParentFile());
}
- private String substituteVMName(String str) {
- String outputStr;
- int index = str.indexOf(VM_STRING);
- if (index >= 0) {
- String theVM = "MMProcess"; //$NON-NLS-1$
- outputStr = str.substring(0, index) + theVM + str.substring(index + VM_STRING_LEN);
- } else {
- outputStr = str;
- }
- return outputStr;
- }
}
Modified: trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationManager.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationManager.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -130,9 +130,7 @@
//key=ProductServiceConfigID id, value=value=Collection of service def IDs
private HashMap serviceDefnMap = new HashMap();
-
private ConfigurationID nextStartUpId = Configuration.NEXT_STARTUP_ID;
- private ConfigurationID startUpId = Configuration.STARTUP_ID;
private ArrayList listeners = new ArrayList();
@@ -1649,20 +1647,6 @@
return refreshNeeded;
}
- /**
- * Indicates if the given parameter is the identifier of the
- * startup configuration.
- * @param theId the identifier being compared
- * @return <code>true</code> if equal to the startup configuration;
- * <code>false</code> otherwise.
- */
- public boolean isStartUpConfig(ConfigurationID theId) {
- if (theId == null) {
- return false;
- }
- return startUpId.equals(theId);
- }
-
private Object modify(
ComponentObject theObject,
Properties theProperties)
@@ -1880,17 +1864,6 @@
addConfig(nextStartUp);
}
- ConfigurationModelContainer startup = getAPI().getConfigurationModel(Configuration.STARTUP);
-
- if (startup == null) {
- LogManager.logCritical(
- LogContexts.CONFIG,
- "ConfigurationManager.refreshConfigs:" + //$NON-NLS-1$
- "Startup Configuration is null."); //$NON-NLS-1$
- } else {
- addConfig(startup);
- }
-
fireConfigurationChange(
new ConfigurationChangeEvent(ConfigurationChangeEvent.REFRESH_END,
this));
Modified: trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationPropertiedObjectEditor.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationPropertiedObjectEditor.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/models/ConfigurationPropertiedObjectEditor.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -663,7 +663,6 @@
Iterator iterator = componentTypeDefns.iterator();
ConfigurationID nextStartupID = Configuration.NEXT_STARTUP_ID;
- ConfigurationID startupID = Configuration.STARTUP_ID;
while (iterator.hasNext()) {
ComponentTypeDefn cDefn = (ComponentTypeDefn)iterator.next();
@@ -672,13 +671,8 @@
PropertyDefinitionImpl pDefn = new PropertyDefinitionImpl(propDefn);
if(id.equals(nextStartupID)) {
pDefn.setModifiable(true);
- }else if(id.equals(startupID)) {
- pDefn.setModifiable(false);
-
}else {
pDefn.setModifiable(false);
-
-
}
result.add(pDefn);
}else {
Modified: trunk/console/src/main/java/com/metamatrix/console/models/PropertiesManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/PropertiesManager.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/models/PropertiesManager.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -215,65 +215,6 @@
// cfgCurrConfig.getID();
}
- public Configuration getStartUpConfiguration()
- throws AuthorizationException, InvalidSessionException,
- ComponentNotFoundException, ConfigurationException,
- ModificationException,
- MetaMatrixComponentException {
- Configuration suConfig = ModelManager.getConfigurationManager(getConnection()).getConfig(Configuration.STARTUP_ID);
-
-// Configuration suConfig = configAPI.getStartupConfiguration();
- return suConfig;
- }
-
- public Collection getStartUpDefn() throws ExternalException,
- AuthorizationException, ComponentNotFoundException {
- ArrayList startupDefn = new ArrayList();
- ComponentTypeDefn compTypeDefn = null;
- PropertyDefinition nDefinition = null;
- try {
- Configuration startupConfig = getStartUpConfiguration(); //loads from server
- ComponentTypeID configTypeID = startupConfig.getComponentTypeID();
- Collection componentTypeDefns =
- getConfigAPI().getAllComponentTypeDefinitions(configTypeID); //loads from server
- Iterator iterator = componentTypeDefns.iterator();
-
- while (iterator.hasNext()) {
- compTypeDefn = (ComponentTypeDefn)iterator.next();
- nDefinition = compTypeDefn.getPropertyDefinition();
- if (!undisplayed(nDefinition)) {
- startupDefn.add(nDefinition);
- }
- }
-
- } catch (AuthorizationException e) {
- throw(e);
- } catch (ComponentNotFoundException e) {
- throw(e);
- } catch (Exception e) {
- throw new ExternalException(e);
- }
- return startupDefn;
- }
-
- public Properties getSUProperties() throws ExternalException,
- AuthorizationException, ComponentNotFoundException {
- Properties startupProps = null;
- try {
-
- Configuration startupConfig = getStartUpConfiguration();
- // Configuration startupConfig = getConfigAPI().getStartupConfiguration(); //loads from server
- startupProps = startupConfig.getProperties();
-// } catch (AuthorizationException e) {
-// throw(e);
-// } catch (ComponentNotFoundException e) {
-// throw(e);
- } catch (Exception e) {
- throw new ExternalException(e);
- }
- return startupProps;
- }
-
private Configuration getConfiguration() throws AuthorizationException,
InvalidSessionException, ComponentNotFoundException,
ConfigurationException, ModificationException,
Modified: trunk/console/src/main/java/com/metamatrix/console/models/ResourceManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/ResourceManager.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/models/ResourceManager.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -61,9 +61,6 @@
case NEXT_STARTUP_CONFIG:
configID = capi.getNextStartupConfigurationID();
break;
- case STARTUP_CONFIG:
- configID = capi.getStartupConfigurationID();
- break;
}
} catch (AuthorizationException ex) {
@@ -81,8 +78,15 @@
public ResourcePropertiedObjectEditor getResourcePropertiedObjectEditor()
throws AuthorizationException, ExternalException {
- ConfigurationID configID = getConfigurationID(NEXT_STARTUP_CONFIG);
- return new ResourcePropertiedObjectEditor(getConnection(), configID);
+ ConfigurationAdminAPI capi = ModelManager.getConfigurationAPI(
+ getConnection());
+ try {
+ return new ResourcePropertiedObjectEditor(getConnection(), capi.getNextStartupConfigurationID());
+ } catch (AuthorizationException ex) {
+ throw ex;
+ } catch (Exception ex) {
+ throw new ExternalException(ex);
+ }
}
public SharedResource[] getResources()
Modified: trunk/console/src/main/java/com/metamatrix/console/models/ServerLogManager.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/models/ServerLogManager.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/models/ServerLogManager.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -87,9 +87,6 @@
Configuration config = null;
try {
switch (index) {
- case SystemLogSetUpPanel.STARTUP_INDEX:
- config = getConfigAPI().getStartupConfiguration();
- break;
case SystemLogSetUpPanel.NEXT_STARTUP_INDEX:
config = getConfigAPI().getNextStartupConfiguration();
break;
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/layout/ConsoleAboutPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/layout/ConsoleAboutPanel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/layout/ConsoleAboutPanel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,37 +22,37 @@
package com.metamatrix.console.ui.layout;
-import java.awt.Cursor;
-import java.awt.Event;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
+import java.awt.Cursor;
+import java.awt.Event;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.KeyStroke;
+
+import com.metamatrix.common.config.CurrentConfiguration;
+import com.metamatrix.common.util.ApplicationInfo;
+import com.metamatrix.console.ConsolePlugin;
+import com.metamatrix.toolbox.ToolboxPlugin;
+import com.metamatrix.toolbox.ui.widget.AboutPanel;
+import com.metamatrix.toolbox.ui.widget.ButtonWidget;
+import com.metamatrix.toolbox.ui.widget.DialogPanel;
+import com.metamatrix.toolbox.ui.widget.DialogWindow;
+import com.metamatrix.toolbox.ui.widget.SpacerWidget;
+import com.metamatrix.toolbox.ui.widget.SplashPanel;
+import com.metamatrix.toolbox.ui.widget.util.BrowserControl;
+import com.metamatrix.toolbox.ui.widget.util.IconFactory;
-import javax.swing.ImageIcon;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import javax.swing.KeyStroke;
-
-import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.common.util.VMNaming;
-import com.metamatrix.console.ConsolePlugin;
-import com.metamatrix.toolbox.ToolboxPlugin;
-import com.metamatrix.toolbox.ui.widget.AboutPanel;
-import com.metamatrix.toolbox.ui.widget.ButtonWidget;
-import com.metamatrix.toolbox.ui.widget.DialogPanel;
-import com.metamatrix.toolbox.ui.widget.DialogWindow;
-import com.metamatrix.toolbox.ui.widget.SpacerWidget;
-import com.metamatrix.toolbox.ui.widget.SplashPanel;
-import com.metamatrix.toolbox.ui.widget.util.BrowserControl;
-import com.metamatrix.toolbox.ui.widget.util.IconFactory;
-
/**
* @since 2.0
*/
@@ -112,7 +112,7 @@
setContent(panel);
registerKeyboardAction(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
- final JTextArea box = new JTextArea(VMNaming.getHostInfo());
+ final JTextArea box = new JTextArea(CurrentConfiguration.getInstance().getHostInfo());
box.setLineWrap(false);
box.setEditable(false);
final DialogPanel panel = new DialogPanel(new JScrollPane(box)) {
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/authorization/SummaryMain.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/authorization/SummaryMain.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/authorization/SummaryMain.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -105,7 +105,7 @@
new Insets(2, 2, 2, 2), 0, 0));
// Initialize the display to startup config values
- refresh(Configuration.STARTUP_ID);
+ refresh(Configuration.NEXT_STARTUP_ID);
}
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/ConfigurationTreeCellRenderer.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/ConfigurationTreeCellRenderer.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/ConfigurationTreeCellRenderer.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -28,7 +28,12 @@
import javax.swing.Icon;
import javax.swing.JTree;
-import com.metamatrix.common.config.api.*;
+import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.config.api.ConfigurationID;
+import com.metamatrix.common.config.api.DeployedComponent;
+import com.metamatrix.common.config.api.ProductType;
+import com.metamatrix.common.config.api.ServiceComponentDefn;
+import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.util.MetaMatrixProductNames;
import com.metamatrix.console.connections.ConnectionInfo;
import com.metamatrix.console.models.ConfigurationManager;
@@ -46,14 +51,12 @@
///////////////////////////////////////////////////////////////////////////
private static final Icon NEXT_CONFIG_ICON;
- private static final Icon START_CONFIG_ICON;
private static final Icon HOST_ICON;
private static final Icon PROCESS_ICON;
private static final Icon SERVICE_ICON;
private static final Icon PSC_ICON;
private static final Icon DEPLOYMENTS_ICON;
private static final Icon CONNECTOR_ICON;
- private static final Icon METADATA_SERVER_ICON;
private static final Icon METAMATRIX_SERVER_ICON;
private static final Icon PLATFORM_ICON;
private static final Icon PSC_HDR_ICON;
@@ -64,14 +67,12 @@
static {
NEXT_CONFIG_ICON = DeployPkgUtils.getIcon("icon.nextstartup"); //$NON-NLS-1$
- START_CONFIG_ICON = DeployPkgUtils.getIcon("icon.startup"); //$NON-NLS-1$
HOST_ICON = DeployPkgUtils.getIcon("icon.host"); //$NON-NLS-1$
PROCESS_ICON = DeployPkgUtils.getIcon("icon.process"); //$NON-NLS-1$
SERVICE_ICON = DeployPkgUtils.getIcon("icon.service"); //$NON-NLS-1$
PSC_ICON = DeployPkgUtils.getIcon("icon.psc"); //$NON-NLS-1$
DEPLOYMENTS_ICON = DeployPkgUtils.getIcon("icon.deployments"); //$NON-NLS-1$
CONNECTOR_ICON = DeployPkgUtils.getIcon("icon.connector"); //$NON-NLS-1$
- METADATA_SERVER_ICON = DeployPkgUtils.getIcon("icon.mdserver"); //$NON-NLS-1$
METAMATRIX_SERVER_ICON = DeployPkgUtils.getIcon("icon.mmserver"); //$NON-NLS-1$
PLATFORM_ICON = DeployPkgUtils.getIcon("icon.platform"); //$NON-NLS-1$
PSC_HDR_ICON = DeployPkgUtils.getIcon("icon.pschdr"); //$NON-NLS-1$
@@ -119,8 +120,6 @@
(ConfigurationID)((Configuration)userObj).getID();
if (getConfigurationManager().isNextStartUpConfig(configId)) {
setIcon(NEXT_CONFIG_ICON);
- } else if (getConfigurationManager().isStartUpConfig(configId)) {
- setIcon(START_CONFIG_ICON);
}
}
} else if (userObj instanceof ServiceComponentDefn) {
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/DetailPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/DetailPanel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/DetailPanel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -188,8 +188,6 @@
String iconId = null;
if (getConfigurationManager().isNextStartUpConfig(configId)) {
iconId = "icon.nextstartup.big"; //$NON-NLS-1$
- } else if (getConfigurationManager().isStartUpConfig(configId)) {
- iconId = "icon.startup.big"; //$NON-NLS-1$
}
if (iconId != null) {
lblConfig.setIcon(getIcon(iconId));
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/ServiceDefinitionPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/ServiceDefinitionPanel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/deploy/ServiceDefinitionPanel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -40,6 +40,7 @@
import javax.swing.JPanel;
import javax.swing.border.CompoundBorder;
+import com.metamatrix.admin.api.objects.PropertyDefinition.RestartType;
import com.metamatrix.common.config.api.ConfigurationID;
import com.metamatrix.common.config.api.ProductServiceConfig;
import com.metamatrix.common.config.api.ProductType;
@@ -64,6 +65,7 @@
import com.metamatrix.toolbox.ui.widget.TextFieldWidget;
import com.metamatrix.toolbox.ui.widget.TitledBorder;
import com.metamatrix.toolbox.ui.widget.property.PropertiedObjectPanel;
+import com.metamatrix.toolbox.ui.widget.property.PropertyDefinitionLabel;
/**
* @version 1.0
@@ -107,7 +109,7 @@
//whether any properties have changed that require a restart
- private boolean propsDifferentRequiresRestart = false;
+ private RestartType propsDifferentRequiresRestart = RestartType.NONE;
private PscDefinitionPanel parentPanel;
private boolean editMode;
@@ -383,18 +385,31 @@
saveEnabled = chkEnabled.isSelected();
}
if (propsDifferent) {
- String message = "Note change will not take effect until service/connector is restarted in the Runtime panel."; //$NON-NLS-1$
- if (propsDifferentRequiresRestart) {
- message = message + "\n\nYou have changed some properties marked \"[REQUIRES RESTART]\". These properties will not take effect until the server is restarted or bounced."; //$NON-NLS-1$
+ String message = null;
+ switch (propsDifferentRequiresRestart) {
+ case NONE:
+ message = "The change will take effect immediately."; //$NON-NLS-1$
+ break;
+ case SERVICE:
+ message = "The change(s) will not take effect until the affected services/connectors are restarted in the Runtime panel."; //$NON-NLS-1$
+ break;
+ case PROCESS:
+ message = "You have changed some properties marked " + PropertyDefinitionLabel.REQUIRES_PROCESS_RESTART_LABEL + "These properties will not take effect until the server is restarted or bounced."; //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case ALL_PROCESSES:
+ message = "You have changed some properties marked " + PropertyDefinitionLabel.REQUIRES_BOUNCE_LABEL + "These properties will not take effect until the system is bounced."; //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case CLUSTER:
+ message = "You have changed some properties marked " + PropertyDefinitionLabel.REQUIRES_CLUSTER_RESTART_LABEL + "These properties will not take effect until the system, including host controllers, is restarted."; //$NON-NLS-1$ //$NON-NLS-2$
+ break;
}
StaticUtilities.displayModalDialogWithOK("Modify Service Properties", message); //$NON-NLS-1$
-
getConfigurationManager().modifyPropertiedObject(propEditor);
propValueMap.clear();
propsDifferent = false;
- propsDifferentRequiresRestart = false;
+ propsDifferentRequiresRestart = RestartType.NONE;
changedPropertyNames.clear();
}
checkResetState();
@@ -434,18 +449,19 @@
* @return
* @since 4.3
*/
- private boolean checkPropsDifferentRequiresRestart() {
+ private RestartType checkPropsDifferentRequiresRestart() {
+ RestartType result = RestartType.NONE;
if (propsDifferent) {
Iterator itr = changedPropertyNames.iterator();
while (itr.hasNext()) {
String prop = (String) itr.next();
PropertyDefinition def = (PropertyDefinition) propDefsMap.get(prop);
- if (def != null && def.getRequiresRestart()) {
- return true;
+ if (def != null && def.getRequiresRestart().compareTo(result) > 0) {
+ result = def.getRequiresRestart();
}
}
}
- return false;
+ return result;
}
@@ -466,7 +482,7 @@
private void resetPropertiedObject() {
propsDifferent = false;
- propsDifferentRequiresRestart = false;
+ propsDifferentRequiresRestart = RestartType.NONE;
changedPropertyNames.clear();
Iterator itr = propValueMap.keySet().iterator();
while (itr.hasNext()) {
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/logsetup/SystemLogSetUpPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/logsetup/SystemLogSetUpPanel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/logsetup/SystemLogSetUpPanel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -39,13 +39,11 @@
public class SystemLogSetUpPanel extends JPanel implements WorkspacePanel,
ConfigurationLogSetUpPanelController, NotifyOnExitConsole, Refreshable {
- public final static int NUM_CONFIGURATIONS = 2;
+ public final static int NUM_CONFIGURATIONS = 1;
public final static int NEXT_STARTUP_INDEX = 0;
- public final static int STARTUP_INDEX = 1;
public final static String[] CONFIGURATION_NAMES = new String[] {
- "Next Startup", "Startup"}; //$NON-NLS-1$ //$NON-NLS-2$
+ "Next Startup"}; //$NON-NLS-1$
public final static Icon[] CONFIGURATION_ICONS = new Icon[] {
- IconFactory.getIconForImageFile("startup_small.gif"), //$NON-NLS-1$
IconFactory.getIconForImageFile("NextStartUp_small.gif") //$NON-NLS-1$
};
@@ -136,8 +134,7 @@
CONFIGURATION_ICONS[j];
}
}
- boolean modifiable = (canModify &&
- (i != STARTUP_INDEX));
+ boolean modifiable = canModify;
configPanels[i] = new ConfigurationLogSetUpPanel(
CONFIGURATION_NAMES[i], modifiable, this,
otherSourceNames, otherSourceIcons,
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/ConsolePropertiedEditor.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/ConsolePropertiedEditor.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/ConsolePropertiedEditor.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -42,8 +42,7 @@
public class ConsolePropertiedEditor implements PropertiedObjectEditor, ChangeListener{
public static final short NSUCONFIGINDICATOR = 2;
- public static final short STARTUPCONFIGINDICATOR = 3;
- private Collection allPropDefns, allNSUPropDefns, allSUPropDefns;
+ private Collection allPropDefns, allNSUPropDefns;
private ArrayList currentPropDefns = new ArrayList();
private Properties oraginalProperties, allProperties;
private Properties oldNSUProperties, nsuProperties;
@@ -102,15 +101,7 @@
}
this.allPropDefns = this.allNSUPropDefns;
allProperties = nsuProperties;
- } else if (currentTabName == PropertiesMasterPanel.STARTUP) {
-
- if (allSUPropDefns == null) {
- getSUDefn();
- getSUProperty();
- }
- this.allPropDefns = this.allSUPropDefns;
- allProperties = oraginalProperties;//TODO: May be using stProperties instead
- }
+ }
if (propHM != null)
propHM.clear();
}
@@ -163,34 +154,6 @@
return allNSUPropDefns;
}
- private void getSUDefn() {
- try{
- allSUPropDefns = manager.getStartUpDefn();
- } catch (Exception ex) {
- ExceptionUtility.showMessage("Failed getting start up definition", ex);
- LogManager.logError(LogContexts.PROPERTIES, ex,
- "Error creating start up property definition");
- }
- if (allSUPropDefns == null) {
- allSUPropDefns = new ArrayList(0);
- }
- allPropDefns = allSUPropDefns;
- }
-
- private void getSUProperty() {
- try{
- oraginalProperties = manager.getSUProperties();
- } catch (Exception ex) {
- ExceptionUtility.showMessage("Failed getting start up properties", ex);
- LogManager.logError(LogContexts.PROPERTIES, ex,
- "Error creating start up property");
- }
- if (oraginalProperties !=null)
- allProperties = oraginalProperties;
-
- //TODO currect properties
- }
-
boolean getButtonState() {
return buttonState;
}
@@ -287,10 +250,6 @@
return getDefnsFromAll(this.allNSUPropDefns, propDefnsList);
}
- public List getSUDefns(List propDefnsList) {
- return getDefnsFromAll(this.allSUPropDefns, propDefnsList);
- }
-
private List getDefnsFromAll(Collection allDefns, List defns) {
List result = new ArrayList();
Iterator iter = defns.listIterator();
@@ -312,8 +271,6 @@
public void refreshData() {
if (currentTabName == PropertiesMasterPanel.NEXT_STARTUP) {
getNSUProperty();
- } else if (currentTabName == PropertiesMasterPanel.STARTUP) {
- getSUProperty();
}
if (propHM != null) {
propHM = null;
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/NextStartupPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/NextStartupPanel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/NextStartupPanel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -125,9 +125,6 @@
propObjPanel.setShowExpertProperties(true);
propObjPanel.setShowHiddenProperties(true);
- if (getTitle().equals(PropertiesMasterPanel.STARTUP)) {
- propObjPanel.setReadOnlyForced(true);
- }
if (!parent.isModifyServerProperties()) {
propObjPanel.setReadOnlyForced(true);
}
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/PropertiesMasterPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/PropertiesMasterPanel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/PropertiesMasterPanel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -57,12 +57,8 @@
implements WorkspacePanel, ManagerListener, ChangeListener,
NotifyOnExitConsole, Refreshable {
public static final String NEXT_STARTUP = "Next Startup";
- public static final String STARTUP = "Startup";
public static final Icon NEXT_STARTUP_ICON =
IconFactory.getIconForImageFile("NextStartUp_small.gif");
- public static final Icon STARTUP_ICON =
- IconFactory.getIconForImageFile("startup_small.gif");
-
private NextStartupPanel nextStartupPanel/*, startupPanel*/;
private JTabbedPane masterTabbedPane;
private HashMap htSelectors = new HashMap();
@@ -108,11 +104,8 @@
masterTabbedPane.addChangeListener(editor);
nextStartupPanel = pfPanel.getNextStartupPanel();
-// startupPanel =
- pfPanel.getStartupPanel();
addSelector(pfPanel.getNextStartupPanel());
- addSelector(pfPanel.getStartupPanel());
propDetailPanel = new JPanel();
propDetailPanel.setLayout(new BorderLayout());
@@ -167,7 +160,7 @@
if (previousTitle.equals(NEXT_STARTUP)) {
nextStartupPanel.getApplyButton().setEnabled(false);
}
- if (sSelectedTitle.equals(STARTUP) || !canModifyServerProperties) {
+ if (!canModifyServerProperties) {
pfPanel.setMRBStatus(true);
} else {
pfPanel.setMRBStatus(false);
Modified: trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/PropertyFilterPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/PropertyFilterPanel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/console/ui/views/properties/PropertyFilterPanel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -73,7 +73,7 @@
private ButtonGroup groupBE = new ButtonGroup();
private ButtonGroup groupMR = new ButtonGroup();
- private NextStartupPanel nextStartupPanel, startupPanel;
+ private NextStartupPanel nextStartupPanel;
private PropertyFilter suFilter;
private ConsolePropertiedEditor propEditor;
@@ -170,9 +170,6 @@
nextStartupPanel = new NextStartupPanel(PropertiesMasterPanel.NEXT_STARTUP,
PropertiesMasterPanel.NEXT_STARTUP_ICON, this,
masterPanel.getConnection());
- startupPanel = new NextStartupPanel(PropertiesMasterPanel.STARTUP,
- PropertiesMasterPanel.STARTUP_ICON, this,
- masterPanel.getConnection());
suFilter = new PropertyFilter();
nextStartupPanel.setPropertiedEditor(propEditor);
propDefns = propEditor.getPropDefn();
@@ -185,8 +182,6 @@
StaticTreeUtilities.expandAll(tree);
JScrollPane sp = new JScrollPane(tree);
pnlSystemTree.add(sp, BorderLayout.CENTER);
- startupPanel.setPropertiedEditor(propEditor);
-
StaticUtilities.endWait(this);
propControllProcess();
}
@@ -211,10 +206,6 @@
return nextStartupPanel;
}
- NextStartupPanel getStartupPanel() {
- return startupPanel;
- }
-
public void postRealize() {
}
@@ -244,9 +235,7 @@
if (title.equals(PropertiesMasterPanel.NEXT_STARTUP)) {
nextStartupPanel.setGroupName(gn, propEditor.getNSUDefns((java.util.List)propDefns), suFilter);
- } else if (title.equals(PropertiesMasterPanel.STARTUP)) {
- startupPanel.setGroupName(gn, propEditor.getSUDefns((java.util.List)propDefns), suFilter);
- }
+ }
//clear hashmap that contain property value change nspFilter, opFilter, suFilter
if (nextStartupPanel.getPropertiedEditor().getChangeHM() != null)
@@ -283,16 +272,10 @@
if (tabIndex.equals(PropertiesMasterPanel.NEXT_STARTUP)|| tabIndex.equals(ALL_TAB)) {
nextStartupPanel.setGroupName(ConsolePropertyObjectId.ALL_SYS_PROPS, null, suFilter);
}
- if (tabIndex.equals(PropertiesMasterPanel.STARTUP) || tabIndex.equals(ALL_TAB)) {
- startupPanel.setGroupName(ConsolePropertyObjectId.ALL_SYS_PROPS, null, suFilter);
- }
} else {
if (tabIndex.equals(PropertiesMasterPanel.NEXT_STARTUP)) {
nextStartupPanel.setGroupName(gn, propEditor.getNSUDefns((java.util.List)propDefns), suFilter);
}
- if (tabIndex.equals(PropertiesMasterPanel.STARTUP)) {
- startupPanel.setGroupName(gn, propEditor.getSUDefns((java.util.List)propDefns), suFilter);
- }
}
}
@@ -318,8 +301,7 @@
expertCB.setEnabled(status);
bothBECB.setEnabled(status);
- if ((propEditor.getCurrentTitle().equals(PropertiesMasterPanel.STARTUP)
- || (!canModifyServerProperties))) {
+ if (!canModifyServerProperties) {
return;
}
Modified: trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/AboutPanel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/AboutPanel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/AboutPanel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -36,10 +36,10 @@
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
+import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.common.util.VMNaming;
+import com.metamatrix.toolbox.ToolboxPlugin;
import com.metamatrix.toolbox.ui.widget.util.BrowserControl;
-import com.metamatrix.toolbox.ToolboxPlugin;
/**
* @since 2.0
@@ -96,7 +96,7 @@
setContent(panel);
registerKeyboardAction(new ActionListener() {
public void actionPerformed(final ActionEvent event) {
- final JTextArea box = new JTextArea(VMNaming.getHostInfo());
+ final JTextArea box = new JTextArea(CurrentConfiguration.getInstance().getHostInfo());
box.setLineWrap(false);
box.setEditable(false);
final DialogPanel panel = new DialogPanel(new JScrollPane(box)) {
Modified: trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/property/PropertyDefinitionLabel.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/property/PropertyDefinitionLabel.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/console/src/main/java/com/metamatrix/toolbox/ui/widget/property/PropertyDefinitionLabel.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -26,12 +26,13 @@
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
+import java.util.EnumSet;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
+import com.metamatrix.admin.api.objects.PropertyDefinition.RestartType;
import com.metamatrix.common.object.PropertyDefinition;
-
import com.metamatrix.toolbox.ui.widget.LabelWidget;
/**
@@ -48,8 +49,13 @@
private final static Color invalidColor = Color.red;
private final static Color requiresRestartColor = Color.BLUE;
- private final static String REQUIRES_RESTART_LABEL = " [REQUIRES RESTART]"; //$NON-NLS-1$
- private final static String REQUIRES_RESTART_TOOLTIP = " [Requires a restart or bounce of the server to take effect]"; //$NON-NLS-1$
+ private final static EnumSet<RestartType> uncolored = EnumSet.of(RestartType.NONE, RestartType.SERVICE);
+
+ public final static String REQUIRES_NO_RESTART_LABEL = " [IMMEDIATE]"; //$NON-NLS-1$
+ public final static String REQUIRES_PROCESS_RESTART_LABEL = " [REQUIRES PROCESS RESTART]"; //$NON-NLS-1$
+ public final static String REQUIRES_BOUNCE_LABEL = " [REQUIRES BOUNCE]"; //$NON-NLS-1$
+ public final static String REQUIRES_CLUSTER_RESTART_LABEL = " [REQUIRES CLUSTER RESTART]"; //$NON-NLS-1$
+ private final static String REQUIRES_RESTART_TOOLTIP = " [Requires a restart to take effect]"; //$NON-NLS-1$
private static final int VERTICAL_MARGIN = PropertyComponentFactory.PROTOTYPE.getInsets().top;
@@ -63,8 +69,21 @@
boolean isInvalid) {
super();
String displayName = def.getDisplayName();
- if (def.getRequiresRestart()) {
- displayName = displayName + REQUIRES_RESTART_LABEL;
+ switch (def.getRequiresRestart()) {
+ case CLUSTER:
+ displayName = displayName + REQUIRES_CLUSTER_RESTART_LABEL;
+ break;
+ case NONE:
+ displayName = displayName + REQUIRES_NO_RESTART_LABEL;
+ break;
+ case PROCESS:
+ displayName = displayName + REQUIRES_PROCESS_RESTART_LABEL;
+ break;
+ case SERVICE:
+ break;
+ case ALL_PROCESSES:
+ displayName = displayName + REQUIRES_BOUNCE_LABEL;
+ break;
}
super.setText(displayName);
@@ -74,7 +93,7 @@
if (showTooltip) {
String text = def.getShortDescription();
- if (def.getRequiresRestart()) {
+ if (def.getRequiresRestart() != RestartType.NONE) {
text = text + REQUIRES_RESTART_TOOLTIP;
}
@@ -97,7 +116,7 @@
public void refreshDisplay(boolean isInvalid) {
if (isInvalid) {
setForeground(invalidColor);
- } else if (def.getRequiresRestart()) {
+ } else if (!uncolored.contains(def.getRequiresRestart())) {
setForeground(requiresRestartColor);
} else if (showRequiredProperties && def.isRequired()) {
setForeground(requiredColor);
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -52,7 +52,7 @@
public class EmbeddedConnection extends MMConnection {
// constant value giving product name
- private final static String SERVER_NAME = "MetaMatrix Query"; //$NON-NLS-1$
+ private final static String SERVER_NAME = "Teiid Embedded"; //$NON-NLS-1$
EmbeddedConnectionFactoryImpl manager = null;
ConnectionListener listener = null;
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -29,7 +29,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -86,7 +85,6 @@
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.VMComponentDefnType;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
import com.metamatrix.common.config.model.BasicConnectorArchive;
@@ -1414,8 +1412,6 @@
ModificationActionQueue maq = coe.getDestination();
java.util.List actions = maq.popActions();
getRuntimeStateAdminAPIHelper().setLogConfiguration(config, logConfig, actions, getUserName());
- } catch (ConfigurationLockException e) {
- throw new AdminComponentException(e);
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
} catch (ServiceException e) {
@@ -2267,11 +2263,7 @@
@Override
public Properties getBootstrapProperties() throws AdminException {
Properties p = new Properties();
- try {
- p.putAll(CurrentConfiguration.getInstance().getBootStrapProperties());
- } catch (ConfigurationException e) {
- throw new AdminComponentException(e);
- }
+ p.putAll(CurrentConfiguration.getInstance().getBootStrapProperties());
return p;
}
Modified: trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/admin/server/ServerMonitoringAdminImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -982,7 +982,7 @@
//get state from RuntimeStateAdminAPIHelper, etc.
try {
boolean isStarted = getRuntimeStateAdminAPIHelper().isSystemStarted();
- Date startTime = getConfigurationServiceProxy().getServerStartupTime();
+ Date startTime = getRuntimeStateAdminAPIHelper().getEldestProcessStartTime();
Configuration currentConfiguration = getConfigurationServiceProxy().getCurrentConfiguration();
system = new MMSystem();
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/SocketVMController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/SocketVMController.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/SocketVMController.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -29,6 +29,7 @@
import com.google.inject.name.Named;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.comm.platform.socket.server.SocketListener;
+import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.VMComponentDefnType;
import com.metamatrix.common.log.LogManager;
@@ -37,7 +38,6 @@
import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.util.PlatformProxyHelper;
@@ -113,7 +113,7 @@
int maxThreads = PropertiesUtils.getIntProperty(props, MAX_THREADS, DEFAULT_MAX_THREADS);
int inputBufferSize = PropertiesUtils.getIntProperty(props, INPUT_BUFFER_SIZE, DEFAULT_INPUT_BUFFER_SIZE);
int outputBufferSize = PropertiesUtils.getIntProperty(props, OUTPUT_BUFFER_SIZE, DEFAULT_OUTPUT_BUFFER_SIZE);
- String bindaddress = VMNaming.getBindAddress();
+ String bindaddress = CurrentConfiguration.getInstance().getBindAddress();
final Object[] param = new Object[] {
this.processName, bindaddress, String.valueOf(socketPort)
Modified: trunk/server/src/main/java/com/metamatrix/common/config/JDBCConnectionPoolHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/config/JDBCConnectionPoolHelper.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/config/JDBCConnectionPoolHelper.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,9 +22,7 @@
package com.metamatrix.common.config;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.jdbc.SimplePooledConnectionSource;
-import com.metamatrix.core.MetaMatrixRuntimeException;
/**
* Created on May 14, 2002
@@ -40,11 +38,7 @@
public static synchronized SimplePooledConnectionSource getInstance() {
if (INSTANCE == null) {
- try {
- INSTANCE = new SimplePooledConnectionSource(CurrentConfiguration.getInstance().getBootStrapProperties());
- } catch (ConfigurationException e) {
- throw new MetaMatrixRuntimeException(e);
- }
+ INSTANCE = new SimplePooledConnectionSource(CurrentConfiguration.getInstance().getBootStrapProperties());
}
return INSTANCE;
}
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/ExtensionModuleManager.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -46,6 +46,7 @@
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogCommonConstants;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.platform.admin.api.ExtensionSourceAdminAPI;
import com.metamatrix.server.ResourceFinder;
@@ -129,16 +130,6 @@
*/
private static ExtensionModuleManager extensionModuleManager;
- /**
- * Prevents access to this instance if it is not initialized.
- */
- private boolean isInitialized = false;
-
- /**
- * Error message used with Assertion if the instance was not initialized
- */
- private static final String NOT_INITIALIZED_MESSAGE = CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0007);
-
//===================================================================
//PUBLIC INTERFACE
//===================================================================
@@ -150,27 +141,11 @@
*/
public static synchronized ExtensionModuleManager getInstance(){
if (extensionModuleManager == null){
- extensionModuleManager = new ExtensionModuleManager();
- extensionModuleManager.init();
+ extensionModuleManager = new ExtensionModuleManager();
}
return extensionModuleManager;
}
- /**
- * <p>Return a cached ExtensionModuleManager instance for this
- * process, fully initialized and ready for use. This is not
- * a singleton, it is merely cached for convenience. This package-level
- * method allows trusted code to instantiate this object with
- * an alternate set of Properties.</p>
- */
- static synchronized ExtensionModuleManager getInstance(Properties env){
- if (extensionModuleManager == null){
- extensionModuleManager = new ExtensionModuleManager();
- extensionModuleManager.init(env);
- }
- return extensionModuleManager;
- }
-
static synchronized void reInit() {
extensionModuleManager = null;
}
@@ -205,7 +180,6 @@
*/
public ExtensionModuleDescriptor addSource(String principalName, String type, String sourceName, byte[] source, String description, boolean enabled)
throws DuplicateExtensionModuleException, InvalidExtensionModuleTypeException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(principalName);
ArgCheck.isNotNull(type);
ArgCheck.isNotNull(sourceName);
@@ -270,7 +244,6 @@
*/
public void removeSource(String principalName, String sourceName)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(principalName);
ArgCheck.isNotNull(sourceName);
ArgCheck.isNotZeroLength(principalName);
@@ -308,7 +281,6 @@
* @throws ExtensionModuleRuntimeException if this object wasn't initialized properly
*/
public Collection getSourceTypes() throws MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
return ExtensionModuleTypes.ALL_TYPES;
}
@@ -322,7 +294,6 @@
* @throws ExtensionModuleRuntimeException if this object wasn't initialized properly
*/
public List getSourceNames() throws MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
List result = null;
ExtensionModuleTransaction transaction = null;
try {
@@ -356,7 +327,6 @@
* @throws ExtensionModuleRuntimeException if this object wasn't initialized properly
*/
public List getSourceDescriptors() throws MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
List result = null;
ExtensionModuleTransaction transaction = null;
try {
@@ -395,7 +365,6 @@
*/
public List getSourceDescriptors(String type)
throws InvalidExtensionModuleTypeException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(type);
ArgCheck.isNotZeroLength(type);
ExtensionModuleTypes.checkTypeIsValid(type);
@@ -437,7 +406,6 @@
*/
public boolean isSourceInUse(String sourceName)
throws MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(sourceName);
ArgCheck.isNotZeroLength(sourceName);
ExtensionModuleTransaction transaction = null;
@@ -476,7 +444,6 @@
*/
public ExtensionModuleDescriptor getSourceDescriptor(String sourceName)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(sourceName);
ArgCheck.isNotZeroLength(sourceName);
ExtensionModuleDescriptor result = null;
@@ -521,7 +488,6 @@
*/
public List setSearchOrder(String principalName, List sourceNames)
throws ExtensionModuleOrderingException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(principalName);
ArgCheck.isNotNull(sourceNames);
ArgCheck.isNotZeroLength(principalName);
@@ -577,7 +543,6 @@
*/
public List setEnabled(String principalName, Collection sourceNames, boolean enabled)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(principalName);
ArgCheck.isNotNull(sourceNames);
ArgCheck.isNotZeroLength(principalName);
@@ -636,7 +601,6 @@
*/
public byte[] getSource(String sourceName)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(sourceName);
ArgCheck.isNotZeroLength(sourceName);
LogManager.logDetail(LOG_CONTEXT, new Object[]{"Attempting to load extension module", sourceName}); //$NON-NLS-1$
@@ -682,7 +646,6 @@
*/
public ExtensionModuleDescriptor setSource(String principalName, String sourceName, byte[] source)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(principalName);
ArgCheck.isNotNull(sourceName);
ArgCheck.isNotZeroLength(principalName);
@@ -729,7 +692,6 @@
*/
public ExtensionModuleDescriptor setSourceName(String principalName, String sourceName, String newName)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(principalName);
ArgCheck.isNotNull(sourceName);
ArgCheck.isNotNull(newName);
@@ -779,7 +741,6 @@
*/
public ExtensionModuleDescriptor setSourceDescription(String principalName, String sourceName, String description)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
- checkIsTrue(isInitialized, NOT_INITIALIZED_MESSAGE);
ArgCheck.isNotNull(principalName);
ArgCheck.isNotNull(sourceName);
ArgCheck.isNotZeroLength(principalName);
@@ -816,57 +777,35 @@
/**
* constructor
+ * @throws ManagedConnectionException
*/
- public ExtensionModuleManager(){}
-
- /**
- * <p>Initializes this object by assembling the necessary properties
- * together - combines resource properties gotten from
- * {@link com.metamatrix.common.config.CurrentConfiguration CurrentConfiguration}
- * with
- * {@link #DEFAULT_PROPERTIES default Properties} defined by this class.</p>
- */
- public void init(){
-
- Properties resourceProps = new Properties();
-
- //If this is being used by a tool such as the CDK, then resource properties
- //are not supported by CurrentConfiguration; these two essential properties
- //will be checked for in ordinary CurrentConfiguration properties
- String key = ExtensionModulePropertyNames.CONNECTION_FACTORY;
- if (resourceProps.getProperty(key) == null){
- String value = CurrentConfiguration.getInstance().getProperties().getProperty(key);
- if (value != null) {
- resourceProps.setProperty(key, value);
- }
- }
+ public ExtensionModuleManager() {
+ Properties resourceProps = new Properties();
+ String key = ExtensionModulePropertyNames.CONNECTION_FACTORY;
+ resourceProps.setProperty(key, CurrentConfiguration.getInstance().getBootStrapProperties().getProperty(key, ExtensionModulePropertyNames.DEFAULT_CONNECTION_FACTORY_CLASS));
init(resourceProps);
}
+
+ public ExtensionModuleManager(Properties p) {
+ init(p);
+ }
/**
* Initializes this object, given the necessary Properties.
* @param env the necessary Properties to initialize this class,
* see {@link ExtensionModulePropertyNames}
+ * @throws ManagedConnectionException
*/
- protected void init(Properties env){
-
- LogManager.logDetail(LOG_CONTEXT, new Object[]{"Initializing with Properties:", env}); //$NON-NLS-1$
- isInitialized = true;
-
+ protected void init(Properties env) {
+ if (env.getProperty(ExtensionModulePropertyNames.CONNECTION_FACTORY) == null) {
+ env.setProperty(ExtensionModulePropertyNames.CONNECTION_FACTORY, ExtensionModulePropertyNames.DEFAULT_CONNECTION_FACTORY_CLASS);
+ }
+ env.setProperty(TransactionMgr.FACTORY, env.getProperty(ExtensionModulePropertyNames.CONNECTION_FACTORY));
try {
- if (env.getProperty(ExtensionModulePropertyNames.CONNECTION_FACTORY) == null) {
- env.setProperty(ExtensionModulePropertyNames.CONNECTION_FACTORY, ExtensionModulePropertyNames.DEFAULT_CONNECTION_FACTORY_CLASS);
- }
- env.setProperty(TransactionMgr.FACTORY, env.getProperty(ExtensionModulePropertyNames.CONNECTION_FACTORY));
- transMgr = new TransactionMgr(env, "ExtensionModuleManager"); //$NON-NLS-1$
- } catch ( ManagedConnectionException e ) {
- LogManager.logError(LOG_CONTEXT, e, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0028));
- isInitialized = false;
- }
-
- if (!isInitialized){
- LogManager.logDetail(LOG_CONTEXT, new Object[]{"ExtensionModuleManager could not be initialized with properties ",env}); //$NON-NLS-1$
- }
+ transMgr = new TransactionMgr(env, "ExtensionModuleManager"); //$NON-NLS-1$
+ } catch (ManagedConnectionException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
}
//===================================================================
@@ -882,33 +821,15 @@
return algorithm.getValue();
}
- protected ExtensionModuleTransaction getReadTransaction() throws ManagedConnectionException {
+ public ExtensionModuleTransaction getReadTransaction() throws ManagedConnectionException {
return (ExtensionModuleTransaction) this.transMgr.getReadTransaction();
}
- protected ExtensionModuleTransaction getWriteTransaction() throws ManagedConnectionException {
+ public ExtensionModuleTransaction getWriteTransaction() throws ManagedConnectionException {
return (ExtensionModuleTransaction) this.transMgr.getWriteTransaction();
}
-
- //===================================================================
- //ADDITIONAL UTILITIES - designed to check input parameters and
- //throw runtime exceptions if parameters or state is invalid
- //===================================================================
-
/**
- * Checks condition
- * @throws ExtensionModuleRuntimeException if false
- */
- private static final void checkIsTrue(boolean condition, String failMessage) {
- if(! condition) {
- throw new ExtensionModuleRuntimeException(failMessage);
- }
- }
-
-
-
- /**
* Notifies listeners when JDBCNames.ExtensionFilesTable.ColumnName.FILE_TYPE
* has changed.
*
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/ExtensionModuleTransaction.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/ExtensionModuleTransaction.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/ExtensionModuleTransaction.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -209,19 +209,6 @@
ExtensionModuleDescriptor setSourceDescription(String principalName, String sourceName, String description)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException;
- /**
- * Indicates that ExtensionModuleManager should clear its cache and refresh itself because
- * the data this object fronts has changed (optional operation). A service provider
- * is not required to keep track of whether data has changed by outside means, in fact
- * it may not even make sense.
- * @return whether data has changed since ExtensionModuleManager last accessed this data
- * store.
- * @throws MetaMatrixComponentException indicating a non-business-related
- * exception (such as a communication exception)
- * @throws UnsupportedOperationException if not supported by this Transaction.
- */
- boolean needsRefresh() throws MetaMatrixComponentException, UnsupportedOperationException;
-
/**
* Indicates if an extension module name is already in used.
* The method will return <code>true</code> if the source name is already used,
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleReader.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -62,14 +62,10 @@
* @since 4.2
*/
private static void initFileCache() {
- //NOTE: DO NOT PUT LOGGING IN THIS METHOD
- // Because configuration initializes by getting the source
- // from the database prior to configuration properties being
- // available
-
- if (fileCache == null) {
+ CurrentConfiguration config = CurrentConfiguration.getInstance();
+ if (config.isAvailable() && fileCache == null) {
fileCache = new FileCache();
- String typesToCacheString = CurrentConfiguration.getInstance().getProperties().getProperty(CommonPropertyNames.EXTENSION_TYPES_TO_CACHE);
+ String typesToCacheString = config.getProperties().getProperty(CommonPropertyNames.EXTENSION_TYPES_TO_CACHE);
if (typesToCacheString != null) {
StringTokenizer tokenizer = new StringTokenizer(typesToCacheString, ","); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
@@ -143,7 +139,7 @@
private static byte[] getConfigContent(String sourceName, Connection jdbcConnection)
- throws ExtensionModuleNotFoundException, MetaMatrixComponentException, SQLException {
+ throws MetaMatrixComponentException, SQLException {
String sql = null;
PreparedStatement statement = null;
@@ -202,11 +198,6 @@
private synchronized static byte[] getFileContent(String sourceName, Connection jdbcConnection)
throws ExtensionModuleNotFoundException, MetaMatrixComponentException, SQLException {
- //NOTE: DO NOT PUT LOGGING IN THIS METHOD
- // Because configuration initializes by getting the source
- // from the database prior to configuration properties being
- // available
-
initFileCache();
CheckSumAndType csat = loadChecksumAndType(sourceName, jdbcConnection);
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTransaction.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTransaction.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleTransaction.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -39,14 +39,11 @@
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleOrderingException;
import com.metamatrix.common.extensionmodule.spi.ExtensionModuleTransaction;
import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.common.util.LogCommonConstants;
public class JDBCExtensionModuleTransaction extends BaseTransaction implements ExtensionModuleTransaction {
private Connection jdbcConnection;
- private static final String CONTEXT = LogCommonConstants.CTX_EXTENSION_SOURCE_JDBC;
-
/**
* Create a new instance of a transaction for a managed connection.
* @param connectionPool the pool to which the transaction should return the connection when completed
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleUtil.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -61,7 +61,6 @@
static {
configurationNames = new HashSet();
configurationNames.add(Configuration.NEXT_STARTUP);
- configurationNames.add(Configuration.STARTUP);
}
@@ -99,7 +98,7 @@
Connection connection = null;
try {
- connection = JDBCConnectionPoolHelper.getInstance().getConnection(); //$NON-NLS-1$
+ connection = JDBCConnectionPoolHelper.getInstance().getConnection();
@@ -160,7 +159,7 @@
Connection connection = null;
try {
- connection = JDBCConnectionPoolHelper.getInstance().getConnection(); //$NON-NLS-1$
+ connection = JDBCConnectionPoolHelper.getInstance().getConnection();
byte[] data = JDBCExtensionModuleReader.getSource(sourceName, connection);
@@ -197,7 +196,7 @@
try {
connection =
- JDBCConnectionPoolHelper.getInstance().getConnection(); //$NON-NLS-1$
+ JDBCConnectionPoolHelper.getInstance().getConnection();
boolean inuse = JDBCExtensionModuleReader.isNameInUse(extName, connection);
@@ -295,12 +294,12 @@
* required unless otherwise noted)
*/
public void deleteExtensionModule(String sourceName)
- throws ExtensionModuleNotFoundException, MetaMatrixComponentException{
+ throws MetaMatrixComponentException{
Connection connection = null;
try {
- connection = JDBCConnectionPoolHelper.getInstance().getConnection(); //$NON-NLS-1$
+ connection = JDBCConnectionPoolHelper.getInstance().getConnection();
boolean inuse = JDBCExtensionModuleReader.isNameInUse(sourceName, connection);
if (!inuse) {
@@ -326,7 +325,7 @@
protected void positionExtensionModule(String extName, String position)
- throws ExtensionModuleNotFoundException, DuplicateExtensionModuleException, MetaMatrixComponentException{
+ throws MetaMatrixComponentException{
int pos = -1;
if (position == null) {
return;
@@ -340,7 +339,7 @@
Connection connection = null;
try {
connection =
- JDBCConnectionPoolHelper.getInstance().getConnection(); //$NON-NLS-1$
+ JDBCConnectionPoolHelper.getInstance().getConnection();
LinkedList orderList = new LinkedList();
Collection descriptors = JDBCExtensionModuleReader.getSourceDescriptors(null, true, connection);
Modified: trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/extensionmodule/spi/jdbc/JDBCExtensionModuleWriter.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -233,9 +233,8 @@
} catch (SQLException e) {
if (!firstException) {
throw new MetaMatrixComponentException(e, ErrorMessageKeys.EXTENSION_0054, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0054, sourceName,sql));
- } else {
- LogManager.logDetail(CONTEXT, e, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0054, new Object[]{sourceName, sql}));
}
+ LogManager.logDetail(CONTEXT, e, CommonPlugin.Util.getString(ErrorMessageKeys.EXTENSION_0054, new Object[]{sourceName, sql}));
}
}
Modified: trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -30,9 +30,9 @@
import java.util.Properties;
import com.metamatrix.common.CommonPlugin;
+import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.core.log.LogMessage;
import com.metamatrix.core.util.DateUtil;
import com.metamatrix.core.util.StringUtil;
@@ -309,10 +309,10 @@
stmt.setString(5, StringUtil.truncString(message.getText(), maxMsgLength));
// Message hostname column
- stmt.setString(6, StringUtil.truncString(VMNaming.getConfigName(), maxGeneralLength));
+ stmt.setString(6, StringUtil.truncString(CurrentConfiguration.getInstance().getConfigurationName(), maxGeneralLength));
// Message VM ID column
- stmt.setString(7, StringUtil.truncString(VMNaming.getProcessName(), maxGeneralLength));
+ stmt.setString(7, StringUtil.truncString(CurrentConfiguration.getInstance().getProcessName(), maxGeneralLength));
// Message thread name column
stmt.setString(8, StringUtil.truncString(message.getThreadName(), maxGeneralLength));
Modified: trunk/server/src/main/java/com/metamatrix/common/log/reader/DBLogReader.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/reader/DBLogReader.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/log/reader/DBLogReader.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -38,7 +38,6 @@
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
-import com.metamatrix.common.connection.ManagedConnectionException;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.util.DateUtil;
@@ -98,16 +97,8 @@
- protected Connection getConnection() throws ManagedConnectionException {
- try {
-
- Connection connection = JDBCConnectionPoolHelper.getInstance().getConnection();
- // Connection connection = JDBCUtil.createJDBCConnection(this.connectionProperties);
-
- return connection;
- } catch (Exception e) {
- throw new ManagedConnectionException(e, ErrorMessageKeys.LOG_ERR_0009, CommonPlugin.Util.getString(ErrorMessageKeys.LOG_ERR_0009));
- }
+ protected Connection getConnection() throws SQLException {
+ return JDBCConnectionPoolHelper.getInstance().getConnection();
}
@@ -129,47 +120,6 @@
}
-
- /**
- * Due to the change in using ResourcePooling, the database destination for the LogManager
- * does not need to have its properties processed as before in the
- * original method createConnectionProperties.
- * However, the DirectLogViewer used the original method to obtain its connection properties.
- * Therefore, the original method was split into two methods to satisfy both needs.
- */
-//
-// private static Properties createLogViewerConnectionProperties( Properties props ) throws MetaMatrixException {
-//
-// String pwd = null;
-// try {
-// String password = (rd.getProperty(JDBCConnectionResource.PASSWORD));
-// if (password == null) {
-// String msg = CommonPlugin.Util.getString(ErrorMessageKeys.LOG_ERR_0023);
-// throw new MetaMatrixException(msg);
-// }
-// if (CryptoUtil.isValueEncrypted(password)) {
-// pwd = CryptoUtil.stringDecrypt(password);
-// }
-// else {
-// pwd = password;
-// }
-// } catch (CryptoException e) {
-// String msg = CommonPlugin.Util.getString(ErrorMessageKeys.LOG_ERR_0024);
-// throw new MetaMatrixException(msg);
-// }
-// jdbcProps.put(JDBCUtil.PASSWORD, pwd);
-// jdbcProps.put(JDBCUtil.DRIVER, rd.getProperty(JDBCConnectionResource.DRIVER));
-// jdbcProps.put(JDBCUtil.USERNAME, rd.getProperty(JDBCConnectionResource.USERNAME));
-// if (rd.getProperty(JDBCConnectionResource.PROTOCOL) != null && rd.getProperty(JDBCConnectionResource.PROTOCOL).trim().length() > 0) {
-// jdbcProps.put(JDBCUtil.PROTOCOL, rd.getProperty(JDBCConnectionResource.PROTOCOL));
-// }
-// jdbcProps.put(JDBCUtil.DATABASE, rd.getProperty(JDBCConnectionResource.DATABASE));
-//
-// return jdbcProps;
-// }
-//
-//
-
/**
* @see com.metamatrix.platform.admin.api.RuntimeStateAdminAPI#getLogEntries(java.util.Date, java.util.Date, java.util.List, java.util.List, int)
* @since 4.3
@@ -198,8 +148,6 @@
ResultSet result = statement.getResultSet();
return convertResults(result, maxRows);
- } catch (ManagedConnectionException e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.LOG_ERR_0032, CommonPlugin.Util.getString(ErrorMessageKeys.LOG_ERR_0032, sqlString));
} catch (SQLException e) {
throw new MetaMatrixComponentException(e, ErrorMessageKeys.LOG_ERR_0032, CommonPlugin.Util.getString(ErrorMessageKeys.LOG_ERR_0032, sqlString));
} finally {
Deleted: trunk/server/src/main/java/com/metamatrix/common/messaging/MessageBusConstants.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/messaging/MessageBusConstants.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/messaging/MessageBusConstants.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.messaging;
-
-public interface MessageBusConstants {
-
- public static final String MESSAGE_BUS_TYPE = "metamatrix.message.bus.type"; //$NON-NLS-1$
-
- public static final String TYPE_NOOP = "noop.message.bus"; //$NON-NLS-1$
- public static final String TYPE_JGROUPS = "jgroups.message.bus"; //$NON-NLS-1$
-
-}
Deleted: trunk/server/src/main/java/com/metamatrix/common/messaging/VMMessageBus.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/messaging/VMMessageBus.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/messaging/VMMessageBus.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,181 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.messaging;
-
-import java.io.Serializable;
-import java.util.EventObject;
-import java.util.Properties;
-
-import org.jgroups.ChannelException;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.name.Named;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.messaging.jgroups.JGroupsMessageBus;
-import com.metamatrix.common.util.ErrorMessageKeys;
-import com.metamatrix.core.event.AsynchEventBroker;
-import com.metamatrix.core.event.EventBroker;
-import com.metamatrix.core.event.EventBrokerException;
-import com.metamatrix.core.event.EventObjectListener;
-import com.metamatrix.core.event.EventSourceException;
-import com.metamatrix.server.ChannelProvider;
-import com.metamatrix.server.Configuration;
-
-@Singleton
-public class VMMessageBus implements MessageBus {
-
- private Object messageBus;
- private Object lock = new Object();
- private boolean closed = true;
-
- private EventBroker eventBroker = new AsynchEventBroker("VMMessageBus"); //$NON-NLS-1$
-
- @Inject
- public VMMessageBus(ChannelProvider channelProvider, @Named(Configuration.CLUSTERNAME) String clusterName) throws MetaMatrixComponentException {
- Properties env = null;
- // when the old messagebus Resource was replaced with the JGroups resource,
- // the MESSAGE_BUS_TYPE property was moved to the global properties section
- // however, (HERES THE HACK), CurrentConfiguration.getInstance().getProperties() does not
- // allow the system properties to override configuration settings, therefore,
- // the MESSAGE_BUS_TYPE property could not be overridden with TYPE_NOOP
- // so were looking at System.getProperty() to force the override
- String mbType = System.getProperty(MessageBusConstants.MESSAGE_BUS_TYPE);
-
- if (mbType == null || mbType.trim().length() == 0) {
- env = CurrentConfiguration.getInstance().getProperties();
- mbType = env.getProperty(MessageBusConstants.MESSAGE_BUS_TYPE);
- }
-
- if (mbType != null && mbType.equals(MessageBusConstants.TYPE_NOOP)) {
- messageBus = new NoOpMessageBus();
- } else {
- try {
- messageBus = new JGroupsMessageBus(channelProvider, eventBroker, clusterName);
- } catch (ChannelException e) {
- throw new MetaMatrixComponentException(e);
- }
- }
- closed = false;
- }
-
- public void addListener(Class eventClass, EventObjectListener listener) throws MessagingException {
- synchronized (lock) {
- if (closed) {
- return;
- }
- try {
- eventBroker.addListener(eventClass, listener);
- } catch (EventSourceException e) {
- throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0013, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0013));
- }
- }
- }
-
- public void shutdown() throws MessagingException {
- synchronized (lock) {
- if (closed) {
- return;
- }
- closed = true;
- ((MessageBus)messageBus).shutdown();
- try {
- eventBroker.shutdown();
- } catch (EventBrokerException e) {
- throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0014, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0014));
- }
- messageBus = null;
- eventBroker = null;
- }
- }
-
- public void removeListener(Class eventClass, EventObjectListener listener)
- throws MessagingException {
-
- synchronized (lock) {
- if (closed) {
- return;
- }
- try {
- eventBroker.removeListener(eventClass, listener);
- } catch (EventSourceException e) {
- throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0015, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0015));
- }
- }
- }
-
- public void removeListener(EventObjectListener listener)
- throws MessagingException {
-
- synchronized (lock) {
- if (closed) {
- return;
- }
- try {
- eventBroker.removeListener(listener);
- } catch (EventSourceException e) {
- throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0015, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0015));
- }
- }
- }
-
- public void processEvent(EventObject obj) throws MessagingException {
- synchronized (lock) {
- if (closed) {
- return;
- }
- ((MessageBus)messageBus).processEvent(obj);
- eventBroker.processEvent(obj);
- }
- }
-
- public Serializable export(Object object, Class[] targetClasses) {
- synchronized (lock) {
- if (closed) {
- return null;
- }
- return ((MessageBus)messageBus).export(object, targetClasses);
- }
- }
-
- public Object getRPCProxy(Object object) {
- synchronized (lock) {
- if (closed) {
- return null;
- }
- return ((MessageBus)messageBus).getRPCProxy(object);
- }
- }
-
- public void unExport(Object object) {
- synchronized (lock) {
- if (closed) {
- return;
- }
- ((MessageBus)messageBus).unExport(object);
- }
- }
-}
-
Modified: trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/JGroupsMessageBus.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/JGroupsMessageBus.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/JGroupsMessageBus.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -41,6 +41,9 @@
import org.jgroups.blocks.RpcDispatcher;
import org.jgroups.util.RspList;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.name.Named;
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
@@ -49,12 +52,17 @@
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.event.AsynchEventBroker;
import com.metamatrix.core.event.EventBroker;
+import com.metamatrix.core.event.EventBrokerException;
import com.metamatrix.core.event.EventObjectListener;
+import com.metamatrix.core.event.EventSourceException;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.server.ChannelProvider;
+import com.metamatrix.server.Configuration;
+@Singleton
public class JGroupsMessageBus implements MessageBus {
public static final String MESSAGE_KEY = "MessageKey"; //$NON-NLS-1$
@@ -62,13 +70,16 @@
private Channel channel;
private volatile boolean shutdown;
+
+ private EventBroker eventBroker = new AsynchEventBroker("VMMessageBus"); //$NON-NLS-1$
// these are original objects that implement
private ConcurrentHashMap<UUID, RPCStruct> rpcStructs = new ConcurrentHashMap<UUID, RPCStruct>();
private RpcDispatcher rpcDispatcher;
- public JGroupsMessageBus(ChannelProvider channelProvider, final EventBroker eventBroker, final String clusterName) throws ChannelException {
+ @Inject
+ public JGroupsMessageBus(ChannelProvider channelProvider, @Named(Configuration.CLUSTERNAME) final String clusterName) throws ChannelException {
Channel c = channelProvider.get(ChannelProvider.ChannelID.RPC);
if (c == null || !c.isOpen()) {
@@ -138,9 +149,7 @@
}
});
}
-
-
/**
* @see com.metamatrix.common.messaging.MessageBus#processEvent(java.util.EventObject)
*/
@@ -153,30 +162,57 @@
throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0004, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0004));
}
}
+ eventBroker.processEvent(obj);
}
public synchronized void shutdown() throws MessagingException {
+ if (shutdown) {
+ return;
+ }
shutdown = true;
this.channel.close();
this.rpcDispatcher.stop();
this.rpcStructs.clear();
+ try {
+ eventBroker.shutdown();
+ } catch (EventBrokerException e) {
+ throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0014, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0014));
+ }
}
public void addListener(Class eventClass, EventObjectListener listener)
throws MessagingException {
-
+ if (shutdown) {
+ return;
+ }
+ try {
+ eventBroker.addListener(eventClass, listener);
+ } catch (EventSourceException e) {
+ throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0013, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0013));
+ }
}
public void removeListener(Class eventClass, EventObjectListener listener)
throws MessagingException {
-
+ if (shutdown) {
+ return;
+ }
+ try {
+ eventBroker.removeListener(eventClass, listener);
+ } catch (EventSourceException e) {
+ throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0015, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0015));
+ }
}
public void removeListener(EventObjectListener listener)
throws MessagingException {
-
+ if (shutdown) {
+ return;
+ }
+ try {
+ eventBroker.removeListener(listener);
+ } catch (EventSourceException e) {
+ throw new MessagingException(e, ErrorMessageKeys.MESSAGING_ERR_0015, CommonPlugin.Util.getString(ErrorMessageKeys.MESSAGING_ERR_0015));
+ }
}
}
-
-
-
Modified: trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -24,7 +24,6 @@
-import java.io.PrintStream;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
@@ -52,7 +51,6 @@
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.VMComponentDefnID;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
-import com.metamatrix.common.connection.ManagedConnection;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.vdb.api.ModelInfo;
@@ -65,7 +63,7 @@
import com.metamatrix.metadata.runtime.api.VirtualDatabase;
import com.metamatrix.metadata.runtime.api.VirtualDatabaseID;
import com.metamatrix.platform.config.spi.xml.XMLConfigurationConnector;
-import com.metamatrix.platform.config.spi.xml.XMLConfigurationConnectorFactory;
+import com.metamatrix.platform.config.spi.xml.XMLConfigurationMgr;
/**
@@ -85,16 +83,10 @@
private static final String UNDEFINED_PRINCIPAL = "VDBCreation_UndefinedPrincipal"; //$NON-NLS-1$
- private static PrintStream logger=null;
- // properties used to call createVDB
-
private Properties runtimeProps;
- private XMLConfigurationConnectorFactory factory = null;
private boolean updateBindingProperties = false;
private List vmsToDeployTo = null;
- private ManagedConnection conn = null;
-
private String thePrincipal;
@@ -146,14 +138,8 @@
}
}
- try{
- writer.executeActions(editor.getDestination().popActions(), thePrincipal);
- writer.commit();
- } catch (Exception e) {
- e.printStackTrace();
- writer.rollback();
- throw e;
- }
+ writer.executeActions(editor.getDestination().popActions());
+ writer.commit();
VirtualDatabase vdb = RuntimeMetadataCatalog.getInstance().createVirtualDatabase(vdbArchive, principal);
VirtualDatabaseID vdbID = (VirtualDatabaseID)vdb.getID();
@@ -510,27 +496,8 @@
}
- protected static void log(String msg) {
- if (logger != null) {
- logger.println(msg);
- } else {
- LogManager.logWarning(LogCommonConstants.CTX_CONFIG, msg);
- }
- }
-
-
private XMLConfigurationConnector getWriter() throws Exception {
-
- if (factory == null) {
-
- factory = new XMLConfigurationConnectorFactory();
-
- conn = factory.createConnection(new Properties(), thePrincipal);
- }
-
- XMLConfigurationConnector writer = (XMLConfigurationConnector) factory.createTransaction(conn, false);
-
- return writer;
+ return XMLConfigurationMgr.getInstance().getTransaction(thePrincipal);
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/ConfigurationAdminAPIImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,11 +22,8 @@
package com.metamatrix.platform.admin.apiimpl;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -48,10 +45,7 @@
import com.metamatrix.common.config.api.ConfigurationObjectEditor;
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.HostID;
-import com.metamatrix.common.config.api.ProductType;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
-import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.admin.api.ConfigurationAdminAPI;
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
@@ -99,31 +93,6 @@
}
/**
- * Returns the <code>ConfigurationID</code> for the current configuration.
- *
- * @param sessionID
- * ID of administrator's session
- * @return ConfigurationID for current configuration
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException
- * if there is not a valid administrative session
- * @throws AuthorizationException
- * if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException
- * if a general remote system problem occurred
- */
- public synchronized ConfigurationID getCurrentConfigurationID() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getCurrentConfigurationID();
- }
-
- /**
* Returns the ID of the next startup <code>Configuration</code>, which should reflect the desired runtime state of the
* system.
*
@@ -150,31 +119,6 @@
}
/**
- * Returns the ID of the startup <code>Configuration</code>, which should reflect the desired runtime state of the system.
- *
- * @param sessionID
- * ID of administrator's session
- * @return ID of startup configuration
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException
- * if there is not a valid administrative session
- * @throws AuthorizationException
- * if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException
- * if a general remote system problem occurred
- */
- public synchronized ConfigurationID getStartupConfigurationID() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getStartupConfigurationID();
- }
-
- /**
* Returns the current deployed <code>Configuration</code>. Note, this configuration may not match the actual configuration
* the system is currently executing under due to administrative task that can be done to tune the system. Those
* administrative task <b>do not</b> change the actual <code>Configuration</code> stored in the
@@ -214,48 +158,6 @@
return configAdmin.getNextStartupConfiguration();
}
- /**
- * Returns the current deployed <code>Configuration</code>. Note, this configuration may not match the actual configuration
- * the system is currently executing under due to administrative task that can be done to tune the system. Those
- * administrative task <b>do not</b> change the actual <code>Configuration</code> stored in the
- * <code>ConfigurationService</code>.
- *
- * @return Configuration that is currently in use
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- public synchronized Configuration getStartupConfiguration() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getStartupConfiguration();
- }
-
- /**
- * Returns the named <code>Configuration</code>.
- *
- * @param configName
- * is the name of the Configuration to obtain
- * @return Configuration
- * @throws InvalidConfigurationException
- * if the specified name does not exist
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- public synchronized Configuration getConfiguration(String configName) throws InvalidConfigurationException,
- ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getConfiguration(configName);
- }
-
public synchronized ConfigurationModelContainer getConfigurationModel(String configName) throws ConfigurationException,
InvalidSessionException,
AuthorizationException,
@@ -330,82 +232,6 @@
}
/**
- * <p>
- * This method will return a Collection of objects that represent the set of global configuration objects currently
- * represented in the configuration database. This method will generally be used when attempting to import a configuration
- * into the database as the 'Next Startup' configuration. This information is important when importing a new configuration so
- * that any global type configuration objects that are to be imported can be resolved against the global objects that
- * currently exist in the database.
- * </p>
- *
- * <pre>
- *
- * The Collection of objects will contain the following configuration
- * object types:
- *
- * ComponentTypes
- * ProductTypes
- * Hosts
- *
- * </pre>
- *
- * @return a Collection of all of the global configuration objects as they exist in the database.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException
- * if there is not a valid administrative session
- * @throws AuthorizationException
- * if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException
- * if a general remote system problem occurred
- */
- public synchronized Collection getAllGlobalConfigObjects() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getAllGlobalConfigObjects();
- }
-
- /**
- * Baselines the realtime portion of the current (operational) configuration into the next-startup configuration.
- *
- * @param principalName
- * the name of the principal that is requesting the baselining
- */
- public synchronized void baselineCurrentConfiguration() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.baselineCurrentConfiguration()"); //$NON-NLS-1$
- configAdmin.baselineCurrentConfiguration(token.getUsername());
- }
-
- /**
- * Returns a Map of component type definitions for each <code>ComponentTypeID</code> that is contained in the passed
- * <code>Collection</code>. This does not return the dependent definitions for service type components.
- *
- * @param componentIDs
- * is a Collection
- * @return Map of a Map of component type difinitions keyed by <code>ComponentTypeID</code>
- * @see getDependentComponentTypeDefintions(Collection)
- */
- public synchronized Map getComponentTypeDefinitions(Collection componentIDs) throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getComponentTypeDefinitions(componentIDs);
- }
-
- /**
* Returns the component type definitions for the specified <code>ComponentTypeID</code>. This does not return the
* dependent definitions for service type components.
*
@@ -445,28 +271,6 @@
}
/**
- * Returns a <code>List</code> of type <code>ComponentType</code> . that are flagged as being monitored. A component of
- * this type is considered to be available for monitoring statistics.
- *
- * @param includeDeprecated
- * true if class names that have been deprecated should be included in the returned list, or false if only
- * non-deprecated constants should be returned.
- * @return Collection of type <code>ComponentType</code>
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @see #ComponentType
- */
- public synchronized Collection getMonitoredComponentTypes(boolean includeDeprecated) throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getMonitoredComponentTypes(includeDeprecated);
- }
-
- /**
* Returns a <code>ComponentType</code> for the specified <code>ComponentTypeID</code>
*
* @param id
@@ -509,35 +313,6 @@
/**
- * Returns a <code>List</code> of type <code>ProductType</code> that represents all the ProductTypes defined.
- *
- * @param includeDeprecated
- * true if class names that have been deprecated should be included in the returned list, or false if only
- * non-deprecated constants should be returned.
- * @return Collection of type <code>ProductType</code>
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @see #ProductType
- */
- public Collection getAllProductTypes(boolean includeDeprecated) throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- Iterator allTypes = getAllComponentTypes(includeDeprecated).iterator();
- ArrayList productTypes = new ArrayList();
- Object aType = null;
- while (allTypes.hasNext()) {
- aType = allTypes.next();
- if (aType instanceof ProductType) {
- productTypes.add(aType);
- }
- }
- return productTypes;
- }
-
-
-
- /**
* Returns a <code>Host</code> for the specified <code>HostID</code>. </br>
*
* @return Host
@@ -554,50 +329,6 @@
return configAdmin.getHost(hostID);
}
- /**
- * Returns a <code>Collection</code> of currently defined hosts. This method does not cache, it reretrieves the data
- * everytime. </br>
- *
- * @return Collection of type Host
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- public synchronized Collection getHosts() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getHosts();
- }
-
- /**
- * Returns a collection of <code>ComponentDefn</code>s for the specified collection of <code>ComponentDefnID</code>s and
- * <code>ConfigurationID</code>. If the configuration is null the parent name from the componentID will be used. </br> The
- * reason for adding the option to specify the configurationID is so that the same collection of componentIDs can be used to
- * obtain the componentDefns from the different configurations. Otherwise, the requestor would have to create a new set of
- * componetDefnIDs for each configuration. <br>
- *
- * @param componentDefnIDs
- * contains all the ids for which componet defns to be returned
- * @param configurationID
- * is the configuration from which the component defns are to be derived; optional, nullalble
- * @return Collection of ComponentDefn objects
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- public synchronized Collection getComponentDefns(Collection componentDefnIDs,
- ConfigurationID configurationID) throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getComponentDefns(componentDefnIDs, configurationID);
- }
-
public synchronized ComponentDefn getComponentDefn(ConfigurationID configurationID,
ComponentDefnID componentDefnID) throws ConfigurationException,
InvalidSessionException,
@@ -634,29 +365,6 @@
}
/**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor} that are of the
- * specified resource type.
- *
- * @param componentTypeID
- * that identifies the type of resources to be returned
- * @throws AuthorizationException
- * if caller is not authorized to perform this method.
- * @throws InvalidSessionException
- * if the <code>callerSessionID</code> is not valid or is expired.
- * @throws MetaMatrixComponentException
- * if an error occurred in communicating with a component.
- */
- public synchronized Collection getResources(ComponentTypeID componentTypeID) throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- AdminAPIHelper.validateSession(getSessionID());
- // Any administrator may call this read-only method - no need to validate role
- return configAdmin.getResources(componentTypeID);
- }
-
- /**
* Save the resource changes based on each {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor} in
* the collection.
*
@@ -703,7 +411,6 @@
* if an error occurred within or during communication with the Metadata Service.
*/
public synchronized Set executeTransaction(ActionDefinition action) throws ModificationException,
- ConfigurationLockException,
ConfigurationException,
InvalidSessionException,
AuthorizationException,
@@ -732,7 +439,6 @@
* if an error occurred within or during communication with the Metadata Service.
*/
public synchronized Set executeTransaction(List actions) throws ModificationException,
- ConfigurationLockException,
ConfigurationException,
InvalidSessionException,
AuthorizationException,
@@ -745,153 +451,6 @@
}
/**
- * Execute a list of insert actions and for actions on objects of type ComponentDefn or DeployedComponent object, it will have
- * its configuration id resassigned, and optionally return the set of objects or object IDs that were affected/modified by the
- * action. Only insert actions can be performed here because changing a configuration id on a modify action has larger
- * consiquences.
- *
- * @param assignConfigurationID
- * the configuration for which any action for a component object will have its configurationID set to this.
- * @param actions
- * the ordered list of actions that are to be performed on data within the repository.
- * @return the set of objects that were affected by this transaction.
- * @throws ModificationException
- * if the target of any of the actions is invalid, or an action that is not an insert, or if the target object is
- * not a supported class of targets.
- * @throws IllegalArgumentException
- * if the action is null or if the result specification is invalid
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Metadata Service.
- */
- public synchronized Set executeInsertTransaction(ConfigurationID assignConfigurationID,
- List actions) throws ModificationException,
- ConfigurationLockException,
- ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.executeInsertTransaction(" + assignConfigurationID + ", " + actions + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return configAdmin.executeInsertTransaction(assignConfigurationID, actions, token.getUsername());
- }
-
- /**
- * Undo the specified number of previously-committed transactions.
- *
- * @param numberOfActions
- * the number of actions in the history that are to be undone.
- * @param principalName
- * of the person executing the transaction
- * @return the set of objects that were affected by undoing these actions.
- * @throws IllegalArgumentException
- * if the number is negative.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Metadata Service.
- */
- public synchronized Set undoActionsAsTransaction(int numberOfActions) throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.undoActionsAsTransaction(" + numberOfActions + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- return configAdmin.undoActionsAsTransaction(numberOfActions, token.getUsername());
- }
-
- /**
- * Get the history of actions executed in transactions by this editor. The actions at the front of the list will be those most
- * recently executed.
- *
- * @return the ordered list of actions in the history.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Metadata Service.
- */
- public synchronized List getHistory()
- throws ConfigurationException,InvalidSessionException, AuthorizationException, MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.getHistory()"); //$NON-NLS-1$
- return configAdmin.getHistory();
- }
-
- /**
- * Clear the history of all actions without undoing any of them.
- *
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Metadata Service.
- */
- public synchronized void clearHistory() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.clearHistory()"); //$NON-NLS-1$
- configAdmin.clearHistory();
- }
-
- /**
- * Get the number of actions that are currently in the history.
- *
- * @return the number of actions in the history.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Metadata Service.
- */
- public synchronized int getHistorySize() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.getHistorySize()"); //$NON-NLS-1$
- return configAdmin.getHistorySize();
- }
-
- /**
- * Set the limit on the number of actions in the history. Note that the history may at times be greater than this limit,
- * because when actions are removed from the history, all actions for a transactions are removed at the same time. If doing so
- * would make the history size smaller than the limit, no actions are removed.
- *
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Metadata Service.
- */
- public synchronized int getHistoryLimit() throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.getHistoryLimit()"); //$NON-NLS-1$
- return configAdmin.getHistoryLimit();
- }
-
- /**
- * Set the limit on the number of actions in the history. Note that the history may at times be greater than this limit,
- * because when actions are removed from the history, all actions for a transactions are removed at the same time. If doing so
- * would make the history size smaller than the limit, no actions are removed.
- *
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Metadata Service.
- */
- public synchronized void setHistoryLimit(int maximumHistoryCount) throws ConfigurationException,
- InvalidSessionException,
- AuthorizationException,
- MetaMatrixComponentException {
- // Validate caller's session
- SessionToken token = AdminAPIHelper.validateSession(getSessionID());
- // Validate caller's role
- AdminAPIHelper.checkForRequiredRole(token, AdminRoles.RoleName.ADMIN_SYSTEM, "ConfigurationAdminAPIImpl.setHistoryLimit(" +maximumHistoryCount + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- configAdmin.setHistoryLimit(maximumHistoryCount);
- }
-
- /**
* @see com.metamatrix.platform.admin.apiimpl.ConfigurationAdminAPI#addHost(java.lang.String, java.util.Properties)
* @since 4.3
*/
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -26,6 +26,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -41,7 +42,6 @@
import com.metamatrix.common.config.api.ConfigurationID;
import com.metamatrix.common.config.api.ServiceComponentDefnID;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.util.MetaMatrixExceptionUtil;
@@ -55,9 +55,9 @@
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.registry.HostControllerRegistryBinding;
+import com.metamatrix.platform.registry.ProcessRegistryBinding;
import com.metamatrix.platform.registry.ResourceNotBoundException;
import com.metamatrix.platform.registry.ServiceRegistryBinding;
-import com.metamatrix.platform.registry.ProcessRegistryBinding;
import com.metamatrix.platform.security.api.service.AuthorizationServiceInterface;
import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
import com.metamatrix.platform.security.api.service.SessionServiceInterface;
@@ -464,7 +464,7 @@
public void setLogConfiguration(Configuration config,
LogConfiguration logConfig,
List actions,
- String principalName) throws ConfigurationLockException,
+ String principalName) throws
ConfigurationException,
ServiceException,
MetaMatrixComponentException {
@@ -645,5 +645,29 @@
ProcessManagement vmController = processBinding.getProcessController();
return vmController.exportLogs();
}
+
+ /**
+ * Return all processes.
+ *
+ * @return List of processes
+ * @throws MetaMatrixComponentException
+ * if an error occurred in communicating with a component.
+ */
+ public List<ProcessRegistryBinding> getProcesses() throws MetaMatrixComponentException {
+ return registry.getVMs(null);
+ }
+
+ public Date getEldestProcessStartTime() throws MetaMatrixComponentException {
+ long start = 0;
+ for (ProcessRegistryBinding processRegistryBinding : getProcesses()) {
+ if (processRegistryBinding.isAlive()) {
+ start = Math.max(start, processRegistryBinding.getStartTime());
+ }
+ }
+ if (start != 0) {
+ return new Date(start);
+ }
+ return null;
+ }
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -54,9 +54,9 @@
import com.metamatrix.platform.admin.api.runtime.SystemState;
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.registry.ClusteredRegistryState;
+import com.metamatrix.platform.registry.ProcessRegistryBinding;
import com.metamatrix.platform.registry.ResourceNotBoundException;
import com.metamatrix.platform.registry.ServiceRegistryBinding;
-import com.metamatrix.platform.registry.ProcessRegistryBinding;
import com.metamatrix.platform.security.api.SessionToken;
import com.metamatrix.platform.service.ServicePlugin;
import com.metamatrix.platform.service.api.ServiceID;
@@ -676,12 +676,7 @@
* if an error occurred in communicating with a component.
*/
public synchronized Date getServerStartTime() throws AuthorizationException, InvalidSessionException, MetaMatrixComponentException {
- try {
- return configAdmin.getServerStartupTime();
- } catch (Exception e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.ADMIN_0083,
- PlatformPlugin.Util.getString(ErrorMessageKeys.ADMIN_0083));
- }
+ return this.helper.getEldestProcessStartTime();
}
/**
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -24,15 +24,10 @@
import java.io.InputStream;
import java.util.Collection;
-import java.util.Date;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.common.actions.ActionDefinition;
import com.metamatrix.common.actions.ModificationException;
import com.metamatrix.common.config.api.ComponentDefn;
@@ -49,7 +44,6 @@
import com.metamatrix.common.config.api.HostID;
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
import com.metamatrix.platform.service.api.ServiceInterface;
@@ -69,7 +63,6 @@
*/
ConfigurationObjectEditor createEditor() throws ConfigurationException;
-
/**
* Returns the <code>ConfigurationID</code> for the operational configuration.
*
@@ -90,23 +83,6 @@
ConfigurationID getNextStartupConfigurationID() throws ConfigurationException;
/**
- * Returns the ID of the startup <code>Configuration</code>, which should reflect the desired runtime state of the system.
- *
- * @return ID of startup configuration
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- ConfigurationID getStartupConfigurationID() throws ConfigurationException;
-
- /**
- * Baselines the realtime portion of the current (operational) configuration into the next-startup configuration.
- *
- * @param principalName
- * the name of the principal that is requesting the baselining
- */
- void baselineCurrentConfiguration(String principalName) throws ConfigurationException;
-
- /**
* Returns the current deployed <code>Configuration</code>. Note, this configuration may not match the actual configuration
* the system is currently executing under due to administrative task that can be done to tune the system. Those
* administrative task <b>do not</b> change the actual <code>Configuration</code> stored in the
@@ -129,28 +105,6 @@
Configuration getNextStartupConfiguration() throws ConfigurationException;
/**
- * Returns the startup <code>Configuration</code>, the Configuration that the system booted up with.
- *
- * @return Configuration that the system booted up with.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- Configuration getStartupConfiguration() throws ConfigurationException;
-
- /**
- * Returns the named <code>Configuration</code>.
- *
- * @param configName
- * is the name of the Configuration to obtain
- * @return Configuration
- * @throws InvalidConfigurationException
- * if the specified name does not exist
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- Configuration getConfiguration(String configName) throws InvalidConfigurationException, ConfigurationException;
-
- /**
* Returns the <code>ConfigurationModelContainer</code> that contains everything (i.e., ComponentTypes, Shared Resources and
* ComponentDefns) that the server needs to start.
*
@@ -208,52 +162,6 @@
Collection getConfigurationAndDependents(ConfigurationID configID) throws ConfigurationException;
/**
- * <p>
- * This method will return a Collection of objects that represent the set of global configuration objects currently
- * represented in the configuration database. This method will generally be used when attempting to import a configuration
- * into the database as the 'Next Startup' configuration. This information is important when importing a new configuration so
- * that any global type configuration objects that are to be imported can be resolved against the global objects that
- * currently exist in the database.
- * </p>
- *
- * <pre>
- *
- * The Collection of objects will contain the following configuration
- * object types:
- *
- * ComponentTypes
- * ProductTypes
- * Hosts
- *
- * </pre>
- *
- * @return a Collection of all of the global configuration objects as they exist in the database.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException
- * if there is not a valid administrative session
- * @throws AuthorizationException
- * if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException
- * if a general remote system problem occurred
- */
- public Collection getAllGlobalConfigObjects()
- throws ConfigurationException;
-
- /**
- * Returns a Map of component type definitions for each <code>ComponentTypeID</code> that is contained in the passed
- * <code>Collection</code>. This does not return the dependent definitions for service type components.
- *
- * @param componentIDs
- * is a Collection
- * @return Map of a Map of component type difinitions keyed by <code>ComponentTypeID</code>
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @see getDependentComponentTypeDefintions(Collection)
- */
- Map getComponentTypeDefinitions(Collection componentIDs) throws ConfigurationException;
-
- /**
* Returns the component type definitions for the specified <code>ComponentTypeID</code>. This does not return the
* dependent definitions for service type components.
*
@@ -266,7 +174,6 @@
*/
Collection getComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException;
-
/**
* Returns the all component type definitions for the specified <code>ComponentTypeID</code>. This includes the dependent
* definitions for service type components.
@@ -281,49 +188,6 @@
Collection getAllComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException;
/**
- * Returns a Map of all component type definitions for each <code>ComponentTypeID</code> that is contained in the passed
- * <code>Collection</code>. This only returns the dependent definitions for service type components where the component
- * type is defined as having a super component type.
- *
- * @param componentIDs
- * is a Collection
- * @return Map of component type difinitions keyed by <code>ComponentTypeID</code>
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @see getComponentTypeDefinitions(Collection)
- * @see getDependentComponentTypeDefinitions(ComponentType)
- */
- Map getDependentComponentTypeDefinitions(Collection componentIDs) throws ConfigurationException;
-
- /**
- * Returns the component type definitions for the specified <code>ComponentTypeID</code>. This only returns the dependent
- * definitions for service type components where the component type is defined as having a super component type.
- *
- * @param componentTypeID
- * is a ComponentTypeID
- * @return Collection of ComponentTypeDefns
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @see getComponentTypeDefinitions(ComponentTypeID)
- */
- Collection getDependentComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException;
-
-
- /**
- * Returns a <code>List</code> of type <code>ComponentType</code> . that are flagged as being monitored. A component of
- * this type is considered to be available for monitoring statistics.
- *
- * @param includeDeprecated
- * true if class names that have been deprecated should be included in the returned list, or false if only
- * non-deprecated constants should be returned.
- * @return Collection of type <code>ComponentType</code>
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- * @see #ComponentType
- */
- Collection getMonitoredComponentTypes(boolean includeDeprecated) throws ConfigurationException;
-
- /**
* Returns a <code>ComponentType</code> for the specified <code>ComponentTypeID</code>
*
* @param id
@@ -383,24 +247,6 @@
throws ConfigurationException;
/**
- * Returns a collection of <code>ComponentDefn</code>s for the specified collection of <code>ComponentDefnID</code>s and
- * <code>ConfigurationID</code>. If the configuration is null the parent name from the componentID will be used. </br> The
- * reason for adding the option to specify the configurationID is so that the same collection of componentIDs can be used to
- * obtain the componentDefns from the different configurations. Otherwise, the requestor would have to create a new set of
- * componetDefnIDs for each configuration. <br>
- *
- * @param componentDefnIDs
- * contains all the ids for which componet defns to be returned
- * @param configurationID
- * is the configuration from which the component defns are to be derived; optional, nullalble
- * @return Collection of ComponentDefn objects
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- Collection getComponentDefns(Collection componentDefnIDs, ConfigurationID configurationID)
- throws ConfigurationException;
-
- /**
* Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor} for all internal
* resources defined to the system. The internal resources are not managed with the other configuration related information.
* They are not dictated based on which configuration they will operate (i.e., next startup or operational);
@@ -411,18 +257,6 @@
Collection getResources() throws ConfigurationException;
/**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor} that are of the
- * specified resource type.
- *
- * @param componentTypeID
- * that identifies the type of resources to be returned
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- Collection getResources(ComponentTypeID componentTypeID) throws ConfigurationException;
-
-
- /**
* Save the resource changes based on each {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor} in
* the collection.
*
@@ -466,7 +300,7 @@
* if an error occurred within or during communication with the Configuration Service.
*/
Set executeTransaction(ActionDefinition action, String principalName )
- throws ModificationException, ConfigurationLockException, ConfigurationException;
+ throws ModificationException, ConfigurationException;
/**
* Execute a list of actions, and optionally return the set of objects or object IDs that were affected/modified by the
@@ -485,106 +319,10 @@
* if an error occurred within or during communication with the Configuration Service.
*/
Set executeTransaction(List actions, String principalName)
- throws ModificationException, ConfigurationLockException, ConfigurationException;
+ throws ModificationException, ConfigurationException;
/**
- * Execute a list of insert actions and for actions on objects of type ComponentDefn or DeployedComponent object, it will have
- * its configuration id resassigned, and optionally return the set of objects or object IDs that were affected/modified by the
- * action. Only insert actions can be performed here because changing a configuration id on a modify action has larger
- * consequences.
- *
- * @param assignConfigurationID
- * the configuration for which any action for a component object will have its configurationID set to this.
- * @param actions
- * the ordered list of actions that are to be performed on data within the repository.
- * @param principalName
- * of the person executing the transaction
- * @return the set of objects that were affected by this transaction.
- * @throws ModificationException
- * if the target of any of the actions is invalid, or an action that is not an insert, or if the target object is
- * not a supported class of targets.
- * @throws IllegalArgumentException
- * if the action is null or if the result specification is invalid
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- Set executeInsertTransaction(ConfigurationID assignConfigurationID, List actions, String principalName)
- throws ModificationException, ConfigurationLockException, ConfigurationException;
-
- /**
- * Undo the specified number of previously-committed transactions.
- *
- * @param numberOfActions
- * the number of actions in the history that are to be undone.
- * @param principalName
- * of the person executing the transaction
- * @return the set of objects that were affected by undoing these actions.
- * @throws IllegalArgumentException
- * if the number is negative.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- Set undoActionsAsTransaction(int numberOfActions, String principalName) throws ConfigurationException;
-
- /**
- * Get the history of actions executed in transactions by this editor. The actions at the front of the list will be those most
- * recently executed.
- *
- * @return the ordered list of actions in the history.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- List getHistory() throws ConfigurationException;
-
- /**
- * Clear the history of all actions without undoing any of them.
- *
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- void clearHistory() throws ConfigurationException;
-
- /**
- * Get the number of actions that are currently in the history.
- *
- * @return the number of actions in the history.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- int getHistorySize() throws ConfigurationException;
-
- /**
- * Set the limit on the number of actions in the history. Note that the history may at times be greater than this limit,
- * because when actions are removed from the history, all actions for a transactions are removed at the same time. If doing so
- * would make the history size smaller than the limit, no actions are removed.
- *
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- int getHistoryLimit() throws ConfigurationException;
-
- /**
- * Set the limit on the number of actions in the history. Note that the history may at times be greater than this limit,
- * because when actions are removed from the history, all actions for a transactions are removed at the same time. If doing so
- * would make the history size smaller than the limit, no actions are removed.
- *
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- void setHistoryLimit(int maximumHistoryCount) throws ConfigurationException;
-
-
- /**
- * Return the time the server was started. If the state of the server is not "Started" then a null is returned.
- *
- * @return Date Time server was started.
- * @throws ConfigurationException
- * if an error occurred within or during communication with the Configuration Service.
- */
- Date getServerStartupTime() throws ConfigurationException;
-
- /**
* Add Host to Configuration Add a new Host to the System (MetaMatrix Cluster)
*
* @param hostName
@@ -777,17 +515,5 @@
* @since 4.3
*/
public List checkPropertiesDecryptable(List defns) throws ConfigurationException;
-
- /**
- * Check whether the given properties pertaining to the given component (name and type)
- * contain at least one value that the server cannot decrypt with its current keystore.
- * @param props component properties possibly containing encrypted values.
- * @param componentTypeIdentifier The type identifier of the component to which the properties belong.
- * @return <code>true</code> if all of the encrypted properties, if any, can be decrypted.
- * @throws ConfigurationException
- * @since 4.3
- */
- boolean checkPropertiesDecryptable(Properties props,
- String componentTypeIdentifier) throws ConfigurationException;
}
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServicePropertyNames.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServicePropertyNames.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServicePropertyNames.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.api.service;
-
-public class ConfigurationServicePropertyNames {
-
- /**
- * The environment property name for the class that is to be used for the MetadataConnectionFactory implementation.
- * This property is required (there is no default).
- */
- public static final String CONNECTION_FACTORY = "metamatrix.config.connection.Factory"; //$NON-NLS-1$
-
- /**
- * The environment property name for the class of the driver.
- * This property is optional.
- */
- public static final String CONNECTION_DRIVER = "metamatrix.config.connection.Driver"; //$NON-NLS-1$
-
- /**
- * The environment property name for the protocol for connecting to the metadata store.
- * This property is optional.
- */
- public static final String CONNECTION_PROTOCOL = "metamatrix.config.connection.Protocol"; //$NON-NLS-1$
-
- /**
- * The environment property name for the name of the metadata store database.
- * This property is optional.
- */
- public static final String CONNECTION_DATABASE = "metamatrix.config.connection.Database"; //$NON-NLS-1$
-
- /**
- * The environment property name for the username that is to be used for connecting to the metadata store.
- * This property is optional.
- */
- public static final String CONNECTION_USERNAME = "metamatrix.config.connection.User"; //$NON-NLS-1$
-
- /**
- * The environment property name for the password that is to be used for connecting to the metadata store.
- * This property is optional.
- */
- public static final String CONNECTION_PASSWORD = "metamatrix.config.connection.Password"; //$NON-NLS-1$
-
- /**
- * The environment property name for the maximum number of milliseconds that a metadata connection
- * may remain unused before it becomes a candidate for garbage collection.
- * This property is optional.
- */
- public static final String CONNECTION_POOL_MAXIMUM_AGE = "metamatrix.config.connection.MaximumAge"; //$NON-NLS-1$
-
- /**
- * The environment property name for the maximum number of concurrent users of a single metadata connection.
- * This property is optional.
- */
- public static final String CONNECTION_POOL_MAXIMUM_CONCURRENT_USERS = "metamatrix.config.connection.MaximumConcurrentReaders"; //$NON-NLS-1$
-
- /**
- * The default connection factory class to use when one is not specified.
- */
- public static final String DEFAULT_CONNECTION_FACTORY_CLASS="com.metamatrix.platform.config.spi.xml.XMLConfigurationConnectorFactory";
-}
-
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/event/ConfigurationChangeEvent.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/event/ConfigurationChangeEvent.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/event/ConfigurationChangeEvent.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -46,9 +46,7 @@
public ConfigurationChangeEvent(Object source, Collection baseIDs, int action) {
super(source);
- if(baseIDs == null){
- Assertion.isNotNull(baseIDs, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0007));
- }
+ Assertion.isNotNull(baseIDs, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0007));
this.action = action;
this.ids = baseIDs;
Added: trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java (rev 0)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -0,0 +1,133 @@
+package com.metamatrix.platform.config.persistence.api;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import com.metamatrix.common.config.api.ConfigurationID;
+import com.metamatrix.common.config.api.ConfigurationModelContainer;
+import com.metamatrix.common.config.api.exceptions.ConfigurationException;
+import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
+import com.metamatrix.common.connection.ManagedConnectionException;
+import com.metamatrix.common.extensionmodule.ExtensionModuleTypes;
+import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
+import com.metamatrix.common.extensionmodule.spi.ExtensionModuleTransaction;
+import com.metamatrix.platform.PlatformPlugin;
+import com.metamatrix.platform.util.ErrorMessageKeys;
+
+public class ExtensionModuleConnection implements PersistentConnection {
+
+ private ExtensionModuleTransaction trans;
+ private ConfigurationModelContainerAdapter adapter = new ConfigurationModelContainerAdapter();
+
+ public ExtensionModuleConnection(ExtensionModuleTransaction trans) {
+ this.trans = trans;
+ }
+
+ @Override
+ public void close() {
+ trans.close();
+ }
+
+ @Override
+ public void commit() throws ConfigurationException {
+ try {
+ trans.commit();
+ } catch (ManagedConnectionException e) {
+ throw new ConfigurationException(e);
+ }
+ }
+
+ @Override
+ public void delete(ConfigurationID configID, String principal)
+ throws ConfigurationException {
+ try {
+ boolean inUse = trans.isNameInUse(configID.getFullName());
+
+ if (inUse) {
+ trans.removeSource(principal, configID.getFullName());
+ }
+ } catch (Exception e) {
+ throw new ConfigurationException(e, ErrorMessageKeys.CONFIG_0153, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0153, configID));
+ }
+ }
+
+ @Override
+ public boolean isClosed() {
+ return trans.isClosed();
+ }
+
+ @Override
+ public ConfigurationModelContainer read(ConfigurationID configID)
+ throws ConfigurationException {
+ try {
+
+ byte[] data = trans.getSource(configID.getFullName());
+
+ if (data == null) {
+ throw new ConfigurationException(ErrorMessageKeys.CONFIG_0154, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0154, configID));
+ }
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(data);
+ InputStream isContent = new BufferedInputStream(bais);
+
+ ConfigurationModelContainer model = this.adapter.readConfigurationModel(isContent, configID);
+ return model;
+ } catch (ExtensionModuleNotFoundException notFound) {
+ throw new ConfigurationException(notFound, ErrorMessageKeys.CONFIG_0154, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0154, configID));
+ } catch (Exception e) {
+ throw new ConfigurationException(e, ErrorMessageKeys.CONFIG_0155, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0155, configID));
+ }
+
+ }
+
+ @Override
+ public void rollback() throws ConfigurationException {
+ try {
+ trans.rollback();
+ } catch (ManagedConnectionException e) {
+ throw new ConfigurationException(e);
+ }
+ }
+
+ @Override
+ public void write(ConfigurationModelContainer model, String principal)
+ throws ConfigurationException {
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ BufferedOutputStream bos = new BufferedOutputStream(out);
+
+ adapter.writeConfigurationModel(bos, model, principal);
+
+ bos.close();
+ out.close();
+
+ byte[] data = out.toByteArray();
+
+ if (data == null || data.length == 0) {
+ throw new ConfigurationException(ErrorMessageKeys.CONFIG_0156, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0156));
+ }
+
+ boolean inUse = trans.isNameInUse(model.getConfigurationID().getFullName());
+
+ if (inUse) {
+ trans.setSource(principal, model.getConfigurationID().getFullName(), data, data.length);
+ } else {
+ trans.addSource(principal, ExtensionModuleTypes.CONFIGURATION_MODEL_TYPE,
+ model.getConfigurationID().getFullName(),
+ data,
+ data.length,
+ model.getConfigurationID().getFullName() + " Configuration Model", //$NON-NLS-1$
+ true);
+
+ }
+
+ } catch (Exception e) {
+ throw new ConfigurationException(e, ErrorMessageKeys.CONFIG_0157, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0157, model.getConfigurationID()));
+
+ }
+ }
+
+}
Property changes on: trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/ExtensionModuleConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/PersistentConnection.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/PersistentConnection.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/PersistentConnection.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,7 +22,6 @@
package com.metamatrix.platform.config.persistence.api;
-import com.metamatrix.common.config.StartupStateException;
import com.metamatrix.common.config.api.ConfigurationID;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
@@ -44,58 +43,6 @@
boolean isClosed();
/**
- * Call to set the startup state to @see {StartupStateController.STARTING Starting}.
- * The server must be in the STOPPED state in order for this to work. Otherwise,
- * a StartpStateException will be thrown.
- * @throws StartupStateException is thrown if the server state is not currently
- * set to STOPPED.
- */
- void setServerStarting() throws StartupStateException, ConfigurationException;
-
- /**
- * Call to forcibly set the startup state to @see {StartupStateController.STARTING Starting},
- * regardless of the current state of the server.
- * @throws StartupStateException is thrown if the server state cannot be set.
- */
- void setServerStarting( boolean force) throws StartupStateException, ConfigurationException;
-
- /**
- * Call to set the startup state to @see {StartupStateController.STARTED Started}.
- * The server must be in the STARTING state in order for this to work. Otherwise,
- * a StartpStateException will be thrown.
- * @throws StartupStateException is thrown if the server state cannot be set.
- */
- void setServerStarted( ) throws StartupStateException, ConfigurationException;
-
-
- /**
- * Call to set the startup state to @see {StartupStateController.STOPPED Stopped}.
- * This is normally called when the system is shutdown.
- * @throws StartupStateException is thrown if the server state cannot be set.
- */
- void setServerStopped() throws StartupStateException, ConfigurationException;
-
-
-
- /**
- * Call to get the current state
- * @return int state @see {StartupStateController Controller}
- * @throws ConfigurationException if an error occurs
- */
- int getServerState() throws ConfigurationException;
-
-
- /**
- * Call to get the startup time of the server. If the current state of the server
- * is not @see {StartupStateController.STARTED STARTED}, then the return value
- * will be null.
- * @return time the server stated, may be null if not in a started state
- * @throws ConfigurationException if an error occurs
- */
- java.util.Date getStartupTime() throws ConfigurationException;
-
-
- /**
* Returns an ConfigurationModelContainer based on how the implementation read configuation information
* @param configID indicates which configuration to read
* @return ConfigurationModel
@@ -122,8 +69,6 @@
void delete(ConfigurationID configID, String principal) throws ConfigurationException;
- void beginTransaction() throws ConfigurationException;
-
void rollback() throws ConfigurationException;
void commit() throws ConfigurationException;
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/PersistentConnectionFactory.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/PersistentConnectionFactory.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/persistence/api/PersistentConnectionFactory.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,26 +22,20 @@
package com.metamatrix.platform.config.persistence.api;
-import java.util.Arrays;
import java.util.Properties;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
-import com.metamatrix.platform.config.ConfigMessages;
-import com.metamatrix.platform.config.ConfigPlugin;
-import com.metamatrix.platform.config.persistence.impl.file.FilePersistentConnectionFactory;
-import com.metamatrix.platform.config.persistence.impl.jdbc.JDBCPersistentConnectionFactory;
+import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
+import com.metamatrix.common.connection.ManagedConnectionException;
+import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
+import com.metamatrix.platform.config.persistence.impl.file.FilePersistentConnection;
-public abstract class PersistentConnectionFactory {
+public class PersistentConnectionFactory {
public static final String PERSISTENT_FACTORY_NAME = "metamatrix.config.persistent.factory"; //$NON-NLS-1$
+ public static final String FILE_FACTORY_NAME = FilePersistentConnection.class.getName();
- public static final String FILE_FACTORY_NAME = FilePersistentConnectionFactory.class.getName();
- public static final String JDBC_FACTORY_NAME = JDBCPersistentConnectionFactory.class.getName();
-
private Properties properties;
public PersistentConnectionFactory(Properties factoryProperties) {
@@ -51,61 +45,34 @@
public Properties getProperties() {
return properties;
}
- /**
- * createPersistentConnectionFactory is used for bootstrapping the system.
- * The connection is normally only used for starting the system, then
- * then {@link #createPersistentConnectionFactory} is used.
- * @param props
- * @return
- * @throws ConfigurationException
- */
- public static final PersistentConnectionFactory createPersistentConnectionFactory(Properties props) throws ConfigurationException {
- Properties properties = PropertiesUtils.clone(props, false);
- String factoryName = properties.getProperty(PERSISTENT_FACTORY_NAME);
-
- if (factoryName == null || factoryName.trim().length() == 0) {
- // if no factory name, then check if this a file connection
- if (isFileFactory(properties)) {
- return new FilePersistentConnectionFactory(properties);
- }
-
- if (isJDBCFactory(properties)) {
- return new JDBCPersistentConnectionFactory(properties);
- }
-
- throw new ConfigurationException(ConfigMessages.CONFIG_0009, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0009, PERSISTENT_FACTORY_NAME));
-
- }
- try {
- return (PersistentConnectionFactory) ReflectionHelper.create(factoryName, Arrays.asList(properties), Thread.currentThread().getContextClassLoader());
- //create(factoryName, args);
- } catch (MetaMatrixCoreException err) {
- throw new ConfigurationException(err, ConfigMessages.CONFIG_0013, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0013, factoryName));
-
- }
- }
-
/**
* Creates the the of {@link PersistentConnection} required to communicate
* to the configuration repository.
* @param properties are the settings for persistence storage
* @return PersistentSource class for handling configuration storage
*/
- public abstract PersistentConnection createPersistentConnection()
- throws ConfigurationException;
+ public PersistentConnection createPersistentConnection(boolean readOnly)
+ throws ConfigurationException {
+ if (isFileFactory(properties)) {
+ return new FilePersistentConnection(properties, new ConfigurationModelContainerAdapter());
+ }
+ ExtensionModuleManager manager = ExtensionModuleManager.getInstance();
+ try {
+ return new ExtensionModuleConnection(readOnly?manager.getReadTransaction():manager.getWriteTransaction());
+ } catch (ManagedConnectionException e) {
+ throw new ConfigurationException(e);
+ }
+ }
private static boolean isFileFactory(Properties props) {
- String configFileName = props.getProperty("metamatrix.config.ns.filename");
+ if (FILE_FACTORY_NAME.equals(props.getProperty(PERSISTENT_FACTORY_NAME))) {
+ return true;
+ }
+ String configFileName = props.getProperty(FilePersistentConnection.CONFIG_NS_FILE_NAME_PROPERTY);
return configFileName != null && configFileName.length() > 0;
}
- private static boolean isJDBCFactory(Properties props) {
- String driver = props.getProperty("metamatrix.config.jdbc.persistent.readerDriver");
-
- return driver != null && driver.length() > 0;
- }
-
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/persistence/impl/file/FilePersistentConnection.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/persistence/impl/file/FilePersistentConnection.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/persistence/impl/file/FilePersistentConnection.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -29,11 +29,8 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Date;
import java.util.Properties;
-import com.metamatrix.common.config.StartupStateController;
-import com.metamatrix.common.config.StartupStateException;
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.ConfigurationID;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
@@ -67,10 +64,6 @@
*/
public static final String NEXT_STARTUP_FILE_NAME = "config_ns.xml"; //$NON-NLS-1$
- private int state = StartupStateController.STATE_STOPPED;
-
- private Date startupTime = null;
-
private String path;
private String ns_full_path;
@@ -81,8 +74,14 @@
private boolean closed = true;
- public FilePersistentConnection(Properties props, ConfigurationModelContainerAdapter adapter) {
+ public FilePersistentConnection(Properties props, ConfigurationModelContainerAdapter adapter) throws ConfigurationException {
this.adapter = adapter;
+
+ String filename = props.getProperty(FilePersistentConnection.CONFIG_NS_FILE_NAME_PROPERTY);
+ if (filename == null || filename.length() == 0) {
+ throw new ConfigurationException(ErrorMessageKeys.CONFIG_0029, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0029,
+ FilePersistentConnection.CONFIG_NS_FILE_NAME_PROPERTY ));
+ }
path = props.getProperty(CONFIG_FILE_PATH_PROPERTY, ""); //$NON-NLS-1$
if (props.getProperty(CONFIG_NS_FILE_NAME_PROPERTY, null) != null) {
@@ -144,85 +143,7 @@
}
- /**
- * Call to set the startup state to @see {StartupStateController.STARTING Starting}.
- * The server must be in the STOPPED state in order for this to work. Otherwise,
- * a StartpStateException will be thrown.
- * @throws StartupStateException is thrown if the server state is not currently
- * set to STOPPED.
- */
- public synchronized void setServerStarting() throws StartupStateException, ConfigurationException {
- if (this.state != StartupStateController.STATE_STOPPED) {
- throw new StartupStateException(StartupStateController.STATE_STARTING, this.state);
- }
-
-
- this.state = StartupStateController.STATE_STARTING;
-
- }
-
- /**
- * Call to forcibly set the startup state to @see {StartupStateController.STARTING Starting},
- * regardless of the current state of the server.
- * @throws StartupStateException is thrown if the server state cannot be set.
- */
- public synchronized void setServerStarting( boolean force) throws StartupStateException, ConfigurationException {
- this.state = StartupStateController.STATE_STARTING;
-
- }
-
- /**
- * Call to set the startup state to @see {StartupStateController.STARTED Started}.
- * The server must be in the STARTING state in order for this to work. Otherwise,
- * a StartpStateException will be thrown.
- * @throws StartupStateException is thrown if the server state cannot be set.
- */
- public synchronized void setServerStarted( ) throws StartupStateException, ConfigurationException {
- if (this.state != StartupStateController.STATE_STARTING) {
- throw new StartupStateException(StartupStateController.STATE_STARTED, this.state);
- }
-
- this.state = StartupStateController.STATE_STARTED;
- this.startupTime = new Date();
-
- }
-
-
- /**
- * Call to set the startup state to @see {StartupStateController.STOPPED Stopped}.
- * This is normally called when the system is shutdown.
- * @throws StartupStateException is thrown if the server state cannot be set.
- */
- public synchronized void setServerStopped() throws StartupStateException, ConfigurationException {
- state = StartupStateController.STATE_STOPPED;
- }
-
-
-
- /**
- * Call to get the current state
- * @return int state @see {StartupStateController Controller}
- */
- public int getServerState() throws ConfigurationException {
- return this.state;
- }
-
- /**
- * Call to get the current state
- * @return int state @see {StartupStateController Controller}
- */
-
- public java.util.Date getStartupTime() throws ConfigurationException {
- if (getServerState() == StartupStateController.STATE_STARTED) {
- return startupTime;
- }
- // go ahead and return a date, even though its not correct
- return new Date();
- }
-
-
-
- private InputStream readConfigurationFromFile(String fileName) throws ConfigurationException {
+ private InputStream readConfigurationFromFile(String fileName) throws ConfigurationException {
InputStream inputStream = null;
File configFile = new File(fileName);
@@ -250,13 +171,8 @@
}
public synchronized void write(ConfigurationModelContainer model, String principal) throws ConfigurationException {
- if(model == null){
- Assertion.isNotNull(model, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0022));
- }
-
- if(principal == null){
- Assertion.isNotNull(principal, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0023));
- }
+ Assertion.isNotNull(model, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0022));
+ Assertion.isNotNull(principal, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0023));
init();
@@ -284,7 +200,6 @@
} catch(Exception ioe) {
- ioe.printStackTrace();
throw new ConfigurationException(ioe, ErrorMessageKeys.CONFIG_0024, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0024, fileName));
}
@@ -301,7 +216,6 @@
deleteFile(fileName);
} catch(Exception ioe) {
- ioe.printStackTrace();
throw new ConfigurationException(ioe, ErrorMessageKeys.CONFIG_0025, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0025, fileName));
}
@@ -312,11 +226,8 @@
if (id.equals(Configuration.NEXT_STARTUP_ID)) {
return ns_full_path;
- } else if (id.equals(Configuration.STARTUP_ID)) {
- return ns_full_path;
- } else {
- throw new ConfigurationException(ErrorMessageKeys.CONFIG_0026, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0026, id));
}
+ throw new ConfigurationException(ErrorMessageKeys.CONFIG_0026, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0026, id));
}
private void copyFile(String fromFileName, String toFileName) throws ConfigurationException {
@@ -354,7 +265,6 @@
}
} catch(Exception ioe) {
- ioe.printStackTrace();
throw new ConfigurationException(ioe, ErrorMessageKeys.CONFIG_0028, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0028, fileToDelete ));
}
@@ -371,10 +281,6 @@
}
@Override
- public void beginTransaction() throws ConfigurationException {
- }
-
- @Override
public void commit() throws ConfigurationException {
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/persistence/impl/file/FilePersistentUtil.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/persistence/impl/file/FilePersistentUtil.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/persistence/impl/file/FilePersistentUtil.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -48,12 +48,12 @@
public static ConfigurationModelContainer readModel(Properties props, ConfigurationID configID) throws Exception {
- PersistentConnectionFactory pf = PersistentConnectionFactory.createPersistentConnectionFactory(props);
+ PersistentConnectionFactory pf = new PersistentConnectionFactory(props);
- PersistentConnection readin = pf.createPersistentConnection();
+ PersistentConnection readin = pf.createPersistentConnection(true);
ConfigurationModelContainer model = readin.read(configID);
-
+ readin.close();
return model;
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -26,7 +26,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -40,8 +39,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.common.actions.ActionDefinition;
-import com.metamatrix.common.actions.AddObject;
-import com.metamatrix.common.actions.CreateObject;
import com.metamatrix.common.actions.ModificationException;
import com.metamatrix.common.config.api.ComponentDefn;
import com.metamatrix.common.config.api.ComponentDefnID;
@@ -63,25 +60,20 @@
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.VMComponentDefnID;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.config.api.exceptions.InvalidArgumentException;
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
import com.metamatrix.common.config.model.ComponentCryptoUtil;
import com.metamatrix.common.config.xml.XMLConfigurationImportExportUtility;
-import com.metamatrix.common.connection.ManagedConnectionException;
-import com.metamatrix.common.connection.TransactionMgr;
import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.namedobject.BaseID;
import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
-import com.metamatrix.platform.config.api.service.ConfigurationServicePropertyNames;
-import com.metamatrix.platform.config.spi.ConfigurationTransaction;
-import com.metamatrix.platform.config.spi.SystemConfigurationNames;
+import com.metamatrix.platform.config.spi.xml.XMLConfigurationConnector;
+import com.metamatrix.platform.config.spi.xml.XMLConfigurationMgr;
import com.metamatrix.platform.service.api.exception.ServiceException;
import com.metamatrix.platform.service.controller.AbstractService;
import com.metamatrix.platform.util.ErrorMessageKeys;
@@ -95,24 +87,13 @@
public class ConfigurationServiceImpl extends AbstractService implements ConfigurationServiceInterface {
- /**
- * The transaction mgr for ManagedConnections.
- */
- private TransactionMgr transMgr;
-
-// private int sessionCount;
- private ActionHistory actionHistory = new ActionHistory();
-
- /**
+/**
* Flag denoting whether this service is closed and may not accept new work.
*/
// private boolean serviceIsClosed = false;
private static final String CONTEXT = LogCommonConstants.CTX_CONFIG;
- private static BasicConfigurationObjectEditor editor = new BasicConfigurationObjectEditor(false);
-
-
public ConfigurationServiceImpl() {
super();
}
@@ -121,29 +102,11 @@
// S E R V I C E - R E L A T E D M E T H O D S
// -----------------------------------------------------------------------------------
- public void initializeForTesting(Properties env) throws Exception {
- this.initService(env);
- }
-
/**
* Perform initialization and commence processing. This method is called only once.
*/
protected void initService(Properties env) throws Exception {
-
- try {
-
- if (env.getProperty(ConfigurationServicePropertyNames.CONNECTION_FACTORY) == null) {
- env.setProperty(ConfigurationServicePropertyNames.CONNECTION_FACTORY, ConfigurationServicePropertyNames.DEFAULT_CONNECTION_FACTORY_CLASS);
- }
- env.setProperty(TransactionMgr.FACTORY, env.getProperty(ConfigurationServicePropertyNames.CONNECTION_FACTORY));
-
- transMgr = new TransactionMgr(env, this.getInstanceName());
-
- I18nLogManager.logInfo(CONTEXT, LogMessageKeys.CONFIG_0002, new Object[] { getInstanceName()});
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e);
- }
+ I18nLogManager.logInfo(CONTEXT, LogMessageKeys.CONFIG_0002, new Object[] { getInstanceName()});
}
/**
@@ -199,34 +162,13 @@
}
/**
- * Baselines the realtime portion of the current (operational) configuration into the
- * next-startup configuration.
- * @param principalName the name of the principal that is requesting the
- * baselining
- */
- public void baselineCurrentConfiguration(String principalName) throws ConfigurationException {
- throw new UnsupportedOperationException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0039));
-
- }
-
- /**
- * Returns the ID of the startup <code>Configuration</code>, which should reflect
- * the desired runtime state of the system.
- * @return ID of startup configuration
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- public ConfigurationID getStartupConfigurationID() throws ConfigurationException {
- return this.getDesignatedConfigurationID(SystemConfigurationNames.STARTUP);
- }
-
- /**
* Returns the operational <code>Configuration</code>, which should reflect
* the desired runtime state of the system.
* @return Configuration that is currently in use
* @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
*/
public Configuration getCurrentConfiguration() throws ConfigurationException {
- return this.getDesignatedConfiguration(SystemConfigurationNames.NEXT_STARTUP);
+ return this.getDesignatedConfiguration(Configuration.NEXT_STARTUP);
}
/**
@@ -236,56 +178,30 @@
* @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
*/
public Configuration getNextStartupConfiguration() throws ConfigurationException{
- return this.getDesignatedConfiguration(SystemConfigurationNames.NEXT_STARTUP);
+ return this.getDesignatedConfiguration(Configuration.NEXT_STARTUP);
}
- /**
- * Returns the startup <code>Configuration</code>, the Configuration
- * that the system booted up with.
- * @return Configuration that the system booted up with.
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- public Configuration getStartupConfiguration() throws ConfigurationException{
- return this.getDesignatedConfiguration(SystemConfigurationNames.STARTUP);
- }
-
private Configuration getDesignatedConfiguration(String designation) throws ConfigurationException {
// Look in the cache ...
Configuration config = null;
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
+ XMLConfigurationConnector transaction = null;
+ transaction = getConnection(null);
config = transaction.getDesignatedConfiguration(designation);
if (config != null) {
LogManager.logDetail(CONTEXT, "Found " + designation + " configuration " + config.getName()); //$NON-NLS-1$ //$NON-NLS-2$
} else {
- LogManager.logDetail(CONTEXT, "No " + designation + " configuration found "); //$NON-NLS-1$ //$NON-NLS-2$
throw new ConfigurationException("No " + designation + " configuration was found"); //$NON-NLS-1$ //$NON-NLS-2$
}
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0040, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0040, designation));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
-
return config;
}
private ConfigurationID getDesignatedConfigurationID(String designation) throws ConfigurationException {
ConfigurationID configID = null;
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
+ XMLConfigurationConnector transaction = null;
+ transaction = getConnection(null);
configID = transaction.getDesignatedConfigurationID(designation);
if (configID != null) {
@@ -293,19 +209,6 @@
} else {
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0042, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0042));
}
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0042, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0042));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
return configID;
}
@@ -313,66 +216,22 @@
// Look in the cache ...
ConfigurationModelContainer config = null;
- ConfigurationTransaction transaction = null;
+ XMLConfigurationConnector transaction = null;
try {
- transaction = getReadTransaction();
+ transaction = getConnection(null);
config = transaction.getConfigurationModel(configName);
- if (config != null) {
- } else {
+ if (config == null) {
LogManager.logTrace(CONTEXT, "No configuration model found"); //$NON-NLS-1$
}
}catch ( Exception e ) {
throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0043, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0043));
- }finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
}
return config;
}
- public Configuration getConfiguration(String configName) throws InvalidConfigurationException, ConfigurationException {
- if ( configName == null) {
- throw new IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045, "configName")); //$NON-NLS-1$
- }
-
- // Look in the cache ...
- Configuration config = null;
-
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
- config = transaction.getConfiguration(configName);
-
- if (config != null) {
- LogManager.logDetail(CONTEXT, "Found current configuration " + configName); //$NON-NLS-1$
- } else {
- LogManager.logTrace(CONTEXT, "No current configuration found for " + configName); //$NON-NLS-1$
- }
-
- }catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0044, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0044, configName));
- }finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
- return config;
- }
-
/**
* <p>Returns a Collection containing the Configuration object for the specified
* ConfigurationID id, and also any dependant objects needed to fully
@@ -429,89 +288,21 @@
// Look in the cache ...
Collection result = null;
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
+ XMLConfigurationConnector transaction = null;
+ transaction = getConnection(null);
result = transaction.getAllObjectsForConfigurationModel(configID);
return result;
-
- }catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0046, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0046, configID));
- }finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
-
-// throw new ConfigurationException("Unable to find the configuration and dependent objects from " + configID);
}
- /**
- * <p>This method will return a Collection of objects that represent the
- * set of global configuration objects currently represented in the
- * configuration database. This method will generally be used when
- * attempting to import a configuration into the database as the 'Next Startup'
- * configuration. This information is important when importing a new configuration
- * so that any global type configuration objects that are to be imported can
- * be resolved against the global objects that currently exist in the
- * database.</p>
- *
- * <pre>
- * The Collection of objects will contain the following configuration
- * object types:
- *
- * ComponentTypes
- * ProductTypes
- * Hosts
- * </pre>
- *
- * @return a Collection of all of the global configuration objects as they
- * exist in the database.
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @throws InvalidSessionException if there is not a valid administrative session
- * @throws AuthorizationException if the administrator does not have privileges to use this method
- * @throws MetaMatrixComponentException if a general remote system problem occurred
- */
- public Collection getAllGlobalConfigObjects()
- throws ConfigurationException{
- Collection allObjects = new ArrayList();
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
- allObjects.addAll(transaction.getAllComponentTypes(true));
- allObjects.addAll(transaction.getProductTypes(true));
- allObjects.addAll(transaction.getHosts());
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0047, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0047));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
- return allObjects;
-
-
- }
public ComponentType getComponentType(ComponentTypeID id) throws ConfigurationException {
if ( id == null) {
throw new IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045, "id")); //$NON-NLS-1$
}
ComponentType type = null;
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
+ XMLConfigurationConnector transaction = null;
+ transaction = getConnection(null);
type = transaction.getComponentType(id);
if (type != null) {
@@ -519,28 +310,14 @@
} else {
LogManager.logDetail(CONTEXT, "No component type found for " + id); //$NON-NLS-1$
}
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0048, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0048, "id")); //$NON-NLS-1$
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
return type;
}
public Collection getAllComponentTypes(boolean includeDeprecated) throws ConfigurationException {
- ConfigurationTransaction transaction = null;
+ XMLConfigurationConnector transaction = null;
Collection result = new LinkedList();
- try {
- transaction = getReadTransaction();
+ transaction = getConnection(null);
result = transaction.getAllComponentTypes(includeDeprecated);
if (result != null && result.size() > 0) {
@@ -549,58 +326,14 @@
} else {
throw new ConfigurationException(ErrorMessageKeys.CONFIG_0049, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0049));
}
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0049, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0049));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
return result;
}
- public Collection getMonitoredComponentTypes(boolean includeDeprecated) throws ConfigurationException {
- ConfigurationTransaction transaction = null;
- Collection result = null;
- try {
- transaction = getReadTransaction();
- result = transaction.getMonitoredComponentTypes(includeDeprecated);
-
- if (result != null && result.size() > 0) {
- LogManager.logDetail(CONTEXT, "Found monitored component types"); //$NON-NLS-1$
-
- } else {
- LogManager.logTrace(CONTEXT, "No monitored component types found"); //$NON-NLS-1$
- result = new ArrayList(1);
- }
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0050, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0050));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
- return result;
- }
-
public Collection getComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException {
- ConfigurationTransaction transaction = null;
+ XMLConfigurationConnector transaction = null;
Collection result=null;
- try {
- transaction = getReadTransaction();
+ transaction = getConnection(null);
result = transaction.getComponentTypeDefinitions(componentTypeID);
if (result != null && result.size() > 0) {
@@ -610,19 +343,6 @@
LogManager.logTrace(CONTEXT, new Object[] {"Couldn't find component type definitions for ", componentTypeID} ); //$NON-NLS-1$
}
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0051, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0051, componentTypeID));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
-
if (result == null) {
result = new ArrayList(1);
}
@@ -632,95 +352,14 @@
}
- public Map getComponentTypeDefinitions(Collection componentIDs) throws ConfigurationException {
- Map map = new HashMap();
- Collection defns;
- BaseID id = null ;
- ComponentType type;
- Iterator it = componentIDs.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof ComponentTypeID) {
- id = (ComponentTypeID) obj;
- } else if (obj instanceof ComponentType) {
- type = (ComponentType) obj;
- id = type.getID();
- } else {
- continue;
- }
-
- defns = getComponentTypeDefinitions( (ComponentTypeID) id);
- map.put(id, defns);
- }
-
- return map;
+ private Collection getDependentComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException {
+ XMLConfigurationConnector transaction = getConnection(null);
+ Collection defns = getDependentComponentTypeDefinitions(transaction, componentTypeID);
+ return defns;
}
- public Map getDependentComponentTypeDefinitions(Collection componentIDs) throws ConfigurationException {
- ConfigurationTransaction transaction = null;
- Map map = new HashMap(componentIDs.size());
- BaseID id = null;
- ComponentType type;
+ private Collection getDependentComponentTypeDefinitions(XMLConfigurationConnector transaction, ComponentTypeID componentTypeID) throws ConfigurationException {
- try {
- transaction = getReadTransaction();
- Iterator it = componentIDs.iterator();
- while (it.hasNext()) {
-
- Object obj = it.next();
- if (obj instanceof ComponentTypeID) {
- id = (ComponentTypeID) obj;
- } else if (obj instanceof ComponentType) {
- type = (ComponentType) obj;
- id = type.getID();
- } else {
- continue;
- }
-
- Collection defns = getDependentComponentTypeDefinitions(transaction, (ComponentTypeID) id);
- map.put(id, defns);
- }
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0052, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0052));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
-
- return map;
-
- }
-
- public Collection getDependentComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException {
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
- Collection defns = getDependentComponentTypeDefinitions(transaction, componentTypeID);
- return defns;
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0052, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0052));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
- }
-
- private Collection getDependentComponentTypeDefinitions(ConfigurationTransaction transaction, ComponentTypeID componentTypeID) throws ConfigurationException {
-
Collection result=null;
Collection types = transaction.getAllComponentTypes(false);
@@ -757,7 +396,7 @@
private Collection getSuperComponentTypeDefinitions(Map defnMap, Collection defns,
Collection componentTypes,
ComponentTypeID componentTypeID,
- ConfigurationTransaction transaction) throws ConfigurationException {
+ XMLConfigurationConnector transaction) throws ConfigurationException {
if (defnMap == null) {
defnMap = new HashMap();
}
@@ -866,24 +505,10 @@
public Collection getHosts() throws ConfigurationException {
Collection hosts = null;
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
+ XMLConfigurationConnector transaction = null;
+ transaction = getConnection(null);
hosts = transaction.getHosts();
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0055, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0055));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
-
if (hosts == null) {
hosts = Collections.EMPTY_LIST;
}
@@ -892,48 +517,7 @@
}
- public Collection getComponentDefns(Collection componentDefnIDs, ConfigurationID configurationID)
- throws ConfigurationException {
-
-
- if (componentDefnIDs == null || componentDefnIDs.size() == 0) {
- return Collections.EMPTY_LIST;
- }
- Collection defns = new ArrayList(componentDefnIDs.size());
-
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
- ComponentDefnID id;
- ComponentDefn defn = null;
-
- for (Iterator it=componentDefnIDs.iterator(); it.hasNext(); ) {
- id = (ComponentDefnID) it.next();
- defn = transaction.getComponentDefinition(id, configurationID);
- if (defn != null) {
- defns.add(defn);
- }
- }
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0056, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0056));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0057, txne);
- }
- transaction = null;
- }
- }
-
- return defns;
-
- }
-
-
- /**
+ /**
* Returns a <code>ComponentDefn</code> for the specified <code>ComponentDefnID</code>.
* </br>
* @param configurationID is the configuration for which the component exist
@@ -943,27 +527,12 @@
*/
public ComponentDefn getComponentDefn(ConfigurationID configurationID, ComponentDefnID componentDefnID)
throws ConfigurationException{
- ConfigurationTransaction transaction = null;
+ XMLConfigurationConnector transaction = null;
ComponentDefn defn = null;
- try {
- transaction = getReadTransaction();
+ transaction = getConnection(null);
defn = transaction.getComponentDefinition(componentDefnID, configurationID);
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0058, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0058,componentDefnID.getName()));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0059, txne, new Object[] {componentDefnID.getName()});
- }
- transaction = null;
- }
- }
-
return defn;
}
@@ -979,59 +548,13 @@
*/
public Collection getResources()
throws ConfigurationException{
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
+ XMLConfigurationConnector transaction = null;
+ transaction = getConnection(null);
return transaction.getResources();
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0060, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0060));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0061, txne);
- }
- transaction = null;
- }
- }
-
}
/**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
- * that are of the specified resource type.
- * @param componentType that identifies the type of resources to be returned
- * @throws AuthorizationException if caller is not authorized to perform this method.
- * @throws InvalidSessionException if the <code>callerSessionID</code> is not valid or is expired.
- * @throws MetaMatrixComponentException if an error occurred in communicating with a component.
- */
- public Collection getResources(ComponentTypeID componentTypeID)
- throws ConfigurationException {
- ConfigurationTransaction transaction = null;
- try {
- transaction = getReadTransaction();
-
- return transaction.getResources(componentTypeID);
-
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0060, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0060));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0061, txne);
- }
- transaction = null;
- }
- }
-
- }
-
- /**
* Save the resource changes based on each {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
* in the collection.
* @param resourceDescriptors for the resources to be changed *
@@ -1041,36 +564,12 @@
*/
public void saveResources(Collection resourceDescriptors, String principalName)
throws ConfigurationException {
- ConfigurationTransaction transaction = null;
- boolean success = false;
- try {
+ XMLConfigurationConnector transaction = null;
+ transaction = this.getConnection(principalName);
- transaction = this.getWriteTransaction();
+ transaction.saveResources(resourceDescriptors, principalName);
- transaction.saveResources(resourceDescriptors, principalName);
-
- transaction.commit(); // commit the transaction
- success = true;
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e);
- } finally {
- if ( transaction != null ) {
- if (!success) {
- try {
- transaction.rollback(); // rollback the transaction
- } catch ( Exception e2 ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0063, e2);
- }
- }
-
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- }
- }
-
+ transaction.commit(); // commit the transaction
}
/**
@@ -1108,7 +607,7 @@
* communication with the Configuration Service.
*/
public Set executeTransaction(ActionDefinition action, String principalName)
- throws ModificationException, ConfigurationLockException, ConfigurationException{
+ throws ModificationException, ConfigurationException{
if ( action == null ) {
throw new IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045, "action")); //$NON-NLS-1$
}
@@ -1131,7 +630,7 @@
* @throws ConfigurationException if an error occurred within or during
* communication with the Configuration Service.
*/
- public Set executeTransaction(List actions, String principalName) throws ModificationException, ConfigurationLockException, ConfigurationException {
+ public Set executeTransaction(List actions, String principalName) throws ModificationException, ConfigurationException {
if ( actions == null ) {
throw new IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045, "actions")); //$NON-NLS-1$
}
@@ -1141,243 +640,24 @@
return result;
}
- ConfigurationTransaction transaction = null;
+ XMLConfigurationConnector transaction = null;
// Iterate through the actions, and apply all as a single transaction
try {
- transaction = this.getWriteTransaction();
- result = transaction.executeActions(actions,principalName);
+ transaction = this.getConnection(principalName);
+ result = transaction.executeActions(actions);
transaction.commit(); // commit the transaction
-
- // Add the actions to the history ...
- this.actionHistory.addActionsForTransaction(actions);
- } catch ( ConfigurationLockException e ) {
- try {
- if ( transaction != null ) {
- transaction.rollback(); // rollback the transaction
- }
- } catch ( Exception e2 ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0065, e,new Object[]{ principalName, printActions(actions)});
- }
- throw e;
} catch ( ConfigurationException e ) {
- // must increment by 1 because each actionList starts at zero
- //actionCounter += e.getActionIndex() + 1;
- //e.setActionIndex(actionCounter);
-
- try {
- if ( transaction != null ) {
- transaction.rollback(); // rollback the transaction
- }
- } catch ( Exception e2 ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0065, e,new Object[]{ principalName, printActions(actions)});
- }
throw e;
} catch ( Exception e ) {
- try {
- if ( transaction != null ) {
- transaction.rollback(); // rollback the transaction
- }
- } catch ( Exception e2 ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0065, e,new Object[]{ principalName, printActions(actions)});
- }
throw new ConfigurationException(e);
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
}
return result;
}
- /**
- * Execute a list of insert actions and for actions on objects of type component object, it will have its
- * configuration id resassigned, and optionally
- * return the set of objects or object IDs that were affected/modified by the action.
- * @param assignConfigurationID the configuration for which any action for a component object will
- * have its configurationID set to this.
- * @param actions the ordered list of actions that are to be performed on data within
- * the repository.
- * @param principalName of the person executing the transaction
- * @return the set of objects that were affected by this transaction.
- * @throws ModificationException if the target of any of the actions is invalid, or
- * if the target object is not a supported class of targets.
- * @throws IllegalArgumentException if the action is null
- * or if the result specification is invalid
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Metadata Service.
- */
- public Set executeInsertTransaction(ConfigurationID assignConfigurationID, List actions, String principalName)
- throws ModificationException, ConfigurationLockException, ConfigurationException {
- if ( actions == null ) {
- throw new IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045, "actions")); //$NON-NLS-1$
- }
- // Iterate through the actions, and set the ConfigurationID on the
- // arg if necessary
- ActionDefinition currentAction = null;
- Iterator iter = actions.iterator();
- Object argObj;
- boolean chk = false;
- while ( iter.hasNext() ) {
- currentAction = (ActionDefinition) iter.next();
- if ( currentAction instanceof CreateObject) {
- chk = true;
- } else if (currentAction instanceof AddObject) {
- chk = false;
- } else {
- throw new ModificationException(ErrorMessageKeys.CONFIG_0066, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0066));
- }
-
- // only CreateObjects have arguments
- if (chk && assignConfigurationID != null) {
- Object args[] = currentAction.getArguments();
- argObj = args[0];
- editor.assignConfigurationID(argObj,assignConfigurationID);
- }
- }
-
- //Pass this on through to the executeTransaction method
- return this.executeTransaction(actions, principalName);
- }
-
- /**
- * Undo the specified number of previously-committed transactions.
- * @param numberOfActions the number of actions in the history that are to be undone.
- * @return the set of objects that were affected by undoing these actions.
- * @throws IllegalArgumentException if the number is negative.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public Set undoActionsAsTransaction(int numberOfActions, String principalName) throws ConfigurationException {
- if ( numberOfActions < 0 ) {
- throw new IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0068, numberOfActions ));
- }
- LogManager.logDetail(CONTEXT, new Object[]{"Undoing ",new Integer(numberOfActions)," action(s)"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- Set result = null;
- synchronized( this.actionHistory ) {
- List actions = this.actionHistory.pop(numberOfActions);
- List undoActions = new ArrayList();
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
- undoActions.add( action.getUndoActionDefinition() );
- }
-
- try {
- result = this.executeTransaction(undoActions, principalName);
- I18nLogManager.logInfo(CONTEXT, LogMessageKeys.CONFIG_0004, new Object[]{new Integer(numberOfActions)});
- } catch ( ConfigurationException e ) {
- // put the actions back on the history ...
- this.actionHistory.addActionsForTransaction(actions);
- throw e;
- } catch ( ModificationException e ) {
- ConfigurationException me = new ConfigurationException(e,ErrorMessageKeys.CONFIG_0069, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0069));
- // put the actions back on the history ...
- this.actionHistory.addActionsForTransaction(actions);
- throw me;
- }
- }
- return result;
- }
-
- /**
- * Get the history of actions executed in transactions by this editor.
- * The actions at the front of the list will be those most recently executed.
- * @return the ordered list of actions in the history.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public List getHistory() throws ConfigurationException {
- return this.actionHistory.getHistory();
- }
-
-
- /**
- * Clear the history of all actions without undoing any of them.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public void clearHistory() throws ConfigurationException {
- this.actionHistory.clearHistory();
- }
-
-
- /**
- * Get the number of actions that are currently in the history.
- * @return the number of actions in the history.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public int getHistorySize() throws ConfigurationException {
- return this.actionHistory.getHistorySize();
- }
-
-
- /**
- * Set the limit on the number of actions in the history. Note that the
- * history may at times be greater than this limit, because when actions
- * are removed from the history, all actions for a transactions are
- * removed at the same time. If doing so would make the history size
- * smaller than the limit, no actions are removed.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public int getHistoryLimit() throws ConfigurationException {
- return this.actionHistory.getHistoryLimit();
- }
-
-
- /**
- * Set the limit on the number of actions in the history. Note that the
- * history may at times be greater than this limit, because when actions
- * are removed from the history, all actions for a transactions are
- * removed at the same time. If doing so would make the history size
- * smaller than the limit, no actions are removed.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public void setHistoryLimit(int maximumHistoryCount) throws ConfigurationException {
- this.actionHistory.setHistoryLimit(maximumHistoryCount);
- }
-
- /**
- * Return the time the server was started. If the state of the server is not "Started"
- * then a null is returned.
- *
- * @return Date Time server was started.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public Date getServerStartupTime() throws ConfigurationException {
- ConfigurationTransaction transaction = null;
- Date timestamp = null;
- try {
- transaction = getReadTransaction();
- timestamp = transaction.getServerStartupTime();
- } catch ( ManagedConnectionException e ) {
- throw new ConfigurationException(e, ErrorMessageKeys.CONFIG_0070, PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0070));
- } finally {
- if ( transaction != null ) {
- try {
- transaction.close();
- } catch ( Exception txne ) {
- I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
- }
- transaction = null;
- }
- }
- return timestamp;
- }
-
protected void addProperty(Properties source, String sourceName, Properties props, String propName) {
String value = source.getProperty(sourceName);
if (value != null) {
@@ -1392,89 +672,10 @@
// ----------------------------------------------------------------------------------------
- protected String printActions( List actions ) {
- StringBuffer sb = new StringBuffer();
- Iterator iter = actions.iterator();
- if ( iter.hasNext() ) {
- sb.append( iter.next().toString() );
- }
- while ( iter.hasNext() ) {
- sb.append("; "); //$NON-NLS-1$
- sb.append( iter.next().toString() );
- }
- return sb.toString();
+ protected XMLConfigurationConnector getConnection(String principal) throws ConfigurationException {
+ return XMLConfigurationMgr.getInstance().getTransaction(principal==null?this.getInstanceName():principal);
}
- protected ConfigurationTransaction getReadTransaction() throws ManagedConnectionException {
- return (ConfigurationTransaction) this.transMgr.getReadTransaction();
- }
-
- protected ConfigurationTransaction getWriteTransaction() throws ManagedConnectionException {
- return (ConfigurationTransaction) this.transMgr.getWriteTransaction();
- }
-
-
-
-
-// /**
-// * Return the list of allowable values for the specified type.
-// * @param type the allowable type
-// * @return the map of values (keys) and descriptions (values) for the specified type.
-// * @throws ConfigurationException if an error occurred within or during communication with this connection.
-// */
-// private List getAllowableValues( Integer type, boolean includeDeprecated ) throws ConfigurationException {
-// if ( this.serviceIsClosed ) {
-// throw new ConfigurationException("This ConfigurationService instance is closed and may not accept requests");
-// }
-//
-// Collection values = null;
-//
-// ConfigurationTransaction transaction = null;
-// try {
-// transaction = getReadTransaction();
-//// values = transaction.getAllowableValues(type);
-// } catch ( Exception e ) {
-// ConfigurationException e2 = new ConfigurationException(e,"Unable to find the allowable values");
-// LogManager.logError(CONTEXT, e2, "Error reading allowable values");
-// throw e2;
-// } finally {
-// if ( transaction != null ) {
-// try {
-// transaction.close();
-// } catch ( Exception txne ) {
-// I18nLogManager.logError(CONTEXT, ErrorMessageKeys.CONFIG_0041, txne);
-// }
-// transaction = null;
-// }
-// }
-//
-// List result = new LinkedList(values);
-// if ( !includeDeprecated ) {
-// Iterator iter = result.iterator();
-// while ( iter.hasNext() ) {
-// ComponentType cType = (ComponentType) iter.next();
-// if ( cType.isDeprecated() ) {
-// iter.remove();
-// }
-// }
-// }
-//
-// return result;
-// }
-
-
-// protected boolean isClosed() {
-// return this.serviceIsClosed;
-// }
-
-// protected SessionToken getSessionToken() {
-// return this.token;
-// }
-
- //
- // Configuration Admin Methods
- //
-
/**
* @see com.metamatrix.platform.config.api.service.ConfigurationServiceInterface#addHost(java.lang.String,
* java.util.Properties)
@@ -1750,7 +951,7 @@
public Object modify(ComponentObject theObject,
Properties theProperties,
- String principalName) throws ModificationException, ConfigurationLockException, ConfigurationException{
+ String principalName) throws ModificationException, ConfigurationException{
ConfigurationObjectEditor editor = null;
try {
editor = createEditor();
@@ -1974,34 +1175,6 @@
}
return results;
- }
-
-
- /**
- * @see com.metamatrix.platform.config.api.service.ConfigurationServiceInterface#checkPropertiesDecryptable(java.util.Properties, java.lang.String)
- * @since 4.3
- */
- public boolean checkPropertiesDecryptable(Properties props,
- String componentTypeIdentifier) throws ConfigurationException {
- Collection componentTypes = getAllComponentTypes(false);
-
- ComponentType actualType = null;
- for ( Iterator typeItr = componentTypes.iterator(); typeItr.hasNext(); ) {
- ComponentType aType = (ComponentType)typeItr.next();
- if (aType.getName().equals(componentTypeIdentifier)) {
- actualType = aType;
- break;
- }
- }
-
- if ( actualType == null ) {
- throw new ConfigurationException(PlatformPlugin.Util.getString("ConfigurationServiceImpl.ConnectorType_not_found", //$NON-NLS-1$
- new Object[] {componentTypeIdentifier}));
- }
-
- Collection maskedPropertyNames = actualType.getMaskedPropertyNames();
-
- return ComponentCryptoUtil.checkPropertiesDecryptable(props, maskedPropertyNames);
}
}
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/ConfigurationTransaction.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/ConfigurationTransaction.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/ConfigurationTransaction.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,402 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi;
-
-import java.util.*;
-
-import com.metamatrix.common.config.api.*;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.InvalidComponentException;
-import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
-import com.metamatrix.common.connection.ManagedConnectionException;
-import com.metamatrix.common.connection.TransactionInterface;
-
-public interface ConfigurationTransaction extends TransactionInterface {
-
- public static class ComponentTypeSearch {
-
- /* Identifies certain ComponentTypes as Deployable */
- public static final int DEPLOYABLE_COMPONENT_TYPE = 0;
- /* Identifies certain ComponentTypes as Monitored */
- public static final int MONITORED_COMPONENT_TYPE = 1;
-
- }
-
-
- /**
- * Make all changes made during this transaction's lifetime
- * and release any data source locks currently held by the associated Connection.
- * A transaction can be committed or rolled back any number of times throughout its lifetime,
- * and throughout its lifetime the transaction is guaranteed to have the same connection.
- * @throws ManagedConnectionException if an error occurred within or during communication with the associated connection.
- */
- void commit() throws ManagedConnectionException;
-
- /**
- * Drops all changes made during this transaction's lifetime
- * and release any data source locks currently held by the associated Connection.
- * Once this method is executed, the transaction (after rolling back) becomes invalid, and the connection
- * referenced by this transaction is returned to the pool.
- * <p>
- * Calling this method on a read-only transaction is unneccessary (and discouraged, since
- * the implementation does nothing in that case anyway).
- * @throws ManagedConnectionException if an error occurred within or during communication with the associated connection.
- */
- void rollback() throws ManagedConnectionException;
-
- // ------------------------------------------------------------------------------------
- // C O N F I G U R A T I O N I N F O R M A T I O N
- // ------------------------------------------------------------------------------------
-
- /**
- * Returns the current deployed <code>Configuration</code>. Note, this configuration
- * may not match the actual configuration the system is currently executing under due
- * to administrative task that can be done to tune the system. Those administrative
- * task <b>do not</b> change the actual <code>Configuration</code> stored in the
- * <code>ConfigurationService</code>.
- * @return Configuration that is currently in use
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @deprecated as of v 2.0 beta 1 use {@link #getDesignatedConfiguration}
- */
- Configuration getCurrentConfiguration() throws ConfigurationException;
-
- /**
- * Returns one of the well-known
- * {@link SystemConfigurationNames system configurations}, either
- * the
- * {@link SystemConfigurationNames#OPERATIONAL operational configuration},
- * the
- * {@link SystemConfigurationNames#NEXT_STARTUP next startup configuration},
- * or the
- * {@link SystemConfigurationNames#STARTUP startup configuration}. Use
- * {@link SystemConfigurationNames} to supply the String parameter.
- * @param designation String indicating which of the system configurations
- * is desired; use one of the {@link SystemConfigurationNames} constants
- * @return the desired Configuration
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- Configuration getDesignatedConfiguration(String designation) throws ConfigurationException;
-
- /**
- * Obtain a configuration that contains all its components and
- * the deployed components.
- * @param configurationName
- * @return the serializable Configuration instance
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Configuration getConfiguration(String configurationName) throws ConfigurationException;
-
-
- /**
- * Returns the configuration model that contains everything a server needs
- * to start.
- * param configName is the name of the configuration model to return
- * @return ConfigurationModelContainer
- */
- ConfigurationModelContainer getConfigurationModel(String configName) throws ConfigurationException;
-
-
- /**
- * Returns a <code>ComponentDefn</code> for the specified
- * <code>ComponentDefnID</code> and <code>ConfigurationID</code>.
- * If the configuration is null the parent name from the
- * componentID will be used.
- * </br>
- * The reason for allowing the configurationID to be optionally
- * specified is so that the same componentID can be used
- * to obtain a componentDefn from different configurations.
- * Otherwise, the requestor would have to create a new
- * of componetDefnID for each configuration.
- * <br>
- * @param componentDefnID contains all the ids for which componet defns to be returned
- * @param configurationID is the configuration from which the component defns are to
- * be derived; optional, nullalble
- * @return Collection of ComponentDefn objects
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- ComponentDefn getComponentDefinition(ComponentDefnID componentDefnID, ConfigurationID configurationID) throws ConfigurationException;
-
- /**
- * Obtain the list of component definition instances that makeup the configuration.
- * @return the list of Component instances
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Map getComponentDefinitions(ConfigurationID configurationID) throws ConfigurationException;
-
-
- /**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
- * for all resource pools defined to the system.
- * @param configurationID is the configuration from which the component defns are to
- * be derived
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Collection getConnectionPools(ConfigurationID configurationID) throws ConfigurationException;
-
- /**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
- * for all internal resources defined to the system. The internal resources are not managed with
- * the other configuration related information. They are not dictated based on which configuration
- * they will operate (i.e., next startup or operational);
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Collection getResources() throws ConfigurationException;
-
- /**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
- * that are of the specified resource type.
- * @param componentTypeID that identifies the type of resources to be returned
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Collection getResources(ComponentTypeID componentTypeID) throws ConfigurationException;
-
-
- /**
- * Save the resource changes based on each {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
- * in the collection.
- * @param resourceDescriptors for the resources to be changed *
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- void saveResources(Collection resourceDescriptors, String principalName) throws ConfigurationException;
-
-
- /**
- * Obtain the value for a specific property name
- * @param componentObjectID is the component for which the value is to be retrieved for
- * @param typeID is the type of the component the object represents
- * @param propertyName is the name of the property to obtain
- * @return the property value
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- String getComponentPropertyValue(ComponentObjectID componentObjectID, ComponentTypeID typeID, String propertyName) throws ConfigurationException;
-
- /**
- * Returns a Map of component type definitions for the <code>ComponentTypeID</code> specified,
- * keyed by the ComponentTypeDefnID
- * @param componentTypeID for the ComponentTypeID that has definitions defined.
- * @return Collection of component type difinitions
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Collection getComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException;
-
-
- /**
- * Obtain the list of deployed components that represent the configuration
- * when deployed.
- * @return the list of DeployedComponents
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- List getDeployedComponents(ConfigurationID configrationID) throws ConfigurationException;
-
- /**
- * Returns a <code>ComponentType</code> for the specified <code>ComponentTypeID</code>
- * @param id is for the requested component type.
- * @return ComponentType based on the id
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- ComponentType getComponentType(ComponentTypeID id) throws ConfigurationException;
-
- /**
- * Returns a <code>Map</code> of type <code>ComponentType</code> keyed by ComponentTypeID.
- * @param includeDeprecated true if class names that have been deprecated should be
- * included in the returned list, or false if only non-deprecated constants should be returned.
- * @return Collection of type <code>ComponentType</code>
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- *
- */
- Collection getAllComponentTypes(boolean includeDeprecated) throws ConfigurationException;
-
- /**
- * Returns a <code>Map</code> of type <code>ProductType</code> keyed by ProductTypeID.
- * @param includeDeprecated true if class names that have been deprecated should be
- * included in the returned list, or false if only non-deprecated constants should be returned.
- * @return Collection of type <code>ComponentType</code>
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @deprecated as of v 2.0 beta 1 use {@link #getDesignatedConfigurationID}
- *
- */
- Collection getProductTypes(boolean includeDeprecated) throws ConfigurationException;
-
- /**
- * Returns the current configurationID
- * @return ConfigurationID for the current configuration
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @deprecated as of v 2.0 beta 1 use {@link #getDesignatedConfigurationID}
- */
- ConfigurationID getCurrentConfigurationID() throws ConfigurationException;
-
- /**
- * Returns the ID of one of the well-known
- * {@link SystemConfigurationNames system configurations}, either
- * the
- * {@link SystemConfigurationNames#OPERATIONAL operational configuration},
- * the
- * {@link SystemConfigurationNames#NEXT_STARTUP next startup configuration},
- * or the
- * {@link SystemConfigurationNames#STARTUP startup configuration}. Use
- * {@link SystemConfigurationNames} to supply the String parameter.
- * @param designation String indicating which of the system configurations
- * is desired; use one of the {@link SystemConfigurationNames} constants
- * @return the desired Configuration
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- ConfigurationID getDesignatedConfigurationID(String designation) throws ConfigurationException;
-
- /**
- * Returns a <code>Map</code> of type <code>ComponentType</code> keyed by ComponentTypeID
- * that are flagged as being monitored. A component of this type is considered
- * to be available for monitoring statistics.
- * @param includeDeprecated true if class names that have been deprecated should be
- * included in the returned list, or false if only non-deprecated constants should be returned.
- * @return Collection of type <code>ComponentType</code> keyed by ComponentTypeID
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Collection getMonitoredComponentTypes(boolean includeDeprecated) throws ConfigurationException;
-
- /**
- * Obtain the list of registered host
- * @return Collection of Hosts
- * @throws ConfigurationException if an error occurred within or during communication with the Metadata Service.
- */
- Collection getHosts() throws ConfigurationException;
-
- /**
- * Return the time the server was started. If the state of the server is not "Started"
- * then a null is returned.
- *
- * @return Date Time server was started.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- Date getServerStartupTime() throws ConfigurationException;
-
-
- /**
- * <p>Returns a Collection containing the Configuration object for the specified
- * ConfigurationID id, and also any dependant objects needed to fully
- * define this configuration, such as Host objects, ComponentType
- * objects, and ComponentTypeDefn objects.</p>
- *
- * <p>A Configuration instance contains all of the
- * <code>ComponentDefn</code> objects that "belong" to just that
- * Configuration model: VM component definitions, service
- * component definitions, product service configurations, and
- * deployed components. Objects such as Host objects,
- * ComponentType objects, ComponentTypeDefn, Resources, and
- * ConnectorBinding objects describe or support
- * ComponentDefns, but are not contained by a Configuration. Therefore,
- * they are included in this Collection for convenience.</p>
- *
- * <p>The Collection will contain instances of
- * {@link com.metamatrix.common.namedobject.BaseObject}.
- * Specifically, this Map should contain the objects for:
- * one configuration object, one or more Host objects, one or more
- * ComponentType objects, and one or more ComponentTypeDefn objects.</p>
- *
- * <p>This method is intended to facilitate exporting a configuration
- * to XML.</p>
- *
- * <p>Here is what the Collection would contain at runtime:
- * <pre>
- * Configuration instance
- * Host instance1
- * Host instance2
- * ...
- * ConnectorBinding instance1
- * ConnectorBinding instance2
- * ...
- * SharedResource intance1
- * SharedResource instance
- * ...
- * ComponentType instance1
- * ComponentType instance2
- * ...
- * ComponentTypeDefn instance1
- * ComponentTypeDefn instance2
- * </pre></p>
- *
- * @param configID ID Of a Configuration
- * @return Collection of BaseObject instances
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
-
- Collection getAllObjectsForConfigurationModel(ConfigurationID configID) throws ConfigurationException;
-
- /**
- * Returns a boolean indicating if the configuration already exist or not.
- * @param configurationName the identifier of the configuration
- * @return boolean of false if the configuration is found
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- public boolean doesConfigurationExist( String configurationName )
- throws ConfigurationException;
-
-
- // ----------------------------------------------------------------------------------------
- // C O N F I G U R A T I O N U P D A T E M E T H O D S
- // ----------------------------------------------------------------------------------------
-
- /**
- * Execute the specified actions.
- * @param List of actions to be performed
- * @param principalName the name of the principal that is requesting the lock
- * @return the set of BaseID objects denoting which objects were affected
- * by these actions
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- Set executeActions( List actions, String principalName ) throws InvalidComponentException, ConfigurationException;
-
- /**
- * Execute the specified actions.
- * @param doAdjust boolean to turn ConnectorBinding adjustments on/off
- * @param List of actions to be performed
- * @param principalName the name of the principal that is requesting the lock
- * @return the set of BaseID objects denoting which objects were affected
- * by these actions
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- // Set executeActions( boolean doAdjust, List actions, String principalName ) throws InvalidComponentException, ConfigurationException;
-
- /**
- * Overwrite the specified configuration by copying another configuration
- * over it. This includes assigning any
- * {@link #getDesignatedConfiguration designations}
- * of the configuration to be overwritten to the configuration to
- * be copied. Both configurations must already be in the data source.
- * (This method is needed to implement baselining).
- * @param configToCopy the ConfigurationID of the Configuration to be
- * copied
- * @param configToCopy the ConfigurationID of the Configuration to be
- * deleted - the "configToCopy" will be overwritten in its place.
- * @param principalName the name of the principal that is requesting the
- * modification
- * @return the new ID of the newly-copied Configuration
- * @throws InvalidConfigurationException if either ConfigurationID is invalid.
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- ConfigurationID overwriteConfiguration(ConfigurationID configToCopy, ConfigurationID configToOverwrite, String principalName) throws InvalidConfigurationException, ConfigurationException;
-
-}
-
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/SystemConfigurationNames.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/SystemConfigurationNames.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/SystemConfigurationNames.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi;
-
-import com.metamatrix.common.config.api.Configuration;
-
-/**
- * <p>This interface has the labels of the three well-known system
- * configurations:
- * <ol>
- * <li> The {@link #OPERATIONAL} config
- * <li> The {@link #NEXT_STARTUP} config
- * <li> The {@link #STARTUP} config
- * </ol>
- * These three labels can be used by an service provider to designate
- * any stored configurations as one of the three.
- * </p>
- */
-public interface SystemConfigurationNames {
-
- /**
- * The name of the Operational system configuration, which models
- * the desired runtime state of the system
- */
-// public static final String OPERATIONAL = Configuration.OPERATIONAL;
-
- /**
- * The name of the Next Startup system configuration, which is a model
- * of how the system should next start up
- */
- public static final String NEXT_STARTUP = Configuration.NEXT_STARTUP;
-
- /**
- * The name of the Next Startup system configuration, which is a model
- * of how the system started up
- */
- public static final String STARTUP = Configuration.STARTUP;
-
-}
-
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransaction.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransaction.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransaction.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,236 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import com.metamatrix.common.id.TransactionID;
-import com.metamatrix.common.transaction.TransactionException;
-import com.metamatrix.common.transaction.TransactionStatus;
-import com.metamatrix.platform.config.ConfigMessages;
-import com.metamatrix.platform.config.ConfigPlugin;
-
-public class ConfigTransaction {
-
-
-
-// codes 0 - 2 for Server states
- public static final int SERVER_INITIALIZATION = 1;
- public static final int SERVER_SHUTDOWN = 2;
- public static final int SERVER_FORCE_INITIALIZATION = 3;
- public static final int SERVER_STARTED = 4;
-
- public static final int NO_SERVER_INITIALIZATION_ACTION = -1;
-
-// codes 10 and above for other states
-
-// private static final int DEFAULT_NO_DEFINED_ACTION = -1;
-
-// private static final String NON_TRANSACTION_ACQUIRED_BY = "ReadTransaction";
-
- private TransactionID txnID;
- private int status;
- private long beginTime;
-// private long timeout; // 2 seconds
- private boolean isReadOnly;
- private String principal;
-
- private Map configurationObjects = new HashMap(3);
-
- // @see StartupStateController for states
- private int action = NO_SERVER_INITIALIZATION_ACTION;
-
- protected ConfigTransaction(TransactionID txnID, long defaultTimeoutSeconds) {
- this.txnID = txnID;
- this.status = TransactionStatus.STATUS_ACTIVE; //???
-// this.timeout = defaultTimeoutSeconds;
- this.isReadOnly = true;
- this.beginTime = System.currentTimeMillis();
- }
-
- /**
- * Obtain the status of the transaction associated with this object.
- * @return The transaction status.
- * @throws TransactionException if the status for this transaction could
- * not be obtained.
- */
- public int getStatus() {
- return this.status;
- }
-
- public long getBeginTime() {
- return beginTime;
- }
-
- /**
- * This method is implemented by this class so that the
- * actual lock can be obtained prior to the transaction beginning.
- */
- public void begin(String principal, int reason, boolean readOnly) throws TransactionException{
- setReadOnly(readOnly);
- this.principal = principal;
- }
-
- /**
- * Returns the name that holds the lock.
- * @return String name who holds the lock
- */
- public String getLockAcquiredBy() {
- return principal;
- }
-
-
- /**
- * Returns the transaction id that uniquely identifies this transaction
- * @return TransactionID that identifies the transaction
- */
- public TransactionID getTransactionID() {
- return this.txnID;
- }
-
-
- public boolean isReadOnly() {
- return this.isReadOnly;
- }
-
- public int getAction() {
- return this.action;
- }
-
- public void setAction(int actionPerformed) {
- // only allow the setting of the action once for the duration of the transaction
- if (action == NO_SERVER_INITIALIZATION_ACTION) {
- this.action = actionPerformed;
- }
- }
-
- /**
- * Call to set the transaction as read only.
- * A value of <code>true</code> will indicate the transaction
- * is a read only transaction.
- * @param readTxn value of true sets the transaction to read only
- */
- void setReadOnly( boolean readTxn ) {
- this.isReadOnly = readTxn;
- }
-
- /**
- * Modify the transaction such that the only possible outcome of the transaction
- * is to roll back the transaction.
- * @throws TransactionException if the rollback flag is unable to be set
- * for this transaction.
- */
- public void setRollbackOnly() throws TransactionException{
- this.status = TransactionStatus.STATUS_MARKED_ROLLBACK;
- }
-
-
-
- /**
- * Complete the transaction represented by this TransactionObject.
- * @throws TransactionException if the transaction is unable to commit.
- */
- public void commit() throws TransactionException{
- if ( this.status == TransactionStatus.STATUS_MARKED_ROLLBACK ) {
- throw new TransactionException(ConfigMessages.CONFIG_0160, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0160));
- }
- if ( this.status != TransactionStatus.STATUS_ACTIVE ) {
- throw new TransactionException(ConfigMessages.CONFIG_0161, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0161));
- }
- this.status = TransactionStatus.STATUS_COMMITTING;
-
- if ( isReadOnly() ) {
- this.status = TransactionStatus.STATUS_COMMITTED;
- return;
- }
-
- this.status = TransactionStatus.STATUS_COMMITTED;
- }
-
- /**
- * Roll back the transaction represented by this TransactionObject.
- * @throws TransactionException if the transaction is unable to roll back.
- */
- public void rollback() throws TransactionException{
- if ( isReadOnly() ) {
- return;
- }
-
- this.status = TransactionStatus.STATUS_ROLLEDBACK;
-/*
- ToolkitLog.logCritical(ToolkitLogConstants.CTX_TXN,"*******************************************");
- ToolkitLog.logCritical(ToolkitLogConstants.CTX_TXN,"ToolkitTransaction.rollback not implemented");
- ToolkitLog.logCritical(ToolkitLogConstants.CTX_TXN,"*******************************************");
- ToolkitLog.logTrace(ToolkitLogConstants.CTX_TXN,"END ToolkitTransaction.rollback()");
-*/
- }
-
-
- /**
- * Returns the objects that changed during this transaction
- */
- public Collection getObjects() {
- Collection objs = new ArrayList();
-
- Iterator it = configurationObjects.keySet().iterator();
- while (it.hasNext()) {
- Object key = it.next();
- objs.add(configurationObjects.get(key));
- }
-
- return objs;
-
- }
-
- /**
- * Call to add an object to the set of objects that changed during this
- * transaction.
- * For the configuration process, this object will be
- * @see {ConfigurationModelContainer Configuration}
- * @param key is the id of the configuration
- * @param value is the configuration container
- */
- public void addObjects(Object key, Object value) {
- configurationObjects.put(key, value);
-
- }
-
- /**
- * Returns the objects that changed during this transaction. For
- * the configuration process, these objects will be
- * @see {ConfigurationModelContainer Configurations}.
- * @return Collection of objects that changed during the transaction.
- */
- public Object getObject(Object key) {
- return configurationObjects.get(key);
- }
-
- public boolean contains(Object key) {
- return configurationObjects.containsKey(key);
- }
-
-}
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransactionException.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransactionException.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransactionException.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -26,7 +26,7 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import com.metamatrix.common.transaction.TransactionException;
+import com.metamatrix.common.config.api.exceptions.ConfigurationException;
/**
* Date Oct 10, 2002
@@ -36,17 +36,11 @@
* executed because of an error with the transaction.
*/
-public class ConfigTransactionException extends TransactionException {
+public class ConfigTransactionException extends ConfigurationException {
//the transState indicates the state of the transaction
private String transState = ""; //$NON-NLS-1$
- public static final String TRANS_ALREADY_LOCKED = "TRANS_ALREADY_LOCKED"; //$NON-NLS-1$
-
- public static final String TRANS_NOT_LOCKED_BY_SAME_USER = "TRANS_NOT_LOCKED_BY_SAME_USER"; //$NON-NLS-1$
-
- public static final String TRANS_PROCESSING_ERROR = "TRANS_PROCESSING_ERROR"; //$NON-NLS-1$
-
public void setTransactionState(String code) {
this.transState = code;
}
@@ -56,22 +50,6 @@
}
/**
- * No-arg CTOR
- */
- public ConfigTransactionException( ) {
- super( );
- }
-
- /**
- * Construct an instance with the message specified.
- *
- * @param message A message describing the exception
- */
- public ConfigTransactionException( String message ) {
- super( message );
- }
-
- /**
* Construct an instance with the message and error code specified.
*
* @param message A message describing the exception
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigUserTransaction.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigUserTransaction.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigUserTransaction.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,130 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import com.metamatrix.common.id.TransactionID;
-import com.metamatrix.common.transaction.TransactionException;
-import com.metamatrix.common.transaction.TransactionStatus;
-import com.metamatrix.core.id.ObjectIDFactory;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.platform.config.ConfigMessages;
-import com.metamatrix.platform.config.ConfigPlugin;
-
-public class ConfigUserTransaction {
-
- private static final int DEFAULT_TIMEOUT = 300000; // 5 mins
-
- public static final int LOCK_SERVER_STARTING = 1;
- public static final int LOCK_CONFIG_CHANGING = 2;
-
- /** The underlying "real" transaction to which this user transaction is bound */
- private ConfigTransaction txn;
-
- /** Used to track the status when this user transaction is not bound to an underlying transaction */
- private int status;
-
- private boolean readTxn;
-
- private boolean alreadyBegun;
-// private ConfigTransactionLockFactory configLockFactory;
- private String name;
-
- private ObjectIDFactory idFactory;
-
- ConfigUserTransaction(boolean isReadOnly, ObjectIDFactory idFactory, String name ) {
- ArgCheck.isNotNull(idFactory);
- this.readTxn = isReadOnly;
- this.status = TransactionStatus.STATUS_UNKNOWN;
- this.idFactory = idFactory;
- this.name = name;
-// this.configLockFactory = null;
-
-
- }
-
- public void begin() throws TransactionException {
- if ( alreadyBegun ) {
- throw new IllegalStateException("already begun"); //$NON-NLS-1$
- }
- if ( this.status != TransactionStatus.STATUS_UNKNOWN ) {
- throw new TransactionException(ConfigMessages.CONFIG_0073, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0073));
- }
-
- TransactionID id = null;
- synchronized (idFactory) {
- id = (TransactionID) this.idFactory.create();
- }
- this.txn = new XMLConfigurationTransaction(XMLConfigurationMgr.getInstance(), id, DEFAULT_TIMEOUT);
- this.txn.begin(name, LOCK_CONFIG_CHANGING, this.readTxn);
-
-// this needs to be last so that it officially has been begun until this step has completed
-// also, its so commit cannot be called until the begin has completed.
- this.alreadyBegun = true;
-
-//System.out.println("<CFG USER TRANS>ENDED BEGIN TRANS");
-
- }
- public void commit() throws TransactionException {
- if ( ! alreadyBegun ) {
- throw new TransactionException(ConfigMessages.CONFIG_0075, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075));
- }
- if ( this.txn == null ) {
- throw new TransactionException(ConfigMessages.CONFIG_0076, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0076));
- }
-
- try {
- this.txn.commit();
- } finally {
- // Get status so we always have it
- this.status = this.txn.getStatus();
- this.txn = null; // we're done with the underlying transaction
- }
- }
-
- public void rollback() throws TransactionException {
- if ( ! alreadyBegun ) {
- return; // there's nothing to do, 'cause this was likely caused after 'begin' failed
- }
- if ( this.txn == null ) {
- throw new TransactionException(ConfigMessages.CONFIG_0076, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0076));
- }
- try {
- this.txn.rollback();
- } finally {
- // Get status so we always have it
- this.status = this.txn.getStatus();
- this.txn = null; // we're done with the underlying transaction
- }
- }
-
- public boolean isReadTransaction() {
- return readTxn;
- }
-
-
- public ConfigTransaction getTransaction() {
- return txn;
- }
-
-}
-
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigUserTransactionFactory.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigUserTransactionFactory.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigUserTransactionFactory.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import com.metamatrix.common.id.TransactionIDFactory;
-import com.metamatrix.common.transaction.TransactionException;
-import com.metamatrix.core.id.ObjectIDFactory;
-
-//implements UserTransactionFactory
-public class ConfigUserTransactionFactory {
- private ObjectIDFactory idFactory = new TransactionIDFactory();
-// private ConfigTransactionLockFactory configLockFactory;
-
- /**
- * Construct a factory that can be used to create read or write transactions.
- */
- public ConfigUserTransactionFactory() {
- }
-
-
- /**
- * Create a new instance of a UserTransaction that may be used to
- * read information. Read transactions do not have a source object
- * associated with them (since they never directly modify data).
- * @return the new transaction object
- */
- public ConfigUserTransaction createReadTransaction(String principal) throws TransactionException {
- return new ConfigUserTransaction( true, idFactory, principal);
- }
-
-
- /**
- * Create a new instance of a UserTransaction that may be used to
- * write and/or update information. The transaction will <i>not</i> have a source object
- * associated with it.
- * @param principal the name to be associated with this transaction
- * @return the new transaction object
- */
- public ConfigUserTransaction createWriteTransaction(String principal) throws TransactionException {
- return new ConfigUserTransaction( false, idFactory, principal);
-/*
- if (this.configLockFactory != null) {
-
- }
- throw new ConfigTransactionException("ConfigUserTransactionFactory was not instantiated to all the creation of write transactions.");
- */
- }
-
-}
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -111,7 +111,7 @@
}
- public Set executeActionsOnTarget(Object target, List actions, ConfigTransaction transaction )
+ public Set executeActionsOnTarget(Object target, List actions, XMLConfigurationConnector transaction )
throws ConfigTransactionException, ConfigurationException {
// System.out.println("STRATEGY: Start Execute on Target " + target + " of type " + target.getClass().getName());
@@ -306,7 +306,7 @@
return affectedIDs;
}
- private ConfigurationModelContainerImpl getConfigModel(BaseID id, ConfigTransaction transaction) throws ConfigurationException {
+ private ConfigurationModelContainerImpl getConfigModel(BaseID id, XMLConfigurationConnector transaction) throws ConfigurationException {
String name;
if (id instanceof ConfigurationID) {
@@ -358,7 +358,7 @@
public Set executeActions(ConfigurationModelContainerImpl config,
AuthenticationProviderID targetID, List actions,
- ConfigTransaction transaction)
+ XMLConfigurationConnector transaction)
throws InvalidConfigurationException, ConfigurationException {
Set affectedIDs = new HashSet();
@@ -462,7 +462,7 @@
- public Set executeActions(ConfigurationModelContainerImpl config, DeployedComponentID targetID, List actions, ConfigTransaction transaction) throws InvalidDeployedComponentException, ConfigurationException{
+ public Set executeActions(ConfigurationModelContainerImpl config, DeployedComponentID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidDeployedComponentException, ConfigurationException{
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -556,7 +556,7 @@
}
- public Set executeActions(ConfigurationModelContainerImpl config, ProductServiceConfigID targetID, List actions, ConfigTransaction transaction) throws InvalidDeployedComponentException, ConfigurationException{
+ public Set executeActions(ConfigurationModelContainerImpl config, ProductServiceConfigID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidDeployedComponentException, ConfigurationException{
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -713,7 +713,7 @@
- public Set executeActions(ConfigurationModelContainerImpl config, ServiceComponentDefnID targetID, List actions, ConfigTransaction transaction) throws InvalidDeployedComponentException, ConfigurationException{
+ public Set executeActions(ConfigurationModelContainerImpl config, ServiceComponentDefnID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidDeployedComponentException, ConfigurationException{
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -867,7 +867,7 @@
}
- public Set executeActions( ConfigurationModelContainerImpl config, VMComponentDefnID targetID, List actions, ConfigTransaction transaction) throws InvalidDeployedComponentException, ConfigurationException{
+ public Set executeActions( ConfigurationModelContainerImpl config, VMComponentDefnID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidDeployedComponentException, ConfigurationException{
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -1010,7 +1010,7 @@
}
- public Set executeActions( ConfigurationModelContainerImpl config, ConnectorBindingID targetID, List actions, ConfigTransaction transaction) throws InvalidDeployedComponentException, ConfigurationException{
+ public Set executeActions( ConfigurationModelContainerImpl config, ConnectorBindingID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidDeployedComponentException, ConfigurationException{
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -1175,7 +1175,7 @@
- public Set executeActions( ConfigurationID targetID, List actions, ConfigTransaction transaction) throws InvalidConfigurationException, ConfigurationException{
+ public Set executeActions( ConfigurationID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidConfigurationException, ConfigurationException{
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -1299,7 +1299,7 @@
}
- public Set executeActions(ConfigurationModelContainerImpl config,ComponentTypeID targetID, List actions, ConfigTransaction transaction) throws InvalidConfigurationException, ConfigurationException {
+ public Set executeActions(ConfigurationModelContainerImpl config,ComponentTypeID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidConfigurationException, ConfigurationException {
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -1449,7 +1449,7 @@
}
- public Set executeActions(ConfigurationModelContainerImpl config, ComponentTypeDefnID targetID, List actions, ConfigTransaction transaction) throws InvalidConfigurationException, ConfigurationException {
+ public Set executeActions(ConfigurationModelContainerImpl config, ComponentTypeDefnID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidConfigurationException, ConfigurationException {
/**
* This method is used for the mass importing of a configuration, instead of
@@ -1547,7 +1547,7 @@
}
- public Set executeActions(ConfigurationModelContainerImpl config,PropDefnAllowedValueID targetID, List actions, ConfigTransaction transaction ) throws InvalidConfigurationException, ConfigurationException {
+ public Set executeActions(ConfigurationModelContainerImpl config,PropDefnAllowedValueID targetID, List actions, XMLConfigurationConnector transaction ) throws InvalidConfigurationException, ConfigurationException {
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -1563,7 +1563,7 @@
- public Set executeActions(ConfigurationModelContainerImpl config, HostID targetID, List actions, ConfigTransaction transaction) throws InvalidComponentException, ConfigurationException{
+ public Set executeActions(ConfigurationModelContainerImpl config, HostID targetID, List actions, XMLConfigurationConnector transaction) throws InvalidComponentException, ConfigurationException{
Set affectedIDs = new HashSet();
if ( actions.isEmpty() ) {
return affectedIDs;
@@ -1663,7 +1663,7 @@
* @param componentTypes is the configuration to be updated
*/
- public Set executeActions(ConfigurationModelContainerImpl config, SharedResourceID targetID, List actions, ConfigTransaction transaction )
+ public Set executeActions(ConfigurationModelContainerImpl config, SharedResourceID targetID, List actions, XMLConfigurationConnector transaction )
throws InvalidConfigurationException, ConfigurationException{
Set affectedIDs = new HashSet();
@@ -1764,7 +1764,7 @@
return affectedIDs;
}
- public void updateSharedResource(SharedResource resource, ConfigTransaction transaction) throws ConfigurationException{
+ public void updateSharedResource(SharedResource resource, XMLConfigurationConnector transaction) throws ConfigurationException{
Collection trans = transaction.getObjects();
for (Iterator it=trans.iterator(); it.hasNext(); ) {
@@ -1804,7 +1804,7 @@
* @param componentTypes is the configuration to be updated
*/
- public Set executeActions(ConfigurationModelContainerImpl config, ProductTypeID targetID, List actions, ConfigTransaction transaction )
+ public Set executeActions(ConfigurationModelContainerImpl config, ProductTypeID targetID, List actions, XMLConfigurationConnector transaction )
throws InvalidConfigurationException, ConfigurationException{
Set affectedIDs = new HashSet();
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnector.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnector.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnector.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -25,109 +25,105 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.metamatrix.common.actions.ActionDefinition;
+import com.metamatrix.common.actions.CreateObject;
+import com.metamatrix.common.actions.DestroyObject;
import com.metamatrix.common.config.api.ComponentDefn;
import com.metamatrix.common.config.api.ComponentDefnID;
-import com.metamatrix.common.config.api.ComponentObjectID;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeID;
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConfigurationInfo;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.config.api.DeployedComponentID;
-import com.metamatrix.common.config.api.ResourceDescriptor;
import com.metamatrix.common.config.api.SharedResource;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.config.api.exceptions.InvalidComponentException;
-import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
-import com.metamatrix.common.config.api.exceptions.InvalidNameException;
-import com.metamatrix.common.connection.BaseTransaction;
-import com.metamatrix.common.connection.ManagedConnection;
-import com.metamatrix.common.connection.ManagedConnectionException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.transaction.TransactionException;
import com.metamatrix.common.util.LogCommonConstants;
+import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.platform.config.ConfigMessages;
import com.metamatrix.platform.config.ConfigPlugin;
-import com.metamatrix.platform.config.spi.ConfigurationTransaction;
-import com.metamatrix.platform.config.spi.SystemConfigurationNames;
+/**
+ * Acts as a scoped unit of work configuration service layer.
+ */
+public class XMLConfigurationConnector {
-/*******************
- JDBCConfigurationTransaction is responsible for executing and managing
- transactions.
+ private String principal;
+ private XMLConfigurationMgr configurationMgr;
- History:
- 12/20/00 vhalbert - when adding/updating property values, the values
- will be trimmed. This is because the use
- of the value later is incorrect if the user
- does not trim. Thereforre, it is easier to do
- this trimming one time and in one location.
- @see addProperty() and updateProperty()
+ private Map configurationObjects = new HashMap(3);
+ private XMLActionUpdateStrategy updateStrategy = new XMLActionUpdateStrategy();
+
+ XMLConfigurationConnector(XMLConfigurationMgr configurationMgr, String principal) {
+ this.configurationMgr = configurationMgr;
+ this.principal = principal;
+ }
+
+ /**
+ * Returns the name that holds the lock.
+ * @return String name who holds the lock
+ */
+ public String getLockAcquiredBy() {
+ return principal;
+ }
-*/
+ /**
+ * Complete the transaction represented by this TransactionObject.
+ * @throws TransactionException if the transaction is unable to commit.
+ */
+ public void commit() throws ConfigTransactionException{
+ Collection<ConfigurationModelContainer> models = getObjects();
+ this.configurationObjects.clear();
+ configurationMgr.applyTransaction(models, this.principal);
+ }
-public class XMLConfigurationConnector extends BaseTransaction implements ConfigurationTransaction {
+ /**
+ * Returns the objects that changed during this transaction
+ */
+ public Collection getObjects() {
+ return new ArrayList(configurationObjects.values());
+ }
- private ConfigUserTransaction configUserTransaction=null;
-
-// private static final int INITIAL_TREE_PATH = -1;
-// private static final int PARENT_TREE_PATH = 1;
-// private static final int SUPER_TREE_PATH = 2;
-
- private XMLConfigurationReader reader = null;
- private XMLConfigurationWriter writer = null;
-
/**
- * Create a new instance of a transaction for a managed connection.
- * @param connection the connection that should be used and that was created using this
- * factory's <code>createConnection</code> method (thus the transaction subclass may cast to the
- * type created by the <code>createConnection</code> method.
- * @param readonly true if the transaction is to be readonly, or false otherwise
- * @throws ManagedConnectionException if there is an error creating the transaction.
+ * Call to add an object to the set of objects that changed during this
+ * transaction.
+ * For the configuration process, this object will be
+ * @see {ConfigurationModelContainer Configuration}
+ * @param key is the id of the configuration
+ * @param value is the configuration container
*/
- XMLConfigurationConnector( ManagedConnection connection, boolean readonly ) throws ManagedConnectionException {
- super(connection,readonly);
-/*
- try {
+ public void addObjects(Object key, Object value) {
+ configurationObjects.put(key, value);
+ }
- JDBCMgdResourceConnection jdbcManagedConnection = (JDBCMgdResourceConnection) connection;
- this.jdbcConnection = jdbcManagedConnection.getConnection();
+ /**
+ * Returns the objects that changed during this transaction. For
+ * the configuration process, these objects will be
+ * @see {ConfigurationModelContainer Configurations}.
+ * @return Collection of objects that changed during the transaction.
+ */
+ public Object getObject(Object key) {
+ return configurationObjects.get(key);
+ }
- } catch ( Exception e ) {
- throw new ManagedConnectionException("The connection is not the appropriate type (\"" + JDBCMgdResourceConnection.class.getName() + "\")");
- }
-*/
- }
// ------------------------------------------------------------------------------------
// C O N F I G U R A T I O N I N F O R M A T I O N
// ------------------------------------------------------------------------------------
/**
- * Returns the current deployed <code>Configuration</code>. Note, this configuration
- * may not match the actual configuration the system is currently executing under due
- * to administrative task that can be done to tune the system. Those administrative
- * task <b>do not</b> change the actual <code>Configuration</code> stored in the
- * <code>ConfigurationService</code>.
- * @return Configuration that is currently in use
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- * @deprecated as of v 2.0 beta 1 use {@link #getDesignatedConfiguration}
- */
- public Configuration getCurrentConfiguration() throws ConfigurationException {
- return getConfigurationReader().getDesignatedConfiguration(Configuration.NEXT_STARTUP_ID);
- }
-
- /**
* Returns one of the well-known
* {@link SystemConfigurationNames system configurations}, either
* the
@@ -144,47 +140,15 @@
* communication with the Configuration Service.
*/
public Configuration getDesignatedConfiguration(String designation) throws ConfigurationException{
- return getConfigurationReader().getDesignatedConfiguration(designation);
+ return getConfigurationModel(XMLConfigurationMgr.getDesignatedConfigurationID(designation)).getConfiguration();
}
- /**
- * Obtain a configuration that contains all its components and
- * the deployed components.
- * @param configurationName
- * @return the serializable Configuration instance
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- public Configuration getConfiguration(String configurationName) throws ConfigurationException{
- return getConfigurationReader().getDesignatedConfiguration(configurationName);
- }
-
public ConfigurationModelContainer getConfigurationModel(String configName) throws ConfigurationException {
- if (configName.equalsIgnoreCase(Configuration.STARTUP)) {
- return getConfigurationReader().getConfigurationModel(Configuration.STARTUP_ID);
- }
- return getConfigurationReader().getConfigurationModel(Configuration.NEXT_STARTUP_ID);
+ return getConfigurationModel(XMLConfigurationMgr.getDesignatedConfigurationID(configName));
}
- /**
- * Obtain the configuration info for the specified configuration and version.
- * @return the configuration info instance
- * @param configurationName
- * @throws InvalidNameException if the configuration does not exist
- * @throws ConfigurationException when an error occurred within or during communication with the Configuration Service.
- */
- public ConfigurationInfo getConfigurationInfo(String configurationName) throws InvalidNameException, ConfigurationException{
- throw new UnsupportedOperationException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0110, "getConfigurationInfo" )); //$NON-NLS-1$
- }
-
- /**
- * @deprecated as of v 2.0 beta 1 use {@link #getDesignatedConfigurationID}
- */
- public ConfigurationID getCurrentConfigurationID() throws ConfigurationException {
- return getConfigurationReader().getDesignatedConfigurationID(Configuration.NEXT_STARTUP);
- }
-
public ConfigurationID getDesignatedConfigurationID(String designation) throws ConfigurationException {
- return getConfigurationReader().getDesignatedConfigurationID(designation);
+ return XMLConfigurationMgr.getDesignatedConfigurationID(designation);
}
/**
@@ -193,16 +157,14 @@
* @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
*/
public Map getComponentDefinitions(ConfigurationID configurationID) throws ConfigurationException {
- return getConfigurationReader().getComponentDefinitions(configurationID);
- }
+ ConfigurationModelContainer config = getConfigurationModel(configurationID);
-/**
- * @deprecated 5.5.4
- */
- public Collection getConnectionPools(ConfigurationID configurationID) throws ConfigurationException {
- return getConfigurationReader().getConnectionPools(configurationID);
-
+ return config.getConfiguration().getComponentDefns();
}
+
+ public ConfigurationModelContainer getConfigurationModel(ConfigurationID configurationID) throws ConfigurationException {
+ return this.configurationMgr.getConfigurationModel(configurationID);
+ }
/**
* Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
@@ -212,52 +174,41 @@
* @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
*/
public Collection getResources() throws ConfigurationException {
- return getConfigurationReader().getResources();
+ ConfigurationModelContainer cmc = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
+ return cmc.getResources();
}
/**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
- * that are of the specified resource type.
- * @param componentType that identifies the type of resources to be returned
+ * Obtain the component definition
+ * @return the ComponentDefn
* @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
*/
- public Collection getResources(ComponentTypeID componentTypeID) throws ConfigurationException{
+ public ComponentDefn getComponentDefinition(ComponentDefnID targetID, ConfigurationID configurationID) throws ConfigurationException{
+ if (targetID == null) {
+ throw new ConfigurationException(ConfigMessages.CONFIG_0045,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045,"ComponentDefnID")); //$NON-NLS-1$
+ }
+ ComponentDefn defn = null;
- Collection resources = getResources();
- Collection resourcesForType = new ArrayList(resources.size());
-
- for (Iterator it = resources.iterator(); it.hasNext(); ) {
- ResourceDescriptor rd = (ResourceDescriptor) it.next();
- if (rd.getComponentTypeID().equals(componentTypeID)) {
- resourcesForType.add(rd);
- }
+ if (configurationID == null) {
+ configurationID = getDesignatedConfigurationID(targetID.getParentFullName());
}
- return resourcesForType;
+ ConfigurationModelContainer config = getConfigurationModel(configurationID);
+ defn = config.getConfiguration().getComponentDefn(targetID);
+ return defn;
}
- public String getComponentPropertyValue(ComponentObjectID componentObjectID, ComponentTypeID typeID, String propertyName) throws ConfigurationException {
- String value = getConfigurationReader().getComponentPropertyValue(componentObjectID, typeID, propertyName);
- return value;
- }
-
-
- /**
- * Obtain the component definition
- * @return the ComponentDefn
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- public ComponentDefn getComponentDefinition(ComponentDefnID componentID, ConfigurationID configurationID) throws ConfigurationException{
- return getConfigurationReader().getComponentDefinition(componentID, configurationID);
- }
-
-
public Collection getComponentTypeDefinitions(ComponentTypeID componentTypeID) throws ConfigurationException{
- return getConfigurationReader().getComponenTypeDefinitions(componentTypeID);
+ ConfigurationModelContainer config = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
+ ComponentType t = config.getComponentType(componentTypeID.getFullName());
+ if (t!= null) {
+ return t.getComponentTypeDefinitions();
+ }
+ return Collections.EMPTY_LIST;
}
@@ -268,278 +219,145 @@
* @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
*/
public List getDeployedComponents(ConfigurationID configurationID) throws ConfigurationException{
- return getConfigurationReader().getDeployedComponents(configurationID);
- }
+ ConfigurationModelContainer config = getConfigurationModel(configurationID);
- /**
- * Obtain the deployed component
- * @return the DeployedComponent
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- public DeployedComponent getDeployedComponent(DeployedComponentID deployedComponentID) throws ConfigurationException{
- throw new UnsupportedOperationException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0110, "getDeployedComponent" )); //$NON-NLS-1$
+
+ Collection dcs = config.getConfiguration().getDeployedComponents();
+ List result = new LinkedList();
+ result.addAll(dcs);
+ return result;
}
-
/**
* Obtain the list of registered host
* @return Collection of Hosts
* @throws ConfigurationException if an error occurred within or during communication with the Metadata Service.
*/
public Collection getHosts() throws ConfigurationException{
- return getConfigurationReader().getHosts();
+ return this.configurationMgr.getConfigurationModel(Configuration.NEXT_STARTUP_ID).getConfiguration().getHosts();
}
public ComponentType getComponentType(ComponentTypeID id) throws ConfigurationException {
- return getConfigurationReader().getComponentType(id);
+ if ( id == null ) {
+ throw new ConfigurationException(ConfigMessages.CONFIG_0127, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0127));
+ }
+ return this.configurationMgr.getConfigurationModel(Configuration.NEXT_STARTUP_ID).getComponentType(id.getFullName());
}
public Collection getAllComponentTypes(boolean includeDeprecated) throws ConfigurationException {
- return getConfigurationReader().getComponentTypes(includeDeprecated);
+ ConfigurationModelContainer config = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
+ Map typeMap = config.getComponentTypes();
+ Collection types = new ArrayList(typeMap.size());
+ types.addAll(typeMap.values());
+ return types;
+
}
- public Collection getProductTypes(boolean includedeprecated) throws ConfigurationException {
- return Collections.EMPTY_LIST;
-// return getConfigurationReader().getProductTypes(includedeprecated);
- }
-
-
public Collection getAllObjectsForConfigurationModel(ConfigurationID configID) throws ConfigurationException {
- return getConfigurationReader().getConfigurationModel(configID).getAllObjects();
+ return this.configurationMgr.getConfigurationModel(configID).getAllObjects();
}
+ // ----------------------------------------------------------------------------------------
+ // C O N F I G U R A T I O N U P D A T E M E T H O D S
+ // ----------------------------------------------------------------------------------------
+ public Set executeActions( List actions ) throws InvalidComponentException, ConfigurationException {
+ ArgCheck.isNotNull(actions, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045, "actions")); //$NON-NLS-1$
- public Collection getMonitoredComponentTypes(boolean includeDeprecated) throws ConfigurationException {
- throw new UnsupportedOperationException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0110, "getMonitoredComponentTypes" )); //$NON-NLS-1$
+ LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Executing", actions.size(), "action(s) for principal", principal); //$NON-NLS-1$ //$NON-NLS-2$
-// return getConfigurationReader().getMonitoredComponentTypes(includeDeprecated);
- }
+ Set result = new HashSet();
- /**
- * Return the time the server was started. If the state of the server is not "Started"
- * then a null is returned.
- *
- * @return Date Time server was started.
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public Date getServerStartupTime() throws ConfigurationException {
- return getConfigurationReader().getServerStartupTime();
- }
-
-
- public int getServerStartupState() throws ConfigurationException {
- return getConfigurationReader().getServerStartupState();
- }
-
-
-
- //**************************************************
- //
- // L O C K I N G M E T H O D S
- //
- //**************************************************
-
- /**
- * Attempt to reserve a lock for the specified version of the specified configuration.
- * If the configuration is already locked by the same principal, this method simply returns true.
- * Otherwise, this method attempts to reserve a lock, and returns whether
- * the lock could be successfully reserved.
- * @param configurationName the identifier of the configuration.
- * @param principalName the name of the principal that is requesting the lock
- * @return true if the requested lock was able to be reserved by this
- * editor, or false if the lock could not be reserved because there
- * already exists a lock reserved by another editor.
- * @throws InvalidConfigurationException if the configuration name and version are invalid.
- * @throws ConfigurationLockException if there was an error locking the configuration
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
-/*
- public boolean lockConfiguration(ConfigurationID configurationID, String principalName)
- throws InvalidConfigurationException, ConfigurationLockException, ConfigurationException{
- throw new UnsupportedOperationException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0110, "lockConfiguration" ));
- }
-*/
- /**
- * Attempt to release the lock currently held by the principal for the
- * specified configuration and version. If this principal does not have a lock,
- * this method simply returns false.
- * Otherwise, this method attempts to release the lock, and returns whether
- * the lock could be successfully released.
- * @param configurationName the identifier of the configuration.
- * @param principalName the name of the principal that holds the lock
- * to be released.
- * @return true if the lock held by this editor for the specified
- * configuration was able to be returned, or false if the lock could not
- * returned because a lock for the specified configuration was not
- * held.
- * @throws InvalidConfigurationException if the configuration name and version are invalid.
- * @throws ConfigurationLockException if there was an error unlocking the configuration
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
-
-// public boolean unlockConfiguration(LockedConfigurationID configurationID, String principalName )
-/*
- public boolean unlockConfiguration(ConfigurationID configurationID, String principalName )
- throws InvalidConfigurationException, ConfigurationLockException, ConfigurationException{
- throw new UnsupportedOperationException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0110, "unlockConfiguration" ));
- }
-*/
- /**
- * Retrieve the lock information (if a lock exists) for the configuration
- * with the specified configuration name and version.
- * @param configurationName the identifier of the configuration.
- * @return the lock information if a lock exists for the configuration, or null
- * if no lock is held.
- * @throws InvalidConfigurationException if the configurationName and version are invalid.
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- /*
- public LockedConfigurationID getConfigurationLockInformation( ConfigurationID configurationID )
- throws InvalidConfigurationException, ConfigurationException{
- throw new UnsupportedOperationException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0110, "getConfigurationLockInformation" ));
- }
-*/
-
- /**
- * Returns a boolean indicating if the configuration already exist or not.
- * @param configurationName the identifier of the configuration
- * @return boolean of false if the configuration is found
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- public boolean doesConfigurationExist( String configurationName )
- throws ConfigurationException{
- ConfigurationID id = getConfigurationReader().getDesignatedConfigurationID(configurationName);
- if (id != null) {
- return true;
+ if ( actions.isEmpty() ) {
+ return result;
}
- return false;
- }
+ List actionsWithSameTarget = new ArrayList(13); // guessing at an initial size, probably high
+ Object currentTarget = null;
+ ActionDefinition currentAction = null;
+ ActionDefinition nextAction = null;
+ int actionCounter = -1;
- public void commit() throws ManagedConnectionException {
+ // Iterate through the actions, and apply all as a single transaction
+ try {
+ boolean createObject = false;
- if (configUserTransaction != null) {
- try {
- configUserTransaction.commit();
- } catch (Exception ce) {
- throw new ManagedConnectionException(ce, ConfigMessages.CONFIG_0111,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0111, configUserTransaction.getTransaction().getLockAcquiredBy()));
- }
+ // Get the first action and its target, and add it to the list ...
+ Iterator iter = actions.iterator();
+ if ( iter.hasNext() ) {
+ currentAction = (ActionDefinition) iter.next();
+ currentTarget = currentAction.getTarget();
+ actionsWithSameTarget.add(currentAction);
+ }
- }
+//System.out.println("WRITER: Iterater Actions " + actions.size());
+ while ( iter.hasNext() ) {
+ nextAction = (ActionDefinition) iter.next();
+ if ( currentAction instanceof CreateObject ) {
+ createObject = true;
+ }
- super.commit();
+ // If the current action is a 'DestroyObject' action, then process only
+ // the destroy (other actions not processed up to this point do not
+ // need to be processed, since the target will be destroyed anyway).
+ if ( currentAction instanceof DestroyObject ) {
+ // If creating and destroying an object in the same action list,
+ // then don't need to do anything ...
+ if ( !createObject ) {
+ result.addAll( executeActionsOnTarget( currentTarget,actionsWithSameTarget) );
+ }
+ actionCounter += actionsWithSameTarget.size();
+ actionsWithSameTarget.clear();
+ createObject = false;
+ currentTarget = nextAction.getTarget();
+ }
- configUserTransaction = null;
+ // Otherwise, if the next action has another target, process up to the current action ...
+ else if ( currentTarget != nextAction.getTarget() ) {
+ result.addAll( executeActionsOnTarget( currentTarget,actionsWithSameTarget) );
+ actionCounter += actionsWithSameTarget.size();
+ actionsWithSameTarget.clear();
+ createObject = false;
+ currentTarget = nextAction.getTarget();
+ }
- }
+ // Add this next action ...
+ currentAction = nextAction;
+ actionsWithSameTarget.add(currentAction);
+ }
- public void rollback() throws ManagedConnectionException {
- if (configUserTransaction != null) {
- try {
- configUserTransaction.rollback();
+ // Process the last set of actions ...
+ if ( actionsWithSameTarget.size() != 0 ) {
- } catch (Exception re) {
+ result.addAll( executeActionsOnTarget(currentTarget,actionsWithSameTarget) );
+ createObject = false;
}
- }
- super.rollback();
-
- }
-
-
-
- // ----------------------------------------------------------------------------------------
- // C O N F I G U R A T I O N U P D A T E M E T H O D S
- // ----------------------------------------------------------------------------------------
-
- public Set executeActions( List actions, String principalName ) throws InvalidComponentException, ConfigurationException {
- Set affectedIDs = null;
- LogManager.logDetail(LogCommonConstants.CTX_CONFIG, new Object[] {"Executing " + actions.size() + " action(s) for principal ", principalName} ); //$NON-NLS-1$ //$NON-NLS-2$
-
- try {
-
- configUserTransaction = getConfigurationWriter().getTransaction(principalName);
- affectedIDs = getConfigurationWriter().executeActions(actions, configUserTransaction.getTransaction());
-
- } catch (TransactionException e) {
- LogManager.logTrace(LogCommonConstants.CTX_CONFIG, e, new Object[]{"Failed actions: ", actions}); //$NON-NLS-1$
-
- try {
- configUserTransaction.rollback();
- } catch(Exception re) {
- }
-
- throw new ConfigurationException(e, ConfigPlugin.Util.getString(ConfigMessages.MSG_0006));
- } catch (ConfigurationException e) {
- LogManager.logTrace(LogCommonConstants.CTX_CONFIG, e, new Object[]{"Failed actions: ", actions}); //$NON-NLS-1$
-
- try {
- configUserTransaction.rollback();
- } catch(Exception re) {
- }
-
- throw e;
- } finally {
- // release the lock
-// unlockconfiguration(lockID, principalName);
+ } catch ( Exception e ) {
+ throw new ConfigurationException(e);
}
LogManager.logInfo(LogCommonConstants.CTX_CONFIG,ConfigPlugin.Util.getString(ConfigMessages.MSG_0007));
-
- return affectedIDs;
+ return result;
}
-
- public Set executeActions( boolean doAdjust, List actions, String principalName ) throws InvalidComponentException, ConfigurationException{
- throw new UnsupportedOperationException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0112));
-
- }
-
-
-
+
/**
- * Overwrite the specified configuration by copying another configuration
- * over it. This includes assigning any
- * {@link #getDesignatedConfiguration designations}
- * of the configuration to be overwritten to the configuration to
- * be copied. Both configurations must already be in the data source.
- * (This method is needed to implement baselining).
- * @param configToCopy the ConfigurationID of the Configuration to be
- * copied
- * @param configToCopy the ConfigurationID of the Configuration to be
- * deleted - the "configToCopy" will be overwritten in its place.
- * @param principalName the name of the principal that is requesting the
- * modification
- * @return the new ID of the newly-copied Configuration
- * @throws InvalidConfigurationException if either ConfigurationID is invalid.
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
+ * Executes the specified transactions, which must all be applied to the same target, using
+ * the specified transaction.
*/
- public ConfigurationID overwriteConfiguration(ConfigurationID configToCopy, ConfigurationID configToOverwrite, String principalName) throws InvalidConfigurationException, ConfigurationException{
- ConfigurationID resultID = null;
- LogManager.logDetail(LogCommonConstants.CTX_CONFIG, new Object[] {"Overwriting configuration ", configToOverwrite, "with configuration ", configToCopy, " for principal", principalName} ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ private Set executeActionsOnTarget( Object target, List actions)
+ throws ConfigTransactionException, ConfigurationException {
+ Set results = updateStrategy.executeActionsOnTarget(target, actions, this);
- try {
+ return results;
- configUserTransaction = getConfigurationWriter().getTransaction(principalName);
-
- resultID = getConfigurationWriter().overwriteConfiguration(configToCopy, configToOverwrite, configUserTransaction.getTransaction());
-
- } catch (ConfigTransactionException te) {
-// LogManager.logCritical(LogCommonConstants.CTX_CONFIG, e, "Unable to execute actions; use trace logging for actions");
-// LogManager.logTrace(LogCommonConstants.CTX_CONFIG, e, new Object[]{"Failed actions: ", actions});
- throw new ConfigurationException(te);
- }
- LogManager.logInfo(LogCommonConstants.CTX_CONFIG, ConfigPlugin.Util.getString(ConfigMessages.MSG_0008));
-
- return resultID;
}
- /**
+ /**
* Save the resource changes based on each {@link com.metamatrix.common.config.api.ResourceDescriptor ResourceDescriptor}
* in the collection.
* @param resourceDescriptors for the resources to be changed *
@@ -547,53 +365,13 @@
*/
public void saveResources(Collection resourceDescriptors, String principalName) throws ConfigurationException {
+ for (Iterator it=resourceDescriptors.iterator(); it.hasNext(); ) {
+ SharedResource rd = (SharedResource) it.next();
- try {
+ ArgCheck.isNotNull(rd, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0130));
- configUserTransaction = getConfigurationWriter().getTransaction(principalName);
-
- for (Iterator it=resourceDescriptors.iterator(); it.hasNext(); ) {
- SharedResource rd = (SharedResource) it.next();
-
- getConfigurationWriter().updateSharedResource(rd, configUserTransaction.getTransaction());
-
- }
-
- } catch (ConfigTransactionException te) {
- throw new ConfigurationException(te);
+ updateStrategy.updateSharedResource(rd, this);
}
-
-
}
-
- protected XMLConfigurationReader getConfigurationReader() throws ConfigurationException {
- if (reader == null) {
- try {
- reader = new XMLConfigurationReader(getConnection());
- } catch (ManagedConnectionException mce) {
- throw new ConfigurationException(mce);
- }
- }
- return reader;
- }
-
- protected XMLConfigurationWriter getConfigurationWriter() throws ConfigurationException {
- if (writer == null) {
- try {
- writer = new XMLConfigurationWriter(getConnection());
- } catch (ManagedConnectionException mce) {
- throw new ConfigurationException(mce);
- }
-
-
- }
- return writer;
- }
-
}
-
-
-
-
-
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnectorFactory.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnectorFactory.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnectorFactory.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import java.util.Properties;
-
-import com.metamatrix.common.connection.*;
-
-public class XMLConfigurationConnectorFactory implements TransactionFactory {
-
- /**
- *@link dependency
- * @stereotype instantiate
- */
-
- /**
- * Create a new instance of a metadata connection.
- * @param env the environment properties for the new connection.
- * @throws ManagedConnectionException if there is an error creating the connection.
- */
- public ManagedConnection createConnection(Properties env, String userName)
-
- throws ManagedConnectionException {
-// return new JDBCMgdResourceConnection(env, userName);
- return new SimpleManagedConnection(env, userName);
- }
-
- /**
- * Create a new instance of a transaction for a managed connection.
- * @param connection the connection that should be used and that was created using this
- * factory's <code>createConnection</code> method (thus the transaction subclass may cast to the
- * type created by the <code>createConnection</code> method.
- * @param readonly true if the transaction is to be readonly, or false otherwise
- * @throws ManagedConnectionException if there is an error creating the transaction.
- */
- public TransactionInterface createTransaction(ManagedConnection connection, boolean readonly )
- throws ManagedConnectionException {
- return new XMLConfigurationConnector(connection, readonly);
- }
-
-}
-
-
-
-
-
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationMgr.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationMgr.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationMgr.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -25,28 +25,24 @@
import java.util.Collection;
import java.util.EventObject;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
-import com.metamatrix.common.config.StartupStateController;
-import com.metamatrix.common.config.StartupStateException;
+import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.ConfigurationID;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.exceptions.ConfigurationConnectionException;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
import com.metamatrix.common.config.util.ConfigObjectsNotResolvableException;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.messaging.MessagingException;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.VMNaming;
+import com.metamatrix.common.util.LogCommonConstants;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.event.EventObjectListener;
-import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.core.util.Assertion;
-import com.metamatrix.server.ResourceFinder;
import com.metamatrix.platform.config.ConfigMessages;
import com.metamatrix.platform.config.ConfigPlugin;
import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
@@ -56,191 +52,79 @@
/**
* Created on Aug 27, 2002
*
- * The Mgr operates under the single pattern. It uses other components
+ * The Mgr operates under the singleton pattern. It uses other components
* to manage the configuration. This would include transactions and persistence.
* Those components are implemented such they can be changed so that the
* behavior of the mgr is changed.
- *
- * NOTE:
- * - STARTUP - before any changes can be made to any configuration, the
- * the performSystemInitialization must be performed.
*/
public class XMLConfigurationMgr {
- private static XMLConfigurationMgr mgr = null;
+ private static XMLConfigurationMgr mgr;
- private PersistentConnection connection = null;
- private PersistentConnectionFactory connFactory = null;
+ private PersistentConnectionFactory connFactory;
+ private MessageBus messageBus;
+
+ private Map<String, ConfigurationModelContainer> configs = new HashMap<String, ConfigurationModelContainer>();
+ private ConfigurationModelContainerAdapter adapter = new ConfigurationModelContainerAdapter();
- private Properties props = null;
+ private XMLConfigurationMgr(Properties properties) throws ConfigurationException {
+ Assertion.isNotNull(properties, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0113));
- private MessageBus messageBus = null;
+ connFactory = new PersistentConnectionFactory(properties);
-
- private Map configs = new HashMap();
-
- // this map of config models are only used by the writer for transaction processing
- //
- // NOTE: this is done to keep the problem where changes are applied
- // to the same config model reference twice.
- // HOW DOES THIS HAPPEN: When processing is done within the same VM,
- // the same reference used by the ConfigurationObjectEditor is also
- // used in the update transaction {@see XMLConfigurationWriter.getWriteTransaction}
- // therefore, a change applied by the editor to the configuration object
- // now exist in the model when the same reference is used to apply the
- // actions created by the editor.
- private Map transConfigs = new HashMap();
-
- private ConfigurationModelContainerAdapter adapter = new ConfigurationModelContainerAdapter();
- private String hostName = null;
+ getConfigurationModel(Configuration.NEXT_STARTUP_ID);
+ }
- private XMLConfigurationMgr(MessageBus bus) {
- this.messageBus = bus;
- this.hostName = VMNaming.getConfigName();
+ protected XMLConfigurationMgr() {
- try {
- messageBus.addListener(ConfigurationChangeEvent.class, createChangeListener());
- } catch (MessagingException e) {
- System.out.println(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0126));
- }
}
+
+ public void setMessageBus(MessageBus messageBus) {
+ this.messageBus = messageBus;
+ if (messageBus != null) {
+ try {
+ messageBus.addListener(ConfigurationChangeEvent.class, new EventObjectListener() {
+ public void processEvent(EventObject obj){
+ if(obj instanceof ConfigurationChangeEvent){
+ mgr.clearCache();
+ }
+ }
+ });
+ } catch (MessagingException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+ }
/**
* Always call getInstance to get the reference to the XMLConfigurationMgr to
* use to make other method calls on.
*/
public static final synchronized XMLConfigurationMgr getInstance() {
-
if (mgr == null) {
-
- XMLConfigurationMgr xmlMgr = new XMLConfigurationMgr(ResourceFinder.getMessageBus());
- mgr = xmlMgr;
-
+ try {
+ mgr = new XMLConfigurationMgr(CurrentConfiguration.getInstance().getBootStrapProperties());
+ } catch (ConfigurationException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
}
return mgr;
-
}
-
- public synchronized void init(Properties properties) throws ConfigurationException {
-
-
- // if already initialized before, don't reinit everything
- if (this.connection != null && !connection.isClosed()) {
- return;
- }
-
- if(properties == null){
- Assertion.isNotNull(properties, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0113));
- }
-
-
- this.props = PropertiesUtils.clone(properties, false);
-
- Properties factoryProps = new Properties();
- factoryProps.putAll(this.props);
-
- connFactory = PersistentConnectionFactory.createPersistentConnectionFactory(props);
-// createPersistentConnectionFactory(props);
-
- connection = connFactory.createPersistentConnection();
-
- // preload next startup
- ConfigurationModelContainer cmc = readModel(Configuration.NEXT_STARTUP_ID);
-
- if (cmc == null) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0114, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0114, Configuration.NEXT_STARTUP_ID ));
- }
-
- configs.put(cmc.getConfigurationID().getFullName(), cmc);
-
- try {
- ConfigurationModelContainer cmct = (ConfigurationModelContainer) cmc.clone();
-
- transConfigs.put(cmct.getConfigurationID().getFullName(), cmct);
- } catch (Exception ce) {
- throw new ConfigurationException(ce,ConfigMessages.CONFIG_0115, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0115,cmc.getConfigurationID()));
- }
+
+ public XMLConfigurationConnector getTransaction(String principal) throws ConfigurationException {
+ XMLConfigurationConnector transaction = new XMLConfigurationConnector(this, principal);
+ ConfigurationID configID = XMLConfigurationMgr.getDesignatedConfigurationID(Configuration.NEXT_STARTUP);
+ ConfigurationModelContainer transconfig = getConfigurationModelForTransaction(configID);
+ transaction.addObjects(configID.getFullName(), transconfig);
+ return transaction;
}
- protected Properties getProperties() {
- return this.props;
- }
-
- public synchronized java.util.Date getServerStartupTime() throws ConfigurationException {
- return getConnection().getStartupTime();
- }
-
-
- public synchronized int getServerStartupState() throws ConfigurationException {
- return getConnection().getServerState();
-
- }
-
- public boolean isServerStarting() throws ConfigurationException {
- int startupState = getServerStartupState();
-
- if (startupState == StartupStateController.STATE_STARTING) {
- return true;
- }
- return false;
- }
-
-
- public boolean isServerStopped() throws ConfigurationException {
- int startupState = getServerStartupState();
-
- if (startupState == StartupStateController.STATE_STOPPED) {
- return true;
- }
- return false;
- }
-
- public boolean isServerAvailable() throws ConfigurationException {
- // the assumption here is that onle one user can have a lock at a time,
- // therefore, if a change has been committed therefore they have the lock
- // and the server state must be updated on their behalf
- int startupState = getServerStartupState();
-
-
- if (startupState == StartupStateController.STATE_STARTED) {
- return true;
- }
- return false;
- }
-
-
/**
- * The setting of the server state is not part
- */
-
- protected synchronized void setServerStateToStarting(boolean force) throws StartupStateException, ConfigurationException {
- PersistentConnection conn = getConnection();
- if (force) {
- conn.setServerStarting(force);
- } else {
-
- conn.setServerStarting();
- }
-
- }
-
- protected synchronized void setServerStateToStopped() throws StartupStateException,ConfigurationException {
-
- getConnection().setServerStopped();
-
- }
-
- protected synchronized void setServerStateToStarted() throws StartupStateException,ConfigurationException {
-
- getConnection().setServerStarted();
- }
-
- /**
* Returns the configuration for the specified configID.
* {@see Configuration}.
*/
public synchronized ConfigurationModelContainer getConfigurationModel(ConfigurationID configID) throws ConfigurationException {
- ConfigurationModelContainer cmc = (ConfigurationModelContainer)configs.get(configID.getFullName());
+ ConfigurationModelContainer cmc = configs.get(configID.getFullName());
if (cmc == null) {
cmc = readModel(configID);
@@ -251,244 +135,124 @@
}
configs.put(cmc.getConfigurationID().getFullName(), cmc);
-
- try {
- ConfigurationModelContainer cmct = (ConfigurationModelContainer)cmc.clone();
-
- transConfigs.put(cmct.getConfigurationID().getFullName(), cmct);
- } catch (Exception ce) {
- throw new ConfigurationException(ce, ConfigMessages.CONFIG_0116,
- ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0116, configID));
- }
}
return cmc;
}
- private synchronized ConfigurationModelContainer readModel(ConfigurationID configID) throws ConfigurationException {
- return getConnection().read(configID);
+ private ConfigurationModelContainer readModel(ConfigurationID configID) throws ConfigurationException {
+ PersistentConnection pc = getConnection(true);
+ try {
+ return pc.read(configID);
+ } finally {
+ pc.close();
+ }
}
/**
* This method is only used by the XMLConfigurationWriter so that is may obtain
* a model specifically for transaction purposes.
*/
- synchronized ConfigurationModelContainer getConfigurationModelForTransaction(ConfigurationID configID) throws ConfigurationException {
- if (transConfigs.containsKey(configID.getFullName())) {
- return (ConfigurationModelContainer) transConfigs.get(configID.getFullName());
- }
-
- // call to refresh caches
- getConfigurationModel(configID);
-
- if (transConfigs.containsKey(configID.getFullName())) {
- return (ConfigurationModelContainer) transConfigs.get(configID.getFullName());
+ private ConfigurationModelContainer getConfigurationModelForTransaction(ConfigurationID configID) throws ConfigurationException {
+ ConfigurationModelContainer cmc = getConfigurationModel(configID);
+
+ if (cmc == null) {
+ throw new ConfigurationException(ConfigMessages.CONFIG_0114, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0114, configID));
}
-
-
- throw new ConfigurationException(ConfigMessages.CONFIG_0114, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0114, configID));
-
+
+ return (ConfigurationModelContainer)cmc.clone();
}
-//******************************
-//
-// Transaction related methods
-//
-//******************************
-
-
- public synchronized void rollbackTransaction() {
- this.connection.close();
- this.connection = null;
- }
-
/**
* Apply transaction is called when the Transaction is committed.
* @param transaction is the transaction that contains the object model that changed
* @throws ConfigurationException if a problem occurs setting the configuration.
*/
- public synchronized void applyTransaction(ConfigTransaction transaction) throws ConfigTransactionException {
- ArgCheck.isNotNull(transaction, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0118));
+ synchronized void applyTransaction(Collection<ConfigurationModelContainer> models, String principal) throws ConfigTransactionException {
-// System.out.println("MGR - APPLY TRANSACTION " + transaction.getAction());
- // only for non-initialization or server startup actions will the configuration be written
- // the no server initialize actions are created due to specific changes to the configuration
- // the initialize actions are results of starting and bouncing the server
- if (transaction.getAction() == ConfigTransaction.NO_SERVER_INITIALIZATION_ACTION ||
- transaction.getAction() == ConfigTransaction.SERVER_FORCE_INITIALIZATION ||
- transaction.getAction() == ConfigTransaction.SERVER_INITIALIZATION) {
+ if (models == null || models.isEmpty()) {
+ throw new ConfigTransactionException(ConfigMessages.CONFIG_0119, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0119));
+ }
- if (transaction.getObjects() == null || transaction.getObjects().isEmpty()) {
- throw new ConfigTransactionException(ConfigMessages.CONFIG_0119, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0119));
- }
+ PersistentConnection pc = null;
+ boolean success = false;
+ try {
+ for (ConfigurationModelContainer config : models) {
+ try {
+
+ //validate the model before saving
+ adapter.validateModel(config);
- Collection models = transaction.getObjects();
- PersistentConnection pc = null;
- boolean success = false;
- try {
- for (Iterator it=models.iterator(); it.hasNext(); ) {
-
- Object obj = it.next();
- if (!(obj instanceof ConfigurationModelContainer)) {
- throw new ConfigTransactionException(ConfigMessages.CONFIG_0121, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0121, obj.getClass().getName()));
+ if (pc == null) {
+ pc = getConnection(false);
}
- ConfigurationModelContainer config = (ConfigurationModelContainer) obj;
-
- try {
-
- //validate the model before saving
- adapter.validateModel(config);
-
- if (pc == null) {
- pc = getConnection();
- pc.beginTransaction();
- }
- pc.write(config, transaction.getLockAcquiredBy());
- // transConfigs.clear();
-
- // clearCache();
- // System.out.println("<CONFIGMGR> write configuration " + config.getConfigurationID().getFullName());
-
- /*
- ConfigurationModelContainer checkM = readModel(config.getConfigurationID());
- if (checkM == null) {
- throw new ConfigTransactionException("Error persisting configuration " + config.getConfigurationID() + ", it was not saved properly");
- }
- */
- //
- configs.put(config.getConfigurationID().getFullName(), config);
-
- ConfigurationModelContainer cmct = (ConfigurationModelContainer) config.clone();
-
- transConfigs.put(cmct.getConfigurationID().getFullName(), cmct);
- } catch (ConfigurationException ce) {
- throw new ConfigTransactionException(ce, ConfigMessages.CONFIG_0120, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0120, config.getConfigurationID()));
- } catch (ConfigObjectsNotResolvableException e) {
- throw new ConfigTransactionException(e, ConfigMessages.CONFIG_0120, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0120, config.getConfigurationID()));
- }
- }
- try {
- pc.commit();
- } catch (ConfigurationException e) {
- throw new ConfigTransactionException(e, e.getMessage());
- }
- success = true;
- } finally {
+ pc.write(config, principal);
+ configs.put(config.getConfigurationID().getFullName(), config);
+ } catch (ConfigurationException ce) {
+ throw new ConfigTransactionException(ce, ConfigMessages.CONFIG_0120, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0120, config.getConfigurationID()));
+ } catch (ConfigObjectsNotResolvableException e) {
+ throw new ConfigTransactionException(e, ConfigMessages.CONFIG_0120, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0120, config.getConfigurationID()));
+ }
+ }
+ try {
+ pc.commit();
+ } catch (ConfigurationException e) {
+ throw new ConfigTransactionException(e, e.getMessage());
+ }
+ success = true;
+ } finally {
+ try {
if (!success && pc != null) {
try {
pc.rollback();
} catch (ConfigurationException e) {
throw new ConfigTransactionException(e, e.getMessage());
}
- }
+ }
+ } finally {
+ pc.close();
}
}
- if (transaction.getAction() != ConfigTransaction.SERVER_SHUTDOWN) {
- if(messageBus != null){
- try{
-// System.out.println("<CONFIG_MGR>Send Change Event " + v);
- messageBus.processEvent(new ConfigurationChangeEvent(hostName, ConfigurationChangeEvent.CONFIG_REFRESH));
- }catch(Exception e){
- System.err.println(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0122, e.getMessage()));
-
- }
- }
+ if (messageBus != null){
+ try {
+ messageBus.processEvent(new ConfigurationChangeEvent(XMLConfigurationMgr.class.getName(), ConfigurationChangeEvent.CONFIG_REFRESH));
+ } catch (MessagingException e) {
+ LogManager.logWarning(LogCommonConstants.CTX_CONFIG, e, "Exception sending refresh event"); //$NON-NLS-1$
+ }
}
-
-
}
-
-
-
/**
- * Call to initialize persistence when the NextStartUp configuration
- * needs to copied to the Operation configuation.
- *
- * This method is used for the following reasons:
- * <li> When the ServerMgr starts it calls performSystemInitialization
- * <li> Bouncing server
- */
- void performSystemInitialization(ConfigTransaction transaction) throws ConfigurationException, StartupStateException, ConfigurationLockException {
-
- if (!isServerStarting()) {
- throw new StartupStateException(StartupStateController.STATE_STARTING, getServerStartupState());
- }
-
-
- ConfigurationModelContainer ns = readModel(Configuration.NEXT_STARTUP_ID);
-
- ConfigurationModelContainer st = ns.copyAs(Configuration.STARTUP_ID);
-
- transaction.addObjects(ns.getConfigurationID().getFullName(), ns);
- transaction.addObjects(st.getConfigurationID().getFullName(), st);
-
- }
-
-
- /**
* This method should connect to the persitent storage.
* @throws ConfigurationConnectionException if there is an error establishing the connection.
*/
-
- synchronized PersistentConnection getConnection( ) throws ConfigurationConnectionException{
- if (connection==null) {
- try {
- connection = connFactory.createPersistentConnection();
- } catch (ConfigurationException e) {
- throw new ConfigurationConnectionException(e);
- }
- } else {
- if (connection.isClosed()) {
- try {
- connection = connFactory.createPersistentConnection();
- } catch (ConfigurationException e) {
- throw new ConfigurationConnectionException(e);
- }
-
- }
- }
-
- return this.connection;
-
+ private PersistentConnection getConnection(boolean readOnly) throws ConfigurationException{
+ return connFactory.createPersistentConnection(readOnly);
}
-
-
- protected synchronized void clearCache() {
+ private synchronized void clearCache() {
configs.clear();
- transConfigs.clear();
}
- protected ConfigurationChangeListener createChangeListener() {
- return new ConfigurationChangeListener(this);
- }
+ /**
+ * Returns ID of one of the well-known configuration. Will
+ * return null if the designation parameter is invalid.
+ * @param designation String indicating which of the system configurations
+ * is desired; use one of the {@link SystemConfigurationNames} constants
+ * @param jdbcConnection connection to the proper config database
+ * @return the desired ConfigurationID
+ * @throws ConfigurationException if an error occurred within or during
+ * communication with the Configuration Service.
+ */
+ public static ConfigurationID getDesignatedConfigurationID(String designation ) throws ConfigurationException{
+ // This was changed to public so installation could use the method
+
+ if (designation.startsWith(Configuration.NEXT_STARTUP) ) {
+ return Configuration.NEXT_STARTUP_ID;
+ }
+ throw new ConfigurationException(ConfigMessages.CONFIG_0128, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0128, designation ));
+ }
-
- protected class ConfigurationChangeListener implements EventObjectListener{
- private XMLConfigurationMgr mgr = null;
-
- public ConfigurationChangeListener(XMLConfigurationMgr theMgr) {
- mgr = theMgr;
- }
-
- public void processEvent(EventObject obj){
- if(obj instanceof ConfigurationChangeEvent){
-// ConfigurationChangeEvent eventObj = (ConfigurationChangeEvent)obj;
- // [vah 5/23/02] per Steve W., the events passed along the
- // JMS Message Bus were not originally notifing all JVMs
- // The change was made to the JMSMessageBus to notify all JVMs
- // so the change here is to not execute the change
- // if the event came from the same VM
-
- // Null source object means the event came from another VM
-
-// if (eventObj.getSource() == null) {
- mgr.clearCache();
-// }
- }
- }
- }
}
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationReader.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationReader.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationReader.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,707 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import com.metamatrix.common.config.api.ComponentDefn;
-import com.metamatrix.common.config.api.ComponentDefnID;
-import com.metamatrix.common.config.api.ComponentObjectID;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeID;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.common.config.api.Host;
-import com.metamatrix.common.config.api.HostID;
-import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.connection.ManagedConnection;
-import com.metamatrix.common.transaction.TransactionException;
-import com.metamatrix.platform.config.ConfigMessages;
-import com.metamatrix.platform.config.ConfigPlugin;
-
-public class XMLConfigurationReader {
-
-
- private static XMLConfigurationMgr configMgr = XMLConfigurationMgr.getInstance();
- private ConfigUserTransactionFactory factory;
-
-// private ManagedConnection mgdConnection;
-
- // private static ConfigurationObjectEditor editor;
-
-
- public XMLConfigurationReader(ManagedConnection mgdConnection) {
-// this.mgdConnection = mgdConnection;
-
-// editor = new BasicConfigurationObjectEditor(false);
-
- factory = new ConfigUserTransactionFactory();
-
-
- }
-
- public Host getHost(HostID hostID) throws ConfigurationException{
-
- ConfigurationModelContainer config = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
- return config.getConfiguration().getHost(hostID.getFullName());
-
- }
-
- public Collection getHosts() throws ConfigurationException{
-
- ConfigurationModelContainer config = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
-
- return config.getConfiguration().getHosts();
- }
-
- /**
- * Obtain the Date that represents the time the server was started
- * @return Date
- * @throws ConfigurationException if an business error occurred within or during communication with the Configuration Service.
- */
- public java.util.Date getServerStartupTime() throws ConfigurationException {
- java.util.Date timestamp = configMgr.getServerStartupTime();
- return timestamp;
- }
-
-
- public ComponentType getComponentType(ComponentTypeID typeID) throws ConfigurationException{
- if ( typeID == null ) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0127, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0127));
- }
-
- ConfigurationModelContainer model = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
-
- return model.getComponentType(typeID.getFullName());
-
- }
-
-
- public Collection getComponentTypes(boolean includeDeprecated) throws ConfigurationException{
-
- ConfigurationModelContainer config = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
-
- Map typeMap = config.getComponentTypes();
- Collection types = new ArrayList(typeMap.size());
- types.addAll(typeMap.values());
-// for (Iterator it=typeMap.values().iterator(); it.hasNext(); ) {
-// types.add(it.next());
-// }
-
- return types;
- }
-
- public Collection getProductTypes(boolean includeDeprecated) throws ConfigurationException {
-
- ConfigurationModelContainer config = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
-
- Collection intypes = config.getProductTypes();
- Collection types = new ArrayList(intypes.size());
- types.addAll(intypes);
-
- return types;
-
- }
-
-
-
- public String getComponentPropertyValue(ComponentObjectID componentObjectID, ComponentTypeID typeID, String propertyName) throws ConfigurationException{
-
-
- String result = null;
-/*
- UniqueID uid = getUniqueUID(componentObjectID, jdbcConnection);
-
- if (componentObjectID instanceof DeployedComponentID) {
- sql = JDBCConfigurationTranslator.SELECT_PROPERTY_VALUE_FOR_DEPLOYED_COMPONENT;
- statement = jdbcConnection.prepareStatement(sql);
- statement.setInt(1,(int)uid.getValue());
- statement.setString(2,propertyName);
-
- } else {
-
- sql = JDBCConfigurationTranslator.SELECT_PROPERTY_VALUE_FOR_COMPONENT;
- statement = jdbcConnection.prepareStatement(sql);
- statement.setInt(1,(int)uid.getValue());
- statement.setString(2,typeID.getFullName());
- statement.setString(3,propertyName);
- }
-
-*/
- return result;
- }
-/*
- public ProductServiceConfig getProductServiceConfig(ServiceComponentDefnID serviceID) throws ConfigurationException{
- ProductServiceConfig result = null;
-
- ConfigurationID configurationID = getDesignatedConfigurationID(serviceID.getParentFullName());
- // ComponentDefn defn = getComponentDefinition(serviceID, configurationID);
- // if (defn == null) {
- // throw new ConfigurationException("Service Component was not found for id " + serviceID );
- // }
-
- ConfigurationModelContainer config = getConfigurationModel(configurationID);
-
- ProductServiceConfigID pscID = config.getConfiguration().getPSCForServiceDefn(serviceID);
-
- if (pscID == null) {
- throw new ConfigurationException("No PSC was found to contain service id " + serviceID );
- }
-
- result = (ProductServiceConfig) config.getConfiguration().getComponentDefn(pscID);
-
- if (pscID == null) {
- throw new ConfigurationException("Configuration Error: Matched PSC ID to service id " + serviceID + " but no PSC object found" );
- }
-
- return result;
- }
-*/
-
-
- public ComponentDefn getComponentDefinition(ComponentDefnID targetID) throws ConfigurationException{
- if (targetID == null) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0045,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045,"ComponentDefnID")); //$NON-NLS-1$
- }
-
- ConfigurationID configurationID = getDesignatedConfigurationID(targetID.getParentFullName());
-
- ComponentDefn defn = getComponentDefinition(targetID, configurationID);
-
-/* Should already be populated
- *
- if (defn instanceof ProductServiceConfig){
- defn = populateProductServiceConfig((ProductServiceConfig)defn);
- }
-*/
- return defn;
-
- }
-
- public ComponentDefn getComponentDefinition(ComponentDefnID targetID, ConfigurationID configurationID) throws ConfigurationException{
-
- if (targetID == null) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0045,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045,"ComponentDefnID")); //$NON-NLS-1$
- }
- ComponentDefn defn = null;
-
-
- if (configurationID == null) {
- configurationID = getDesignatedConfigurationID(targetID.getParentFullName());
- }
-
- ConfigurationModelContainer config = getConfigurationModel(configurationID);
- defn = config.getConfiguration().getComponentDefn(targetID);
-
-
-/** should already be populated
- if (defn instanceof ProductServiceConfig){
- defn = populateProductServiceConfig((ProductServiceConfig)defn);
- }
-
-*/
- return defn;
-
- }
-
-
-
- public Map getComponentDefinitions(ConfigurationID configID ) throws ConfigurationException {
-
- ConfigurationModelContainer config = getConfigurationModel(configID);
-
- return config.getConfiguration().getComponentDefns();
- }
-
-
- public Collection getConnectionPools(ConfigurationID configurationID ) throws ConfigurationException {
-
- ConfigurationModelContainer model = getConfigurationModel(configurationID);
-
- return model.getConnectionPools();
-
- }
-
-/*
- private ComponentType buildComponentType(ResultSet results, boolean includeDeprecated ) throws ConfigurationException, SQLException {
-
- // set default type code
- int compTypeCode = ComponentType.CONFIGURATION_COMPONENT_TYPE_CODE;
-
-
-
- if (isComponentTypeOfTypeConfiguration(results)) {
- } else if (isComponentTypeOfTypeConnector(results, jdbcConnection)) {
- compTypeCode = ComponentType.CONNECTOR_COMPONENT_TYPE_CODE;
- } else if (isComponentTypeOfTypeProduct(results, jdbcConnection)) {
- compTypeCode = ComponentType.PRODUCT_COMPONENT_TYPE_CODE;
- } else if (isComponentTypeofTypeResource(results, jdbcConnection)) {
- compTypeCode = ComponentType.RESOURCE_COMPONENT_TYPE_CODE;
- } else {
- compTypeCode = ComponentType.SERVICE_COMPONENT_TYPE_CODE;
- }
-
-
- ComponentType type = JDBCConfigurationTranslator.getComponentType(compTypeCode, results);
- Collection defns = null;
-
- if (includeDeprecated) {
- defns = getComponenTypeDefinitions( (ComponentTypeID) type.getID(), jdbcConnection);
- type = editor.setComponentTypeDefinitions(type, defns);
-
- } else if (!type.isDeprecated()) {
- defns = getComponenTypeDefinitions( (ComponentTypeID) type.getID(), jdbcConnection);
- type = editor.setComponentTypeDefinitions(type, defns);
-
- }
-
- if (type instanceof ProductType){
- String sql = null;
- PreparedStatement statement = null;
- try{
- sql = JDBCConfigurationTranslator.SELECT_COMPONENT_TYPES_BY_PARENT_NAME;
- statement = jdbcConnection.prepareStatement(sql);
- statement.setString(1, type.getFullName());
-
- if ( ! statement.execute() ) {
- throw new ConfigurationException("Failed to execute the query \"" + sql + "\"");
- }
- ResultSet moreResults = statement.getResultSet();
-
- // check here for the next row, because this is flaky if you pass the results
- // back to the calling method to do the checking.
- if (moreResults.next()) {
- type = populateProductType(moreResults, (ProductType)type);
- }
-
- } catch ( SQLException e ) {
- throw new ConfigurationException(e, "Failed to execute the query \"" + sql + "\" and/or process the results");
- } catch ( Exception e ) {
- if (e instanceof ConfigurationException){
- throw (ConfigurationException)e;
- }
- throw new ConfigurationException(e);
- } finally {
- if ( statement != null ) {
- try {
- statement.close();
- statement=null;
- } catch ( SQLException e ) {
- e.printStackTrace();
- System.out.println("Unable to close the statement for query \"" + sql + "\"");
- }
- }
- }
- }
-
- return type;
- }
-*/
- /**
- * Takes a ProductType, and puts into it the ComponentTypeID objects
- * representing legal service types for that product type.
- */
-/*
- private ProductType populateProductType(ResultSet results, ProductType prodType) throws ConfigurationException, SQLException {
- Iterator serviceTypes = JDBCConfigurationTranslator.getComponentTypes(ComponentType.SERVICE_COMPONENT_TYPE_CODE, results).iterator();
- ComponentType serviceType = null;
- while (serviceTypes.hasNext()){
- serviceType = (ComponentType)serviceTypes.next();
- prodType = editor.addServiceComponentType(prodType, serviceType);
- }
- return prodType;
- }
-*/
-
-
- public Collection getComponenTypeDefinitions(ComponentTypeID componentTypeID ) throws ConfigurationException{
-
- ConfigurationModelContainer config = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
- ComponentType t = config.getComponentType(componentTypeID.getFullName());
- if (t!= null) {
- return t.getComponentTypeDefinitions();
- }
- return Collections.EMPTY_LIST;
-
- }
-
- /**
- * The results should contain 1 or more rows of property defn information. Only the
- * uid will obtained from the results in order to get the allowed values.
- */
-/*
- private List getPropertyDefnAllowedValues(ComponentTypeDefnID typeDefnID, ComponentTypeID typeID, UniqueID uniqueID ) throws ConfigurationException{
-
- if ( jdbcConnection == null) {
- throw new ConfigurationException("The current (JDBC) configuration reader is not connected");
- }
-
- List result = null;
- String sql = null;
- PreparedStatement statement = null;
- try {
-
- sql = JDBCConfigurationTranslator.SELECT_ALL_PROPERTY_DEFN_ALLOWED_VALUES;
- statement = jdbcConnection.prepareStatement(sql);
- statement.setInt(1, (int)uniqueID.getValue());
-
- if ( ! statement.execute() ) {
- throw new ConfigurationException("Failed to execute the query \"" + sql + "\"");
- }
- ResultSet resultValues = statement.getResultSet();
-
- if (resultValues.next()) {
- result = JDBCConfigurationTranslator.getPropertyDefnAllowedValues(typeDefnID, typeID, resultValues);
- }
-
- } catch ( SQLException e ) {
- throw new ConfigurationException(e, "Failed to execute the query \"" + sql + "\" with parameter(s) \"" + uniqueID + "\" and/or process the results");
- } catch ( Exception e ) {
- if (e instanceof ConfigurationException){
- throw (ConfigurationException)e;
- }
- throw new ConfigurationException(e);
- } finally {
- if ( statement != null ) {
- try {
- statement.close();
- statement=null;
- } catch ( SQLException e ) {
- e.printStackTrace();
- System.out.println("Unable to close the statement for query \"" + sql + "\"");
- }
- }
- }
-
- return result;
- }
-*/
-
-
- /**
- * Returns a UIDCollection of all the deployed components for the configuration. These
- * components will be complete with properties
- */
- public List getDeployedComponents(ConfigurationID configurationID ) throws ConfigurationException {
- // 1st get the deployed components and then add their properties
-
- ConfigurationModelContainer config = getConfigurationModel(configurationID);
-
-
- Collection dcs = config.getConfiguration().getDeployedComponents();
- List result = new LinkedList();
- result.addAll(dcs);
- return result;
-
- }
-
-/*
- public Map getResourcesProperties() throws ConfigurationException{
- return configMgr.getResourcesProperties();
- }
-*/
- /**
- * @returns Collection of type ResourceDescriptor
- */
- public Collection getResources() throws ConfigurationException{
- ConfigurationModelContainer cmc = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
-
- return cmc.getResources();
-
- }
-
-
- public SharedResource getResource(String resourceName ) throws ConfigurationException {
- ConfigurationModelContainer cmc = getConfigurationModel(Configuration.NEXT_STARTUP_ID);
-
- return cmc.getResource(resourceName);
-
- }
-
- /**
- * Returns the int startup state, use constants in
- * {@link com.metamatrix.common.config.StartupStateController} to
- * interpret the meaning
- */
- public int getServerStartupState() throws ConfigurationException{
- return configMgr.getServerStartupState();
- }
-
-
-
- public boolean doesResourceExist(String resourceName ) throws ConfigurationException {
- SharedResource rd = getResource(resourceName);
- return rd != null;
- }
-
-
- public boolean isDefinitionDeployable(ComponentDefnID defnID ) throws ConfigurationException{
- ComponentDefn defn = getComponentDefinition(defnID);
-
- ComponentType type = getComponentType(defn.getComponentTypeID());
-
- return type.isDeployable();
- }
-
- // ------------------------------------------------------------------------
- // PRIVATE METHODS
- // ------------------------------------------------------------------------
-/*
- private ComponentDefn getComponentDefinition(String componentName, String parentName, Connection jdbcConnection) throws ConfigurationException{
- Configuration config = getConfigurationByName(parentName);
-
-
- ComponentDefnID id = editor.
-
-
-
- return null;
- }
-*/
-// /**
-// * return true if the passed result set is the Connector component type or
-// * it is a sub type of the Connector component type.
-// */
-// private boolean isComponentTypeOfTypeConnector(ComponentType type) throws ConfigurationException, SQLException {
-// return isComponentTypeOfIndicatedType(type, ConnectorBindingType.COMPONENT_TYPE_NAME);
-// }
-//
-// /**
-// * return true if the passed result set is the Service component type or
-// * it is a sub type of the Service component type.
-// */
-// private boolean isComponentTypeOfTypeService(ComponentType type ) throws ConfigurationException, SQLException {
-// return isComponentTypeOfIndicatedType(type, ServiceComponentType.COMPONENT_TYPE_NAME);
-// }
-//
-// /**
-// * Return true if the passed result set is the Product component type or
-// * it is a sub type of the Product component type.
-// */
-// private boolean isComponentTypeOfTypeProduct(ComponentType type ) throws ConfigurationException, SQLException {
-// return isComponentTypeOfIndicatedType(type, ProductType.COMPONENT_TYPE_NAME);
-// }
-
-// /**
-// * return true if the passed result set if is the Resource component type or
-// * it is a sub type of the Resource component type.
-// */
-// private boolean isComponentTypeofTypeResource(ComponentType type ) throws ConfigurationException, SQLException {
-// return isComponentTypeOfIndicatedType(type, SharedResourceComponentType.COMPONENT_TYPE_NAME);
-// }
-
-// /**
-// * Return true if the passed result set is the indicated component type or
-// * it is a sub type of the indicated component type.
-// * @param typeName indicated type name
-// */
-// private boolean isComponentTypeOfIndicatedType(ComponentType type , String typeName) throws ConfigurationException, SQLException {
-//
-// String name = type.getFullName();
-// // if the result row is a service type then return true
-// if (name.equals(typeName)) {
-// return true;
-// }
-//
-// String superName = type.getSuperComponentTypeID().getFullName();
-//
-// // traverse the super type hierarchy to determine
-// // if this result row has a super type of indicated type
-// while (true) {
-// if (superName == null) {
-// return false;
-// } else if (superName.equals(typeName)) {
-// return true;
-// }
-//
-// type = getComponentType(type.getSuperComponentTypeID());
-//
-// superName = type.getSuperComponentTypeID().getFullName();
-// }
-// }
-
-
-// /**
-// * return true if the passed result set is the Service component type or
-// * it is a super class of the Service component type.
-// */
-// private boolean isComponentTypeOfTypeConfiguration(ComponentType type) throws ConfigurationException, SQLException {
-//
-// // if it has a supername then it is not part of the configuration types
-// String superName = type.getSuperComponentTypeID().getFullName();
-// if (superName != null) {
-// return false;
-// } else {
-// String name = type.getFullName();
-// if (name.equals(ServiceComponentType.COMPONENT_TYPE_NAME)) {
-// return false;
-// }
-//
-// return true;
-// }
-// }
-
-
- /**
- * Returns ID of one of the well-known
- * {@link SystemConfigurationNames system configurations}, either
- * the
- * {@link SystemConfigurationNames#OPERATIONAL operational configuration},
- * the
- * {@link SystemConfigurationNames#NEXT_STARTUP next startup configuration},
- * or the
- * {@link SystemConfigurationNames#STARTUP startup configuration}. Use
- * {@link SystemConfigurationNames} to supply the String parameter. Will
- * return null if the designation parameter is invalid.
- * @param designation String indicating which of the system configurations
- * is desired; use one of the {@link SystemConfigurationNames} constants
- * @param jdbcConnection connection to the proper config database
- * @return the desired ConfigurationID
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public ConfigurationID getDesignatedConfigurationID(String designation ) throws ConfigurationException{
- // This was changed to public so installation could use the method
-
- if (designation.startsWith(Configuration.NEXT_STARTUP) ) {
- return Configuration.NEXT_STARTUP_ID;
- } else if (designation.startsWith(Configuration.STARTUP)) {
- return Configuration.STARTUP_ID;
- } else {
- throw new ConfigurationException(ConfigMessages.CONFIG_0128, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0128, designation ));
- }
-
-
- }
-
-
-
-
- /**
- * used specifically by the CurrentConfiguration via
- * JDBCCurrentConfigurationReader
- */
- public Properties getDesignatedConfigurationProperties(String designation ) throws ConfigurationException{
-
- ConfigurationModelContainer config = getConfigurationModel(getDesignatedConfigurationID(designation));
-
- return config.getConfiguration().getProperties();
-
- }
-
-
-
- /**
- * Returns the Configuration for the given name, or null if the ID is
- * invalid.
- * @param name of a valid Configuration
- * @param configurationID ID of a valid Configuration
- * @return jdbcConnection Connection to the configuration data source
- * @throws ConfigurationException if a problem occurs communicating with
- * the data source
- */
- public Configuration getDesignatedConfiguration(String name) throws ConfigurationException {
- ConfigurationID id = getDesignatedConfigurationID(name);
-
- return getDesignatedConfiguration(id);
-
- }
-
- public ConfigurationModelContainer getConfigurationModel(ConfigurationID configID) throws ConfigurationException {
- ConfigurationModelContainer config = configMgr.getConfigurationModel(configID);
-
- return config;
- }
-
-
- /**
- * Returns one of the well-known
- * {@link SystemConfigurationNames system configurations}, either
- * the
- * {@link SystemConfigurationNames#OPERATIONAL operational configuration},
- * the
- * {@link SystemConfigurationNames#NEXT_STARTUP next startup configuration},
- * or the
- * {@link SystemConfigurationNames#STARTUP startup configuration}. Use
- * {@link SystemConfigurationNames} to supply the String parameter. Will
- * return null if the designation parameter is invalid.
- * @param designation String indicating which of the system configurations
- * is desired; use one of the {@link SystemConfigurationNames} constants
- * @return the desired Configuration
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public Configuration getDesignatedConfiguration(ConfigurationID configurationID ) throws ConfigurationException{
-
- ConfigurationModelContainer model = getConfigurationModel(configurationID);
-
- return model.getConfiguration();
-
- }
-
-
- public Collection getMonitoredComponentTypes(boolean includeDeprecated) throws ConfigurationException{
- return Collections.EMPTY_LIST;
- }
-
- public ConfigUserTransaction getTransaction(String principal) throws ConfigTransactionException {
- ConfigUserTransaction userTrans = null;
- try {
-
- userTrans = factory.createReadTransaction(principal);
-
- userTrans.begin();
-
- return userTrans;
-
- } catch (TransactionException te) {
- if (userTrans != null) {
- try {
- userTrans.rollback();
- } catch (Exception e) {
- }
-
- }
- if (te instanceof ConfigTransactionException) {
- throw (ConfigTransactionException) te;
- }
-
-
- throw new ConfigTransactionException(te, ConfigMessages.CONFIG_0129, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0129, principal));
-
- }
-
-
- }
-
-
-
-}
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationTransaction.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationTransaction.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationTransaction.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import com.metamatrix.common.id.TransactionID;
-import com.metamatrix.common.transaction.TransactionException;
-import com.metamatrix.common.transaction.TransactionStatus;
-
-public class XMLConfigurationTransaction extends ConfigTransaction {
-
- private XMLConfigurationMgr configMgr;
-
- public XMLConfigurationTransaction(XMLConfigurationMgr mgr, TransactionID txnID, long defaultTimeoutSeconds) {
- super(txnID, defaultTimeoutSeconds);
- this.configMgr = mgr;
- }
-
- /**
- * Complete the transaction represented by this TransactionObject.
- * @throws TransactionException if the transaction is unable to commit.
- */
- public void commit() throws TransactionException{
- super.commit();
-
- if (getStatus() == TransactionStatus.STATUS_COMMITTED) {
- if ( isReadOnly() ) {
- return;
- }
- configMgr.applyTransaction(this);
- }
-
- }
-
- public void rollback() throws TransactionException{
- try {
- super.rollback();
- } finally {
- configMgr.rollbackTransaction();
- }
- }
-
-}
-
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationWriter.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationWriter.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,360 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import com.metamatrix.common.actions.ActionDefinition;
-import com.metamatrix.common.actions.CreateObject;
-import com.metamatrix.common.actions.DestroyObject;
-import com.metamatrix.common.config.StartupStateException;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
-import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
-import com.metamatrix.common.connection.ManagedConnection;
-import com.metamatrix.common.transaction.TransactionException;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.platform.config.ConfigMessages;
-import com.metamatrix.platform.config.ConfigPlugin;
-
-public class XMLConfigurationWriter {
-
-
- private static XMLConfigurationMgr configMgr = XMLConfigurationMgr.getInstance();
-
- private XMLConfigurationReader reader = null;
-
- private ConfigUserTransactionFactory factory;
- private ManagedConnection mgdConnection;
- private XMLActionUpdateStrategy updateStrategy = new XMLActionUpdateStrategy();
-
-
- public XMLConfigurationWriter(ManagedConnection mgdConnection) {
- this.mgdConnection = mgdConnection;
-
-
- factory = new ConfigUserTransactionFactory();
-
- }
-
-/*
- public void insertResource(String resourceName, ConfigTransaction transaction) throws ConfigurationException, ConfigTransactionException{
-
- ArgCheck.isNotNull(resourceName, "Unable to insert resource, the resource name is null");
- validateLock(transaction);
-
- // both models are added because changes are applied across the board
- addConfigurationToTransaction(Configuration.NEXT_STARTUP, transaction);
- addConfigurationToTransaction(Configuration.OPERATIONAL, transaction);
-
- updateStrategy.insertResource(resourceName, transaction);
- }
-
- public void insertResourceProperties(String resourceName, Properties properties, ConfigTransaction transaction) throws ConfigurationException, ConfigTransactionException{
- ArgCheck.isNotNull(resourceName, "Unable to insert resource properties, the resource name is null");
- ArgCheck.isNotNull(properties, "Unable to insert resource, the resource properties are null");
- validateLock(transaction);
-
- // both models are added because changes are applied across the board
-
- addConfigurationToTransaction(Configuration.NEXT_STARTUP, transaction);
- addConfigurationToTransaction(Configuration.OPERATIONAL, transaction);
-
- updateStrategy.insertResourceProperties(resourceName, properties, transaction);
- }
-*/
- public void updateSharedResource(SharedResource resource, ConfigTransaction transaction) throws ConfigurationException, ConfigTransactionException{
- validateLock(transaction);
-
- if(resource == null){
- ArgCheck.isNotNull(resource, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0130));
- }
-
- updateStrategy.updateSharedResource(resource, transaction);
-
- }
-
- // ----------------------------------------------------------------------------------------
- // S Y S T E M S T A R T U P S T A T E M E T H O D S
- // ----------------------------------------------------------------------------------------
-
- /**
- * Called by {@link XMLCurrentConfigurationReader#performSystemInitialization}
- *
- * NOTE - This is a self contained transaction, the calling class cannot
- * control the transaction
- *
- * @see XMLCurrentConfigurationReader#performSystemInitialization
- */
- public void performSystemInitialization(ConfigTransaction transaction) throws StartupStateException, ConfigurationException{
- validateLock(transaction);
-
- configMgr.performSystemInitialization(transaction);
-
- }
-
- public void beginSystemInitialization(boolean forceInitialization, ConfigTransaction transaction) throws StartupStateException, ConfigurationException{
- validateLock(transaction);
-
-
- if (forceInitialization) {
-
- transaction.setAction(ConfigTransaction.SERVER_FORCE_INITIALIZATION);
- } else {
- transaction.setAction(ConfigTransaction.SERVER_INITIALIZATION);
- }
-
- configMgr.setServerStateToStarting(forceInitialization);
-
- }
-
- /**
- * Called by {@link JDBCCurrentConfigurationReader#finishSystemInitialization}
- * @see JDBCCurrentConfigurationReader#finishSystemInitialization
- */
-
- public void finishSystemInitialization(ConfigTransaction transaction) throws StartupStateException, ConfigurationException{
- validateLock(transaction);
-
- configMgr.setServerStateToStarted();
-
- }
-
- /**
- * Called by {@link XMLCurrentConfigurationReader#indicateSystemShutdown}
- * @see XMLCurrentConfigurationReader#indicateSystemShutdown
- */
- public void indicateSystemShutdown(ConfigTransaction transaction) throws StartupStateException, ConfigurationException{
- validateLock(transaction);
-
- transaction.setAction(ConfigTransaction.SERVER_SHUTDOWN);
- configMgr.setServerStateToStopped();
- //NOTE: when the transaction is committed, the change will be applied to the persistent layer
-//
-
- }
-
- /**
- * Called by {@link JDBCCurrentConfigurationReader#beginSystemInitialization}
- * @see JDBCCurrentConfigurationReader#beginSystemInitialization
- */
-/*
- public void initializeConfigurations(ConfigTransaction transaction) throws StartupStateException, ConfigurationException{
- }
-*/
-
- // ----------------------------------------------------------------------------------------
- // C O N F I G U R A T I O N U P D A T E M E T H O D S
- // ----------------------------------------------------------------------------------------
-
- /**
- * Overwrite the specified configuration by copying another configuration
- * over it. This includes assigning any
- * {@link #getDesignatedConfiguration designations}
- * of the configuration to be overwritten to the configuration to
- * be copied. Both configurations must already be in the data source.
- * (This method is needed to implement baselining).
- * @param configToCopy the ConfigurationID of the Configuration to be
- * copied
- * @param configToCopy the ConfigurationID of the Configuration to be
- * deleted - the "configToCopy" will be overwritten in its place.
- * @return the new ID of the newly-copied Configuration
- * @throws InvalidConfigurationException if either ConfigurationID is invalid.
- * @throws ConfigurationException if an error occurred within or during communication with the Configuration Service.
- */
- public ConfigurationID overwriteConfiguration(ConfigurationID configIDToCopy, ConfigurationID configIDToOverwrite, ConfigTransaction transaction) throws InvalidConfigurationException, ConfigurationException{
- throw new UnsupportedOperationException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0131));
-/*
- validateLock(transaction);
-
- configMgr.overwriteConfiguration(configIDToCopy, configIDToOverwrite, transaction);
- return configIDToOverwrite;
-*/
- }
-
-
- /**
- * Executes the list of actions, returns the Set of affected objects.
- * This is assumed one logical transaction.
- * @return Set of affected configuration objects
- */
- public Set executeActions(List actions, ConfigTransaction transaction) throws ConfigTransactionException, ConfigurationLockException, ConfigurationException {
- validateLock(transaction);
-
- if(actions == null){
- ArgCheck.isNotNull(actions, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045, "actions")); //$NON-NLS-1$
- }
- if(transaction == null){
- ArgCheck.isNotNull(transaction, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045, "transaction")); //$NON-NLS-1$
- }
-
-
- Set result = new HashSet();
-
- if ( actions.isEmpty() ) {
- return result;
- }
-
- List actionsWithSameTarget = new ArrayList(13); // guessing at an initial size, probably high
- Object currentTarget = null;
- ActionDefinition currentAction = null;
- ActionDefinition nextAction = null;
-
- int actionCounter = -1;
-
- // Iterate through the actions, and apply all as a single transaction
- try {
- boolean createObject = false;
-
- // Get the first action and its target, and add it to the list ...
- Iterator iter = actions.iterator();
- if ( iter.hasNext() ) {
- currentAction = (ActionDefinition) iter.next();
- currentTarget = currentAction.getTarget();
- actionsWithSameTarget.add(currentAction);
- }
-
-//System.out.println("WRITER: Iterater Actions " + actions.size());
- while ( iter.hasNext() ) {
- nextAction = (ActionDefinition) iter.next();
- if ( currentAction instanceof CreateObject ) {
- createObject = true;
- }
-
- // If the current action is a 'DestroyObject' action, then process only
- // the destroy (other actions not processed up to this point do not
- // need to be processed, since the target will be destroyed anyway).
- if ( currentAction instanceof DestroyObject ) {
- // If creating and destroying an object in the same action list,
- // then don't need to do anything ...
- if ( !createObject ) {
- result.addAll( executeActionsOnTarget( currentTarget,actionsWithSameTarget,transaction) );
- }
- actionCounter += actionsWithSameTarget.size();
- actionsWithSameTarget.clear();
- createObject = false;
- currentTarget = nextAction.getTarget();
- }
-
- // Otherwise, if the next action has another target, process up to the current action ...
- else if ( currentTarget != nextAction.getTarget() ) {
-
- result.addAll( executeActionsOnTarget( currentTarget,actionsWithSameTarget,transaction) );
- actionCounter += actionsWithSameTarget.size();
- actionsWithSameTarget.clear();
- createObject = false;
- currentTarget = nextAction.getTarget();
- }
-
- // Add this next action ...
- currentAction = nextAction;
- actionsWithSameTarget.add(currentAction);
- }
-
- // Process the last set of actions ...
- if ( actionsWithSameTarget.size() != 0 ) {
-
- result.addAll( executeActionsOnTarget(currentTarget,actionsWithSameTarget,transaction) );
- createObject = false;
- }
-
- } catch ( Exception e ) {
- throw new ConfigurationException(e);
- }
- return result;
-
- }
-
-
- /**
- * Executes the specified transactions, which must all be applied to the same target, using
- * the specified transaction.
- */
- private Set executeActionsOnTarget( Object target, List actions, ConfigTransaction transaction )
- throws ConfigTransactionException, ConfigurationLockException, ConfigurationException {
- // System.out.println("WRITER: Execute on target " + target);
-
- Set results = updateStrategy.executeActionsOnTarget(target, actions, transaction);
-
- return results;
-
- }
-
-
- protected ConfigUserTransaction getTransaction(String principal) throws ConfigTransactionException, ConfigurationException {
- ConfigUserTransaction trans = XMLConfigurationWriter.getWriteTransactionWithRetry(principal, factory);
- ConfigTransaction transaction = trans.getTransaction();
- ConfigurationID configID = getConfigurationReader().getDesignatedConfigurationID(Configuration.NEXT_STARTUP);
- ConfigurationModelContainer transconfig = configMgr.getConfigurationModelForTransaction(configID);
- transaction.addObjects(configID.getFullName(), transconfig);
-
-
-
- return trans;
- }
-
-
-
- protected XMLConfigurationReader getConfigurationReader() {
- if (reader == null) {
- reader = new XMLConfigurationReader(mgdConnection);
- }
- return reader;
- }
-
-
- private void validateLock(ConfigTransaction transaction) throws ConfigurationLockException {
-
- if (transaction == null) {
- throw new ConfigurationLockException(ConfigMessages.CONFIG_0123, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0123));
- }
-
- }
-
- public static ConfigUserTransaction getWriteTransactionWithRetry(String principal, ConfigUserTransactionFactory factory ) throws ConfigTransactionException {
- try {
-
- ConfigUserTransaction userTrans = factory.createWriteTransaction(principal);
-
- userTrans.begin();
- return userTrans;
-
- } catch (TransactionException te) {
- throw new ConfigTransactionException(te, ConfigMessages.CONFIG_0162, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0162, principal));
- }
- }
-
-}
-
-
-
-
-
Modified: trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLCurrentConfigurationReader.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLCurrentConfigurationReader.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLCurrentConfigurationReader.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,275 +22,18 @@
package com.metamatrix.platform.config.spi.xml;
-import java.util.Properties;
-
-import com.metamatrix.common.config.StartupStateException;
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.common.config.api.exceptions.ConfigurationConnectionException;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.config.reader.CurrentConfigurationReader;
-import com.metamatrix.common.connection.ManagedConnection;
-import com.metamatrix.common.transaction.TransactionException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.platform.config.ConfigMessages;
-import com.metamatrix.platform.config.ConfigPlugin;
public class XMLCurrentConfigurationReader implements CurrentConfigurationReader {
- /**
- * The date of installation of the MetaMatrix suite
- */
- public static final String INSTALL_DATE = "metamatrix.config.installationDate"; //$NON-NLS-1$
-
- private static final String PRINCIPAL = "CurrentConfiguration"; //$NON-NLS-1$
-
- private static XMLConfigurationMgr configMgr = XMLConfigurationMgr.getInstance();
-
- private XMLConfigurationReader reader = null;
- private XMLConfigurationWriter writer = null;
-
-
-
- public XMLCurrentConfigurationReader() {
- }
-
-
- /**
- * This method should connect to the repository that holds the current
- * configuration, using the specified properties. The implementation
- * may <i>not</i> use logging but instead should rely upon returning
- * an exception in the case of any errors.
- * @param env the environment properties that define the information
- * @throws ConfigurationConnectionException if there is an error establishing the connection.
- */
- public synchronized void connect( Properties env ) throws ConfigurationConnectionException{
- try {
- // this needs to be done first before readers and writers use it.
- configMgr.init(env);
-
-
- } catch(Exception e) {
- e.printStackTrace();
- throw new ConfigurationConnectionException(e, ConfigMessages.CONFIG_0133, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0133));
-
- }
-
-
- try {
- XMLConfigurationConnectorFactory factory = new XMLConfigurationConnectorFactory();
- ManagedConnection mc = factory.createConnection(env, PRINCIPAL);
-
- if(mc == null){
- Assertion.isNotNull(mc, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0135));
- }
-
- this.reader = new XMLConfigurationReader(mc);
- this.writer = new XMLConfigurationWriter(mc);
-
- if(reader == null){
- Assertion.isNotNull(reader, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0136));
- }
- if(writer == null){
- Assertion.isNotNull(writer, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0137));
- }
-
- } catch(Exception e) {
- e.printStackTrace();
- throw new ConfigurationConnectionException(e, ConfigMessages.CONFIG_0138, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0138));
-
- }
-
-
- }
-
-
- /**
- * This method should close the connection to the repository that holds the current
- * configuration. The implementation may <i>not</i> use logging but
- * instead should rely upon returning an exception in the case of any errors.
- * @throws Exception if there is an error establishing the connection.
- */
-
- public void close() throws Exception{
- /*
- if ( this.connection != null ) {
- try{
- this.connection.close();
- } catch (SQLException e) {
- throw new ConfigurationConnectionException(e, "JDBCCurrentConfigurationReader - could not close connection");
- }
- this.connection = null;
- }
- */
- }
-
- // ------------------------------------------------------------------------------------
- // C O N F I G U R A T I O N I N F O R M A T I O N
- // ------------------------------------------------------------------------------------
-
- /**
- * Obtain the properties for the current configuration. The implementation
- * may <i>not</i> use logging but instead should rely upon returning
- * an exception in the case of any errors.
- * @return the properties
- * @throws ConfigurationException if an error occurred within or during
- * communication with the repository.
- */
- public Properties getConfigurationProperties() throws ConfigurationException{
- Properties result = getConfigurationReader().getDesignatedConfigurationProperties(Configuration.NEXT_STARTUP);
-
- if ( result == null ) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0139, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0139));
- }
-
- return result;
- }
-
- /**
- * Obtain the next startup configuration. The implementation
- * may <i>not</i> use logging but instead should rely upon returning
- * an exception in the case of any errors.
- * @return the serializable Configuration instance
- * @throws ConfigurationException if an error occurred within or during
- * communication with the repository.
- */
-
- public Configuration getNextStartupConfiguration() throws ConfigurationException {
- return getConfigurationReader().getDesignatedConfiguration(Configuration.NEXT_STARTUP_ID);
- }
-
- /**
- * Obtain the next startup configuration model. The implementation
- * may <i>not</i> use logging but instead should rely upon returning
- * an exception in the case of any errors.
- * @return the serializable Configuration instance
- * @throws ConfigurationException if an error occurred within or during
- * communication with the repository.
- */
- public ConfigurationModelContainer getConfigurationModel() throws ConfigurationException {
- return getConfigurationReader().getConfigurationModel(Configuration.NEXT_STARTUP_ID);
- }
-
- public synchronized void performSystemInitialization(boolean forceInitialization) throws StartupStateException, ConfigurationException {
-
- /*
-
-
- the basic process is this:
-- The performInitialization process will obtain a lock using the user of "SystemInitialization"
-- The state of server should be STOPPED
-- Set the startup state to STARTING
-- The lock will be registered with userName, Start Date/Time of Lock, Expiration of Lock
-- Initialize the models
-- Set the startup state to STARTED
-- Release the lock
-
-if the process ends abrubtly and the state doesn't get changed, here's how it can be handled:
-- The performInitialization process is started again
-- Get the current state of the server
- - if state = STOPPED
- - if can obtain lock then perform system initialization
- otherwise
- - if another user already has a lock then see performLockCheck ROUTINE
-
- - if state = STARTING
- - if no lock is held then proceed to perform system initialization (This assumes the system never previously fully started)
- or
- - if another user already has a lock then see performLockCheckK ROUTINE
-
- - if state = STARTED
- - if no lock is held then perform system initialization (this assumes the user wants to restart the server - i.e., bounce or when a server stops abrubtly and the state never gets set back to stopped)
- This is also making the assumption that only one server in a clustered environment should have called the startserver.
- However,, it doesn't hurt if they do, it just means the NextStartup model will be copied to Startup.
- - if another user already has a lock then see performLockCheck ROUTINE
-
- */
-
- boolean force = !configMgr.isServerStopped();
-
- ConfigUserTransaction inittrans = null;
- try {
- inittrans = getWriteTransaction();
-
- ConfigTransaction cfgt = inittrans.getTransaction();
-
- getConfigurationWriter().beginSystemInitialization(force, cfgt);
-
- getConfigurationWriter().performSystemInitialization(cfgt);
-
- getConfigurationWriter().finishSystemInitialization(cfgt);
-
- inittrans.commit();
-
- } catch(TransactionException te) {
- if (inittrans != null) {
- rollbackTransaction(inittrans);
- }
-
- throw new ConfigurationException(te, ConfigMessages.CONFIG_0143, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0143));
-
- }
-
+
+ @Override
+ public ConfigurationModelContainer getConfigurationModel()
+ throws ConfigurationException {
+ return XMLConfigurationMgr.getInstance().getConfigurationModel(Configuration.NEXT_STARTUP_ID);
}
- /**
- * @see com.metamatrix.common.config.reader.CurrentConfigurationInitializer#indicateSystemShutdown
- */
- public synchronized void indicateSystemShutdown() throws ConfigurationException{
-
- ConfigUserTransaction trans = null;
- try {
- trans = getWriteTransaction();
- getConfigurationWriter().indicateSystemShutdown(trans.getTransaction());
- trans.commit();
- } catch(StartupStateException sse) {
- if (trans != null) {
- try {
- trans.rollback();
-
- } catch(Exception e) {
- }
- }
-
- throw new ConfigurationException(sse, ConfigMessages.CONFIG_0143, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0143));
-
-
- } catch(TransactionException te) {
- if (trans != null) {
- try {
- trans.rollback();
-
- } catch(Exception e) {
- }
- }
-
- throw new ConfigurationException(te, ConfigMessages.CONFIG_0143, ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0143));
-
- }
-
- }
-
- private void rollbackTransaction(ConfigUserTransaction trans) {
- try {
- trans.rollback();
-
- } catch(Exception e) {
- }
- }
-
- protected ConfigUserTransaction getWriteTransaction() throws ConfigTransactionException, ConfigurationException {
-
- return getConfigurationWriter().getTransaction(PRINCIPAL);
- }
-
- protected XMLConfigurationReader getConfigurationReader() {
- return this.reader;
- }
-
- protected XMLConfigurationWriter getConfigurationWriter() {
- return this.writer;
- }
-
-
}
Added: trunk/server/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java (rev 0)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2000-2007 MetaMatrix, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.platform.config.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+import com.metamatrix.common.config.CurrentConfiguration;
+import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.config.api.ConfigurationID;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.platform.config.persistence.api.PersistentConnection;
+import com.metamatrix.platform.config.persistence.api.PersistentConnectionFactory;
+import com.metamatrix.platform.config.persistence.impl.file.FilePersistentConnection;
+import com.metamatrix.platform.config.spi.xml.XMLCurrentConfigurationReader;
+
+/**
+ * The CurrentConfigHelper is used to load a configuration into memory when a repository isn't available.
+ * @author vanhalbert
+ *
+ */
+public class CurrentConfigHelper {
+
+ public void loadMetaMatrixPropertiesIntoSystem() throws Exception {
+ loadMetaMatrixPropertiesIntoSystem("metamatrix.properties"); //$NON-NLS-1$
+ }
+
+ public void loadMetaMatrixPropertiesIntoSystem(String filename) throws Exception {
+ Properties bootstrapProps = new Properties();
+ InputStream bootstrapPropStream = new FileInputStream(new File(filename));
+ bootstrapProps.load(bootstrapPropStream);
+ bootstrapProps.remove(CurrentConfiguration.CONFIGURATION_READER_CLASS_PROPERTY_NAME);
+
+ Properties sys = System.getProperties();
+ sys.putAll(bootstrapProps);
+ System.setProperties(sys);
+ }
+
+
+ /**
+ * init will do the following:
+ * <li>remove existing config_ns.xml file</li>
+ * <li>set required system properties for CurrentConfiguration<li>
+ * <li>reload CurrentConfiguration with new information from <code<fileName</code>
+ * @param fileName is the configuration file to use; if contains full path, set path to null
+ * @param path can optionally specify the path seperate from the fileName
+ * @param principal is the user initializing configuration
+
+ */
+ public static void initConfig(String fileName, String path, String principal) throws Exception {
+ Properties sysProps = new Properties();
+ initConfig(fileName, path, sysProps, principal);
+ }
+
+ public static void initXMLConfig(String fileName, String path, String principal) throws Exception {
+ Properties sysProps = new Properties();
+ sysProps.put(CurrentConfiguration.CONFIGURATION_READER_CLASS_PROPERTY_NAME, XMLCurrentConfigurationReader.class.getName());
+ initConfig(fileName, path, sysProps, principal);
+ }
+
+ /**
+ * init will do the following:
+ * <li>remove existing config_ns.xml file</li>
+ * <li>set required system properties for CurrentConfiguration<li>
+ * <li>reload CurrentConfiguration with new information from <code<fileName</code>
+ * @param fileName is the configuration file to use; if contains full path, set path to null
+ * @param path can optionally specify the path seperate from the fileName
+ * @param properties will be set as the System properties
+ * @param principal is the user initializing configuration
+ */
+ static void initConfig(String fileName, String path, Properties properties, String principal) throws Exception {
+ File f = new File(path, fileName);
+ if (!f.exists()) {
+ throw new Exception("Configuration file " + f.getAbsolutePath() + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ Properties sysProps = PropertiesUtils.clone(System.getProperties(), false);
+
+ sysProps.putAll(properties);
+ System.setProperties(sysProps);
+
+ cleanModelFile(principal, fileName, path);
+ CurrentConfiguration.reset();
+
+ createSystemProperties(fileName, path);
+
+ CurrentConfiguration.getInstance().getConfiguration();
+ }
+
+
+
+ protected static void cleanModelFile(String principal, String fileName, String path) throws Exception {
+ Properties props = createSystemProperties(fileName, path);
+
+ deleteModel(Configuration.NEXT_STARTUP_ID, props, principal);
+
+ }
+
+ protected static Properties createSystemProperties(String fileName, String path) {
+ Properties props = new Properties();
+
+ if (fileName != null) {
+ props.setProperty(FilePersistentConnection.CONFIG_NS_FILE_NAME_PROPERTY, fileName );
+ props.setProperty(PersistentConnectionFactory.PERSISTENT_FACTORY_NAME, PersistentConnectionFactory.FILE_FACTORY_NAME);
+ }
+
+ if (path != null) {
+ props.setProperty(FilePersistentConnection.CONFIG_FILE_PATH_PROPERTY, path );
+ }
+
+ // these system props need to be set for the CurrentConfiguration call
+
+ Properties sysProps = System.getProperties();
+ sysProps.putAll(props);
+ System.setProperties(sysProps);
+
+ return props;
+ }
+
+ public static void deleteModel(ConfigurationID configID, Properties props,
+ String principal) throws Exception {
+
+ PersistentConnectionFactory pf = new PersistentConnectionFactory(props);
+
+ PersistentConnection readin = pf.createPersistentConnection(false);
+
+ readin.delete(configID, principal);
+ readin.commit();
+ readin.close();
+
+ }
+
+
+}
Property changes on: trunk/server/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessRegistryBinding.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessRegistryBinding.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessRegistryBinding.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -42,6 +42,8 @@
private String processName;
private boolean alive;
+
+ private long startTime = System.currentTimeMillis();
/**
* Local reference to VMController, this is transient to prevent it from
@@ -126,5 +128,13 @@
public String toString() {
return "Process<" +this.hostName+"|"+ this.processName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
+
+ public long getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(long startTime) {
+ this.startTime = startTime;
+ }
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/AuditMessage.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -27,11 +27,11 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import com.metamatrix.common.util.VMNaming;
+import com.metamatrix.common.config.CurrentConfiguration;
public class AuditMessage implements Externalizable {
- public static final String PROCESS_NAME = VMNaming.getProcessName();
- public static final String HOST_NAME = VMNaming.getConfigName();
+ public static final String PROCESS_NAME = CurrentConfiguration.getInstance().getProcessName();
+ public static final String HOST_NAME = CurrentConfiguration.getInstance().getConfigurationName();
private static final String RESOURCE_DELIMITER = ", "; //$NON-NLS-1$
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/SingleFileAuditDestination.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -28,8 +28,8 @@
import java.util.List;
import java.util.Properties;
+import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.security.audit.AuditMessage;
@@ -119,7 +119,7 @@
int index = fileName.indexOf(VM_NAME_TOKEN);
if ( index != -1 ) {
StringBuffer tempFileName = new StringBuffer(fileName);
- String processName = VMNaming.getConfigName()+"_"+VMNaming.getProcessName(); //$NON-NLS-1$
+ String processName = CurrentConfiguration.getInstance().getConfigurationName()+"_"+CurrentConfiguration.getInstance().getProcessName(); //$NON-NLS-1$
tempFileName.replace(index,index+VM_NAME_TOKEN.length(),processName);
fileName = tempFileName.toString();
}
Modified: trunk/server/src/main/java/com/metamatrix/platform/vm/api/controller/ProcessManagement.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/vm/api/controller/ProcessManagement.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/vm/api/controller/ProcessManagement.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -23,7 +23,6 @@
package com.metamatrix.platform.vm.api.controller;
import java.net.InetAddress;
-import java.util.Date;
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.common.config.api.ServiceComponentDefnID;
@@ -77,7 +76,7 @@
/**
* Get the time the VM was initialized.
*/
- Date getStartTime();
+ long getStartTime();
/**
* Get the address of the host this VM is running on.
Modified: trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -28,7 +28,6 @@
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.EventObject;
import java.util.HashMap;
import java.util.Iterator;
@@ -47,7 +46,6 @@
import com.metamatrix.common.comm.platform.socket.server.AdminAuthorizationInterceptor;
import com.metamatrix.common.comm.platform.socket.server.LogonImpl;
import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.JDBCConnectionPoolHelper;
import com.metamatrix.common.config.api.ComponentTypeID;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.DeployedComponent;
@@ -75,7 +73,6 @@
import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.common.util.LogContextsUtil.PlatformAdminConstants;
import com.metamatrix.core.event.EventObjectListener;
import com.metamatrix.core.util.FileUtil;
@@ -98,9 +95,9 @@
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
import com.metamatrix.platform.registry.ClusteredRegistryState;
+import com.metamatrix.platform.registry.ProcessRegistryBinding;
import com.metamatrix.platform.registry.ResourceNotBoundException;
import com.metamatrix.platform.registry.ServiceRegistryBinding;
-import com.metamatrix.platform.registry.ProcessRegistryBinding;
import com.metamatrix.platform.security.api.ILogon;
import com.metamatrix.platform.security.api.service.AuthorizationServiceInterface;
import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
@@ -147,7 +144,7 @@
protected Host host;
protected String processName;
- private Date startTime;
+ private long startTime;
private Properties vmProps;
VMComponentDefn vmComponentDefn;
@@ -165,7 +162,6 @@
protected ClientServiceRegistry clientServices;
private Map<ComponentTypeID, Properties> defaultPropertiesCache = new HashMap<ComponentTypeID, Properties>();
- private Properties hostProperties;
private ClassLoader commonExtensionClassLoader = null;
private String commonExtensionClasspath;
@@ -193,10 +189,8 @@
this.startServicePool = WorkerPoolFactory.newWorkerPool("StartServiceQueue", maxThreads, timeToLive); //$NON-NLS-1$
- initVMProperties(host.getFullName(), processname);
+ initVMProperties();
- this.startTime = new Date();
-
this.clientServices = new ClientServiceRegistry();
RuntimeMetadataCatalog.getInstance().init(CurrentConfiguration.getInstance().getProperties(), ResourceFinder.getMessageBus(), ResourceFinder.getCacheFactory());
@@ -279,38 +273,33 @@
* - vmComponentDefnID
* - vmProps
*/
- private void initVMProperties(String hostname, String processName) throws Exception {
+ private void initVMProperties() throws Exception {
+ String hostname = host.getFullName();
ConfigurationModelContainer config = getConfigurationModel();
VMComponentDefn deployedVM = config.getConfiguration().getVMForHost(hostname, processName);
- if (deployedVM != null) {
- this.vmComponentDefn = deployedVM;
-
- vmProps = config.getDefaultPropertyValues(deployedVM.getComponentTypeID());
- Properties props = config.getConfiguration().getAllPropertiesForComponent(deployedVM.getID());
- vmProps.putAll(props);
-
- // this system property setting will override the setting in the VM
- // this is done because the command line argument
- force_shutdown_time = PropertiesUtils.getIntProperty(System.getProperties(), STOP_DELAY_TIME, DEFAULT_FORCE_SHUTDOWN_TIME);
- if (DEFAULT_FORCE_SHUTDOWN_TIME == force_shutdown_time) {
- force_shutdown_time = PropertiesUtils.getIntProperty(vmProps, VMComponentDefnType.FORCED_SHUTDOWN_TIME, DEFAULT_FORCE_SHUTDOWN_TIME);
- }
-
- Properties allProps = new Properties();
- allProps.putAll(System.getProperties());
- allProps.putAll(config.getConfiguration().getProperties());
- allProps.putAll(host.getProperties());
- allProps.putAll(props);
- System.setProperties(allProps);
-
- logMessage(PlatformPlugin.Util.getString("VMController.VM_Force_Shutdown_Time", force_shutdown_time)); //$NON-NLS-1$
-
- // add the vm to registry
- ProcessRegistryBinding binding = new ProcessRegistryBinding(host.getFullName(), this.processName, deployedVM, this, this.messageBus);
- this.events.processAdded(binding);
- }
+ this.vmComponentDefn = deployedVM;
+
+ vmProps = new Properties(CurrentConfiguration.getInstance().getSystemBootStrapProperties());
+ PropertiesUtils.putAll(vmProps, config.getConfiguration().getProperties());
+ PropertiesUtils.putAll(vmProps, host.getProperties());
+ PropertiesUtils.putAll(vmProps, config.getDefaultPropertyValues(deployedVM.getComponentTypeID()));
+ PropertiesUtils.putAll(vmProps, config.getConfiguration().getAllPropertiesForComponent(deployedVM.getID()));
+
+ // this system property setting will override the setting in the VM
+ // this is done because the command line argument
+ force_shutdown_time = PropertiesUtils.getIntProperty(System.getProperties(), STOP_DELAY_TIME, DEFAULT_FORCE_SHUTDOWN_TIME);
+ if (DEFAULT_FORCE_SHUTDOWN_TIME == force_shutdown_time) {
+ force_shutdown_time = PropertiesUtils.getIntProperty(vmProps, VMComponentDefnType.FORCED_SHUTDOWN_TIME, DEFAULT_FORCE_SHUTDOWN_TIME);
+ }
+
+ logMessage(PlatformPlugin.Util.getString("VMController.VM_Force_Shutdown_Time", force_shutdown_time)); //$NON-NLS-1$
+
+ // add the vm to registry
+ ProcessRegistryBinding binding = new ProcessRegistryBinding(host.getFullName(), this.processName, deployedVM, this, this.messageBus);
+ this.startTime = binding.getStartTime();
+ this.events.processAdded(binding);
}
protected void logMessage(String s) {
@@ -436,20 +425,15 @@
defaultProps = defaultPropertiesCache.get(deployedService.getComponentTypeID());
if (defaultProps == null) {
- if (hostProperties == null) {
- hostProperties = CurrentConfiguration.getInstance().getSystemBootStrapProperties();
- hostProperties = new Properties(hostProperties);
- PropertiesUtils.putAll(hostProperties, host.getProperties());
- }
- defaultProps = new Properties(hostProperties);
- defaultProps.putAll(configModel.getDefaultPropertyValues(deployedService.getComponentTypeID()));
+ defaultProps = new Properties(vmProps);
+ PropertiesUtils.putAll(defaultProps, configModel.getDefaultPropertyValues(deployedService.getComponentTypeID()));
defaultPropertiesCache.put(deployedService.getComponentTypeID(), defaultProps);
}
}
Properties serviceProps = new Properties(defaultProps);
Properties props = configModel.getConfiguration().getAllPropertiesForComponent(deployedService.getID());
- serviceProps.putAll(props);
- PropertiesUtils.setOverrideProperies(serviceProps, hostProperties);
+ PropertiesUtils.putAll(serviceProps, props);
+ PropertiesUtils.setOverrideProperies(serviceProps, vmProps);
ProductServiceConfigID pscID = deployedService.getProductServiceConfigID();
String serviceClassName = serviceProps.getProperty( ServicePropertyNames.SERVICE_CLASS_NAME );
@@ -538,7 +522,7 @@
/**
* Get the time the VM was initialized.
*/
- public Date getStartTime() {
+ public long getStartTime() {
return this.startTime;
}
@@ -770,14 +754,8 @@
String componentType = serviceProps.getProperty(ServicePropertyNames.COMPONENT_TYPE_NAME);
String serviceType = serviceProps.getProperty(ServicePropertyNames.SERVICE_NAME);
String routingID = serviceProps.getProperty(ServicePropertyNames.SERVICE_ROUTING_ID);
- String essentialStr = serviceProps.getProperty(ServicePropertyNames.SERVICE_ESSENTIAL);
+ boolean essential = PropertiesUtils.getBooleanProperty(serviceProps, ServicePropertyNames.SERVICE_ESSENTIAL, false);
-
- boolean essential = false;
- if (essentialStr != null && essentialStr.trim().length() != 0) {
- essential = Boolean.valueOf(essentialStr).booleanValue();
- }
-
// Create an instance of serviceClass
final ServiceInterface service = (ServiceInterface) Thread.currentThread().getContextClassLoader().loadClass(serviceClass).newInstance();
@@ -1000,7 +978,7 @@
public InetAddress getAddress() {
- return VMNaming.getHostAddress();
+ return CurrentConfiguration.getInstance().getHostAddress();
}
Modified: trunk/server/src/main/java/com/metamatrix/server/HostController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -37,7 +37,6 @@
import com.google.inject.name.Named;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.StartupStateController;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.VMComponentDefn;
@@ -46,9 +45,7 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.util.LogCommonConstants;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.registry.HostControllerRegistryBinding;
@@ -87,9 +84,6 @@
System.exit(-1);
}
- // normal startup.
- StartupStateController.performSystemInitialization(true);
-
createTempDirectories();
Runtime.getRuntime().addShutdownHook(new ShutdownThread());
@@ -252,22 +246,9 @@
}
try {
- LogManager.logInfo(LogCommonConstants.CTX_CONTROLLER,logMsg);
-
- Host host = null;
- try {
- host = CurrentConfiguration.getInstance().getDefaultHost();
- } catch (ConfigurationException e) {
- }
+ LogManager.logInfo(LogCommonConstants.CTX_CONTROLLER,logMsg);
+ Host host = CurrentConfiguration.getInstance().getDefaultHost();
- if (host == null) {
- LogManager.logError(LogCommonConstants.CTX_CONTROLLER,"ERROR " + PlatformPlugin.Util.getString(ErrorMessageKeys.HOST_0001)); //$NON-NLS-1$
- System.exit(-1);
- }
-
- // VMNaming used in multiple places to get the host-address
- VMNaming.setup(host.getFullName(), host.getHostAddress(), host.getBindAddress());
-
HostController hostController = loadHostcontroller(host);
if (!shutdown) {
hostController.run(startProcesses);
@@ -286,7 +267,7 @@
private static HostController loadHostcontroller(Host host) {
Injector injector = Guice.createInjector(new HostControllerGuiceModule(host));
- ResourceFinder.setInjector(injector);
+ ResourceFinder.setInjectorAndCompleteInitialization(injector);
return injector.getInstance(HostController.class);
}
@@ -491,7 +472,6 @@
if (isRootHost(hostName)) {
try {
LogManager.logInfo(LogCommonConstants.CTX_CONTROLLER, "StartVM " + processName); //$NON-NLS-1$
- CurrentConfiguration.getInstance().verifyBootstrapProperties();
ConfigurationModelContainer currentConfig = CurrentConfiguration.getInstance().getConfigurationModel();
VMComponentDefn deployedVM = currentConfig.getConfiguration().getVMForHost(this.host.getFullName(), processName);
@@ -520,9 +500,10 @@
if (isRootHost(hostName)) {
try {
+ LogManager.logInfo(LogCommonConstants.CTX_CONTROLLER,"Copying NextStartup configuration to Startup configuration."); //$NON-NLS-1$
+
hostName = this.host.getFullName();
LogManager.logInfo(LogCommonConstants.CTX_CONTROLLER,"StartAllVMs on Host " + hostName); //$NON-NLS-1$
- CurrentConfiguration.getInstance().verifyBootstrapProperties();
ConfigurationModelContainer currentConfig = CurrentConfiguration.getInstance().getConfigurationModel();
Collection deployedVMs = currentConfig.getConfiguration().getVMsForHost(hostName);
Modified: trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -36,7 +36,7 @@
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
-import com.metamatrix.common.messaging.VMMessageBus;
+import com.metamatrix.common.messaging.jgroups.JGroupsMessageBus;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.platform.registry.ClusteredRegistryState;
@@ -89,7 +89,7 @@
bind(Cache.class).toProvider(CacheProvider.class).in(Scopes.SINGLETON);
bind(CacheFactory.class).to(JBossCacheFactory.class).in(Scopes.SINGLETON);
bind(ClusteredRegistryState.class).in(Scopes.SINGLETON);
- bind(MessageBus.class).to(VMMessageBus.class).in(Scopes.SINGLETON); // VM Message bus is in common-internal
+ bind(MessageBus.class).to(JGroupsMessageBus.class).in(Scopes.SINGLETON); // VM Message bus is in common-internal
bind(HostMonitor.class).in(Scopes.SINGLETON);
}
Modified: trunk/server/src/main/java/com/metamatrix/server/JGroupsProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/JGroupsProvider.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/JGroupsProvider.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -42,7 +42,6 @@
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogCommonConstants;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.core.MetaMatrixRuntimeException;
/**
@@ -141,7 +140,7 @@
String udpMulticastAddress = configProps.getProperty(UDP_MCAST_ADDR_PROPERTY);
if (udpMulticastAddress == null || udpMulticastAddress.length() == 0) {
- String currentAddr = VMNaming.getBindAddress();
+ String currentAddr = CurrentConfiguration.getInstance().getBindAddress();
if (currentAddr.indexOf('.') != -1) {
String lastNode = currentAddr.substring(currentAddr.indexOf('.')+1);
udpMulticastAddress = DEFAULT_UDP_MCAST_ADDR_PREFIX + lastNode;
@@ -183,7 +182,7 @@
// check for command line system property being set from vm.starter.command for jgroup
String bindAddress = System.getProperty(JGroupsProvider.BIND_ADDRESS_PROPERTY);
if (bindAddress == null) {
- bindAddress = VMNaming.getBindAddress();
+ bindAddress = CurrentConfiguration.getInstance().getBindAddress();
}
if (bindAddress == null) {
Modified: trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/LogApplicationInfo.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -45,12 +45,11 @@
import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.ByteArrayHelper;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.TempDirectory;
import com.metamatrix.core.util.ZipFileUtil;
-class LogApplicationInfo extends Thread {
+class LogApplicationInfo implements Runnable {
String applFileName = null;
String logPath = null;
String hostName;
@@ -75,7 +74,7 @@
ApplicationInfo info = ApplicationInfo.getInstance();
StringBuffer sb = new StringBuffer();
- sb.append(VMNaming.getHostInfo());
+ sb.append(CurrentConfiguration.getInstance().getHostInfo());
sb.append("\n---- System Properties ----\n"); //$NON-NLS-1$
sb.append(PropertiesUtils.prettyPrint(System.getProperties()));
Modified: trunk/server/src/main/java/com/metamatrix/server/Main.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -23,6 +23,9 @@
package com.metamatrix.server;
import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Arrays;
import com.google.inject.Guice;
import com.google.inject.Inject;
@@ -30,16 +33,14 @@
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
import com.metamatrix.common.config.api.Host;
-import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.messaging.MessagingException;
-import com.metamatrix.common.util.VMNaming;
+import com.metamatrix.core.log.FileLimitSizeLogWriter;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.dqp.ResourceFinder;
-import com.metamatrix.platform.PlatformPlugin;
+import com.metamatrix.platform.config.persistence.impl.file.FilePersistentUtil;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.vm.api.controller.ProcessManagement;
@@ -47,6 +48,8 @@
* This is main server starter class.
*/
public class Main {
+
+ private static final String CONFIG_PREFIX = "config-"; //$NON-NLS-1$
@Inject
MessageBus messageBus;
@@ -60,55 +63,45 @@
@Inject
ClusteredRegistryState registry;
- public static void main(String[] args) {
-
- try {
- if (args.length != 1) {
- System.out.println("Usage: java com.metamatrix.server.Main <vm_name>"); //$NON-NLS-1$
- System.exit(1);
- }
+ public static void main(String[] args) throws Exception {
+ if (args.length != 1) {
+ System.out.println("Usage: java com.metamatrix.server.Main <vm_name>"); //$NON-NLS-1$
+ System.exit(1);
+ }
- String processName = args[0];
+ final String processName = args[0];
- Host host = null;
- try {
- host = CurrentConfiguration.getInstance().getDefaultHost();
- } catch (ConfigurationException e) {
+ CurrentConfiguration.getInstance().setProcessName(processName);
+
+ final Host host = CurrentConfiguration.getInstance().getDefaultHost();
+
+ Thread t = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ saveCurrentConfigurationToFile(host, processName);
+ } catch (ConfigurationException e) {
+ System.out.print("Could not archive start up configuration"); //$NON-NLS-1$
+ }
+ // write info log
+ writeInfoLog(host, processName);
}
-
- if (host == null) {
- System.err.println(PlatformPlugin.Util.getString("SocketVMController.5")); //$NON-NLS-1$
- System.exit(-1);
- }
-
- VMComponentDefn deployedVM = CurrentConfiguration.getInstance().getConfiguration().getVMForHost(host.getName(), processName);
- String bindAddress = deployedVM.getBindAddress();
-
- VMNaming.setProcessName(processName);
- VMNaming.setup(host.getFullName(), host.getHostAddress(), bindAddress);
-
- // write info log
- writeInfoLog(host, processName);
-
- createTempDirectory();
-
- // wire up guice modules
- Main main = loadMain(host, processName);
-
- // launch the server
-
- main.launchServer();
- } catch (Throwable e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
+ }, "Main Info Thread"); //$NON-NLS-1$
+ t.start();
+
+ createTempDirectory();
+
+ // wire up guice modules
+ Main main = loadMain(host, processName);
+
+ // launch the server
+ main.launchServer();
}
-
private static Main loadMain(Host host, String processName) {
Injector injector = Guice.createInjector(new ServerGuiceModule(host, processName));
// Until we get the all the DI working we have to resort to this kind of stuff..
- ResourceFinder.setInjector(injector);
+ ResourceFinder.setInjectorAndCompleteInitialization(injector);
return injector.getInstance(Main.class);
}
@@ -154,11 +147,32 @@
return hostFileName + "_" + processName; //$NON-NLS-1$
}
+ private static void saveCurrentConfigurationToFile(Host host, String processName) throws ConfigurationException {
+ FilePersistentUtil.writeModel(CONFIG_PREFIX+FileLimitSizeLogWriter.getDate()+".xml", host.getConfigDirectory(), //$NON-NLS-1$
+ CurrentConfiguration.getInstance().getConfigurationModel(),
+ processName);
+ //remove old instances
+ File f = new File(host.getConfigDirectory());
+ String[] result = f.list(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.startsWith(CONFIG_PREFIX);
+ }
+ });
+ if (result.length > 10) {
+ Arrays.sort(result);
+ try {
+ FileUtils.remove(result[0]);
+ } catch (IOException e) {
+ System.out.println("Error removing archived config"); //$NON-NLS-1$
+ }
+ }
+ }
private static void writeInfoLog(Host host, String processName) {
// trigger the logging of the current application info to a log file for debugging
LogApplicationInfo logApplInfo = new LogApplicationInfo(host.getFullName(), processName, host.getLogDirectory(), buildPrefix(host.getFullName(), processName) + "_info.log"); //$NON-NLS-1$
- logApplInfo.start();
+ logApplInfo.run();
}
/**
Modified: trunk/server/src/main/java/com/metamatrix/server/ResourceFinder.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ResourceFinder.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/ResourceFinder.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -23,8 +23,10 @@
package com.metamatrix.server;
+import com.google.inject.Injector;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.messaging.NoOpMessageBus;
+import com.metamatrix.platform.config.spi.xml.XMLConfigurationMgr;
public class ResourceFinder extends com.metamatrix.dqp.ResourceFinder {
@@ -33,5 +35,10 @@
return new NoOpMessageBus();
}
return injector.getInstance(MessageBus.class);
- }
+ }
+
+ public static void setInjectorAndCompleteInitialization(Injector injector) {
+ ResourceFinder.setInjector(injector);
+ XMLConfigurationMgr.getInstance().setMessageBus(getMessageBus());
+ }
}
Modified: trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -37,7 +37,7 @@
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
-import com.metamatrix.common.messaging.VMMessageBus;
+import com.metamatrix.common.messaging.jgroups.JGroupsMessageBus;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.platform.registry.ClusteredRegistryState;
@@ -82,7 +82,7 @@
bind(CacheFactory.class).to(JBossCacheFactory.class).in(Scopes.SINGLETON);
bind(ClusteredRegistryState.class).in(Scopes.SINGLETON);
bind(ProxyManager.class).in(Scopes.SINGLETON);
- bind(MessageBus.class).to(VMMessageBus.class).in(Scopes.SINGLETON); // VM Message bus is in common-internal
+ bind(MessageBus.class).to(JGroupsMessageBus.class).in(Scopes.SINGLETON); // VM Message bus is in common-internal
bind(ProcessManagement.class).to(SocketVMController.class).in(Scopes.SINGLETON);
bind(ServerEvents.class).to(ProcessMonitor.class).in(Scopes.SINGLETON);
bind(HostManagement.class).toProvider(HostManagementProvider.class).in(Scopes.SINGLETON);
Modified: trunk/server/src/main/java/com/metamatrix/server/ServiceManager.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServiceManager.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/ServiceManager.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -44,21 +44,16 @@
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.HostID;
import com.metamatrix.common.config.api.VMComponentDefn;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.messaging.MessagingException;
import com.metamatrix.common.queue.WorkerPoolStats;
-import com.metamatrix.common.util.LogCommonConstants;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.admin.apiimpl.RuntimeStateAdminAPIHelper;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.registry.HostControllerRegistryBinding;
-import com.metamatrix.platform.registry.ServiceRegistryBinding;
import com.metamatrix.platform.registry.ProcessRegistryBinding;
+import com.metamatrix.platform.registry.ServiceRegistryBinding;
import com.metamatrix.platform.service.api.CacheAdmin;
import com.metamatrix.platform.service.api.ServiceID;
import com.metamatrix.platform.service.api.ServiceInterface;
@@ -1181,7 +1176,7 @@
private static ServiceManager loadServiceManager(Host host) {
Injector injector = Guice.createInjector(new ServiceManagerGuiceModule(host));
- ResourceFinder.setInjector(injector);
+ ResourceFinder.setInjectorAndCompleteInitialization(injector);
return injector.getInstance(ServiceManager.class);
}
@@ -1196,19 +1191,8 @@
command = command + args[i] + " "; //$NON-NLS-1$
}
- Host host = null;
- try {
- host = CurrentConfiguration.getInstance().getDefaultHost();
- } catch (ConfigurationException e) {
- }
-
- if (host == null) {
- LogManager.logError(LogCommonConstants.CTX_CONTROLLER,"ERROR " + PlatformPlugin.Util.getString(ErrorMessageKeys.HOST_0001)); //$NON-NLS-1$
- System.exit(-1);
- }
+ Host host = CurrentConfiguration.getInstance().getDefaultHost();
- VMNaming.setup(host.getFullName(), host.getHostAddress(), host.getBindAddress());
-
try {
ServiceManager manager = loadServiceManager(host);
manager.run(command,exit);
Modified: trunk/server/src/main/java/com/metamatrix/server/ServiceManagerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServiceManagerGuiceModule.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/ServiceManagerGuiceModule.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -26,7 +26,6 @@
import com.metamatrix.common.config.api.Host;
class ServiceManagerGuiceModule extends HostControllerGuiceModule {
- Host host;
public ServiceManagerGuiceModule(Host host) {
super(host);
Modified: trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -74,12 +74,9 @@
import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.common.util.crypto.CryptoUtil;
-import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.event.EventObjectListener;
-import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestID;
@@ -246,7 +243,7 @@
String connID = id.getHostName()+"|"+ id.getProcessName() + "|" + id.getID(); //$NON-NLS-1$ //$NON-NLS-2$
deMaskedProps.put(ConnectorPropertyNames.CONNECTOR_ID, connID);
deMaskedProps.put(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, getInstanceName());
- deMaskedProps.put(ConnectorPropertyNames.CONNECTOR_VM_NAME, VMNaming.getProcessName());
+ deMaskedProps.put(ConnectorPropertyNames.CONNECTOR_VM_NAME, CurrentConfiguration.getInstance().getProcessName());
connectorManager.setClassloader(loader);
connectorManager.initialize(deMaskedProps);
return connectorManager;
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformTransactionService.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -39,7 +39,6 @@
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogCommonConstants;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.core.util.FileUtils;
@@ -81,7 +80,7 @@
props.putAll(env);
props.setProperty(TransactionService.TXN_MGR_LOG_DIR, logDir);
props.setProperty(TransactionService.HOSTNAME, host.getFullName());
- props.setProperty(TransactionService.VMNAME, VMNaming.getProcessName());
+ props.setProperty(TransactionService.VMNAME, CurrentConfiguration.getInstance().getProcessName());
props.setProperty(TransactionService.TXN_STORE_DIR, host.getDataDirectory());
arjunaTs.init(ArjunaTransactionProvider.getInstance(props));
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/service/tracker/TransactionLogWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/service/tracker/TransactionLogWriter.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/service/tracker/TransactionLogWriter.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -56,8 +56,6 @@
private static final int WRITE_RETRIES = 3; // # of retries before stop writing
private static final int RESUME_LOGGING_AFTER_TIME = 180 * 1000; // 3 mins
- private Properties connProps;
-
private static volatile boolean isLogSuspended=false;
private static volatile long resumeTime=-1;
private boolean shutdown = false;
@@ -71,7 +69,6 @@
* initialization.
*/
public TransactionLogWriter(Properties props) {
- this.connProps = props;
}
public void print(TransactionLogMessage message) {
Modified: trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/java/com/metamatrix/server/query/service/QueryService.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -25,8 +25,6 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@@ -44,11 +42,9 @@
import com.metamatrix.common.config.api.DeployedComponentID;
import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
-import com.metamatrix.common.extensionmodule.protocol.URLFactory;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.queue.WorkerPoolStats;
import com.metamatrix.common.util.LogCommonConstants;
-import com.metamatrix.common.util.VMNaming;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.client.ClientSideDQP;
@@ -62,7 +58,6 @@
import com.metamatrix.server.ServerPlugin;
import com.metamatrix.server.dqp.config.PlatformConfigSource;
import com.metamatrix.server.util.LogConstants;
-import com.metamatrix.server.util.ServerPropertyNames;
/**
* Wraps up a QueryServiceEngine to tie it into the platform concept of services. Is a remote object.
@@ -73,7 +68,6 @@
*/
public class QueryService extends AbstractService implements QueryServiceInterface {
- private static final String CLASSPATH_DELIMITER = ";"; //$NON-NLS-1$
private static final String CODE_TABLE_CACHE_NAME = "CodeTableCache"; //$NON-NLS-1$
private static final String PLAN_CACHE_NAME = "PreparedPlanCache"; //$NON-NLS-1$
private static final String RESULT_SET_CACHE_NAME = "QueryServiceResultSetCache"; //$NON-NLS-1$
@@ -96,7 +90,7 @@
LogManager.logError(LogConstants.CTX_QUERY_SERVICE, t, ServerPlugin.Util.getString("QueryService.Unable_to_register_user-defined_function_source__{0}_1", udfSource)); //$NON-NLS-1$
}
- DQPConfigSource configSource = new PlatformConfigSource(props, CurrentConfiguration.getInstance().getProperties(), new Long(getID().getID()), CurrentConfiguration.getInstance().getDefaultHost(), VMNaming.getProcessName());
+ DQPConfigSource configSource = new PlatformConfigSource(props, CurrentConfiguration.getInstance().getProperties(), new Long(getID().getID()), CurrentConfiguration.getInstance().getDefaultHost(), CurrentConfiguration.getInstance().getProcessName());
dqp = new DQPCore();
dqp.start(configSource);
}
Modified: trunk/server/src/main/sqlrepository/data/data_clear.sql
===================================================================
--- trunk/server/src/main/sqlrepository/data/data_clear.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/data/data_clear.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -4,9 +4,6 @@
DELETE FROM AUTHREALMS;
DELETE FROM AUTHPOLICIES;
-DELETE FROM CFG_STARTUP_STATE;
-DELETE FROM CS_SYSTEM_PROPS;
-
DELETE FROM CS_EXT_FILES;
DELETE FROM LOGENTRIES;
Modified: trunk/server/src/main/sqlrepository/data/data_insert.sql
===================================================================
--- trunk/server/src/main/sqlrepository/data/data_insert.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/data/data_insert.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -20,9 +20,6 @@
SELECT 5,POLICYNAME,15,PERMTYPEUID,REALMUID,POLICYUID FROM AUTHPERMTYPES,AUTHREALMS,AUTHPOLICIES
WHERE DISPLAYNAME='RolePermissionFactory' and REALMNAME='AdminRoleRealm' and POLICYNAME='Admin.ReadOnlyAdmin';
-INSERT INTO CFG_STARTUP_STATE(STATE) VALUES (0);
-
-
INSERT INTO LOGMESSAGETYPES(MESSAGELEVEL, NAME, DISPLAYNAME) VALUES (1,'CRITICAL','Critical');
INSERT INTO LOGMESSAGETYPES(MESSAGELEVEL, NAME, DISPLAYNAME) VALUES (2,'ERROR','Error');
INSERT INTO LOGMESSAGETYPES(MESSAGELEVEL, NAME, DISPLAYNAME) VALUES (3,'WARNING','Warning');
Modified: trunk/server/src/main/sqlrepository/schema/db2/mm_create.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/db2/mm_create.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/db2/mm_create.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -53,13 +53,6 @@
CONSTRAINT P_KEY_3 PRIMARY KEY (REALMUID)
)%
-CREATE TABLE CFG_STARTUP_STATE
-(
- STATE NUMERIC,
- LASTCHANGED VARCHAR(50)
-)%
-
-
CREATE TABLE IDTABLE
(
IDCONTEXT VARCHAR(20) NOT NULL,
@@ -267,16 +260,6 @@
ALTER TABLE CS_EXT_FILES ADD CONSTRAINT CSEXFILS_FIL_NA_UK UNIQUE (FILE_NAME)
%
-CREATE TABLE CS_SYSTEM_PROPS (
- PROPERTY_NAME VARCHAR(255),
- PROPERTY_VALUE VARCHAR(255)
-)
-%
-
-CREATE UNIQUE INDEX SYSPROPS_KEY ON CS_SYSTEM_PROPS (PROPERTY_NAME)
-%
-
-
CREATE FUNCTION SYSDATE ()
RETURNS TIMESTAMP
LANGUAGE SQL
Modified: trunk/server/src/main/sqlrepository/schema/db2/mm_drop.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/db2/mm_drop.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/db2/mm_drop.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -10,8 +10,6 @@
DROP TABLE AUTHREALMS%
-DROP TABLE CFG_STARTUP_STATE%
-
DROP TABLE IDTABLE%
DROP TABLE LOGENTRIES%
@@ -36,8 +34,6 @@
DROP TABLE TX_SRCCMDLOG%
-DROP TABLE CS_SYSTEM_PROPS%
-
DROP TABLE TX_SQL%
DROP FUNCTION SYSDATE%
Modified: trunk/server/src/main/sqlrepository/schema/derby/mm_create.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/derby/mm_create.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/derby/mm_create.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -47,11 +47,6 @@
DESCRIPTION VARCHAR(550),
CONSTRAINT P_KEY_3a PRIMARY KEY (REALMUID)
);
-CREATE TABLE CFG_STARTUP_STATE
-(
- STATE NUMERIC,
- LASTCHANGED VARCHAR(50)
-);
CREATE TABLE IDTABLE
(
IDCONTEXT VARCHAR(20) NOT NULL,
@@ -198,15 +193,6 @@
;
-CREATE TABLE CS_SYSTEM_PROPS (
- PROPERTY_NAME VARCHAR(255),
- PROPERTY_VALUE VARCHAR(255)
-)
-;
-
-CREATE UNIQUE INDEX SYSPROPS_KEY ON CS_SYSTEM_PROPS (PROPERTY_NAME);
-
-
CREATE FUNCTION SYSDATE ()
RETURNS TIMESTAMP
PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA
Modified: trunk/server/src/main/sqlrepository/schema/derby/mm_drop.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/derby/mm_drop.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/derby/mm_drop.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -10,8 +10,6 @@
DROP TABLE AUTHREALMS;
-DROP TABLE CFG_STARTUP_STATE;
-
DROP TABLE IDTABLE;
DROP TABLE LOGENTRIES;
@@ -36,8 +34,6 @@
;
DROP TABLE TX_SRCCMDLOG
;
-DROP TABLE CS_SYSTEM_PROPS
-;
DROP TABLE TX_SQL
;
Modified: trunk/server/src/main/sqlrepository/schema/mysql/mm_create.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/mysql/mm_create.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/mysql/mm_create.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -44,13 +44,6 @@
DESCRIPTION VARCHAR(550)
);
-CREATE TABLE CFG_STARTUP_STATE
-(STATE INTEGER DEFAULT 0 ,
-LASTCHANGED VARCHAR(50) );
-
-
-
-
CREATE TABLE IDTABLE
(
IDCONTEXT VARCHAR(20) NOT NULL PRIMARY KEY,
@@ -190,14 +183,6 @@
ALTER TABLE CS_EXT_FILES ADD CONSTRAINT CSEXFILS_FIL_NA_UK UNIQUE (FILE_NAME);
-
-CREATE TABLE CS_SYSTEM_PROPS (
- PROPERTY_NAME VARCHAR(255),
- PROPERTY_VALUE VARCHAR(255)
-);
-
-CREATE UNIQUE INDEX SYSPROPS_KEY ON CS_SYSTEM_PROPS (PROPERTY_NAME);
-
CREATE TABLE TX_MMXCMDLOG
(
REQUESTID VARCHAR(255) NOT NULL,
Modified: trunk/server/src/main/sqlrepository/schema/mysql/mm_drop.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/mysql/mm_drop.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/mysql/mm_drop.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -10,8 +10,6 @@
DROP TABLE IF EXISTS AUTHREALMS CASCADE;
-DROP TABLE IF EXISTS CFG_STARTUP_STATE CASCADE;
-
DROP TABLE IF EXISTS IDTABLE CASCADE;
DROP TABLE IF EXISTS LOGENTRIES CASCADE;
@@ -36,8 +34,6 @@
CASCADE;
DROP TABLE IF EXISTS TX_SRCCMDLOG
CASCADE;
-DROP TABLE IF EXISTS CS_SYSTEM_PROPS
- CASCADE;
DROP TABLE IF EXISTS TX_SQL
CASCADE;
Modified: trunk/server/src/main/sqlrepository/schema/oracle/mm_create.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/oracle/mm_create.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/oracle/mm_create.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -53,13 +53,6 @@
DESCRIPTION VARCHAR2(550)
);
-CREATE TABLE CFG_STARTUP_STATE
-(STATE INTEGER DEFAULT (0) NULL,
-LASTCHANGED VARCHAR(50) );
-
-
-
-
CREATE TABLE IDTABLE
(
IDCONTEXT VARCHAR2(20) NOT NULL PRIMARY KEY,
@@ -255,13 +248,6 @@
ALTER TABLE CS_EXT_FILES ADD CONSTRAINT CSEXFILS_FIL_NA_UK UNIQUE (FILE_NAME);
-CREATE TABLE CS_SYSTEM_PROPS (
- PROPERTY_NAME VARCHAR(255),
- PROPERTY_VALUE VARCHAR(255)
-);
-
-CREATE UNIQUE INDEX SYSPROPS_KEY ON CS_SYSTEM_PROPS (PROPERTY_NAME);
-
CREATE TABLE TX_MMXCMDLOG
(
REQUESTID VARCHAR(255) NOT NULL,
Modified: trunk/server/src/main/sqlrepository/schema/oracle/mm_drop.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/oracle/mm_drop.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/oracle/mm_drop.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -11,7 +11,6 @@
TRUNCATE TABLE LOGMESSAGETYPES;
TRUNCATE TABLE IDTABLE;
-TRUNCATE TABLE CFG_STARTUP_STATE;
TRUNCATE TABLE AUTHPOLICIES;
TRUNCATE TABLE AUTHPERMISSIONS;
@@ -21,7 +20,6 @@
TRUNCATE TABLE AUDITENTRIES;
TRUNCATE TABLE CS_EXT_FILES;
-TRUNCATE TABLE CS_SYSTEM_PROPS;
TRUNCATE TABLE TX_MMXCMDLOG;
TRUNCATE TABLE TX_SRCCMDLOG;
TRUNCATE TABLE TX_SQL;
@@ -36,7 +34,6 @@
DROP TABLE LOGMESSAGETYPES CASCADE CONSTRAINTS;
DROP TABLE LOGENTRIES CASCADE CONSTRAINTS;
DROP TABLE IDTABLE CASCADE CONSTRAINTS;
-DROP TABLE CFG_STARTUP_STATE CASCADE CONSTRAINTS;
DROP TABLE AUTHREALMS CASCADE CONSTRAINTS;
DROP TABLE AUTHPRINCIPALS CASCADE CONSTRAINTS;
DROP TABLE AUTHPOLICIES CASCADE CONSTRAINTS;
@@ -44,7 +41,6 @@
DROP TABLE AUTHPERMISSIONS CASCADE CONSTRAINTS;
DROP TABLE AUDITENTRIES CASCADE CONSTRAINTS;
DROP TABLE CS_EXT_FILES CASCADE CONSTRAINTS ;
-DROP TABLE CS_SYSTEM_PROPS;
DROP TABLE TX_MMXCMDLOG;
DROP TABLE TX_SRCCMDLOG;
Modified: trunk/server/src/main/sqlrepository/schema/postgres/mm_create.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/postgres/mm_create.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/postgres/mm_create.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -45,14 +45,6 @@
)
GO
-CREATE TABLE CFG_STARTUP_STATE
-(STATE INTEGER DEFAULT (0) NULL,
-LASTCHANGED VARCHAR(50) )
-GO
-
-
-GO
-
CREATE TABLE IDTABLE
(
IDCONTEXT VARCHAR(20) NOT NULL PRIMARY KEY,
@@ -213,16 +205,6 @@
ALTER TABLE CS_EXT_FILES ADD CONSTRAINT CSEXFILS_FIL_NA_UK UNIQUE (FILE_NAME)
GO
-CREATE TABLE CS_SYSTEM_PROPS (
- PROPERTY_NAME VARCHAR(255),
- PROPERTY_VALUE VARCHAR(255)
-)
-GO
-
-CREATE UNIQUE INDEX SYSPROPS_KEY ON CS_SYSTEM_PROPS (PROPERTY_NAME)
-GO
-
-
CREATE TABLE TX_MMXCMDLOG
(
REQUESTID VARCHAR(255) NOT NULL,
Modified: trunk/server/src/main/sqlrepository/schema/postgres/mm_drop.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/postgres/mm_drop.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/postgres/mm_drop.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -17,8 +17,6 @@
GO
DROP TABLE IDTABLE
GO
-DROP TABLE CFG_STARTUP_STATE
-GO
DROP TABLE AUTHPRINCIPALS
GO
DROP TABLE AUTHPERMISSIONS
@@ -33,8 +31,6 @@
GO
DROP TABLE CS_EXT_FILES
GO
-DROP TABLE CS_SYSTEM_PROPS
-GO
DROP TABLE TX_MMXCMDLOG
GO
DROP TABLE TX_SRCCMDLOG
Modified: trunk/server/src/main/sqlrepository/schema/sqlserver/mm_create.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/sqlserver/mm_create.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/sqlserver/mm_create.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -47,14 +47,6 @@
)
GO
-CREATE TABLE CFG_STARTUP_STATE
-(STATE INTEGER DEFAULT (0) NULL,
-LASTCHANGED VARCHAR(50) )
-GO
-
-
-GO
-
CREATE TABLE IDTABLE
(
IDCONTEXT VARCHAR(20) NOT NULL PRIMARY KEY,
@@ -216,16 +208,6 @@
ALTER TABLE CS_EXT_FILES ADD CONSTRAINT CSEXFILS_FIL_NA_UK UNIQUE (FILE_NAME)
GO
-CREATE TABLE CS_SYSTEM_PROPS (
- PROPERTY_NAME VARCHAR(255),
- PROPERTY_VALUE VARCHAR(255)
-)
-GO
-
-CREATE UNIQUE INDEX SYSPROPS_KEY ON CS_SYSTEM_PROPS (PROPERTY_NAME)
-GO
-
-
CREATE TABLE TX_MMXCMDLOG
(
REQUESTID VARCHAR(255) NOT NULL,
Modified: trunk/server/src/main/sqlrepository/schema/sqlserver/mm_drop.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/sqlserver/mm_drop.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/sqlserver/mm_drop.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -66,18 +66,10 @@
DROP TABLE [AUTHREALMS]
GO
-if exists (select * from dbo.sysobjects where id = object_id(N'[CFG_STARTUP_STATE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
-DROP TABLE [CFG_STARTUP_STATE]
-GO
-
if exists (select * from dbo.sysobjects where id = object_id(N'[CS_EXT_FILES]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [CS_EXT_FILES]
GO
-if exists (select * from dbo.sysobjects where id = object_id(N'[CS_SYSTEM_PROPS]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
-DROP TABLE [CS_SYSTEM_PROPS]
-GO
-
if exists (select * from dbo.sysobjects where id = object_id(N'[IDTABLE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
DROP TABLE [IDTABLE]
GO
Modified: trunk/server/src/main/sqlrepository/schema/sybase/mm_create.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/sybase/mm_create.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/sybase/mm_create.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -44,11 +44,6 @@
)
go
-CREATE TABLE CFG_STARTUP_STATE
-(STATE INTEGER DEFAULT (0) NULL,
-LASTCHANGED VARCHAR(50) NULL)
-go
-
CREATE TABLE IDTABLE
(
IDCONTEXT VARCHAR(20) NOT NULL PRIMARY KEY,
@@ -210,16 +205,6 @@
ALTER TABLE CS_EXT_FILES ADD CONSTRAINT CSEXFILS_FIL_NA_UK UNIQUE (FILE_NAME)
go
-CREATE TABLE CS_SYSTEM_PROPS (
- PROPERTY_NAME VARCHAR(255) NULL,
--- Case change ..dw
- Property_VALUE VARCHAR(255) NULL
-)
-go
-
-CREATE UNIQUE INDEX SYSPROPS_KEY ON CS_SYSTEM_PROPS (PROPERTY_NAME)
-go
-
CREATE TABLE TX_MMXCMDLOG
(
REQUESTID VARCHAR(255) NOT NULL,
Modified: trunk/server/src/main/sqlrepository/schema/sybase/mm_drop.sql
===================================================================
--- trunk/server/src/main/sqlrepository/schema/sybase/mm_drop.sql 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/main/sqlrepository/schema/sybase/mm_drop.sql 2009-04-01 20:56:55 UTC (rev 686)
@@ -16,8 +16,6 @@
go
DROP TABLE IDTABLE
go
-DROP TABLE CFG_STARTUP_STATE
-go
DROP TABLE AUTHPRINCIPALS
go
DROP TABLE AUTHPERMISSIONS
@@ -32,8 +30,6 @@
go
DROP TABLE CS_EXT_FILES
go
-DROP TABLE CS_SYSTEM_PROPS
-go
DROP TABLE TX_MMXCMDLOG
go
DROP TABLE TX_SRCCMDLOG
Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -60,7 +60,6 @@
import com.metamatrix.common.config.api.SharedResourceID;
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.config.api.exceptions.InvalidArgumentException;
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
@@ -433,7 +432,6 @@
*/
public Set executeTransaction(ActionDefinition action,
String principalName) throws ModificationException,
- ConfigurationLockException,
ConfigurationException {
return null;
}
@@ -443,7 +441,6 @@
*/
public Set executeTransaction(List actions,
String principalName) throws ModificationException,
- ConfigurationLockException,
ConfigurationException {
if (actions != null) {
for (Iterator it=actions.iterator(); it.hasNext();) {
@@ -464,7 +461,6 @@
public Set executeInsertTransaction(ConfigurationID assignConfigurationID,
List actions,
String principalName) throws ModificationException,
- ConfigurationLockException,
ConfigurationException {
return null;
}
Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeExtensionModuleManager.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeExtensionModuleManager.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeExtensionModuleManager.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -59,7 +59,7 @@
return null;
}
- protected ExtensionModuleTransaction getReadTransaction() throws ManagedConnectionException {
+ public ExtensionModuleTransaction getReadTransaction() throws ManagedConnectionException {
return null;
}
@@ -120,7 +120,7 @@
return null;
}
- protected ExtensionModuleTransaction getWriteTransaction() throws ManagedConnectionException {
+ public ExtensionModuleTransaction getWriteTransaction() throws ManagedConnectionException {
return null;
}
Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeRuntimeStateAdminAPIHelper.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeRuntimeStateAdminAPIHelper.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeRuntimeStateAdminAPIHelper.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -38,7 +38,6 @@
import com.metamatrix.common.config.api.ConnectorBindingType;
import com.metamatrix.common.config.api.DeployedComponent;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.config.api.exceptions.ConfigurationLockException;
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.messaging.NoOpMessageBus;
import com.metamatrix.common.queue.WorkerPoolStats;
@@ -108,10 +107,6 @@
return null;
}
- public List getProcesses() throws MetaMatrixComponentException {
- return null;
- }
-
/**
* Return fake ServiceRegistryBinding for testing, based on the specified ServiceID.
* Returns "connectorBinding2" and "connectorBinding3"; "dqp2" and "dqp3"
@@ -296,7 +291,7 @@
public void setLogConfiguration(Configuration config,
LogConfiguration logConfig,
List actions,
- String principalName) throws ConfigurationLockException,
+ String principalName) throws
ConfigurationException,
ServiceException,
MetaMatrixComponentException {
Modified: trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -64,9 +64,6 @@
public void setUp() throws Exception {
- System.setProperty("metamatrix.config.none", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- System.setProperty("metamatrix.message.bus.type", "noop.message.bus"); //$NON-NLS-1$ //$NON-NLS-2$
-
ClusteredRegistryState registry = FakeRegistryUtil.getFakeRegistry();
parent = new FakeServerAdminImpl(registry);
admin = new ServerMonitoringAdminImpl(parent, registry);
Modified: trunk/server/src/test/java/com/metamatrix/common/extensionmodule/TestExtensionModuleManager.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/common/extensionmodule/TestExtensionModuleManager.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/common/extensionmodule/TestExtensionModuleManager.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -22,6 +22,8 @@
package com.metamatrix.common.extensionmodule;
+import static org.junit.Assert.*;
+
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
@@ -33,68 +35,39 @@
import java.util.zip.CRC32;
import java.util.zip.Checksum;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.extensionmodule.exception.DuplicateExtensionModuleException;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleOrderingException;
import com.metamatrix.common.extensionmodule.exception.InvalidExtensionModuleTypeException;
-import com.metamatrix.common.messaging.MessageBusConstants;
-import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.common.extensionmodule.spi.InMemoryExtensionModuleTransactionFactory;
-public class TestExtensionModuleManager extends TestCase {
+public class TestExtensionModuleManager {
private static final String PRINCIPAL = "TestPrincipal"; //$NON-NLS-1$
- private ExtensionModuleManager manager;
+ private static ExtensionModuleManager manager;
- // ################################## FRAMEWORK ################################
-
- public TestExtensionModuleManager(String name) {
- super(name);
- }
-
/**
* Loads most of the extension sources into the ExtensionModuleManager
* up front, one time, to avoid overhead - this is used by
* {@link #suite} method
*/
- public static void setUpOnce() throws Exception{
- ExtensionModuleManager.reInit();
- resetProperties();
+ @BeforeClass public static void setUpOnce() throws Exception{
+ manager = new ExtensionModuleManager(getExtensionModuleProperties());
FakeData.init();
}
- public static void resetProperties() {
- try {
- CurrentConfiguration.getInstance().reset();
- } catch (ConfigurationException e) {
- }
- System.setProperty(MessageBusConstants.MESSAGE_BUS_TYPE, MessageBusConstants.TYPE_NOOP);
- boolean deepClone = false;
- boolean makeUnmodifiable = false;
- Properties newSystemProps = PropertiesUtils.clone(System.getProperties(), getExtensionModuleProperties(), deepClone, makeUnmodifiable);
- //flatten
- newSystemProps = PropertiesUtils.clone(newSystemProps, makeUnmodifiable);
- System.setProperties(newSystemProps);
- }
-
private static Properties getExtensionModuleProperties() {
Properties BASE_PROPERTIES = new Properties();
- BASE_PROPERTIES.setProperty("metamatrix.log.captureSystemOut","false"); //$NON-NLS-1$ //$NON-NLS-2$
- BASE_PROPERTIES.setProperty("metamatrix.log.captureSystemErr","false"); //$NON-NLS-1$ //$NON-NLS-2$
- BASE_PROPERTIES.setProperty("metamatrix.log","5"); //$NON-NLS-1$ //$NON-NLS-2$
- BASE_PROPERTIES.setProperty("metamatrix.log.console","true"); //$NON-NLS-1$ //$NON-NLS-2$
- BASE_PROPERTIES.setProperty("metamatrix.log.consoleFormat","com.metamatrix.common.log.format.ReadableLogMessageFormat"); //$NON-NLS-1$ //$NON-NLS-2$
- BASE_PROPERTIES.setProperty(ExtensionModulePropertyNames.CONNECTION_FACTORY,"com.metamatrix.common.extensionmodule.spi.InMemoryExtensionModuleTransactionFactory"); //$NON-NLS-1$
+ BASE_PROPERTIES.setProperty(ExtensionModulePropertyNames.CONNECTION_FACTORY,InMemoryExtensionModuleTransactionFactory.class.getName());
return BASE_PROPERTIES;
}
@@ -103,8 +76,7 @@
* All remaining extension sources are removed - this is used by
* {@link #suite} method
*/
- public static void tearDownOnce() throws Exception{
- ExtensionModuleManager manager = ExtensionModuleManager.getInstance();
+ @AfterClass public static void tearDownOnce() throws Exception{
Iterator i = manager.getSourceNames().iterator();
while (i.hasNext()){
manager.removeSource( PRINCIPAL, i.next().toString());
@@ -115,8 +87,7 @@
* One of the tests jars will be added here, which clears the cache
* of ExtensionModuleManager between each test
*/
- public void setUp() throws Exception{
- manager = ExtensionModuleManager.getInstance();
+ @Before public void setUp() throws Exception{
try {
manager.removeSource(PRINCIPAL, FakeData.TestJar1.SOURCE_NAME);
} catch (ExtensionModuleNotFoundException e) {
@@ -176,29 +147,15 @@
/**
* @see ExtensionModuleManager@addSource
*/
- public void testAddSource(){
- manager = ExtensionModuleManager.getInstance();
+ @Test public void testAddSource() throws Exception {
try{
manager.removeSource( PRINCIPAL, FakeData.TestJar1.SOURCE_NAME);
} catch (ExtensionModuleNotFoundException e){
//ignore
- } catch (MetaMatrixComponentException e){
- fail(e.getMessage());
}
+ ExtensionModuleDescriptor desc = manager.addSource( PRINCIPAL, FakeData.TestJar1.TYPE, FakeData.TestJar1.SOURCE_NAME, FakeData.TestJar1.data, FakeData.TestJar1.DESCRIPTION, true);
- ExtensionModuleDescriptor desc = null;
- try{
- desc = manager.addSource( PRINCIPAL, FakeData.TestJar1.TYPE, FakeData.TestJar1.SOURCE_NAME, FakeData.TestJar1.data, FakeData.TestJar1.DESCRIPTION, true);
- //printDescriptor(desc, System.out);
- } catch (DuplicateExtensionModuleException e){
- fail("Source " + FakeData.TestJar1.SOURCE_NAME + " already exists: " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (InvalidExtensionModuleTypeException e){
- fail("Type is invalid: " + e.getMessage()); //$NON-NLS-1$
- } catch (MetaMatrixComponentException e){
- fail(e.getMessage());
- }
-
//check checksum
assertTrue(desc.getName().equals(FakeData.TestJar1.SOURCE_NAME));
assertTrue(desc.getType().equals(FakeData.TestJar1.TYPE));
@@ -212,7 +169,7 @@
* Tests that an DuplicateExtensionModuleException is (correctly) triggered
* @see ExtensionModuleManager@addSource
*/
- public void testAddDuplicateSource(){
+ @Test public void testAddDuplicateSource(){
DuplicateExtensionModuleException exception = null;
try{
manager.addSource( PRINCIPAL, FakeData.TestJar1.TYPE, FakeData.TestJar1.SOURCE_NAME, FakeData.TestJar1.data, FakeData.TestJar1.DESCRIPTION, true);
@@ -233,7 +190,7 @@
* it is asked for after that
* @see ExtensionModuleManager@removeSource
*/
- public void testRemoveSource() {
+ @Test public void testRemoveSource() {
try{
manager.removeSource( PRINCIPAL, FakeData.TestJar2.SOURCE_NAME);
} catch (ExtensionModuleNotFoundException e){
@@ -264,7 +221,7 @@
* Just tests that collection comes back as non-null
* @see ExtensionModuleManager@getSourceDescriptors
*/
- public void testGetDescriptors(){
+ @Test public void testGetDescriptors(){
List descriptors = null;
try{
descriptors = manager.getSourceDescriptors( );
@@ -283,7 +240,7 @@
* @see ExtensionModuleManager@getSourceTypes
* @see ExtensionModuleManager@getSourceDescriptors
*/
- public void testGetTypesAndDescriptors(){
+ @Test public void testGetTypesAndDescriptors(){
Collection types = null;
try{
types = manager.getSourceTypes();
@@ -312,7 +269,7 @@
* Tests that an InvalidExtensionTypeException is (correctly) triggered
* @see ExtensionModuleManager@getSourceDescriptors
*/
- public void testGetDescriptorsOfInvalidType(){
+ @Test public void testGetDescriptorsOfInvalidType(){
InvalidExtensionModuleTypeException exception = null;
try{
manager.getSourceDescriptors( "!!BOGUS TYPE!!"); //$NON-NLS-1$
@@ -330,7 +287,7 @@
* Tests that the descriptor is not null and has the correct source name
* @see ExtensionModuleManager@getSourceDescriptor
*/
- public void testGetDescriptor(){
+ @Test public void testGetDescriptor(){
ExtensionModuleDescriptor result = null;
try{
result = manager.getSourceDescriptor( FakeData.TestJar2.SOURCE_NAME);
@@ -355,7 +312,7 @@
/**
* @see ExtensionModuleManager@setSearchOrder
*/
- public void testShuffleSources(){
+ @Test public void testShuffleSources(){
List sourceNames = null;
try{
sourceNames = manager.getSourceNames();
@@ -390,7 +347,7 @@
* </ul>
* @see ExtensionModuleManager@setSearchOrder
*/
- public void testInvalidOrdering(){
+ @Test public void testInvalidOrdering(){
List sourceNames = null;
List oneMissing = null;
List oneTooMany = null;
@@ -474,7 +431,7 @@
/**
* @see ExtensionModuleManager@setSearchOrder
*/
- public void testSetEnabled() throws Exception {
+ @Test public void testSetEnabled() throws Exception {
List sourceNames = new ArrayList(2);
sourceNames.add(FakeData.TestJar1.SOURCE_NAME);
sourceNames.add(FakeData.TestJar2.SOURCE_NAME);
@@ -499,7 +456,7 @@
/**
* @see ExtensionModuleManager@getSource
*/
- public void testGetSource(){
+ @Test public void testGetSource(){
byte[] source = null;
try{
source = manager.getSource( FakeData.TestJar1.SOURCE_NAME);
@@ -520,7 +477,7 @@
* @see ExtensionModuleManager@setSource
* @see ExtensionModuleManager@getSource
*/
- public void testSetSource(){
+ @Test public void testSetSource(){
ExtensionModuleDescriptor descriptor = null;
try{
descriptor = manager.setSource(PRINCIPAL, FakeData.TestTextFile.SOURCE_NAME, FakeData.TestTextFile2.data);
@@ -575,7 +532,7 @@
/**
* @see ExtensionModuleManager@setSourceName
*/
- public void testSetSourceName(){
+ @Test public void testSetSourceName(){
ExtensionModuleDescriptor descriptor = null;
String newName = "BOGUS NAME"; //$NON-NLS-1$
try{
@@ -608,7 +565,7 @@
/**
* @see ExtensionModuleManager@setSourceDescription
*/
- public void testSetSourceDescription(){
+ @Test public void testSetSourceDescription(){
ExtensionModuleDescriptor descriptor = null;
String newDesc = "BOGUS DESCRIPTION"; //$NON-NLS-1$
try{
@@ -633,7 +590,7 @@
* is the same number as one generated by scratch using the binary
* data and a java.util.zip.CRC32 instance.
*/
- public void testChecksum(){
+ @Test public void testChecksum(){
Checksum algorithm = new CRC32();
algorithm.update(FakeData.TestJar1.data, 0, FakeData.TestJar1.data.length);
long thisChecksum = algorithm.getValue();
@@ -651,25 +608,4 @@
}
}
- // ################################## TEST SUITE ################################
-
- /**
- * This suite of all tests could be defined in another class but it seems easier to
- * maintain it here.
- */
- public static Test suite() {
-
- TestSuite suite = new TestSuite();
- suite.addTestSuite(TestExtensionModuleManager.class);
- //return suite;
- return new TestSetup(suite){
- protected void setUp() throws Exception{
- TestExtensionModuleManager.setUpOnce();
- }
- protected void tearDown() throws Exception{
- TestExtensionModuleManager.tearDownOnce();
- }
- };
- }
-
}
Modified: trunk/server/src/test/java/com/metamatrix/platform/config/BaseTest.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/config/BaseTest.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/config/BaseTest.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -30,14 +30,12 @@
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
-import com.metamatrix.common.connection.ManagedConnection;
-import com.metamatrix.common.messaging.MessageBusConstants;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.platform.config.persistence.api.PersistentConnectionFactory;
import com.metamatrix.platform.config.persistence.impl.file.FilePersistentConnection;
import com.metamatrix.platform.config.spi.xml.XMLConfigurationConnector;
-import com.metamatrix.platform.config.spi.xml.XMLConfigurationConnectorFactory;
+import com.metamatrix.platform.config.spi.xml.XMLConfigurationMgr;
public abstract class BaseTest extends TestCase {
@@ -53,22 +51,11 @@
private static BasicConfigurationObjectEditor editor = new BasicConfigurationObjectEditor(
true);
- private static XMLConfigurationConnectorFactory factory = new XMLConfigurationConnectorFactory();
private XMLConfigurationConnector writer = null;
- private ManagedConnection conn = null;
public BaseTest(String name) {
super(name);
initData();
- // must remove the system property that is being set for every junit
- // test
- // the indicates to use no configuration
- Properties sysProps = System.getProperties();
- sysProps.put(MessageBusConstants.MESSAGE_BUS_TYPE,
- MessageBusConstants.TYPE_NOOP);
-
- System.setProperties(sysProps);
-
}
public BaseTest(String name, boolean useNoOpConfig) {
@@ -127,9 +114,7 @@
// configuration transactions.
public void initTransactions(Properties props) throws Exception {
- conn = factory.createConnection(props, getName());
- writer = (XMLConfigurationConnector) factory.createTransaction(conn,
- false);
+ writer = XMLConfigurationMgr.getInstance().getTransaction("test"); //$NON-NLS-1$
}
@@ -145,19 +130,10 @@
}
public void commit() throws Exception {
+ writer.executeActions(editor.getDestination().popActions());
+ writer.commit();
- try {
- writer.executeActions(editor.getDestination().popActions(),
- getName());
- writer.commit();
- } catch (Exception e) {
- writer.rollback();
- throw e;
- }
-
- writer = (XMLConfigurationConnector) factory.createTransaction(conn,
- false);
-
+ writer = XMLConfigurationMgr.getInstance().getTransaction("test"); //$NON-NLS-1$
}
protected XMLConfigurationConnector getWriter() {
Deleted: trunk/server/src/test/java/com/metamatrix/platform/config/CurrentConfigHelper.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/config/CurrentConfigHelper.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/config/CurrentConfigHelper.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,150 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config;
-
-import java.util.Properties;
-
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.messaging.MessageBusConstants;
-import com.metamatrix.platform.config.persistence.api.PersistentConnection;
-import com.metamatrix.platform.config.persistence.api.PersistentConnectionFactory;
-import com.metamatrix.platform.config.persistence.impl.file.FilePersistentConnection;
-
-public class CurrentConfigHelper {
-
- /**
- * Constructor for CurrentConfigHelper.
- */
- protected CurrentConfigHelper() {
- super();
- }
-
- /**
- * init will do the following:
- * <li>remove existing config_ns.xml file</li>
- * <li>set required system properties for CurrentConfiguration<li>
- * <li>reload CurrentConfiguration with new information from <code<fileName</code>
- * @param fileName is the configuration file to use; if contains full path, set path to null
- * @param path can optionally specify the path seperate from the fileName
- * @param principal is the user initializing configuration
-
- */
- public static void initConfig(String fileName, String path, String principal) throws Exception {
- Properties sysProps = new Properties();
- sysProps.put(MessageBusConstants.MESSAGE_BUS_TYPE, MessageBusConstants.TYPE_NOOP);
- sysProps.put(CurrentConfiguration.CONFIGURATION_READER_CLASS_PROPERTY_NAME, "com.metamatrix.platform.config.spi.xml.XMLCurrentConfigurationReader"); //$NON-NLS-1$
- sysProps.put("metamatrix.security.password.PasswordKeyStore", "c3B1dG5pazEz"); //$NON-NLS-1$ //$NON-NLS-2$
-
- initConfig(fileName, path, sysProps, principal);
- }
-
- /**
- * init will do the following:
- * <li>remove existing config_ns.xml file</li>
- * <li>set required system properties for CurrentConfiguration<li>
- * <li>reload CurrentConfiguration with new information from <code<fileName</code>
- * @param fileName is the configuration file to use; if contains full path, set path to null
- * @param path can optionally specify the path seperate from the fileName
- * @param properties will be set as the System properties
- * @param principal is the user initializing configuration
- */
- static void initConfig(String fileName, String path, Properties properties, String principal) throws Exception {
- Properties sysProps = System.getProperties();
-
- sysProps.putAll(properties);
- System.setProperties(sysProps);
-
- cleanModelFile(principal, fileName, path);
- CurrentConfiguration.getInstance().reset();
-
- createSystemProperties(fileName, path);
-
- CurrentConfiguration.getInstance().performSystemInitialization(true);
- CurrentConfiguration.getInstance().getConfiguration();
-
- }
-
-
-
- protected static void cleanModelFile(String principal, String fileName, String path) throws Exception {
- Properties props = createSystemProperties("config.xml", path);
-
- deleteModel(Configuration.NEXT_STARTUP_ID, props, principal);
-
- deleteModel(Configuration.STARTUP_ID, props, principal);
-
- }
-
- protected static Properties createSystemProperties(String fileName, String path) {
- Properties cfg_props = createProperties(fileName, path);
-
- // these system props need to be set for the CurrentConfiguration call
-
- Properties sysProps = System.getProperties();
- sysProps.putAll(cfg_props);
- System.setProperties(sysProps);
-
- return cfg_props;
-
- }
-
-
- protected static Properties createProperties(String fileName, String path) {
-
-
- Properties props = new Properties();
-
- if (fileName != null) {
- props.setProperty(FilePersistentConnection.CONFIG_NS_FILE_NAME_PROPERTY, fileName );
- props.setProperty(PersistentConnectionFactory.PERSISTENT_FACTORY_NAME, PersistentConnectionFactory.FILE_FACTORY_NAME);
- }
-
- if (path != null) {
- props.setProperty(FilePersistentConnection.CONFIG_FILE_PATH_PROPERTY, path );
- }
-
-
- return props;
-
-
-
- }
-
-
-
- public static void deleteModel(ConfigurationID configID, Properties props,
- String principal) throws Exception {
-
- PersistentConnectionFactory pf = PersistentConnectionFactory
- .createPersistentConnectionFactory(props);
-
- PersistentConnection readin = pf.createPersistentConnection();
-
- readin.delete(configID, principal);
-
- }
-
-
-}
Deleted: trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestConfigTransactions.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestConfigTransactions.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestConfigTransactions.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,382 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-
-import com.metamatrix.common.transaction.TransactionException;
-import com.metamatrix.common.transaction.TransactionNotSupportedException;
-import com.metamatrix.platform.config.BaseTest;
-import com.metamatrix.platform.config.spi.xml.ConfigTransactionException;
-import com.metamatrix.platform.config.spi.xml.ConfigUserTransaction;
-import com.metamatrix.platform.config.spi.xml.ConfigUserTransactionFactory;
-
-public class TestConfigTransactions extends BaseTest {
-
-
- public TestConfigTransactions(String name) {
- super(name);
-
- printMessages = false;
- }
-
- /**
- * Basic test, does it work
- * Test the following:
- * <li> can a read transaction be obtained
- */
- public void testReadTransaction() {
- printMsg("Starting readTransaction"); //$NON-NLS-1$
-
- ConfigUserTransaction userTrans = null;
- try {
-
-
- ConfigUserTransactionFactory factory = new ConfigUserTransactionFactory();
-
-
- userTrans = factory.createReadTransaction("TestConfigTransactions.testReadTransaction"); //$NON-NLS-1$
-
- userTrans.begin();
- userTrans.commit();
-
- } catch (Exception e) {
- System.out.println(e.getMessage());
- fail(e.getMessage());
-
- }
-
- printMsg("Completed readTransaction"); //$NON-NLS-1$
-
- }
-
-
- /**
- * Basic test, does it work
- * Test the following:
- * <li> can a read transaction be obtained
- */
- public void testWriteTransaction() throws Exception {
- printMsg("Starting testWriteTransaction"); //$NON-NLS-1$
-
-
- ConfigUserTransactionFactory factory = new ConfigUserTransactionFactory();
-
- ConfigUserTransaction userTrans = factory.createWriteTransaction("TestConfigTransactions.testReadTransaction"); //$NON-NLS-1$
-
- assertNotNull("Unable to obtain a user write transaction, userTrans is null", userTrans); //$NON-NLS-1$
-
- userTrans.begin();
- try {
- userTrans.commit();
- fail("expected exception"); //$NON-NLS-1$
- } catch (ConfigTransactionException e) {
- //TODO: this seems like a bad exception
- assertEquals("Configuration Transaction Error: Unable to set configuration changes due to there are not changes in the Transaction object.", e.getMessage()); //$NON-NLS-1$
- }
-
- printMsg("Completed testWriteTransaction"); //$NON-NLS-1$
- }
-
-
- /**
- * Test the following:
- * <li> can multiple write transactions be simultaneously obtained using the same thread
- *
- * THIS TEST SHOULD FAIL - ONLY ONE TRANSACTION PER THREAD IS VALID AT A TIME
- *
- * NOTE: This test will not work because the same thread cannot
- * obtain multiple transactions.
- * @throws Exception
- */
- public void testNegSimultaneousWriteSameThread() throws Exception {
- printMsg("Starting testNegSimultaneousReadTransactions"); //$NON-NLS-1$
-
- /**
- * This test will not work because the same thread cannot
- * obtain multiple transactions.
- */
- int num = 5;
- Collection trans = new ArrayList();
- try {
-
- ConfigUserTransactionFactory factory = new ConfigUserTransactionFactory();
-
- for (int i = 0; i<num; i++) {
- String user = "TestConfigTransactions.testWriteTransaction" + i; //$NON-NLS-1$
- ConfigUserTransaction userTrans = factory.createWriteTransaction(user);
- userTrans.begin();
- trans.add(userTrans);
- }
-
- // this should not be reached because the exception should have been thrown
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigUserTransaction ut = (ConfigUserTransaction) it.next();
- ut.commit();
- }
-
- } catch (TransactionException e) {
- // The ConfigTransactionManager throws this exception because
- // the same thread cannot obtain multiple transactons.
- printMsg("negSimultaneousWriteTransactions failed correctly"); //$NON-NLS-1$
-
- // this should not be reached because the exception should have been thrown
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigUserTransaction ut = (ConfigUserTransaction) it.next();
- try {
- ut.rollback();
- } catch (Exception re) {
- }
- }
- }
-
- printMsg("Completed testNegSimultaneousReadTransactions"); //$NON-NLS-1$
- }
-
-
- /**
- * Basic test, does it work
- * Test the following:
- * <li> can multiple read transactions be simultaneously obtained
- *
- * THIS TEST SHOULD FAIL - ONLY ONE TRANSACTION PER THREAD IS VALID AT A TIME
- *
- * NOTE: This test will not work because the same thread cannot
- * obtain multiple transactions.
- */
- public void testNegSimultaneousReadSameThread() {
- printMsg("Starting testNegSimultaneousReadTransactions"); //$NON-NLS-1$
-
- /**
- * This test will not work because the same thread cannot
- * obtain multiple transactions.
- */
- int num = 5;
- try {
- ConfigUserTransactionFactory factory = new ConfigUserTransactionFactory();
-
- Collection trans = new ArrayList();
- for (int i = 0; i<num; i++) {
- String user = "TestConfigTransactions.testReadTransaction" + i; //$NON-NLS-1$
- ConfigUserTransaction userTrans = factory.createReadTransaction(user);
- userTrans.begin();
- trans.add(userTrans);
- }
-
- // this should not be reached because the exception should have been thrown
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigUserTransaction ut = (ConfigUserTransaction) it.next();
- ut.commit();
- }
-
- } catch (Exception e) {
- // The ConfigTransactionManager throws this exception because
- // the same thread cannot obtain multiple transactons.
- if (e instanceof TransactionNotSupportedException) {
- printMsg("negSimultaneousReadTransactions failed correctly"); //$NON-NLS-1$
- } else {
-
- fail(e.getMessage());
- }
- }
-
- printMsg("Completed testNegSimultaneousReadTransactions"); //$NON-NLS-1$
-
-
- }
-
- /**
- * Test that mutliple threads can obtain a read transaction at the same time
- * Each thread can ONLY OBTAIN ON READ TRANSACTION, otherwise see
- * NOTE on test {see #testNegSimultaneousReadTransactions}
- */
- public void testMultiThreadSimultaneousReadTransactions() {
- printMsg("Starting testMultiThreadSimultaneousReadTransactions"); //$NON-NLS-1$
-
- ConfigUserTransactionFactory factory = new ConfigUserTransactionFactory();
-
- int count;
- int threadCnt = 500; // number of threads to run
- int threadTries = 1; // ONLY USE ONE,
-
- ReadTransThread[] ts = new ReadTransThread[threadCnt];
-
- for (count = 0; count < threadCnt; count++) {
- ts[count] = new ReadTransThread(factory, threadTries, count);
- }
-
- Exception e = helperMultiThreadSimultaneousTransactions(threadCnt, threadTries, ts);
- if (e != null) {
- fail(e.getMessage());
- }
-
- printMsg("Completed testMultiThreadSimultaneousReadTransactions"); //$NON-NLS-1$
-
- }
-
- private Exception helperMultiThreadSimultaneousTransactions(int threadCnt,
- int threadTries,
- BaseThread[] ts) {
-
- for(int k = 0; k < threadCnt; k++){
- ts[k].start();
- }
-
- // join the threads to finish together
- try {
- for(int k = 0; k < threadCnt; k++){
- ts[k].join();
- }
- } catch (InterruptedException e) {
- }
-
-// int cntEs = 0;
- Exception te = null;
- for(int k = 0; k < threadCnt; k++){
- if (ts[k].hasException()) {
- Exception e = ts[k].getException();
- te = e;
- break;
-
- }
- }
-
- return te;
-
- }
-
-
-
- protected class ReadTransThread extends BaseThread{
- private ConfigUserTransactionFactory factory;
-
- public ReadTransThread(ConfigUserTransactionFactory factory, int tries, int num) {
- super(tries, num);
- this.factory = factory;
- }
- public void run(){
- Collection trans = new ArrayList();
- for (int i=0; i < perThreadCnt; i++ ) {
-
- try {
-
- ConfigUserTransaction userTrans = factory.createReadTransaction(objName);
-
- userTrans.begin();
-// printMsg("<" + objName + ">Begin trans in thread ");
- trans.add(userTrans);
-
-
- } catch (Exception toe) {
- setException(toe);
-
- }
- }
- try {
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigUserTransaction ut = (ConfigUserTransaction) it.next();
- ut.commit();
-// printMsg("<" + objName + ">Committed trans in thread ");
-
- }
- } catch (Exception te) {
- setException(te);
-
- }
-
- }
- }
-
- protected class WriteTransThread extends BaseThread{
- private ConfigUserTransactionFactory factory;
-
- public WriteTransThread(ConfigUserTransactionFactory factory, int tries, int num) {
- super(tries, num);
- this.factory = factory;
- }
- public void run(){
- printMsg("<" + objName + ">Start thread " + new Date()); //$NON-NLS-1$ //$NON-NLS-2$
- Collection trans = new ArrayList();
- for (int i=0; i < perThreadCnt; i++ ) {
-
- try {
-
- ConfigUserTransaction userTrans = XMLConfigurationWriter.getWriteTransactionWithRetry(objName, factory);
-// printMsg("<" + objName + ">Begin write trans in thread ");
- printMsg("<" + objName + ">Started write trans in thread "); //$NON-NLS-1$ //$NON-NLS-2$
- trans.add(userTrans);
-
-
- } catch (Exception toe) {
- setException(toe);
-
- }
- }
- try {
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigUserTransaction ut = (ConfigUserTransaction) it.next();
- ut.commit();
- printMsg("<" + objName + ">Committed write trans in thread "); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
- } catch (Exception te) {
- setException(te);
-
- }
-
- }
-
-
- }
-
-
- protected class BaseThread extends Thread{
- protected String objName ;
- protected int perThreadCnt = 1;
- private Exception t = null;
-
-
- public BaseThread(int iterationCnt, int num) {
- perThreadCnt = iterationCnt;
- objName = "Thread " + num; //$NON-NLS-1$
- }
-
- public Exception getException() {
- return t;
- }
-
- public void setException(Exception te) {
- t = te;
- }
-
- public boolean hasException() {
- return (t==null ? false : true);
- }
-
- }
-
-
-}
Modified: trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestCurrentConfiguration.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestCurrentConfiguration.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestCurrentConfiguration.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -29,144 +29,93 @@
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.Host;
import com.metamatrix.platform.config.BaseTest;
-import com.metamatrix.platform.config.CurrentConfigHelper;
+import com.metamatrix.platform.config.util.CurrentConfigHelper;
public class TestCurrentConfiguration extends BaseTest {
- protected static final String CONFIG_30_FILE = "config_30.xml"; //$NON-NLS-1$
+ protected static final String CONFIG_30_FILE = "config30_ns.xml"; //$NON-NLS-1$
-
-
private static String PRINCIPAL = "TestCurrentConfiguration"; //$NON-NLS-1$
-//
-// private static boolean oneTime = true;
public TestCurrentConfiguration(String name) {
super(name);
printMessages = false;
-
- System.setProperty("metamatrix.encryption.jce.provider","none"); //$NON-NLS-1$ //$NON-NLS-2$$
-
-
}
-
protected void init(String cfgFile) throws Exception {
-
-
- CurrentConfigHelper.initConfig(cfgFile, this.getPath(), PRINCIPAL);
-
+ CurrentConfigHelper.initXMLConfig(cfgFile, this.getPath(), PRINCIPAL);
}
-
- public void testValidateConfiguration() {
+ public void testValidateConfiguration() throws Exception {
printMsg("Starting testValidateConfiguration"); //$NON-NLS-1$
- try {
- init(CONFIG_FILE);
-
- validConfigurationModel();
+ init(CONFIG_FILE);
+
+ validConfigurationModel();
- } catch (Exception e) {
- fail(e.getMessage());
- }
- printMsg("Completed testValidateConfiguration"); //$NON-NLS-1$
-
-
+ printMsg("Completed testValidateConfiguration"); //$NON-NLS-1$
}
- public void testSystemInitialization() {
+ public void testSystemInitialization() throws Exception {
printMsg("Starting testSystemInitialization"); //$NON-NLS-1$
- try {
-
- init(CONFIG_FILE);
-
- CurrentConfiguration.getInstance().performSystemInitialization(true);
+ init(CONFIG_FILE);
+
+ validConfigurationModel();
- validConfigurationModel();
-
-
- Properties configProps = CurrentConfiguration.getInstance().getProperties();
- if (configProps == null || configProps.isEmpty()) {
- fail("No Global Configuration Properties were found"); //$NON-NLS-1$
- }
-
-
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
-
- printMsg("Completed testSystemInitialization"); //$NON-NLS-1$
+ Properties configProps = CurrentConfiguration.getInstance().getProperties();
+ if (configProps == null || configProps.isEmpty()) {
+ fail("No Global Configuration Properties were found"); //$NON-NLS-1$
+ }
+
+ printMsg("Completed testSystemInitialization"); //$NON-NLS-1$
}
- public void testCurrentHost() {
-
+ public void testCurrentHost() throws Exception {
printMsg("Starting testCurrentHost"); //$NON-NLS-1$
- try {
- System.setProperty(CurrentConfiguration.CONFIGURATION_NAME, "DummyHost"); //$NON-NLS-1$ //$NON-NLS-2$
- System.setProperty("metamatrix.vmname", "MetaMatrixProcess"); //$NON-NLS-1$ //$NON-NLS-2$
+ System.setProperty(CurrentConfiguration.CONFIGURATION_NAME, "DummyHost"); //$NON-NLS-1$
+ System.setProperty("metamatrix.vmname", "MetaMatrixProcess"); //$NON-NLS-1$ //$NON-NLS-2$
- init(CONFIG_FILE);
-
- CurrentConfiguration.getInstance().performSystemInitialization(true);
-
- Host host = CurrentConfiguration.getInstance().getDefaultHost();
-
- if (!host.getFullName().equals("DummyHost")) { //$NON-NLS-1$
- fail("DummyHost host was not the default host in the configuration");//$NON-NLS-1$
- }
-
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
+ init(CONFIG_FILE);
+
+ Host host = CurrentConfiguration.getInstance().getDefaultHost();
+
+ if (!host.getFullName().equals("DummyHost")) { //$NON-NLS-1$
+ fail("DummyHost host was not the default host in the configuration");//$NON-NLS-1$
}
- printMsg("Completed testCurrentHost"); //$NON-NLS-1$
+ printMsg("Completed testCurrentHost"); //$NON-NLS-1$
}
- public void test30SystemInitialization() {
+ public void test30SystemInitialization() throws Exception {
printMsg("**** Starting test30SystemInitialization"); //$NON-NLS-1$
- try {
- init(CONFIG_30_FILE);
-
- CurrentConfiguration.getInstance().performSystemInitialization(true);
-
- Configuration config = CurrentConfiguration.getInstance().getConfiguration();
-
- if (config == null) {
- fail("Configuration was not obtained from CurrentConfiguration after system initialization is performed."); //$NON-NLS-1$
- }
-
- HelperTestConfiguration.validateConfigContents(config);
-
-
- Properties configProps = CurrentConfiguration.getInstance().getProperties();
- if (configProps == null || configProps.isEmpty()) {
- fail("No Global Configuration Properties were found"); //$NON-NLS-1$
- }
-
-
-
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
+ init(CONFIG_30_FILE);
+
+ Configuration config = CurrentConfiguration.getInstance().getConfiguration();
+
+ if (config == null) {
+ fail("Configuration was not obtained from CurrentConfiguration after system initialization is performed."); //$NON-NLS-1$
}
- printMsg("**** Completed test30SystemInitialization"); //$NON-NLS-1$
+ HelperTestConfiguration.validateConfigContents(config);
+
+ Properties configProps = CurrentConfiguration.getInstance().getProperties();
+ if (configProps == null || configProps.isEmpty()) {
+ fail("No Global Configuration Properties were found"); //$NON-NLS-1$
+ }
+
+
+ printMsg("**** Completed test30SystemInitialization"); //$NON-NLS-1$
}
private void validConfigurationModel() throws Exception {
Deleted: trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestCurrentConfigurationShutdown.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestCurrentConfigurationShutdown.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestCurrentConfigurationShutdown.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.StartupStateController;
-import com.metamatrix.common.config.api.ConfigurationModelContainer;
-import com.metamatrix.platform.config.BaseTest;
-import com.metamatrix.platform.config.CurrentConfigHelper;
-
-public class TestCurrentConfigurationShutdown extends BaseTest {
-
-
- private static String PRINCIPAL = "TestCurrentConfigurationShutdown"; //$NON-NLS-1$
-
-
- public TestCurrentConfigurationShutdown(String name) {
- super(name);
- printMessages = false;
-
- }
-
- public void testSystemShutdown() throws Exception {
-
- printMsg("Starting testSystemShutdown"); //$NON-NLS-1$
-
- CurrentConfigHelper.initConfig(CONFIG_FILE, this.getPath(), PRINCIPAL);
-// CurrentConfiguration.getInstance().performSystemInitialization(true);
-
- validConfigurationModel();
-// Configuration config = CurrentConfiguration.getInstance().getConfiguration();
-//
-// if (config == null) {
-// fail("Configuration was not obtained from CurrentConfiguration after system initialization is performed."); //$NON-NLS-1$
-// }
-//
-// HelperTestConfiguration.validateConfigContents(config);
-
- printMsg("Call Configuration to Shutdown System"); //$NON-NLS-1$
-
- CurrentConfiguration.getInstance().indicateSystemShutdown();
-
- printMsg("Shutdown System"); //$NON-NLS-1$
-
- XMLConfigurationMgr mgr = XMLConfigurationMgr.getInstance();
-
- printMsg("Check System State"); //$NON-NLS-1$
- int state = mgr.getServerStartupState();
- if (state != StartupStateController.STATE_STOPPED) {
-
- String lbl;
- if (state == StartupStateController.STATE_STARTED) {
- lbl = StartupStateController.STATE_STARTED_LABEL;
- } else if (state == StartupStateController.STATE_STARTING) {
- lbl = StartupStateController.STATE_STARTING_LABEL;
- } else {
- lbl = "UNDEFINED STATE CODE of " + state; //$NON-NLS-1$
- }
-
- fail("Server State was not set to " + StartupStateController.STATE_STOPPED_LABEL + //$NON-NLS-1$
- " but is currently set to " + lbl); //$NON-NLS-1$
- }
-
- printMsg("Completed testSystemShutdown"); //$NON-NLS-1$
-
- }
-
- private void validConfigurationModel() throws Exception {
- ConfigurationModelContainer ccm = CurrentConfiguration.getInstance().getConfigurationModel();
- if (ccm == null) {
- fail("Configuration Model was not obtained from CurrentConfiguration"); //$NON-NLS-1$
- }
-
-
- HelperTestConfiguration.validateModelContents(ccm);
-
- }
-
-
-
-}
-
Modified: trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestInitialConfigurationRead.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestInitialConfigurationRead.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestInitialConfigurationRead.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -27,72 +27,53 @@
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.platform.config.BaseTest;
-import com.metamatrix.platform.config.CurrentConfigHelper;
+import com.metamatrix.platform.config.util.CurrentConfigHelper;
-
/**
-* This only test one call to the CurrentConfiguration because it assumes
-* nothing else has run to load the configuration in the VM.
-*
-* As with TestCurrentConfiguration, it doesn't know what order the methods will
-* be called that it has to clear the cache everytime.
-*/
-public class TestInitialConfigurationRead extends BaseTest{
-
- private static String PRINCIPAL = "TestInitialConfigurationRead"; //$NON-NLS-1$
-
- public TestInitialConfigurationRead(String name) {
- super(name);
-
- }
+ * This only test one call to the CurrentConfiguration because it assumes
+ * nothing else has run to load the configuration in the VM.
+ *
+ * As with TestCurrentConfiguration, it doesn't know what order the methods will
+ * be called that it has to clear the cache everytime.
+ */
+public class TestInitialConfigurationRead extends BaseTest {
+ private static String PRINCIPAL = "TestInitialConfigurationRead"; //$NON-NLS-1$
+
+ public TestInitialConfigurationRead(String name) {
+ super(name);
+
+ }
+
protected void setUp() throws Exception {
super.setUp();
- CurrentConfigHelper.initConfig(CONFIG_FILE, this.getPath(), PRINCIPAL);
+ CurrentConfigHelper.initXMLConfig(CONFIG_FILE, this.getPath(), PRINCIPAL);
- }
-
-
- /**
- */
- public void testValidateReader() {
- printMsg("Starting TestInititaltConfigurationRead"); //$NON-NLS-1$
+ }
-
- try {
-
- createSystemProperties("config.xml"); //$NON-NLS-1$
-
- // do the reset after setting the system properties
- CurrentConfiguration.getInstance().reset();
-
- validConfigurationModel();
-
- } catch (Exception e) {
- fail(e.getMessage());
- }
- printMsg("Completed TestInititaltConfigurationRead"); //$NON-NLS-1$
-
- }
-
- private void validConfigurationModel() throws Exception {
- ConfigurationModelContainer ccm = CurrentConfiguration.getInstance().getConfigurationModel();
- if (ccm == null) {
- fail("Configuration Model was not obtained from CurrentConfiguration"); //$NON-NLS-1$
- }
-
- Collection providers = ccm.getConfiguration().getAuthenticationProviders();
- if (providers == null || providers.size() == 0) {
- fail("no providers"); //$NON-NLS-1$
- }
-
- HelperTestConfiguration.validateModelContents(ccm);
-
- System.out.println("Providers "+ providers.size()); //$NON-NLS-1$
- }
-
-
-
-
-}
+ /**
+ * @throws Exception
+ */
+ public void testValidateReader() throws Exception {
+ printMsg("Starting TestInititaltConfigurationRead"); //$NON-NLS-1$
+ createSystemProperties("config.xml"); //$NON-NLS-1$
+
+ // do the reset after setting the system properties
+ CurrentConfiguration.reset();
+
+ ConfigurationModelContainer ccm = CurrentConfiguration.getInstance().getConfigurationModel();
+ assertNotNull("Configuration Model was not obtained from CurrentConfiguration", ccm); //$NON-NLS-1$
+
+ Collection providers = ccm.getConfiguration()
+ .getAuthenticationProviders();
+ if (providers == null || providers.size() == 0) {
+ fail("no providers"); //$NON-NLS-1$
+ }
+
+ HelperTestConfiguration.validateModelContents(ccm);
+
+ printMsg("Completed TestInititaltConfigurationRead"); //$NON-NLS-1$
+ }
+
+}
Modified: trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigImportExport.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigImportExport.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigImportExport.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -56,11 +56,11 @@
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.config.BaseTest;
-import com.metamatrix.platform.config.CurrentConfigHelper;
import com.metamatrix.platform.config.persistence.api.PersistentConnection;
import com.metamatrix.platform.config.persistence.api.PersistentConnectionFactory;
import com.metamatrix.platform.config.persistence.impl.file.FilePersistentConnection;
import com.metamatrix.platform.config.persistence.impl.file.FilePersistentUtil;
+import com.metamatrix.platform.config.util.CurrentConfigHelper;
import com.metamatrix.platform.util.ErrorMessageKeys;
@@ -83,7 +83,7 @@
private void initializeConfig(String fileName) throws Exception {
printMsg("Perform initializeConfig using " + fileName); //$NON-NLS-1$
- CurrentConfigHelper.initConfig(fileName, this.getPath(), PRINCIPAL);
+ CurrentConfigHelper.initXMLConfig(fileName, this.getPath(), PRINCIPAL);
this.initTransactions(new Properties());
@@ -126,18 +126,15 @@
Properties props = PropertiesUtils.clone(properties, false);
- PersistentConnectionFactory pf = PersistentConnectionFactory.createPersistentConnectionFactory(props);
+ PersistentConnectionFactory pf = new PersistentConnectionFactory(props);
-// PersistentConnectionFactory pf = new PersistentConnectionFactory();
+ PersistentConnection pc = pf.createPersistentConnection(false);
-
- PersistentConnection pc = pf.createPersistentConnection();
-
- // System.out.println("Props: " + PropertiesUtils.prettyPrint(resourcePoolProperties));
-
// write the models out
pc.delete(Configuration.NEXT_STARTUP_ID, principal);
pc.write(nsModel, principal);
+ pc.commit();
+ pc.close();
}
Modified: trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigReader.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigReader.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigReader.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -26,7 +26,6 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
-import java.util.Properties;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.ComponentType;
@@ -35,18 +34,13 @@
import com.metamatrix.common.config.api.Configuration;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.SharedResource;
-import com.metamatrix.common.connection.ManagedConnection;
import com.metamatrix.platform.config.BaseTest;
-import com.metamatrix.platform.config.CurrentConfigHelper;
+import com.metamatrix.platform.config.util.CurrentConfigHelper;
public class TestXMLConfigReader extends BaseTest {
private static String PRINCIPAL = "TestXMLConfigReader"; //$NON-NLS-1$
- protected static final String CONFIG_FILE = "config.xml"; //$NON-NLS-1$
- private ManagedConnection conn;
- private XMLConfigurationConnectorFactory factory;
-
public TestXMLConfigReader(String name) {
super(name);
@@ -55,16 +49,12 @@
protected void setUp() throws Exception {
super.setUp();
- CurrentConfigHelper.initConfig(CONFIG_FILE, this.getPath(), PRINCIPAL);
-
- factory = new XMLConfigurationConnectorFactory();
-
- conn = factory.createConnection(new Properties(), PRINCIPAL);
+ CurrentConfigHelper.initXMLConfig(CONFIG_FILE, this.getPath(), PRINCIPAL);
}
public void testValidateReader() throws Exception {
- XMLConfigurationConnector reader = (XMLConfigurationConnector)factory.createTransaction(conn, true);
+ XMLConfigurationConnector reader = XMLConfigurationMgr.getInstance().getTransaction(PRINCIPAL);
printMsg("Validate ComponentTypes Exists"); //$NON-NLS-1$
Collection compTypes = reader.getAllComponentTypes(true);
Modified: trunk/server/src/test/java/com/metamatrix/platform/registry/FakeRegistryUtil.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/registry/FakeRegistryUtil.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/registry/FakeRegistryUtil.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -116,6 +116,7 @@
ProcessRegistryBinding binding = new ProcessRegistryBinding(hostName, processName, defn1, vmInterface1, new NoOpMessageBus());
binding.setAlive(true);
+ binding.setStartTime(new Date(1234).getTime());
return binding;
}
Modified: trunk/server/src/test/java/com/metamatrix/platform/registry/TestServiceRegistryBinding.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/registry/TestServiceRegistryBinding.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server/src/test/java/com/metamatrix/platform/registry/TestServiceRegistryBinding.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -29,7 +29,6 @@
import com.metamatrix.admin.server.FakeConfiguration;
import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.messaging.MessageBusConstants;
import com.metamatrix.common.messaging.NoOpMessageBus;
import com.metamatrix.platform.service.api.ServiceID;
import com.metamatrix.platform.service.api.ServiceInterface;
@@ -73,7 +72,6 @@
}
public void testStateCheckingProxy() throws Exception {
- System.setProperty(MessageBusConstants.MESSAGE_BUS_TYPE, MessageBusConstants.TYPE_NOOP);
FakeServiceImpl service = new FakeServiceImpl();
ProcessRegistryBinding vmBinding2 = FakeRegistryUtil.buildVMRegistryBinding("2.2.2.2", "process2"); //$NON-NLS-1$ //$NON-NLS-2$
Deleted: trunk/server-installer/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java
===================================================================
--- trunk/server-installer/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java 2009-04-01 19:34:34 UTC (rev 685)
+++ trunk/server-installer/src/main/java/com/metamatrix/platform/config/util/CurrentConfigHelper.java 2009-04-01 20:56:55 UTC (rev 686)
@@ -1,160 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.util;
-
-import java.io.File;
-import java.util.Properties;
-
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.ConfigurationID;
-import com.metamatrix.common.messaging.MessageBusConstants;
-import com.metamatrix.platform.config.persistence.api.PersistentConnection;
-import com.metamatrix.platform.config.persistence.api.PersistentConnectionFactory;
-import com.metamatrix.platform.config.persistence.impl.file.FilePersistentConnection;
-
-/**
- * The CurrentConfigHelper is used to load a configuration into memory when a repository isn't available.
- * @author vanhalbert
- *
- */
-public class CurrentConfigHelper {
-
- /**
- * Constructor for CurrentConfigHelper.
- */
- protected CurrentConfigHelper() {
- super();
- }
-
- /**
- * init will do the following:
- * <li>remove existing config_ns.xml file</li>
- * <li>set required system properties for CurrentConfiguration<li>
- * <li>reload CurrentConfiguration with new information from <code<fileName</code>
- * @param fileName is the configuration file to use; if contains full path, set path to null
- * @param path can optionally specify the path seperate from the fileName
- * @param principal is the user initializing configuration
-
- */
- public static void initConfig(String fileName, String path, String principal) throws Exception {
- Properties sysProps = new Properties();
- sysProps.put(MessageBusConstants.MESSAGE_BUS_TYPE, MessageBusConstants.TYPE_NOOP);
-
- File f = new File(path, fileName);
- if (!f.exists()) {
- throw new Exception("Configuration file " + f.getAbsolutePath() + " does not exist");
- }
-
- initConfig(fileName, path, sysProps, principal);
- }
-
- /**
- * init will do the following:
- * <li>remove existing config_ns.xml file</li>
- * <li>set required system properties for CurrentConfiguration<li>
- * <li>reload CurrentConfiguration with new information from <code<fileName</code>
- * @param fileName is the configuration file to use; if contains full path, set path to null
- * @param path can optionally specify the path seperate from the fileName
- * @param properties will be set as the System properties
- * @param principal is the user initializing configuration
- */
- static void initConfig(String fileName, String path, Properties properties, String principal) throws Exception {
- Properties sysProps = System.getProperties();
-
- sysProps.putAll(properties);
- System.setProperties(sysProps);
-
- cleanModelFile(principal, fileName, path);
- CurrentConfiguration.getInstance().reset();
-
- createSystemProperties(fileName, path);
-
- CurrentConfiguration.getInstance().performSystemInitialization(true);
- Configuration config = CurrentConfiguration.getInstance().getConfiguration();
- System.out.println("Configuration: " + config.getFullName());
-
- }
-
-
-
- protected static void cleanModelFile(String principal, String fileName, String path) throws Exception {
- Properties props = createSystemProperties(fileName, path);
-
- deleteModel(Configuration.NEXT_STARTUP_ID, props, principal);
-
- deleteModel(Configuration.STARTUP_ID, props, principal);
-
- }
-
- protected static Properties createSystemProperties(String fileName, String path) {
- Properties cfg_props = createProperties(fileName, path);
-
- // these system props need to be set for the CurrentConfiguration call
-
- Properties sysProps = System.getProperties();
- sysProps.putAll(cfg_props);
- System.setProperties(sysProps);
-
- return cfg_props;
-
- }
-
-
- protected static Properties createProperties(String fileName, String path) {
-
-
- Properties props = new Properties();
-
- if (fileName != null) {
- props.setProperty(FilePersistentConnection.CONFIG_NS_FILE_NAME_PROPERTY, fileName );
- props.setProperty(PersistentConnectionFactory.PERSISTENT_FACTORY_NAME, PersistentConnectionFactory.FILE_FACTORY_NAME);
- }
-
- if (path != null) {
- props.setProperty(FilePersistentConnection.CONFIG_FILE_PATH_PROPERTY, path );
- }
-
-
- return props;
-
-
-
- }
-
-
-
- public static void deleteModel(ConfigurationID configID, Properties props,
- String principal) throws Exception {
-
- PersistentConnectionFactory pf = PersistentConnectionFactory
- .createPersistentConnectionFactory(props);
-
- PersistentConnection readin = pf.createPersistentConnection();
-
- readin.delete(configID, principal);
-
- }
-
-
-}
[View Less]
16 years
teiid SVN: r685 - trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-01 15:34:34 -0400 (Wed, 01 Apr 2009)
New Revision: 685
Modified:
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java
Log:
removing the catch (Exception e) to specific catch calls
Modified: trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/admin/…
[View More]apiimpl/RuntimeStateAdminAPIHelper.java 2009-04-01 18:16:58 UTC (rev 684)
+++ trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java 2009-04-01 19:34:34 UTC (rev 685)
@@ -307,9 +307,8 @@
if (hData.isDeployed() && !hData.isRegistered()) {
try {
this.hostManagement.startServers(hData.getName());
- } catch (Exception e) {
+ } catch (MetaMatrixComponentException e) {
exceptions.add(e);
- // errorMsg.append(e.getMessage());
}
newHosts.add(hData);
}
@@ -349,9 +348,8 @@
try {
ProcessRegistryBinding vmBinding = this.registry.getProcessBinding(pData.getHostName(), pData.getName());
vmController = vmBinding.getProcessController();
- } catch (Exception e) {
- exceptions.add(e); // if we can't get the vmController then go to next process
- // errorMsg.append(e.getMessage());
+ } catch (ResourceNotBoundException e) {
+ exceptions.add(new MetaMatrixComponentException(e, e.getMessage()));
break;
}
}
@@ -359,7 +357,7 @@
if (pData.isDeployed() && !pData.isRegistered()) {
try {
this.hostManagement.startServer(hostName, pData.getName());
- } catch (Exception e) {
+ } catch (MetaMatrixComponentException e) {
exceptions.add(e);
}
// not deployed/Running - stopVM and then kill via MetaMatrixController
@@ -377,43 +375,35 @@
Iterator sIter = services.iterator();
// looping thru services
while (sIter.hasNext()) {
- ServiceData sData = (ServiceData)sIter.next();
- // if not deployed but running then kill, kill, kill
- if (!sData.isDeployed() && sData.isRegistered()) {
- try {
- vmController.stopService(sData.getServiceID(), false, true);
- } catch (Exception e) {
- exceptions.add(e);
- }
- // if deployed but not running then start
- } else if (sData.isDeployed() && !sData.isRegistered()) {
- try {
- vmController.startDeployedService((ServiceComponentDefnID)sData.getComponentDefnID());
- } catch (Exception e) {
- exceptions.add(e);
- }
- // deployed and registered
- // make sure we are running
- } else if (sData.isDeployed() && sData.isRegistered()) {
- ServiceID serviceID = sData.getServiceID();
- try {
- switch (sData.getCurrentState()) {
- case ServiceState.STATE_CLOSED:
- case ServiceState.STATE_FAILED:
- case ServiceState.STATE_INIT_FAILED:
- vmController.startService(serviceID);
- break;
-
- case ServiceState.STATE_DATA_SOURCE_UNAVAILABLE:
- vmController.checkService(serviceID);
- break;
-
- default:
- }
- } catch (Exception e) {
- exceptions.add(e);
- }
- }
+ try {
+ ServiceData sData = (ServiceData)sIter.next();
+ // if not deployed but running then kill, kill, kill
+ if (!sData.isDeployed() && sData.isRegistered()) {
+ vmController.stopService(sData.getServiceID(), false, true);
+ // if deployed but not running then start
+ } else if (sData.isDeployed() && !sData.isRegistered()) {
+ vmController.startDeployedService((ServiceComponentDefnID)sData.getComponentDefnID());
+ // deployed and registered
+ // make sure we are running
+ } else if (sData.isDeployed() && sData.isRegistered()) {
+ ServiceID serviceID = sData.getServiceID();
+ switch (sData.getCurrentState()) {
+ case ServiceState.STATE_CLOSED:
+ case ServiceState.STATE_FAILED:
+ case ServiceState.STATE_INIT_FAILED:
+ vmController.startService(serviceID);
+ break;
+
+ case ServiceState.STATE_DATA_SOURCE_UNAVAILABLE:
+ vmController.checkService(serviceID);
+ break;
+
+ default:
+ }
+ }
+ } catch (ServiceException e) {
+ exceptions.add(new MetaMatrixComponentException(e, e.getMessage()));
+ }
}
}
}
[View Less]
16 years
teiid SVN: r684 - trunk/client-jdbc/src/main/java/com/metamatrix/jdbc.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-01 14:16:58 -0400 (Wed, 01 Apr 2009)
New Revision: 684
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
Log:
TEIID-452
Modified: trunk/…
[View More]client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-04-01 18:16:01 UTC (rev 683)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-04-01 18:16:58 UTC (rev 684)
@@ -114,7 +114,7 @@
// logging
String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
- logger.info(logMsg);
+ logger.fine(logMsg);
return conn;
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-04-01 18:16:01 UTC (rev 683)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-04-01 18:16:58 UTC (rev 684)
@@ -164,7 +164,7 @@
info.put(ExecutionProperties.ALLOW_DBL_QUOTED_VARIABLE, Boolean.FALSE.toString());
}
- logger.info(JDBCPlugin.Util.getString("MMConnection.Session_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMConnection.Session_success")); //$NON-NLS-1$
logConnectionProperties(url, info);
// properties object used in obtaining connection
@@ -197,7 +197,7 @@
modifiedUrl.append(";").append(connUrl.substring(endIndex)); //$NON-NLS-1$
}
}
- logger.info("Connection Url="+modifiedUrl); //$NON-NLS-1$
+ logger.fine("Connection Url="+modifiedUrl); //$NON-NLS-1$
}
// Now clone the properties object and remove password and trusted token
@@ -208,7 +208,7 @@
Object anObj = info.get(key);
// Log each property except for password and token.
if (!MMURL.JDBC.CREDENTIALS.equalsIgnoreCase(key) && !MMURL.CONNECTION.PASSWORD.equalsIgnoreCase(key) && !MMURL.CONNECTION.CLIENT_TOKEN_PROP.equalsIgnoreCase(key)) {
- logger.info(key+"="+anObj); //$NON-NLS-1$
+ logger.fine(key+"="+anObj); //$NON-NLS-1$
}
}
}
@@ -278,7 +278,7 @@
} catch (SQLException se) {
throw MMSQLException.create(se, JDBCPlugin.Util.getString("MMConnection.Err_connection_close", se.getMessage())); //$NON-NLS-1$
} finally {
- logger.info(JDBCPlugin.Util.getString("MMConnection.Connection_close_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMConnection.Connection_close_success")); //$NON-NLS-1$
// set the status of the connection to closed
closed = true;
}
@@ -345,7 +345,7 @@
} catch (XATransactionException e) {
throw MMSQLException.create(e);
}
- logger.info(JDBCPlugin.Util.getString("MMConnection.Commit_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMConnection.Commit_success")); //$NON-NLS-1$
}
private void beginLocalTxn() throws SQLException {
@@ -710,7 +710,7 @@
} catch (XATransactionException e) {
throw MMSQLException.create(e);
}
- logger.info(JDBCPlugin.Util.getString("MMConnection.Rollback_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMConnection.Rollback_success")); //$NON-NLS-1$
} finally {
if (startTxn) {
beginLocalTxn();
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2009-04-01 18:16:01 UTC (rev 683)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2009-04-01 18:16:58 UTC (rev 684)
@@ -478,7 +478,7 @@
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.Best_row_sucess", table); //$NON-NLS-1$
- logger.info(logMsg);
+ logger.fine(logMsg);
// construct results object from column values and their metadata
return createResultSet(records, metadataList);
@@ -506,7 +506,7 @@
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.Catalog_success"); //$NON-NLS-1$
- logger.info(logMsg);
+ logger.fine(logMsg);
// construct results object from column values and their metadata
return createResultSet(records, metadataList);
@@ -695,7 +695,7 @@
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCols_success", columnNamePattern, tableNamePattern); //$NON-NLS-1$
- logger.info(logMsg);
+ logger.fine(logMsg);
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
@@ -813,7 +813,7 @@
// logging
String logMsg = JDBCPlugin.Util.getString("MMDatabaseMetadata.getCrossRef_success", primaryTable, foreignTable); //$NON-NLS-1$
- logger.info(logMsg);
+ logger.fine(logMsg);
return resultSet;
}
@@ -997,7 +997,7 @@
ResultSet resultSet = getReferenceKeys(results);
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getExpKey_success", table));//$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getExpKey_success", table));//$NON-NLS-1$
return resultSet;
}
@@ -1071,7 +1071,7 @@
ResultSet resultSet = getReferenceKeys(results);
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getImpKey_success", table)); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getImpKey_success", table)); //$NON-NLS-1$
return resultSet;
}
@@ -1143,7 +1143,7 @@
throw MMSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_error", table, e.getMessage())); //$NON-NLS-1$
}
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_success", table)); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getIndex_success", table)); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
@@ -1439,7 +1439,7 @@
throw MMSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_error", table, e.getMessage())); //$NON-NLS-1$
}
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getPrimaryKey_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
@@ -1533,7 +1533,7 @@
throw MMSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_error", columnNamePattern, e.getMessage())); //$NON-NLS-1$
}
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_success", columnNamePattern, procedureNamePattern)); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProcCol_success", columnNamePattern, procedureNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
@@ -1640,7 +1640,7 @@
throw MMSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_error", procedureNamePattern, e.getMessage())); //$NON-NLS-1$
}
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_success", procedureNamePattern)); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getProc_success", procedureNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
@@ -1721,7 +1721,7 @@
throw MMSQLException.create(e, JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_error", e.getMessage())); //$NON-NLS-1$
}
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getschema_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
@@ -2013,7 +2013,7 @@
// manually send out a close request is very necessary for PreparedStatement.
//prepareQuery.close();
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_success", tableNamePattern)); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTable_success", tableNamePattern)); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
@@ -2080,7 +2080,7 @@
metadataList[0] = getColumnMetadata(null, JDBCColumnNames.TABLE_TYPES.TABLE_TYPE,
MMJDBCSQLTypeInfo.STRING, ResultsMetadataConstants.NULL_TYPES.NOT_NULL);
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTableType_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTableType_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, metadataList);
@@ -2147,7 +2147,7 @@
ResultSetMetaData rmetadata = ResultsMetadataWithProvider.newInstance(StaticMetadataProvider.createWithData(metadataList, 0));
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTypes_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getTypes_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
@@ -2232,7 +2232,7 @@
// Method not supported, retuning empty ResultSet
ResultSet resultSet = getBestRowIdentifier(catalog, schema, table, 0, true);
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getVersionCols_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getVersionCols_success")); //$NON-NLS-1$
return resultSet;
}
@@ -3211,7 +3211,7 @@
// close the resultset and driver connection
//results.close();
- logger.info(JDBCPlugin.Util.getString("MMDatabaseMetadata.getRefKey_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMDatabaseMetadata.getRefKey_success")); //$NON-NLS-1$
// construct results object from column values and their metadata
return createResultSet(records, rmetadata);
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2009-04-01 18:16:01 UTC (rev 683)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDriver.java 2009-04-01 18:16:58 UTC (rev 684)
@@ -131,7 +131,7 @@
// logging
String logMsg = JDBCPlugin.Util.getString("JDBCDriver.Connection_sucess"); //$NON-NLS-1$
- logger.info(logMsg);
+ logger.fine(logMsg);
return myConnection;
}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-04-01 18:16:01 UTC (rev 683)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2009-04-01 18:16:58 UTC (rev 684)
@@ -305,7 +305,7 @@
// Remove link from connection to statement
this.driverConnection.closeStatement(this);
- logger.info(JDBCPlugin.Util.getString("MMStatement.Close_stmt_success")); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMStatement.Close_stmt_success")); //$NON-NLS-1$
driverConnection = null;
}
@@ -439,7 +439,7 @@
createResultSet(resultsMsg);
}
- logger.info(JDBCPlugin.Util.getString("MMStatement.Success_query", reqMessage.getCommandString())); //$NON-NLS-1$
+ logger.fine(JDBCPlugin.Util.getString("MMStatement.Success_query", reqMessage.getCommandString())); //$NON-NLS-1$
}
protected RequestMessage createRequestMessage(String[] commands,
[View Less]
16 years
teiid SVN: r683 - trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-04-01 14:16:01 -0400 (Wed, 01 Apr 2009)
New Revision: 683
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
Log:
TEIID-297: making the default get operation delegate the call to the time unit based get and wait for the amount of synchronization time
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java
==================================…
[View More]=================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2009-04-01 13:51:04 UTC (rev 682)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/socket/client/SocketServerInstanceImpl.java 2009-04-01 18:16:01 UTC (rev 683)
@@ -275,9 +275,12 @@
}
@Override
- public synchronized Object get()
- throws InterruptedException, ExecutionException {
- throw new UnsupportedOperationException();
+ public synchronized Object get() throws InterruptedException, ExecutionException {
+ try {
+ return this.get(SocketServerConnectionFactory.getInstance().getSynchronousTtl(), TimeUnit.MILLISECONDS);
+ } catch (TimeoutException e) {
+ throw new ExecutionException(e);
+ }
}
/**
[View Less]
16 years
teiid SVN: r682 - trunk/client/src/main/java/com/metamatrix/common/comm/platform/client.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-04-01 09:51:04 -0400 (Wed, 01 Apr 2009)
New Revision: 682
Modified:
trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/ServerAdminFactory.java
Log:
TEIID-422 - Removed extraneous getSystem() call.
Modified: trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/ServerAdminFactory.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/…
[View More]ServerAdminFactory.java 2009-04-01 13:10:03 UTC (rev 681)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/platform/client/ServerAdminFactory.java 2009-04-01 13:51:04 UTC (rev 682)
@@ -214,10 +214,7 @@
ServerAdmin serverAdmin = (ServerAdmin)Proxy.newProxyInstance(Thread.currentThread()
.getContextClassLoader(), new Class[] { ServerAdmin.class }, new ReconnectingProxy(p));
- //make a method call, to test that we are connected
- serverAdmin.getSystem();
-
- return serverAdmin;
+ return serverAdmin;
}
}
[View Less]
16 years
teiid SVN: r681 - trunk/server/src/main/java/com/metamatrix/server.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-04-01 09:10:03 -0400 (Wed, 01 Apr 2009)
New Revision: 681
Modified:
trunk/server/src/main/java/com/metamatrix/server/ServiceManager.java
Log:
TEIID 452 - commands were removed, but the internal numbering wasn't adjusted, causing the max command number (35) to be greater than the actual number of commands (30) and therefore causing a ArrayOutOfBounds exception.
Modified: trunk/server/src/main/java/com/metamatrix/server/ServiceManager.java
===========…
[View More]========================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServiceManager.java 2009-04-01 01:10:40 UTC (rev 680)
+++ trunk/server/src/main/java/com/metamatrix/server/ServiceManager.java 2009-04-01 13:10:03 UTC (rev 681)
@@ -87,22 +87,22 @@
private final static int COMMAND_LIST_VM_PROPERTIES = 12;
private final static int COMMAND_LIST_SERVICE_PROPERTIES = 13;
private final static int COMMAND_SHUTDOWN_SERVER = 14;
- private final static int COMMAND_SHUTDOWN_VM = 17;
- private final static int COMMAND_START_SERVICE = 19;
- private final static int COMMAND_EXPERT_MODE_ON = 20;
- private final static int COMMAND_EXPERT_MODE_OFF = 21;
- private final static int COMMAND_GET_SERVICE_QUEUES = 22;
- private final static int COMMAND_GET_VM_STATS = 24;
- private final static int COMMAND_DUMP_THREADS = 25;
- private final static int COMMAND_SYNCH_SERVER = 26;
- private final static int COMMAND_KILL_ALL_HCS = 27;
- private final static int COMMAND_KILL_HC = 28;
- private final static int COMMAND_BOUNCE_SERVICE = 29;
- private final static int COMMAND_CLEAR_CODE_TABLE_CACHES = 30;
- private final static int COMMAND_CLEAR_PREPARED_STMT_CACHES = 31;
- private final static int COMMAND_EXIT = 33;
- private final static int COMMAND_HELP = 34;
- private final static int COMMAND_INVALID = 35;
+ private final static int COMMAND_SHUTDOWN_VM = 15;
+ private final static int COMMAND_START_SERVICE = 16;
+ private final static int COMMAND_EXPERT_MODE_ON = 17;
+ private final static int COMMAND_EXPERT_MODE_OFF = 18;
+ private final static int COMMAND_GET_SERVICE_QUEUES = 19;
+ private final static int COMMAND_GET_VM_STATS = 20;
+ private final static int COMMAND_DUMP_THREADS = 21;
+ private final static int COMMAND_SYNCH_SERVER = 22;
+ private final static int COMMAND_KILL_ALL_HCS = 23;
+ private final static int COMMAND_KILL_HC = 24;
+ private final static int COMMAND_BOUNCE_SERVICE = 25;
+ private final static int COMMAND_CLEAR_CODE_TABLE_CACHES = 26;
+ private final static int COMMAND_CLEAR_PREPARED_STMT_CACHES = 27;
+ private final static int COMMAND_EXIT = 28;
+ private final static int COMMAND_HELP = 29;
+ private final static int COMMAND_INVALID = 30;
private final static String[] commands = {"ListProcesses", //$NON-NLS-1$
[View Less]
16 years
teiid SVN: r680 - trunk/common-internal/src/test/java/com/metamatrix/common/queue.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-03-31 21:10:40 -0400 (Tue, 31 Mar 2009)
New Revision: 680
Modified:
trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java
Log:
TEIID-445 fix for re-executing a failed task
Modified: trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java …
[View More]2009-04-01 01:09:19 UTC (rev 679)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/queue/TestQueueWorkerPool.java 2009-04-01 01:10:40 UTC (rev 680)
@@ -29,6 +29,7 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Test;
@@ -151,5 +152,19 @@
future.cancel(true);
assertEquals(10, result.size());
}
+
+ @Test public void testFailingWork() throws Exception {
+ final WorkerPool pool = WorkerPoolFactory.newWorkerPool("test", 5, 120000); //$NON-NLS-1$
+ final AtomicInteger count = new AtomicInteger();
+ pool.execute(new Runnable() {
+ @Override
+ public void run() {
+ count.getAndIncrement();
+ throw new RuntimeException();
+ }
+ });
+ Thread.sleep(10);
+ assertEquals(1, count.get());
+ }
}
[View Less]
16 years