001/* 002 * (C) Copyright 2006-2011 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 * bstefanescu 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.runtime.deploy; 023 024import java.util.Collection; 025 026import org.nuxeo.runtime.model.ComponentInstance; 027import org.nuxeo.runtime.model.Extension; 028 029/** 030 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 031 */ 032public abstract class Contribution implements Cloneable { 033 034 protected Extension extension; 035 036 protected String contributionId; 037 038 public abstract void install(ManagedComponent comp, Contribution contrib); 039 040 public abstract void uninstall(ManagedComponent comp, Contribution contrib); 041 042 public String getContributionId() { 043 return contributionId; 044 } 045 046 public void setContributionId(String contributionId) { 047 this.contributionId = contributionId; 048 } 049 050 public void install(ManagedComponent comp) { 051 install(comp, this); 052 } 053 054 public void uninstall(ManagedComponent comp) { 055 uninstall(comp, this); 056 } 057 058 public void resolve(ContributionManager mgr) { 059 // do noting 060 } 061 062 public void unresolve(ContributionManager mgr) { 063 // do nothing 064 } 065 066 public Extension getExtension() { 067 return extension; 068 } 069 070 public void setExtension(Extension extension) { 071 this.extension = extension; 072 } 073 074 public String getExtensionPoint() { 075 return extension.getExtensionPoint(); 076 } 077 078 public ComponentInstance getContributor() { 079 return extension.getComponent(); 080 } 081 082 public Collection<String> getDependencies() { 083 return null; 084 } 085 086 @Override 087 public String toString() { 088 return contributionId; 089 } 090 091 @Override 092 public boolean equals(Object obj) { 093 if (obj == null) { 094 return false; 095 } 096 if (obj instanceof Contribution) { 097 return getClass() == obj.getClass() && contributionId.equals(((Contribution) obj).contributionId); 098 } 099 return false; 100 } 101 102 @Override 103 public int hashCode() { 104 return contributionId != null ? contributionId.hashCode() : 0; 105 } 106 107}