Search in sources :

Example 1 with SymbolSource

use of org.apache.tapestry5.ioc.services.SymbolSource in project flowlogix by flowlogix.

the class TapestryRemoteServiceServlet method doGetSerializationPolicy.

@Override
protected SerializationPolicy doGetSerializationPolicy(HttpServletRequest request, String moduleBaseURL, String strongName) {
    final SymbolSource symbolSource = ExternalServiceUtil.getTapestryService(getServletContext(), SymbolSource.class);
    final String prefix = symbolSource.valueForSymbol(SymbolConstants.ASSET_PATH_PREFIX);
    final AssetPathProcessor pathProcessor = new AssetPathProcessor(prefix);
    return super.doGetSerializationPolicy(request, pathProcessor.removeAssetPathPart(moduleBaseURL), strongName);
}
Also used : SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) AssetPathProcessor(com.flowlogix.web.services.internal.AssetPathProcessor)

Example 2 with SymbolSource

use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.

the class AssetSourceImplTest method get_expanded_asset.

@Test
public void get_expanded_asset() {
    AssetFactory factory = mockAssetFactory();
    Asset asset = mockAsset();
    SymbolSource symbolSource = mockSymbolSource();
    Resource expectedResource = baseResource.forFile("SimpleComponent.properties");
    train_getRootResource(factory, rootResource);
    train_createAsset(factory, expectedResource, asset);
    train_expandSymbols(symbolSource, "${path}/SimpleComponent.properties", "org/apache/tapestry5/internal/services/SimpleComponent.properties");
    Map<String, AssetFactory> configuration = Collections.singletonMap("classpath", factory);
    replay();
    AssetSource source = new AssetSourceImpl(null, configuration, symbolSource, null, tracker);
    // First try creates it:
    assertSame(source.getExpandedAsset("${path}/SimpleComponent.properties"), asset);
    verify();
}
Also used : AssetSource(org.apache.tapestry5.services.AssetSource) SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) Resource(org.apache.tapestry5.commons.Resource) ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) Asset(org.apache.tapestry5.Asset) AssetFactory(org.apache.tapestry5.services.AssetFactory) Test(org.testng.annotations.Test)

Example 3 with SymbolSource

use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.

the class TapestryAppInitializer method announceStartup.

/**
 * Announce application startup, by logging (at INFO level) the names of all pages,
 * components, mixins and services.
 */
public void announceStartup() {
    if (// if info logging is off we can stop now
    !logger.isInfoEnabled()) {
        return;
    }
    long toFinish = System.currentTimeMillis();
    SymbolSource source = registry.getService("SymbolSource", SymbolSource.class);
    StringBuilder buffer = new StringBuilder("Startup status:\n\nServices:\n\n");
    Formatter f = new Formatter(buffer);
    int unrealized = 0;
    ServiceActivityScoreboard scoreboard = registry.getService(ServiceActivityScoreboard.class);
    List<ServiceActivity> serviceActivity = scoreboard.getServiceActivity();
    int longest = 0;
    for (ServiceActivity activity : serviceActivity) {
        Status status = activity.getStatus();
        longest = Math.max(longest, activity.getServiceId().length());
        if (status == Status.DEFINED || status == Status.VIRTUAL)
            unrealized++;
    }
    String formatString = "%" + longest + "s: %s\n";
    for (ServiceActivity activity : serviceActivity) {
        f.format(formatString, activity.getServiceId(), activity.getStatus().name());
    }
    f.format("\n%4.2f%% unrealized services (%d/%d)\n", 100. * unrealized / serviceActivity.size(), unrealized, serviceActivity.size());
    f.format("\nApplication '%s' (version %s) startup time: %,d ms to build IoC Registry, %,d ms overall.", appName, source.valueForSymbol(TapestryHttpSymbolConstants.APPLICATION_VERSION), registryCreatedTime - startTime, toFinish - startTime);
    String version = source.valueForSymbol(TapestryHttpSymbolConstants.TAPESTRY_VERSION);
    boolean productionMode = Boolean.parseBoolean(source.valueForSymbol(TapestryHttpSymbolConstants.PRODUCTION_MODE));
    buffer.append("\n\n");
    buffer.append(" ______                  __             ____\n");
    buffer.append("/_  __/__ ____  ___ ___ / /_______ __  / __/\n");
    buffer.append(" / / / _ `/ _ \\/ -_|_-</ __/ __/ // / /__ \\ \n");
    buffer.append("/_/  \\_,_/ .__/\\__/___/\\__/_/  \\_, / /____/\n");
    f.format("        /_/                   /___/  %s%s\n\n", version, productionMode ? "" : " (development mode)");
    // log multi-line string with OS-specific line endings (TAP5-2294)
    logger.info(buffer.toString().replaceAll("\\n", System.getProperty("line.separator")));
}
Also used : Status(org.apache.tapestry5.ioc.services.Status) SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) Formatter(java.util.Formatter) ServiceActivityScoreboard(org.apache.tapestry5.ioc.services.ServiceActivityScoreboard) ServiceActivity(org.apache.tapestry5.ioc.services.ServiceActivity)

