[Design of POJO Server] - Re: VFS Permissions - JBMICROCONT-149
by anil.saldhana@jboss.com
"alesj" wrote : "alesj" wrote : "adrian(a)jboss.org" wrote :
| | | This requires something in the VFS, my suggestion was to add
| | | VFSUtils.getRealURL(vfsFile);
| | |
| | Should I hold off VFS 2.0.0.GA until these features get into VFS?
| I see Anil already added this to VFS.
| But it looks wrong. ;-)
|
|
| | /**
| | * Get the Real URL
| | * @param vfsURL
| | * @return
| | * @throws Exception
| | */
| | public static URL getRealURL(URL vfsURL) throws Exception
| | {
| | if(vfsURL.getPath().endsWith("jar"))
| | {
| | String urlStr = "jar:" + FILE_PROTOCOL + ":" + vfsURL.getPath() + JAR_URL_SEPARATOR;
| | return new URL(urlStr);
| | }
| |
| | if(vfsURL.getProtocol().startsWith("vfsfile"))
| | return new URL(FILE_PROTOCOL, vfsURL.getHost(), vfsURL.getPort(), vfsURL.getFile());
| |
| | if(vfsURL.getProtocol().startsWith("vfszip"))
| | {
| | String urlStr = vfsURL.toExternalForm();
| | //nested file
| | int indexJar = urlStr.indexOf(".jar");
| | String beforejar = urlStr.substring("vfszip:".length(), urlStr.indexOf(".jar"));
| | String afterjar = urlStr.substring(indexJar + 1 + ".jar".length());
| | return new URL("jar:file:" + beforejar + ".jar " + JAR_URL_SEPARATOR + afterjar);
| | }
| | if(log.isTraceEnabled())
| | log.trace("getRealURL did not have a match for:"+vfsURL.toExternalForm());
| | return vfsURL;
| | }
| |
|
| First some simple code critique.
|
| If you add something to project you don't sustain,
| be fair and add javadocs as it should be done.
| Since this is probably gonna be called for every class we load,
| some more constants won't kill you.
| Dunno how much optimization javac puts on "vfszip."length() and repeated ".jar".
|
| Tests should be more exhaustive.
| As I see some extra space after last ".jar that's probably not supposed to be there.
| Dunno how this would work.
|
| But in general, jar/zip handling is completely broken.
| First, it should be the same code that handles it,
| since, although we currently use vfszip, user can still fall back to old vfsjar handling.
| And they are both the same as far as feature set goes (it's just that we have winz lock problems on vfsjar).
| But the biggest problem I see is how are you gonna handle multiple nested jars.
| Dunno what's the proper/real url for those, but I very much doubt it's how your code does it.
| I guess this would have to be an impl of VirtualFileHandlers, not just VFSUtils.
|
| Conclusion.
| Either this is done right, or it goes out.
| I'll leave it for now, but will check on it before I do 2.0.0.GA.
|
| If you need any help on writing this, open a new forum post.
| And I'll see what can be done. ;-)
Thanks for your comments. I already had generated the constants. I was unable to put it back as I forgot before I slept and you rolled back.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4188485#4188485
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4188485
17 years, 5 months
[Design of POJO Server] - Re: VFS Permissions - JBMICROCONT-149
by anil.saldhana@jboss.com
| */
| public static final String FILE_PROTOCOL = "file";
|
| + /**
| + * Constant representing the JAR file protocol
| + */
| + public static final String JAR_FILE_PROTOCOL = "jar:file:";
| +
| + /**
| + * Constant representing the VFS ZIP protocol
| + */
| + public static final String VFSZIP_PROTOCOL = "vfszip";
| +
| + /**
| + * Constant representing the VFS file protocol
| + */
| + public static final String VFS_FILE_PROTOCOL = "vfsfile";
| +
| /** Standard separator for JAR URL */
| public static final String JAR_URL_SEPARATOR = "!/";
|
| @@ -157,6 +172,40 @@
|
| return buffer.toString();
| }
| +<<<<<<< .mine
| +
| + /**
| + * Get the Real URL
| + * @param vfsURL
| + * @return
| + * @throws Exception
| + */
| + public static URL getRealURL(URL vfsURL) throws Exception
| + {
| + if(vfsURL.getProtocol().startsWith(VFS_FILE_PROTOCOL)) //vfsfile:
| + return new URL(FILE_PROTOCOL, vfsURL.getHost(), vfsURL.getPort(), vfsURL.getFile());
| +
| + if(vfsURL.getProtocol().startsWith(VFSZIP_PROTOCOL)) //vfszip:
| + {
| + String urlStr = vfsURL.toExternalForm();
| +
| + //Look for the first matching archive (sar, war, ear, jar)
| + String tokens[] = urlStr.split(".[a-z&&[jsrew]]ar", 2);
| +
| + int lengthOfToken = tokens[0].length();
| + String typeArchive = urlStr.substring(lengthOfToken,lengthOfToken + 4);
| +
| + String firstPath = tokens[0].substring(VFSZIP_PROTOCOL.length() + 1);
| +
| + return new URL( new URL(JAR_FILE_PROTOCOL + firstPath + typeArchive + JAR_URL_SEPARATOR ),
| + tokens[1]);
| + }
| + if(log.isTraceEnabled())
| + log.trace("getRealURL did not have a match for:"+vfsURL.toExternalForm());
| + return vfsURL;
| + }
| +=======
| +>>>>>>> .r80795
|
|
That was the final version I was supposed to put last night but failed and now it has been rolled back.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4188475#4188475
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4188475
17 years, 5 months
[Design the new POJO MicroContainer] - Re: jboss-scanning.xml
by adrian@jboss.org
"alesj" wrote : Moving this
| - http://lists.jboss.org/pipermail/jboss-development/2008-November/012965.html
| discussion here.
|
| How would this file look like?
| e.g.
|
| | <scanning>
| | <include path="org/jboss/acme/ejbs" filter="ant:*.*Bean"/>
| | <include path="org/jboss/domain/hibernate" filter="regexp:<some-reg-exp>"/>
| | <exclude path="org/jboss/logic"/>
| | <exclude module="rules-impl.jar" />
| | </scanning>
| |
|
That's a horrible syntax. If you really need to go beyond file/ant globbing
for a file filter couldn't you have a seperate attribute to specify a different
fitlerType="regexp"?
anonymous wrote :
| Or what info should we expect from ScanningMetaData?
|
Classes - with a short syntax for ease of use in some cases,
e.g. including specific paths
| <scanning xmlns="urn:jboss:scanning:1.0">
| <path name="myejbs.jar">
| <!-- long form -->
| <classes>
| <include name="com.acme.foo.**"/>
| <exclude name="com.acme.foo.bar.*"/>
| </classes>
| </path>
| <!-- short form -->
| <path name="my.war/WEB-INF/classes" include="com.acme.foo.**"/>
| </scanning>
|
How much of this you actually implement in the first version is upto you.
The minimum would be a list of explicit paths to include (exclusion being the default).
Also, the paths need to be able to handle "external jars",
e.g. those referenced from the manifest
anonymous wrote :
| ejb-jar.xml and web.xml are mentioned in ml discussion.
| How would we transform them into ScanningMetaData?
|
metadata-complete (or pre javaee5 dds) means nothing is scanned
| <scanning xmlns="urn:jboss:scanning:1.0"/> <!-- nothing -->
|
otherwise all the jars and all the classes are scanned
| <scanning xmlns="urn:jboss:scanning:1.0">
| <include name="**"/>
| </scanning>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4188470#4188470
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4188470
17 years, 5 months