Package org.jrebirth.af.core.wave

Examples of org.jrebirth.af.core.wave.Wave


    public void runCommand(Class<? extends Command> commandClass) {

        wait = true;

        Wave wave = globalFacade.getCommandFacade().retrieve(commandClass).run();

        wave.addWaveListener(new DefaultWaveListener() {

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


    @Test
    public void openDefaultStage() {

        final String stageKey = "defaultStage";
        final Wave wave = StageWaveBuilder.create()
                .action(StageAction.show)
                .key(stageKey)
                .build();

        wave.addWaveListener(new WaveListener() {

            @Override
            public void waveSent(final Wave wave) {
                // Nothing to do yet

            }

            @Override
            public void waveProcessed(final Wave wave) {
                // Nothing to do yet

            }

            @Override
            public void waveFailed(final Wave wave) {
                // Nothing to do yet

            }

            @Override
            public void waveDestroyed(final Wave wave) {
                // Nothing to do yet

            }

            @Override
            public void waveCreated(final Wave wave) {
                // Nothing to do yet

            }

            @Override
            public void waveConsumed(final Wave wave) {
                final Stage stage = StageTest.globalFacade.getServiceFacade().retrieve(StageService.class).getStage(stageKey);
                Assert.assertNotNull(stage);
                System.out.println("dddd");
            }

            @Override
            public void waveCancelled(final Wave wave) {
                // Nothing to do yet

            }
        });

        JRebirth.runIntoJIT(new AbstractJrbRunnable("Send Wave " + wave.toString()) {
            @Override
            public void runInto() throws JRebirthThreadException {
                StageTest.globalFacade.getNotifier().sendWave(wave);
            }
        });
View Full Code Here

     * Recursive call.
     */
    private void unqueueWaves() {

        // Extract the next wave to run
        final Wave waveToRun = this.waveList.get(this.index);

        // The wave is null skip it and launch the next one
        if (waveToRun == null) {

            this.index++;
            // Run next command if any
            if (this.waveList.size() > this.index) {
                unqueueWaves();
            }
        } else {

            LOGGER.trace("Unqueue wave N° " + this.index + " >> " + waveToRun.toString());

            // Attach a listener to be informed when the wave will be consumed
            waveToRun.addWaveListener(this);
            // Send it to the queue in order to perform it
            sendWave(waveToRun);
        }

    }
View Full Code Here

    public final Wave run(final Wave wave) {

        // If given wave is null
        // Build a default Wave to avoid NullPointerException when
        // command was directly called by its run() method
        final Wave commandWave = wave == null
                ? WaveBuilder.create()
                        .waveGroup(WaveGroup.CALL_COMMAND)
                        .relatedClass(this.getClass())
                        .build()
                : wave;
View Full Code Here

            chainedWaveList.addAll(preBootList);
        }

        // Manage the creation of the first node and show it !

        final Wave firstViewWave = getLaunchFirstViewWave();
        if (firstViewWave != null) {
            chainedWaveList.add(firstViewWave);
        }

        // Manage waves to run after the First node creation
View Full Code Here

     *
     * @return the wave responsible of the creation of the first view
     */
    @SuppressWarnings("unchecked")
    protected Wave getLaunchFirstViewWave() {
        Wave firstWave = null;
        // Generates the command wave directly to win a Wave cycle
        if (this.application != null && this.application.getRootNode() != null && this.application.getFirstModelClass() != null) {
            firstWave = ShowModelWaveBuilder.create()
                    .childrenPlaceHolder(this.application.getRootNode().getChildren())
                    .showModelKey(getFacade().getUiFacade().buildKey((Class<Model>) this.application.getFirstModelClass()))
View Full Code Here

                    if (this.commandRunIndex == 0) {
                        this.waveSource = wave;
                    }

                    if (this.commandList.size() > this.commandRunIndex) {
                        final Wave subCommandWave = WaveBuilder.create()
                                .waveGroup(WaveGroup.CALL_COMMAND)
                                .relatedClass(this.commandList.get(this.commandRunIndex))
                                .build();

                        subCommandWave.linkWaveBean(wave.getWaveBean());
                        subCommandWave.addWaveListener(this);
                        sendWave(subCommandWave);
                    }
                }

            } else {
                // Store the original wave to be able to mark it as consumed when all of these sub comamnds are achieved
                this.waveSource = wave;

                // Launch all sub command in parallel
                for (final Class<? extends Command> commandClass : this.commandList) {
                    final Wave commandWave = getLocalFacade().retrieve(commandClass).run();
                    // register to Wave status of all command triggered
                    commandWave.addWaveListener(this);
                    // Store the pending command to know when all command are achieved
                    this.pendingWaves.add(commandWave);
                }
            }
        }
View Full Code Here

     *
     * @return the wave built
     */
    private Wave createWave(final WaveGroup waveGroup, final WaveType waveType, final Class<?> relatedClass, final WaveData<?>... waveData) {

        final Wave wave = new WaveBase();

        wave.setWaveGroup(waveGroup);
        wave.setWaveType(waveType);
        wave.setFromClass(this.getClass());
        wave.setRelatedClass(relatedClass);

        for (final WaveData<?> wd : waveData) {
            wave.addData(wd);
        }

        // Track wave creation
        getLocalFacade().getGlobalFacade().trackEvent(JRebirthEventType.CREATE_WAVE, this.getClass(), wave.getClass());

        return wave;
    }
View Full Code Here

     *
     * @return the wave built
     */
    private Wave createWave(final WaveGroup waveGroup, final WaveType waveType, final Class<?> relatedClass, final WaveBean waveBean) {

        final Wave wave = new WaveBase();

        wave.setWaveGroup(waveGroup);
        wave.setWaveType(waveType);
        wave.setFromClass(this.getClass());
        wave.setRelatedClass(relatedClass);

        wave.linkWaveBean(waveBean);

        // Track wave creation
        getLocalFacade().getGlobalFacade().trackEvent(JRebirthEventType.CREATE_WAVE, this.getClass(), wave.getClass());

        return wave;
    }
View Full Code Here

     * @throws CoreException if the wave generation has failed
     */
    @SuppressWarnings("unchecked")
    private void sendReturnWave(final T res) throws CoreException {

        Wave returnWave = null;

        // Try to retrieve the return Wave type, could be null
        final WaveType responseWaveType = this.service.getReturnWaveType(this.wave.getWaveType());

        if (responseWaveType != null) {

            // No service result type defined into a WaveItem
            if (((WaveTypeBase) responseWaveType).getWaveItemList().isEmpty()) {
                LOGGER.log(NO_RETURNED_WAVE_ITEM);
                throw new CoreException(NO_RETURNED_WAVE_ITEM);
            }

            // Get the first (and unique) WaveItem used to define the service result type
            final WaveItem<T> resultWaveItem = (WaveItem<T>) ((WaveTypeBase) responseWaveType).getWaveItemList().get(0);

            // Try to retrieve the command class, could be null
            final Class<? extends Command> responseCommandClass = this.service.getReturnCommand(this.wave.getWaveType());

            if (responseCommandClass != null) {

                // If a Command Class is provided, call it with the right WaveItem to get the real result type
                returnWave = WaveBuilder.create()
                        .waveGroup(WaveGroup.CALL_COMMAND)
                        .fromClass(this.service.getClass())
                        .relatedClass(responseCommandClass)
                        .data(WaveData.build(resultWaveItem, res))
                        .build();
            } else {

                // Otherwise send a generic wave that can be handled by any component
                returnWave = WaveBuilder.create()
                        .waveType(responseWaveType)
                        .fromClass(this.service.getClass())
                        .data(WaveData.build(resultWaveItem, res))
                        .build();
            }

            returnWave.setRelatedWave(this.wave);
            returnWave.addWaveListener(new ServiceTaskReturnWaveListener());

            // Send the return wave to interested components
            this.service.sendWave(returnWave);
        } else {
            // No service return wave Type defined
View Full Code Here

TOP

Related Classes of org.jrebirth.af.core.wave.Wave

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.