-default siteSupportedNames now returns array with getHost
LazyXPlugin/LazyXPluginCache:
-updated getSitesSupported to return array with getHost if none set
-updated setSitesSupported to avoid storing default generated array of Plugin
-updated write to avoid storing default generated array of Plugin

git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@49763 ebf7c1c2-ba36-0410-9fe8-c592906822b4

Former-commit-id: 314fd77661a866152138aad5922364a85234c5c0
This commit is contained in:
jiaz 2024-09-11 14:35:22 +00:00
parent 6ff28242df
commit 68e7f78e71
5 changed files with 44 additions and 9 deletions

View File

@ -1057,7 +1057,7 @@ public abstract class Plugin implements ActionListener {
* @return
*/
public String[] siteSupportedNames() {
return null;
return new String[] { getHost() };
}
/**

View File

@ -32,6 +32,10 @@ public class LazyCrawlerPlugin extends LazyPlugin<PluginForDecrypt> {
return hasConfig;
}
public String getHost() {
return getDisplayName();
}
@Override
protected void setFeatures(LazyPlugin.FEATURE[] features) {
super.setFeatures(features);
@ -61,11 +65,22 @@ public class LazyCrawlerPlugin extends LazyPlugin<PluginForDecrypt> {
private String[] sitesSupported = null;
public String[] getSitesSupported() {
return sitesSupported;
final String[] sitesSupported = this.sitesSupported;
if (sitesSupported != null) {
return sitesSupported;
} else {
return new String[] { getHost() };
}
}
protected void setSitesSupported(String[] sitesSupported) {
this.sitesSupported = sitesSupported;
protected void setSitesSupported(final String[] sitesSupported) {
if (sitesSupported == null || sitesSupported.length == 0) {
this.sitesSupported = null;
} else if (sitesSupported.length == 1 && getHost().equals(sitesSupported[0])) {
this.sitesSupported = null;
} else {
this.sitesSupported = sitesSupported;
}
}
public void updateCrawlRuntime(long r) {

View File

@ -170,7 +170,11 @@ public class LazyCrawlerPluginCache {
if (plugin.isHasConfig() && plugin.getConfigInterface() != null) {
os.writeString(plugin.getConfigInterface());
}
final String[] sitesSupported = plugin.getSitesSupported();
String[] sitesSupported = plugin.getSitesSupported();
if (sitesSupported != null && sitesSupported.length == 1 && plugin.getHost().equals(sitesSupported[0])) {
// memory optimization to avoid storing of default value
sitesSupported = null;
}
os.writeShort(sitesSupported == null ? 0 : sitesSupported.length);
if (sitesSupported != null) {
for (String siteSupported : sitesSupported) {

View File

@ -2,6 +2,7 @@ package org.jdownloader.plugins.controller.host;
import jd.plugins.PluginForHost;
import org.appwork.utils.StringUtils;
import org.jdownloader.plugins.controller.LazyPlugin;
import org.jdownloader.plugins.controller.LazyPluginClass;
import org.jdownloader.plugins.controller.PluginClassLoader.PluginClassLoaderChild;
@ -72,11 +73,22 @@ public class LazyHostPlugin extends LazyPlugin<PluginForHost> {
private String[] sitesSupported = null;
public String[] getSitesSupported() {
return sitesSupported;
final String[] sitesSupported = this.sitesSupported;
if (sitesSupported != null) {
return sitesSupported;
} else {
return new String[] { getHost() };
}
}
protected void setSitesSupported(String[] sitesSupported) {
this.sitesSupported = sitesSupported;
protected void setSitesSupported(final String[] sitesSupported) {
if (sitesSupported == null || sitesSupported.length == 0) {
this.sitesSupported = null;
} else if (sitesSupported.length == 1 && getHost().equals(sitesSupported[0])) {
this.sitesSupported = null;
} else {
this.sitesSupported = sitesSupported;
}
}
protected synchronized final void setProperty(final boolean b, final PROPERTY property) {

View File

@ -211,7 +211,11 @@ public class LazyHostPluginCache {
if (plugin.isHasConfig() && plugin.getConfigInterface() != null) {
os.writeString(plugin.getConfigInterface());
}
final String[] sitesSupported = plugin.getSitesSupported();
String[] sitesSupported = plugin.getSitesSupported();
if (sitesSupported != null && sitesSupported.length == 1 && plugin.getHost().equals(sitesSupported[0])) {
// memory optimization to avoid storing of default value
sitesSupported = null;
}
os.writeShort(sitesSupported == null ? 0 : sitesSupported.length);
if (sitesSupported != null) {
for (String siteSupported : sitesSupported) {