KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > joseki > server > source > SourceControllerFileDebug


1 /*
2  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
3  * [See end of file]
4  */

5
6 package org.joseki.server.source;
7
8 import com.hp.hpl.jena.rdf.model.* ;
9
10 import org.joseki.server.module.*;
11 import org.joseki.server.*;
12 import org.apache.commons.logging.* ;
13
14 /** A simple SourceController which provides some monitoring facilities,
15  * based on the standard SourceControllerFile.
16  * This is an example that does some logging on access to a file-backed model.
17  * It is a loadable Joseki module.
18  *
19  * @author Andy Seaborne
20  * @version $Id: SourceControllerFileDebug.java,v 1.2 2004/04/30 14:13:14 andy_seaborne Exp $
21  */

22
23 public class SourceControllerFileDebug
24     extends SourceControllerFile
25     implements SourceController, Loadable
26 {
27     static Log logger = LogFactory.getLog(SourceControllerFileDebug.class.getName()) ;
28     
29     //static { System.err.println("SourceControllerDebug") ; }
30

31 // String serverURI ;
32
// String filename ;
33

34     // ----------------------------------------------------------
35
// -- Loadable interface
36

37     /** The URI for this loadable class.
38      * Must agree with the URI specified on loading.
39      */

40     public String JavaDoc getInterfaceURI() { return null ; }
41     
42
43     /** Allow an implementation to initialise, based on configuration file */
44     public void init(Resource binding, Resource implementation)
45     {
46         if ( binding.isAnon() )
47             logger.info("Binding: []") ;
48         else
49             logger.info("Binding: "+binding.getURI()) ;
50             
51         if ( implementation.isAnon() )
52             logger.info("Implementation: []") ;
53         else
54             logger.info("Implementation: "+implementation.getURI()) ;
55
56         // Parameters
57
StmtIterator sIter = binding.listProperties() ;
58         for ( ; sIter.hasNext() ;)
59         {
60             Statement s = sIter.nextStatement() ;
61             logger.info(" "+s) ;
62         }
63     }
64     
65     // ----------------------------------------------------------
66
// -- SourceController interface
67

68     // Called once, during configuration
69
public ModelSource createSourceModel(Resource description, String JavaDoc _serverURI)
70     {
71         return super.createSourceModel(description, _serverURI) ;
72     }
73     
74     public String JavaDoc getServerURI() { return super.getServerURI() ; }
75     
76     // Called when used.
77
public void activate()
78     {
79         logger.info("activate: " + getServerURI());
80         super.activate();
81     }
82
83     // Called when not in use any more.
84
public void deactivate()
85     {
86         logger.info("deactivate: " + getServerURI());
87         super.deactivate();
88     }
89     // Called each time a source needs to be built.
90
public Model buildSource()
91     {
92         logger.info("buildSource: "+getServerURI()) ;
93         return super.buildSource() ;
94     }
95     
96     public void releaseSource()
97     {
98         logger.info("releaseSource: "+getServerURI()) ;
99         super.releaseSource() ;
100     }
101
102 }
103
104 /*
105  * (c) Copyright 2003, 2004 Hewlett-Packard Development Company, LP
106  * All rights reserved.
107  *
108  * Redistribution and use in source and binary forms, with or without
109  * modification, are permitted provided that the following conditions
110  * are met:
111  * 1. Redistributions of source code must retain the above copyright
112  * notice, this list of conditions and the following disclaimer.
113  * 2. Redistributions in binary form must reproduce the above copyright
114  * notice, this list of conditions and the following disclaimer in the
115  * documentation and/or other materials provided with the distribution.
116  * 3. The name of the author may not be used to endorse or promote products
117  * derived from this software without specific prior written permission.
118  *
119  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
120  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
121  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
122  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
123  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
124  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
125  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
126  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
127  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
128  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
129  */

130
Popular Tags