List of usage examples for org.apache.commons.logging Log error
void error(Object message);
From source file:org.eclipse.smila.utils.scriptexecution.LogHelper.java
/** * Logs message with specified level.//from w w w . j a v a2 s. c om * * @param log * log * @param message * message * @param logLevel * log level */ private static void log(final Log log, final String message, final LogLevel logLevel) { if (LogLevel.DEBUG.equals(logLevel)) { log.debug(message); } else if (LogLevel.INFO.equals(logLevel)) { log.info(message); } else if (LogLevel.WARN.equals(logLevel)) { log.warn(message); } else if (LogLevel.ERROR.equals(logLevel)) { log.error(message); } else { throw new IllegalArgumentException("Unknown log level [" + logLevel + "]"); } }
From source file:org.eclipse.smila.utils.workspace.WorkspaceHelper.java
/** * Creates the default bundle workspace. * //from w w w. j ava2 s .c om * @param bundleName * the bundle name * @param log * the log * @param workingDir * the working dir * @param bundle * the bundle * * @return the file */ private static File createDefaultBundleWorkspace(final String bundleName, final Log log, File workingDir, final Bundle bundle) { if (bundle == null) { log.error("Bundle " + bundleName + " seems not to be installed, cannot create default working dir."); } else { final IPath location = Platform.getStateLocation(bundle); if (location == null) { log.error("Platform did not return a state location for bundle " + bundleName + "."); } else { workingDir = location.toFile(); } } return workingDir; }
From source file:org.eclipse.smila.utils.workspace.WorkspaceHelper.java
/** * read property $bundleName.workspace to determine and ensure a custom workspace for the given bundle. * /*from w ww .ja v a 2 s.com*/ * @param bundleName * name of bundle * @param log * error log * * @return working dir, if custom bundle workspace has been specified, else null. */ private static File createCustomBundleWorkspace(final String bundleName, final Log log) { File workingDir = null; final String bundleWorkspaceProperty = bundleName + ".workspace"; String customBundleWorkspace = System.getProperty(bundleWorkspaceProperty); if (customBundleWorkspace == null) { customBundleWorkspace = System.getenv(bundleWorkspaceProperty); } if (!StringUtils.isBlank(customBundleWorkspace)) { if (log.isInfoEnabled()) { log.info("Custom workspace for bundle " + bundleName + " is " + customBundleWorkspace); } final File file = new File(customBundleWorkspace); if (!file.exists()) { file.mkdirs(); } if (file.exists() && file.isDirectory()) { workingDir = file; } else { log.error("Creating custom workspace for bundle " + bundleName + " failed, using fallback locations."); } } return workingDir; }
From source file:org.eclipse.smila.utils.xml.SchemaUtils.java
/** * Load schema runtime ex./* w w w . ja v a2 s . c om*/ * * @param bundle * the bundle * @param resourcePath * the resource path * * @return the schema */ public static Schema loadSchemaRuntimeEx(final Bundle bundle, final String resourcePath) { final Log log = LogFactory.getLog(SchemaUtils.class); try { return loadSchema(bundle, resourcePath); } catch (Throwable e) { if (log.isErrorEnabled()) { log.error(e); } throw new RuntimeException(e); } }
From source file:org.energy_home.jemma.internal.ah.m2m.device.M2MUtils.java
static void mapDeviceException(Log log, Exception e, String msg) throws M2MServiceException { log.error("M2MServiceException: " + msg + " - " + e.getClass().getName()); if (log.isDebugEnabled()) log.error("", e); if (e instanceof M2MServiceException) throw (M2MServiceException) e; else/*from ww w . j a v a 2 s . c om*/ throw new M2MServiceException(msg); }
From source file:org.firstopen.singularity.devicemgr.interrogator.WaveTrend_IO.java
/** * Main Method declaration for testing// w w w. j ava2 s . c o m * * @param args * @throws Exception * * @see */ public static void main(String[] args) { Log log = LogFactory.getLog("WaveTrend_IO"); String defaultPort = null; String defaultBaud = null; char CR = '\r'; char LF = '\n'; StringBuffer CRLF = new StringBuffer(); CRLF.append(CR); CRLF.append(LF); boolean useSimple = false; for (int i = 0; i < args.length; i++) { switch (i) { case 0: useSimple = Boolean.parseBoolean(args[i]); case 1: defaultPort = args[i]; break; case 2: defaultBaud = args[i]; break; } } // end for ShutdownManager sdm = new ShutdownManager(); Runtime.getRuntime().addShutdownHook(sdm); try { Properties properties = WaveTrend_IO.getProperties("devicemgr.properties"); if (defaultPort == null) { defaultPort = properties.getProperty("org.firstopen.singularity.devicemgr.commport"); } if (defaultBaud == null) { defaultBaud = properties.getProperty("org.firstopen.singularity.devicemgr.baud"); } DeviceProfile deviceProfile = new DeviceProfile("Dummy"); deviceProfile.setPort(defaultPort); deviceProfile.setBaud(defaultBaud); Set<Sensor> sensors = new HashSet<Sensor>(); sensors.add(new Sensor("embeddedAntenna")); deviceProfile.setSensorSet(sensors); InterrogatorIO interrogator = new DeviceManagerTest(); WaveTrend_IO reader = new WaveTrend_IO(deviceProfile); reader.setInterrogatorIO(interrogator); reader.setNetworkId( Integer.parseInt(properties.getProperty("org.firstopen.singularity.devicemgr.networkId"))); reader.setNodeId( Integer.parseInt(properties.getProperty("org.firstopen.singularity.devicemgr.nodeId"))); reader.setReaderId( Integer.parseInt(properties.getProperty("org.firstopen.singularity.devicemgr.readerId"))); reader.commandline = useSimple; reader.run(); if (reader.serialPort == null) { throw new InfrastructureException("cannot connect to serial port"); } if (reader.commandline == true) { reader.serialPort.addEventListener(new SimpleEventListener(reader.serialPort)); } OutputStream outputStream = reader.serialPort.getOutputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); command[] commandlist = command.values(); String commandLine = null; /* * for(command aCommand : commandlist) { System.out.print(aCommand); } */ ShutdownManager.addManagedObject(reader); byte[] msgBuf = null; while (true) { try { System.out.print("enter command > "); commandLine = br.readLine(); if (commandLine != null && !commandLine.equalsIgnoreCase("exit")) { int commandNumber = Integer.parseInt(commandLine.toString()); reader.log.debug("commandNumber is " + commandNumber); msgBuf = reader.createCommand(commandlist[commandNumber], null); outputStream.write(msgBuf); outputStream.flush(); } else { System.exit(0); } } catch (NumberFormatException e) { log.error("Please enter a number value"); } catch (Exception e) { log.error(e); } } } catch (Exception e) { log.error("failed", e); } }
From source file:org.holodeckb2b.common.workerpool.xml.XMLWorkerPoolConfig.java
/** * Loads the worker pool configuration from file. * /* w w w. jav a 2 s . c om*/ * @param path Path to the XML document containing the pool's configuration * @return The worker pool configuration if succesfully loaded, null otherwise */ public static IWorkerPoolConfiguration loadFromFile(String path) { Log log = LogFactory.getLog(XMLWorkerPoolConfig.class); XMLWorkerPoolConfig poolCfg = null; log.debug("Loading worker pool configuration from XML document in " + path); File f = new File(path); if (f.exists() && f.canRead()) { Serializer serializer = new Persister(); try { poolCfg = serializer.read(XMLWorkerPoolConfig.class, f); // If config file does not set pool name, set it here to file name if (poolCfg.getName() == null || poolCfg.getName().isEmpty()) poolCfg.name = f.getName().substring(0, f.getName().indexOf(".")); log.debug("Loaded configuration"); } catch (Exception ex) { log.error("Error while reading configuration from " + path + "! Details: " + ex.getMessage()); } } else log.error("Unable to access configuration file" + path + "!"); return poolCfg; }
From source file:org.holodeckb2b.ebms.axis2.Axis2Sender.java
/** * Send the message unit to the other MSH. * /* ww w . j a va 2 s .co m*/ * @param message The MessageUnit to send * @param log The log to use for writing log information */ public static void sendMessage(EntityProxy msgProxy, Log log) { ServiceClient sc; OperationClient oc; MessageContext msgCtx = new MessageContext(); MessageUnit message = msgProxy.entity; try { log.debug("Prepare Axis2 client to send " + message.getClass().getSimpleName()); sc = new ServiceClient(HolodeckB2BCoreInterface.getConfiguration().getAxisConfigurationContext(), Axis2Utils.createAnonymousService()); sc.engageModule(HolodeckB2BCoreImpl.HOLODECKB2B_CORE_MODULE); oc = sc.createClient(ANON_OUT_IN_OP); log.debug("Create an empty MessageContext for message with current configuration"); if (message instanceof UserMessage) { log.debug("Message to send is a UserMessage"); msgCtx.setProperty(MessageContextProperties.OUT_USER_MESSAGE, msgProxy); } else if (message instanceof PullRequest) { log.debug("Message to send is a PullRequest"); msgCtx.setProperty(MessageContextProperties.OUT_PULL_REQUEST, msgProxy); } else if (message instanceof ErrorMessage) { log.debug("Message to send is a ErrorMessage"); MessageContextUtils.addErrorSignalToSend(msgCtx, msgProxy); } else if (message instanceof Receipt) { log.debug("Message to send is a Receipt"); MessageContextUtils.addReceiptToSend(msgCtx, msgProxy); } oc.addMessageContext(msgCtx); // This dummy EPR has to be provided to be able to trigger message sending. It will be replaced later // with the correct URL defined in the P-Mode EndpointReference targetEPR = new EndpointReference("http://holodeck-b2b.org/transport/dummy"); Options options = new Options(); options.setTo(targetEPR); options.setExceptionToBeThrownOnSOAPFault(false); oc.setOptions(options); log.debug("Axis2 client configured for sending ebMS message"); } catch (AxisFault af) { // Setting up the Axis environment failed. As it prevents sending the message it is logged as a fatal error log.fatal("Setting up Axis2 to send message failed! Details: " + af.getReason()); return; } try { log.debug("Start the message send process"); oc.execute(true); } catch (AxisFault af) { /* An error occurred while sending the message, it should however be already processed by one of the handlers. In that case the message context will not contain the failure reason. To prevent redundant logging we check if there is a failure reason before we log the error here. */ List<Throwable> errorStack = Utils.getCauses(af); StringBuilder logMsg = new StringBuilder("\n\tError stack: ") .append(errorStack.get(0).getClass().getSimpleName()); for (int i = 1; i < errorStack.size(); i++) { logMsg.append("\n\t Caused by: ").append(errorStack.get(i).getClass().getSimpleName()); } logMsg.append(" {").append(errorStack.get(errorStack.size() - 1).getMessage()).append('}'); log.error("An error occurred while sending the message [" + message.getMessageId() + "]!" + logMsg.toString()); } finally { try { sc.cleanupTransport(); sc.cleanup(); } catch (AxisFault af2) { log.error("Clean up of Axis2 context to send message failed! Details: " + af2.getReason()); } } }
From source file:org.holodeckb2b.ebms3.pulling.PullConfiguration.java
/** * Loads the pulling configuration from file. * /*w w w . ja v a 2 s . c o m*/ * @param path Path to the XML document containing the pulling configuration * @return The pulling configuration if successfully loaded, null otherwise */ public static PullConfiguration loadFromFile(String path) { Log log = LogFactory.getLog(PullConfiguration.class); PullConfiguration pullCfg = null; log.debug("Loading pulling configuration from XML document in " + path); File f = new File(path); if (f.exists() && f.canRead()) { Serializer serializer = new Persister(); try { pullCfg = serializer.read(PullConfiguration.class, f); log.debug("Loaded configuration"); } catch (Exception ex) { log.error("Error while reading configuration from " + path + "! Details: " + ex.getMessage()); } } else log.error("Unable to access configuration file" + path + "!"); return pullCfg; }
From source file:org.hyperic.util.file.match.Matcher.java
/** * Determine if the dir is on a filesystem that we should * be searching./*from www . ja v a2 s .c o m*/ * @param dir The name of the directory. * @param fstypes The filesystem types we're supposed to search. * @param filesystems The filesystems that sigar detected. * @param log The log to use for errors and warnings. * @return true if the directory should be included in the search, * false otherwise. */ private boolean isFSTypeMatch(String dir, int fstypes, FileSystem[] filesystems, Log log) { String longestMatch = ""; int longestMatchIndex = -1; String absPath = (new File(dir)).getAbsolutePath(); String fsMountPoint; if (filesystems == null) { if (log != null) { log.error("matcher: filesystems array was never initialized."); } throw new IllegalArgumentException("filesystems array was never " + "initialized."); } for (int i = 0; i < filesystems.length; i++) { fsMountPoint = filesystems[i].getDirName(); if (absPath.startsWith(fsMountPoint) && fsMountPoint.length() > longestMatch.length()) { longestMatch = fsMountPoint; longestMatchIndex = i; } } if (longestMatchIndex == -1) { if (log != null) { log.warn("Directory " + dir + " did not match " + "any filesystems, it will not be searched."); } return false; } return isCandidateFS(fstypes, filesystems[longestMatchIndex], log); }