Package org.milyn.javabean.lifecycle

Examples of org.milyn.javabean.lifecycle.BeanContextLifecycleEvent


    // If there's already an instance of this bean, notify observers of it's
    // removal (removal by being overwritten)...
    Object currentInstance = getBean(beanId);
    if (currentInstance != null) {
      notifyObservers(new BeanContextLifecycleEvent(executionContext,
          source, BeanLifecycle.REMOVE, beanId, currentInstance));
    }

    // Check if the BeanIdList has new BeanIds and if so then
    // add those new entries to the Map. This ensures we always
    // have an up to date Map.
    checkUpdatedBeanIdList();

    int index = beanId.getIndex();
    ContextEntry repoEntry = entries.get(index);

    clean(index);
    repoEntry.setValue(bean);

    // Add the bean to the context...
    notifyObservers(new BeanContextLifecycleEvent(executionContext, source,
        BeanLifecycle.ADD, beanId, bean));
  }
View Full Code Here


    int index = beanId.getIndex();

    if (entries.size() > index && entries.get(index).getValue() != null) {
      entries.get(index).setValue(bean);

      notifyObservers(new BeanContextLifecycleEvent(executionContext,
          source, BeanLifecycle.CHANGE, beanId, bean));
    } else {
      throw new IllegalStateException("The bean '" + beanId
          + "' can't be changed because it isn't in the repository.");
    }
View Full Code Here

    Object old = repositoryEntry.getValue();

    repositoryEntry.clean();
    repositoryEntry.setValue(null);

    notifyObservers(new BeanContextLifecycleEvent(executionContext, source,
        BeanLifecycle.REMOVE, beanId, getBean(beanId)));

    return old;
  }
View Full Code Here

        beanRouter.setToEndpoint(ENDPOINT_URI);
        beanRouter.initialize();

        final BeanRouterObserver beanRouterObserver = new BeanRouterObserver(beanRouter, beanId);
        final MockExecutionContext smooksExecutionContext = new MockExecutionContext();
        final BeanContextLifecycleEvent event = mock(BeanContextLifecycleEvent.class);
       
        when(event.getBeanId()).thenReturn(new BeanId(null, 0, beanId));
        when(event.getLifecycle()).thenReturn(BeanLifecycle.END_FRAGMENT);
        when(event.getBean()).thenReturn(sampleBean);
        when(event.getExecutionContext()).thenReturn(smooksExecutionContext);
   
        endpoint.setExpectedMessageCount(1);
        beanRouterObserver.onBeanLifecycleEvent(event);
        endpoint.assertIsSatisfied();
        endpoint.expectedBodiesReceived(sampleBean);
View Full Code Here

                    }
                }
            }

            if(notifyPopulate) {
                BeanContextLifecycleEvent event = new BeanContextLifecycleEvent(executionContext, source, BeanLifecycle.POPULATE, beanId, bean);
                executionContext.getBeanContext().notifyObservers(event);
            }
        } catch (IllegalAccessException e) {
            throw new SmooksConfigurationException("Error invoking bean setter method [" + ClassUtil.toSetterName(property) + "] on bean instance class type [" + bean.getClass() + "].", e);
        } catch (InvocationTargetException e) {
View Full Code Here

      BeanRouter beanRouter = createBeanRouter(null, BEAN_ID, END_POINT_URI);
      beanRouter.executeExecutionLifecycleInitialize(execContext);
        execContext.getBeanContext().addBean(BEAN_ID, myBean);

        // Force an END event
        execContext.getBeanContext().notifyObservers(new BeanContextLifecycleEvent(execContext,
                null, BeanLifecycle.END_FRAGMENT, execContext.getBeanContext().getBeanId(BEAN_ID), myBean));

      endpoint.assertIsSatisfied();
    }
View Full Code Here

      beanRouter.executeExecutionLifecycleInitialize(execContext);
        execContext.getBeanContext().addBean(BEAN_ID, myBean);
        execContext.getBeanContext().addBean(HEADER_ID, myBean);

        // Force an END event
        execContext.getBeanContext().notifyObservers(new BeanContextLifecycleEvent(execContext,
                null, BeanLifecycle.END_FRAGMENT, execContext.getBeanContext().getBeanId(BEAN_ID), myBean));

      endpoint.assertIsSatisfied();
    }
View Full Code Here

  }

    private void notifyStartBean(Fragment source, ExecutionContext executionContext) {
        BeanContext beanContext = executionContext.getBeanContext();

        beanContext.notifyObservers(new BeanContextLifecycleEvent(executionContext,
                source, BeanLifecycle.START_FRAGMENT, beanContext.getBeanId(bindTo), ""));
    }
View Full Code Here

    public void executeVisitLifecycleCleanup(Fragment fragment, ExecutionContext executionContext) {
        BeanContext beanContext = executionContext.getBeanContext();
        BeanId beanId = beanContext.getBeanId(bindTo);
        Object bean = beanContext.getBean(beanId);

        beanContext.notifyObservers(new BeanContextLifecycleEvent(executionContext, fragment, BeanLifecycle.END_FRAGMENT, beanId, bean));
        if(!retain) {
            executionContext.getBeanContext().removeBean(beanId, null);
        }
    }
View Full Code Here

        Object bean;
        BeanContext beanContext = executionContext.getBeanContext();

        bean = createBeanInstance(executionContext);

        executionContext.getBeanContext().notifyObservers(new BeanContextLifecycleEvent(executionContext,
                source, BeanLifecycle.START_FRAGMENT, beanId, bean));

        if(initValsExpression != null) {
          initValsExpression.exec(bean);
        }
View Full Code Here

TOP

Related Classes of org.milyn.javabean.lifecycle.BeanContextLifecycleEvent

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.