Package org.jboss.dna.graph.request

Examples of org.jboss.dna.graph.request.CompositeRequest


                    searchProcessor.process(searchRequest);
                } finally {
                    searchProcessor.close();
                }
            } else if (request instanceof CompositeRequest) {
                CompositeRequest composite = (CompositeRequest)request;
                CompositeRequestChannel channel = null;
                RequestProcessor searchProcessor = null;
                try {
                    for (Request nested : composite) {
                        if (nested instanceof AccessQueryRequest) {
                            AccessQueryRequest queryRequest = (AccessQueryRequest)request;
                            if (searchProcessor == null) searchProcessor = searchEngine().createProcessor(context, null, true);
                            searchProcessor.process(queryRequest);
                        } else if (nested instanceof FullTextSearchRequest) {
                            FullTextSearchRequest searchRequest = (FullTextSearchRequest)request;
                            if (searchProcessor == null) searchProcessor = searchEngine().createProcessor(context, null, true);
                            searchProcessor.process(searchRequest);
                        } else {
                            // Delegate to the channel ...
                            if (channel == null) {
                                // Create a connection factory that always returns the delegate connection ...
                                RepositoryConnectionFactory connectionFactory = new RepositoryConnectionFactory() {
                                    /**
                                     * {@inheritDoc}
                                     *
                                     * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
                                     */
                                    public RepositoryConnection createConnection( String sourceName )
                                        throws RepositorySourceException {
                                        assert delegate().getName().equals(sourceName);
                                        return delegateConnection();
                                    }
                                };
                                channel = new CompositeRequestChannel(delegate().getName());
                                channel.start(executorService, context, connectionFactory);
                            }
                            channel.add(request);
                        }
                    }
                } finally {
                    try {
                        if (searchProcessor != null) {
                            searchProcessor.close();
                        }
                    } finally {
                        if (channel != null) {
                            try {
                                channel.close();
                            } finally {
                                try {
                                    channel.await();
                                } catch (CancellationException err) {
                                    composite.cancel();
                                } catch (ExecutionException err) {
                                    composite.setError(err);
                                } catch (InterruptedException err) {
                                    // Reset the thread ...
                                    Thread.interrupted();
                                    // Then log the message ...
                                    I18n msg = GraphI18n.interruptedWhileClosingChannel;
                                    Logger.getLogger(getClass()).warn(err, msg, delegate().getName());
                                    composite.setError(err);
                                }
                            }
                        }
                    }
                }
View Full Code Here


                    searchProcessor.process(searchRequest);
                } finally {
                    searchProcessor.close();
                }
            } else if (request instanceof CompositeRequest) {
                CompositeRequest composite = (CompositeRequest)request;
                List<Request> delegateRequests = null;
                RequestProcessor searchProcessor = null;
                try {
                    Request delegateRequest = composite;
                    for (Request nested : composite) {
View Full Code Here

            if (request == null) {
                return new BatchResults();
            }
            Graph.this.execute(request);
            if (request instanceof CompositeRequest) {
                CompositeRequest composite = (CompositeRequest)request;
                return new BatchResults(composite.getRequests());
            }
            return new BatchResults(request);
        }
View Full Code Here

        return true;
    }

    protected boolean shouldProcessSynchronously( Request request ) {
        if (request instanceof CompositeRequest) {
            CompositeRequest composite = (CompositeRequest)request;
            if (composite.size() == 1) return true;
            // There is more than one request, and the JoinRequestProcessor needs to be able to run even if
            // the ForkRequestProcessor is processing incoming requests. Normally this would work fine,
            // but if the incoming request is a CompositeRequestChannel.CompositeRequest, the ForkRequestProcessor
            // will block if the channel is still open. In a synchronous mode, this prevents the JoinRequestProcessor
            // from completing the incoming requests. See DNA-616 for details.
View Full Code Here

         *        not be null or empty
         */
        protected Channel( final String sourceName ) {
            assert sourceName != null;
            this.sourceName = sourceName;
            this.composite = new CompositeRequest(false) {
                private static final long serialVersionUID = 1L;
                private final LinkedList<Request> allRequests = Channel.this.allRequests;

                /**
                 * {@inheritDoc}
 
View Full Code Here

            if (request == null) {
                return new BatchResults();
            }
            Graph.this.execute(request);
            if (request instanceof CompositeRequest) {
                CompositeRequest composite = (CompositeRequest)request;
                return new BatchResults(composite.getRequests());
            }
            return new BatchResults(request);
        }
View Full Code Here

        assertThat(connection.shouldProcessSynchronously(request), is(true));
    }

    @Test
    public void shouldProcessCompositeRequestWithOneRequestSynchronously() {
        CompositeRequest request = mock(CompositeRequest.class);
        stub(request.size()).toReturn(1);
        assertThat(connection.shouldProcessSynchronously(request), is(true));
    }
View Full Code Here

    }

    @Ignore
    @Test
    public void shouldProcessCompositeRequestWithMultipleRequestsAsynchronously() {
        CompositeRequest request = mock(CompositeRequest.class);
        stub(request.size()).toReturn(2);
        assertThat(connection.shouldProcessSynchronously(request), is(false));
    }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.request.CompositeRequest

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.