Examples of LifecycleBean


Examples of org.springframework.tests.sample.beans.LifecycleBean

    ServletContextEvent event = new ServletContextEvent(sc);
    listener.contextInitialized(event);
    WebApplicationContext context = (WebApplicationContext) sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    assertTrue("Correct WebApplicationContext exposed in ServletContext", context instanceof XmlWebApplicationContext);
    assertTrue(WebApplicationContextUtils.getRequiredWebApplicationContext(sc) instanceof XmlWebApplicationContext);
    LifecycleBean lb = (LifecycleBean) context.getBean("lifecycle");
    assertTrue("Has father", context.containsBean("father"));
    assertTrue("Has rod", context.containsBean("rod"));
    assertTrue("Has kerry", context.containsBean("kerry"));
    assertTrue("Not destroyed", !lb.isDestroyed());
    assertFalse(context.containsBean("beans1.bean1"));
    assertFalse(context.containsBean("beans1.bean2"));
    listener.contextDestroyed(event);
    assertTrue("Destroyed", lb.isDestroyed());
    assertNull(sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
    assertNull(WebApplicationContextUtils.getWebApplicationContext(sc));
  }

Examples of org.springframework.tests.sample.beans.LifecycleBean

    ServletContextEvent event = new ServletContextEvent(sc);
    listener.contextInitialized(event);
    WebApplicationContext context = (WebApplicationContext) sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    assertTrue("Correct WebApplicationContext exposed in ServletContext",
        context instanceof XmlWebApplicationContext);
    LifecycleBean lb = (LifecycleBean) context.getBean("lifecycle");
    assertTrue("Has father", context.containsBean("father"));
    assertTrue("Has rod", context.containsBean("rod"));
    assertTrue("Has kerry", context.containsBean("kerry"));
    assertTrue("Not destroyed", !lb.isDestroyed());
    assertTrue(context.containsBean("beans1.bean1"));
    assertTrue(context.isTypeMatch("beans1.bean1", org.springframework.beans.factory.access.TestBean.class));
    assertTrue(context.containsBean("beans1.bean2"));
    assertTrue(context.isTypeMatch("beans1.bean2", org.springframework.beans.factory.access.TestBean.class));
    listener.contextDestroyed(event);
    assertTrue("Destroyed", lb.isDestroyed());
  }

Examples of org.springframework.tests.sample.beans.LifecycleBean

  /**
   * Test that InitializingBean/BeanFactoryAware/DisposableBean objects receive the
   * afterPropertiesSet() callback before BeanFactoryAware callbacks
   */
  public void testLifecycleCallbacks() {
    LifecycleBean lb = (LifecycleBean) getBeanFactory().getBean("lifecycle");
    assertEquals("lifecycle", lb.getBeanName());
    // The dummy business method will throw an exception if the
    // necessary callbacks weren't invoked in the right order.
    lb.businessMethod();
    assertTrue("Not destroyed", !lb.isDestroyed());
  }

Examples of org.wso2.carbon.governance.custom.lifecycles.checklist.beans.LifecycleBean

    private static Map<String, Boolean> lifecycleAspects = new HashMap<String, Boolean>();

    public static LifecycleBean getLifecycleBean(String path, UserRegistry registry,
                                                 Registry systemRegistry) throws Exception {

        LifecycleBean lifecycleBean;
        ResourcePath resourcePath = new ResourcePath(path);

        try {
            Resource resource = registry.get(path);
            if (resource != null) {
                lifecycleBean = new LifecycleBean();
                lifecycleBean.setMediaType(resource.getMediaType());

                if (resource.getProperty("registry.link") != null &&
                        resource.getProperty("registry.mount") == null) {
                    lifecycleBean.setLink(true);
                    return lifecycleBean;
                }
                if (resource.getProperty("registry.mount") != null) {
                    lifecycleBean.setMounted(true);
                }
                List<String> aspects = resource.getAspects();

                if (aspects != null) {
                    LifecycleActions[] actions = new LifecycleActions[aspects.size()];

                    for (int i = 0; i < actions.length; i++) {
                        String aspect = aspects.get(i);

                        String[] aspectActions = registry.getAspectActions(resourcePath.getPath(), aspect);
                        if (aspectActions == null) continue;

                        LifecycleActions lifecycleActionsEntry = new LifecycleActions();
                        lifecycleActionsEntry.setLifecycle(aspect);
                        lifecycleActionsEntry.setActions(aspectActions);
                        actions[i] = lifecycleActionsEntry;
                    }

                    lifecycleBean.setAvailableActions(actions);
                }

                String[] aspectsToAdd = registry.getAvailableAspects();

                List<String> lifecycleAspectsToAdd = new LinkedList<String>();
                if (aspectsToAdd != null) {
                    boolean isTransactionStarted = false;
                    String tempResourcePath = "/governance/lcm/" + UUIDGenerator.generateUUID();
                    for (String aspectToAdd : aspectsToAdd) {
                        if (systemRegistry.getRegistryContext().isReadOnly()) {
                            lifecycleAspectsToAdd.add(aspectToAdd);
                            continue;
                        }
                        Boolean isLifecycleAspect = lifecycleAspects.get(aspectToAdd);
                        if (isLifecycleAspect == null) {
                            if (!isTransactionStarted) {
                                systemRegistry.beginTransaction();
                                isTransactionStarted = true;
                            }
                            systemRegistry.put(tempResourcePath, systemRegistry.newResource());
                            systemRegistry.associateAspect(tempResourcePath, aspectToAdd);
                            Resource r  = systemRegistry.get(tempResourcePath);
                            Properties props = r.getProperties();
                            Set keys  = props.keySet();
                            for (Object key : keys) {
                                String propKey = (String) key;
                                if (propKey.startsWith("registry.lifecycle.")
                                        || propKey.startsWith("registry.custom_lifecycle.checklist.")) {
                                    isLifecycleAspect = Boolean.TRUE;
                                    break;
                                }
                            }
                            if (isLifecycleAspect == null) {
                                isLifecycleAspect = Boolean.FALSE;
                            }
                            lifecycleAspects.put(aspectToAdd, isLifecycleAspect);
                        }
                        if (isLifecycleAspect) {
                            lifecycleAspectsToAdd.add(aspectToAdd);
                        }
                    }
                    if (isTransactionStarted) {
                        systemRegistry.delete(tempResourcePath);
                        systemRegistry.rollbackTransaction();
                    }
                }
                lifecycleBean.setAspectsToAdd(lifecycleAspectsToAdd.toArray(
                        new String[lifecycleAspectsToAdd.size()]));

                resource = registry.get(path);
                Properties props = resource.getProperties();
                List<Property> propList = new ArrayList<Property>();
                Iterator iKeys = props.keySet().iterator();
                while (iKeys.hasNext()) {
                    String propKey = (String) iKeys.next();

                    if (propKey.startsWith("registry.lifecycle.")
//                            || propKey.equals(Aspect.AVAILABLE_ASPECTS)
                            || propKey.startsWith("registry.custom_lifecycle.checklist.") ){
//                            || propKey.startsWith("registry.custom_lifecycle.js.")) {
                        Property property = new Property();
                        property.setKey(propKey);
                        List<String> propValues = (List<String>) props.get(propKey);
                        property.setValues(propValues.toArray(new String[propValues.size()]));
                        propList.add(property);
                    }
                }

                lifecycleBean.setLifecycleProperties(propList.toArray(new Property[propList.size()]));

                lifecycleBean.setPathWithVersion(resourcePath.getPathWithVersion());
                lifecycleBean.setVersionView(!resourcePath.isCurrentVersion());
                lifecycleBean.setPutAllowed(
                        UserUtil.isPutAllowed(registry.getUserName(), resourcePath.getPath(), registry));
                lifecycleBean.setLoggedIn(!RegistryConstants.ANONYMOUS_USER.equals(registry.getUserName()));
                lifecycleBean.setShowAddDelete(!"application/vnd.wso2-service+xml".equals(resource.getMediaType()));
                resource.discard();
            }
            else {
                lifecycleBean = null;
            }

Examples of org.wso2.carbon.governance.lcm.stub.beans.xsd.LifecycleBean

        return output;
    }

    public LifecycleBean getLifeCycleBean(HttpServletRequest request) throws Exception  {
        String lifecycleName = request.getParameter("lifecycleName");
        LifecycleBean output;
        try {
//            output = stub.getLifecycleBean(lifecycleName);
        } catch (Exception e) {
            if (e instanceof RegistryException) {
                return null;
TOP
Copyright © 2018 www.massapi.com. 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.