001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * bstefanescu 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.runtime.deploy; 016 017import java.util.Collection; 018 019import org.nuxeo.runtime.model.ComponentInstance; 020import org.nuxeo.runtime.model.Extension; 021 022/** 023 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 024 */ 025public abstract class Contribution implements Cloneable { 026 027 protected Extension extension; 028 029 protected String contributionId; 030 031 public abstract void install(ManagedComponent comp, Contribution contrib); 032 033 public abstract void uninstall(ManagedComponent comp, Contribution contrib); 034 035 public String getContributionId() { 036 return contributionId; 037 } 038 039 public void setContributionId(String contributionId) { 040 this.contributionId = contributionId; 041 } 042 043 public void install(ManagedComponent comp) { 044 install(comp, this); 045 } 046 047 public void uninstall(ManagedComponent comp) { 048 uninstall(comp, this); 049 } 050 051 public void resolve(ContributionManager mgr) { 052 // do noting 053 } 054 055 public void unresolve(ContributionManager mgr) { 056 // do nothing 057 } 058 059 public Extension getExtension() { 060 return extension; 061 } 062 063 public void setExtension(Extension extension) { 064 this.extension = extension; 065 } 066 067 public String getExtensionPoint() { 068 return extension.getExtensionPoint(); 069 } 070 071 public ComponentInstance getContributor() { 072 return extension.getComponent(); 073 } 074 075 public Collection<String> getDependencies() { 076 return null; 077 } 078 079 @Override 080 public String toString() { 081 return contributionId; 082 } 083 084 @Override 085 public boolean equals(Object obj) { 086 if (obj == null) { 087 return false; 088 } 089 if (obj instanceof Contribution) { 090 return getClass() == obj.getClass() && contributionId.equals(((Contribution) obj).contributionId); 091 } 092 return false; 093 } 094 095 @Override 096 public int hashCode() { 097 return contributionId != null ? contributionId.hashCode() : 0; 098 } 099 100}