[Design of POJO Server] - Re: Scoping of war/jar file embedded in sar service archives
by adrian@jboss.org
Looks to me like you didn't build the jar in the testsuite, the line in error
is for when it doesn't find the file.
JBossTestServices is trying to create a url for
c:\foo\bar\jboss-head\testsuite\output\lib\whatever.jar
and obviously getting confused. ;-)
It should be creating the url as
file:///c:/foo/bar/jboss-head/testsuite/output/lib/whatever.jar
|
| /**
| * Returns the deployment directory to use. This does it's best to figure out
| * where you are looking. If you supply a complete url, it returns it.
| * Otherwise, it looks for jbosstest.deploy.dir or if missing output/lib. Then it
| * tries to construct a file url or a url.
| *
| * @param filename name of the file/url you want
| * @return A URL
| * @exception MalformedURLException Description of Exception
| */
| protected URL getDeployURL(final String filename)
| throws MalformedURLException
| {
| // First see if it is already a complete url.
| try
| {
| return new URL(filename);
| }
| catch (MalformedURLException e)
| {
| log.debug(filename + " is not a valid URL, " + e.getMessage());
| }
|
| // OK, lets see if we can figure out what it might be.
| String deployDir = System.getProperty("jbosstest.deploy.dir");
| if (deployDir == null)
| {
| deployDir = "output/lib";
| }
| String url = deployDir + "/" + filename;
| log.debug("Testing file: " + url);
| // try to canonicalize the strings a bit.
| File file = new File(url);
| if (file.exists())
| {
| log.debug(file.getAbsolutePath() + " is a valid file");
| return file.toURL();
| }
| else
| {
| log.debug("File does not exist, creating url: " + url);
| return new URL(url); // HERE !!!!!!!!!!!!!!!!!!!!!!!!
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164747#4164747
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164747
17 years, 8 months
[Design the new POJO MicroContainer] - Re: Temp include/exclude filter set in Module
by adrian@jboss.org
Isn't this just missing a check for whether to recurse into a virtual file?
| Index: classloading-vfs/src/main/org/jboss/classloading/plugins/vfs/VFSResourceVisitor.java
| ===================================================================
| --- classloading-vfs/src/main/org/jboss/classloading/plugins/vfs/VFSResourceVisitor.java (revision 75758)
| +++ classloading-vfs/src/main/org/jboss/classloading/plugins/vfs/VFSResourceVisitor.java (working copy)
| @@ -145,6 +145,10 @@
|
| public boolean accepts(VirtualFile file)
| {
| + ResourceContext ctx = new ResourceContext(file.toURL(), file.getName(), classLoader);
| + if (filter.accepts(ctx) == false)
| + return false;
| +
| // This is our current root
| if (file.equals(root))
| return true;
|
|
For was of use it might be better to create a specific api
so people can use the simple filter for accept things like .class files
and a seperate api for which directories/jars to enter
| Index: classloading-vfs/src/main/org/jboss/classloading/plugins/vfs/VFSResourceVisitor.java
| ===================================================================
| --- classloading-vfs/src/main/org/jboss/classloading/plugins/vfs/VFSResourceVisitor.java (revision 75758)
| +++ classloading-vfs/src/main/org/jboss/classloading/plugins/vfs/VFSResourceVisitor.java (working copy)
| @@ -145,6 +145,10 @@
|
| public boolean accepts(VirtualFile file)
| {
| + ResourceContext ctx = new ResourceContext(file.toURL(), file.getName(), classLoader);
| + if (filter.isRecurse(ctx) == false)
| + return false;
| +
| // This is our current root
| if (file.equals(root))
| return true;
| Index: classloading/src/main/org/jboss/classloading/spi/visitor/ResourceFilter.java
| ===================================================================
| --- classloading/src/main/org/jboss/classloading/spi/visitor/ResourceFilter.java (revision 75758)
| +++ classloading/src/main/org/jboss/classloading/spi/visitor/ResourceFilter.java (working copy)
| @@ -36,4 +36,12 @@
| * @return true to visit the resource
| */
| boolean accepts(ResourceContext resource);
| +
| + /**
| + * Controls whether to recurse into a particular resource
| + *
| + * @param resource the resource context
| + * @return true to recurse into the resource
| + */
| + boolean isRecurse(ResourceContext resource);
| }
|
Or for even better ease of use it is probably better to split the two types of filtering
classloading/src/main/org/jboss/classloading/spi/dependency/Module.java
| /**
| * Visit the resources in this module using the given filter(s)
| *
| * Typically the filter is used to determine which types of files to visit, e.g. .class files
| * while the recurseFilter determines which jars/directories to recurse into
| *
| * @param visitor the visitor
| * @param filter the filter
| * @param recurseFilter the recursion filter (null means recurse into everything)
| */
| public void visit(ResourceVisitor visitor, ResourceFilter filter, ResourceFilter recurseFilter)
| {
| throw new UnsupportedOperationException("The module " + getContextName() + " does not support filtering: " + getClass().getName());
| }
|
The last two code snippets are just "ease of use" so a filter can concentrate
on "doing one thing well" and different filters can be mixed and matched for
different purposes. The filter implementation could do this itself.
It is the checking for recursion in VFSResourceVisitor.accepts() that is missing
(the first patch).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164735#4164735
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164735
17 years, 8 months
[Design of POJO Server] - Re: Scoping of war/jar file embedded in sar service archives
by alesj
"scott.stark(a)jboss.org" wrote : Yes, the issue is JBAS-5773 and the test which shows the behavior using the staticarray.sar with:
|
| staticarray1.jar
| staticarray2.jar
| staticarray-web1.war referring to staticarray1.jar via a classpath entry
| staticarray-web2.war referring staticarray2.jar and staticarray1.jar via a classpath entry
|
| I'll create a deployers issue as well for the WARStructure change.
I get this when running smoke-tests on my Winz machine:
| <testcase classname="org.jboss.test.classloader.test.ScopingUnitTestCase" name="testNestedWarManifest" time="2.453">
| <error message="unknown protocol: c" type="java.net.MalformedURLException">java.net.MalformedURLException: unknown protocol: c
| at java.net.URL.<init>(URL.java:574)
| at java.net.URL.<init>(URL.java:464)
| at java.net.URL.<init>(URL.java:413)
| at org.jboss.test.JBossTestServices.getDeployURL(JBossTestServices.java:211)
| at org.jboss.test.JBossTestServices.undeploy(JBossTestServices.java:352)
| at org.jboss.test.JBossTestCase.undeploy(JBossTestCase.java:276)
| at org.jboss.test.classloader.test.ScopingUnitTestCase.testNestedWarManifest(ScopingUnitTestCase.java:255)
|
I doubt it's related to me running trunk/snapshot versions of VFS and Deployers.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164724#4164724
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164724
17 years, 8 months
[Design the new POJO MicroContainer] - Temp include/exclude filter set in Module
by alesj
To be able to dynamically (per deployment unit) filter out which resources we check in Module::visit, I need some extension/hook to the current code.
The issue came up here, where the user explicitly doesn't want to check some apps libs:
- http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164690#4164690
I was thinking of something in this way - in my GenericAnnotationDeployer:
| private ResourceFilter resourceFilter;
| private ClassFilter includedFilter;
| private ClassFilter excludedFilter;
|
| /**
| * Get filter.
| * Try attachment first, then deployer's filter.
| *
| * @param unit the deployment unit
| * @param expectedClass the expected class
| * @param suffix the suffix
| * @param defaultValue the default value
| * @return found filter or null
| */
| protected static <T> T getFilter(DeploymentUnit unit, Class<T> expectedClass, String suffix, T defaultValue)
| {
| String name = expectedClass.getName() + "." + (suffix != null ? suffix : "");
| T result = unit.getAttachment(name, expectedClass);
| if (result == null)
| result = defaultValue;
| return result;
| }
|
| protected GenericAnnotationResourceVisitor createGenericAnnotationResourceVisitor(DeploymentUnit unit, ClassPool pool, ClassLoader classLoader)
| {
| GenericAnnotationResourceVisitor visitor = super.createGenericAnnotationResourceVisitor(unit, pool, classLoader);
| ResourceFilter filter = getFilter(unit, ResourceFilter.class, null, resourceFilter);
| if (filter != null)
| visitor.setResourceFilter(filter);
| return visitor;
| }
|
| protected Module prepareModule(DeploymentUnit unit, Module original)
| {
| ClassFilter included = getFilter(unit, ClassFilter.class, "included", includedFilter);
| ClassFilter excluded = getFilter(unit, ClassFilter.class, "excluded", excludedFilter);
| // TODO - temp set this two
| return super.prepareModule(unit, original);
| }
|
Since actual Module::visit is implemented in some impl detail class, I cannot do this via delegation/wrapper pattern, since I cannot override/delegate all the needed methods to underlying Module.
What can/should be done?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164716#4164716
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164716
17 years, 8 months