View Javadoc

1   /***
2   *
3   * The owl-s matcher software is subject to the GNU Lesser General
4   * Public License Version 2.1 (the "License"). You may not copy or use this
5   * file, in either source code or executable form, except in compliance
6   * with the License. You may obtain a copy of the License at
7   * http://www.fsf.org/licenses/lgpl.txt or http://www.opensource.org/.
8   *
9   * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied without
11  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  * PURPOSE. See the License for the specific language governing rights and
13  * limitations under the License.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this distribution; if not, write to the
17  *
18  * Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330,
20  * Boston, MA  02111-1307 USA
21  *
22  * Copyright (C) 2003-2004
23  * TU Berlin, FG IVS
24  * Stefan Tang,
25  * Christoph Liebetruth,
26  * Michael C. Jaeger, 
27  *
28  * More information available at http://ivs.tu-berlin.de/
29  *
30  * $Id$
31  *
32  */
33  package de.tuberlin.ivs.owl.matching;
34  
35  import de.tuberlin.ivs.owl.service.Service;
36  import java.util.Vector;
37  import de.tuberlin.ivs.owl.matching.config.Configuration;
38  
39  /***
40   * Implements the user-defined matching.
41   *
42   * @author Stefan Tang (steftang@stanford.edu), Christoph Liebetruth (christophl@voelcker.com)
43   * @version 1.1
44   */
45  public class UserDefinedMatching {
46  
47    /***
48     * Default constructor.
49     */
50    public UserDefinedMatching() {
51    }
52  
53    /***
54     * Determines the match based on all active user-defined plug-ins.
55     * @param userDefinedPlugIns A list containing all instantiated plug-ins.
56     * @param config The configuration file. Neccessary since plug-ins are
57     * defined as active in the configuration file.
58     * @param reqService The requested service.
59     * @param advService The advertised service.
60     * @param reasoner An instance of the reasoner class that holds the current
61     * knowledge base.
62     * @return true if all active plug-ins match, false otherwise.
63     */
64    public boolean match(Vector userDefinedPlugIns, Configuration config, Service reqService,
65                         Service advService, Reasoner reasoner) {
66      if (Options.extendedResult==null) {
67        Options.extendedResult = new ExtendedMatchingResult();
68      }
69      if (userDefinedPlugIns==null) {
70        Options.extendedResult.setPluginMatching(true);
71        return true;
72      }
73      for (int i=0; i<userDefinedPlugIns.size(); i++) {
74        UserPlugIn plugIn = (UserPlugIn)userDefinedPlugIns.elementAt(i);
75        String fullPlugInName = plugIn.getClass().getName();
76        if (config.isActivePlugIn(fullPlugInName)) {
77          if (!plugIn.match(reqService, advService, reasoner)) {
78            Options.extendedResult.setUnmatchedPlugIn(fullPlugInName);
79            Options.extendedResult.setPluginMatching(false);
80            return false;
81          } else {
82            Options.extendedResult.addMatchedPlugIn(fullPlugInName);
83          }
84        }
85      }
86      Options.extendedResult.setPluginMatching(true);
87      return true;
88    }
89  
90  }