001/* 002 * (C) Copyright 2008 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 * $Id: IndexingAdapterDescriptor.java 31426 2008-04-09 17:00:34Z ogrisel $ 020 */ 021 022package org.nuxeo.ecm.platform.indexing.gateway.adapter; 023 024import org.nuxeo.common.xmap.annotation.XNode; 025import org.nuxeo.common.xmap.annotation.XObject; 026 027@XObject("adapter") 028public class IndexingAdapterDescriptor implements Comparable<IndexingAdapterDescriptor> { 029 030 @XNode("@class") 031 private String className = ""; 032 033 @XNode("@order") 034 private int order = 0; 035 036 @XNode("@enabled") 037 private boolean enabled = true; 038 039 private IndexingAdapter adapterInstance; 040 041 public String getClassName() { 042 return className; 043 } 044 045 public IndexingAdapter getAdapterInstance() { 046 return adapterInstance; 047 } 048 049 public void setAdapterInstance(IndexingAdapter adapterInstance) { 050 this.adapterInstance = adapterInstance; 051 } 052 053 public int compareTo(IndexingAdapterDescriptor o) { 054 return order - o.order; 055 } 056 057 public boolean isEnabled() { 058 return enabled; 059 } 060 061 // needed to make the following un-registration logics work: 062 // registeredAdapters.remove(registeredAdapters.lastIndexOf(descriptor)); 063 @Override 064 public boolean equals(Object o) { 065 if (o instanceof IndexingAdapterDescriptor) { 066 IndexingAdapterDescriptor otherDescriptor = (IndexingAdapterDescriptor) o; 067 return className.equals(otherDescriptor.className); 068 } 069 return false; 070 } 071 072}