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