1. In the configuration file config.properties: File.rmi=http://localhost:7000/rmi
2. Download Jackrabbit-standalone-2.10.1.jar, open the service:java -jar Jackrabbit-Standalone-2.1. 0.jar --Port 7000
3.
Public classJackrabbitfileserviceimplImplementsFileservice {Private StaticRepository Repository; Public Staticsession Initsession () {Session session=NULL; if(NULL==repository) { Try{Repository=NewUrlremoterepository (Readconfig.getvalue ("File.rmi")); } Catch(malformedurlexception e) {//TODO auto-generated Catch blockE.printstacktrace (); } } Try{Session=repository.login (NewSimplecredentials ("admin", "admin". ToCharArray ())); } Catch(loginexception e) {//TODO auto-generated Catch blockE.printstacktrace (); } Catch(repositoryexception e) {//TODO auto-generated Catch blockE.printstacktrace (); } returnsession; } @Override PublicString Save (InputStream is,Longfilesize) {String FileId=Keyprovider.getprimarykey (); Try{Session Session=initsession (); Node Root=Session.getrootnode (); String MimeType= "Application/octet-stream"; Node Filenode= Root.addnode (FileId, "Nt:file"); Node Resnode= Filenode.addnode ("Jcr:content", "Nt:resource"); Resnode.setproperty ("Jcr:mimetype", MimeType); Resnode.setproperty ("Jcr:encoding", "" "); Resnode.setproperty ("Jcr:data", is); Calendar lastmodified=calendar.getinstance (); Resnode.setproperty ("Jcr:lastmodified", lastmodified); Session.save (); Is.close (); Session.logout (); }Catch(Exception e) {e.printstacktrace (); } returnfileId; } @Override PublicInputStream Getfilebyid (String fileId) {InputStream is=NULL; Try{Session Session=initsession (); Node Root=Session.getrootnode (); if(root!=NULL) {Nodeiterator filenodes=root.getnodes (fileId); while(Filenodes.hasnext ()) {Node n=Filenodes.nextnode (); Nodeiterator Ni1=n.getnodes (); while(Ni1.hasnext ()) {Node N1=Ni1.nextnode (); if(N1.getname (). Equals ("Jcr:content") ) { is= N1.getproperty ("Jcr:data"). GetStream (); }}}} session.logout (); }Catch(Exception e) {e.printstacktrace (); } returnis ; } }
Jackrabbit File Upload Download