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