Re: [JBoss-user] File-system access
Have a look at EXternalContext - http://jboss.org/online-manual/HTML/ch13s126.html hth dim - Original Message - From: "Simon Stewart" <[EMAIL PROTECTED]> To: "Mark Gulbrandsen" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, April 17, 2002 3:05 AM Subject: Re: [JBoss-user] File-system access > And is there a portable way of doing this? Portable between different > app servers, that is > > On Tue, Apr 16, 2002 at 10:30:08AM -0600, Mark Gulbrandsen wrote: > > > > Maybe I could ask a different question. > > > > Can I assign a resource so that I can do a jndi lookup? > > > > Can I configure JBoss to load an arbitrary jar file and set it to a jndi > > name such as "jndi:/user/resource1.jar" "jndi:/usr/resource2.jar"? Then, a > > context lookup would return a JarFile for each of these resource jars. Is > > this possible with Branch_3_0? > > > > -Mark > > Cheers, > > Simon > > -- > "You can't have everything...Where would you put it?" --- Steven Wright > > ___ > JBoss-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-user > ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] File-system access
I have been wondering about this question too. The main thing is that the EJB spec doesn't allow an EJB to access the local file system, because a bean developer has no way of knowing how or where the application developer and application deployer are going to assemble their system. So if you access a local file system, and a really cool cluster-o-rama EJB server has the capability to move EJB's to the physical machine best suited for them on the fly--this is within spec, but would break any EJB that rely on access to a local file system. Weblogic has a T3 file system that is a work around. It is really poor. My suggestion would be so create some sort of JNDI bindable file service. The difficulty comes from the fact that streams are not serializable. If you went all out, you could even make it JCA compatible so you could access it like a JDBC DataSource pool. Here are a couple of scenarios: 1) Simple Local Ref Make an object that the EJB can instantiated or look-up. It would take a URL as an argument. Then it would open a FileStream to that local file and hand it back to the EJB. The FileStream would have to be Transient, and the object capable of dealing with the disappearance and failure of the stream. The object would assume that the file is always available via the local file system. You could use something like NFS to mount the filesystem in the same location across your EJB server machines. 2) Remote Ref This would be just like scenario 1, but instead of using a network file system to distribute the files, write network code into the object. For example, if you just need reads, then you could make it take the URL and have it fetch files from a web server. If you want read/write/versioning/etc. You could make it act as a WebDAV adapter. You might even be happy with just an FTP server. 3) File Service. Create an object that acts like a DataSource object, it grabs a network file system connection out of a JCA compliant network file system connection pool. The "FileSource" object would take parameters to grab a connection of the pool, and to place it back in the pool. The pool objects would then need to be connections to some sort of network file server, like WebDAV, FTP, or NFS. Then you could manage the file system like any JCA resource. It would be the most scalable. The draw back would be that you would need to know about your file system at configuration time. I hope that these help, but the long and short of it is that I don't know of any file system objects for EJB that are server independent. Lucas McGregor -Original Message- From: Simon Stewart [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 16, 2002 10:06 AM To: Mark Gulbrandsen Cc: [EMAIL PROTECTED] Subject: Re: [JBoss-user] File-system access And is there a portable way of doing this? Portable between different app servers, that is On Tue, Apr 16, 2002 at 10:30:08AM -0600, Mark Gulbrandsen wrote: > > Maybe I could ask a different question. > > Can I assign a resource so that I can do a jndi lookup? > > Can I configure JBoss to load an arbitrary jar file and set it to a jndi > name such as "jndi:/user/resource1.jar" "jndi:/usr/resource2.jar"? Then, a > context lookup would return a JarFile for each of these resource jars. Is > this possible with Branch_3_0? > > -Mark Cheers, Simon -- "You can't have everything...Where would you put it?" --- Steven Wright ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
Re: [JBoss-user] File-system access
And is there a portable way of doing this? Portable between different app servers, that is On Tue, Apr 16, 2002 at 10:30:08AM -0600, Mark Gulbrandsen wrote: > > Maybe I could ask a different question. > > Can I assign a resource so that I can do a jndi lookup? > > Can I configure JBoss to load an arbitrary jar file and set it to a jndi > name such as "jndi:/user/resource1.jar" "jndi:/usr/resource2.jar"? Then, a > context lookup would return a JarFile for each of these resource jars. Is > this possible with Branch_3_0? > > -Mark Cheers, Simon -- "You can't have everything...Where would you put it?" --- Steven Wright ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
Re: [JBoss-user] File-system access
Maybe I could ask a different question. Can I assign a resource so that I can do a jndi lookup? Can I configure JBoss to load an arbitrary jar file and set it to a jndi name such as "jndi:/user/resource1.jar" "jndi:/usr/resource2.jar"? Then, a context lookup would return a JarFile for each of these resource jars. Is this possible with Branch_3_0? -Mark On Mon, 15 Apr 2002, Mark Gulbrandsen wrote: > > > I have an ejb jar file that is deployed in server/default/deploy. Call it > myejbs.jar. > > I also have a jar file that has many resources called resources.jar. > resources.jar is placed inside of myejbs.jar. I can access resource.jar > through getClass().getResource("resource.jar"). This gives me a URL, which > I can get a JarFile from via a few other calls. However, the JarFile that > I get is myejbs.jar. So then I have to call into the java.util.jar apis to > finally end up with a JarEntry. > > What I really want to do is access resource.jar as a JarFile, not a > JarEntry. So how do I configure jboss 3.0 to allow me to access > resource.jar as a JarFile? Also, I'd rather not put resource.jar in > myejbs.jar, because these resource could change more often than the ejbs, > but I don't want to have to redeploy my ejbs every time a resource > changes. I tried putting resource.jar in $JBOSS/server/default/deploy/, > but I still couldn't access it. Where can I put resource.jar and what do I > need to configure so my ejbs can access it through the ClassLoader (via > getResource)? > > Thanks, > > Mark > > > > ___ > JBoss-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-user > ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
RE: [JBoss-user] File-system access (fwd)
-- Forwarded message -- Date: Mon, 15 Apr 2002 16:43:35 -0600 (MDT) From: Mark Gulbrandsen <[EMAIL PROTECTED]> To: JD Brennan <[EMAIL PROTECTED]> Subject: RE: [JBoss-user] File-system access String jarURLString = "templates.jar"; System.err.println("opening " + jarURLString); URL jarURL = getClass().getResource(jarURLString); if(jarURL == null) { throw new NullPointerException("can't open " + jarURLString); } System.out.println("Opened " + jarURL); JarURLConnection con = (JarURLConnection)jarURL.openConnection(); System.out.println("con = " + con); JarFile jarFile = con.getJarFile(); System.out.println("jarFile = " + jarFile.getName()); //RIGHT HERE !! the above outputs the name of the ejb.jar file //(which is not ejb.jar, but something else). This outputs the //name of the file that jboss copies to its //$JBOSS/server/default/tmp/deploy directory, something like //92.myejbs.jar. JarEntry jarEntry1 = jarFile.getJarEntry("email/templates.jar"); //email/templates.jar is the jar file inside of myejbs.jar. if(jarEntry1 == null) { throw new NullPointerException("not found"); } System.out.println("found " + jarEntry1.getName()); JarInputStream jarInputStream = new JarInputStream(jarFile.getInputStream(jarEntry1)); JarEntry jarEntry = jarInputStream.getNextJarEntry(); while(jarEntry != null) { System.err.println("found " + jarEntry.getName()); if(jarEntry.getName().compareTo("Payment.txt") == 0) { //the following code is NOT production, it is a test byte[] bytes = new byte[1024*1024*2]; int len = jarInputStream.read(bytes,0,1024*1024*2); System.err.println(new String(bytes)); jarInputStream.read(bytes,len,(1024*1024*2)-len); System.err.println(new String(bytes)); } jarEntry = jarInputStream.getNextJarEntry(); } There you have it. But what I really want to do is to be able to access a resource or something so that I can have templates.jar represented as a JarFile object, because it is less work to access it if it is not in myejbs.jar. I just can't figure out how to find it if it is not in myejbs.jar. Any help? Thanks, Mark On Mon, 15 Apr 2002, JD Brennan wrote: > You can use JarInputStream() instead of JarFile() to > read your resources.jar. > > new JarInputStream(jar.getInputStream(entry)); > > How did you get from the URL to name of the deployed > ejb jar? That would be a neat trick to do. > > JD > > -Original Message- > From: Mark Gulbrandsen [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 15, 2002 1:14 PM > To: [EMAIL PROTECTED] > Subject: [JBoss-user] File-system access > > > > > I have an ejb jar file that is deployed in server/default/deploy. Call it > myejbs.jar. > > I also have a jar file that has many resources called resources.jar. > resources.jar is placed inside of myejbs.jar. I can access resource.jar > through getClass().getResource("resource.jar"). This gives me a URL, which > I can get a JarFile from via a few other calls. However, the JarFile that > I get is myejbs.jar. So then I have to call into the java.util.jar apis to > finally end up with a JarEntry. > > What I really want to do is access resource.jar as a JarFile, not a > JarEntry. So how do I configure jboss 3.0 to allow me to access > resource.jar as a JarFile? Also, I'd rather not put resource.jar in > myejbs.jar, because these resource could change more often than the ejbs, > but I don't want to have to redeploy my ejbs every time a resource > changes. I tried putting resource.jar in $JBOSS/server/default/deploy/, > but I still couldn't access it. Where can I put resource.jar and what do I > need to configure so my ejbs can access it through the ClassLoader (via > getResource)? > > Thanks, > > Mark > > > > ___ > JBoss-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-user > ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] File-system access
I have an ejb jar file that is deployed in server/default/deploy. Call it myejbs.jar. I also have a jar file that has many resources called resources.jar. resources.jar is placed inside of myejbs.jar. I can access resource.jar through getClass().getResource("resource.jar"). This gives me a URL, which I can get a JarFile from via a few other calls. However, the JarFile that I get is myejbs.jar. So then I have to call into the java.util.jar apis to finally end up with a JarEntry. What I really want to do is access resource.jar as a JarFile, not a JarEntry. So how do I configure jboss 3.0 to allow me to access resource.jar as a JarFile? Also, I'd rather not put resource.jar in myejbs.jar, because these resource could change more often than the ejbs, but I don't want to have to redeploy my ejbs every time a resource changes. I tried putting resource.jar in $JBOSS/server/default/deploy/, but I still couldn't access it. Where can I put resource.jar and what do I need to configure so my ejbs can access it through the ClassLoader (via getResource)? Thanks, Mark ___ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user