/** * Will shutdown the application. * @param aIgnore ignored */ public void actionPerformed(ActionEvent aIgnore) { LOG.info("shutting down"); System.exit(0); } }
/** * Prompts the user for a file to load events from. * @param aIgnore an <code>ActionEvent</code> value */ public void actionPerformed(ActionEvent aIgnore) { LOG.info("load file called"); if (mChooser.showOpenDialog(mParent) == JFileChooser.APPROVE_OPTION) { LOG.info("Need to load a file"); final File chosen = mChooser.getSelectedFile(); LOG.info("loading the contents of " + chosen.getAbsolutePath()); try { final int num = loadFile(chosen.getAbsolutePath()); JOptionPane.showMessageDialog( mParent, "Loaded " + num + " events.", "CHAINSAW", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { LOG.warn("caught an exception loading the file", e); JOptionPane.showMessageDialog( mParent, "Error parsing file - " + e.getMessage(), "CHAINSAW", JOptionPane.ERROR_MESSAGE); } } }
static void roll() { try { Socket socket = new Socket(host, port); DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); DataInputStream dis = new DataInputStream(socket.getInputStream()); dos.writeUTF(ExternallyRolledFileAppender.ROLL_OVER); String rc = dis.readUTF(); if(ExternallyRolledFileAppender.OK.equals(rc)) { cat.info("Roll over signal acknowledged by remote appender."); } else { cat.warn("Unexpected return code "+rc+" from remote entity."); System.exit(2); } } catch(IOException e) { cat.error("Could not send roll signal on host "+host+" port "+port+" .", e); System.exit(2); } System.exit(0); } }
public static void main(String argv[]) { if(argv.length == 2) { init(argv[0], argv[1]); } else { usage("Wrong number of arguments."); } try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); cat.info("Connected to client at " + socket.getInetAddress()); cat.info("Starting new socket node."); new Thread(new SocketNode(socket, LogManager.getLoggerRepository())).start(); } } catch(Exception e) { e.printStackTrace(); } }
public static void main(String argv[]) { if(argv.length == 3) init(argv[0], argv[1], argv[2]); else usage("Wrong number of arguments."); try { cat.info("Listening on port " + port); ServerSocket serverSocket = new ServerSocket(port); while(true) { cat.info("Waiting to accept a new client."); Socket socket = serverSocket.accept(); InetAddress inetAddress = socket.getInetAddress(); cat.info("Connected to client at " + inetAddress); LoggerRepository h = (LoggerRepository) server.hierarchyMap.get(inetAddress); if(h == null) { h = server.configureHierarchy(inetAddress); } cat.info("Starting new socket node."); new Thread(new SocketNode(socket, h)).start(); } } catch(Exception e) { e.printStackTrace(); } }
logger.info("Caught java.io.EOFException closing conneciton."); } catch(java.net.SocketException e) { logger.info("Caught java.net.SocketException closing conneciton."); } catch(IOException e) { logger.info("Caught java.io.IOException: "+e); logger.info("Closing connection."); } catch(Exception e) { logger.error("Unexpected exception. Closing conneciton.", e); ois.close(); } catch(Exception e) { logger.info("Could not close connection.", e);
/** Listens for client connections **/ public void run() { LOG.info("Thread started"); try { while (true) { LOG.debug("Waiting for a connection"); final Socket client = mSvrSock.accept(); LOG.debug("Got a connection from " + client.getInetAddress().getHostName()); final Thread t = new Thread(new Slurper(client)); t.setDaemon(true); t.start(); } } catch (IOException e) { LOG.error("Error in accepting connections, stopping.", e); } } }
/** loops getting the events **/ public void run() { LOG.debug("Starting to get data"); try { final ObjectInputStream ois = new ObjectInputStream(mClient.getInputStream()); while (true) { final LoggingEvent event = (LoggingEvent) ois.readObject(); mModel.addEvent(new EventDetails(event)); } } catch (EOFException e) { LOG.info("Reached EOF, closing connection"); } catch (SocketException e) { LOG.info("Caught SocketException, closing connection"); } catch (IOException e) { LOG.warn("Got IOException, closing connection", e); } catch (ClassNotFoundException e) { LOG.warn("Got ClassNotFoundException, closing connection", e); } try { mClient.close(); } catch (IOException e) { LOG.warn("Error closing connection", e); } } }
loadMenuItem.addActionListener(lxa); } catch (NoClassDefFoundError e) { LOG.info("Missing classes for XML parser", e); JOptionPane.showMessageDialog( this, JOptionPane.ERROR_MESSAGE); } catch (Exception e) { LOG.info("Unable to create the action to load XML files", e); JOptionPane.showMessageDialog( this,
LoggerRepository configureHierarchy(InetAddress inetAddress) { cat.info("Locating configuration file for "+inetAddress); // We assume that the toSting method of InetAddress returns is in // the format hostname/d1.d2.d3.d4 e.g. torino/192.168.1.1 String s = inetAddress.toString(); int i = s.indexOf("/"); if(i == -1) { cat.warn("Could not parse the inetAddress ["+inetAddress+ "]. Using default hierarchy."); return genericHierarchy(); } else { String key = s.substring(0, i); File configFile = new File(dir, key+CONFIG_FILE_EXT); if(configFile.exists()) { Hierarchy h = new Hierarchy(new RootLogger((Level) Priority.DEBUG)); hierarchyMap.put(inetAddress, h); new PropertyConfigurator().doConfigure(configFile.getAbsolutePath(), h); return h; } else { cat.warn("Could not find config file ["+configFile+"]."); return genericHierarchy(); } } }
/** * Will shutdown the application. * @param aIgnore ignored */ public void actionPerformed(ActionEvent aIgnore) { LOG.info("shutting down"); System.exit(0); } }
/** * Will shutdown the application. * @param aIgnore ignored */ public void actionPerformed(ActionEvent aIgnore) { LOG.info("shutting down"); System.exit(0); } }
/** * Will shutdown the application. * @param aIgnore ignored */ public void actionPerformed(ActionEvent aIgnore) { LOG.info("shutting down"); System.exit(0); } }
/** * Will shutdown the application. * @param aIgnore ignored */ public void actionPerformed(ActionEvent aIgnore) { LOG.info("shutting down"); System.exit(0); } }
/** * Will shutdown the application. * @param aIgnore ignored */ public void actionPerformed(ActionEvent aIgnore) { LOG.info("shutting down"); System.exit(0); } }
@EventHandler public void on(OrderPlacedEvent event) { Logger .getInstance(getClass()) .info(format("Handling event: %s", event)); Optional .ofNullable(orders.findOne(event.getOrderId())) .map(Order::place) .ifPresent(orders::save); } }
@EventHandler public void on(OrderCanceledEvent event) { Logger .getInstance(getClass()) .info(format("Handling event: %s", event)); Optional .ofNullable(orders.findOne(event.getOrderId())) .ifPresent(orders::delete); } }
@EventHandler public void on(MenuItemRemovedEvent event) { Logger .getInstance(getClass()) .info(format("Handling event: %s", event)); menu.delete(event.getId()); } }
@EventHandler public void on(CustomerSignedUpEvent event) { Logger .getInstance(getClass()) .info(format("Handling event: %s", event)); customers.save(new Customer(event.getId())); } }
private ConcurrencyException concurrencyException(final ConcurrencyException e) { LOG.info("concurrency conflict: " + e.getMessage()); Oid source = e.getSource(); if (source == null) { return e; } else { NakedObject failedObject = NakedObjectsContext.getObjectLoader().getAdapterFor(source); NakedObjectsContext.getObjectPersistor().reload(failedObject); return new ConcurrencyException("Object automatically reloaded: " + failedObject.titleString(), e); } }