use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class RegistrationListenerBean method invokeMethod.
private void invokeMethod(String methodName, Registration registration) {
try {
Method method = getMethod(methodName);
method.invoke(m_target, registration.getProvider(m_serviceInterface), registration.getProperties());
} catch (Throwable e) {
throw new UndeclaredThrowableException(e, "Unexexpected exception invoking method " + methodName);
} finally {
}
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class AnnotationBasedEventListenerAdapter method onEvent.
/* (non-Javadoc)
* @see org.opennms.netmgt.eventd.EventListener#onEvent(org.opennms.netmgt.xml.event.Event)
*/
/** {@inheritDoc} */
@Override
public void onEvent(final Event event) {
if (event.getUei() == null) {
return;
}
Method m = m_ueiToHandlerMap.get(event.getUei());
if (m == null) {
// Try to get a catch-all event handler
m = m_ueiToHandlerMap.get(EventHandler.ALL_UEIS);
if (m == null) {
throw new IllegalArgumentException("Received an event for which we have no handler!");
}
}
final Method method = m;
Logging.withPrefix(m_logPrefix, new Runnable() {
@Override
public void run() {
try {
preprocessEvent(event);
processEvent(event, method);
postprocessEvent(event);
} catch (IllegalArgumentException e) {
throw e;
} catch (IllegalAccessException e) {
throw new UndeclaredThrowableException(e);
} catch (InvocationTargetException e) {
handleException(event, e.getCause());
}
}
});
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class TcpEventReceiver method start.
/**
* Allocates the server socket and starts up the server socket processor
* thread. If an error occurs allocating the server socket or the Fiber is
* in an erronous state then a
* {@link java.lang.RuntimeException runtime exception}is thrown.
*
* @throws java.lang.reflect.UndeclaredThrowableException
* Thrown if an error occurs allocating the server socket.
* @throws java.lang.RuntimeException
* Thrown if the fiber is in an erronous state or the underlying
* thread cannot be started.
*/
@Override
public synchronized void start() {
assertNotRunning();
m_status = STARTING;
try {
InetAddress address = "*".equals(m_ipAddress) ? null : InetAddressUtils.addr(m_ipAddress);
m_server = new TcpServer(this, m_eventHandlers, m_tcpPort, address);
if (m_logPrefix != null) {
m_server.setLogPrefix(m_logPrefix);
}
if (m_recsPerConn != UNLIMITED_EVENTS) {
m_server.setEventsPerConnection(m_recsPerConn);
}
} catch (IOException e) {
throw new UndeclaredThrowableException(e, "Error opening server socket: " + e);
}
m_worker = new Thread(m_server, "Event TCP Server[" + m_tcpPort + "]");
try {
m_worker.start();
} catch (RuntimeException e) {
m_worker.interrupt();
m_status = STOPPED;
throw e;
}
m_status = RUNNING;
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class SmtpMonitorIT method testPollCase3.
@Test
public void testPollCase3() throws UnknownHostException, InterruptedException {
m_serverThread = new Thread(new Runnable() {
@Override
public void run() {
try {
m_serverSocket.setSoTimeout(1000);
Socket s = m_serverSocket.accept();
System.out.println("S: 220 localhost.localdomain ESMTP bogon");
s.getOutputStream().write("220 localhost.localdomain ESMTP bogon\r\n".getBytes());
BufferedReader r = new BufferedReader(new InputStreamReader(s.getInputStream()));
String command = r.readLine();
System.out.println("C: " + command);
if (command.startsWith("HELO ")) {
System.out.println("S: 250 Hello");
s.getOutputStream().write("250 Hello\r\n".getBytes());
}
command = r.readLine();
System.out.println("C: " + command);
if (command.equals("QUIT")) {
System.out.println("S: 221-Goodbye, friend.");
s.getOutputStream().write("221-Goodbye, friend.\r\n".getBytes());
System.out.println("S: 221 See ya");
s.getOutputStream().write("221 See ya\r\n".getBytes());
}
} catch (Throwable e) {
throw new UndeclaredThrowableException(e);
}
}
});
m_serverThread.start();
ServiceMonitor sm = new SmtpMonitor();
MonitoredService svc = new MockMonitoredService(1, "Node One", InetAddressUtils.addr("127.0.0.1"), "SMTP");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("port", m_serverSocket.getLocalPort());
PollStatus ps = sm.poll(svc, parms);
assertTrue(ps.isUp());
assertFalse(ps.isDown());
}
use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.
the class SmtpMonitorIT method testPollCase2.
@Test
public void testPollCase2() throws UnknownHostException, InterruptedException {
m_serverThread = new Thread(new Runnable() {
@Override
public void run() {
try {
m_serverSocket.setSoTimeout(1000);
Socket s = m_serverSocket.accept();
System.out.println("S: 220 localhost.localdomain ESMTP bogon");
s.getOutputStream().write("220 localhost.localdomain ESMTP bogon\r\n".getBytes());
BufferedReader r = new BufferedReader(new InputStreamReader(s.getInputStream()));
String command = r.readLine();
System.out.println("C: " + command);
if (command.startsWith("HELO ")) {
System.out.println("S: 250-Hello");
s.getOutputStream().write("250-Hello\r\n".getBytes());
System.out.println("S: 250 send me mail now!");
s.getOutputStream().write("250 send me mail now!\r\n".getBytes());
}
command = r.readLine();
System.out.println("C: " + command);
if (command.equals("QUIT")) {
System.out.println("S: 250 Hello");
s.getOutputStream().write("221 See ya\r\n".getBytes());
}
} catch (Throwable e) {
throw new UndeclaredThrowableException(e);
}
}
});
m_serverThread.start();
ServiceMonitor sm = new SmtpMonitor();
MonitoredService svc = new MockMonitoredService(1, "Node One", InetAddressUtils.addr("127.0.0.1"), "SMTP");
Map<String, Object> parms = new HashMap<String, Object>();
parms.put("port", m_serverSocket.getLocalPort());
PollStatus ps = sm.poll(svc, parms);
assertTrue(ps.isUp());
assertFalse(ps.isDown());
}
Aggregations