Java tutorial
/* * Copyright 2013-2015 cetvision.com. All rights reserved. * Support: http://www.cetvision.com * License: http://www.cetvision.com/license */ package com.dp2345.plugin; import java.io.File; import java.util.List; import javax.annotation.Resource; import org.apache.commons.lang.builder.CompareToBuilder; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.springframework.stereotype.Component; import com.dp2345.FileInfo; import com.dp2345.entity.PluginConfig; import com.dp2345.service.PluginConfigService; /** * Plugin - * * @author CETVISION CORP * @version 2.0.3 */ public abstract class StoragePlugin implements Comparable<StoragePlugin> { @Resource(name = "pluginConfigServiceImpl") private PluginConfigService pluginConfigService; /** * ?ID * * @return ID */ public final String getId() { return getClass().getAnnotation(Component.class).value(); } /** * ??? * * @return ?? */ public abstract String getName(); /** * ? * * @return */ public abstract String getVersion(); /** * ? * * @return */ public abstract String getAuthor(); /** * ?? * * @return ? */ public abstract String getSiteUrl(); /** * ?URL * * @return URL */ public abstract String getInstallUrl(); /** * ??URL * * @return ?URL */ public abstract String getUninstallUrl(); /** * ?URL * * @return URL */ public abstract String getSettingUrl(); /** * ?? * * @return ? */ public boolean getIsInstalled() { return pluginConfigService.pluginIdExists(getId()); } /** * ??? * * @return ?? */ public PluginConfig getPluginConfig() { return pluginConfigService.findByPluginId(getId()); } /** * ??? * * @return ?? */ public boolean getIsEnabled() { PluginConfig pluginConfig = getPluginConfig(); return pluginConfig != null ? pluginConfig.getIsEnabled() : false; } /** * ? * * @param name * ?? * @return */ public String getAttribute(String name) { PluginConfig pluginConfig = getPluginConfig(); return pluginConfig != null ? pluginConfig.getAttribute(name) : null; } /** * ?? * * @return ? */ public Integer getOrder() { PluginConfig pluginConfig = getPluginConfig(); return pluginConfig != null ? pluginConfig.getOrder() : null; } /** * * * @param path * * @param file * * @param contentType * */ public abstract void upload(String path, File file, String contentType); /** * ?URL * * @param path * * @return URL */ public abstract String getUrl(String path); /** * ? * * @param path * ? * @return ? */ public abstract List<FileInfo> browser(String path); @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } if (this == obj) { return true; } StoragePlugin other = (StoragePlugin) obj; return new EqualsBuilder().append(getId(), other.getId()).isEquals(); } @Override public int hashCode() { return new HashCodeBuilder(17, 37).append(getId()).toHashCode(); } public int compareTo(StoragePlugin storagePlugin) { return new CompareToBuilder().append(getOrder(), storagePlugin.getOrder()) .append(getId(), storagePlugin.getId()).toComparison(); } }