Package org.springframework.osgi.extender.support

Examples of org.springframework.osgi.extender.support.ApplicationContextConfiguration


    // executor used for creating the appCtx
    // chosen based on the sync/async configuration
    TaskExecutor executor = null;

    ApplicationContextConfiguration config = new ApplicationContextConfiguration(bundle);

    String creationType;

    // synch/asynch context creation
    if (config.isCreateAsynchronously()) {
      // for the async stuff use the executor
      executor = taskExecutor;
      creationType = "Asynchronous";
    }
    else {
      // for the sync stuff, use this thread
      executor = sameThreadTaskExecutor;
      creationType = "Synchronous";
    }

    if (debug) {
      log.debug(creationType + " context creation for bundle " + bundleString);
    }

    // wait/no wait for dependencies behaviour
    if (config.isWaitForDependencies()) {
      DependencyWaiterApplicationContextExecutor appCtxExecutor = new DependencyWaiterApplicationContextExecutor(
        localApplicationContext, !config.isCreateAsynchronously(),
        extenderConfiguration.getDependencyFactories());

      appCtxExecutor.setTimeout(config.getTimeout());
      appCtxExecutor.setWatchdog(timer);
      appCtxExecutor.setTaskExecutor(executor);
      appCtxExecutor.setMonitoringCounter(contextsStarted);
      // set events publisher
      appCtxExecutor.setDelegatedMulticaster(this.multicaster);
View Full Code Here


    // executor used for creating the appCtx
    // chosen based on the sync/async configuration
    TaskExecutor executor = null;

    ApplicationContextConfiguration config = new ApplicationContextConfiguration(bundle);

    String creationType;

    // synch/asynch context creation
    if (config.isCreateAsynchronously()) {
      // for the async stuff use the executor
      executor = taskExecutor;
      creationType = "Asynchronous";
    }
    else {
      // for the sync stuff, use this thread
      executor = sameThreadTaskExecutor;
      creationType = "Synchronous";
    }

    if (debug) {
      log.debug(creationType + " context creation for bundle " + bundleString);
    }

    // wait/no wait for dependencies behaviour
    if (config.isWaitForDependencies()) {
      DependencyWaiterApplicationContextExecutor appCtxExecutor = new DependencyWaiterApplicationContextExecutor(
        localApplicationContext, !config.isCreateAsynchronously(),
        extenderConfiguration.getDependencyFactories());

      long timeout;
      // check whether a timeout has been defined

      if (ConfigUtils.isDirectiveDefined(bundle.getHeaders(), ConfigUtils.DIRECTIVE_TIMEOUT)) {
        timeout = config.getTimeout();
        if (debug)
          log.debug("Setting bundle-defined, wait-for-dependencies timeout value=" + timeout
              + " ms, for bundle " + bundleString);

      }
      else {
        timeout = extenderConfiguration.getDependencyWaitTime();
        if (debug)
          log.debug("Setting globally defined wait-for-dependencies timeout value=" + timeout
              + " ms, for bundle " + bundleString);
      }

      appCtxExecutor.setTimeout(config.getTimeout());

      appCtxExecutor.setWatchdog(timer);
      appCtxExecutor.setTaskExecutor(executor);
      appCtxExecutor.setMonitoringCounter(contextsStarted);
      // set events publisher
View Full Code Here

      "file://META-INF/spring/context-two.xml" };

  public void testBundleWithNoHeaderAndNoMetaInfSpringResourcesIsNotSpringPowered() {
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setResultsToReturnOnNextCallToFindEntries(null);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertFalse("bundle is not spring powered", config.isSpringPoweredBundle());
  }
View Full Code Here

  }

  public void testBundleWithSpringResourcesAndNoHeaderIsSpringPowered() {
    EntryLookupControllingMockBundle aBundle = new RepeatingEntryLookupControllingMockBundle(null);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle is spring powered", config.isSpringPoweredBundle());
  }
View Full Code Here

    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "META-INF/spring/context.xml");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(null);
    aBundle.setEntryReturnOnNextCallToGetEntry(new URL("file://META-INF/spring/context.xml"));
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle is spring powered", config.isSpringPoweredBundle());
  }
View Full Code Here

  }

  public void testBundleWithNoHeaderShouldWaitFiveMinutes() {
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertEquals("bundle should timeout in five minutes", new Long(5 * 60 * 1000), new Long(config.getTimeout()));
  }
View Full Code Here

  public void testBundleWithWaitFiveSecondWaitForTimeout() {
    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "*;timeout:=5");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
    assertEquals("bundle should timeout in 5 s", new Long(5 * 1000), new Long(config.getTimeout()));
  }
View Full Code Here

    // *;flavour
    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "*;timeout:=none");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
    assertEquals("bundle should timeout -2 (indicates forever)", new Long(-2), new Long(config.getTimeout()));
  }
View Full Code Here

  }

  public void tstConfigLocationsInMetaInfNoHeader() {
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    String[] configFiles = config.getConfigurationLocations();
    assertEquals("0 config files", 0, configFiles.length);
    // assertEquals("bundle-url:file://META-INF/spring/context.xml",
    // configFiles[0]);
    // assertEquals("bundle-url:file://META-INF/spring/context-two.xml",
    // configFiles[1]);
View Full Code Here

    Dictionary headers = new Hashtable();
    headers.put("Spring-Context", "META-INF/spring/context.xml");
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setResultsToReturnOnNextCallToFindEntries(META_INF_SPRING_CONTENT);
    aBundle.setEntryReturnOnNextCallToGetEntry(new URL("file://META-INF/spring/context.xml"));
    ApplicationContextConfiguration config = new ApplicationContextConfiguration(aBundle);
    String[] configFiles = config.getConfigurationLocations();
    assertTrue("bundle should be Spring powered", config.isSpringPoweredBundle());
    assertEquals("osgibundle:META-INF/spring/context.xml", configFiles[0]);
  }
View Full Code Here

TOP

Related Classes of org.springframework.osgi.extender.support.ApplicationContextConfiguration

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.