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);
}
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();
}
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")));
}
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();
}
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();
}
Aggregations