Search in sources :

Example 1 with LibraryMapping

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;
}
Also used : ComponentLibraryInfo(org.apache.tapestry5.services.ComponentLibraryInfo) InputStream(java.io.InputStream)

Example 2 with LibraryMapping

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;
}
Also used : ArrayList(java.util.ArrayList) LibraryMapping(org.apache.tapestry5.services.LibraryMapping) Cached(org.apache.tapestry5.annotations.Cached)

Example 3 with LibraryMapping

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());
}
Also used : JSONObject(org.apache.tapestry5.json.JSONObject) ComponentLibraryInfo(org.apache.tapestry5.services.ComponentLibraryInfo) TextStreamResponse(org.apache.tapestry5.util.TextStreamResponse) LibraryMapping(org.apache.tapestry5.services.LibraryMapping) OnEvent(org.apache.tapestry5.annotations.OnEvent)

Example 4 with LibraryMapping

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));
}
Also used : LibraryMapping(org.apache.tapestry5.services.LibraryMapping) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Aggregations

LibraryMapping (org.apache.tapestry5.services.LibraryMapping)3 ComponentLibraryInfo (org.apache.tapestry5.services.ComponentLibraryInfo)2 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Cached (org.apache.tapestry5.annotations.Cached)1 OnEvent (org.apache.tapestry5.annotations.OnEvent)1 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)1 JSONObject (org.apache.tapestry5.json.JSONObject)1 TextStreamResponse (org.apache.tapestry5.util.TextStreamResponse)1