1 5 6 package org.joseki.server.source; 7 8 import org.joseki.vocabulary.JosekiVocab ; 9 10 import com.hp.hpl.jena.rdf.model.* ; 11 12 import org.joseki.server.*; 13 import org.joseki.server.module.Loadable; 14 import org.apache.commons.logging.* ; 15 16 22 23 public class SourceControllerFile implements SourceController, Loadable 24 { 25 static Log logger = LogFactory.getLog(SourceControllerFile.class.getName()) ; 26 27 String serverURI ; 28 String filename ; 29 FileManager fileManager ; 30 31 34 public String getInterfaceURI() { return JosekiVocab.SourceController.getURI() ; } 35 public void init(Resource binding, Resource implementation) 36 { 37 fileManager = FileManager.getInstance() ; 38 } 39 40 43 public ModelSource createSourceModel(Resource description, String _serverURI) 45 { 46 serverURI = _serverURI ; 47 Statement aModelStmt = description.getProperty(JosekiVocab.attachedModel) ; 48 49 if ( aModelStmt == null ) 50 { 51 logger.warn("Model: "+serverURI + " : No internal Jena model specified") ; 52 return null ; 53 } 54 55 filename = null ; 56 try { 57 filename = aModelStmt.getResource().getURI() ; 58 logger.debug("File source controller: "+serverURI + " ==> " + filename) ; 59 } catch (RDFException ex) 60 { 61 logger.warn("No internal resource URI for "+serverURI) ; 62 return null ; 63 } 64 65 return new ModelSourceFile(this, serverURI) ; 66 } 67 68 public String getServerURI() { return serverURI ; } 69 70 public void activate() { logger.trace("activate: "+filename) ; return ; } 72 73 public void deactivate() { logger.trace("deactivate: "+filename) ; return ; } 75 76 public Model buildSource() 78 { 79 logger.debug("buildSource: "+serverURI+ " ("+filename+")") ; 80 try { 81 return fileManager.loadModel(filename) ; 82 } catch (RDFException rdfEx) 83 { 84 if ( rdfEx.getCause() != null ) 85 logger.warn(filename+": "+rdfEx.getCause()) ; 86 else 87 logger.warn(filename+": "+rdfEx) ; 88 throw rdfEx ; 89 } 90 } 91 92 public void releaseSource() 94 { 95 logger.debug("releaseSource: "+serverURI+ " ("+filename+")") ; 96 } 97 } 98 99 125 | Popular Tags |