Package net.sf.urlchecker.events

Examples of net.sf.urlchecker.events.BasicChainEvent


     */
    /** {@inheritDoc} */
    @Override
    public Set<Result> process(final Context context)
            throws ConfigurationException {
        fireEvent(new BasicChainEvent(this, context, EventTypes.START));
        if (null == context || null == context.getResults()) {
            throw new IllegalStateException();
        }

        if (!CollectionUtils.isEmpty(context.getResults())) {
View Full Code Here


     */
    /** {@inheritDoc} */
    @Override
    public Set<Result> process(final Context context)
            throws ConfigurationException {
        fireEvent(new BasicChainEvent(this, context, EventTypes.START));
        final Scanner scanner = new Scanner(context.getSource());
        try {
            String match = "";
            while (null != match) {
                match = scanner.findWithinHorizon(CommunicationFactory
View Full Code Here

    public Set<Result> process(final Context input)
            throws ConfigurationException {
        // Fire the end event. Since this code is called as the last step of a
        // the process method of any concrete Command class, this is the END
        // event that is being fired.
        fireEvent(new BasicChainEvent(this, input, EventTypes.END));

        // Check if this is not the end of the chain of responsibility and call
        // the successor.
        if (null != successor) {
            return successor.process(input);
View Full Code Here

    @Before
    public void setUp() throws Exception {

        context = createNiceMock(Context.class);
        uriCommand = new URLMatchCommand(null);
        event = new BasicChainEvent(uriCommand, context, EventTypes.START);
        replay(context);
    }
View Full Code Here

     */
    @Test
    public void testEqualsObject() {
        assertFalse(event.equals(null));
        assertTrue(event.equals(event));
        assertTrue(event.equals(new BasicChainEvent(uriCommand, context,
                EventTypes.START)));
        assertFalse(event.equals(new Object()));
    }
View Full Code Here

        final ExecutorService service = Executors.newFixedThreadPool(context
                .getResults().size());
        final List<Future<CheckUrlsProcess>> tasks = new ArrayList<Future<CheckUrlsProcess>>();

        while (iter.hasNext()) {
            fireEvent(new BasicChainEvent(this, context, EventTypes.FORK));
            final CheckUrlsProcess process = new CheckUrlsProcess(client,
                    localContext, iter.next());
            final Future<CheckUrlsProcess> future = service.submit(process,
                    process);
            tasks.add(future);
        }

        try {
            for (final Future<CheckUrlsProcess> f : tasks) {
                final Result result = f.get().getResult();

                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug(result.getResult() + " for " + result.getURI()
                            + " with " + result.getUserData());
                }
            }

            service.shutdown();
        } catch (final InterruptedException e) {
            LOGGER.error(e);
            fireEvent(new BasicChainEvent(this, context, EventTypes.EXCEPTION));
        } catch (final ExecutionException e) {
            LOGGER.error(e);
            fireEvent(new BasicChainEvent(this, context, EventTypes.EXCEPTION));
        } finally {
            try {
                if (!service.isShutdown()) {
                    service.awaitTermination(terminationTime, TimeUnit.SECONDS);
                }
            } catch (final InterruptedException e) {
                LOGGER.error(e);
                fireEvent(new BasicChainEvent(this, context,
                        EventTypes.EXCEPTION));
            } finally {
                if (!service.isShutdown()) {
                    service.shutdownNow();
                }
View Full Code Here

        final ExecutorService service = Executors.newFixedThreadPool(context
                .getResults().size());
        final List<Future<CheckUrlsProcess>> tasks = new ArrayList<Future<CheckUrlsProcess>>();

        while (iter.hasNext()) {
            fireEvent(new BasicChainEvent(this, context, EventTypes.FORK));
            final CheckUrlsProcess process = new CheckUrlsProcess(client,
                    iter.next());
            final Future<CheckUrlsProcess> future = service.submit(process,
                    process);
            tasks.add(future);
        }

        try {
            for (final Future<CheckUrlsProcess> f : tasks) {
                final Result result = f.get().getResult();

                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug(result.getResult() + " for " + result.getURI()
                            + " with " + result.getUserData());
                }
            }

            service.shutdown();
        } catch (final InterruptedException e) {
            LOGGER.error(e);
            fireEvent(new BasicChainEvent(this, context, EventTypes.EXCEPTION));
        } catch (final ExecutionException e) {
            LOGGER.error(e);
            fireEvent(new BasicChainEvent(this, context, EventTypes.EXCEPTION));
        } finally {
            try {
                if (!service.isShutdown()) {
                    service.awaitTermination(terminationTime, TimeUnit.SECONDS);
                }
            } catch (final InterruptedException e) {
                LOGGER.error(e);
                fireEvent(new BasicChainEvent(this, context,
                        EventTypes.EXCEPTION));
            } finally {
                if (!service.isShutdown()) {
                    service.shutdownNow();
                }
View Full Code Here

TOP

Related Classes of net.sf.urlchecker.events.BasicChainEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.