Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87054 Details for
Bug 208728
refactor GLA runtime and parsers to use generic handlers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for changes to org.eclipse.hyades.logging.adapter and org.eclipse.hyades.logging.parsers
logui.feature208727.patch2.txt (text/plain), 304.43 KB, created by
Dave Smith
on 2008-01-16 10:37:57 EST
(
hide
)
Description:
Patch for changes to org.eclipse.hyades.logging.adapter and org.eclipse.hyades.logging.parsers
Filename:
MIME Type:
Creator:
Dave Smith
Created:
2008-01-16 10:37:57 EST
Size:
304.43 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.hyades.logging.parsers >Index: src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLAHelper.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLAHelper.java >diff -N src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLAHelper.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLAHelper.java 23 May 2007 22:06:59 -0000 1.8 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,501 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005,2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id >- * >- * Contributors: >- * IBM - Initial API and implementation >- **********************************************************************/ >- >-package org.eclipse.hyades.logging.parsers.internal.importer; >- >-import java.io.File; >-import java.lang.reflect.Constructor; >-import java.lang.reflect.InvocationTargetException; >-import java.lang.reflect.Method; >-import java.net.MalformedURLException; >-import java.net.URL; >-import java.util.Locale; >-import java.util.Map; >-import java.util.StringTokenizer; >- >-import org.eclipse.hyades.logging.adapter.impl.AdapterXMLConstants; >-import org.eclipse.hyades.logging.adapter.util.AdapterConstants; >-import org.eclipse.hyades.logging.adapter.util.Messages; >-import org.eclipse.hyades.logging.parsers.LogParserException; >-import org.eclipse.hyades.logging.parsers.ParserConstants; >-import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; >- >-/** >- * Helper class for finding the GLA adapter configuration file. >- * >- * @author apnan >- * >- */ >-public class GLAHelper { >- >- protected static short platform = -1;//flag indicating whether the code runs in the workbench or outside the workbench >- // the values that this flag can have are: >- // -1: GLAHelper wasn't initialized >- // 0: GLAHelper runs outside the workbench >- // 1: GLAHelper runs in the workbench >- >- /** >- * Get the adapter configuration file path. >- * @param table the parser parameters hash stable >- * @param nameSpace the plugin name if running in the workbench, null otherwise >- * @param useOriginalAdapter boolean to indicate to use the original adapter file specification >- * stored in the hash table with key originalAdapter >- * @return the adapter file path. >- * @throws LogParserException >- */ >- public static synchronized String getAdapterPath(Map table, String nameSpace, boolean useOriginalAdapter) throws LogParserException{ >- >- String key; >- >- if (useOriginalAdapter) { >- key = LogParserConstants.ORIGINAL_ADAPTER_KEY; >- } >- else { >- key = getAdapterPathKey(table); >- if(key==null){ >- String message = Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", (String)null); >- throw new LogParserException(message); >- } >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: adapter key="+key); >- } >- } >- >- String config_file = (String)table.get(key); >- >- //get the adapter config file path >- String adapterFilePath = ""; >- >- if(config_file.indexOf("./")>-1){ >- config_file = config_file.substring(2); >- } >- >- /* If running in an eclipse workbench environment then try to get the adapter file >- * path based on the plugin bundle. >- */ >- if(isWorkbenchMode()){ >- try { >- // Bundle bundle = Platform.getBundle(nameSpace); >- Class platformClass = Class.forName("org.eclipse.core.runtime.Platform"); >- Method getBundle = platformClass.getMethod("getBundle", new Class[]{String.class}); >- Object bundle = getBundle.invoke(null, new String[]{nameSpace}); >- Class pathClass = Class.forName("org.eclipse.core.runtime.IPath"); >- Class bundleClass = Class.forName("org.osgi.framework.Bundle"); >- Method find = platformClass.getMethod("find", new Class[]{bundleClass, pathClass}); >- >- if(bundle!=null){ >- //verify if the adapter is NL enabled >- if(config_file.indexOf("/nl/")>-1){ >- config_file = getNLAdapterPath(table, config_file, find, bundle); >- if(config_file==null){ >- String message = Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", (String)table.get(key)); >- throw new Exception(message); >- } >- adapterFilePath = config_file; >- }else{ >- URL fileURL = find(find, bundle, config_file); >- if(fileURL==null){ >- //config_file = "config/"+config_file; >- fileURL = find(find, bundle, "config/"+config_file); >- } >- if(fileURL!=null){ >- adapterFilePath = fileURL.toString(); >- }else{ >- /* Try using the config file root from the hash table if Log Import Wizard modified the >- * adapter with a filter. */ >- adapterFilePath = (String) table.get(LogParserConstants.CONFIG_FILE_ROOT_KEY) + "/" + config_file; >- File test = new File(adapterFilePath); >- if(!test.exists()){ >- // Couldn't find adapter file so throw an exception >- throw new LogParserException(Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", config_file)); >- } >- } >- } >- }else{ >- adapterFilePath = config_file; >- } >- } >- catch (Throwable e) { >- // Capture the exception in a LogParserException >- throw new LogParserException(Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", config_file),e); >- } >- >- } >- /* Else find the adapter file path based on path variables in the hash table */ >- else{ >- >- //verify if the adapter is NL enabled >- if(config_file.indexOf("/nl/")>-1){ >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: trying to get the nl adapter file using base file "+config_file); >- } >- config_file = getNLAdapterPath(table, config_file, null, null); >- if(config_file==null){ >- String message = Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", (String)table.get(key)); >- throw new LogParserException(message); >- } >- adapterFilePath = config_file; >- }else{ >- String adapterPath = (String)table.get(LogParserConstants.CONFIG_FILE_ROOT_KEY) ; >- >-// //check to see if the global properties are set >-// if (adapterPath == null){ >-// adapterPath = CBEConfigurationProperties.instance().getProperties().getProperty(CBEConfigurationProperties.ADAPTER_LOCATION); >-// } >- adapterFilePath = adapterPath + "/" + config_file; >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: try to find the adapter file using ConfigFileRoot path eg. "+adapterFilePath); >- } >- File test = new File(adapterFilePath); >- if(!test.exists()){ >- adapterFilePath = adapterPath + "config/"+config_file; >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: try to find the adapter file using ConfigFileRoot path plus config eg. "+adapterFilePath); >- } >- test = new File(adapterFilePath); >- if(!test.exists()){ >- // last attempt >- // >- // Bug 62317 >- // Try to resolve the config file using the command line list of directories >- // >- String config_paths = (String)table.get(LogParserConstants.CONFIG_PATH_KEY); // get the paths containing the adapter files >- >- // Check to ensure config_path was set in the input table >- // If it is not then throw an appropriate exception. >- if (config_paths != null && config_paths.length() != 0) { >- StringTokenizer strtok = new StringTokenizer(config_paths, File.pathSeparator, false); // tokenize the path >- while(strtok.hasMoreTokens()) { >- String config_path = strtok.nextToken(); >- >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: try to find the adapter file " + config_file + " using config_path "+config_path); >- } >- File f = new File(config_path, config_file); // look for the adapter file using the path >- if(f.exists()) { >-// table.remove(LogParserConstants.CONFIG_PATH_KEY); // This is no longer required >- adapterFilePath = f.getAbsolutePath(); >- return adapterFilePath; >- } >- } >- } >- // Bug 62317 ends >- >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: could not find the adapter file! Throwing an exception."); >- } >- throw new LogParserException(Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", config_file)); >- >- } >- } >- } >- } >- return adapterFilePath; >- } >- /** >- * Initializes the context in which this class is running. >- * Determines whether the code runs in a workbench context or outside. >- * Calling this method is required before using the adapter path helper method. >- * >- */ >- protected static synchronized void initialize(){ >- try { >- Class resourcePlugin = Class.forName("org.eclipse.core.resources.ResourcesPlugin"); >- Method getWorkspace = resourcePlugin.getMethod("getWorkspace", null); >- Object workspace = getWorkspace.invoke(null, null); >- Method getRoot = workspace.getClass().getMethod("getRoot", null); >- Object root = getRoot.invoke(workspace, null); >- >- platform =(short)((root != null) ? 1 : 0); >- } catch (ClassNotFoundException e) { >- platform = 0; >- } catch (SecurityException e) { >- platform = 0; >- } catch (NoSuchMethodException e) { >- platform = 0; >- } catch (IllegalArgumentException e) { >- platform = 0; >- } catch (IllegalAccessException e) { >- platform = 0; >- } catch (InvocationTargetException e) { >- platform = 0; >- } catch (NullPointerException e) { >- platform = 0; >- } >- } >- >- /** >- * Get the absolute path of the adapter configuration file. >- * @param table the parser parameters hash stable >- * @param nameSpace the plugin name if running in the workbench, null otherwise >- * @param useOriginalAdapter boolean to indicate to use the original adapter file specification >- * stored in the hash table with key originalAdapter >- * @return the absolute path of the adapter file. >- * @throws LogParserException >- */ >- public static synchronized String getAbsoluteAdapterPath(Map table, String nameSpace, boolean useOriginalAdapter) throws LogParserException{ >- String adapterPath = getAdapterPath(table, nameSpace, useOriginalAdapter); >- >- /* If running in eclipse workbench environment Then the adapter path returned by getAdapterPath may >- * be a URL based on the plugin bundle. In that case it needs to be converted to an >- * absolute file path. >- */ >- if(isWorkbenchMode()){ >- try{ >- Class platformClass = Class.forName("org.eclipse.core.runtime.Platform"); >- Method asLocalURL = platformClass.getMethod("asLocalURL", new Class[]{URL.class}); >- URL adapterURL = new URL(adapterPath); >- URL absoluteURL = (URL)asLocalURL.invoke(null, new Object[]{adapterURL}); >- return absoluteURL.getFile(); >- }catch (MalformedURLException ue) { >- /* Assume that the path returned by getAdapterPath is not a URL but is already an absolute path for >- * the adapter file. Iit will be returned. >- */ >- }catch (Throwable e) { >- // Capture the exception in a LogParserException >- throw new LogParserException(Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", adapterPath),e); >- } >- >- >- } >- return adapterPath; >- } >- /** >- * Get the key that is used to find the adapter configuration file name in the hash table. >- * @param table the parser parameters hash table >- * @return the hash table key corresponding to the adapter file path, null if no adapter >- * file path found. >- */ >- public static synchronized String getAdapterPathKey(Map table){ >- String key = null; >- String version = (String) (table.get(ParserConstants.APPLICATION_VERSION_KEY)); >- String config_file = null; >- >- // If no version attribute given, use default >- if(version == null) >- { >- version = LogParserConstants.DEFAULT_APPLICATION_VERSION_KEY; >- } >- >- // Get the config file defined for this version >- config_file = (String) (table.get(version)); >- >- if(config_file == null && version != LogParserConstants.DEFAULT_APPLICATION_VERSION_KEY) >- { >- // Cannot find the corresponding config file, use default >- config_file = (String) (table.get(LogParserConstants.DEFAULT_APPLICATION_VERSION_KEY)); >- >- // If the default file is the desired adapter file then set the key to return >- if(config_file != null) { >- key = LogParserConstants.DEFAULT_APPLICATION_VERSION_KEY; >- } >- } >- else if (config_file != null) { >- key = version; >- } >- >- return key; >- >- } >- >- /** >- * >- * @return boolean whether object is executing in an Eclipse workbench environment >- */ >- public static synchronized boolean isWorkbenchMode(){ >- if(platform==-1){ >- initialize(); >- } >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("workbench="+platform); >- } >- >- return platform ==1; >- } >- >- /** >- * Get the adapter configuration file path based on locale and encoding. >- * @param table Hash table of input parameters >- * @param configFilePath The adapter configuration file to find. >- * @param find The method to find the file >- * @param bundle - plugin bundle >- * @return the adapter configuration file path >- */ >- protected static synchronized String getNLAdapterPath(Map table, >- String configFilePath, Method find, Object bundle){ >- >- String characterEncoding = (String) table >- .get(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_CHARACTER_ENCODING); >- String countryCode = (String) table >- .get(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_ISO_COUNTRY_CODE); >- String languageCode = (String) table >- .get(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_ISO_LANGUAGE_CODE); >- >- String locale = null; >- /* >- * bugzilla 135799 >- * Get the default system locale and character encoding if the default string is >- * passed in. >- */ >- if (languageCode != null && languageCode.equals(AdapterConstants.AttributeValue_Default)) { >- languageCode = Locale.getDefault().getLanguage(); >- } >- if (countryCode != null && countryCode.equals(AdapterConstants.AttributeValue_Default)) { >- countryCode = Locale.getDefault().getCountry(); >- } >- >- if (characterEncoding != null && characterEncoding.equals(AdapterConstants.AttributeValue_Default)) { >- try { >- characterEncoding = System.getProperty("file.encoding"); >- } >- catch (SecurityException e) { >- /* null file encoding will be handled below */ >- } >- } >- if(countryCode!=null && countryCode.length() == 0){ >- locale = languageCode; >- }else if(countryCode!=null && languageCode!=null){ >- locale = languageCode + "_" + countryCode; >- } >- >- int i = configFilePath.indexOf("/nl/"); >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("characterEncoding="+characterEncoding); >- GLADebug.INSTANCE.log("countryCode="+countryCode); >- GLADebug.INSTANCE.log("languageCode="+languageCode); >- } >- >- // try to find the adapter in the following order >- // <root>/nl/<ISOLanguageCode>_<ISOCountryCode>/<characterEncoding> >- // <root>/nl/<ISOLanguageCode>_<ISOCountryCode> >- // <root>/nl/<characterEncoding> >- // <root>/nl/ >- >- String[][] searchPath = new String[][]{{locale, characterEncoding}, {locale}, {characterEncoding}, {"/"}}; >- if (i < 0) { >- return configFilePath; >- } >- int j = configFilePath.lastIndexOf('/'); >- String dir = configFilePath.substring(0, i + 3); >- String fileName = configFilePath.substring(j); >- >- StringBuffer path = new StringBuffer(); >- String[] currentPath = null; >- int l = 0; >- >- String fullPath = null; >- String lastPathAppended = null; >- for(int idx=0;idx<4 && fullPath==null;idx++){ >- currentPath = searchPath[idx]; >- l = currentPath.length; >- path.append(dir); >- for(int jdx=0;jdx<l;jdx++){ >- if(currentPath[jdx]==null){ >- continue; >- } >- if(!currentPath[jdx].equals("/")){ >- path.append('/'); >- } >- path.append(currentPath[jdx]); >- lastPathAppended = currentPath[jdx]; >- } >- if(lastPathAppended!=null && lastPathAppended.equals("/")){ >- path.append(fileName.substring(1)); >- }else{ >- path.append(fileName); >- } >- fullPath = getPath(table, find, bundle, path.toString()); >- path.setLength(0); >- } >- >- return fullPath; >- } >- >- /** >- * Get the full path of the adapter configuration file >- * @param table Hash table of input parameters >- * @param find The method to use to find the URL >- * @param bundle The plugin bundle >- * @param configFilePath >- * @return the full path of the adapter file >- */ >- protected static synchronized String getPath(Map table, Method find, Object bundle, String configFilePath){ >- String filePath = null; >- if(bundle!=null){ >- // workbench context mode: local import >- URL fileURL = find(find, bundle, configFilePath); >- if(fileURL==null){ >- fileURL = find(find, bundle, "config/"+configFilePath); >- } >- if (fileURL != null) { >- filePath = fileURL.toString(); >- } >- }else{ >- // outside workbench context: remote import or web client >- String adapterPath = (String)table.get(LogParserConstants.CONFIG_FILE_ROOT_KEY) ; >- >-// //check to see if the global properties are set >-// if (adapterPath == null){ >-// adapterPath = CBEConfigurationProperties.instance().getProperties().getProperty(CBEConfigurationProperties.ADAPTER_LOCATION); >-// } >- >- String adapterFilePath = adapterPath + "/" + configFilePath; >- File file = new File(adapterFilePath); >- if(file.exists()){ >- filePath = adapterFilePath; >- }else { >- String config_paths = (String)table.get(LogParserConstants.CONFIG_PATH_KEY); // get the paths containing the adapter files >- if (config_paths != null && config_paths.length() != 0) { >- StringTokenizer strtok = new StringTokenizer(config_paths, File.pathSeparator, false); // tokenize the path >- while(strtok.hasMoreTokens()) { >- String config_path = strtok.nextToken(); >- >- File f = new File(config_path, configFilePath); // look for the adapter file using the path >- if(f.exists()) { >- filePath = f.getAbsolutePath(); >- } >- } >- } >- } >- } >- if(GLADebug.INSTANCE.debug){ >- GLADebug.INSTANCE.log("GLAHelper.getPath: Attempted to get adapter at path "+configFilePath +" result: file=" +filePath); >- } >- >- return filePath; >- } >- >- /** >- * Find the URL of the adapter configuration file >- * @param find The method to find the adapter file >- * @param bundle - The plugin bundle >- * @param config_file - the adapter configuration file to find >- * @return the URL of the adapter configuration file >- */ >- protected static URL find(Method find, Object bundle, String config_file){ >- URL fileURL = null; >- Class pathClass; >- try { >- pathClass = Class.forName("org.eclipse.core.runtime.Path"); >- Constructor pathConstructor = pathClass.getConstructor(new Class[] {config_file.getClass()}); >- Object path = pathConstructor.newInstance(new Object[] {config_file}); >- fileURL = (URL)find.invoke(null, new Object[]{bundle, path}); >- >- } catch (Exception e) { >- if(GLADebug.INSTANCE.debug) >- e.printStackTrace(); >- } >- return fileURL; >- >- } >- >-} >Index: src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLALoggerFactory.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLALoggerFactory.java >diff -N src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLALoggerFactory.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLALoggerFactory.java 28 Jun 2005 19:33:31 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,88 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: GLALoggerFactory.java,v 1.1 2005/06/28 19:33:31 dnsmith Exp $ >- * >- * Contributors: >- * IBM - Initial API and implementation >- **********************************************************************/ >- >-package org.eclipse.hyades.logging.parsers.internal.importer; >- >-import org.apache.commons.logging.Log; >-import org.apache.commons.logging.LogConfigurationException; >-import org.eclipse.hyades.logging.commons.LoggerFactory; >- >-/** >- * This class extends org.eclipse.hyades.logging.commons.LoggerFactory >- * to instantiate the org.eclpise.hyades.logging.parsers.GLALogger class. >- * >- * @see org.apache.commons.logging.LogFactory >- * @see org.eclipse.hyades.logging.commons.Logger >- * @see org.eclipse.hyades.logging.commons.LoggerFactory >- * @see org.eclipse.hyades.logging.parsers.internal.importer.GLALogger >- */ >-public class GLALoggerFactory extends LoggerFactory { >- >- /** >- * No-argument constructor. >- */ >- public GLALoggerFactory() { >- super(); >- } >- >- /** >- * Returns an instance of a non-null named >- * <code>org.eclipse.hyades.logging.parsers.GLALogger</code> based on the >- * parameter name. >- * <p> >- * Passing a <code>null</code> logger name results in a <code>null</code> >- * return value. >- * <p> >- * An instance of a named >- * <code>org.eclipse.hyades.logging.parsers.GLALogger</code> is created if no >- * named instance current exists or all instances have been released. >- * <p> >- * Once a named <code>org.eclipse.hyades.logging.parsers.GLALogger</code> is >- * created, the instance is cached for future calls to retrieve the same >- * named <code>org.eclipse.hyades.logging.parsers.GLALogger</code>. >- * <p> >- * The name of the <code>org.eclipse.hyades.logging.parsers.GLALogger</code> >- * uniquely identifies an instance of an >- * <code>org.eclipse.hyades.logging.parsers.GLALogger</code>. All subsequent >- * calls will return the same instance of the named >- * <code>org.eclipse.hyades.logging.parsers.GLALogger</code>. >- * <p> >- * >- * @param loggerName >- * The non-null name of the returned >- * <code>org.eclipse.hyades.logging.parsers.GLALogger</code> >- * instance. >- * @return A named <code>org.eclipse.hyades.logging.parsers.GLALogger</code> >- * instance, otherwise <code>null</code> if the parameter logger >- * name is <code>null</code>. >- * @exception LogConfigurationException >- * if the named >- * <code>org.eclipse.hyades.logging.parsers.GLALogger</code> >- * instance could not be created. >- * @see org.apache.commons.logging.LogFactory#getInstance(java.lang.String) >- */ >- public Log getInstance(String loggerName) throws LogConfigurationException { >- >- if (loggerName != null) { >- >- if (loggers.containsKey(loggerName)) { return (((Log) (loggers.get(loggerName)))); } >- >- GLALogger logger = new GLALogger(loggerName); >- >- loggers.put(loggerName, logger); >- >- return logger; >- } >- >- return null; >- } >-} >\ No newline at end of file >Index: src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalLogParserLoader.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalLogParserLoader.java >diff -N src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalLogParserLoader.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalLogParserLoader.java 23 Aug 2006 21:17:51 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,246 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: LocalLogParserLoader.java,v 1.1 2006/08/23 21:17:51 sleeloy Exp $ >- * >- * Contributors: >- * IBM - Initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.logging.parsers.internal.importer; >- >-import java.io.UnsupportedEncodingException; >-import java.util.Hashtable; >- >-import org.apache.commons.logging.Log; >-import org.eclipse.hyades.internal.logging.core.Constants; >-import org.eclipse.hyades.logging.events.cbe.util.EventFormatter; >-import org.eclipse.hyades.logging.events.cbe.util.EventHelpers; >-import org.eclipse.hyades.logging.parsers.importer.ILogParser; >- >-public class LocalLogParserLoader extends LocalLogImportLoader{ >- >- //~ Constructors ------------------------------------------------------------------------------- >- >- public LocalLogParserLoader(ILogParser parser, Hashtable parserParameters, boolean traceXML) { >- super(parser, parserParameters, traceXML); >- loggingLevel=0; >- } >- >- //~ Methods ------------------------------------------------------------------------------------ >- >- >- public Log getParserLogger(){ >- return logParser; >- } >- >- //NOTE: Temporary API to propagate logged raw objects to the model as XML strings: >- private void logXMLToModel(String xml) { >- // Note: L0DocumentEventHandler (perftrace.loader.XMLLoader) XML scanner MUST be passed UTF8 encoded byte array data: >- byte[] xmlLogEntryBytes = null; >- >- try { >- xmlLogEntryBytes = xml.getBytes("UTF8"); >- } >- catch (UnsupportedEncodingException u) { >- xmlLogEntryBytes = xml.getBytes(); >- } >- >- // System.err.println(xml); >- xmlLoader.loadEvent(xmlLogEntryBytes, xmlLogEntryBytes.length); >- } >- >- /** >- * Logs the parameter <code>java.lang.Object</code> log record to the Logging Agent >- * with the same name as the logger if TRACE logging is currently enabled. >- * >- * The log record is first converted to XML and then sent to the Logging Agent. >- * >- * @param record The log record to be logged to the Logging Agent. >- */ >- >- public void trace(Object record) { >-// try { >- if (isTraceEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- >- } >- >- public void trace(Object record, Throwable throwable) { >-// try { >- if (isTraceEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- >- } >- >- public void debug(Object record) { >-// try { >- if (isDebugEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- >- } >- >- public void debug(Object record, Throwable throwable) { >-// try { >- if (isDebugEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- >- } >- >- public void info(Object record) { >-// try { >- if (isInfoEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- >- } >- >- public void info(Object record, Throwable throwable) { >- >-// try { >- if (isInfoEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- } >- >- >- public void warn(Object record) { >-// try { >- if (isWarnEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- } >- >- public void warn(Object record, Throwable throwable) { >-// try { >- if (isWarnEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- } >- >- public void error(Object record) { >-// try { >- if (isErrorEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- } >- >- public void error(Object record, Throwable throwable) { >- >-// try { >- if (isErrorEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- } >- >- >- public void fatal(Object record) { >-// try { >- if (isFatalEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- } >- >- >- public void fatal(Object record, Throwable throwable) { >- >-// try { >- if (isFatalEnabled()) { >- if(!traceXML){ >- logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >- }else{ >- logXMLToModel((String)record); >- } >- } >-// } >-// catch (Throwable t) { >-// } >- } >- >- >-} >- >- >Index: src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLADebug.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLADebug.java >diff -N src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLADebug.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLADebug.java 7 Oct 2005 19:56:25 -0000 1.3 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,123 +0,0 @@ >-/******************************************************************************* >- * Copyright (c) 2005 IBM Corporation and others. All rights reserved. This program and the >- * accompanying materials are made available under the terms of the Eclipse >- * Public License v1.0 which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id >- * >- * Contributors: IBM - Initial API and implementation >- ******************************************************************************/ >- >-package org.eclipse.hyades.logging.parsers.internal.importer; >- >-import java.io.FileNotFoundException; >-import java.io.FileOutputStream; >-import java.io.IOException; >-import java.lang.reflect.Method; >-import java.util.Date; >- >-/** >- * This class provides debugging facilities for the Log Import code. >- * >- * @author apnan >- * >- */ >-public class GLADebug { >- >- public boolean debug = false; >- public boolean logToFile = false; >- >- protected String plugin_name; >- protected String value; >- protected final String NL = System.getProperties().getProperty("line.separator"); >- private FileOutputStream log = null; >- >- public static GLADebug INSTANCE = new GLADebug("org.eclipse.hyades.logging.parsers"); >- >- public GLADebug(String plugin_name) { >- this.plugin_name = plugin_name; >- init(); >- } >- >- /** >- * Initialize the debugging code. >- * >- */ >- protected void init() { >- try { >- // Get the debugging options from the options file. >- Class platformClass = Class.forName("org.eclipse.core.runtime.Platform"); >- Method getDebugOption = platformClass.getMethod("getDebugOption", new Class[]{String.class}); >- value = (String)getDebugOption.invoke(null, new String[]{plugin_name+"/debug"}); >- >- if (value != null) { >- debug = value.equalsIgnoreCase("true"); >- } else if(System.getProperty("GLADebug.debug")!=null) >- { >- debug = Boolean.valueOf(System.getProperty("GLADebug.debug")).booleanValue(); >- } >- value = (String)getDebugOption.invoke(null, new String[]{plugin_name+"/logToFile"}); >- if (value != null) { >- logToFile = value.equalsIgnoreCase("true"); >- } else if(System.getProperty("GLADebug.logToFile")!=null) >- { >- logToFile = Boolean.valueOf(System.getProperty("GLADebug.logToFile")).booleanValue(); >- } >- >- >- } catch (Exception e) { >- // The platform is not available, read the environment variables >- debug = Boolean.valueOf(System.getProperty("GLADebug.debug")).booleanValue(); >- logToFile = Boolean.valueOf(System.getProperty("GLADebug.logToFile")).booleanValue(); >- } >- } >- >- /** >- * Get the debug log file output stream. >- * >- * @return the FileOutputStream for the debug file >- */ >- public FileOutputStream getLog(){ >- if(log==null){ >- try { >- log = new FileOutputStream("./GLADebug-"+(new Date()).getTime()); >- } catch (FileNotFoundException e) { >- if(debug) >- e.printStackTrace(); >- } >- }else{ >- if(!log.getChannel().isOpen()) >- { >- try { >- log = new FileOutputStream("./GLADebug-"+(new Date()).getTime()); >- } catch (FileNotFoundException e) { >- if(debug) >- e.printStackTrace(); >- } >- } >- >- } >- return log; >- } >- >- /** >- * Log a debug message >- * @param message >- */ >- public void log(String message){ >- if(logToFile){ >- // Log the message to the log file. >- try { >- getLog().write(message.getBytes()); >- getLog().write(NL.getBytes()); >- } catch (IOException e) { >- if(debug) >- e.printStackTrace(); >- } >- }else{ >- // Log the message to System.out >- System.out.println(message); >- } >- } >- >-} >Index: src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLALogger.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLALogger.java >diff -N src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLALogger.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/importer/GLALogger.java 28 Jun 2005 19:33:31 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,97 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: GLALogger.java,v 1.1 2005/06/28 19:33:31 dnsmith Exp $ >- * >- * Contributors: >- * IBM - Initial API and implementation >- **********************************************************************/ >- >-package org.eclipse.hyades.logging.parsers.internal.importer; >- >-import org.eclipse.hyades.logging.commons.Logger; >-import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; >- >-/** >- * This class extends org.eclipse.hyades.logging.commons.Logger >- * so that it only logs the Common Base Event message instead of the >- * whole Common Base Event. This class is used to log GLA messages. >- * >- * @see org.apache.commons.logging.Log >- * @see org.apache.commons.logging.LogFactory >- * @see org.eclipse.hyades.logging.core.LoggingAgent >- * @see org.eclipse.hyades.logging.commons.Logger >- * @see org.eclipse.hyades.logging.commons.LoggerFactory >- */ >-public class GLALogger extends Logger { >- >- /** >- * Constructor to create a logger instance with a Logging Agent using the >- * parameter name. >- * >- * NOTE: The default logging level is set to WARN until explicitly set. >- * >- * @param name >- * The name of the newly created logger. >- */ >- public GLALogger(String name) { >- >- super(name); >- >- } >- >- /** >- * Logs the parameter <code>java.lang.Object</code> log record to the >- * Logging Agent with the same name as the logger if TRACE logging is >- * currently enabled. >- * >- * If the log record is a CommonBaseEvent only the CommonBaseEvent message will be >- * sent to the Logging Agent. Otherwise it is assumed the record is a String. >- * >- * @param record >- * The log record to be logged to the Logging Agent. >- */ >- public void trace(Object record) { >- >- if (isTraceEnabled()) { >- if (record instanceof CommonBaseEvent) { >- loggingAgent.write("glalog=" + ((CommonBaseEvent)record).getMsg()); >- } >- else if (record instanceof String) { >- loggingAgent.write((String)record); >- } >- } >- } >- >- /** >- * Logs the parameter <code>java.lang.Object</code> log record and >- * <code>java.lang.Throwable</code> exception to the Logging Agent with >- * the same name as the logger if TRACE logging is currently enabled. >- * >- * If the log record is a CommonBaseEvent only the CommonBaseEvent message will be >- * sent to the Logging Agent. Otherwise it is assumed the record is a String. >- * >- * Only the parameter <code>java.lang.Object</code> log record is logged. >- * The <code>java.lang.Throwable</code> exception is ignored. >- * >- * @param record >- * The log record to be logged to the Logging Agent. >- * @param throwable >- * The exception will be ignored >- */ >- public void trace(Object record, Throwable throwable) { >- >- if (isTraceEnabled()) { >- if (record instanceof CommonBaseEvent) { >- loggingAgent.write("glalog=" + ((CommonBaseEvent)record).getMsg()); >- } >- else if (record instanceof String) { >- loggingAgent.write((String)record); >- } >- } >- } >- >-} >\ No newline at end of file >Index: src.import/org/eclipse/hyades/logging/parsers/internal/importer/StatusMonitor.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/internal/importer/StatusMonitor.java >diff -N src.import/org/eclipse/hyades/logging/parsers/internal/importer/StatusMonitor.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/importer/StatusMonitor.java 28 Jun 2005 19:33:31 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,87 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: StatusMonitor.java,v 1.1 2005/06/28 19:33:31 dnsmith Exp $ >- * >- * Contributors: >- * IBM - Initial API and implementation >- **********************************************************************/ >-package org.eclipse.hyades.logging.parsers.internal.importer; >- >-import org.apache.commons.logging.Log; >- >-/** >- * This class is a runnable that checks the status of a log parser >- * at regular intervals and sends the status to a logging agent. >- */ >-public class StatusMonitor implements Runnable { >- >- // Class of the parser object >- private Class parserClass = null; >- >- // The parser object >- private Object parser = null; >- >- // The logging agent to write the status to. >- private Log statusLogger = null; >- >- /** >- * Constructor with required parameters >- * @param parser object that is doing the log parsing >- * @param parserClass class of the parser object >- * @param statusLogger logging agent to write the status to >- */ >- public StatusMonitor(Object parser, Class parserClass, Log statusLogger) { >- super(); >- >- this.parser = parser; >- this.parserClass = parserClass; >- this.statusLogger = statusLogger; >- } >- >- /** >- * Run this StatusMonitor thread. >- * @see java.lang.Runnable#run() >- */ >- public void run() { >- String status = null; >- >- // Status checking loop. >- while (true) { >- try { >- // Get the status of the parsing object. >- status = (String)parserClass.getMethod("getStatus",null).invoke(parser, null); >- } >- catch (Exception e) { >- System.err.println("Exception occured when getting status: " + e.getMessage()); >- status = null; >- } >- // write status string to status agent >- if (status != null) { >- statusLogger.trace(status); >- } >- >- // If this thread has been interrupted then quit the monitoring loop. >- if (Thread.interrupted()) { >- break; >- } >- >- /* Sleep for 2 seconds before checking the status again. >- * The parsing thread may interrupt this thread to indicate it is done so break >- * from the monitoring loop. >- */ >- try { >- Thread.sleep(2000); >- } >- catch (InterruptedException e) { >- // Quit the monitoring loop if this thread has been interrupted >- break; >- } >- } >- >- } >- >-} >Index: src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalLogImportLoader.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalLogImportLoader.java >diff -N src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalLogImportLoader.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalLogImportLoader.java 13 May 2006 22:23:09 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,179 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * >- * Contributors: >- * IBM - Initial API and implementation >- * >- * Change History: >- **********************************************************************/ >-package org.eclipse.hyades.logging.parsers.internal.importer; >- >-import java.util.Hashtable; >- >-import org.apache.commons.logging.Log; >-import org.eclipse.hyades.loaders.util.XMLLoader; >-import org.eclipse.hyades.logging.parsers.LogParserException; >-import org.eclipse.hyades.logging.parsers.importer.ILogParser; >- >-/** >- * >- * This is a specialized logger to be used by GLA for local log imports. It is >- * instantiated by clients and passed to GLA via ParserWrapper.parse(Log) method. >- * Currently it is available internally only for use by the Log Import Wizard in >- * org.eclipse.tptp.monitoring.logui >- * >- * @author Cindy Jin >- * >- */ >-public class LocalLogImportLoader implements Log { >- >- >- protected Hashtable parserParameters = null; >- protected ILogParser parser = null; >- protected XMLLoader xmlLoader = null; >- protected Log logParser = null; >- protected boolean traceXML = false; >- >- /** >- * Trace logging level value. >- */ >- public static final int TRACE_LEVEL = 0; >- >- /** >- * Debug logging level value. >- */ >- public static final int DEBUG_LEVEL = 1; >- >- /** >- * Information logging level value. >- */ >- public static final int INFO_LEVEL = 2; >- >- /** >- * Warning logging level value. >- */ >- public static final int WARN_LEVEL = 3; >- >- /** >- * Error logging level value. >- */ >- public static final int ERROR_LEVEL = 4; >- >- /** >- * Fatal logging level value. >- */ >- public static final int FATAL_LEVEL = 5; >- >- /** >- * The logger's current logging level value. >- */ >- protected int loggingLevel; >- public LocalLogImportLoader() >- { >- parser = null; >- parserParameters = null; >- } >- >- public LocalLogImportLoader(ILogParser parser, Hashtable parserParameters, boolean traceXML) { >- this.parser = parser; >- this.parserParameters = parserParameters; >- this.traceXML = traceXML; >- } >- >- public void setXMLLoader(XMLLoader xmlLoader) { >- parserParameters.put("xmlLoader", xmlLoader); >- this.xmlLoader = xmlLoader; >- } >- >- >- public void startParsing() throws LogParserException { >- parser.setUserInput(parserParameters); >- parser.parse(this); >- } >- public void setParserLogger(Log logParser){ >- this.logParser = logParser; >- parser.setParserLogger(logParser); >- } >- >- public Log getParserLogger(){ >- return logParser; >- } >- >- public XMLLoader getXMLLoader() >- { >- return xmlLoader; >- } >- >- public boolean isTraceEnabled() { >- return (loggingLevel<=TRACE_LEVEL); >- } >- >- public boolean isDebugEnabled() { >- return (loggingLevel<=DEBUG_LEVEL); >- } >- >- >- public boolean isInfoEnabled() { >- return (loggingLevel<=INFO_LEVEL); >- } >- >- public boolean isWarnEnabled() { >- return (loggingLevel<=WARN_LEVEL); >- } >- >- public boolean isErrorEnabled() { >- return (loggingLevel<=ERROR_LEVEL); >- } >- >- public boolean isFatalEnabled() { >- return (loggingLevel<=FATAL_LEVEL); >- } >- >- >- public void trace(Object record) { >- } >- >- public void trace(Object record, Throwable throwable) { >- } >- >- public void debug(Object record) { >- } >- >- public void debug(Object record, Throwable throwable) { >- } >- >- public void info(Object record) { >- } >- >- public void info(Object record, Throwable throwable) { >- } >- >- >- public void warn(Object record) { >- } >- >- public void warn(Object record, Throwable throwable) { >- } >- >- public void error(Object record) { >- } >- >- public void error(Object record, Throwable throwable) { >- } >- >- >- public void fatal(Object record) { >- >- } >- >- >- public void fatal(Object record, Throwable throwable) { >- >- } >- >- >-} >Index: src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalGLALogger.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalGLALogger.java >diff -N src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalGLALogger.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/importer/LocalGLALogger.java 20 Sep 2006 19:20:23 -0000 1.2 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,203 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2006 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: LocalGLALogger.java,v 1.2 2006/09/20 19:20:23 dnsmith Exp $ >- * >- * Contributors: >- * IBM - Initial API and implementation >- **********************************************************************/ >- >-package org.eclipse.hyades.logging.parsers.internal.importer; >- >-import java.util.ArrayList; >-import java.util.List; >- >-import org.apache.commons.logging.Log; >-import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; >- >-public class LocalGLALogger implements Log { >- >- //private XmlGenerator xmlGenerator = new XmlGenerator(); >- private List events = new ArrayList(); >- private final String NL = System.getProperties().getProperty("line.separator"); >- >- private String detailMessage = null; >- >- /** >- * Trace logging level value. >- */ >- public static final int TRACE_LEVEL = 0; >- >- /** >- * Debug logging level value. >- */ >- public static final int DEBUG_LEVEL = 1; >- >- /** >- * Information logging level value. >- */ >- public static final int INFO_LEVEL = 2; >- >- /** >- * Warning logging level value. >- */ >- public static final int WARN_LEVEL = 3; >- >- /** >- * Error logging level value. >- */ >- public static final int ERROR_LEVEL = 4; >- >- /** >- * Fatal logging level value. >- */ >- public static final int FATAL_LEVEL = 5; >- >- /** >- * The logger's current logging level value. >- */ >- private int loggingLevel; >- >- public LocalGLALogger() { >- //xmlGenerator.reset(null, true, 8); >- loggingLevel = 0; >- } >- >- public String getLogDetails() { >- StringBuffer buffer = new StringBuffer(); >- synchronized(events){ >- int s = events.size(); >- String msg = null; >- if(s>0){ >- for(int i=0;i<s-1;i++){ >- msg = (String)events.get(i); >- if(msg!=null){ >- buffer.append(msg); >- buffer.append(NL); >- } >- } >- msg = (String)events.get(s-1); >- if(msg!=null){ >- buffer.append(msg); >- } >- } >- } >- detailMessage = buffer.toString(); >- return detailMessage; >- } >- >- public boolean isDebugEnabled() { >- return (loggingLevel <= DEBUG_LEVEL); >- } >- >- public boolean isErrorEnabled() { >- return (loggingLevel <= ERROR_LEVEL); >- } >- >- public boolean isFatalEnabled() { >- return (loggingLevel <= FATAL_LEVEL); >- } >- >- public boolean isInfoEnabled() { >- return (loggingLevel <= INFO_LEVEL); >- } >- >- public boolean isTraceEnabled() { >- return (loggingLevel <= TRACE_LEVEL); >- } >- >- public boolean isWarnEnabled() { >- return (loggingLevel <= WARN_LEVEL); >- } >- >- public void trace(Object record) { >- if (isTraceEnabled()) { >- synchronized(events){ >- if(record!=null && record instanceof CommonBaseEvent) >- if(((CommonBaseEvent)record).getMsg()!=null && !events.contains(((CommonBaseEvent)record).getMsg())){ >- events.add(((CommonBaseEvent)record).getMsg()); >- } >- } >-// this.detailMessage = xmlGenerator.objectToXML(record); >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- >- } >- >- public void trace(Object record, Throwable arg1) { >- if (isTraceEnabled()) { >- trace(record); >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- >- } >- >- public void debug(Object record) { >- if (isDebugEnabled()) { >- trace(record); >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- } >- >- public void debug(Object record, Throwable arg1) { >- if (isDebugEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- >- } >- >- public void info(Object record) { >- if (isInfoEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- >- } >- >- public void info(Object record, Throwable arg1) { >- if (isInfoEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- >- } >- >- public void warn(Object record) { >- if (isWarnEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- >- } >- >- public void warn(Object record, Throwable arg1) { >- if (isWarnEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- } >- >- public void error(Object record) { >- if (isErrorEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- } >- >- public void error(Object record, Throwable arg1) { >- if (isErrorEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- } >- >- public void fatal(Object record) { >- if (isFatalEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- } >- >- public void fatal(Object record, Throwable arg1) { >- if (isFatalEnabled()) { >-// logXMLToModel(xmlGenerator.objectToXML(record)); >- } >- } >- >-} >Index: schema/logParser.exsd >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/schema/logParser.exsd,v >retrieving revision 1.24 >diff -u -r1.24 logParser.exsd >--- schema/logParser.exsd 1 Jun 2007 19:59:25 -0000 1.24 >+++ schema/logParser.exsd 16 Jan 2008 11:38:32 -0000 >@@ -110,6 +110,20 @@ > </documentation> > </annotation> > </attribute> >+ <attribute name="override_id" type="string"> >+ <annotation> >+ <documentation> >+ ID of logParser extension that this extension will override. Note, only those attributes included in this extension will be overridden. >+ </documentation> >+ </annotation> >+ </attribute> >+ <attribute name="override_priority" type="string"> >+ <annotation> >+ <documentation> >+ Numeric priority value used to evaluate the priority of this override extension in relation to other override extensions. A value of -1 indicates that the extension that is specified in override_id should be disabled and not available for use as a log parser. Note, this attribute is required if override_id is specified. This attribute is ignored if override_id is not specified. >+ </documentation> >+ </annotation> >+ </attribute> > </complexType> > </element> > >@@ -546,23 +560,7 @@ > </documentation> > </annotation> > >- <annotation> >- <appInfo> >- <meta.section type="apiInfo"/> >- </appInfo> >- <documentation> >- >- </documentation> >- </annotation> > >- <annotation> >- <appInfo> >- <meta.section type="implementation"/> >- </appInfo> >- <documentation> >- >- </documentation> >- </annotation> > > <annotation> > <appInfo> >Index: src.import/org/eclipse/hyades/logging/parsers/internal/adapter/formatters/LocalLogImportCBEFormatter.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src.import/org/eclipse/hyades/logging/parsers/internal/adapter/formatters/LocalLogImportCBEFormatter.java,v >retrieving revision 1.4 >diff -u -r1.4 LocalLogImportCBEFormatter.java >--- src.import/org/eclipse/hyades/logging/parsers/internal/adapter/formatters/LocalLogImportCBEFormatter.java 4 May 2007 07:52:23 -0000 1.4 >+++ src.import/org/eclipse/hyades/logging/parsers/internal/adapter/formatters/LocalLogImportCBEFormatter.java 16 Jan 2008 11:38:35 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -32,7 +32,7 @@ > import org.eclipse.hyades.logging.events.cbe.util.EventHelpers; > import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; > import org.eclipse.hyades.logging.parsers.importer.ParserWrapper; >-import org.eclipse.hyades.logging.parsers.internal.importer.LocalLogImportLoader; >+import org.eclipse.hyades.logging.parsers.provisional.importer.LocalLogImportLoader; > > /** > * >Index: src/org/eclipse/hyades/logging/parsers/adapter/sensors/StaticParserSensor.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src/org/eclipse/hyades/logging/parsers/adapter/sensors/StaticParserSensor.java,v >retrieving revision 1.12 >diff -u -r1.12 StaticParserSensor.java >--- src/org/eclipse/hyades/logging/parsers/adapter/sensors/StaticParserSensor.java 1 Nov 2006 07:19:57 -0000 1.12 >+++ src/org/eclipse/hyades/logging/parsers/adapter/sensors/StaticParserSensor.java 16 Jan 2008 11:38:35 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005,2006 IBM Corporation and others. >+ * Copyright (c) 2005,2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -91,18 +91,11 @@ > } > > /** >- * Update the configuration based on the configuration Element >- * @throws AdapterInvalidConfig if the configuration processing failed. >- * @see org.eclipse.hyades.logging.adapter.IComponent#update() >+ * Read the sensor configuration from the configuration element >+ * @param parserParameters Hashtable to put the sensor parameters in > */ >- public void update() throws AdapterInvalidConfig >- { >- // first get the basic configuration set >- super.update(); >- // maximumBlocking is set by the sensor config >- String directory = null; >- String fileName = null; >- String className = null; >+ protected void readConfiguration(Hashtable parserParameters) { >+ // maximumBlocking is set by the sensor configuration > > String propertyName = null; > String propertyValue = null; >@@ -114,12 +107,10 @@ > > // Make a copy of the sensor properties to use as the parserParameters > Hashtable sensorParameters = getProperties(); >- Hashtable parserParameters = new Hashtable(); > > // This sensor may be configured with a sub element of the config > // or the sensor may be configured with sensor properties only. > >- boolean propertiesPresent = false; > // Get the sensor parameters from the sensor properties > if (sensorParameters != null && !sensorParameters.isEmpty()) { > // bugzilla 160528 - copy the sensor properties into the parserParamenters hash table because >@@ -131,8 +122,8 @@ > > fileName = (String)parserParameters.get(AdapterXMLConstants.HyadesGAfileNameAttributeName); > >- className = (String)parserParameters.get(AdapterXMLConstants.HyadesGAstaticParserClassAttributeName); >- propertiesPresent = true; >+ parserClassName = (String)parserParameters.get(AdapterXMLConstants.HyadesGAstaticParserClassAttributeName); >+ > } > else if (element != null) { > /** >@@ -158,7 +149,7 @@ > fileName = file; > } > if (sensorTypeInstance.hasAttribute(AdapterXMLConstants.HyadesGAstaticParserClassAttributeName)) >- className = sensorTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAstaticParserClassAttributeName); >+ parserClassName = sensorTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAstaticParserClassAttributeName); > > // Get the parameters from the sensor type instance properties > sensorNodes = sensorNode.getChildNodes(); >@@ -184,15 +175,23 @@ > } > } > } >- >+ } >+ >+ /** >+ * Process the values read from the configuration and update the hash table of >+ * parameters if necessary. >+ * @param parserParameters Hashtable of sensor parameters >+ * @throws AdapterInvalidConfig >+ */ >+ protected void processConfiguration(Hashtable parserParameters) throws AdapterInvalidConfig { > // We must have a directory and fileName >- if (directory == null || directory.length() == 0 || fileName == null || fileName.length() == 0 || className == null || className.length() == 0) { >+ if (directory == null || directory.length() == 0 || fileName == null || fileName.length() == 0 || parserClassName == null || parserClassName.length() == 0) { > throw new AdapterInvalidConfig(Messages.getString("HyadesGA_CBE_StaticParserSensor_Invalid_Config_File_ERROR_")); > } > > setDirectory(directory); > setFileName(fileName); >- setParserClassName(className); >+ setParserClassName(parserClassName); > > // Construct the full input log file name > if (getDirectory().endsWith(PATH_SEPARATOR)) { >@@ -265,14 +264,15 @@ > > parserParameters.put(ParserConstants.CONTINUOUS_KEY, new Boolean(continuousContext)); > >- /* bugzilla 91489 - if the directory and file name values are not already in the hash >- * table then add them so the parser class can use them instead of file_path to handle >- * regular expression values better. >+ /* bugzilla 91489 - reset the directory and file name values in the hash >+ * table so the parser class can use them instead of file_path to handle >+ * regular expression values better. The directory and file name values >+ * may have been changed before getting to this point so they should be >+ * reset in the hash table. > */ >- if (!propertiesPresent) { >- parserParameters.put(ParserConstants.DIRECTORY_KEY, directory); >- parserParameters.put(ParserConstants.FILE_NAME_KEY, fileName); >- } >+ >+ parserParameters.put(ParserConstants.DIRECTORY_KEY, directory); >+ parserParameters.put(ParserConstants.FILE_NAME_KEY, fileName); > > // Get the static parser class instance > try { >@@ -296,6 +296,23 @@ > } > > /** >+ * Update the configuration based on the configuration Element >+ * @throws AdapterInvalidConfig if the configuration processing failed. >+ * @see org.eclipse.hyades.logging.adapter.IComponent#update() >+ */ >+ public void update() throws AdapterInvalidConfig >+ { >+ // first get the basic configuration set >+ super.update(); >+ >+ Hashtable parserParameters = new Hashtable(); >+ >+ readConfiguration(parserParameters); >+ >+ processConfiguration(parserParameters); >+ } >+ >+ /** > * simulates a getNext > * @see org.eclipse.hyades.logging.adapter.ISensor#testGetNext() > */ >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/META-INF/MANIFEST.MF,v >retrieving revision 1.20 >diff -u -r1.20 MANIFEST.MF >--- META-INF/MANIFEST.MF 30 Nov 2007 03:05:09 -0000 1.20 >+++ META-INF/MANIFEST.MF 16 Jan 2008 11:38:32 -0000 >@@ -17,7 +17,7 @@ > org.eclipse.hyades.logging.parsers.importer, > org.eclipse.hyades.logging.parsers.internal.adapter.formatters, > org.eclipse.hyades.logging.parsers.internal.adapter.outputters, >- org.eclipse.hyades.logging.parsers.internal.importer >+ org.eclipse.hyades.logging.parsers.provisional.importer > Require-Bundle: org.eclipse.hyades.logging.core;bundle-version="[4.2.0,5.0.0)";visibility:=reexport, > org.eclipse.hyades.logging.adapter;bundle-version="[4.2.0,5.0.0)";visibility:=reexport, > org.eclipse.swt;bundle-version="[3.2.0,4.0.0)", >Index: src.import/org/eclipse/hyades/logging/parsers/importer/RemoteLogParserLoader.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src.import/org/eclipse/hyades/logging/parsers/importer/RemoteLogParserLoader.java,v >retrieving revision 1.14 >diff -u -r1.14 RemoteLogParserLoader.java >--- src.import/org/eclipse/hyades/logging/parsers/importer/RemoteLogParserLoader.java 2 Apr 2006 05:54:08 -0000 1.14 >+++ src.import/org/eclipse/hyades/logging/parsers/importer/RemoteLogParserLoader.java 16 Jan 2008 11:38:33 -0000 >@@ -1,7 +1,7 @@ > package org.eclipse.hyades.logging.parsers.importer; > > /********************************************************************** >- * Copyright (c) 2005,2006 IBM Corporation and others. >+ * Copyright (c) 2005,2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -28,10 +28,10 @@ > import org.eclipse.hyades.logging.core.LoggingAgent; > import org.eclipse.hyades.logging.parsers.LogParserException; > import org.eclipse.hyades.logging.parsers.ParserUtilities; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLADebug; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLALogger; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLALoggerFactory; >-import org.eclipse.hyades.logging.parsers.internal.importer.StatusMonitor; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLADebug; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLALogger; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLALoggerFactory; >+import org.eclipse.hyades.logging.parsers.provisional.importer.StatusMonitor; > /** > * This class handles initialization (e.g. calling the setUserInput() API) > * and invocation (e.g. calling the parse() API) of a remote log >Index: src.import/org/eclipse/hyades/logging/parsers/importer/ParserWrapper.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src.import/org/eclipse/hyades/logging/parsers/importer/ParserWrapper.java,v >retrieving revision 1.21 >diff -u -r1.21 ParserWrapper.java >--- src.import/org/eclipse/hyades/logging/parsers/importer/ParserWrapper.java 2 May 2007 06:44:08 -0000 1.21 >+++ src.import/org/eclipse/hyades/logging/parsers/importer/ParserWrapper.java 16 Jan 2008 11:38:33 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -36,8 +36,8 @@ > import org.eclipse.hyades.logging.parsers.ParserConstants; > import org.eclipse.hyades.logging.parsers.ParserUtilities; > import org.eclipse.hyades.logging.parsers.adapter.outputters.AdapterLogOutputter; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLADebug; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLAHelper; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLADebug; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLAHelper; > import org.w3c.dom.Document; > import org.w3c.dom.Element; > import org.w3c.dom.NamedNodeMap; >@@ -216,7 +216,7 @@ > * @return String - name of new config file > * @throws LogParserException > */ >- private String getNewConfigFile(Hashtable table) throws LogParserException >+ protected String getNewConfigFile(Hashtable table) throws LogParserException > { > Document doc = null; > >@@ -430,191 +430,216 @@ > if(GLADebug.INSTANCE.debug){ > GLADebug.INSTANCE.log("ParserWrapper.getNewConfigFile: setting sensor properties."); > } >- /** >- * Get the sensor config - there should only be one sensor - and fill in >- * the properties and attributes with the values from the input hash table >- */ >- NodeList sensorList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_SENSOR); >- int sensorCount = sensorList.getLength(); >- for (int i = 0; i < sensorCount; ++i) >- { >- Element sensorElement = (Element) sensorList.item(i); >- >- // We should always have a sensor instance but check in case an invalid >- // config file is used. >- if (sensorElement != null) { >- Element sensorNode; >- Element sensorPropertyElement; >- Element sensorTypeInstance = null; >+ >+ /* Iterate through the components in the context instance and set any component >+ * properties with their corresponding values in the input hash table. >+ */ >+ NodeList contextInstanceList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTINSTANCE); >+ >+ Element cIElement = (Element) contextInstanceList.item(0); >+ NodeList componentList = cIElement.getChildNodes(); >+ int compCount = componentList.getLength(); >+ >+ for (int i = 0; i<compCount; ++i) { >+ if (componentList.item(i) instanceof Element) { >+ Element compElement = (Element) componentList.item(i); >+ String tagName = compElement.getTagName(); >+ System.out.println(tagName); > String propValue; > String propName; >- String newConverterCmd = null; >+ Element propertyElement; > >- Element directoryPropertyElement = null; >- Element fileNamePropertyElement = null; >- >- // Get the sensor children (properties or sensor type instances) >- NodeList sensorNodes = sensorElement.getChildNodes(); >- for (int k = 0; k < sensorNodes.getLength(); k++) { >- if (sensorNodes.item(k).getNodeType() == Node.ELEMENT_NODE) { >- sensorNode = (Element) sensorNodes.item(k); >- // Process the sensor property >- if (sensorNode.getTagName().equals(AdapterXMLConstants.HyadesGAPropertyElementTagName)) { >- sensorPropertyElement = sensorNode; >- >- propName = sensorPropertyElement.getAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName); >- propValue = sensorPropertyElement.getAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName); >- >- if (propName.equals(AdapterXMLConstants.HyadesGAdirectoryAttributeName)) { >- // save property element so it can be set after converter processing >- directoryPropertyElement = sensorPropertyElement; >- /* There might not be a log file if the converter command generates a file. >- * If there is a log file then set the directory property >- */ >- if (logFileDir != null) { >- sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, logFileDir); >- } >- } >- else if (propName.equals(AdapterXMLConstants.HyadesGAfileNameAttributeName)) { >- // save property element so it can be set after converter processing >- fileNamePropertyElement = sensorPropertyElement; >- /* There might not be a log file if the converter command generates a file. >- * If there is a log file then set the fileName property >- */ >- if (logFileName != null) { >- sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, logFileName); >- } >- } >- else if (propName.equals(AdapterXMLConstants.HyadesGAconverterCmdAttributeName)) { >- if (propValue != null && propValue.length() > 0) { >- if (newConverterCmd == null) { >- newConverterCmd = modifyConverter(propValue, configFileDirectory, table, logFile); >- // ensure the new converter command is not null >- if (newConverterCmd == null) { >- newConverterCmd = ""; >- } >- } >- sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, newConverterCmd); >- } >- } >- else { >- propValue = (String)table.get(propName); >- if(propValue != null) >- { >- sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, propValue.trim()); >- } >- } >- } >- // Process the sensor type instance >- else if (sensorNode.getTagName().equals(AdapterXMLConstants.HyadesGAStaticParserSensorTagName) || >- sensorNode.getTagName().equals(AdapterXMLConstants.HyadesGASingleFileSensorTagName)) { >- sensorTypeInstance = sensorNode; >- // Get the sensor properties for this sensor type instance >- NodeList sensorPropertyList = sensorTypeInstance.getElementsByTagName(AdapterXMLConstants.HyadesGASensorPropertyElementTagName); >- int sensorPropertyCount = sensorPropertyList.getLength(); >- for(int j = 0; j < sensorPropertyCount; ++j) >- { >- sensorPropertyElement = (Element) sensorPropertyList.item(j); >- propName = sensorPropertyElement.getAttribute(AdapterXMLConstants.HyadesGASensorPropertyNameAttributeName); >- propValue = (String)table.get(propName); >- if(propValue != null) >- { >- sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGASensorPropertyValueAttributeName, propValue.trim()); >- } >- } >+ // If the component is a sensor Then set the appropriate sensor attributes and properties >+ if (compElement.getTagName().equals(AdapterXMLConstants.ELEMENT_TAG_NAME_SENSOR)) { >+ Element sensorElement = compElement; >+ >+ Element sensorNode; >+ Element sensorPropertyElement; >+ Element sensorTypeInstance = null; >+ String newConverterCmd = null; >+ >+ Element directoryPropertyElement = null; >+ Element fileNamePropertyElement = null; >+ >+ // Get the sensor children (properties or sensor type instances) >+ NodeList sensorNodes = sensorElement.getChildNodes(); >+ for (int k = 0; k < sensorNodes.getLength(); k++) { >+ if (sensorNodes.item(k).getNodeType() == Node.ELEMENT_NODE) { >+ sensorNode = (Element) sensorNodes.item(k); >+ // Process the sensor property >+ if (sensorNode.getTagName().equals(AdapterXMLConstants.HyadesGAPropertyElementTagName)) { >+ sensorPropertyElement = sensorNode; > >- // Get the sensor type attributes >- NamedNodeMap sensorTypeAttributeList = sensorTypeInstance.getAttributes(); >- int sensorTypeAttributeCount = sensorTypeAttributeList.getLength(); >- >- for(int j = 0; j < sensorTypeAttributeCount; ++j) >- { >- Node sensorTypeAttribute = sensorTypeAttributeList.item(j); >- String attrName = sensorTypeAttribute.getNodeName(); >- // Modify the attribute based on user input >- if(attrName.equals(AdapterXMLConstants.HyadesGAdirectoryAttributeName)) >- { >+ propName = sensorPropertyElement.getAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName); >+ propValue = sensorPropertyElement.getAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName); >+ >+ if (propName.equals(AdapterXMLConstants.HyadesGAdirectoryAttributeName)) { >+ // save property element so it can be set after converter processing >+ directoryPropertyElement = sensorPropertyElement; > /* There might not be a log file if the converter command generates a file. >- * If there is a log file then set the directory attribute >+ * If there is a log file then set the directory property > */ > if (logFileDir != null) { >- sensorTypeAttribute.setNodeValue(logFileDir); >+ sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, logFileDir); > } > } >- else if(attrName.equals(AdapterXMLConstants.HyadesGAfileNameAttributeName)) >- { >+ else if (propName.equals(AdapterXMLConstants.HyadesGAfileNameAttributeName)) { >+ // save property element so it can be set after converter processing >+ fileNamePropertyElement = sensorPropertyElement; > /* There might not be a log file if the converter command generates a file. >- * If there is a log file then set the fileName attribute >+ * If there is a log file then set the fileName property > */ > if (logFileName != null) { >- sensorTypeAttribute.setNodeValue(logFileName); >+ sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, logFileName); >+ } >+ } >+ else if (propName.equals(AdapterXMLConstants.HyadesGAconverterCmdAttributeName)) { >+ if (propValue != null && propValue.length() > 0) { >+ if (newConverterCmd == null) { >+ newConverterCmd = modifyConverter(propValue, configFileDirectory, table, logFile); >+ // ensure the new converter command is not null >+ if (newConverterCmd == null) { >+ newConverterCmd = ""; >+ } >+ } >+ sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, newConverterCmd); > } > } >- else if(attrName.equals(AdapterXMLConstants.HyadesGAconverterCmdAttributeName)) >- { >- if (newConverterCmd == null) { >- newConverterCmd = modifyConverter(sensorTypeAttribute.getNodeValue(), configFileDirectory, table, logFile); >- // ensure the new converter command is not null >- if (newConverterCmd == null) { >- newConverterCmd = ""; >- } >+ else { >+ propValue = (String)table.get(propName); >+ if(propValue != null) >+ { >+ sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, propValue.trim()); > } >- sensorTypeAttribute.setNodeValue(newConverterCmd); > } >- else >+ } >+ // Process the sensor type instance >+ else if (sensorNode.getTagName().equals(AdapterXMLConstants.HyadesGAStaticParserSensorTagName) || >+ sensorNode.getTagName().equals(AdapterXMLConstants.HyadesGASingleFileSensorTagName)) { >+ sensorTypeInstance = sensorNode; >+ // Get the sensor properties for this sensor type instance >+ NodeList sensorPropertyList = sensorTypeInstance.getElementsByTagName(AdapterXMLConstants.HyadesGASensorPropertyElementTagName); >+ int sensorPropertyCount = sensorPropertyList.getLength(); >+ for(int j = 0; j < sensorPropertyCount; ++j) > { >- propValue = (String)table.get(attrName); >+ sensorPropertyElement = (Element) sensorPropertyList.item(j); >+ propName = sensorPropertyElement.getAttribute(AdapterXMLConstants.HyadesGASensorPropertyNameAttributeName); >+ propValue = (String)table.get(propName); > if(propValue != null) > { >- sensorTypeAttribute.setNodeValue(propValue.trim()); >+ sensorPropertyElement.setAttribute(AdapterXMLConstants.HyadesGASensorPropertyValueAttributeName, propValue.trim()); >+ } >+ } >+ >+ // Get the sensor type attributes >+ NamedNodeMap sensorTypeAttributeList = sensorTypeInstance.getAttributes(); >+ int sensorTypeAttributeCount = sensorTypeAttributeList.getLength(); >+ >+ for(int j = 0; j < sensorTypeAttributeCount; ++j) >+ { >+ Node sensorTypeAttribute = sensorTypeAttributeList.item(j); >+ String attrName = sensorTypeAttribute.getNodeName(); >+ // Modify the attribute based on user input >+ if(attrName.equals(AdapterXMLConstants.HyadesGAdirectoryAttributeName)) >+ { >+ /* There might not be a log file if the converter command generates a file. >+ * If there is a log file then set the directory attribute >+ */ >+ if (logFileDir != null) { >+ sensorTypeAttribute.setNodeValue(logFileDir); >+ } >+ } >+ else if(attrName.equals(AdapterXMLConstants.HyadesGAfileNameAttributeName)) >+ { >+ /* There might not be a log file if the converter command generates a file. >+ * If there is a log file then set the fileName attribute >+ */ >+ if (logFileName != null) { >+ sensorTypeAttribute.setNodeValue(logFileName); >+ } >+ } >+ else if(attrName.equals(AdapterXMLConstants.HyadesGAconverterCmdAttributeName)) >+ { >+ if (newConverterCmd == null) { >+ newConverterCmd = modifyConverter(sensorTypeAttribute.getNodeValue(), configFileDirectory, table, logFile); >+ // ensure the new converter command is not null >+ if (newConverterCmd == null) { >+ newConverterCmd = ""; >+ } >+ } >+ sensorTypeAttribute.setNodeValue(newConverterCmd); >+ } >+ else >+ { >+ propValue = (String)table.get(attrName); >+ if(propValue != null) >+ { >+ sensorTypeAttribute.setNodeValue(propValue.trim()); >+ } > } > } > } > } > } >- } > >- // Get the sensor attributes >- NamedNodeMap sensorAttributeList = sensorElement.getAttributes(); >- int sensorTypeAttributeCount = sensorAttributeList.getLength(); >- >- for(int k = 0; k < sensorTypeAttributeCount; ++k) >- { >- Node sensorTypeAttribute = sensorAttributeList.item(k); >- String attrName = sensorTypeAttribute.getNodeName(); >- >- // Modify the attribute based on user input >- propValue = (String)table.get(attrName); >- if(propValue != null && propValue.length() > 0) >+ // Get the sensor attributes >+ NamedNodeMap sensorAttributeList = sensorElement.getAttributes(); >+ int sensorTypeAttributeCount = sensorAttributeList.getLength(); >+ >+ for(int k = 0; k < sensorTypeAttributeCount; ++k) > { >- sensorTypeAttribute.setNodeValue(propValue.trim()); >+ Node sensorTypeAttribute = sensorAttributeList.item(k); >+ String attrName = sensorTypeAttribute.getNodeName(); >+ >+ // Modify the attribute based on user input >+ propValue = (String)table.get(attrName); >+ if(propValue != null && propValue.length() > 0) >+ { >+ sensorTypeAttribute.setNodeValue(propValue.trim()); >+ } > } >- } > >- // Check if the directory of the log file to be parsed was updated by modifyConverter >- if (newDirectory != null) { >- // If so update it in the config file >- if (directoryPropertyElement != null) { >- directoryPropertyElement.setAttribute(AdapterXMLConstants.HyadesGASensorPropertyValueAttributeName, newDirectory); >- } >- if (sensorTypeInstance != null) { >- // Set the attribute >- Node sensorAttribute = sensorTypeInstance.getAttributeNode(AdapterXMLConstants.HyadesGAdirectoryAttributeName); >- sensorAttribute.setNodeValue(newDirectory); >+ // Check if the directory of the log file to be parsed was updated by modifyConverter >+ if (newDirectory != null) { >+ // If so update it in the config file >+ if (directoryPropertyElement != null) { >+ directoryPropertyElement.setAttribute(AdapterXMLConstants.HyadesGASensorPropertyValueAttributeName, newDirectory); >+ } >+ if (sensorTypeInstance != null) { >+ // Set the attribute >+ Node sensorAttribute = sensorTypeInstance.getAttributeNode(AdapterXMLConstants.HyadesGAdirectoryAttributeName); >+ sensorAttribute.setNodeValue(newDirectory); >+ } > } >+ >+ // Check if the name of the log file to be parsed was updated by modifyConverter >+ if (newFileName != null) { >+ // If so update it in the config file >+ if (fileNamePropertyElement != null) { >+ fileNamePropertyElement.setAttribute(AdapterXMLConstants.HyadesGASensorPropertyValueAttributeName, newFileName); >+ } >+ if (sensorTypeInstance != null) { >+ // Set the attribute >+ Node sensorAttribute = sensorTypeInstance.getAttributeNode(AdapterXMLConstants.HyadesGAfileNameAttributeName); >+ sensorAttribute.setNodeValue(newFileName); >+ } >+ } > } >- >- // Check if the name of the log file to be parsed was updated by modifyConverter >- if (newFileName != null) { >- // If so update it in the config file >- if (fileNamePropertyElement != null) { >- fileNamePropertyElement.setAttribute(AdapterXMLConstants.HyadesGASensorPropertyValueAttributeName, newFileName); >- } >- if (sensorTypeInstance != null) { >- // Set the attribute >- Node sensorAttribute = sensorTypeInstance.getAttributeNode(AdapterXMLConstants.HyadesGAfileNameAttributeName); >- sensorAttribute.setNodeValue(newFileName); >- } >+ // Else set the properties of the non-sensor components >+ else { >+ // Get the property children of the component >+ NodeList compProperties = compElement.getElementsByTagName(AdapterXMLConstants.HyadesGAPropertyElementTagName); >+ for (int k = 0; k < compProperties.getLength(); k++) { >+ propertyElement = (Element) compProperties.item(k); >+ // Set the property's value to the value of the corresponding parameter in the input hash table >+ propName = propertyElement.getAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName); >+ propValue = (String)table.get(propName); >+ if(propValue != null) >+ { >+ System.out.println("Set property " + propName + " with value " + propValue); >+ propertyElement.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, propValue.trim()); >+ } >+ } > } > } > } >Index: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLALoggerFactory.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLALoggerFactory.java >diff -N src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLALoggerFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLALoggerFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,88 @@ >+/********************************************************************** >+ * Copyright (c) 2005,2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: GLALoggerFactory.java,v 1.1 2005/06/28 19:33:31 dnsmith Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.logging.parsers.provisional.importer; >+ >+import org.apache.commons.logging.Log; >+import org.apache.commons.logging.LogConfigurationException; >+import org.eclipse.hyades.logging.commons.LoggerFactory; >+ >+/** >+ * This class extends org.eclipse.hyades.logging.commons.LoggerFactory >+ * to instantiate the org.eclpise.hyades.logging.parsers.GLALogger class. >+ * >+ * @see org.apache.commons.logging.LogFactory >+ * @see org.eclipse.hyades.logging.commons.Logger >+ * @see org.eclipse.hyades.logging.commons.LoggerFactory >+ * @see org.eclipse.hyades.logging.parsers.provisional.importer.GLALogger >+ */ >+public class GLALoggerFactory extends LoggerFactory { >+ >+ /** >+ * No-argument constructor. >+ */ >+ public GLALoggerFactory() { >+ super(); >+ } >+ >+ /** >+ * Returns an instance of a non-null named >+ * <code>org.eclipse.hyades.logging.parsers.GLALogger</code> based on the >+ * parameter name. >+ * <p> >+ * Passing a <code>null</code> logger name results in a <code>null</code> >+ * return value. >+ * <p> >+ * An instance of a named >+ * <code>org.eclipse.hyades.logging.parsers.GLALogger</code> is created if no >+ * named instance current exists or all instances have been released. >+ * <p> >+ * Once a named <code>org.eclipse.hyades.logging.parsers.GLALogger</code> is >+ * created, the instance is cached for future calls to retrieve the same >+ * named <code>org.eclipse.hyades.logging.parsers.GLALogger</code>. >+ * <p> >+ * The name of the <code>org.eclipse.hyades.logging.parsers.GLALogger</code> >+ * uniquely identifies an instance of an >+ * <code>org.eclipse.hyades.logging.parsers.GLALogger</code>. All subsequent >+ * calls will return the same instance of the named >+ * <code>org.eclipse.hyades.logging.parsers.GLALogger</code>. >+ * <p> >+ * >+ * @param loggerName >+ * The non-null name of the returned >+ * <code>org.eclipse.hyades.logging.parsers.GLALogger</code> >+ * instance. >+ * @return A named <code>org.eclipse.hyades.logging.parsers.GLALogger</code> >+ * instance, otherwise <code>null</code> if the parameter logger >+ * name is <code>null</code>. >+ * @exception LogConfigurationException >+ * if the named >+ * <code>org.eclipse.hyades.logging.parsers.GLALogger</code> >+ * instance could not be created. >+ * @see org.apache.commons.logging.LogFactory#getInstance(java.lang.String) >+ */ >+ public Log getInstance(String loggerName) throws LogConfigurationException { >+ >+ if (loggerName != null) { >+ >+ if (loggers.containsKey(loggerName)) { return (((Log) (loggers.get(loggerName)))); } >+ >+ GLALogger logger = new GLALogger(loggerName); >+ >+ loggers.put(loggerName, logger); >+ >+ return logger; >+ } >+ >+ return null; >+ } >+} >Index: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalLogImportLoader.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalLogImportLoader.java >diff -N src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalLogImportLoader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalLogImportLoader.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,179 @@ >+/********************************************************************** >+ * Copyright (c) 2006,2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ * Change History: >+ **********************************************************************/ >+package org.eclipse.hyades.logging.parsers.provisional.importer; >+ >+import java.util.Hashtable; >+ >+import org.apache.commons.logging.Log; >+import org.eclipse.hyades.loaders.util.XMLLoader; >+import org.eclipse.hyades.logging.parsers.LogParserException; >+import org.eclipse.hyades.logging.parsers.importer.ILogParser; >+ >+/** >+ * >+ * This is a specialized logger to be used by GLA for local log imports. It is >+ * instantiated by clients and passed to GLA via ParserWrapper.parse(Log) method. >+ * Currently it is available internally only for use by the Log Import Wizard in >+ * org.eclipse.tptp.monitoring.logui >+ * >+ * @author Cindy Jin >+ * >+ */ >+public class LocalLogImportLoader implements Log { >+ >+ >+ protected Hashtable parserParameters = null; >+ protected ILogParser parser = null; >+ protected XMLLoader xmlLoader = null; >+ protected Log logParser = null; >+ protected boolean traceXML = false; >+ >+ /** >+ * Trace logging level value. >+ */ >+ public static final int TRACE_LEVEL = 0; >+ >+ /** >+ * Debug logging level value. >+ */ >+ public static final int DEBUG_LEVEL = 1; >+ >+ /** >+ * Information logging level value. >+ */ >+ public static final int INFO_LEVEL = 2; >+ >+ /** >+ * Warning logging level value. >+ */ >+ public static final int WARN_LEVEL = 3; >+ >+ /** >+ * Error logging level value. >+ */ >+ public static final int ERROR_LEVEL = 4; >+ >+ /** >+ * Fatal logging level value. >+ */ >+ public static final int FATAL_LEVEL = 5; >+ >+ /** >+ * The logger's current logging level value. >+ */ >+ protected int loggingLevel; >+ public LocalLogImportLoader() >+ { >+ parser = null; >+ parserParameters = null; >+ } >+ >+ public LocalLogImportLoader(ILogParser parser, Hashtable parserParameters, boolean traceXML) { >+ this.parser = parser; >+ this.parserParameters = parserParameters; >+ this.traceXML = traceXML; >+ } >+ >+ public void setXMLLoader(XMLLoader xmlLoader) { >+ parserParameters.put("xmlLoader", xmlLoader); >+ this.xmlLoader = xmlLoader; >+ } >+ >+ >+ public void startParsing() throws LogParserException { >+ parser.setUserInput(parserParameters); >+ parser.parse(this); >+ } >+ public void setParserLogger(Log logParser){ >+ this.logParser = logParser; >+ parser.setParserLogger(logParser); >+ } >+ >+ public Log getParserLogger(){ >+ return logParser; >+ } >+ >+ public XMLLoader getXMLLoader() >+ { >+ return xmlLoader; >+ } >+ >+ public boolean isTraceEnabled() { >+ return (loggingLevel<=TRACE_LEVEL); >+ } >+ >+ public boolean isDebugEnabled() { >+ return (loggingLevel<=DEBUG_LEVEL); >+ } >+ >+ >+ public boolean isInfoEnabled() { >+ return (loggingLevel<=INFO_LEVEL); >+ } >+ >+ public boolean isWarnEnabled() { >+ return (loggingLevel<=WARN_LEVEL); >+ } >+ >+ public boolean isErrorEnabled() { >+ return (loggingLevel<=ERROR_LEVEL); >+ } >+ >+ public boolean isFatalEnabled() { >+ return (loggingLevel<=FATAL_LEVEL); >+ } >+ >+ >+ public void trace(Object record) { >+ } >+ >+ public void trace(Object record, Throwable throwable) { >+ } >+ >+ public void debug(Object record) { >+ } >+ >+ public void debug(Object record, Throwable throwable) { >+ } >+ >+ public void info(Object record) { >+ } >+ >+ public void info(Object record, Throwable throwable) { >+ } >+ >+ >+ public void warn(Object record) { >+ } >+ >+ public void warn(Object record, Throwable throwable) { >+ } >+ >+ public void error(Object record) { >+ } >+ >+ public void error(Object record, Throwable throwable) { >+ } >+ >+ >+ public void fatal(Object record) { >+ >+ } >+ >+ >+ public void fatal(Object record, Throwable throwable) { >+ >+ } >+ >+ >+} >Index: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalGLALogger.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalGLALogger.java >diff -N src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalGLALogger.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalGLALogger.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,203 @@ >+/********************************************************************** >+ * Copyright (c) 2006,2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: LocalGLALogger.java,v 1.2 2006/09/20 19:20:23 dnsmith Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.logging.parsers.provisional.importer; >+ >+import java.util.ArrayList; >+import java.util.List; >+ >+import org.apache.commons.logging.Log; >+import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; >+ >+public class LocalGLALogger implements Log { >+ >+ //private XmlGenerator xmlGenerator = new XmlGenerator(); >+ private List events = new ArrayList(); >+ private final String NL = System.getProperties().getProperty("line.separator"); >+ >+ private String detailMessage = null; >+ >+ /** >+ * Trace logging level value. >+ */ >+ public static final int TRACE_LEVEL = 0; >+ >+ /** >+ * Debug logging level value. >+ */ >+ public static final int DEBUG_LEVEL = 1; >+ >+ /** >+ * Information logging level value. >+ */ >+ public static final int INFO_LEVEL = 2; >+ >+ /** >+ * Warning logging level value. >+ */ >+ public static final int WARN_LEVEL = 3; >+ >+ /** >+ * Error logging level value. >+ */ >+ public static final int ERROR_LEVEL = 4; >+ >+ /** >+ * Fatal logging level value. >+ */ >+ public static final int FATAL_LEVEL = 5; >+ >+ /** >+ * The logger's current logging level value. >+ */ >+ private int loggingLevel; >+ >+ public LocalGLALogger() { >+ //xmlGenerator.reset(null, true, 8); >+ loggingLevel = 0; >+ } >+ >+ public String getLogDetails() { >+ StringBuffer buffer = new StringBuffer(); >+ synchronized(events){ >+ int s = events.size(); >+ String msg = null; >+ if(s>0){ >+ for(int i=0;i<s-1;i++){ >+ msg = (String)events.get(i); >+ if(msg!=null){ >+ buffer.append(msg); >+ buffer.append(NL); >+ } >+ } >+ msg = (String)events.get(s-1); >+ if(msg!=null){ >+ buffer.append(msg); >+ } >+ } >+ } >+ detailMessage = buffer.toString(); >+ return detailMessage; >+ } >+ >+ public boolean isDebugEnabled() { >+ return (loggingLevel <= DEBUG_LEVEL); >+ } >+ >+ public boolean isErrorEnabled() { >+ return (loggingLevel <= ERROR_LEVEL); >+ } >+ >+ public boolean isFatalEnabled() { >+ return (loggingLevel <= FATAL_LEVEL); >+ } >+ >+ public boolean isInfoEnabled() { >+ return (loggingLevel <= INFO_LEVEL); >+ } >+ >+ public boolean isTraceEnabled() { >+ return (loggingLevel <= TRACE_LEVEL); >+ } >+ >+ public boolean isWarnEnabled() { >+ return (loggingLevel <= WARN_LEVEL); >+ } >+ >+ public void trace(Object record) { >+ if (isTraceEnabled()) { >+ synchronized(events){ >+ if(record!=null && record instanceof CommonBaseEvent) >+ if(((CommonBaseEvent)record).getMsg()!=null && !events.contains(((CommonBaseEvent)record).getMsg())){ >+ events.add(((CommonBaseEvent)record).getMsg()); >+ } >+ } >+// this.detailMessage = xmlGenerator.objectToXML(record); >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ >+ } >+ >+ public void trace(Object record, Throwable arg1) { >+ if (isTraceEnabled()) { >+ trace(record); >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ >+ } >+ >+ public void debug(Object record) { >+ if (isDebugEnabled()) { >+ trace(record); >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ } >+ >+ public void debug(Object record, Throwable arg1) { >+ if (isDebugEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ >+ } >+ >+ public void info(Object record) { >+ if (isInfoEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ >+ } >+ >+ public void info(Object record, Throwable arg1) { >+ if (isInfoEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ >+ } >+ >+ public void warn(Object record) { >+ if (isWarnEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ >+ } >+ >+ public void warn(Object record, Throwable arg1) { >+ if (isWarnEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ } >+ >+ public void error(Object record) { >+ if (isErrorEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ } >+ >+ public void error(Object record, Throwable arg1) { >+ if (isErrorEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ } >+ >+ public void fatal(Object record) { >+ if (isFatalEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ } >+ >+ public void fatal(Object record, Throwable arg1) { >+ if (isFatalEnabled()) { >+// logXMLToModel(xmlGenerator.objectToXML(record)); >+ } >+ } >+ >+} >Index: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/StatusMonitor.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/StatusMonitor.java >diff -N src.import/org/eclipse/hyades/logging/parsers/provisional/importer/StatusMonitor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src.import/org/eclipse/hyades/logging/parsers/provisional/importer/StatusMonitor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/********************************************************************** >+ * Copyright (c) 2005,2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: StatusMonitor.java,v 1.1 2005/06/28 19:33:31 dnsmith Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.logging.parsers.provisional.importer; >+ >+import org.apache.commons.logging.Log; >+ >+/** >+ * This class is a runnable that checks the status of a log parser >+ * at regular intervals and sends the status to a logging agent. >+ */ >+public class StatusMonitor implements Runnable { >+ >+ // Class of the parser object >+ private Class parserClass = null; >+ >+ // The parser object >+ private Object parser = null; >+ >+ // The logging agent to write the status to. >+ private Log statusLogger = null; >+ >+ /** >+ * Constructor with required parameters >+ * @param parser object that is doing the log parsing >+ * @param parserClass class of the parser object >+ * @param statusLogger logging agent to write the status to >+ */ >+ public StatusMonitor(Object parser, Class parserClass, Log statusLogger) { >+ super(); >+ >+ this.parser = parser; >+ this.parserClass = parserClass; >+ this.statusLogger = statusLogger; >+ } >+ >+ /** >+ * Run this StatusMonitor thread. >+ * @see java.lang.Runnable#run() >+ */ >+ public void run() { >+ String status = null; >+ >+ // Status checking loop. >+ while (true) { >+ try { >+ // Get the status of the parsing object. >+ status = (String)parserClass.getMethod("getStatus",null).invoke(parser, null); >+ } >+ catch (Exception e) { >+ System.err.println("Exception occured when getting status: " + e.getMessage()); >+ status = null; >+ } >+ // write status string to status agent >+ if (status != null) { >+ statusLogger.trace(status); >+ } >+ >+ // If this thread has been interrupted then quit the monitoring loop. >+ if (Thread.interrupted()) { >+ break; >+ } >+ >+ /* Sleep for 2 seconds before checking the status again. >+ * The parsing thread may interrupt this thread to indicate it is done so break >+ * from the monitoring loop. >+ */ >+ try { >+ Thread.sleep(2000); >+ } >+ catch (InterruptedException e) { >+ // Quit the monitoring loop if this thread has been interrupted >+ break; >+ } >+ } >+ >+ } >+ >+} >Index: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLAHelper.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLAHelper.java >diff -N src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLAHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLAHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,501 @@ >+/********************************************************************** >+ * Copyright (c) 2005,2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.logging.parsers.provisional.importer; >+ >+import java.io.File; >+import java.lang.reflect.Constructor; >+import java.lang.reflect.InvocationTargetException; >+import java.lang.reflect.Method; >+import java.net.MalformedURLException; >+import java.net.URL; >+import java.util.Locale; >+import java.util.Map; >+import java.util.StringTokenizer; >+ >+import org.eclipse.hyades.logging.adapter.impl.AdapterXMLConstants; >+import org.eclipse.hyades.logging.adapter.util.AdapterConstants; >+import org.eclipse.hyades.logging.adapter.util.Messages; >+import org.eclipse.hyades.logging.parsers.LogParserException; >+import org.eclipse.hyades.logging.parsers.ParserConstants; >+import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; >+ >+/** >+ * Helper class for finding the GLA adapter configuration file. >+ * >+ * @author apnan >+ * >+ */ >+public class GLAHelper { >+ >+ protected static short platform = -1;//flag indicating whether the code runs in the workbench or outside the workbench >+ // the values that this flag can have are: >+ // -1: GLAHelper wasn't initialized >+ // 0: GLAHelper runs outside the workbench >+ // 1: GLAHelper runs in the workbench >+ >+ /** >+ * Get the adapter configuration file path. >+ * @param table the parser parameters hash stable >+ * @param nameSpace the plugin name if running in the workbench, null otherwise >+ * @param useOriginalAdapter boolean to indicate to use the original adapter file specification >+ * stored in the hash table with key originalAdapter >+ * @return the adapter file path. >+ * @throws LogParserException >+ */ >+ public static synchronized String getAdapterPath(Map table, String nameSpace, boolean useOriginalAdapter) throws LogParserException{ >+ >+ String key; >+ >+ if (useOriginalAdapter) { >+ key = LogParserConstants.ORIGINAL_ADAPTER_KEY; >+ } >+ else { >+ key = getAdapterPathKey(table); >+ if(key==null){ >+ String message = Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", (String)null); >+ throw new LogParserException(message); >+ } >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: adapter key="+key); >+ } >+ } >+ >+ String config_file = (String)table.get(key); >+ >+ //get the adapter config file path >+ String adapterFilePath = ""; >+ >+ if(config_file.indexOf("./")>-1){ >+ config_file = config_file.substring(2); >+ } >+ >+ /* If running in an eclipse workbench environment then try to get the adapter file >+ * path based on the plugin bundle. >+ */ >+ if(isWorkbenchMode()){ >+ try { >+ // Bundle bundle = Platform.getBundle(nameSpace); >+ Class platformClass = Class.forName("org.eclipse.core.runtime.Platform"); >+ Method getBundle = platformClass.getMethod("getBundle", new Class[]{String.class}); >+ Object bundle = getBundle.invoke(null, new String[]{nameSpace}); >+ Class pathClass = Class.forName("org.eclipse.core.runtime.IPath"); >+ Class bundleClass = Class.forName("org.osgi.framework.Bundle"); >+ Method find = platformClass.getMethod("find", new Class[]{bundleClass, pathClass}); >+ >+ if(bundle!=null){ >+ //verify if the adapter is NL enabled >+ if(config_file.indexOf("/nl/")>-1){ >+ config_file = getNLAdapterPath(table, config_file, find, bundle); >+ if(config_file==null){ >+ String message = Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", (String)table.get(key)); >+ throw new Exception(message); >+ } >+ adapterFilePath = config_file; >+ }else{ >+ URL fileURL = find(find, bundle, config_file); >+ if(fileURL==null){ >+ //config_file = "config/"+config_file; >+ fileURL = find(find, bundle, "config/"+config_file); >+ } >+ if(fileURL!=null){ >+ adapterFilePath = fileURL.toString(); >+ }else{ >+ /* Try using the config file root from the hash table if Log Import Wizard modified the >+ * adapter with a filter. */ >+ adapterFilePath = (String) table.get(LogParserConstants.CONFIG_FILE_ROOT_KEY) + "/" + config_file; >+ File test = new File(adapterFilePath); >+ if(!test.exists()){ >+ // Couldn't find adapter file so throw an exception >+ throw new LogParserException(Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", config_file)); >+ } >+ } >+ } >+ }else{ >+ adapterFilePath = config_file; >+ } >+ } >+ catch (Throwable e) { >+ // Capture the exception in a LogParserException >+ throw new LogParserException(Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", config_file),e); >+ } >+ >+ } >+ /* Else find the adapter file path based on path variables in the hash table */ >+ else{ >+ >+ //verify if the adapter is NL enabled >+ if(config_file.indexOf("/nl/")>-1){ >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: trying to get the nl adapter file using base file "+config_file); >+ } >+ config_file = getNLAdapterPath(table, config_file, null, null); >+ if(config_file==null){ >+ String message = Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", (String)table.get(key)); >+ throw new LogParserException(message); >+ } >+ adapterFilePath = config_file; >+ }else{ >+ String adapterPath = (String)table.get(LogParserConstants.CONFIG_FILE_ROOT_KEY) ; >+ >+// //check to see if the global properties are set >+// if (adapterPath == null){ >+// adapterPath = CBEConfigurationProperties.instance().getProperties().getProperty(CBEConfigurationProperties.ADAPTER_LOCATION); >+// } >+ adapterFilePath = adapterPath + "/" + config_file; >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: try to find the adapter file using ConfigFileRoot path eg. "+adapterFilePath); >+ } >+ File test = new File(adapterFilePath); >+ if(!test.exists()){ >+ adapterFilePath = adapterPath + "config/"+config_file; >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: try to find the adapter file using ConfigFileRoot path plus config eg. "+adapterFilePath); >+ } >+ test = new File(adapterFilePath); >+ if(!test.exists()){ >+ // last attempt >+ // >+ // Bug 62317 >+ // Try to resolve the config file using the command line list of directories >+ // >+ String config_paths = (String)table.get(LogParserConstants.CONFIG_PATH_KEY); // get the paths containing the adapter files >+ >+ // Check to ensure config_path was set in the input table >+ // If it is not then throw an appropriate exception. >+ if (config_paths != null && config_paths.length() != 0) { >+ StringTokenizer strtok = new StringTokenizer(config_paths, File.pathSeparator, false); // tokenize the path >+ while(strtok.hasMoreTokens()) { >+ String config_path = strtok.nextToken(); >+ >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: try to find the adapter file " + config_file + " using config_path "+config_path); >+ } >+ File f = new File(config_path, config_file); // look for the adapter file using the path >+ if(f.exists()) { >+// table.remove(LogParserConstants.CONFIG_PATH_KEY); // This is no longer required >+ adapterFilePath = f.getAbsolutePath(); >+ return adapterFilePath; >+ } >+ } >+ } >+ // Bug 62317 ends >+ >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("GLAHelper.getAdapterPath: could not find the adapter file! Throwing an exception."); >+ } >+ throw new LogParserException(Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", config_file)); >+ >+ } >+ } >+ } >+ } >+ return adapterFilePath; >+ } >+ /** >+ * Initializes the context in which this class is running. >+ * Determines whether the code runs in a workbench context or outside. >+ * Calling this method is required before using the adapter path helper method. >+ * >+ */ >+ protected static synchronized void initialize(){ >+ try { >+ Class resourcePlugin = Class.forName("org.eclipse.core.resources.ResourcesPlugin"); >+ Method getWorkspace = resourcePlugin.getMethod("getWorkspace", null); >+ Object workspace = getWorkspace.invoke(null, null); >+ Method getRoot = workspace.getClass().getMethod("getRoot", null); >+ Object root = getRoot.invoke(workspace, null); >+ >+ platform =(short)((root != null) ? 1 : 0); >+ } catch (ClassNotFoundException e) { >+ platform = 0; >+ } catch (SecurityException e) { >+ platform = 0; >+ } catch (NoSuchMethodException e) { >+ platform = 0; >+ } catch (IllegalArgumentException e) { >+ platform = 0; >+ } catch (IllegalAccessException e) { >+ platform = 0; >+ } catch (InvocationTargetException e) { >+ platform = 0; >+ } catch (NullPointerException e) { >+ platform = 0; >+ } >+ } >+ >+ /** >+ * Get the absolute path of the adapter configuration file. >+ * @param table the parser parameters hash stable >+ * @param nameSpace the plugin name if running in the workbench, null otherwise >+ * @param useOriginalAdapter boolean to indicate to use the original adapter file specification >+ * stored in the hash table with key originalAdapter >+ * @return the absolute path of the adapter file. >+ * @throws LogParserException >+ */ >+ public static synchronized String getAbsoluteAdapterPath(Map table, String nameSpace, boolean useOriginalAdapter) throws LogParserException{ >+ String adapterPath = getAdapterPath(table, nameSpace, useOriginalAdapter); >+ >+ /* If running in eclipse workbench environment Then the adapter path returned by getAdapterPath may >+ * be a URL based on the plugin bundle. In that case it needs to be converted to an >+ * absolute file path. >+ */ >+ if(isWorkbenchMode()){ >+ try{ >+ Class platformClass = Class.forName("org.eclipse.core.runtime.Platform"); >+ Method asLocalURL = platformClass.getMethod("asLocalURL", new Class[]{URL.class}); >+ URL adapterURL = new URL(adapterPath); >+ URL absoluteURL = (URL)asLocalURL.invoke(null, new Object[]{adapterURL}); >+ return absoluteURL.getFile(); >+ }catch (MalformedURLException ue) { >+ /* Assume that the path returned by getAdapterPath is not a URL but is already an absolute path for >+ * the adapter file. Iit will be returned. >+ */ >+ }catch (Throwable e) { >+ // Capture the exception in a LogParserException >+ throw new LogParserException(Messages.getString("HyadesGA_CBE_Adapter_No_Config_File_ERROR_", adapterPath),e); >+ } >+ >+ >+ } >+ return adapterPath; >+ } >+ /** >+ * Get the key that is used to find the adapter configuration file name in the hash table. >+ * @param table the parser parameters hash table >+ * @return the hash table key corresponding to the adapter file path, null if no adapter >+ * file path found. >+ */ >+ public static synchronized String getAdapterPathKey(Map table){ >+ String key = null; >+ String version = (String) (table.get(ParserConstants.APPLICATION_VERSION_KEY)); >+ String config_file = null; >+ >+ // If no version attribute given, use default >+ if(version == null) >+ { >+ version = LogParserConstants.DEFAULT_APPLICATION_VERSION_KEY; >+ } >+ >+ // Get the config file defined for this version >+ config_file = (String) (table.get(version)); >+ >+ if(config_file == null && version != LogParserConstants.DEFAULT_APPLICATION_VERSION_KEY) >+ { >+ // Cannot find the corresponding config file, use default >+ config_file = (String) (table.get(LogParserConstants.DEFAULT_APPLICATION_VERSION_KEY)); >+ >+ // If the default file is the desired adapter file then set the key to return >+ if(config_file != null) { >+ key = LogParserConstants.DEFAULT_APPLICATION_VERSION_KEY; >+ } >+ } >+ else if (config_file != null) { >+ key = version; >+ } >+ >+ return key; >+ >+ } >+ >+ /** >+ * >+ * @return boolean whether object is executing in an Eclipse workbench environment >+ */ >+ public static synchronized boolean isWorkbenchMode(){ >+ if(platform==-1){ >+ initialize(); >+ } >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("workbench="+platform); >+ } >+ >+ return platform ==1; >+ } >+ >+ /** >+ * Get the adapter configuration file path based on locale and encoding. >+ * @param table Hash table of input parameters >+ * @param configFilePath The adapter configuration file to find. >+ * @param find The method to find the file >+ * @param bundle - plugin bundle >+ * @return the adapter configuration file path >+ */ >+ protected static synchronized String getNLAdapterPath(Map table, >+ String configFilePath, Method find, Object bundle){ >+ >+ String characterEncoding = (String) table >+ .get(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_CHARACTER_ENCODING); >+ String countryCode = (String) table >+ .get(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_ISO_COUNTRY_CODE); >+ String languageCode = (String) table >+ .get(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_ISO_LANGUAGE_CODE); >+ >+ String locale = null; >+ /* >+ * bugzilla 135799 >+ * Get the default system locale and character encoding if the default string is >+ * passed in. >+ */ >+ if (languageCode != null && languageCode.equals(AdapterConstants.AttributeValue_Default)) { >+ languageCode = Locale.getDefault().getLanguage(); >+ } >+ if (countryCode != null && countryCode.equals(AdapterConstants.AttributeValue_Default)) { >+ countryCode = Locale.getDefault().getCountry(); >+ } >+ >+ if (characterEncoding != null && characterEncoding.equals(AdapterConstants.AttributeValue_Default)) { >+ try { >+ characterEncoding = System.getProperty("file.encoding"); >+ } >+ catch (SecurityException e) { >+ /* null file encoding will be handled below */ >+ } >+ } >+ if(countryCode!=null && countryCode.length() == 0){ >+ locale = languageCode; >+ }else if(countryCode!=null && languageCode!=null){ >+ locale = languageCode + "_" + countryCode; >+ } >+ >+ int i = configFilePath.indexOf("/nl/"); >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("characterEncoding="+characterEncoding); >+ GLADebug.INSTANCE.log("countryCode="+countryCode); >+ GLADebug.INSTANCE.log("languageCode="+languageCode); >+ } >+ >+ // try to find the adapter in the following order >+ // <root>/nl/<ISOLanguageCode>_<ISOCountryCode>/<characterEncoding> >+ // <root>/nl/<ISOLanguageCode>_<ISOCountryCode> >+ // <root>/nl/<characterEncoding> >+ // <root>/nl/ >+ >+ String[][] searchPath = new String[][]{{locale, characterEncoding}, {locale}, {characterEncoding}, {"/"}}; >+ if (i < 0) { >+ return configFilePath; >+ } >+ int j = configFilePath.lastIndexOf('/'); >+ String dir = configFilePath.substring(0, i + 3); >+ String fileName = configFilePath.substring(j); >+ >+ StringBuffer path = new StringBuffer(); >+ String[] currentPath = null; >+ int l = 0; >+ >+ String fullPath = null; >+ String lastPathAppended = null; >+ for(int idx=0;idx<4 && fullPath==null;idx++){ >+ currentPath = searchPath[idx]; >+ l = currentPath.length; >+ path.append(dir); >+ for(int jdx=0;jdx<l;jdx++){ >+ if(currentPath[jdx]==null){ >+ continue; >+ } >+ if(!currentPath[jdx].equals("/")){ >+ path.append('/'); >+ } >+ path.append(currentPath[jdx]); >+ lastPathAppended = currentPath[jdx]; >+ } >+ if(lastPathAppended!=null && lastPathAppended.equals("/")){ >+ path.append(fileName.substring(1)); >+ }else{ >+ path.append(fileName); >+ } >+ fullPath = getPath(table, find, bundle, path.toString()); >+ path.setLength(0); >+ } >+ >+ return fullPath; >+ } >+ >+ /** >+ * Get the full path of the adapter configuration file >+ * @param table Hash table of input parameters >+ * @param find The method to use to find the URL >+ * @param bundle The plugin bundle >+ * @param configFilePath >+ * @return the full path of the adapter file >+ */ >+ protected static synchronized String getPath(Map table, Method find, Object bundle, String configFilePath){ >+ String filePath = null; >+ if(bundle!=null){ >+ // workbench context mode: local import >+ URL fileURL = find(find, bundle, configFilePath); >+ if(fileURL==null){ >+ fileURL = find(find, bundle, "config/"+configFilePath); >+ } >+ if (fileURL != null) { >+ filePath = fileURL.toString(); >+ } >+ }else{ >+ // outside workbench context: remote import or web client >+ String adapterPath = (String)table.get(LogParserConstants.CONFIG_FILE_ROOT_KEY) ; >+ >+// //check to see if the global properties are set >+// if (adapterPath == null){ >+// adapterPath = CBEConfigurationProperties.instance().getProperties().getProperty(CBEConfigurationProperties.ADAPTER_LOCATION); >+// } >+ >+ String adapterFilePath = adapterPath + "/" + configFilePath; >+ File file = new File(adapterFilePath); >+ if(file.exists()){ >+ filePath = adapterFilePath; >+ }else { >+ String config_paths = (String)table.get(LogParserConstants.CONFIG_PATH_KEY); // get the paths containing the adapter files >+ if (config_paths != null && config_paths.length() != 0) { >+ StringTokenizer strtok = new StringTokenizer(config_paths, File.pathSeparator, false); // tokenize the path >+ while(strtok.hasMoreTokens()) { >+ String config_path = strtok.nextToken(); >+ >+ File f = new File(config_path, configFilePath); // look for the adapter file using the path >+ if(f.exists()) { >+ filePath = f.getAbsolutePath(); >+ } >+ } >+ } >+ } >+ } >+ if(GLADebug.INSTANCE.debug){ >+ GLADebug.INSTANCE.log("GLAHelper.getPath: Attempted to get adapter at path "+configFilePath +" result: file=" +filePath); >+ } >+ >+ return filePath; >+ } >+ >+ /** >+ * Find the URL of the adapter configuration file >+ * @param find The method to find the adapter file >+ * @param bundle - The plugin bundle >+ * @param config_file - the adapter configuration file to find >+ * @return the URL of the adapter configuration file >+ */ >+ protected static URL find(Method find, Object bundle, String config_file){ >+ URL fileURL = null; >+ Class pathClass; >+ try { >+ pathClass = Class.forName("org.eclipse.core.runtime.Path"); >+ Constructor pathConstructor = pathClass.getConstructor(new Class[] {config_file.getClass()}); >+ Object path = pathConstructor.newInstance(new Object[] {config_file}); >+ fileURL = (URL)find.invoke(null, new Object[]{bundle, path}); >+ >+ } catch (Exception e) { >+ if(GLADebug.INSTANCE.debug) >+ e.printStackTrace(); >+ } >+ return fileURL; >+ >+ } >+ >+} >Index: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLALogger.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLALogger.java >diff -N src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLALogger.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLALogger.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,97 @@ >+/********************************************************************** >+ * Copyright (c) 2005,2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: GLALogger.java,v 1.1 2005/06/28 19:33:31 dnsmith Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+ >+package org.eclipse.hyades.logging.parsers.provisional.importer; >+ >+import org.eclipse.hyades.logging.commons.Logger; >+import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; >+ >+/** >+ * This class extends org.eclipse.hyades.logging.commons.Logger >+ * so that it only logs the Common Base Event message instead of the >+ * whole Common Base Event. This class is used to log GLA messages. >+ * >+ * @see org.apache.commons.logging.Log >+ * @see org.apache.commons.logging.LogFactory >+ * @see org.eclipse.hyades.logging.core.LoggingAgent >+ * @see org.eclipse.hyades.logging.commons.Logger >+ * @see org.eclipse.hyades.logging.commons.LoggerFactory >+ */ >+public class GLALogger extends Logger { >+ >+ /** >+ * Constructor to create a logger instance with a Logging Agent using the >+ * parameter name. >+ * >+ * NOTE: The default logging level is set to WARN until explicitly set. >+ * >+ * @param name >+ * The name of the newly created logger. >+ */ >+ public GLALogger(String name) { >+ >+ super(name); >+ >+ } >+ >+ /** >+ * Logs the parameter <code>java.lang.Object</code> log record to the >+ * Logging Agent with the same name as the logger if TRACE logging is >+ * currently enabled. >+ * >+ * If the log record is a CommonBaseEvent only the CommonBaseEvent message will be >+ * sent to the Logging Agent. Otherwise it is assumed the record is a String. >+ * >+ * @param record >+ * The log record to be logged to the Logging Agent. >+ */ >+ public void trace(Object record) { >+ >+ if (isTraceEnabled()) { >+ if (record instanceof CommonBaseEvent) { >+ loggingAgent.write("glalog=" + ((CommonBaseEvent)record).getMsg()); >+ } >+ else if (record instanceof String) { >+ loggingAgent.write((String)record); >+ } >+ } >+ } >+ >+ /** >+ * Logs the parameter <code>java.lang.Object</code> log record and >+ * <code>java.lang.Throwable</code> exception to the Logging Agent with >+ * the same name as the logger if TRACE logging is currently enabled. >+ * >+ * If the log record is a CommonBaseEvent only the CommonBaseEvent message will be >+ * sent to the Logging Agent. Otherwise it is assumed the record is a String. >+ * >+ * Only the parameter <code>java.lang.Object</code> log record is logged. >+ * The <code>java.lang.Throwable</code> exception is ignored. >+ * >+ * @param record >+ * The log record to be logged to the Logging Agent. >+ * @param throwable >+ * The exception will be ignored >+ */ >+ public void trace(Object record, Throwable throwable) { >+ >+ if (isTraceEnabled()) { >+ if (record instanceof CommonBaseEvent) { >+ loggingAgent.write("glalog=" + ((CommonBaseEvent)record).getMsg()); >+ } >+ else if (record instanceof String) { >+ loggingAgent.write((String)record); >+ } >+ } >+ } >+ >+} >Index: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLADebug.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLADebug.java >diff -N src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLADebug.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src.import/org/eclipse/hyades/logging/parsers/provisional/importer/GLADebug.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,123 @@ >+/******************************************************************************* >+ * Copyright (c) 2005,2008 IBM Corporation and others. All rights reserved. This program and the >+ * accompanying materials are made available under the terms of the Eclipse >+ * Public License v1.0 which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id >+ * >+ * Contributors: IBM - Initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.hyades.logging.parsers.provisional.importer; >+ >+import java.io.FileNotFoundException; >+import java.io.FileOutputStream; >+import java.io.IOException; >+import java.lang.reflect.Method; >+import java.util.Date; >+ >+/** >+ * This class provides debugging facilities for the Log Import code. >+ * >+ * @author apnan >+ * >+ */ >+public class GLADebug { >+ >+ public boolean debug = false; >+ public boolean logToFile = false; >+ >+ protected String plugin_name; >+ protected String value; >+ protected final String NL = System.getProperties().getProperty("line.separator"); >+ private FileOutputStream log = null; >+ >+ public static GLADebug INSTANCE = new GLADebug("org.eclipse.hyades.logging.parsers"); >+ >+ public GLADebug(String plugin_name) { >+ this.plugin_name = plugin_name; >+ init(); >+ } >+ >+ /** >+ * Initialize the debugging code. >+ * >+ */ >+ protected void init() { >+ try { >+ // Get the debugging options from the options file. >+ Class platformClass = Class.forName("org.eclipse.core.runtime.Platform"); >+ Method getDebugOption = platformClass.getMethod("getDebugOption", new Class[]{String.class}); >+ value = (String)getDebugOption.invoke(null, new String[]{plugin_name+"/debug"}); >+ >+ if (value != null) { >+ debug = value.equalsIgnoreCase("true"); >+ } else if(System.getProperty("GLADebug.debug")!=null) >+ { >+ debug = Boolean.valueOf(System.getProperty("GLADebug.debug")).booleanValue(); >+ } >+ value = (String)getDebugOption.invoke(null, new String[]{plugin_name+"/logToFile"}); >+ if (value != null) { >+ logToFile = value.equalsIgnoreCase("true"); >+ } else if(System.getProperty("GLADebug.logToFile")!=null) >+ { >+ logToFile = Boolean.valueOf(System.getProperty("GLADebug.logToFile")).booleanValue(); >+ } >+ >+ >+ } catch (Exception e) { >+ // The platform is not available, read the environment variables >+ debug = Boolean.valueOf(System.getProperty("GLADebug.debug")).booleanValue(); >+ logToFile = Boolean.valueOf(System.getProperty("GLADebug.logToFile")).booleanValue(); >+ } >+ } >+ >+ /** >+ * Get the debug log file output stream. >+ * >+ * @return the FileOutputStream for the debug file >+ */ >+ public FileOutputStream getLog(){ >+ if(log==null){ >+ try { >+ log = new FileOutputStream("./GLADebug-"+(new Date()).getTime()); >+ } catch (FileNotFoundException e) { >+ if(debug) >+ e.printStackTrace(); >+ } >+ }else{ >+ if(!log.getChannel().isOpen()) >+ { >+ try { >+ log = new FileOutputStream("./GLADebug-"+(new Date()).getTime()); >+ } catch (FileNotFoundException e) { >+ if(debug) >+ e.printStackTrace(); >+ } >+ } >+ >+ } >+ return log; >+ } >+ >+ /** >+ * Log a debug message >+ * @param message >+ */ >+ public void log(String message){ >+ if(logToFile){ >+ // Log the message to the log file. >+ try { >+ getLog().write(message.getBytes()); >+ getLog().write(NL.getBytes()); >+ } catch (IOException e) { >+ if(debug) >+ e.printStackTrace(); >+ } >+ }else{ >+ // Log the message to System.out >+ System.out.println(message); >+ } >+ } >+ >+} >Index: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalLogParserLoader.java >=================================================================== >RCS file: src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalLogParserLoader.java >diff -N src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalLogParserLoader.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src.import/org/eclipse/hyades/logging/parsers/provisional/importer/LocalLogParserLoader.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,246 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: LocalLogParserLoader.java,v 1.1 2006/08/23 21:17:51 sleeloy Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ **********************************************************************/ >+package org.eclipse.hyades.logging.parsers.provisional.importer; >+ >+import java.io.UnsupportedEncodingException; >+import java.util.Hashtable; >+ >+import org.apache.commons.logging.Log; >+import org.eclipse.hyades.internal.logging.core.Constants; >+import org.eclipse.hyades.logging.events.cbe.util.EventFormatter; >+import org.eclipse.hyades.logging.events.cbe.util.EventHelpers; >+import org.eclipse.hyades.logging.parsers.importer.ILogParser; >+ >+public class LocalLogParserLoader extends LocalLogImportLoader{ >+ >+ //~ Constructors ------------------------------------------------------------------------------- >+ >+ public LocalLogParserLoader(ILogParser parser, Hashtable parserParameters, boolean traceXML) { >+ super(parser, parserParameters, traceXML); >+ loggingLevel=0; >+ } >+ >+ //~ Methods ------------------------------------------------------------------------------------ >+ >+ >+ public Log getParserLogger(){ >+ return logParser; >+ } >+ >+ //NOTE: Temporary API to propagate logged raw objects to the model as XML strings: >+ private void logXMLToModel(String xml) { >+ // Note: L0DocumentEventHandler (perftrace.loader.XMLLoader) XML scanner MUST be passed UTF8 encoded byte array data: >+ byte[] xmlLogEntryBytes = null; >+ >+ try { >+ xmlLogEntryBytes = xml.getBytes("UTF8"); >+ } >+ catch (UnsupportedEncodingException u) { >+ xmlLogEntryBytes = xml.getBytes(); >+ } >+ >+ // System.err.println(xml); >+ xmlLoader.loadEvent(xmlLogEntryBytes, xmlLogEntryBytes.length); >+ } >+ >+ /** >+ * Logs the parameter <code>java.lang.Object</code> log record to the Logging Agent >+ * with the same name as the logger if TRACE logging is currently enabled. >+ * >+ * The log record is first converted to XML and then sent to the Logging Agent. >+ * >+ * @param record The log record to be logged to the Logging Agent. >+ */ >+ >+ public void trace(Object record) { >+// try { >+ if (isTraceEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ >+ } >+ >+ public void trace(Object record, Throwable throwable) { >+// try { >+ if (isTraceEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ >+ } >+ >+ public void debug(Object record) { >+// try { >+ if (isDebugEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ >+ } >+ >+ public void debug(Object record, Throwable throwable) { >+// try { >+ if (isDebugEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ >+ } >+ >+ public void info(Object record) { >+// try { >+ if (isInfoEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ >+ } >+ >+ public void info(Object record, Throwable throwable) { >+ >+// try { >+ if (isInfoEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ } >+ >+ >+ public void warn(Object record) { >+// try { >+ if (isWarnEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ } >+ >+ public void warn(Object record, Throwable throwable) { >+// try { >+ if (isWarnEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ } >+ >+ public void error(Object record) { >+// try { >+ if (isErrorEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ } >+ >+ public void error(Object record, Throwable throwable) { >+ >+// try { >+ if (isErrorEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ } >+ >+ >+ public void fatal(Object record) { >+// try { >+ if (isFatalEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ } >+ >+ >+ public void fatal(Object record, Throwable throwable) { >+ >+// try { >+ if (isFatalEnabled()) { >+ if(!traceXML){ >+ logXMLToModel(EventFormatter.toCanonicalXMLString(EventHelpers.convertObjectToCommonBaseEvent(record,4), true).concat(Constants.LINE_SEPARATOR)); >+ }else{ >+ logXMLToModel((String)record); >+ } >+ } >+// } >+// catch (Throwable t) { >+// } >+ } >+ >+ >+} >+ >+ >#P org.eclipse.hyades.logging.adapter >Index: src/org/eclipse/hyades/logging/adapter/internal/util/Controller.java >=================================================================== >RCS file: src/org/eclipse/hyades/logging/adapter/internal/util/Controller.java >diff -N src/org/eclipse/hyades/logging/adapter/internal/util/Controller.java >--- src/org/eclipse/hyades/logging/adapter/internal/util/Controller.java 22 Mar 2007 05:29:24 -0000 1.9 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,1184 +0,0 @@ >-/********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >- * All rights reserved. This program and the accompanying materials >- * are made available under the terms of the Eclipse Public License v1.0 >- * which accompanies this distribution, and is available at >- * http://www.eclipse.org/legal/epl-v10.html >- * $Id: Controller.java,v 1.9 2007/03/22 05:29:24 dnsmith Exp $ >- * >- * Contributors: >- * IBM - Initial API and implementation >- * >- * Change History: >- * Bugzilla Description >- * 79014 Improved error handling and message logging >- * >- **********************************************************************/ >-package org.eclipse.hyades.logging.adapter.internal.util; >- >-import java.io.FileInputStream; >-import java.io.FileNotFoundException; >-import java.io.IOException; >-import java.io.InputStream; >-import java.util.Iterator; >-import java.util.List; >- >-import javax.xml.parsers.DocumentBuilderFactory; >-import javax.xml.parsers.ParserConfigurationException; >- >-import org.eclipse.hyades.logging.adapter.AdapterException; >-import org.eclipse.hyades.logging.adapter.AdapterInvalidConfig; >-import org.eclipse.hyades.logging.adapter.AdapterPlugin; >-import org.eclipse.hyades.logging.adapter.IComponent; >-import org.eclipse.hyades.logging.adapter.IContext; >-import org.eclipse.hyades.logging.adapter.IContextListener; >-import org.eclipse.hyades.logging.adapter.IOutputter; >-import org.eclipse.hyades.logging.adapter.IProcessUnit; >-import org.eclipse.hyades.logging.adapter.impl.AdapterContext; >-import org.eclipse.hyades.logging.adapter.impl.AdapterXMLConstants; >-import org.eclipse.hyades.logging.adapter.impl.Component; >-import org.eclipse.hyades.logging.adapter.impl.Context; >-import org.eclipse.hyades.logging.adapter.impl.Status; >-import org.eclipse.hyades.logging.adapter.parsers.PreparationException; >-import org.eclipse.hyades.logging.adapter.util.AdapterConstants; >-import org.eclipse.hyades.logging.adapter.util.AdapterUtilities; >-import org.eclipse.hyades.logging.adapter.util.Messages; >-import org.w3c.dom.Document; >-import org.w3c.dom.Element; >-import org.w3c.dom.Node; >-import org.w3c.dom.NodeList; >-import org.xml.sax.SAXException; >-/** >- * Controller manages a set of Context objects by setting the configurations and then starting each context. >- * >- */ >-public class Controller implements Runnable { >- >- private boolean singleFileInputMode = false; >- >- /* Keep our contexts and thier associated threads within a list. It is imperative that the index >- * of each list be kept consistant. That is, the thread running context at index n must be in the >- * thread list at index n >- */ >- private Context[] contexts; >- private Thread[] contextThreads; >- >- // Adapter log outputter component >- private IOutputter logOutputter = null; >- >- private String contextConfigurationFile = AdapterConstants.HyadesGADefaultContextConfigurationFile; >- private String componentConfigurationFile = AdapterConstants.HyadesGADefaultComponentConfigurationsFile; >- private DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); >- private InputStream inContextParams = null; >- private InputStream inAppParams = null; >- private boolean running = false; >- private long sleepTime = 500; >- >- // Overall logging level for the Adapter >- private short loggingLevel = -1; >- /** >- * Constructor for Controller. >- */ >- public Controller() { >- super(); >- } >- >- /** >- * Returns whether the Controller is running. >- * @return true if Controller is running, false otherwise >- */ >- public boolean isRunning() { >- return running; >- } >- >- /** >- * Start running the controller which means starting up each of the contexts. >- */ >- public void start() { >- /* RKD: We will run all of the contexts except the first one >- * (our internal logging context), each in its own thread. >- * The internal logging context was already started >- * when we went through the prepare stage. >- */ >- synchronized(contexts) { >- for (int i = 1; i < contextThreads.length; ++i) { >- if (contexts[i] != null && !contexts[i].isDisabled()) { >- contextThreads[i]=new Thread(contexts[i]); >- contextThreads[i].setName(contexts[i].getName() + AdapterConstants.HyadesGA + contexts[i].getUniqueID()); >- contextThreads[i].setDaemon(true); >- contextThreads[i].start(); >- } >- } >- } >- running = true; >- } >- >- /** >- * Stop the controller which means stopping all of the contexts if they >- * are still running. >- */ >- public void stop() { >- >- if (contexts != null && contextThreads != null) { >- synchronized(contexts) { >- int contextStopCount = 0; >- /* stop them in reverse order so that the logging context gets stopped last */ >- for (int i=contexts.length-1; i>0; i--) { >- /* bugzilla 74713 - set stopping flag instead of calling Context.stop() because >- * we're running in a different thread than the context. Also, only stop the >- * context if the context thread is still alive >- */ >- if (contexts[i] != null && contextThreads.length > i && contextThreads[i] != null && contextThreads[i].isAlive()) { >- contexts[i].setStopping(true); >- contextStopCount++; >- } >- } >- /* If other contexts are stopping Then sleep before stopping >- * the logging context to allow the other contexts >- * to log messages and end. >- * bugzilla 91218 - only sleep if there are contexts in the >- * process of stopping. >- */ >- if (contextStopCount > 0) { >- try { >- Thread.sleep(1500); >- } >- catch (InterruptedException e) { >- >- } >- } >- // Stop the logging context. >- if (contexts[0] != null && contextThreads.length > 0 && contextThreads[0] != null && contextThreads[0].isAlive()) { >- contexts[0].setStopping(true); >- // Wait until logging context is finished >- while (contextThreads[0] != null && contextThreads[0].isAlive()) { >- try { >- Thread.sleep(200); >- // System.out.println("Waited a fifth of a second for logging context to end"); >- } >- catch (InterruptedException e) { >- >- } >- } >- } >- } >- } >- running = false; >- } >- >- /** >- * This stop method will still cause the contexts to be stopped but will >- * not call the context listener methods when flushing the components. >- */ >- public void hardStop() { >- synchronized(contexts) { >- if (contexts != null && contextThreads != null) >- /* stop them in reverse order so that the logging context gets stopped last */ >- for (int i=contexts.length-1; i>=0; i--) { >- /* bugzilla 74713 - set hard stop flag instead of calling Context.stop() because >- * we're running in a different thread than the context. Also, only stop the >- * context if the context thread is still alive >- */ >- if (contexts[i] != null && contextThreads.length > i && contextThreads[i] != null && contextThreads[i].isAlive()) { >- // Set hardStop flag to stop the context >- contexts[i].setHardStop(); >- } >- } >- } >- running = false; >- } >- >- /** >- * Get the set of Context objects >- * @return the set of Context objects >- */ >- public IContext[] getContexts() { >- synchronized(contexts) { >- // Ensure the contexts have been created >- if (contexts == null || contexts.length <= 1) { >- return null; >- } >- // Exclude the internal logging context >- IContext newContextSet[] = new IContext[contexts.length-1]; >- for (int i=1; i < contexts.length; i++) { >- newContextSet[i-1] = contexts[i]; >- } >- return newContextSet; >- } >- } >- >- /** >- * Set the name of the file containing the configurations for the >- * contexts. >- * @param config - name of the context configuation file >- */ >- public void setContextConfigPath(String config) { >- contextConfigurationFile = config; >- } >- >- /** >- * Get the name of the file containing the configurations for the contexts >- * @return the contextConfigurationFile >- */ >- public String getContextConfigPath() { >- return contextConfigurationFile; >- } >- >- /** >- * Set the name of the file containing the configurations for the >- * components of the contexts. >- * @param config - name of the component configuation file >- */ >- public void setComponentConfigPath(String config) { >- componentConfigurationFile = config; >- } >- >- /** >- * Get the name of the file containing the configurations for the components of the contexts. >- * @return the componentConfigurationFile >- */ >- public String getComponentConfigPath() { >- return componentConfigurationFile; >- } >- >- /* >- * Validates an adapter file against the schema files. >- */ >- private void validateAdapterConfigurations(InputStream inAppStream, IProcessUnit logger) throws AdapterInvalidConfig { >- AdapterConfigValidator validator = new AdapterConfigValidator(logger); >- try{ >- validator.validate(inAppStream); >- }catch(AdapterException e){ >- log(e.toString()); >- } >- } >- >- /** >- * Prepare the adapter for execution. This involves reading and validating the adapter >- * configuration file(s), getting the context listeners from eclipse, starting the internal >- * logging context, and initializing the contexts. >- * @param validating boolean flag to indicate this method is called as part of adapter validation >- */ >- public void prepareAdapter(boolean validating) throws AdapterException { >- /* Open the context and configuration files */ >- try { >- inContextParams = new FileInputStream(contextConfigurationFile); >- if (singleFileInputMode) { >- inAppParams = new FileInputStream(contextConfigurationFile); >- } >- else { >- inAppParams = new FileInputStream(componentConfigurationFile); >- } >- } >- catch(FileNotFoundException e) { >- String filename=null; >- if(inContextParams==null) { >- filename=contextConfigurationFile; >- } >- else { >- filename=componentConfigurationFile; >- try { >- inContextParams.close(); >- } >- catch(IOException eprime) { >- /* We will ignore if this fails. It should be successful as we just opened the file */ >- } >- } >- /* We cannot open the adapter file */ >- throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Open_ERROR_", filename)); >- } >- catch (Throwable e) { >- String filename=null; >- if(inContextParams==null) { >- filename=contextConfigurationFile; >- } >- else { >- filename=componentConfigurationFile; >- try { >- inContextParams.close(); >- } >- catch(IOException eprime) { >- /* We will ignore if this fails. It should be successful as we just opened the file */ >- } >- } >- /* We cannot open the adapter file */ >- throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Open_ERROR_", filename),e); >- } >- >- // build the contexts based on configurations >- try { >- contexts = createContextsAndComponents(inContextParams); >- synchronized(contexts) { >- setComponentConfigurations(inAppParams); >- } >- >- /* We are done with the files. Lets close them */ >- try { >- inContextParams.close(); >- if(!singleFileInputMode) { >- inAppParams.close(); >- } >- } >- catch(IOException e) { >- /* We just had the file open. We are now closing it */ >- } >- >- /* Before we start the contexts locate any IContextListeners that >- * are registered with the plugin. This only works when we are running >- * as a plugin inside of Eclipse. Outside of Eclipse there is no notion >- * of IContextListeners. >- */ >- if (AdapterUtilities.isWorkbench()) { >- try { >- List contextListeners = AdapterPlugin.getContextListeners(); >- >- /* If this context has a listener then set it */ >- if (contextListeners != null) { >- Iterator listenerIterator = contextListeners.iterator(); >- while (listenerIterator.hasNext()) { >- IContextListener listener = (IContextListener) listenerIterator.next(); >- String[] targetContexts = listener.getTargetContextUniqueIds(); >- for (int j = 0; j < targetContexts.length; j++) { >- for (int k = 0; k < contexts.length; k++) { >- if (contexts[k].getUniqueID().equals(targetContexts[j])) { >- contexts[k].setContextListener(listener); >- } >- } >- } >- } >- } >- } >- catch (AdapterException e) { >- throw e; >- } >- catch (Throwable e) { >- throw new AdapterException(Messages.getString("HyadesGAInitialization_GetContextListeners_Failure_ERROR_"), e); >- } >- } >- >- /* Start the logging context in its entirty before we continue with anything else */ >- IProcessUnit logger=startInternalLoggingContext(); >- >- /* Validate the adapter configuration file against the schema files before starting the rest of the contexts. >- * It would have been good to have done this above, however, we want our internal logging context running so that we >- * can report any errors during validation >- */ >- inAppParams = new FileInputStream(contextConfigurationFile); >- validateAdapterConfigurations(inAppParams, logger); >- >- if (!singleFileInputMode) { >- inAppParams = new FileInputStream(componentConfigurationFile); >- validateAdapterConfigurations(inAppParams, logger); >- } >- >- // Count the number of contexts that are initialized and ready to execute >- int contextsReadyCount = 0; >- AdapterException initException = null; >- >- synchronized(contexts) { >- for (int i = 1; i < contexts.length; ++i) { >- if (contexts[i] != null) { >- >- /* Set the logger for this context to be the internal logging sensor */ >- contexts[i].setLogger(logger); >- >- /* Set the validating status for the context */ >- contexts[i].setValidating(validating); >- >- /* bugzilla 96433 >- * Set logging level of context and components if it needs to be globally set >- * and it is not being validated. >- */ >- if (!validating && loggingLevel > -1) { >- contexts[i].setLoggingLevel(loggingLevel); >- IComponent comp[] = contexts[i].getComponents(); >- for (int j=0; j<comp.length; j++) { >- comp[j].setLoggingLevel(loggingLevel); >- } >- } >- >- // set all the context config info >- if (!(contexts[i].init())) { >- contexts[i]=null; >- /* Make sure we log that this context will not be started */ >- log(Messages.getString("HyadesGAContextFatal_ERROR_")); >- continue; >- } >- // set all the component config info >- >- /* Setup the configuration information for this context. At this point in time the context >- * may fail to initialize itself properly. If that is the case then this context should be >- * disabled. >- */ >- try { >- contexts[i].update(); >- // Only increment context ready count if context is not disabled >- if (!contexts[i].isDisabled()) { >- contextsReadyCount++; >- } >- } >- catch(AdapterException e) { >- if (!validating) { >- contexts[i]=null; >- /* Make sure we log that this context will not be started */ >- log(Messages.getString("HyadesGAContextFatal_ERROR_")); >- } >- initException = e; >- } >- } >- } >- } >- // If there are no contexts ready to execute then quit! >- if (contextsReadyCount == 0) { >- if (initException != null) { >- throw initException; >- } >- else { >- throw new AdapterException(Messages.getString("HyadesGAContextFatal_ERROR_")); >- } >- } >- } >- catch(Throwable e) { >- /* RKD: Our caller will need to use our exception information for now to handle the error.*/ >- /* Don't log anything here. Assume the caller handles the exception and >- * logs a message if necessary. >- * log(Messages.getString("HyadesGAAdapterFatal_ERROR_")); >- * log(e.toString()); >- */ >- if (e instanceof AdapterException) { >- throw (AdapterException)e; >- } >- >- // Wrap non-AdapterException in an AdapterException >- String errorMsg = e.getMessage(); >- if (errorMsg == null) { >- errorMsg = e.toString(); >- } >- throw new AdapterException(errorMsg); >- } >- finally { >- >- /* Close our configuration file */ >- try { >- if (inAppParams != null) { >- inAppParams.close(); >- } >- if (inContextParams != null) { >- inContextParams.close(); >- } >- } >- catch (IOException e) { >- /* We couldn't close the configuration files. This should only occur if we failed to >- * open the file in the first place. >- */ >- log(e.toString()); >- } >- } >- } >- >- /** >- * Prepare the adapter configuration for execution. This involves >- * starting the internal logging context, and initializing the contexts. >- * @param validating boolean flag to indicate this method is called as part of adapter validation >- */ >- public void prepareConfiguration(boolean validating) throws AdapterException { >- >- try { >- /* Start the logging context in its entirty before we continue with anything else */ >- IProcessUnit logger=startInternalLoggingContext(); >- >- // Count the number of contexts that are initialized and ready to execute >- int contextsReadyCount = 0; >- AdapterException initException = null; >- >- synchronized(contexts) { >- for (int i = 1; i < contexts.length; ++i) { >- if (contexts[i] != null) { >- >- /* Set the logger for this context to be the internal logging sensor */ >- contexts[i].setLogger(logger); >- >- /* Set the validating status for the context */ >- contexts[i].setValidating(validating); >- >- /* bugzilla 96433 >- * Set logging level of context and components if it needs to be globally set >- * and it is not being validated. >- */ >- if (!validating && loggingLevel > -1) { >- contexts[i].setLoggingLevel(loggingLevel); >- IComponent comp[] = contexts[i].getComponents(); >- for (int j=0; j<comp.length; j++) { >- comp[j].setLoggingLevel(loggingLevel); >- } >- } >- >- // set all the context config info >- if (!(contexts[i].init())) { >- contexts[i]=null; >- /* Make sure we log that this context will not be started */ >- log(Messages.getString("HyadesGAContextFatal_ERROR_")); >- continue; >- } >- // set all the component config info >- >- /* Setup the configuration information for this context. At this point in time the context >- * may fail to initialize itself properly. If that is the case then this context should be >- * disabled. >- */ >- try { >- contexts[i].update(); >- // Only increment context ready count if context is not disabled >- if (!contexts[i].isDisabled()) { >- contextsReadyCount++; >- } >- } >- catch(AdapterException e) { >- if (!validating) { >- contexts[i]=null; >- /* Make sure we log that this context will not be started */ >- log(Messages.getString("HyadesGAContextFatal_ERROR_")); >- } >- initException = e; >- } >- } >- } >- } >- // If there are no contexts ready to execute then quit! >- if (contextsReadyCount == 0) { >- if (initException != null) { >- throw initException; >- } >- else { >- throw new AdapterException(Messages.getString("HyadesGAContextFatal_ERROR_")); >- } >- } >- } >- catch(Throwable e) { >- /* RKD: Our caller will need to use our exception information for now to handle the error.*/ >- /* Don't log anything here. Assume the caller handles the exception and >- * logs a message if necessary. >- * log(Messages.getString("HyadesGAAdapterFatal_ERROR_")); >- * log(e.toString()); >- */ >- if (e instanceof AdapterException) { >- throw (AdapterException)e; >- } >- >- // Wrap non-AdapterException in an AdapterException >- String errorMsg = e.getMessage(); >- if (errorMsg == null) { >- errorMsg = e.toString(); >- } >- throw new AdapterException(errorMsg); >- } >- >- } >- >- /** >- * parses Context configurations and build the Context objects >- * as well as set teh context config for each component >- */ >- private Context[] createContextsAndComponents(InputStream inContextStream) throws PreparationException { >- >- Document doc = null; >- Context[] contexts = null; >- try { >- doc = docFactory.newDocumentBuilder().parse(inContextStream); >- >- //Add the adapter logging context as default: >- Element loggingContext = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXT); >- loggingContext.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Context instance for the current component"); >- loggingContext.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.impl.AdapterContext"); >- loggingContext.setAttribute(AdapterXMLConstants.HyadesGAImplementationCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >- loggingContext.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "60"); >- loggingContext.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, AdapterXMLConstants.HyadesGAAdapterContextName); >- loggingContext.setAttribute(AdapterXMLConstants.HyadesGARoleAttributeName, "context"); >- loggingContext.setAttribute(AdapterXMLConstants.HyadesGARoleCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >- loggingContext.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "NB1F4ED002DA11D8A519FBE7C98C2F53"); >- >- Element loggingSensor = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_COMPONENT); >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Adapter logging sensor"); >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.internal.util.AdapterSensor"); >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGAImplementationCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >- // bugzilla 84698 - If there is an outputter Then let WARNING or higher messages be logged. >- if (logOutputter != null) { >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "30"); >- } >- // Otherwise let all messages be logged >- else { >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "0"); >- } >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "AdapterLogSensor"); >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGARoleAttributeName, "sensor"); >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGARoleCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >- loggingSensor.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "NF991E0004FF11D8930381B6A308BEB5"); >- >- loggingContext.appendChild(loggingSensor); >- >- Element loggingOutputter = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_COMPONENT); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Adapter logging outputter"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationVersionAttributeName, ""); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationVersionDescriptionAttributeName, ""); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGARoleAttributeName, "outputter"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGARoleCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N5F286A002DA11D8BC799C6AF4352915"); >- >- // Add the outputter specified by the user (eg. set by StaticParserWrapper in the log import case) >- if (logOutputter != null) { >- //Set the logging level so we get Warning, Critical and Fatal error messages >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "30"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, logOutputter.getClass().getName()); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "AdapterLogOutputter"); >- >- /************************************************************************************************* >- * bugzilla 79014 >- * Comment this out because we should not need to log to a file in the log import >- * case. GLA messages will be handled by the outputter set by the user. >- * However, we'll keep the code here in case we find it necessar to log to a file as well. >- * >- * loggingContext.appendChild(loggingOutputter); >- * >- * // Create a file outputter too >- * loggingOutputter = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_COMPONENT); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Adapter File logging outputter"); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationVersionAttributeName, ""); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationVersionDescriptionAttributeName, ""); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGARoleAttributeName, "outputter"); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGARoleCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "AdapterFileLoggerId"); >- * //Set the logging level so we get Warning, Critical and Fatal error messages >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "30"); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.internal.util.AdapterLogFileOutputter"); >- * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "AdapterLogFileOutputter"); >- * >- **************************************************************************************************/ >- } >- //Add the Eclipse Problems View outputter if in Eclipse mode. This is used when the context runs in the GLA editor. >- else if (AdapterUtilities.isWorkbench()) { >- //Set the logging level so we get any messages that are at least informational >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "10"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.internal.util.GlaTaskOutputter"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "CBEEclipseProblemsViewOutputter"); >- } >- //Add the log file outputter if in standalone mode: >- else { >- //Set the logging level so we get Warning, Critical and Fatal error messages >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "30"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.internal.util.AdapterLogFileOutputter"); >- loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "AdapterLogFileOutputter"); >- } >- >- loggingContext.appendChild(loggingOutputter); >- >- NodeList contextsNodeList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTS); >- >- if (contextsNodeList.getLength() == 0) { >- >- //Create a contexts element: >- Element contextsElement = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTS); >- >- /* Insert the logging context at the first of the child list of elements */ >- NodeList children=contextsElement.getChildNodes(); >- for(int i=0; i<children.getLength(); i++) { >- if(children.item(i).getNodeType()==Node.ELEMENT_NODE) { >- contextsElement.insertBefore(loggingContext, children.item(i)); >- break; >- } >- } >- >- doc.getDocumentElement().appendChild(contextsElement); >- } >- else { >- >- //ASSUMPTION: Only one contexts element permitted. >- >- //Retrieve the contexts element: >- Node contextsElement = contextsNodeList.item(0); >- /* Insert the logging context at the first of the child list of elements */ >- NodeList children=contextsElement.getChildNodes(); >- for(int i=0; i<children.getLength(); i++) { >- if(children.item(i).getNodeType()==Node.ELEMENT_NODE) { >- contextsElement.insertBefore(loggingContext, children.item(i)); >- break; >- } >- } >- >- doc.getDocumentElement().appendChild(contextsElement); >- } >- >- try { >- NodeList contextList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXT); >- // check to see if this file contains everything or just the context config >- NodeList tempInstanceList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTINSTANCE); >- if (tempInstanceList.getLength() > 0) >- singleFileInputMode = true; >- else >- singleFileInputMode = false; >- int count = contextList.getLength(); >- contexts = new Context[count]; >- int j = 0; >- Element element = null; >- Context context = null; >- Component component = null; >- >- for (int i = 0; i < count; ++i) { >- //TODO: HS need to support imbedded/nested contexts/components >- // Extract each root context and copy the expected attributes >- element = (Element) contextList.item(i); >- /* try and build the context. A number of things can go wrong here as we use relection to build the instance. */ >- context = ContextFactory.buildContext(element.getAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName), element.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName), element.getAttribute(AdapterXMLConstants.HyadesGANameAttributeName)); >- context.setContextConfiguration(element); >- >- // >- // get a list of all sub elements and assume they are components >- NodeList componentList = element.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_COMPONENT); >- IComponent[] compArray = null; >- int componentCount = componentList.getLength(); >- compArray = new IComponent[componentCount]; >- for (int k = 0, l = 0; k < componentCount; k++) { >- // Extract each component config >- element = (Element) componentList.item(k); >- >- // Check if we have a log outputter object already and if so then use that >- if (i == 0 && k ==1 && logOutputter != null) { >- component = (Component)logOutputter; >- component.setName(element.getAttribute(AdapterXMLConstants.HyadesGANameAttributeName)); >- component.setUniqueID(element.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName)); >- component.setExecutableClassName(element.getAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName)); >- } >- else { >- component = ComponentFactory.buildComponent(element.getAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName), element.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName), element.getAttribute(AdapterXMLConstants.HyadesGANameAttributeName)); >- } >- component.setContextConfiguration(element); >- compArray[l++] = component; >- } >- // put the components in the context >- context.setComponents(compArray); >- // put this context in the controller's array >- contexts[j++] = context; >- } >- } >- catch (PreparationException e) { >- throw e; >- } >- catch (Exception e) { >- throw new PreparationException(Messages.getString("HyadesGAInitialization_ContextConfiguration_Failure_ERROR_", contextConfigurationFile), e); >- } >- } >- catch (SAXException e) { >- /* We have a problem parsing the configuration file ABORT */ >- throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", contextConfigurationFile), e); >- } >- catch (ParserConfigurationException e) { >- throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", contextConfigurationFile), e); >- } >- catch (IOException e) { >- throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", contextConfigurationFile), e); >- } >- return contexts; >- } >- >- /** >- * CreateContextsConfig takes in an entire component configurations file and >- * separates out the context instances and gives each context the sub tree for itself and >- * it's components. >- */ >- private void setComponentConfigurations(InputStream inAppStream) throws AdapterInvalidConfig, PreparationException { >- >- Document doc = null; >- >- try { >- >- doc = docFactory.newDocumentBuilder().parse(inAppStream); >- >- //Add the adapter internal logging context instance as default: >- Element loggingSensorInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_SENSOR); >- loggingSensorInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "An adapter CBE sensor"); >- loggingSensorInstance.setAttribute(AdapterXMLConstants.HyadesGAmaximumBlockingAttributeName, "5"); >- loggingSensorInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "NF991E0004FF11D8930381B6A308BEB5"); >- >- Element loggerContextInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTINSTANCE); >- loggerContextInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Context instance for the current component"); >- /* Configure the internal logging context to run forever or until the adatper is explicitly stopped */ >- loggerContextInstance.setAttribute(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_CONTINUOUS_OPERATION, "true"); >- loggerContextInstance.setAttribute(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_MAXIMUM_IDLE_TIME, "0"); >- loggerContextInstance.setAttribute(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_PAUSE_INTERVAL, "10"); >- loggerContextInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "NB1F4ED002DA11D8A519FBE7C98C2F53"); >- >- loggerContextInstance.appendChild(loggingSensorInstance); >- >- // Configure the log outputter for the log import case >- if (logOutputter != null) { >- Element loggingOutputterInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_OUTPUTTER); >- loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Adapter log outputter"); >- loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N5F286A002DA11D8BC799C6AF4352915"); >- >- /* This outputter is created and configured by the user so there will not be any configuration properties for it. */ >- >- loggerContextInstance.appendChild(loggingOutputterInstance); >- >- /************************************************************************************************* >- * bugzilla 79014 >- * Comment this out because we should not need to log to a file in the log import >- * case. GLA messages will be handled by the outputter set by the user. >- * However, we'll keep the code here in case we find it necessary to log to a file as well. >- * >- * // Get the directory for the GLA log file >- * String glaLogDirectory = "."; >- * try { >- * >- * // Try to get the plugin's workspace directory (e.g. <workspace>/.metadata/plugins/org.eclipse.hyades.logging.adapter) >- * >- * Class platformClass = Class.forName("org.eclipse.core.runtime.Platform"); >- * >- * Method getPluginStateLocationMethod = platformClass.getMethod("getPluginStateLocation",new Class[]{Class.forName("org.eclipse.core.runtime.Plugin")}); >- * >- * Object iPathObject = getPluginStateLocationMethod.invoke(null,new Object[]{AdapterPlugin.getPlugin()}); >- * >- * Class iPathClass = iPathObject.getClass(); >- * >- * Method toOSStringMethod = iPathClass.getMethod("toOSString",null); >- * >- * glaLogDirectory = (String)(toOSStringMethod.invoke(iPathObject,null)); >- * } >- * catch (Exception e) { >- * // Ignore this and use the current directory for the GLA log file >- * } >- * >- * // Add the file logger component configuration >- * loggingOutputterInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_OUTPUTTER); >- * loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Single file outputter"); >- * loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "AdapterFileLoggerId"); >- * >- * Element outputterProperty = doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >- * outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, glaLogDirectory); >- * outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName,AdapterXMLConstants.HyadesGAdirectoryAttributeName); >- * loggingOutputterInstance.appendChild(outputterProperty); >- * >- * outputterProperty = doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >- * outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, "hgla.log"); >- * outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName,AdapterXMLConstants.HyadesGAfileNameAttributeName); >- * loggingOutputterInstance.appendChild(outputterProperty); >- * >- * loggerContextInstance.appendChild(loggingOutputterInstance); >- * >- ************************************************************************************/ >- } >- // Configure the Problems View outputter for the GLA editor case >- else if (AdapterUtilities.isWorkbench()) { >- >- Element loggingOutputterInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_OUTPUTTER); >- loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Eclipse error dialog outputter"); >- loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N5F286A002DA11D8BC799C6AF4352915"); >- >- /* RKD: We need to inform the outputter of the configuration path so it can create markers for the resource */ >- Element resourcePathProperty=doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >- resourcePathProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName, "resourceName"); >- resourcePathProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, contextConfigurationFile); >- >- loggingOutputterInstance.appendChild(resourcePathProperty); >- loggerContextInstance.appendChild(loggingOutputterInstance); >- } >- else{ >- >- Element loggingOutputterInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_OUTPUTTER); >- loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Single file outputter"); >- loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N5F286A002DA11D8BC799C6AF4352915"); >- >- Element outputterProperty = doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >- outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, "."); >- outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName,AdapterXMLConstants.HyadesGAdirectoryAttributeName); >- loggingOutputterInstance.appendChild(outputterProperty); >- >- outputterProperty = doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >- outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, "hgla.log"); >- outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName,AdapterXMLConstants.HyadesGAfileNameAttributeName); >- loggingOutputterInstance.appendChild(outputterProperty); >- >- loggerContextInstance.appendChild(loggingOutputterInstance); >- } >- >- NodeList configurationNodeList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONFIGURATION); >- >- if (configurationNodeList.getLength() == 0) { >- >- //Create a configuration element: >- Element loggerConfigurationInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_CONFIGURATION); >- loggerConfigurationInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "The component level configurations for this adapter"); >- loggerConfigurationInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N06FBD3004FF11D8BCF4CFA9EA8F31E7"); >- >- loggerConfigurationInstance.appendChild(loggerContextInstance); >- >- doc.getDocumentElement().appendChild(loggerConfigurationInstance); >- } >- else { >- >- //ASSUMPTION: Only one configuration element permitted. >- >- //Retrieve the configuration element: >- Node loggerConfigurationInstance = configurationNodeList.item(0); >- loggerConfigurationInstance.appendChild(loggerContextInstance); >- >- doc.getDocumentElement().appendChild(loggerConfigurationInstance); >- } >- >- try { >- // get a list of all the context instances and associates each with a context >- NodeList contextInstanceList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTINSTANCE); >- >- int contextInstanceCount = contextInstanceList.getLength(); >- for (int i = 0; i < contextInstanceCount; ++i) { >- try { >- //find the matching Context and Context Instance >- Element contextElement = (Element) contextInstanceList.item(i); >- String contextInstanceID = contextElement.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName); >- >- int contextCount = contexts.length; >- /* Throw an exception if we have a mismatch in the number of Context's and >- * the number of ContextInstance's. >- */ >- if (contextInstanceCount != contextCount) { >- throw new AdapterInvalidConfig(Messages.getString("HyadesGAContextConfigurationErrorContextCountMismatchFatal_ERROR_")); >- } >- >- boolean contextFound = false; >- for (int j = 0; j < contextCount; j++) { >- if (contexts[j].getUniqueID().equals(contextInstanceID)) { >- contexts[j].setConfiguration(contextElement); >- contextFound = true; >- // so now we have a good context which may or may not have components >- //assume each child of the contextInstance is a component >- NodeList componentInstanceList = contextElement.getChildNodes(); >- int numberOfComponentInstances = componentInstanceList.getLength(); >- // get the components from the context >- IComponent components[] = contexts[j].getComponents(); >- int componentCount = components.length; >- >- int componentInstanceCount = 0; >- for (int k = 0; k < numberOfComponentInstances; k++) { >- if (componentInstanceList.item(k).getNodeType() == Node.ELEMENT_NODE) { >- Element componentElement = (Element) componentInstanceList.item(k); >- String componentInstanceID = componentElement.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName); >- boolean componentFound = false; >- componentInstanceCount++; >- // walk through the components of the context and set the config >- for (int l = 0; l < componentCount; l++) { >- if (components[l].getUniqueID().equals(componentInstanceID)) { >- components[l].setConfiguration(componentElement); >- componentFound = true; >- /* bugzilla 82193 >- * If this is a formatter and we are running in the GLA editor >- */ >- if (componentElement.getNodeName().equals(AdapterXMLConstants.ELEMENT_TAG_NAME_FORMATTER) && >- logOutputter == null && AdapterUtilities.isWorkbench()) { >- /* Add the test attribute to the formatter element to indicate we are running >- * in the GLA editor environment. >- */ >- componentElement.setAttribute(AdapterConstants.AttrubuteName_Test,AdapterConstants.AttrubuteValue_Test_True); >- } >- break; >- } >- } >- if (!componentFound) { >- throw new AdapterInvalidConfig(Messages.getString("HyadesGAContextInstanceConfigurationErrorComponentIdNotFoundFatal_ERROR_",componentInstanceID , contexts[j].getUniqueID())); >- } >- } >- } >- /* Throw an exception if we have a mismatch in number of components between >- * the context and the contextInstance. >- */ >- if (componentInstanceCount != componentCount) { >- throw new AdapterInvalidConfig(Messages.getString("HyadesGAContextInstanceConfigurationErrorComponentMismatchFatal_ERROR_",contexts[j].getUniqueID())); >- } >- break; >- } >- } >- if (!contextFound) { >- throw new AdapterInvalidConfig(Messages.getString("HyadesGAContextInstanceConfigurationErrorContextIdNotFoundFatal_ERROR_", contextInstanceID)); >- } >- } >- catch (AdapterInvalidConfig e) { >- throw e; >- } >- catch (Exception e) { >- throw new PreparationException(Messages.getString("HyadesGAInitialization_ContextInstanceConfiguration_Failure_ERROR_", componentConfigurationFile), e); >- } >- } >- } >- catch (AdapterInvalidConfig e) { >- throw e; >- } >- catch (Exception e) { >- throw new PreparationException(Messages.getString("HyadesGAInitialization_ContextInstanceConfiguration_Failure_ERROR_", componentConfigurationFile), e); >- } >- } >- catch (SAXException e) { >- /* We have a problem parsing the configuration file ABORT */ >- throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", componentConfigurationFile), e); >- } >- catch (ParserConfigurationException e) { >- throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", componentConfigurationFile), e); >- } >- catch (IOException e) { >- throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", componentConfigurationFile), e); >- } >- } >- /** >- * run provides the basic loop for a Controller thread. It starts the Controller thread and >- * then monitors it. >- */ >- public void run() { >- start(); >- while (isRunning()) { >- synchronized (this) { >- try { >- wait(sleepTime); >- } >- catch (Exception e) { >- log(e.toString()); >- } >- if (areContextsDone()) { >- // Stop the Adapter logging context >- stop(); >- } >- } >- } >- } >- /** >- * return false if any context is still alive, otherwise return true >- */ >- private boolean areContextsDone() { >- if (contextThreads != null) { >- /* Ignore the internal logging context. hense we start at index 1 */ >- for (int i = 1; i < contextThreads.length; i++) { >- if (contextThreads[i] != null) { >- if (contextThreads[i].isAlive() && !(contexts[i] instanceof AdapterContext)) >- return false; >- } >- } >- } >- return true; >- } >- >- /** >- * clean a controller by nulling out everything >- */ >- private void clean() { >- if (contexts != null) { >- for (int i = 0; i < contexts.length; i++) { >- contexts[i] = null; >- } >- } >- contexts = null; >- // hashContextConfig.clear(); >- } >- >- /** >- * Starts the internal logging context. >- * >- */ >- private IProcessUnit startInternalLoggingContext() { >- contexts[0].init(); >- contextThreads=new Thread[contexts.length]; >- try { >- contexts[0].update(); >- // bugzilla 96433 - Reset the logging context status >- contexts[0].setStopping(false); >- contextThreads[0]=new Thread(contexts[0]); >- contextThreads[0].setName(contexts[0].getName() + AdapterConstants.HyadesGA + contexts[0].getUniqueID()); >- contextThreads[0].setDaemon(true); >- contextThreads[0].start(); >- return (IProcessUnit)contexts[0].getComponents()[0]; >- >- } >- catch(AdapterException e) { >- /* Since we are generating the context content we should not have configuration problems */ >- /* However, we may get an exception here if the GLA logging cannot be initialized. */ >- log(Messages.getString("HyadesGAInitialization_Internal_Logging_Not_Started_WARN_", e.getLocalizedMessage())); >- } >- catch(Exception e) { >- /* Catch any other kind of exception and log a message */ >- log(Messages.getString("HyadesGAInitialization_Internal_Logging_Not_Started_WARN_", e.toString())); >- } >- return null; >- } >- >- /** >- * Log the string message to standard error since the logging outputter(s) >- * associated with the <code>AdapterSensor</code> logger will never be >- * started. >- * >- * @param logRecord The string message to be logged to standard error. >- */ >- public void log(String logRecord) { >- if(!AdapterUtilities.isWorkbench()) { >- System.err.println(logRecord); >- } >- >- } >- >- /** >- * Get the status of the contexts >- * @return the array of Status objects representing the status of the contexts >- */ >- public Status [] getStatus() { >- Status [] statuses = null; >- >- /* If there are context then get their status */ >- if (contexts != null) { >- synchronized(contexts) { >- statuses = new Status[contexts.length]; >- /* get the status for each context */ >- for (int i=0; i < contexts.length; i++) { >- if (contexts[i] != null) { >- statuses[i] = contexts[i].getContextStatus(); >- } >- else { >- statuses[i] = null; >- } >- } >- } >- } >- >- return statuses; >- } >- >- /** >- * Get the custom Outputter that the internal logging context is using. >- * @return Returns the custom Outputter that the internal logging context is using. >- */ >- public IOutputter getLogOutputter() { >- return logOutputter; >- } >- /** >- * Sets the custom Outputter for the internal logging context to use. >- * @param logOutputter The custom Outputter for the internal logging context. >- */ >- public void setLogOutputter(IOutputter logOutputter) { >- this.logOutputter = logOutputter; >- } >- >- /** >- * Sets the loggingLevel of the Adapter object. This value will override >- * all values in the adapter configuration. The logging level value specified will >- * take effect the next time the Adapter is started. If this method is >- * not called or is called with a value of -1, the logging levels specified in the >- * adapter configuration will be used. >- * @param newLevel The level of logging that the Adapter will use during execution >- */ >- public void setLoggingLevel(short newLevel) >- { >- loggingLevel = newLevel; >- } >- >- /** >- * Get the logging level of the Adapter object. >- * @return the level of logging the Adapter is currently using >- */ >- public short getLoggingLevel() { >- return loggingLevel; >- } >-} >Index: src/org/eclipse/hyades/logging/adapter/outputters/CBEFileOutputter.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.adapter/src/org/eclipse/hyades/logging/adapter/outputters/CBEFileOutputter.java,v >retrieving revision 1.8 >diff -u -r1.8 CBEFileOutputter.java >--- src/org/eclipse/hyades/logging/adapter/outputters/CBEFileOutputter.java 8 Sep 2006 07:25:12 -0000 1.8 >+++ src/org/eclipse/hyades/logging/adapter/outputters/CBEFileOutputter.java 16 Jan 2008 11:38:36 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005,2006 IBM Corporation and others. >+ * Copyright (c) 2005,2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -47,6 +47,8 @@ > private String fileName = null; > protected String rawLogFileName = null; > protected FileWriter fw = null; >+ protected String tmpFileName = null; >+ protected String tmpDirectory = null; > > /** > * This implementation processes messages represented by an array of CommonBaseEvent objects >@@ -188,24 +190,11 @@ > this.fileName = fileName; > updateConfigurationPropertyChild(AdapterXMLConstants.HyadesGAfileNameAttributeName, fileName); > } >- >+ > /** >- * update the configuration based on the configuration Element >+ * Read the outputter configuration from the configuration element > */ >- public void update() throws AdapterInvalidConfig >- { >- // first get the basic configuration set >- super.update(); >- >- /* The directory and fileName may be set already if the >- * outputter is passed to the adapter as the GLA Adapter Log >- * Outputter so intialize the local variables with those values. >- * Note, they will be overwritten below by the values in the >- * configuration if they are present. >- */ >- String directory = getDirectory(); >- String fileName = getFileName(); >- >+ protected void readConfiguration() { > // Get configuration > > Element element = getConfiguration(); >@@ -216,9 +205,9 @@ > // Get the outputter parameters from the outputter properties > Hashtable outputterProperties = getProperties(); > if (outputterProperties != null && !outputterProperties.isEmpty()) { >- directory = (String)outputterProperties.get(AdapterXMLConstants.HyadesGAdirectoryAttributeName); >+ tmpDirectory = (String)outputterProperties.get(AdapterXMLConstants.HyadesGAdirectoryAttributeName); > >- fileName = (String)outputterProperties.get(AdapterXMLConstants.HyadesGAfileNameAttributeName); >+ tmpFileName = (String)outputterProperties.get(AdapterXMLConstants.HyadesGAfileNameAttributeName); > } > else if (element != null) { > /** >@@ -234,27 +223,33 @@ > outputterTypeInstance = outputterNode; > // Get attributes > if (outputterTypeInstance.hasAttribute(AdapterXMLConstants.HyadesGAdirectoryAttributeName)) >- directory = outputterTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAdirectoryAttributeName); >+ tmpDirectory = outputterTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAdirectoryAttributeName); > if (outputterTypeInstance.hasAttribute(AdapterXMLConstants.HyadesGAfileNameAttributeName)) >- fileName = outputterTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAfileNameAttributeName); >+ tmpFileName = outputterTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAfileNameAttributeName); > } > } > } > } >- >+ } >+ >+ /** >+ * Process the values read from the configuration and perform other initialization >+ * @throws AdapterInvalidConfig >+ */ >+ protected void processConfiguration() throws AdapterInvalidConfig { > // We must have a directory and fileName >- if (directory == null || directory.length() == 0 || fileName == null || fileName.length() == 0) { >+ if (tmpDirectory == null || tmpDirectory.length() == 0 || tmpFileName == null || tmpFileName.length() == 0) { > throw new AdapterInvalidConfig(Messages.getString("HyadesGA_CBE_SingleFileOutputter_Invalid_Config_File_ERROR_")); > } > > // Check if the directory is actually a directory >- File dir = new File(directory); >+ File dir = new File(tmpDirectory); > if (!dir.isDirectory()) { > throw new AdapterInvalidConfig(Messages.getString("HyadesGA_CBE_SingleFileOutputter_Invalid_Config_File_ERROR_")); > } > >- setDirectory(directory); >- setFileName(fileName); >+ setDirectory(tmpDirectory); >+ setFileName(tmpFileName); > > // Get the parent context so we can get the validating flag > boolean validating = false; >@@ -274,6 +269,28 @@ > } > > /** >+ * update the configuration based on the configuration Element >+ */ >+ public void update() throws AdapterInvalidConfig >+ { >+ // first get the basic configuration set >+ super.update(); >+ >+ /* The directory and fileName may be set already if the >+ * outputter is passed to the adapter as the GLA Adapter Log >+ * Outputter so intialize the local variables with those values. >+ * Note, they will be overwritten below by the values in the >+ * configuration if they are present. >+ */ >+ tmpDirectory = getDirectory(); >+ tmpFileName = getFileName(); >+ >+ readConfiguration(); >+ >+ processConfiguration(); >+ } >+ >+ /** > * Prepare the file for the log CBE output > */ > protected void prepareFile() throws AdapterInvalidConfig >Index: src/org/eclipse/hyades/logging/adapter/sensors/SingleOSFileSensor.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.adapter/src/org/eclipse/hyades/logging/adapter/sensors/SingleOSFileSensor.java,v >retrieving revision 1.15 >diff -u -r1.15 SingleOSFileSensor.java >--- src/org/eclipse/hyades/logging/adapter/sensors/SingleOSFileSensor.java 20 Sep 2006 05:04:50 -0000 1.15 >+++ src/org/eclipse/hyades/logging/adapter/sensors/SingleOSFileSensor.java 16 Jan 2008 11:38:37 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005,2006 IBM Corporation and others. >+ * Copyright (c) 2005,2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -97,6 +97,9 @@ > private File tmpFile = null; > private static String prefix = "hgla"; > >+ protected String tmpFileName = null; >+ protected String tmpDirectory = null; >+ protected String tmpConverterCmd = null; > /** > * No-arguement constructor to create a SingleOSFileSensor. > */ >@@ -122,23 +125,11 @@ > super.stop(); > clean(); > } >+ > /** >- * Update the configuration based on the configuration Element. >- * >- * @see org.eclipse.hyades.logging.adapter.IComponent#update() >+ * Read the sensor configuration from the configuration element > */ >- /* (non-Javadoc) >- * @see org.eclipse.hyades.logging.adapter.impl.Sensor#update() >- */ >- public void update() throws AdapterInvalidConfig >- { >- // first get the basic configuration set >- super.update(); >- // maximumBlocking is set by the sensor config >- lastLine = new String[maximumBlocking]; >- String directory = null; >- String fileName = null; >- String converterCmdAttribute = null; >+ protected void readConfiguration() { > > Element sensorTypeInstance = null; > Element sensorNode; >@@ -147,11 +138,11 @@ > // Get the sensor parameters from the sensor properties > Hashtable sensorProperties = getProperties(); > if (sensorProperties != null && !sensorProperties.isEmpty()) { >- directory = (String)sensorProperties.get(AdapterXMLConstants.HyadesGAdirectoryAttributeName); >+ tmpDirectory = (String)sensorProperties.get(AdapterXMLConstants.HyadesGAdirectoryAttributeName); > >- fileName = (String)sensorProperties.get(AdapterXMLConstants.HyadesGAfileNameAttributeName); >+ tmpFileName = (String)sensorProperties.get(AdapterXMLConstants.HyadesGAfileNameAttributeName); > >- converterCmdAttribute = (String)sensorProperties.get(AdapterXMLConstants.HyadesGAconverterCmdAttributeName); >+ tmpConverterCmd = (String)sensorProperties.get(AdapterXMLConstants.HyadesGAconverterCmdAttributeName); > > converterShell = (String)sensorProperties.get(AdapterXMLConstants.HyadesGAconverterShellAttributeName); > >@@ -169,14 +160,14 @@ > // Get the sensor parameters from the sensor type instance attributes > sensorTypeInstance = sensorNode; > if (sensorTypeInstance.hasAttribute(AdapterXMLConstants.HyadesGAdirectoryAttributeName)) { >- directory = sensorTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAdirectoryAttributeName); >+ tmpDirectory = sensorTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAdirectoryAttributeName); > } > if (sensorTypeInstance.hasAttribute(AdapterXMLConstants.HyadesGAfileNameAttributeName)) { >- fileName = sensorTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAfileNameAttributeName); >+ tmpFileName = sensorTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAfileNameAttributeName); > } > > if (sensorTypeInstance.hasAttribute(AdapterXMLConstants.HyadesGAconverterCmdAttributeName)) { >- converterCmdAttribute = sensorTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAconverterCmdAttributeName); >+ tmpConverterCmd = sensorTypeInstance.getAttribute(AdapterXMLConstants.HyadesGAconverterCmdAttributeName); > } > > if (sensorTypeInstance.hasAttribute(AdapterXMLConstants.HyadesGAconverterShellAttributeName)) { >@@ -187,10 +178,10 @@ > } > } > >- if (converterCmdAttribute != null) { >- converterCmdAttribute = converterCmdAttribute.trim(); >- if (converterCmdAttribute.length() == 0) { >- converterCmdAttribute = null; >+ if (tmpConverterCmd != null) { >+ tmpConverterCmd = tmpConverterCmd.trim(); >+ if (tmpConverterCmd.length() == 0) { >+ tmpConverterCmd = null; > } > } > >@@ -200,9 +191,6 @@ > converterShell = null; > } > } >- >- filterExitClassInstance = getFilterExitClassInstance(); >- > > // Get the parent context so we can get the charset and > // continuous operation flag >@@ -217,17 +205,28 @@ > break; > } > } >+ } >+ >+ /** >+ * Process the values read from the configuration and perform other initialization >+ * @throws AdapterInvalidConfig >+ */ >+ protected void processConfiguration() throws AdapterInvalidConfig { > // Check if the directory and fileName properties are non null >- if (directory == null || directory.trim().length() == 0 || >- fileName == null || fileName.trim().length() == 0) { >+ if (tmpDirectory == null || tmpDirectory.trim().length() == 0 || >+ tmpFileName == null || tmpFileName.trim().length() == 0) { > throw new AdapterInvalidConfig(Messages.getString("HyadesGA_CBE_SingleFileSensor_Invalid_Config_File_ERROR_")); > } >+ >+ filterExitClassInstance = getFilterExitClassInstance(); > >+ // maximumBlocking is set by the sensor config >+ lastLine = new String[maximumBlocking]; > > /* Assume the fileName specified is a regular expression and try to > * use the MultipleFilesReader class. > */ >- mfr = new MultipleFilesReader(directory, fileName, tmpLog); >+ mfr = new MultipleFilesReader(tmpDirectory, tmpFileName, tmpLog); > mfr.init(); > > // If only one file matches the regex, use the original SingleOSFileSensor >@@ -246,19 +245,19 @@ > String fn = mfr.getNext(); > //We must have a vaild directory and fileName that exists on the local file system: > if (fn == null || fn.trim().length() == 0 || >- (converterCmdAttribute == null && !(new File(fn).canRead()))) { >+ (tmpConverterCmd == null && !(new File(fn).canRead()))) { > throw new AdapterInvalidConfig(Messages.getString("HyadesGA_CBE_SingleFileSensor_Invalid_Config_File_ERROR_")); > } > setFileName(new File(fn).getName()); // Because the name is fully-qualified > } > else { // no match at all > // If there was no converter command to generate the log file and the sensor is not running in a continuous context then throw an exception >- if (converterCmdAttribute == null && !continuousContext) { >+ if (tmpConverterCmd == null && !continuousContext) { > throw new AdapterInvalidConfig(Messages.getString("HyadesGA_CBE_SingleFileSensor_Invalid_Config_File_ERROR_")); > } > else { > // use the original file name, assuming the converter command will generate the file >- setFileName(fileName.trim()); >+ setFileName(tmpFileName.trim()); > } > } > } >@@ -282,8 +281,8 @@ > } > } > >- setDirectory(directory.trim()); >- setConverterCommand(converterCmdAttribute); >+ setDirectory(tmpDirectory.trim()); >+ setConverterCommand(tmpConverterCmd); > > CommonBaseEvent event = getEventFactory().createCommonBaseEvent(); > event.setMsg(Messages.getString("HyadesGASensor_SingleOSFileSensor_Configuration_INFO_",getFileName(), getDirectory(), getConverterCommand())); >@@ -301,6 +300,25 @@ > } > } > } >+ >+ /** >+ * Update the configuration based on the configuration Element. >+ * >+ * @see org.eclipse.hyades.logging.adapter.IComponent#update() >+ */ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.impl.Sensor#update() >+ */ >+ public void update() throws AdapterInvalidConfig >+ { >+ // first get the basic configuration set >+ super.update(); >+ >+ readConfiguration(); >+ >+ processConfiguration(); >+ >+ } > > /** > * simulates a getNext >Index: src/org/eclipse/hyades/logging/adapter/Adapter.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.adapter/src/org/eclipse/hyades/logging/adapter/Adapter.java,v >retrieving revision 1.13 >diff -u -r1.13 Adapter.java >--- src/org/eclipse/hyades/logging/adapter/Adapter.java 5 May 2007 05:22:22 -0000 1.13 >+++ src/org/eclipse/hyades/logging/adapter/Adapter.java 16 Jan 2008 11:38:36 -0000 >@@ -1,7 +1,5 @@ >-package org.eclipse.hyades.logging.adapter; >- > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -17,9 +15,13 @@ > * > **********************************************************************/ > >+package org.eclipse.hyades.logging.adapter; >+ > import org.eclipse.hyades.logging.adapter.impl.Status; >-import org.eclipse.hyades.logging.adapter.internal.util.Controller; > import org.eclipse.hyades.logging.adapter.parsers.PreparationException; >+import org.eclipse.hyades.logging.adapter.provisional.util.ControllerFactory; >+import org.eclipse.hyades.logging.adapter.provisional.util.IController; >+import org.eclipse.hyades.logging.adapter.provisional.util.IControllerFactory; > import org.eclipse.hyades.logging.adapter.util.AdapterConstants; > import org.eclipse.hyades.logging.adapter.util.Messages; > >@@ -54,7 +56,9 @@ > */ > public class Adapter { > >- private Controller rootController = null; >+ >+ private IControllerFactory controllerFactory; >+ private IController rootController = null; > private String contextFile = null; > private String componentFile = null; > // Adapter internal log outputter >@@ -66,7 +70,16 @@ > * Status object representing the status of this adapter instance. > */ > private Status status = new Status(); >- >+ >+ /** >+ * Adapter constructor >+ */ >+ public Adapter() { >+ super(); >+ // Create a controller factory >+ controllerFactory = new ControllerFactory(); >+ >+ } > /** > * Sets the path of the file containing the context configuration portion of the > * adapter configuration. This method must be called before the validate and start >@@ -138,7 +151,7 @@ > } > // Otherwise create a new controller and load the configuration from the adapter file to validate it. > else { >- rootController = new Controller(); >+ rootController = controllerFactory.getController(); > > if (componentFile == null) { > componentFile = AdapterConstants.HyadesGADefaultComponentConfigurationsFile; //$NON-NLS-1$ >@@ -206,7 +219,7 @@ > // Otherwise create a new controller and load the configuration from the adapter file. > else { > /* Get a new controller to run the adapter */ >- rootController = new Controller(); >+ rootController = controllerFactory.getController(); > > if (componentFile == null) { > componentFile = AdapterConstants.HyadesGADefaultComponentConfigurationsFile; //$NON-NLS-1$ >@@ -381,7 +394,7 @@ > } > } > else { >- rootController = new Controller(); >+ rootController = controllerFactory.getController(); > > if (componentFile == null) { > componentFile = AdapterConstants.HyadesGADefaultComponentConfigurationsFile; //$NON-NLS-1$ >Index: src/org/eclipse/hyades/logging/adapter/provisional/util/ControllerFactory.java >=================================================================== >RCS file: src/org/eclipse/hyades/logging/adapter/provisional/util/ControllerFactory.java >diff -N src/org/eclipse/hyades/logging/adapter/provisional/util/ControllerFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/logging/adapter/provisional/util/ControllerFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: Controller.java,v 1.9 2007/03/22 05:29:24 dnsmith Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ **********************************************************************/ >+ >+package org.eclipse.hyades.logging.adapter.provisional.util; >+ >+/** >+ * Implementation of an IControllerFactory that generates Controller instances >+ * >+ * @author smith >+ * >+ */ >+public class ControllerFactory implements IControllerFactory { >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.provisional.util.IControllerFactory#getController() >+ */ >+ public IController getController() { >+ // TODO Auto-generated method stub >+ return new Controller(); >+ } >+ >+} >Index: src/org/eclipse/hyades/logging/adapter/provisional/util/Controller.java >=================================================================== >RCS file: src/org/eclipse/hyades/logging/adapter/provisional/util/Controller.java >diff -N src/org/eclipse/hyades/logging/adapter/provisional/util/Controller.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/logging/adapter/provisional/util/Controller.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1158 @@ >+/********************************************************************** >+ * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: Controller.java,v 1.9 2007/03/22 05:29:24 dnsmith Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ * Change History: >+ * Bugzilla Description >+ * 79014 Improved error handling and message logging >+ * >+ **********************************************************************/ >+package org.eclipse.hyades.logging.adapter.provisional.util; >+ >+import java.io.FileInputStream; >+import java.io.FileNotFoundException; >+import java.io.IOException; >+import java.io.InputStream; >+import java.util.Iterator; >+import java.util.List; >+ >+import javax.xml.parsers.DocumentBuilderFactory; >+import javax.xml.parsers.ParserConfigurationException; >+ >+import org.eclipse.hyades.logging.adapter.AdapterException; >+import org.eclipse.hyades.logging.adapter.AdapterInvalidConfig; >+import org.eclipse.hyades.logging.adapter.AdapterPlugin; >+import org.eclipse.hyades.logging.adapter.IComponent; >+import org.eclipse.hyades.logging.adapter.IContext; >+import org.eclipse.hyades.logging.adapter.IContextListener; >+import org.eclipse.hyades.logging.adapter.IOutputter; >+import org.eclipse.hyades.logging.adapter.IProcessUnit; >+import org.eclipse.hyades.logging.adapter.impl.AdapterContext; >+import org.eclipse.hyades.logging.adapter.impl.AdapterXMLConstants; >+import org.eclipse.hyades.logging.adapter.impl.Component; >+import org.eclipse.hyades.logging.adapter.impl.Context; >+import org.eclipse.hyades.logging.adapter.impl.Status; >+import org.eclipse.hyades.logging.adapter.internal.util.AdapterConfigValidator; >+import org.eclipse.hyades.logging.adapter.internal.util.ComponentFactory; >+import org.eclipse.hyades.logging.adapter.internal.util.ContextFactory; >+import org.eclipse.hyades.logging.adapter.parsers.PreparationException; >+import org.eclipse.hyades.logging.adapter.util.AdapterConstants; >+import org.eclipse.hyades.logging.adapter.util.AdapterUtilities; >+import org.eclipse.hyades.logging.adapter.util.Messages; >+import org.w3c.dom.Document; >+import org.w3c.dom.Element; >+import org.w3c.dom.Node; >+import org.w3c.dom.NodeList; >+import org.xml.sax.SAXException; >+/** >+ * The TPTP implementation of the IController interface. >+ * >+ */ >+public class Controller implements IController { >+ >+ private boolean singleFileInputMode = false; >+ >+ /* Keep our contexts and their associated threads within a list. It is imperative that the index >+ * of each list be kept consistent. That is, the thread running context at index n must be in the >+ * thread list at index n >+ */ >+ private Context[] contexts; >+ private Thread[] contextThreads; >+ >+ // Adapter log outputter component >+ private IOutputter logOutputter = null; >+ >+ private String contextConfigurationFile = AdapterConstants.HyadesGADefaultContextConfigurationFile; >+ private String componentConfigurationFile = AdapterConstants.HyadesGADefaultComponentConfigurationsFile; >+ private DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); >+ private InputStream inContextParams = null; >+ private InputStream inAppParams = null; >+ private boolean running = false; >+ private long sleepTime = 500; >+ >+ // Overall logging level for the Adapter >+ private short loggingLevel = -1; >+ /** >+ * Constructor for Controller. >+ */ >+ public Controller() { >+ super(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#isRunning() >+ */ >+ public boolean isRunning() { >+ return running; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#start() >+ */ >+ public void start() { >+ /* RKD: We will run all of the contexts except the first one >+ * (our internal logging context), each in its own thread. >+ * The internal logging context was already started >+ * when we went through the prepare stage. >+ */ >+ synchronized(contexts) { >+ for (int i = 1; i < contextThreads.length; ++i) { >+ if (contexts[i] != null && !contexts[i].isDisabled()) { >+ contextThreads[i]=new Thread(contexts[i]); >+ contextThreads[i].setName(contexts[i].getName() + AdapterConstants.HyadesGA + contexts[i].getUniqueID()); >+ contextThreads[i].setDaemon(true); >+ contextThreads[i].start(); >+ } >+ } >+ } >+ running = true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#stop() >+ */ >+ public void stop() { >+ >+ if (contexts != null && contextThreads != null) { >+ synchronized(contexts) { >+ int contextStopCount = 0; >+ /* stop them in reverse order so that the logging context gets stopped last */ >+ for (int i=contexts.length-1; i>0; i--) { >+ /* bugzilla 74713 - set stopping flag instead of calling Context.stop() because >+ * we're running in a different thread than the context. Also, only stop the >+ * context if the context thread is still alive >+ */ >+ if (contexts[i] != null && contextThreads.length > i && contextThreads[i] != null && contextThreads[i].isAlive()) { >+ contexts[i].setStopping(true); >+ contextStopCount++; >+ } >+ } >+ /* If other contexts are stopping Then sleep before stopping >+ * the logging context to allow the other contexts >+ * to log messages and end. >+ * bugzilla 91218 - only sleep if there are contexts in the >+ * process of stopping. >+ */ >+ if (contextStopCount > 0) { >+ try { >+ Thread.sleep(1500); >+ } >+ catch (InterruptedException e) { >+ >+ } >+ } >+ // Stop the logging context. >+ if (contexts[0] != null && contextThreads.length > 0 && contextThreads[0] != null && contextThreads[0].isAlive()) { >+ contexts[0].setStopping(true); >+ // Wait until logging context is finished >+ while (contextThreads[0] != null && contextThreads[0].isAlive()) { >+ try { >+ Thread.sleep(200); >+ // System.out.println("Waited a fifth of a second for logging context to end"); >+ } >+ catch (InterruptedException e) { >+ >+ } >+ } >+ } >+ } >+ } >+ running = false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#hardStop() >+ */ >+ public void hardStop() { >+ synchronized(contexts) { >+ if (contexts != null && contextThreads != null) >+ /* stop them in reverse order so that the logging context gets stopped last */ >+ for (int i=contexts.length-1; i>=0; i--) { >+ /* bugzilla 74713 - set hard stop flag instead of calling Context.stop() because >+ * we're running in a different thread than the context. Also, only stop the >+ * context if the context thread is still alive >+ */ >+ if (contexts[i] != null && contextThreads.length > i && contextThreads[i] != null && contextThreads[i].isAlive()) { >+ // Set hardStop flag to stop the context >+ contexts[i].setHardStop(); >+ } >+ } >+ } >+ running = false; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#getContexts() >+ */ >+ public IContext[] getContexts() { >+ synchronized(contexts) { >+ // Ensure the contexts have been created >+ if (contexts == null || contexts.length <= 1) { >+ return null; >+ } >+ // Exclude the internal logging context >+ IContext newContextSet[] = new IContext[contexts.length-1]; >+ for (int i=1; i < contexts.length; i++) { >+ newContextSet[i-1] = contexts[i]; >+ } >+ return newContextSet; >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#setContextConfigPath(java.lang.String) >+ */ >+ public void setContextConfigPath(String config) { >+ contextConfigurationFile = config; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#getContextConfigPath() >+ */ >+ public String getContextConfigPath() { >+ return contextConfigurationFile; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#setComponentConfigPath(java.lang.String) >+ */ >+ public void setComponentConfigPath(String config) { >+ componentConfigurationFile = config; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#getComponentConfigPath() >+ */ >+ public String getComponentConfigPath() { >+ return componentConfigurationFile; >+ } >+ >+ /* >+ * Validates an adapter file against the schema files. >+ */ >+ private void validateAdapterConfigurations(InputStream inAppStream, IProcessUnit logger) throws AdapterInvalidConfig { >+ AdapterConfigValidator validator = new AdapterConfigValidator(logger); >+ try{ >+ validator.validate(inAppStream); >+ }catch(AdapterException e){ >+ log(e.toString()); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#prepareAdapter(boolean) >+ */ >+ public void prepareAdapter(boolean validating) throws AdapterException { >+ /* Open the context and configuration files */ >+ try { >+ inContextParams = new FileInputStream(contextConfigurationFile); >+ if (singleFileInputMode) { >+ inAppParams = new FileInputStream(contextConfigurationFile); >+ } >+ else { >+ inAppParams = new FileInputStream(componentConfigurationFile); >+ } >+ } >+ catch(FileNotFoundException e) { >+ String filename=null; >+ if(inContextParams==null) { >+ filename=contextConfigurationFile; >+ } >+ else { >+ filename=componentConfigurationFile; >+ try { >+ inContextParams.close(); >+ } >+ catch(IOException eprime) { >+ /* We will ignore if this fails. It should be successful as we just opened the file */ >+ } >+ } >+ /* We cannot open the adapter file */ >+ throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Open_ERROR_", filename)); >+ } >+ catch (Throwable e) { >+ String filename=null; >+ if(inContextParams==null) { >+ filename=contextConfigurationFile; >+ } >+ else { >+ filename=componentConfigurationFile; >+ try { >+ inContextParams.close(); >+ } >+ catch(IOException eprime) { >+ /* We will ignore if this fails. It should be successful as we just opened the file */ >+ } >+ } >+ /* We cannot open the adapter file */ >+ throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Open_ERROR_", filename),e); >+ } >+ >+ // build the contexts based on configurations >+ try { >+ contexts = createContextsAndComponents(inContextParams); >+ synchronized(contexts) { >+ setComponentConfigurations(inAppParams); >+ } >+ >+ /* We are done with the files. Lets close them */ >+ try { >+ inContextParams.close(); >+ if(!singleFileInputMode) { >+ inAppParams.close(); >+ } >+ } >+ catch(IOException e) { >+ /* We just had the file open. We are now closing it */ >+ } >+ >+ /* Before we start the contexts locate any IContextListeners that >+ * are registered with the plugin. This only works when we are running >+ * as a plugin inside of Eclipse. Outside of Eclipse there is no notion >+ * of IContextListeners. >+ */ >+ if (AdapterUtilities.isWorkbench()) { >+ try { >+ List contextListeners = AdapterPlugin.getContextListeners(); >+ >+ /* If this context has a listener then set it */ >+ if (contextListeners != null) { >+ Iterator listenerIterator = contextListeners.iterator(); >+ while (listenerIterator.hasNext()) { >+ IContextListener listener = (IContextListener) listenerIterator.next(); >+ String[] targetContexts = listener.getTargetContextUniqueIds(); >+ for (int j = 0; j < targetContexts.length; j++) { >+ for (int k = 0; k < contexts.length; k++) { >+ if (contexts[k].getUniqueID().equals(targetContexts[j])) { >+ contexts[k].setContextListener(listener); >+ } >+ } >+ } >+ } >+ } >+ } >+ catch (AdapterException e) { >+ throw e; >+ } >+ catch (Throwable e) { >+ throw new AdapterException(Messages.getString("HyadesGAInitialization_GetContextListeners_Failure_ERROR_"), e); >+ } >+ } >+ >+ /* Start the logging context in its entirty before we continue with anything else */ >+ IProcessUnit logger=startInternalLoggingContext(); >+ >+ /* Validate the adapter configuration file against the schema files before starting the rest of the contexts. >+ * It would have been good to have done this above, however, we want our internal logging context running so that we >+ * can report any errors during validation >+ */ >+ inAppParams = new FileInputStream(contextConfigurationFile); >+ validateAdapterConfigurations(inAppParams, logger); >+ >+ if (!singleFileInputMode) { >+ inAppParams = new FileInputStream(componentConfigurationFile); >+ validateAdapterConfigurations(inAppParams, logger); >+ } >+ >+ // Count the number of contexts that are initialized and ready to execute >+ int contextsReadyCount = 0; >+ AdapterException initException = null; >+ >+ synchronized(contexts) { >+ for (int i = 1; i < contexts.length; ++i) { >+ if (contexts[i] != null) { >+ >+ /* Set the logger for this context to be the internal logging sensor */ >+ contexts[i].setLogger(logger); >+ >+ /* Set the validating status for the context */ >+ contexts[i].setValidating(validating); >+ >+ /* bugzilla 96433 >+ * Set logging level of context and components if it needs to be globally set >+ * and it is not being validated. >+ */ >+ if (!validating && loggingLevel > -1) { >+ contexts[i].setLoggingLevel(loggingLevel); >+ IComponent comp[] = contexts[i].getComponents(); >+ for (int j=0; j<comp.length; j++) { >+ comp[j].setLoggingLevel(loggingLevel); >+ } >+ } >+ >+ // set all the context config info >+ if (!(contexts[i].init())) { >+ contexts[i]=null; >+ /* Make sure we log that this context will not be started */ >+ log(Messages.getString("HyadesGAContextFatal_ERROR_")); >+ continue; >+ } >+ // set all the component config info >+ >+ /* Setup the configuration information for this context. At this point in time the context >+ * may fail to initialize itself properly. If that is the case then this context should be >+ * disabled. >+ */ >+ try { >+ contexts[i].update(); >+ // Only increment context ready count if context is not disabled >+ if (!contexts[i].isDisabled()) { >+ contextsReadyCount++; >+ } >+ } >+ catch(AdapterException e) { >+ if (!validating) { >+ contexts[i]=null; >+ /* Make sure we log that this context will not be started */ >+ log(Messages.getString("HyadesGAContextFatal_ERROR_")); >+ } >+ initException = e; >+ } >+ } >+ } >+ } >+ // If there are no contexts ready to execute then quit! >+ if (contextsReadyCount == 0) { >+ if (initException != null) { >+ throw initException; >+ } >+ else { >+ throw new AdapterException(Messages.getString("HyadesGAContextFatal_ERROR_")); >+ } >+ } >+ } >+ catch(Throwable e) { >+ /* RKD: Our caller will need to use our exception information for now to handle the error.*/ >+ /* Don't log anything here. Assume the caller handles the exception and >+ * logs a message if necessary. >+ * log(Messages.getString("HyadesGAAdapterFatal_ERROR_")); >+ * log(e.toString()); >+ */ >+ if (e instanceof AdapterException) { >+ throw (AdapterException)e; >+ } >+ >+ // Wrap non-AdapterException in an AdapterException >+ String errorMsg = e.getMessage(); >+ if (errorMsg == null) { >+ errorMsg = e.toString(); >+ } >+ throw new AdapterException(errorMsg); >+ } >+ finally { >+ >+ /* Close our configuration file */ >+ try { >+ if (inAppParams != null) { >+ inAppParams.close(); >+ } >+ if (inContextParams != null) { >+ inContextParams.close(); >+ } >+ } >+ catch (IOException e) { >+ /* We couldn't close the configuration files. This should only occur if we failed to >+ * open the file in the first place. >+ */ >+ log(e.toString()); >+ } >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#prepareConfiguration(boolean) >+ */ >+ public void prepareConfiguration(boolean validating) throws AdapterException { >+ >+ try { >+ /* Start the logging context in its entirty before we continue with anything else */ >+ IProcessUnit logger=startInternalLoggingContext(); >+ >+ // Count the number of contexts that are initialized and ready to execute >+ int contextsReadyCount = 0; >+ AdapterException initException = null; >+ >+ synchronized(contexts) { >+ for (int i = 1; i < contexts.length; ++i) { >+ if (contexts[i] != null) { >+ >+ /* Set the logger for this context to be the internal logging sensor */ >+ contexts[i].setLogger(logger); >+ >+ /* Set the validating status for the context */ >+ contexts[i].setValidating(validating); >+ >+ /* bugzilla 96433 >+ * Set logging level of context and components if it needs to be globally set >+ * and it is not being validated. >+ */ >+ if (!validating && loggingLevel > -1) { >+ contexts[i].setLoggingLevel(loggingLevel); >+ IComponent comp[] = contexts[i].getComponents(); >+ for (int j=0; j<comp.length; j++) { >+ comp[j].setLoggingLevel(loggingLevel); >+ } >+ } >+ >+ // set all the context config info >+ if (!(contexts[i].init())) { >+ contexts[i]=null; >+ /* Make sure we log that this context will not be started */ >+ log(Messages.getString("HyadesGAContextFatal_ERROR_")); >+ continue; >+ } >+ // set all the component config info >+ >+ /* Setup the configuration information for this context. At this point in time the context >+ * may fail to initialize itself properly. If that is the case then this context should be >+ * disabled. >+ */ >+ try { >+ contexts[i].update(); >+ // Only increment context ready count if context is not disabled >+ if (!contexts[i].isDisabled()) { >+ contextsReadyCount++; >+ } >+ } >+ catch(AdapterException e) { >+ if (!validating) { >+ contexts[i]=null; >+ /* Make sure we log that this context will not be started */ >+ log(Messages.getString("HyadesGAContextFatal_ERROR_")); >+ } >+ initException = e; >+ } >+ } >+ } >+ } >+ // If there are no contexts ready to execute then quit! >+ if (contextsReadyCount == 0) { >+ if (initException != null) { >+ throw initException; >+ } >+ else { >+ throw new AdapterException(Messages.getString("HyadesGAContextFatal_ERROR_")); >+ } >+ } >+ } >+ catch(Throwable e) { >+ /* RKD: Our caller will need to use our exception information for now to handle the error.*/ >+ /* Don't log anything here. Assume the caller handles the exception and >+ * logs a message if necessary. >+ * log(Messages.getString("HyadesGAAdapterFatal_ERROR_")); >+ * log(e.toString()); >+ */ >+ if (e instanceof AdapterException) { >+ throw (AdapterException)e; >+ } >+ >+ // Wrap non-AdapterException in an AdapterException >+ String errorMsg = e.getMessage(); >+ if (errorMsg == null) { >+ errorMsg = e.toString(); >+ } >+ throw new AdapterException(errorMsg); >+ } >+ >+ } >+ >+ /** >+ * parses Context configurations and build the Context objects >+ * as well as set teh context config for each component >+ */ >+ private Context[] createContextsAndComponents(InputStream inContextStream) throws PreparationException { >+ >+ Document doc = null; >+ Context[] contexts = null; >+ try { >+ doc = docFactory.newDocumentBuilder().parse(inContextStream); >+ >+ //Add the adapter logging context as default: >+ Element loggingContext = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXT); >+ loggingContext.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Context instance for the current component"); >+ loggingContext.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.impl.AdapterContext"); >+ loggingContext.setAttribute(AdapterXMLConstants.HyadesGAImplementationCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >+ loggingContext.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "60"); >+ loggingContext.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, AdapterXMLConstants.HyadesGAAdapterContextName); >+ loggingContext.setAttribute(AdapterXMLConstants.HyadesGARoleAttributeName, "context"); >+ loggingContext.setAttribute(AdapterXMLConstants.HyadesGARoleCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >+ loggingContext.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "NB1F4ED002DA11D8A519FBE7C98C2F53"); >+ >+ Element loggingSensor = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_COMPONENT); >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Adapter logging sensor"); >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.internal.util.AdapterSensor"); >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGAImplementationCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >+ // bugzilla 84698 - If there is an outputter Then let WARNING or higher messages be logged. >+ if (logOutputter != null) { >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "30"); >+ } >+ // Otherwise let all messages be logged >+ else { >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "0"); >+ } >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "AdapterLogSensor"); >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGARoleAttributeName, "sensor"); >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGARoleCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >+ loggingSensor.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "NF991E0004FF11D8930381B6A308BEB5"); >+ >+ loggingContext.appendChild(loggingSensor); >+ >+ Element loggingOutputter = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_COMPONENT); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Adapter logging outputter"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationVersionAttributeName, ""); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationVersionDescriptionAttributeName, ""); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGARoleAttributeName, "outputter"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGARoleCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N5F286A002DA11D8BC799C6AF4352915"); >+ >+ // Add the outputter specified by the user (eg. set by StaticParserWrapper in the log import case) >+ if (logOutputter != null) { >+ //Set the logging level so we get Warning, Critical and Fatal error messages >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "30"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, logOutputter.getClass().getName()); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "AdapterLogOutputter"); >+ >+ /************************************************************************************************* >+ * bugzilla 79014 >+ * Comment this out because we should not need to log to a file in the log import >+ * case. GLA messages will be handled by the outputter set by the user. >+ * However, we'll keep the code here in case we find it necessar to log to a file as well. >+ * >+ * loggingContext.appendChild(loggingOutputter); >+ * >+ * // Create a file outputter too >+ * loggingOutputter = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_COMPONENT); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Adapter File logging outputter"); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationVersionAttributeName, ""); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAImplementationVersionDescriptionAttributeName, ""); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGARoleAttributeName, "outputter"); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGARoleCreationDateAttributeName, "Fri Jan 09 15:27:17 EST 2004"); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "AdapterFileLoggerId"); >+ * //Set the logging level so we get Warning, Critical and Fatal error messages >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "30"); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.internal.util.AdapterLogFileOutputter"); >+ * loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "AdapterLogFileOutputter"); >+ * >+ **************************************************************************************************/ >+ } >+ //Add the Eclipse Problems View outputter if in Eclipse mode. This is used when the context runs in the GLA editor. >+ else if (AdapterUtilities.isWorkbench()) { >+ //Set the logging level so we get any messages that are at least informational >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "10"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.internal.util.GlaTaskOutputter"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "CBEEclipseProblemsViewOutputter"); >+ } >+ //Add the log file outputter if in standalone mode: >+ else { >+ //Set the logging level so we get Warning, Critical and Fatal error messages >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGALoggingLevelAttributeName, "30"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName, "org.eclipse.hyades.logging.adapter.internal.util.AdapterLogFileOutputter"); >+ loggingOutputter.setAttribute(AdapterXMLConstants.HyadesGANameAttributeName, "AdapterLogFileOutputter"); >+ } >+ >+ loggingContext.appendChild(loggingOutputter); >+ >+ NodeList contextsNodeList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTS); >+ >+ if (contextsNodeList.getLength() == 0) { >+ >+ //Create a contexts element: >+ Element contextsElement = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTS); >+ >+ /* Insert the logging context at the first of the child list of elements */ >+ NodeList children=contextsElement.getChildNodes(); >+ for(int i=0; i<children.getLength(); i++) { >+ if(children.item(i).getNodeType()==Node.ELEMENT_NODE) { >+ contextsElement.insertBefore(loggingContext, children.item(i)); >+ break; >+ } >+ } >+ >+ doc.getDocumentElement().appendChild(contextsElement); >+ } >+ else { >+ >+ //ASSUMPTION: Only one contexts element permitted. >+ >+ //Retrieve the contexts element: >+ Node contextsElement = contextsNodeList.item(0); >+ /* Insert the logging context at the first of the child list of elements */ >+ NodeList children=contextsElement.getChildNodes(); >+ for(int i=0; i<children.getLength(); i++) { >+ if(children.item(i).getNodeType()==Node.ELEMENT_NODE) { >+ contextsElement.insertBefore(loggingContext, children.item(i)); >+ break; >+ } >+ } >+ >+ doc.getDocumentElement().appendChild(contextsElement); >+ } >+ >+ try { >+ NodeList contextList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXT); >+ // check to see if this file contains everything or just the context config >+ NodeList tempInstanceList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTINSTANCE); >+ if (tempInstanceList.getLength() > 0) >+ singleFileInputMode = true; >+ else >+ singleFileInputMode = false; >+ int count = contextList.getLength(); >+ contexts = new Context[count]; >+ int j = 0; >+ Element element = null; >+ Context context = null; >+ Component component = null; >+ >+ for (int i = 0; i < count; ++i) { >+ //TODO: HS need to support imbedded/nested contexts/components >+ // Extract each root context and copy the expected attributes >+ element = (Element) contextList.item(i); >+ /* try and build the context. A number of things can go wrong here as we use relection to build the instance. */ >+ context = ContextFactory.buildContext(element.getAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName), element.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName), element.getAttribute(AdapterXMLConstants.HyadesGANameAttributeName)); >+ context.setContextConfiguration(element); >+ >+ // >+ // get a list of all sub elements and assume they are components >+ NodeList componentList = element.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_COMPONENT); >+ IComponent[] compArray = null; >+ int componentCount = componentList.getLength(); >+ compArray = new IComponent[componentCount]; >+ for (int k = 0, l = 0; k < componentCount; k++) { >+ // Extract each component config >+ element = (Element) componentList.item(k); >+ >+ // Check if we have a log outputter object already and if so then use that >+ if (i == 0 && k ==1 && logOutputter != null) { >+ component = (Component)logOutputter; >+ component.setName(element.getAttribute(AdapterXMLConstants.HyadesGANameAttributeName)); >+ component.setUniqueID(element.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName)); >+ component.setExecutableClassName(element.getAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName)); >+ } >+ else { >+ component = ComponentFactory.buildComponent(element.getAttribute(AdapterXMLConstants.HyadesGAExecutableClassAttributeName), element.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName), element.getAttribute(AdapterXMLConstants.HyadesGANameAttributeName)); >+ } >+ component.setContextConfiguration(element); >+ compArray[l++] = component; >+ } >+ // put the components in the context >+ context.setComponents(compArray); >+ // put this context in the controller's array >+ contexts[j++] = context; >+ } >+ } >+ catch (PreparationException e) { >+ throw e; >+ } >+ catch (Exception e) { >+ throw new PreparationException(Messages.getString("HyadesGAInitialization_ContextConfiguration_Failure_ERROR_", contextConfigurationFile), e); >+ } >+ } >+ catch (SAXException e) { >+ /* We have a problem parsing the configuration file ABORT */ >+ throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", contextConfigurationFile), e); >+ } >+ catch (ParserConfigurationException e) { >+ throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", contextConfigurationFile), e); >+ } >+ catch (IOException e) { >+ throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", contextConfigurationFile), e); >+ } >+ return contexts; >+ } >+ >+ /** >+ * CreateContextsConfig takes in an entire component configurations file and >+ * separates out the context instances and gives each context the sub tree for itself and >+ * it's components. >+ */ >+ private void setComponentConfigurations(InputStream inAppStream) throws AdapterInvalidConfig, PreparationException { >+ >+ Document doc = null; >+ >+ try { >+ >+ doc = docFactory.newDocumentBuilder().parse(inAppStream); >+ >+ //Add the adapter internal logging context instance as default: >+ Element loggingSensorInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_SENSOR); >+ loggingSensorInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "An adapter CBE sensor"); >+ loggingSensorInstance.setAttribute(AdapterXMLConstants.HyadesGAmaximumBlockingAttributeName, "5"); >+ loggingSensorInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "NF991E0004FF11D8930381B6A308BEB5"); >+ >+ Element loggerContextInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTINSTANCE); >+ loggerContextInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Context instance for the current component"); >+ /* Configure the internal logging context to run forever or until the adatper is explicitly stopped */ >+ loggerContextInstance.setAttribute(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_CONTINUOUS_OPERATION, "true"); >+ loggerContextInstance.setAttribute(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_MAXIMUM_IDLE_TIME, "0"); >+ loggerContextInstance.setAttribute(AdapterXMLConstants.CONTEXTINSTANCE_ATTR_NAME_PAUSE_INTERVAL, "10"); >+ loggerContextInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "NB1F4ED002DA11D8A519FBE7C98C2F53"); >+ >+ loggerContextInstance.appendChild(loggingSensorInstance); >+ >+ // Configure the log outputter for the log import case >+ if (logOutputter != null) { >+ Element loggingOutputterInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_OUTPUTTER); >+ loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Adapter log outputter"); >+ loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N5F286A002DA11D8BC799C6AF4352915"); >+ >+ /* This outputter is created and configured by the user so there will not be any configuration properties for it. */ >+ >+ loggerContextInstance.appendChild(loggingOutputterInstance); >+ >+ /************************************************************************************************* >+ * bugzilla 79014 >+ * Comment this out because we should not need to log to a file in the log import >+ * case. GLA messages will be handled by the outputter set by the user. >+ * However, we'll keep the code here in case we find it necessary to log to a file as well. >+ * >+ * // Get the directory for the GLA log file >+ * String glaLogDirectory = "."; >+ * try { >+ * >+ * // Try to get the plugin's workspace directory (e.g. <workspace>/.metadata/plugins/org.eclipse.hyades.logging.adapter) >+ * >+ * Class platformClass = Class.forName("org.eclipse.core.runtime.Platform"); >+ * >+ * Method getPluginStateLocationMethod = platformClass.getMethod("getPluginStateLocation",new Class[]{Class.forName("org.eclipse.core.runtime.Plugin")}); >+ * >+ * Object iPathObject = getPluginStateLocationMethod.invoke(null,new Object[]{AdapterPlugin.getPlugin()}); >+ * >+ * Class iPathClass = iPathObject.getClass(); >+ * >+ * Method toOSStringMethod = iPathClass.getMethod("toOSString",null); >+ * >+ * glaLogDirectory = (String)(toOSStringMethod.invoke(iPathObject,null)); >+ * } >+ * catch (Exception e) { >+ * // Ignore this and use the current directory for the GLA log file >+ * } >+ * >+ * // Add the file logger component configuration >+ * loggingOutputterInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_OUTPUTTER); >+ * loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Single file outputter"); >+ * loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "AdapterFileLoggerId"); >+ * >+ * Element outputterProperty = doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >+ * outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, glaLogDirectory); >+ * outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName,AdapterXMLConstants.HyadesGAdirectoryAttributeName); >+ * loggingOutputterInstance.appendChild(outputterProperty); >+ * >+ * outputterProperty = doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >+ * outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, "hgla.log"); >+ * outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName,AdapterXMLConstants.HyadesGAfileNameAttributeName); >+ * loggingOutputterInstance.appendChild(outputterProperty); >+ * >+ * loggerContextInstance.appendChild(loggingOutputterInstance); >+ * >+ ************************************************************************************/ >+ } >+ // Configure the Problems View outputter for the GLA editor case >+ else if (AdapterUtilities.isWorkbench()) { >+ >+ Element loggingOutputterInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_OUTPUTTER); >+ loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Eclipse error dialog outputter"); >+ loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N5F286A002DA11D8BC799C6AF4352915"); >+ >+ /* RKD: We need to inform the outputter of the configuration path so it can create markers for the resource */ >+ Element resourcePathProperty=doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >+ resourcePathProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName, "resourceName"); >+ resourcePathProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, contextConfigurationFile); >+ >+ loggingOutputterInstance.appendChild(resourcePathProperty); >+ loggerContextInstance.appendChild(loggingOutputterInstance); >+ } >+ else{ >+ >+ Element loggingOutputterInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_OUTPUTTER); >+ loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "Single file outputter"); >+ loggingOutputterInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N5F286A002DA11D8BC799C6AF4352915"); >+ >+ Element outputterProperty = doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >+ outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, "."); >+ outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName,AdapterXMLConstants.HyadesGAdirectoryAttributeName); >+ loggingOutputterInstance.appendChild(outputterProperty); >+ >+ outputterProperty = doc.createElement(AdapterXMLConstants.HyadesGAPropertyElementTagName); >+ outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyValueAttributeName, "hgla.log"); >+ outputterProperty.setAttribute(AdapterXMLConstants.HyadesGAPropertyNameAttributeName,AdapterXMLConstants.HyadesGAfileNameAttributeName); >+ loggingOutputterInstance.appendChild(outputterProperty); >+ >+ loggerContextInstance.appendChild(loggingOutputterInstance); >+ } >+ >+ NodeList configurationNodeList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONFIGURATION); >+ >+ if (configurationNodeList.getLength() == 0) { >+ >+ //Create a configuration element: >+ Element loggerConfigurationInstance = doc.createElement(AdapterXMLConstants.ELEMENT_TAG_NAME_CONFIGURATION); >+ loggerConfigurationInstance.setAttribute(AdapterXMLConstants.HyadesGADescriptionAttributeName, "The component level configurations for this adapter"); >+ loggerConfigurationInstance.setAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName, "N06FBD3004FF11D8BCF4CFA9EA8F31E7"); >+ >+ loggerConfigurationInstance.appendChild(loggerContextInstance); >+ >+ doc.getDocumentElement().appendChild(loggerConfigurationInstance); >+ } >+ else { >+ >+ //ASSUMPTION: Only one configuration element permitted. >+ >+ //Retrieve the configuration element: >+ Node loggerConfigurationInstance = configurationNodeList.item(0); >+ loggerConfigurationInstance.appendChild(loggerContextInstance); >+ >+ doc.getDocumentElement().appendChild(loggerConfigurationInstance); >+ } >+ >+ try { >+ // get a list of all the context instances and associates each with a context >+ NodeList contextInstanceList = doc.getElementsByTagName(AdapterXMLConstants.ELEMENT_TAG_NAME_CONTEXTINSTANCE); >+ >+ int contextInstanceCount = contextInstanceList.getLength(); >+ for (int i = 0; i < contextInstanceCount; ++i) { >+ try { >+ //find the matching Context and Context Instance >+ Element contextElement = (Element) contextInstanceList.item(i); >+ String contextInstanceID = contextElement.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName); >+ >+ int contextCount = contexts.length; >+ /* Throw an exception if we have a mismatch in the number of Context's and >+ * the number of ContextInstance's. >+ */ >+ if (contextInstanceCount != contextCount) { >+ throw new AdapterInvalidConfig(Messages.getString("HyadesGAContextConfigurationErrorContextCountMismatchFatal_ERROR_")); >+ } >+ >+ boolean contextFound = false; >+ for (int j = 0; j < contextCount; j++) { >+ if (contexts[j].getUniqueID().equals(contextInstanceID)) { >+ contexts[j].setConfiguration(contextElement); >+ contextFound = true; >+ // so now we have a good context which may or may not have components >+ //assume each child of the contextInstance is a component >+ NodeList componentInstanceList = contextElement.getChildNodes(); >+ int numberOfComponentInstances = componentInstanceList.getLength(); >+ // get the components from the context >+ IComponent components[] = contexts[j].getComponents(); >+ int componentCount = components.length; >+ >+ int componentInstanceCount = 0; >+ for (int k = 0; k < numberOfComponentInstances; k++) { >+ if (componentInstanceList.item(k).getNodeType() == Node.ELEMENT_NODE) { >+ Element componentElement = (Element) componentInstanceList.item(k); >+ String componentInstanceID = componentElement.getAttribute(AdapterXMLConstants.HyadesGAUniqueIDAttributeName); >+ boolean componentFound = false; >+ componentInstanceCount++; >+ // walk through the components of the context and set the config >+ for (int l = 0; l < componentCount; l++) { >+ if (components[l].getUniqueID().equals(componentInstanceID)) { >+ components[l].setConfiguration(componentElement); >+ componentFound = true; >+ /* bugzilla 82193 >+ * If this is a formatter and we are running in the GLA editor >+ */ >+ if (componentElement.getNodeName().equals(AdapterXMLConstants.ELEMENT_TAG_NAME_FORMATTER) && >+ logOutputter == null && AdapterUtilities.isWorkbench()) { >+ /* Add the test attribute to the formatter element to indicate we are running >+ * in the GLA editor environment. >+ */ >+ componentElement.setAttribute(AdapterConstants.AttrubuteName_Test,AdapterConstants.AttrubuteValue_Test_True); >+ } >+ break; >+ } >+ } >+ if (!componentFound) { >+ throw new AdapterInvalidConfig(Messages.getString("HyadesGAContextInstanceConfigurationErrorComponentIdNotFoundFatal_ERROR_",componentInstanceID , contexts[j].getUniqueID())); >+ } >+ } >+ } >+ /* Throw an exception if we have a mismatch in number of components between >+ * the context and the contextInstance. >+ */ >+ if (componentInstanceCount != componentCount) { >+ throw new AdapterInvalidConfig(Messages.getString("HyadesGAContextInstanceConfigurationErrorComponentMismatchFatal_ERROR_",contexts[j].getUniqueID())); >+ } >+ break; >+ } >+ } >+ if (!contextFound) { >+ throw new AdapterInvalidConfig(Messages.getString("HyadesGAContextInstanceConfigurationErrorContextIdNotFoundFatal_ERROR_", contextInstanceID)); >+ } >+ } >+ catch (AdapterInvalidConfig e) { >+ throw e; >+ } >+ catch (Exception e) { >+ throw new PreparationException(Messages.getString("HyadesGAInitialization_ContextInstanceConfiguration_Failure_ERROR_", componentConfigurationFile), e); >+ } >+ } >+ } >+ catch (AdapterInvalidConfig e) { >+ throw e; >+ } >+ catch (Exception e) { >+ throw new PreparationException(Messages.getString("HyadesGAInitialization_ContextInstanceConfiguration_Failure_ERROR_", componentConfigurationFile), e); >+ } >+ } >+ catch (SAXException e) { >+ /* We have a problem parsing the configuration file ABORT */ >+ throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", componentConfigurationFile), e); >+ } >+ catch (ParserConfigurationException e) { >+ throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", componentConfigurationFile), e); >+ } >+ catch (IOException e) { >+ throw new PreparationException(Messages.getString("HyadesGA_CBE_Adapter_Config_File_Parse_ERROR_", componentConfigurationFile), e); >+ } >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#run() >+ */ >+ public void run() { >+ start(); >+ while (isRunning()) { >+ synchronized (this) { >+ try { >+ wait(sleepTime); >+ } >+ catch (Exception e) { >+ log(e.toString()); >+ } >+ if (areContextsDone()) { >+ // Stop the Adapter logging context >+ stop(); >+ } >+ } >+ } >+ } >+ /** >+ * return false if any context is still alive, otherwise return true >+ */ >+ private boolean areContextsDone() { >+ if (contextThreads != null) { >+ /* Ignore the internal logging context. hense we start at index 1 */ >+ for (int i = 1; i < contextThreads.length; i++) { >+ if (contextThreads[i] != null) { >+ if (contextThreads[i].isAlive() && !(contexts[i] instanceof AdapterContext)) >+ return false; >+ } >+ } >+ } >+ return true; >+ } >+ >+ /** >+ * clean a controller by nulling out everything >+ */ >+ private void clean() { >+ if (contexts != null) { >+ for (int i = 0; i < contexts.length; i++) { >+ contexts[i] = null; >+ } >+ } >+ contexts = null; >+ // hashContextConfig.clear(); >+ } >+ >+ /** >+ * Starts the internal logging context. >+ * >+ */ >+ private IProcessUnit startInternalLoggingContext() { >+ contexts[0].init(); >+ contextThreads=new Thread[contexts.length]; >+ try { >+ contexts[0].update(); >+ // bugzilla 96433 - Reset the logging context status >+ contexts[0].setStopping(false); >+ contextThreads[0]=new Thread(contexts[0]); >+ contextThreads[0].setName(contexts[0].getName() + AdapterConstants.HyadesGA + contexts[0].getUniqueID()); >+ contextThreads[0].setDaemon(true); >+ contextThreads[0].start(); >+ return (IProcessUnit)contexts[0].getComponents()[0]; >+ >+ } >+ catch(AdapterException e) { >+ /* Since we are generating the context content we should not have configuration problems */ >+ /* However, we may get an exception here if the GLA logging cannot be initialized. */ >+ log(Messages.getString("HyadesGAInitialization_Internal_Logging_Not_Started_WARN_", e.getLocalizedMessage())); >+ } >+ catch(Exception e) { >+ /* Catch any other kind of exception and log a message */ >+ log(Messages.getString("HyadesGAInitialization_Internal_Logging_Not_Started_WARN_", e.toString())); >+ } >+ return null; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#log(java.lang.String) >+ */ >+ public void log(String logRecord) { >+ if(!AdapterUtilities.isWorkbench()) { >+ System.err.println(logRecord); >+ } >+ >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#getStatus() >+ */ >+ public Status [] getStatus() { >+ Status [] statuses = null; >+ >+ /* If there are context then get their status */ >+ if (contexts != null) { >+ synchronized(contexts) { >+ statuses = new Status[contexts.length]; >+ /* get the status for each context */ >+ for (int i=0; i < contexts.length; i++) { >+ if (contexts[i] != null) { >+ statuses[i] = contexts[i].getContextStatus(); >+ } >+ else { >+ statuses[i] = null; >+ } >+ } >+ } >+ } >+ >+ return statuses; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#getLogOutputter() >+ */ >+ public IOutputter getLogOutputter() { >+ return logOutputter; >+ } >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#setLogOutputter(org.eclipse.hyades.logging.adapter.IOutputter) >+ */ >+ public void setLogOutputter(IOutputter logOutputter) { >+ this.logOutputter = logOutputter; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#setLoggingLevel(short) >+ */ >+ public void setLoggingLevel(short newLevel) >+ { >+ loggingLevel = newLevel; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.hyades.logging.adapter.internal.util.IController#getLoggingLevel() >+ */ >+ public short getLoggingLevel() { >+ return loggingLevel; >+ } >+} >Index: src/org/eclipse/hyades/logging/adapter/provisional/util/IController.java >=================================================================== >RCS file: src/org/eclipse/hyades/logging/adapter/provisional/util/IController.java >diff -N src/org/eclipse/hyades/logging/adapter/provisional/util/IController.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/logging/adapter/provisional/util/IController.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,150 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: Controller.java,v 1.9 2007/03/22 05:29:24 dnsmith Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ **********************************************************************/ >+ >+package org.eclipse.hyades.logging.adapter.provisional.util; >+ >+import org.eclipse.hyades.logging.adapter.AdapterException; >+import org.eclipse.hyades.logging.adapter.IContext; >+import org.eclipse.hyades.logging.adapter.IOutputter; >+import org.eclipse.hyades.logging.adapter.impl.Status; >+ >+/** >+ * This interface represents a Controller that manages a set of Context >+ * objects by setting the configurations and then starting each context. >+ * >+ * @author dnsmith >+ */ >+ >+public interface IController extends Runnable { >+ >+ /** >+ * Returns whether the Controller is running. >+ * @return true if Controller is running, false otherwise >+ */ >+ public boolean isRunning(); >+ >+ /** >+ * Start running the controller which means starting up each of the contexts. >+ */ >+ public void start(); >+ >+ /** >+ * Stop the controller which means stopping all of the contexts if they >+ * are still running. >+ */ >+ public void stop(); >+ >+ /** >+ * This stop method will still cause the contexts to be stopped but will >+ * not call the context listener methods when flushing the components. >+ */ >+ public void hardStop(); >+ >+ /** >+ * Get the set of Context objects >+ * @return the set of Context objects >+ */ >+ public IContext[] getContexts(); >+ >+ /** >+ * Set the name of the file containing the configurations for the >+ * contexts. >+ * @param config - name of the context configuation file >+ */ >+ public void setContextConfigPath(String config); >+ >+ /** >+ * Get the name of the file containing the configurations for the contexts >+ * @return the contextConfigurationFile >+ */ >+ public String getContextConfigPath(); >+ >+ /** >+ * Set the name of the file containing the configurations for the >+ * components of the contexts. >+ * @param config - name of the component configuation file >+ */ >+ public void setComponentConfigPath(String config); >+ >+ /** >+ * Get the name of the file containing the configurations for the components of the contexts. >+ * @return the componentConfigurationFile >+ */ >+ public String getComponentConfigPath(); >+ >+ /** >+ * Prepare the adapter for execution. This involves reading and validating the adapter >+ * configuration file(s), getting the context listeners from eclipse, starting the internal >+ * logging context, and initializing the contexts. >+ * @param validating boolean flag to indicate this method is called as part of adapter validation >+ */ >+ public void prepareAdapter(boolean validating) throws AdapterException; >+ >+ /** >+ * Prepare the adapter configuration for execution. This involves >+ * starting the internal logging context, and initializing the contexts. >+ * @param validating boolean flag to indicate this method is called as part of adapter validation >+ */ >+ public void prepareConfiguration(boolean validating) >+ throws AdapterException; >+ >+ /** >+ * run provides the basic loop for a Controller thread. It starts the Controller thread and >+ * then monitors it. >+ >+ public void run(); >+ */ >+ /** >+ * Log the string message to standard error since the logging outputter(s) >+ * associated with the <code>AdapterSensor</code> logger will never be >+ * started. >+ * >+ * @param logRecord The string message to be logged to standard error. >+ */ >+ public void log(String logRecord); >+ >+ /** >+ * Get the status of the contexts >+ * @return the array of Status objects representing the status of the contexts >+ */ >+ public Status[] getStatus(); >+ >+ /** >+ * Get the custom Outputter that the internal logging context is using. >+ * @return Returns the custom Outputter that the internal logging context is using. >+ */ >+ public IOutputter getLogOutputter(); >+ >+ /** >+ * Sets the custom Outputter for the internal logging context to use. >+ * @param logOutputter The custom Outputter for the internal logging context. >+ */ >+ public void setLogOutputter(IOutputter logOutputter); >+ >+ /** >+ * Sets the loggingLevel of the Adapter object. This value will override >+ * all values in the adapter configuration. The logging level value specified will >+ * take effect the next time the Adapter is started. If this method is >+ * not called or is called with a value of -1, the logging levels specified in the >+ * adapter configuration will be used. >+ * @param newLevel The level of logging that the Adapter will use during execution >+ */ >+ public void setLoggingLevel(short newLevel); >+ >+ /** >+ * Get the logging level of the Adapter object. >+ * @return the level of logging the Adapter is currently using >+ */ >+ public short getLoggingLevel(); >+ >+} >Index: src/org/eclipse/hyades/logging/adapter/provisional/util/IControllerFactory.java >=================================================================== >RCS file: src/org/eclipse/hyades/logging/adapter/provisional/util/IControllerFactory.java >diff -N src/org/eclipse/hyades/logging/adapter/provisional/util/IControllerFactory.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/hyades/logging/adapter/provisional/util/IControllerFactory.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,30 @@ >+/********************************************************************** >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * $Id: Controller.java,v 1.9 2007/03/22 05:29:24 dnsmith Exp $ >+ * >+ * Contributors: >+ * IBM - Initial API and implementation >+ * >+ **********************************************************************/ >+ >+package org.eclipse.hyades.logging.adapter.provisional.util; >+ >+/** >+ * This interface represents a factory to create IController instances. >+ * >+ * @author dnsmith >+ * >+ */ >+public interface IControllerFactory { >+ >+ /** >+ * Gets an instance of an IController class >+ * @return IController instance >+ */ >+ public IController getController(); >+ >+} >#P org.eclipse.tptp.monitoring.la.core >Index: cbe.import/org/eclipse/tptp/monitoring/log/internal/core/RemoteImportHandler.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.la.core/cbe.import/org/eclipse/tptp/monitoring/log/internal/core/RemoteImportHandler.java,v >retrieving revision 1.18 >diff -u -r1.18 RemoteImportHandler.java >--- cbe.import/org/eclipse/tptp/monitoring/log/internal/core/RemoteImportHandler.java 27 Nov 2007 04:57:28 -0000 1.18 >+++ cbe.import/org/eclipse/tptp/monitoring/log/internal/core/RemoteImportHandler.java 16 Jan 2008 11:38:39 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -44,7 +44,7 @@ > import org.eclipse.hyades.logging.parsers.LoggingParsersPlugin; > import org.eclipse.hyades.logging.parsers.importer.ILogParser; > import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; >-import org.eclipse.hyades.logging.parsers.internal.importer.LocalLogImportLoader; >+import org.eclipse.hyades.logging.parsers.provisional.importer.LocalLogImportLoader; > import org.eclipse.hyades.models.hierarchy.TRCAgent; > import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; > import org.eclipse.hyades.models.hierarchy.TRCProcessProxy; >Index: cbe.import/org/eclipse/tptp/monitoring/log/internal/core/ImportLogHelper.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.la.core/cbe.import/org/eclipse/tptp/monitoring/log/internal/core/ImportLogHelper.java,v >retrieving revision 1.5 >diff -u -r1.5 ImportLogHelper.java >--- cbe.import/org/eclipse/tptp/monitoring/log/internal/core/ImportLogHelper.java 21 Mar 2007 21:30:15 -0000 1.5 >+++ cbe.import/org/eclipse/tptp/monitoring/log/internal/core/ImportLogHelper.java 16 Jan 2008 11:38:39 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005,2007 IBM Corporation and others. >+ * Copyright (c) 2005,2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -46,7 +46,7 @@ > import org.eclipse.hyades.logging.parsers.adapter.sensors.StaticParserSensor; > import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; > import org.eclipse.hyades.logging.parsers.internal.adapter.outputters.CBEtoCSVOutputter; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLAHelper; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLAHelper; > import org.eclipse.hyades.models.hierarchy.TRCAgent; > import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; > import org.eclipse.hyades.models.hierarchy.util.IHyadesResourceExtension; >Index: cbe.import/org/eclipse/tptp/monitoring/log/internal/core/AbstractImportHandler.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.la.core/cbe.import/org/eclipse/tptp/monitoring/log/internal/core/AbstractImportHandler.java,v >retrieving revision 1.3 >diff -u -r1.3 AbstractImportHandler.java >--- cbe.import/org/eclipse/tptp/monitoring/log/internal/core/AbstractImportHandler.java 1 Mar 2007 17:13:15 -0000 1.3 >+++ cbe.import/org/eclipse/tptp/monitoring/log/internal/core/AbstractImportHandler.java 16 Jan 2008 11:38:38 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -17,7 +17,7 @@ > import java.util.Map; > > import org.eclipse.core.runtime.IStatus; >-import org.eclipse.hyades.logging.parsers.internal.importer.LocalLogImportLoader; >+import org.eclipse.hyades.logging.parsers.provisional.importer.LocalLogImportLoader; > import org.eclipse.hyades.models.hierarchy.util.ISessionManager; > import org.eclipse.hyades.models.hierarchy.util.internal.SessionManagerWrapper; > import org.eclipse.tptp.monitoring.log.provisional.cbeimport.IErrorHandler; >Index: cbe.import/org/eclipse/tptp/monitoring/log/internal/core/AbstractLocalImportHandler.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.la.core/cbe.import/org/eclipse/tptp/monitoring/log/internal/core/AbstractLocalImportHandler.java,v >retrieving revision 1.11 >diff -u -r1.11 AbstractLocalImportHandler.java >--- cbe.import/org/eclipse/tptp/monitoring/log/internal/core/AbstractLocalImportHandler.java 1 Mar 2007 17:13:15 -0000 1.11 >+++ cbe.import/org/eclipse/tptp/monitoring/log/internal/core/AbstractLocalImportHandler.java 16 Jan 2008 11:38:38 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -29,8 +29,8 @@ > import org.eclipse.hyades.logging.parsers.internal.adapter.formatters.LocalLogImportCBEFormatter; > import org.eclipse.hyades.logging.parsers.internal.adapter.outputters.CBEtoCSVOutputter; > import org.eclipse.hyades.logging.parsers.internal.adapter.outputters.CBEtoMemoryOutputter; >-import org.eclipse.hyades.logging.parsers.internal.importer.LocalLogImportLoader; >-import org.eclipse.hyades.logging.parsers.internal.importer.LocalLogParserLoader; >+import org.eclipse.hyades.logging.parsers.provisional.importer.LocalLogImportLoader; >+import org.eclipse.hyades.logging.parsers.provisional.importer.LocalLogParserLoader; > import org.eclipse.hyades.models.hierarchy.TRCAgent; > import org.eclipse.hyades.models.hierarchy.util.IHyadesResourceExtension; > import org.eclipse.hyades.models.hierarchy.util.ISessionManager; >Index: cbe.import/org/eclipse/tptp/monitoring/log/internal/core/GLAFilterHelper.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.la.core/cbe.import/org/eclipse/tptp/monitoring/log/internal/core/GLAFilterHelper.java,v >retrieving revision 1.9 >diff -u -r1.9 GLAFilterHelper.java >--- cbe.import/org/eclipse/tptp/monitoring/log/internal/core/GLAFilterHelper.java 21 Mar 2007 21:30:14 -0000 1.9 >+++ cbe.import/org/eclipse/tptp/monitoring/log/internal/core/GLAFilterHelper.java 16 Jan 2008 11:38:38 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -69,7 +69,7 @@ > import org.eclipse.hyades.logging.events.cbe.EventPackage; > import org.eclipse.hyades.logging.parsers.LoggingParsersPlugin; > import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLAHelper; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLAHelper; > import org.eclipse.hyades.models.cbe.CBEPackage; > import org.eclipse.hyades.models.hierarchy.TRCAgent; > import org.eclipse.hyades.models.hierarchy.extensions.BinaryExpression; >Index: cbe.import/org/eclipse/tptp/monitoring/log/internal/core/LocalDownloadImportHandler.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.la.core/cbe.import/org/eclipse/tptp/monitoring/log/internal/core/LocalDownloadImportHandler.java,v >retrieving revision 1.5 >diff -u -r1.5 LocalDownloadImportHandler.java >--- cbe.import/org/eclipse/tptp/monitoring/log/internal/core/LocalDownloadImportHandler.java 30 Nov 2007 04:51:15 -0000 1.5 >+++ cbe.import/org/eclipse/tptp/monitoring/log/internal/core/LocalDownloadImportHandler.java 16 Jan 2008 11:38:39 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -31,7 +31,7 @@ > import org.eclipse.core.runtime.Status; > import org.eclipse.hyades.execution.local.CommunicationDebug; > import org.eclipse.hyades.logging.parsers.LoggingParsersPlugin; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLAHelper; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLAHelper; > import org.eclipse.hyades.ui.internal.util.StringUtil; > import org.eclipse.tptp.monitoring.log.provisional.cbeimport.IImportHandler; > import org.eclipse.tptp.monitoring.log.provisional.cbeimport.ILogFileElement; >Index: cbe.import/org/eclipse/tptp/monitoring/log/internal/core/LocalImportHandler.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.la.core/cbe.import/org/eclipse/tptp/monitoring/log/internal/core/LocalImportHandler.java,v >retrieving revision 1.7 >diff -u -r1.7 LocalImportHandler.java >--- cbe.import/org/eclipse/tptp/monitoring/log/internal/core/LocalImportHandler.java 1 Mar 2007 17:13:15 -0000 1.7 >+++ cbe.import/org/eclipse/tptp/monitoring/log/internal/core/LocalImportHandler.java 16 Jan 2008 11:38:39 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -25,7 +25,7 @@ > import org.eclipse.core.runtime.Status; > import org.eclipse.hyades.loaders.util.LoadersUtils; > import org.eclipse.hyades.logging.parsers.LoggingParsersPlugin; >-import org.eclipse.hyades.logging.parsers.internal.importer.LocalGLALogger; >+import org.eclipse.hyades.logging.parsers.provisional.importer.LocalGLALogger; > import org.eclipse.hyades.models.hierarchy.util.MonitoredInputStream; > import org.eclipse.hyades.models.util.ModelDebugger; > import org.eclipse.osgi.util.NLS; >#P org.eclipse.tptp.monitoring.logui >Index: src/org/eclipse/tptp/monitoring/logui/internal/wizards/LogSetManager.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.logui/src/org/eclipse/tptp/monitoring/logui/internal/wizards/LogSetManager.java,v >retrieving revision 1.18 >diff -u -r1.18 LogSetManager.java >--- src/org/eclipse/tptp/monitoring/logui/internal/wizards/LogSetManager.java 16 Jan 2008 06:38:24 -0000 1.18 >+++ src/org/eclipse/tptp/monitoring/logui/internal/wizards/LogSetManager.java 16 Jan 2008 11:38:43 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >Index: src/org/eclipse/tptp/monitoring/logui/internal/wizards/LocalLogParserLoader.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.logui/src/org/eclipse/tptp/monitoring/logui/internal/wizards/LocalLogParserLoader.java,v >retrieving revision 1.10 >diff -u -r1.10 LocalLogParserLoader.java >--- src/org/eclipse/tptp/monitoring/logui/internal/wizards/LocalLogParserLoader.java 27 Apr 2007 07:49:13 -0000 1.10 >+++ src/org/eclipse/tptp/monitoring/logui/internal/wizards/LocalLogParserLoader.java 16 Jan 2008 11:38:43 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -19,11 +19,11 @@ > import org.eclipse.hyades.logging.events.cbe.util.EventFormatter; > import org.eclipse.hyades.logging.events.cbe.util.EventHelpers; > import org.eclipse.hyades.logging.parsers.importer.ILogParser; >-import org.eclipse.hyades.logging.parsers.internal.importer.LocalLogImportLoader; >+import org.eclipse.hyades.logging.parsers.provisional.importer.LocalLogImportLoader; > > /** > * >- * @deprecated since TPTP 4.4 - this class was moved to org.eclipse.hyades.logging.parsers.internal.importer >+ * @deprecated since TPTP 4.4 - this class was moved to org.eclipse.hyades.logging.parsers.provisional.importer > * package in TPTP 4.3. > * > */ >Index: src/org/eclipse/tptp/monitoring/logui/internal/wizards/LocalGLALogger.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.logui/src/org/eclipse/tptp/monitoring/logui/internal/wizards/LocalGLALogger.java,v >retrieving revision 1.5 >diff -u -r1.5 LocalGLALogger.java >--- src/org/eclipse/tptp/monitoring/logui/internal/wizards/LocalGLALogger.java 27 Apr 2007 07:49:13 -0000 1.5 >+++ src/org/eclipse/tptp/monitoring/logui/internal/wizards/LocalGLALogger.java 16 Jan 2008 11:38:43 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -20,7 +20,7 @@ > > /** > * >- * @deprecated since TPTP 4.4 - this class was moved to org.eclipse.hyades.logging.parsers.internal.importer >+ * @deprecated since TPTP 4.4 - this class was moved to org.eclipse.hyades.logging.parsers.provisional.importer > * package in TPTP 4.3. > * > */ >Index: src/org/eclipse/tptp/monitoring/logui/internal/wizards/ImportLogWizard.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.logui/src/org/eclipse/tptp/monitoring/logui/internal/wizards/ImportLogWizard.java,v >retrieving revision 1.111 >diff -u -r1.111 ImportLogWizard.java >--- src/org/eclipse/tptp/monitoring/logui/internal/wizards/ImportLogWizard.java 16 Jan 2008 06:38:23 -0000 1.111 >+++ src/org/eclipse/tptp/monitoring/logui/internal/wizards/ImportLogWizard.java 16 Jan 2008 11:38:43 -0000 >@@ -54,7 +54,7 @@ > import org.eclipse.hyades.loaders.util.LoadersUtils; > import org.eclipse.hyades.logging.parsers.importer.ILogParser; > import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLAHelper; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLAHelper; > import org.eclipse.hyades.models.hierarchy.CorrelationContainerProxy; > import org.eclipse.hyades.models.hierarchy.TRCAgent; > import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; >Index: src/org/eclipse/tptp/monitoring/logui/internal/util/ImportLogHelper.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.logui/src/org/eclipse/tptp/monitoring/logui/internal/util/ImportLogHelper.java,v >retrieving revision 1.13 >diff -u -r1.13 ImportLogHelper.java >--- src/org/eclipse/tptp/monitoring/logui/internal/util/ImportLogHelper.java 22 Mar 2007 22:37:30 -0000 1.13 >+++ src/org/eclipse/tptp/monitoring/logui/internal/util/ImportLogHelper.java 16 Jan 2008 11:38:41 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2007 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -43,7 +43,7 @@ > import org.eclipse.hyades.logging.parsers.adapter.sensors.StaticParserSensor; > import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; > import org.eclipse.hyades.logging.parsers.internal.adapter.outputters.CBEtoCSVOutputter; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLAHelper; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLAHelper; > import org.eclipse.hyades.models.hierarchy.TRCAgent; > import org.eclipse.hyades.models.hierarchy.TRCAgentProxy; > import org.eclipse.hyades.models.hierarchy.util.IHyadesResourceExtension; >Index: src/org/eclipse/tptp/monitoring/logui/internal/util/GLAFilterHelper.java >=================================================================== >RCS file: /cvsroot/tptp/monitoring/org.eclipse.tptp.monitoring.logui/src/org/eclipse/tptp/monitoring/logui/internal/util/GLAFilterHelper.java,v >retrieving revision 1.30 >diff -u -r1.30 GLAFilterHelper.java >--- src/org/eclipse/tptp/monitoring/logui/internal/util/GLAFilterHelper.java 16 Aug 2006 21:33:52 -0000 1.30 >+++ src/org/eclipse/tptp/monitoring/logui/internal/util/GLAFilterHelper.java 16 Jan 2008 11:38:41 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -67,7 +67,7 @@ > import org.eclipse.hyades.logging.adapter.model.internal.outputter.OutputterFactory; > import org.eclipse.hyades.logging.events.cbe.EventPackage; > import org.eclipse.hyades.logging.parsers.importer.LogParserConstants; >-import org.eclipse.hyades.logging.parsers.internal.importer.GLAHelper; >+import org.eclipse.hyades.logging.parsers.provisional.importer.GLAHelper; > import org.eclipse.hyades.models.cbe.CBEPackage; > import org.eclipse.hyades.models.hierarchy.TRCAgent; > import org.eclipse.hyades.models.hierarchy.extensions.BinaryExpression;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 208728
:
87053
| 87054 |
88693
|
88694
|
88695