Commit 9da8dd36 authored by michael.simon's avatar michael.simon
Browse files

remove more deprectaion warnings for Class.forName().newInstance()

parent 3d6d60ec
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.dao.jpa; package edu.kit.scc.webreg.dao.jpa;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -53,10 +54,8 @@ public abstract class JpaBaseDao<T extends BaseEntity<PK>, PK extends Serializab ...@@ -53,10 +54,8 @@ public abstract class JpaBaseDao<T extends BaseEntity<PK>, PK extends Serializab
@Override @Override
public T createNew() { public T createNew() {
try { try {
return getEntityClass().newInstance(); return getEntityClass().getConstructor().newInstance();
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
return null;
} catch (IllegalAccessException e) {
return null; return null;
} }
} }
......
package edu.kit.scc.webreg.dto.service; package edu.kit.scc.webreg.dto.service;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -20,10 +21,8 @@ public abstract class BaseDtoServiceImpl<T extends BaseEntity<PK>, E extends Bas ...@@ -20,10 +21,8 @@ public abstract class BaseDtoServiceImpl<T extends BaseEntity<PK>, E extends Bas
@Override @Override
public E createNewDto() { public E createNewDto() {
try { try {
return getMapper().getEntityDtoClass().newInstance(); return getMapper().getEntityDtoClass().getConstructor().newInstance();
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
return null;
} catch (IllegalAccessException e) {
return null; return null;
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.event; package edu.kit.scc.webreg.event;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -59,7 +60,7 @@ public class EventSubmitterImpl implements EventSubmitter { ...@@ -59,7 +60,7 @@ public class EventSubmitterImpl implements EventSubmitter {
for (EventEntity eventEntity : eventList) { for (EventEntity eventEntity : eventList) {
if (eventType.equals(eventEntity.getEventType())) { if (eventType.equals(eventEntity.getEventType())) {
try { try {
Object o = Class.forName(eventEntity.getJobClass().getJobClassName()).newInstance(); Object o = Class.forName(eventEntity.getJobClass().getJobClassName()).getConstructor().newInstance();
if (o instanceof EventExecutor<?, ?>) { if (o instanceof EventExecutor<?, ?>) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -84,16 +85,10 @@ public class EventSubmitterImpl implements EventSubmitter { ...@@ -84,16 +85,10 @@ public class EventSubmitterImpl implements EventSubmitter {
logger.warn("Could not execute job {} ({}): not instance of EventExecutor", logger.warn("Could not execute job {} ({}): not instance of EventExecutor",
eventEntity.getJobClass().getName(), eventEntity.getJobClass().getJobClassName()); eventEntity.getJobClass().getName(), eventEntity.getJobClass().getJobClassName());
} }
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("Failed spawning event executor", e); logger.warn("Failed spawning event executor", e);
throw new EventSubmitException("Failed spawning event executor", e); throw new EventSubmitException("Failed spawning event executor", e);
} catch (IllegalAccessException e) { }
logger.warn("Failed spawning event executor", e);
throw new EventSubmitException("Failed spawning event executor", e);
} catch (ClassNotFoundException e) {
logger.warn("Failed spawning event executor", e);
throw new EventSubmitException("Failed spawning event executor", e);
}
} }
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
******************************************************************************/ ******************************************************************************/
package edu.kit.scc.webreg.service.impl; package edu.kit.scc.webreg.service.impl;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
...@@ -59,16 +60,12 @@ public class HookManager { ...@@ -59,16 +60,12 @@ public class HookManager {
hook = hook.trim(); hook = hook.trim();
try { try {
logger.debug("installing hook {}", hook); logger.debug("installing hook {}", hook);
UserServiceHook h = (UserServiceHook) Class.forName(hook).newInstance(); UserServiceHook h = (UserServiceHook) Class.forName(hook).getConstructor().newInstance();
h.setAppConfig(appConfig); h.setAppConfig(appConfig);
newUserHooks.add(h); newUserHooks.add(h);
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("Could not spawn hook " + hook, e); logger.warn("Could not spawn hook " + hook, e);
} catch (IllegalAccessException e) { }
logger.warn("Could not spawn hook " + hook, e);
} catch (ClassNotFoundException e) {
logger.warn("Could not spawn hook " + hook, e);
}
} }
} }
...@@ -86,16 +83,12 @@ public class HookManager { ...@@ -86,16 +83,12 @@ public class HookManager {
hook = hook.trim(); hook = hook.trim();
try { try {
logger.debug("installing hook {}", hook); logger.debug("installing hook {}", hook);
GroupServiceHook h = (GroupServiceHook) Class.forName(hook).newInstance(); GroupServiceHook h = (GroupServiceHook) Class.forName(hook).getConstructor().newInstance();
h.setAppConfig(appConfig); h.setAppConfig(appConfig);
newGroupHooks.add(h); newGroupHooks.add(h);
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("Could not spawn hook " + hook, e);
} catch (IllegalAccessException e) {
logger.warn("Could not spawn hook " + hook, e);
} catch (ClassNotFoundException e) {
logger.warn("Could not spawn hook " + hook, e); logger.warn("Could not spawn hook " + hook, e);
} }
} }
} }
......
package edu.kit.scc.webreg.service.reg.impl; package edu.kit.scc.webreg.service.reg.impl;
import java.lang.reflect.InvocationTargetException;
import java.util.Date; import java.util.Date;
import javax.ejb.Stateless; import javax.ejb.Stateless;
...@@ -116,20 +117,14 @@ public class AttributeSourceQueryServiceImpl implements AttributeSourceQueryServ ...@@ -116,20 +117,14 @@ public class AttributeSourceQueryServiceImpl implements AttributeSourceQueryServ
public AttributeSourceWorkflow getWorkflowInstance(String className) { public AttributeSourceWorkflow getWorkflowInstance(String className) {
try { try {
Object o = Class.forName(className).newInstance(); Object o = Class.forName(className).getConstructor().newInstance();
if (o instanceof AttributeSourceWorkflow) if (o instanceof AttributeSourceWorkflow)
return (AttributeSourceWorkflow) o; return (AttributeSourceWorkflow) o;
else { else {
logger.warn("AttributeSourceWorkflow bean misconfigured, Object not Type AttributeSourceWorkflow but: {}", o.getClass()); logger.warn("AttributeSourceWorkflow bean misconfigured, Object not Type AttributeSourceWorkflow but: {}", o.getClass());
return null; return null;
} }
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("AttributeSourceWorkflow bean misconfigured: {}", e.getMessage());
return null;
} catch (IllegalAccessException e) {
logger.warn("AttributeSourceWorkflow bean misconfigured: {}", e.getMessage());
return null;
} catch (ClassNotFoundException e) {
logger.warn("AttributeSourceWorkflow bean misconfigured: {}", e.getMessage()); logger.warn("AttributeSourceWorkflow bean misconfigured: {}", e.getMessage());
return null; return null;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.service.reg.impl; package edu.kit.scc.webreg.service.reg.impl;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -696,7 +697,7 @@ public class Registrator implements Serializable { ...@@ -696,7 +697,7 @@ public class Registrator implements Serializable {
public RegisterUserWorkflow getWorkflowInstance(String className) { public RegisterUserWorkflow getWorkflowInstance(String className) {
try { try {
Object o = Class.forName(className).newInstance(); Object o = Class.forName(className).getConstructor().newInstance();
if (o instanceof RegisterUserWorkflow) { if (o instanceof RegisterUserWorkflow) {
if (o instanceof ScriptingWorkflow) if (o instanceof ScriptingWorkflow)
((ScriptingWorkflow) o).setScriptingEnv(scriptingEnv); ((ScriptingWorkflow) o).setScriptingEnv(scriptingEnv);
...@@ -707,13 +708,7 @@ public class Registrator implements Serializable { ...@@ -707,13 +708,7 @@ public class Registrator implements Serializable {
logger.warn("Service Register bean misconfigured, Object not Type RegisterUserWorkflow but: {}", o.getClass()); logger.warn("Service Register bean misconfigured, Object not Type RegisterUserWorkflow but: {}", o.getClass());
return null; return null;
} }
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("Service Register bean misconfigured: {}", e.getMessage());
return null;
} catch (IllegalAccessException e) {
logger.warn("Service Register bean misconfigured: {}", e.getMessage());
return null;
} catch (ClassNotFoundException e) {
logger.warn("Service Register bean misconfigured: {}", e.getMessage()); logger.warn("Service Register bean misconfigured: {}", e.getMessage());
return null; return null;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
******************************************************************************/ ******************************************************************************/
package edu.kit.scc.webreg.service.timer; package edu.kit.scc.webreg.service.timer;
import java.lang.reflect.InvocationTargetException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -94,7 +95,7 @@ public class ClusterSchedulerImpl implements ClusterScheduler { ...@@ -94,7 +95,7 @@ public class ClusterSchedulerImpl implements ClusterScheduler {
logger.debug("----ClusterScheduler invokes: {} [{}]", jobClass.getName(), jobClass.getJobClassName()); logger.debug("----ClusterScheduler invokes: {} [{}]", jobClass.getName(), jobClass.getJobClassName());
try { try {
Object o = Class.forName(jobClass.getJobClassName()).newInstance(); Object o = Class.forName(jobClass.getJobClassName()).getConstructor().newInstance();
if (o instanceof ExecutableJob) { if (o instanceof ExecutableJob) {
ExecutableJob job = (ExecutableJob) o; ExecutableJob job = (ExecutableJob) o;
job.setJobStore(jobClass.getJobStore()); job.setJobStore(jobClass.getJobStore());
...@@ -103,13 +104,9 @@ public class ClusterSchedulerImpl implements ClusterScheduler { ...@@ -103,13 +104,9 @@ public class ClusterSchedulerImpl implements ClusterScheduler {
else { else {
logger.warn("Could not execute job {} ({}): not instance of ExecutableJob", jobClass.getName(), jobClass.getJobClassName()); logger.warn("Could not execute job {} ({}): not instance of ExecutableJob", jobClass.getName(), jobClass.getJobClassName());
} }
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("Could not execute job {} ({}): {}", jobClass.getName(), jobClass.getJobClassName(), e.toString()); logger.warn("Could not execute job {} ({}): {}", jobClass.getName(), jobClass.getJobClassName(), e.toString());
} catch (IllegalAccessException e) { }
logger.warn("Could not execute job {} ({}): {}", jobClass.getName(), jobClass.getJobClassName(), e.toString());
} catch (ClassNotFoundException e) {
logger.warn("Could not execute job {} ({}): {}", jobClass.getName(), jobClass.getJobClassName(), e.toString());
}
} }
@Override @Override
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.service.timer; package edu.kit.scc.webreg.service.timer;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -104,7 +105,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable { ...@@ -104,7 +105,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable {
logger.debug("----StandardScheduler invokes: {} [{}]", jobClass.getName(), jobClass.getJobClassName()); logger.debug("----StandardScheduler invokes: {} [{}]", jobClass.getName(), jobClass.getJobClassName());
try { try {
Object o = Class.forName(jobClass.getJobClassName()).newInstance(); Object o = Class.forName(jobClass.getJobClassName()).getConstructor().newInstance();
if (o instanceof ExecutableJob) { if (o instanceof ExecutableJob) {
ExecutableJob job = (ExecutableJob) o; ExecutableJob job = (ExecutableJob) o;
job.setJobStore(jobClass.getJobStore()); job.setJobStore(jobClass.getJobStore());
...@@ -113,11 +114,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable { ...@@ -113,11 +114,7 @@ public class StandardSchedulerImpl implements StandardScheduler, Serializable {
else { else {
logger.warn("Could not execute job {} ({}): not instance of ExecutableJob", jobClass.getName(), jobClass.getJobClassName()); logger.warn("Could not execute job {} ({}): not instance of ExecutableJob", jobClass.getName(), jobClass.getJobClassName());
} }
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("Could not execute job {} ({}): {}", jobClass.getName(), jobClass.getJobClassName(), e.toString());
} catch (IllegalAccessException e) {
logger.warn("Could not execute job {} ({}): {}", jobClass.getName(), jobClass.getJobClassName(), e.toString());
} catch (ClassNotFoundException e) {
logger.warn("Could not execute job {} ({}): {}", jobClass.getName(), jobClass.getJobClassName(), e.toString()); logger.warn("Could not execute job {} ({}): {}", jobClass.getName(), jobClass.getJobClassName(), e.toString());
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.bean; package edu.kit.scc.webreg.bean;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import javax.inject.Named; import javax.inject.Named;
import javax.faces.view.ViewScoped; import javax.faces.view.ViewScoped;
...@@ -118,20 +119,14 @@ public class ApproveUserBean implements Serializable { ...@@ -118,20 +119,14 @@ public class ApproveUserBean implements Serializable {
private ApproverRoleApprovalWorkflow getApprovalWorkflowInstance(String className) { private ApproverRoleApprovalWorkflow getApprovalWorkflowInstance(String className) {
try { try {
Object o = Class.forName(className).newInstance(); Object o = Class.forName(className).getConstructor().newInstance();
if (o instanceof ApproverRoleApprovalWorkflow) if (o instanceof ApproverRoleApprovalWorkflow)
return (ApproverRoleApprovalWorkflow) o; return (ApproverRoleApprovalWorkflow) o;
else { else {
logger.warn("Service Register bean misconfigured, Object not Type ApprovalWorkflow but: {}", o.getClass()); logger.warn("Service Register bean misconfigured, Object not Type ApprovalWorkflow but: {}", o.getClass());
return null; return null;
} }
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("Service Register bean misconfigured: {}", e.getMessage());
return null;
} catch (IllegalAccessException e) {
logger.warn("Service Register bean misconfigured: {}", e.getMessage());
return null;
} catch (ClassNotFoundException e) {
logger.warn("Service Register bean misconfigured: {}", e.getMessage()); logger.warn("Service Register bean misconfigured: {}", e.getMessage());
return null; return null;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package edu.kit.scc.webreg.bean.admin.timer; package edu.kit.scc.webreg.bean.admin.timer;
import java.io.Serializable; import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.faces.event.ComponentSystemEvent; import javax.faces.event.ComponentSystemEvent;
...@@ -52,7 +53,7 @@ public class ShowJobClassBean implements Serializable { ...@@ -52,7 +53,7 @@ public class ShowJobClassBean implements Serializable {
logger.debug("Directly invoking: {} [{}]", entity.getName(), entity.getJobClassName()); logger.debug("Directly invoking: {} [{}]", entity.getName(), entity.getJobClassName());
try { try {
Object o = Class.forName(entity.getJobClassName()).newInstance(); Object o = Class.forName(entity.getJobClassName()).getConstructor().newInstance();
if (o instanceof ExecutableJob) { if (o instanceof ExecutableJob) {
ExecutableJob job = (ExecutableJob) o; ExecutableJob job = (ExecutableJob) o;
job.setJobStore(entity.getJobStore()); job.setJobStore(entity.getJobStore());
...@@ -61,14 +62,9 @@ public class ShowJobClassBean implements Serializable { ...@@ -61,14 +62,9 @@ public class ShowJobClassBean implements Serializable {
else { else {
logger.warn("Could not execute job {} ({}): not instance of ExecutableJob", entity.getName(), entity.getJobClassName()); logger.warn("Could not execute job {} ({}): not instance of ExecutableJob", entity.getName(), entity.getJobClassName());
} }
} catch (InstantiationException e) { } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
logger.warn("Could not execute job {} ({}): {}", entity.getName(), entity.getJobClassName(), e.toString()); logger.warn("Could not execute job {} ({}): {}", entity.getName(), entity.getJobClassName(), e.toString());
} catch (IllegalAccessException e) { }
logger.warn("Could not execute job {} ({}): {}", entity.getName(), entity.getJobClassName(), e.toString());
} catch (ClassNotFoundException e) {
logger.warn("Could not execute job {} ({}): {}", entity.getName(), entity.getJobClassName(), e.toString());
}
} }
public JobClassEntity getEntity() { public JobClassEntity getEntity() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment