use of org.apache.tapestry5.services.LibraryMapping in project tapestry-5 by apache.
the class MavenComponentLibraryInfoSource method find.
@Override
public ComponentLibraryInfo find(LibraryMapping libraryMapping) {
ComponentLibraryInfo info = null;
if (cache.containsKey(libraryMapping.libraryName)) {
info = cache.get(libraryMapping.libraryName);
} else {
final String pomPath = getPomPath(libraryMapping);
if (pomPath != null) {
InputStream inputStream = getClass().getResourceAsStream("/" + pomPath);
info = parse(inputStream);
info.setLibraryMapping(libraryMapping);
cache.put(libraryMapping.libraryName, info);
} else {
cache.put(libraryMapping.libraryName, null);
}
}
return info;
}
use of org.apache.tapestry5.services.LibraryMapping in project tapestry-5 by apache.
the class ComponentLibraries method getLibraryMappings.
@Cached
public List<LibraryMapping> getLibraryMappings() {
List<LibraryMapping> mappings = new ArrayList<LibraryMapping>();
// add all the library mappings, except the "" (empty string) one.
for (LibraryMapping libraryMapping : componentClassResolver.getLibraryMappings()) {
if (!"".equals(libraryMapping.libraryName)) {
mappings.add(libraryMapping);
}
}
Collections.sort(mappings, LIBRARY_MAPPING_COMPARATOR);
return mappings;
}
use of org.apache.tapestry5.services.LibraryMapping in project tapestry-5 by apache.
the class ComponentLibraries method generateJSONDescription.
@OnEvent("json")
Object generateJSONDescription(String libraryName) {
for (LibraryMapping mapping : componentClassResolver.getLibraryMappings()) {
if (libraryName.equalsIgnoreCase(mapping.libraryName)) {
this.libraryMapping = mapping;
break;
}
}
JSONObject object = new JSONObject();
object.put("libraryName", libraryName);
object.put("rootPackage", libraryMapping.getRootPackage());
final ComponentLibraryInfo info = getInfo();
if (info != null) {
JSONObject infoJsonObject = new JSONObject();
putIfNotNull("description", info.getDescription(), infoJsonObject);
putIfNotNull("homepage", info.getHomepageUrl(), infoJsonObject);
putIfNotNull("documentationUrl", info.getDocumentationUrl(), infoJsonObject);
putIfNotNull("javadocUrl", info.getJavadocUrl(), infoJsonObject);
putIfNotNull("groupId", info.getGroupId(), infoJsonObject);
putIfNotNull("artifactId", info.getArtifactId(), infoJsonObject);
putIfNotNull("version", info.getVersion(), infoJsonObject);
putIfNotNull("sourceBrowseUrl", info.getSourceBrowseUrl(), infoJsonObject);
putIfNotNull("sourceRootUrl", info.getSourceRootUrl(), infoJsonObject);
putIfNotNull("issueTrackerUrl", info.getIssueTrackerUrl(), infoJsonObject);
putIfNotNull("dependencyInfoUrl", info.getDependencyManagementInfoUrl(), infoJsonObject);
if (info.getTags() != null) {
for (String tag : info.getTags()) {
infoJsonObject.accumulate("tags", tag);
}
}
object.put("info", infoJsonObject);
}
addClasses("components", filter(componentClassResolver.getComponentNames()), Type.COMPONENT, info, object);
addClasses("pages", filter(componentClassResolver.getPageNames()), Type.PAGE, info, object);
addClasses("mixins", filter(componentClassResolver.getMixinNames()), Type.MIXIN, info, object);
return new TextStreamResponse("text/javascript", object.toString());
}
use of org.apache.tapestry5.services.LibraryMapping in project tapestry-5 by apache.
the class TapestryModule method provideCoreAndAppLibraries.
@Contribute(ComponentClassResolver.class)
public static void provideCoreAndAppLibraries(Configuration<LibraryMapping> configuration, @Symbol(TapestryHttpInternalConstants.TAPESTRY_APP_PACKAGE_PARAM) String appRootPackage) {
configuration.add(new LibraryMapping(InternalConstants.CORE_LIBRARY, "org.apache.tapestry5.corelib"));
configuration.add(new LibraryMapping("", appRootPackage));
}
Aggregations