use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.
the class TreeMouseListener method getLogConfFromService.
private LoggingConfigurableOperations getLogConfFromService(final String serviceName) throws Exception {
System.out.println("Getting LoggingConfigurable out of Manager for service " + serviceName);
// Manager
final Manager mgr = model.getManagerRef();
if (mgr == null) {
throw new Exception("Invalid manager reference");
}
SwingWorker<LoggingConfigurableOperations, Void> worker = new SwingWorker<LoggingConfigurableOperations, Void>() {
protected LoggingConfigurableOperations doInBackground() throws Exception {
LoggingConfigurableOperations logConf;
try {
logConf = LoggingConfigurableHelper.narrow(mgr.get_service(model.getAdminClient().getHandle(), serviceName, false));
} catch (Throwable t) {
throw new Exception("Error getting the LoggingConfigurable out of Manager for service " + serviceName + " :\n" + t.getMessage(), t);
}
return logConf;
}
};
worker.execute();
return worker.get();
}
use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.
the class TreeMouseListener method getLogConfFromContainer.
/**
* Get the LoggingConfigurable out of the container
*
* @return The LoggingConfigurable for the container
*/
private LoggingConfigurableOperations getLogConfFromContainer(ContainerInfo info) throws Exception {
if (info == null) {
throw new IllegalArgumentException("Invalid null ContainerInfo");
}
final Container cnt = info.reference;
if (cnt == null) {
throw new Exception("The reference to the container is null in ContainerInfo");
}
SwingWorker<LoggingConfigurableOperations, Void> worker = new SwingWorker<LoggingConfigurableOperations, Void>() {
protected LoggingConfigurableOperations doInBackground() throws Exception {
LoggingConfigurableOperations logConf;
try {
logConf = LoggingConfigurableHelper.narrow(cnt);
} catch (Throwable t) {
throw new Exception("Error getting the LoggingConfigurable out of Manager:\n" + t.getMessage(), t);
}
return logConf;
}
};
worker.execute();
return worker.get();
}
use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.
the class TreeMouseListener method showLoggingConfigTab.
/**
* Show the dialog to read and configure the log level
*
* @param path The path of the selected node
*
*/
private void showLoggingConfigTab(TreePath path) {
if (path == null) {
throw new IllegalArgumentException("Invalid null path");
}
DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) path.getLastPathComponent();
DefaultMutableTreeNode targetNode = selNode;
boolean implementsLogging = implementsLoggingConfigurable(selNode);
if (!implementsLogging) {
// yatagai: ad hoc implementation
targetNode = (DefaultMutableTreeNode) selNode.getParent();
if (targetNode == null || !implementsLoggingConfigurable(targetNode))
return;
}
// Get a reference to the LoggingConfigurable for the
// selected item
LoggingConfigurableOperations logConf = null;
if (model.isManagerNode(targetNode)) {
try {
logConf = getLogConfFromManager();
} catch (Throwable t) {
JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
} else if (model.isServiceNode(targetNode)) {
try {
logConf = getLogConfFromService(targetNode.getUserObject().toString());
} catch (Throwable t) {
JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
} else {
ContainerInfo cInfo;
try {
cInfo = ((TreeContainerInfo) targetNode.getUserObject()).getClientInfo();
} catch (Throwable t) {
JOptionPane.showInternalMessageDialog(tree, "Error retrieving ContainerInfo from the node", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
logConf = getLogConfFromContainer(cInfo);
} catch (Throwable t) {
JOptionPane.showInternalMessageDialog(tree, "Error getting the LoggingConfigurable:\n" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
if (logConf == null) {
JOptionPane.showMessageDialog(tree, "LoggingConfigurable is null", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
tree.getTabPanel().showTab(targetNode.getUserObject().toString());
} catch (LogPaneNotFoundException e) {
// The tab with this name does not exist: create and add a new one
LogLevelSelectorPanel pnl;
try {
pnl = new LogLevelSelectorPanel(logConf, targetNode.getUserObject().toString(), logger);
//} catch (LogLvlSelNotSupportedException ex) {
} catch (Exception t) {
JOptionPane.showMessageDialog(tree, //"<HTML>"+targetNode.getUserObject().toString()+" does not support selection of log levels:<BR>"+ex.getMessage(),
"<HTML>" + targetNode.getUserObject().toString() + " Error selecting log level panel:<BR>" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
tree.getTabPanel().addLogSelectorTab(pnl);
} catch (Throwable t) {
JOptionPane.showMessageDialog(tree, "<HTML>Error creating the panel for " + targetNode.getUserObject().toString() + ":<BR>" + t.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
// yatagai : Although the mousePressed action for a LoggingConfigurable
// folder node, expanding or collapsing, which is set by the JTree UI is not desirable,
// I could not find a good way to disable it.
//
// Reaching here, a LoggingConfigTab is displayed.
// If this is a folder node, the following code cancels expanding or collapsing
// action.
TreeNode node = (TreeNode) path.getLastPathComponent();
if (node.isLeaf())
return;
else {
if (tree.isExpanded(path))
tree.collapsePath(path);
else
tree.expandPath(path);
}
}
use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.
the class TreeMouseListener method getLogConfFromManager.
/**
* Get the LoggingConfigurable out of the manager
*
* @return The LoggingConfigurable for the manager
*/
private LoggingConfigurableOperations getLogConfFromManager() throws Exception {
System.out.println("Getting LoggingConfigurable out of Manager");
// Manager
Manager mgr = model.getManagerRef();
if (mgr == null) {
throw new Exception("Invalid manager reference");
}
SwingWorker<LoggingConfigurableOperations, Void> worker = new SwingWorker<LoggingConfigurableOperations, Void>() {
protected LoggingConfigurableOperations doInBackground() throws Exception {
LoggingConfigurableOperations logConf;
try {
logConf = LoggingConfigurableHelper.narrow(model.getManagerRef());
} catch (Throwable t) {
throw new Exception("Error getting the LoggingConfigurable out of Manager:\n" + t.getMessage(), t);
}
return logConf;
}
};
worker.execute();
return worker.get();
}
use of alma.Logging.LoggingConfigurableOperations in project ACS by ACS-Community.
the class ContainerUtil method setContainerLogLevels.
/**
* Dynamically configures container log levels, using {@link #getContainerLoggingIF(String)}.
* @param containerName
* @param defaultConfig
* @param namedLoggerConfigs
*/
public void setContainerLogLevels(String containerName, ContainerLogLevelSpec spec) throws AcsJContainerEx, NoPermissionEx {
LoggingConfigurableOperations loggingConfigurable = getContainerLoggingIF(containerName);
spec.configure(loggingConfigurable);
}
Aggregations