parent
1e2f52daca
commit
d129e0a802
@ -0,0 +1,65 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.download.group; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.common.AbsNormalTarget; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author aria |
||||||
|
* @Date 2019-09-05 |
||||||
|
*/ |
||||||
|
public class GroupTargetFactory { |
||||||
|
|
||||||
|
public static volatile GroupTargetFactory INSTANCE; |
||||||
|
|
||||||
|
private GroupTargetFactory() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static GroupTargetFactory getInstance() { |
||||||
|
|
||||||
|
if (INSTANCE == null) { |
||||||
|
synchronized (GroupTargetFactory.class) { |
||||||
|
if (INSTANCE == null) { |
||||||
|
INSTANCE = new GroupTargetFactory(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
public <T extends AbsNormalTarget> T generateNormalTarget(Class<T> clazz, long taskId, |
||||||
|
String targetName) { |
||||||
|
T target = null; |
||||||
|
if (clazz == GroupNormalTarget.class) { |
||||||
|
target = (T) new GroupNormalTarget(taskId, targetName); |
||||||
|
} else if (clazz == FtpDirNormalTarget.class) { |
||||||
|
target = (T) new FtpDirNormalTarget(taskId, targetName); |
||||||
|
} |
||||||
|
|
||||||
|
return target; |
||||||
|
} |
||||||
|
|
||||||
|
public FtpDirBuilderTarget generateDirBuilderTarget(String url, String targetName) { |
||||||
|
return new FtpDirBuilderTarget(url, targetName); |
||||||
|
} |
||||||
|
|
||||||
|
public GroupBuilderTarget generateGroupBuilderTarget(List<String> urls, String targetName) { |
||||||
|
return new GroupBuilderTarget(urls, targetName); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.download.normal; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.common.AbsBuilderTarget; |
||||||
|
import com.arialyy.aria.core.common.AbsNormalTarget; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author aria |
||||||
|
* @Date 2019-09-05 |
||||||
|
*/ |
||||||
|
public class DNormalTargetFactory { |
||||||
|
|
||||||
|
public static volatile DNormalTargetFactory INSTANCE; |
||||||
|
|
||||||
|
private DNormalTargetFactory() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static DNormalTargetFactory getInstance() { |
||||||
|
|
||||||
|
if (INSTANCE == null) { |
||||||
|
synchronized (DNormalTargetFactory.class) { |
||||||
|
if (INSTANCE == null) { |
||||||
|
INSTANCE = new DNormalTargetFactory(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
public <T extends AbsNormalTarget> T generateNormalTarget(Class<T> clazz, long taskId, |
||||||
|
String targetName) { |
||||||
|
T target = null; |
||||||
|
if (clazz == HttpNormalTarget.class) { |
||||||
|
target = (T) new HttpNormalTarget(taskId, targetName); |
||||||
|
} else if (clazz == FtpNormalTarget.class) { |
||||||
|
target = (T) new FtpNormalTarget(taskId, targetName); |
||||||
|
} |
||||||
|
|
||||||
|
return target; |
||||||
|
} |
||||||
|
|
||||||
|
public <T extends AbsBuilderTarget> T generateBuilderTarget(Class<T> clazz, String url, |
||||||
|
String targetName) { |
||||||
|
T target = null; |
||||||
|
if (clazz == HttpBuilderTarget.class) { |
||||||
|
target = (T) new HttpBuilderTarget(url, targetName); |
||||||
|
} else if (clazz == FtpBuilderTarget.class) { |
||||||
|
target = (T) new FtpBuilderTarget(url, targetName); |
||||||
|
} |
||||||
|
|
||||||
|
return target; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.upload.normal; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.common.AbsBuilderTarget; |
||||||
|
import com.arialyy.aria.core.common.AbsNormalTarget; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author aria |
||||||
|
* @Date 2019-09-05 |
||||||
|
*/ |
||||||
|
public class UNormalTargetFactory { |
||||||
|
|
||||||
|
public static volatile UNormalTargetFactory INSTANCE; |
||||||
|
|
||||||
|
private UNormalTargetFactory() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static UNormalTargetFactory getInstance() { |
||||||
|
|
||||||
|
if (INSTANCE == null) { |
||||||
|
synchronized (UNormalTargetFactory.class) { |
||||||
|
if (INSTANCE == null) { |
||||||
|
INSTANCE = new UNormalTargetFactory(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
public <T extends AbsNormalTarget> T generateNormalTarget(Class<T> clazz, long taskId, |
||||||
|
String targetName) { |
||||||
|
T target = null; |
||||||
|
if (clazz == HttpNormalTarget.class) { |
||||||
|
target = (T) new HttpNormalTarget(taskId, targetName); |
||||||
|
} else if (clazz == FtpNormalTarget.class) { |
||||||
|
target = (T) new FtpNormalTarget(taskId, targetName); |
||||||
|
} |
||||||
|
|
||||||
|
return target; |
||||||
|
} |
||||||
|
|
||||||
|
public <T extends AbsBuilderTarget> T generateBuilderTarget(Class<T> clazz, String url, |
||||||
|
String targetName) { |
||||||
|
T target = null; |
||||||
|
if (clazz == HttpBuilderTarget.class) { |
||||||
|
target = (T) new HttpBuilderTarget(url, targetName); |
||||||
|
} else if (clazz == FtpBuilderTarget.class) { |
||||||
|
target = (T) new FtpBuilderTarget(url, targetName); |
||||||
|
} |
||||||
|
|
||||||
|
return target; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue