| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package net.sf.tacos.resolvers; |
| 18 |
|
|
| 19 |
|
import org.apache.hivemind.Resource; |
| 20 |
|
import org.apache.hivemind.impl.DefaultClassResolver; |
| 21 |
|
import org.apache.hivemind.impl.LocationImpl; |
| 22 |
|
import org.apache.hivemind.util.ClasspathResource; |
| 23 |
|
import org.apache.tapestry.INamespace; |
| 24 |
|
import org.apache.tapestry.IRequestCycle; |
| 25 |
|
import org.apache.tapestry.resolver.ISpecificationResolverDelegate; |
| 26 |
|
import org.apache.tapestry.services.ClassFinder; |
| 27 |
|
import org.apache.tapestry.spec.IComponentSpecification; |
| 28 |
|
import org.apache.tapestry.spec.ComponentSpecification; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
0 |
public class ClasspathSpecResolverDelegate implements ISpecificationResolverDelegate { |
| 36 |
|
private ClassFinder classFinder; |
| 37 |
|
|
| 38 |
|
public IComponentSpecification findComponentSpecification( |
| 39 |
|
IRequestCycle cycle, INamespace namespace, String name) { |
| 40 |
0 |
return null; |
| 41 |
|
} |
| 42 |
|
|
| 43 |
|
public IComponentSpecification findPageSpecification(IRequestCycle cycle, |
| 44 |
|
INamespace namespace, String name) { |
| 45 |
0 |
if (namespace.isApplicationNamespace()) { |
| 46 |
0 |
String packages = namespace |
| 47 |
|
.getPropertyValue("org.apache.tapestry.page-class-packages"); |
| 48 |
|
|
| 49 |
0 |
String className = name.replace('/', '.'); |
| 50 |
|
|
| 51 |
0 |
Class pageClass = classFinder.findClass(packages, className); |
| 52 |
|
|
| 53 |
0 |
if (pageClass == null) { |
| 54 |
0 |
return null; |
| 55 |
|
} |
| 56 |
0 |
String fullPath = pageClass.getName().replace('.', '/'); |
| 57 |
0 |
ClasspathResource html = new ClasspathResource(new DefaultClassResolver(), fullPath + ".html"); |
| 58 |
|
|
| 59 |
0 |
if (html.getResourceURL() != null) { |
| 60 |
0 |
return setupImplicitPage(namespace.getSpecificationLocation(), |
| 61 |
|
new ClasspathResource(new DefaultClassResolver(), fullPath + ".page")); |
| 62 |
|
} |
| 63 |
|
} |
| 64 |
0 |
return null; |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
private IComponentSpecification setupImplicitPage(Resource resource, Resource pageResource) { |
| 68 |
0 |
IComponentSpecification specification = new ComponentSpecification(); |
| 69 |
0 |
specification.setPageSpecification(true); |
| 70 |
0 |
specification.setSpecificationLocation(pageResource); |
| 71 |
0 |
specification.setLocation(new LocationImpl(resource)); |
| 72 |
|
|
| 73 |
0 |
return specification; |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
public void setClassFinder(ClassFinder classFinder) { |
| 77 |
0 |
this.classFinder = classFinder; |
| 78 |
0 |
} |
| 79 |
|
|
| 80 |
|
} |
| 81 |
|
|