Search in sources :

Example 1 with Description

use of org.apache.tapestry5.ioc.annotations.Description in project tapestry-5 by apache.

the class MavenComponentLibraryInfoSource method parse.

private ComponentLibraryInfo parse(InputStream inputStream) {
    ComponentLibraryInfo info = null;
    if (inputStream != null) {
        Document document;
        try {
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            document = documentBuilder.parse(inputStream);
        } catch (Exception e) {
            logger.warn("Exception while parsing pom.xml", e);
            return null;
        }
        info = new ComponentLibraryInfo();
        info.setGroupId(extractText(document, "(/project/groupId | /project/parent/groupId)[1]"));
        info.setArtifactId(extractText(document, "/project/artifactId"));
        info.setVersion(extractText(document, "/project/version"));
        info.setName(extractText(document, "/project/name"));
        info.setDescription(extractText(document, "/project/description"));
        info.setDocumentationUrl(extractText(document, "/project/properties/documentationUrl"));
        info.setHomepageUrl(extractText(document, "/project/properties/homepageUrl"));
        info.setIssueTrackerUrl(extractText(document, "/project/issueManagement/url"));
        info.setJavadocUrl(extractText(document, "/project/properties/javadocUrl"));
        info.setSourceBrowseUrl(extractText(document, "/project/scm/url"));
        info.setSourceRootUrl(extractText(document, "/project/properties/sourceRootUrl"));
        info.setTapestryVersion(extractText(document, "(/project/dependencies/dependency[./groupId='org.apache.tapestry'][./artifactId='tapestry-core']/version | /project/properties/tapestryVersion)[1]"));
        String tags = extractText(document, "/project/properties/tags");
        if (tags != null && tags.length() > 0) {
            info.setTags(Arrays.asList(tags.split(",")));
        }
    }
    return info;
}
Also used : DocumentBuilder(javax.xml.parsers.DocumentBuilder) ComponentLibraryInfo(org.apache.tapestry5.services.ComponentLibraryInfo) Document(org.w3c.dom.Document) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IOException(java.io.IOException)

Example 2 with Description

use of org.apache.tapestry5.ioc.annotations.Description in project tapestry-5 by apache.

the class BindingSourceImplTest method expression_has_no_prefix.

@Test
public void expression_has_no_prefix() {
    BindingFactory factory = mockBindingFactory();
    Binding binding = mockBinding();
    ComponentResources container = mockComponentResources();
    ComponentResources component = mockComponentResources();
    Location l = mockLocation();
    String defaultPrefix = "def";
    String description = "descrip";
    String expression = "full expression";
    train_newBinding(factory, description, container, component, expression, l, binding);
    replay();
    Map<String, BindingFactory> map = newMap();
    map.put(defaultPrefix, factory);
    BindingSource source = new BindingSourceImpl(map, interner);
    Binding actual = source.newBinding(description, container, component, defaultPrefix, expression, l);
    assertSame(actual, binding);
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) BindingSource(org.apache.tapestry5.services.BindingSource) BindingFactory(org.apache.tapestry5.services.BindingFactory) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 3 with Description

use of org.apache.tapestry5.ioc.annotations.Description in project tapestry-5 by apache.

the class BindingSourceImplTest method expression_prefix_not_in_configuration.

@Test
public void expression_prefix_not_in_configuration() {
    BindingFactory factory = mockBindingFactory();
    Binding binding = mockBinding();
    ComponentResources container = mockComponentResources();
    ComponentResources component = mockComponentResources();
    Location l = mockLocation();
    String defaultPrefix = "def";
    String description = "descrip";
    String expression = "javascript:not-a-known-prefix";
    train_newBinding(factory, description, container, component, expression, l, binding);
    replay();
    Map<String, BindingFactory> map = newMap();
    map.put(defaultPrefix, factory);
    BindingSource source = new BindingSourceImpl(map, interner);
    Binding actual = source.newBinding(description, container, component, defaultPrefix, expression, l);
    assertSame(actual, binding);
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) BindingSource(org.apache.tapestry5.services.BindingSource) BindingFactory(org.apache.tapestry5.services.BindingFactory) ComponentResources(org.apache.tapestry5.ComponentResources) Location(org.apache.tapestry5.commons.Location) Test(org.testng.annotations.Test)

Example 4 with Description

use of org.apache.tapestry5.ioc.annotations.Description in project tapestry-5 by apache.

the class BindingSourceImpl method newBinding.

public Binding newBinding(String description, ComponentResources container, ComponentResources component, String defaultPrefix, String expression, Location location) {
    assert InternalUtils.isNonBlank(description);
    assert container != null;
    assert InternalUtils.isNonBlank(defaultPrefix);
    assert component != null;
    // TAP5-845: The expression may be the empty string. This is ok, if it's compatible with
    // the default prefix (the empty string is not a valid property expression, but is valid
    // as a literal string, perhaps as an informal parameter).
    // Location might be null
    String subexpression = expression;
    int colonx = expression.indexOf(':');
    BindingFactory factory = null;
    if (colonx > 0) {
        String prefix = expression.substring(0, colonx);
        factory = factories.get(prefix);
        if (factory != null)
            subexpression = expression.substring(colonx + 1);
    }
    if (factory == null)
        factory = factories.get(defaultPrefix);
    try {
        return factory.newBinding(interner.intern(description), container, component, subexpression, location);
    } catch (Exception ex) {
        throw new TapestryException(String.format("Could not convert '%s' into a component parameter binding: %s", expression, ExceptionUtils.toMessage(ex)), location, ex);
    }
}
Also used : TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException) TapestryException(org.apache.tapestry5.commons.internal.util.TapestryException) BindingFactory(org.apache.tapestry5.services.BindingFactory)

Example 5 with Description

use of org.apache.tapestry5.ioc.annotations.Description in project tapestry-5 by apache.

the class PropBindingFactory method newBinding.

public Binding newBinding(String description, ComponentResources container, ComponentResources component, String expression, Location location) {
    Object target = container.getComponent();
    Class targetClass = target.getClass();
    PropertyConduit conduit = source.create(targetClass, expression);
    String toString = interner.format("PropBinding[%s %s(%s)]", description, container.getCompleteId(), expression);
    return new PropBinding(location, target, conduit, expression, toString);
}
Also used : PropertyConduit(org.apache.tapestry5.beanmodel.PropertyConduit)

Aggregations

JSONObject (org.apache.tapestry5.json.JSONObject)9 Binding (org.apache.tapestry5.Binding)6 ComponentResources (org.apache.tapestry5.ComponentResources)6 Location (org.apache.tapestry5.commons.Location)6 BindingFactory (org.apache.tapestry5.services.BindingFactory)6 Test (org.testng.annotations.Test)6 JSONArray (org.apache.tapestry5.json.JSONArray)4 BindingSource (org.apache.tapestry5.services.BindingSource)4 Logger (org.slf4j.Logger)4 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)3 ServiceResources (org.apache.tapestry5.ioc.ServiceResources)3 Method (java.lang.reflect.Method)2 RequestParameter (org.apache.tapestry5.annotations.RequestParameter)2 RestInfo (org.apache.tapestry5.annotations.RestInfo)2 PlasticMethod (org.apache.tapestry5.plastic.PlasticMethod)2 ComponentLibraryInfo (org.apache.tapestry5.services.ComponentLibraryInfo)2 IFn (clojure.lang.IFn)1 Symbol (clojure.lang.Symbol)1 IOException (java.io.IOException)1 ObjectStreamException (java.io.ObjectStreamException)1