Example 4 with SymbolSource

use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.

the class MetaDataLocatorImplTest method not_found_by_page_name_but_found_in_configuration.

@Test
public void not_found_by_page_name_but_found_in_configuration() {
    ComponentModel model = mockComponentModel();
    SymbolSource symbolSource = mockSymbolSource();
    ComponentModelSource modelSource = mockComponentModelSource();
    String key = "foo.bar";
    String value = "zaphod";
    String pageName = "gnip/Gnop";
    expect(modelSource.getPageModel(pageName)).andReturn(model);
    train_getMeta(model, key, null);
    train_expandSymbols(symbolSource, value, "*expanded*");
    replay();
    Map<String, String> configuration = CollectionFactory.newMap();
    configuration.put("gnip:foo.bar", value);
    MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
    assertSame(locator.findMeta(key, pageName, String.class), "*expanded*");
    verify();
}
Also used : SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) ComponentModel(org.apache.tapestry5.model.ComponentModel) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Example 5 with SymbolSource

use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.

the class MetaDataLocatorImplTest method find_by_page_name.

@Test
public void find_by_page_name() {
    ComponentModel model = mockComponentModel();
    SymbolSource symbolSource = mockSymbolSource();
    ComponentModelSource modelSource = mockComponentModelSource();
    String key = "foo.bar";
    String value = "zaphod";
    String pageName = "foo/Bar";
    expect(modelSource.getPageModel(pageName)).andReturn(model);
    train_getMeta(model, key, value);
    train_expandSymbols(symbolSource, value, "*expanded*");
    replay();
    Map<String, String> configuration = Collections.emptyMap();
    MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
    assertSame(locator.findMeta(key, pageName, String.class), "*expanded*");
    verify();
}
Also used : SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) ComponentModel(org.apache.tapestry5.model.ComponentModel) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) Test(org.testng.annotations.Test)

Aggregations

SymbolSource (org.apache.tapestry5.ioc.services.SymbolSource)15 Test (org.testng.annotations.Test)13 ComponentModel (org.apache.tapestry5.model.ComponentModel)9 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)9 ComponentResources (org.apache.tapestry5.ComponentResources)7 Asset (org.apache.tapestry5.Asset)3 AssetSource (org.apache.tapestry5.services.AssetSource)3 AnnotationProvider (org.apache.tapestry5.commons.AnnotationProvider)2 ObjectLocator (org.apache.tapestry5.commons.ObjectLocator)2 ObjectProvider (org.apache.tapestry5.commons.ObjectProvider)2 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)2 AssetPathProcessor (com.flowlogix.web.services.internal.AssetPathProcessor)1 Formatter (java.util.Formatter)1 ServletContext (javax.servlet.ServletContext)1 Path (org.apache.tapestry5.annotations.Path)1 Resource (org.apache.tapestry5.commons.Resource)1 SymbolBeanFactoryPostProcessor (org.apache.tapestry5.internal.spring.SymbolBeanFactoryPostProcessor)1 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)1 ClasspathResource (org.apache.tapestry5.ioc.internal.util.ClasspathResource)1 ServiceActivity (org.apache.tapestry5.ioc.services.ServiceActivity)1