Example usage for java.beans ExceptionListener exceptionThrown

List of usage examples for java.beans ExceptionListener exceptionThrown

Introduction

In this page you can find the example usage for java.beans ExceptionListener exceptionThrown.

Prototype

public void exceptionThrown(Exception e);

Source Link

Document

This method is called when a recoverable exception has been caught.

Usage

From source file:be.ac.ua.comp.scarletnebula.gui.SSHPanel.java

public SSHPanel(final Server server) {
    super();/*from   w w w. ja v a 2 s . co  m*/

    final JCTermSwing term = new JCTermSwing();
    term.setCompression(7);
    term.setAntiAliasing(true);

    setLayout(new BorderLayout());

    addComponentListener(new ComponentListener() {

        @Override
        public void componentShown(final ComponentEvent e) {
        }

        @Override
        public void componentResized(final ComponentEvent e) {
            final Component c = e.getComponent();
            int cw = c.getWidth();
            int ch = c.getHeight();

            final JPanel source = ((JPanel) c);

            final int cwm = source.getBorder() != null
                    ? source.getBorder().getBorderInsets(c).left + source.getBorder().getBorderInsets(c).right
                    : 0;
            final int chm = source.getBorder() != null
                    ? source.getBorder().getBorderInsets(c).bottom + source.getBorder().getBorderInsets(c).top
                    : 0;
            cw -= cwm;
            ch -= chm;

            term.setBorder(BorderFactory.createMatteBorder(0, 0, term.getTermHeight() - c.getHeight(),
                    term.getTermWidth() - c.getWidth(), Color.BLACK));
            term.setSize(cw, ch);
            term.setPreferredSize(new Dimension(cw, ch));
            // term.setMinimumSize(new Dimension(cw, ch));
            term.setMaximumSize(new Dimension(cw, ch));
            term.redraw(0, 0, term.getTermWidth(), term.getTermHeight());
        }

        @Override
        public void componentMoved(final ComponentEvent e) { // TODO
            // Auto-generated
            // method
            // stub

        }

        @Override
        public void componentHidden(final ComponentEvent e) { // TODO
            // Auto-generated
            // method
            // stub

        }
    });

    add(term, BorderLayout.CENTER);

    setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20),
            BorderFactory.createBevelBorder(BevelBorder.LOWERED)));

    final Thread connectionThread = new Thread() {
        @Override
        public void run() {

            Connection connection = null;
            try {
                final SSHCommandConnection commandConnection = (SSHCommandConnection) server
                        .newCommandConnection(new NotPromptingJschUserInfo());

                connection = commandConnection.getJSchTerminalConnection();

                term.requestFocusInWindow();
                term.start(connection);
            } catch (final Exception e) {
                for (final ExceptionListener listener : exceptionListeners) {
                    listener.exceptionThrown(e);
                }

                log.warn("Exception thrown by SSHPanel", e);
            } finally {
            }

        }
    };

    connectionThread.start();
}

From source file:org.ibeans.impl.DefaultIBeanInvoker.java

public void intercept(InvocationContext invocationContext) throws Throwable {
    ExceptionListener exceptionListener = invocationContext.getExceptionListener();

    Response result;/*from   ww w . jav  a2s . c o  m*/

    if (invocationContext.getMethod().isAnnotationPresent(Invoke.class)) {
        result = invokeHandler.invoke(invocationContext);
    }
    //Can Template handler be simplified here? Is there a need to register evals on the handler?
    else if (templateHandler != null && templateHandler.isMatch(invocationContext.getMethod())) {
        result = templateHandler.invoke(invocationContext);
    } else {
        result = callHandler.invoke(invocationContext);
    }

    ((InternalInvocationContext) invocationContext).setResponse(result);

    if (result != null) {
        invocationContext.setResult(result.getPayload());
    }

    if (result != null) {
        if (result.getException() != null) {
            Throwable t = result.getException();
            if (exceptionListener != null) {
                if (Exception.class.isAssignableFrom(t.getClass())) {
                    exceptionListener.exceptionThrown((Exception) t);
                } else {
                    exceptionListener.exceptionThrown(new Exception(t));
                }
            } else {
                t = ProcessErrorsInterceptor.createCallException(invocationContext, t);
                throw t;
            }
        }
    }
}

From source file:org.marketcetera.client.ClientImpl.java

void exceptionThrown(ConnectionException inException) {
    synchronized (mExceptionListeners) {
        for (ExceptionListener l : mExceptionListeners) {
            try {
                l.exceptionThrown(inException);
            } catch (Exception e) {
                Messages.LOG_ERROR_NOTIFY_EXCEPTION.warn(this, e, ObjectUtils.toString(inException));
                ExceptUtils.interrupt(e);
            }//from   w  w w.  j ava  2  s  .c  o  m
        }
    }
}