Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards new molr #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Ongoing work! This project is just in the process of being rewoked...

It is an attempt to use the java debugging api in order to expose missions which are pure java code through the molr API. Quite some way to go still ;-)
It is an attempt to use the java debugging api in order to expose jdiMissions which are pure java code through the molr API. Quite some way to go still ;-)

Contributors:

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ allprojects {
apply plugin: "idea"
apply plugin: "eclipse"
apply plugin: "java"
apply plugin: 'jacoco'
//apply plugin: 'jacoco'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand All @@ -15,7 +15,7 @@ allprojects {
dependencies {
compile 'org.slf4j:slf4j-api:1.7.16'
}

/*
jacoco {
toolVersion = '0.8.4'
}
Expand All @@ -28,7 +28,7 @@ allprojects {
csv.enabled = false
}
}

*/
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
Expand All @@ -49,7 +49,7 @@ project(":gui") {
project(":inspector") {
dependencies {
compile project(":mole")
compile project(":jdiscript")
// compile project(":jdiscript")
}
}

Expand Down
2 changes: 1 addition & 1 deletion commons/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
implementation 'org.javassist:javassist:3.26.0-GA'
compile group: "com.google.code.gson", name: "gson", version: "2.+"
testCompile group: 'org.mockito', name: 'mockito-core', version: '3.+'
//testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
// testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'junit-addons:junit-addons:1.4'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* @author mgalilee
* @author tiagomr
*/
public interface Mission {
public interface JdiMission {

/**
* @return A {@link String} with the fully qualified domain name to the type of {@link cern.molr.commons.mole.Mole}
* which will run the tasks of this {@link Mission}.
* which will run the tasks of this {@link JdiMission}.
*/
String getMoleClassName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
*/
package cern.molr.commons.domain.impl;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;

import java.util.ArrayList;
import java.util.List;

/**
* Simple implementation of {@link Mission}
* Simple implementation of {@link JdiMission}
*
* @author tiagomr
* @author mgalilee
*/
public class MissionImpl implements Mission {
public class MissionImpl implements JdiMission {

/**
* Name of the mole that can execute the {@link Mission}
* Name of the mole that can execute the {@link JdiMission}
*/
private String moleClassName;

/**
* Class used by the exposed {@link Mission}
* Class used by the exposed {@link JdiMission}
*/
private String missionContentClassName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

package cern.molr.commons.exception;

import cern.molr.commons.domain.JdiMission;

/**
* Exception to be used whenever its not possible to
* {@link cern.molr.commons.mole.Mole#run(String, Object...)} a {@link cern.molr.commons.domain.Mission}
* {@link cern.molr.commons.mole.Mole#run(String, Object...)} a {@link JdiMission}
*
* @author timartin
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

package cern.molr.commons.exception;

import cern.molr.commons.domain.JdiMission;

/**
* Exception to be used whenever its not possible to
* {@link cern.molr.commons.mission.MissionMaterializer#materialize(Class)} a {@link cern.molr.commons.domain.Mission}
* {@link cern.molr.commons.mission.MissionMaterializer#materialize(Class)} a {@link JdiMission}
*
* @author timartin
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

package cern.molr.commons.mission;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;
import cern.molr.commons.exception.MissionMaterializationException;

/**
* Interface that provides a way to instantiate {@link Mission}s
* Interface that provides a way to instantiate {@link JdiMission}s
*
* @author tiagomr
*/
Expand All @@ -19,9 +19,9 @@ public interface MissionMaterializer {
/**
* Tries to instantiate a mission from a given {@link Class}
*
* @param classType {@link Class} from which the {@link Mission} will be generated
* @return A {@link Mission}
* @see Mission
* @param classType {@link Class} from which the {@link JdiMission} will be generated
* @return A {@link JdiMission}
* @see JdiMission
*/
Mission materialize(Class<?> classType) throws MissionMaterializationException;
JdiMission materialize(Class<?> classType) throws MissionMaterializationException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@

package cern.molr.commons.mission;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;

import java.util.Set;

/**
* Interface that provides a way to discover {@link Mission}s
* Interface that provides a way to discover {@link JdiMission}s
*
* @author timartin
* @author mgalilee
*/
public interface MissionsDiscoverer {

/**
* Searches for available {@link Mission}s
* Searches for available {@link JdiMission}s
*
* @return A {@link Set} of {@link Mission}s
* @return A {@link Set} of {@link JdiMission}s
*/
Set<Mission> availableMissions();
Set<JdiMission> availableMissions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package cern.molr.commons.mission.impl;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;
import cern.molr.commons.domain.impl.MissionImpl;
import cern.molr.commons.exception.MissionMaterializationException;
import cern.molr.commons.mission.MissionMaterializer;
Expand All @@ -22,7 +22,7 @@
import java.util.stream.Collectors;

/**
* Implementation of {@link MissionMaterializer} that can instantiate {@link Mission}s from {@link Class}es
* Implementation of {@link MissionMaterializer} that can instantiate {@link JdiMission}s from {@link Class}es
* annotated with {@link RunWithMole}
*
* @author tiagomr
Expand All @@ -32,7 +32,7 @@ public class AnnotatedMissionMaterializer implements MissionMaterializer {
private static final Logger LOGGER = LoggerFactory.getLogger(AnnotatedMissionMaterializer.class);

@Override
public Mission materialize(Class<?> classType) throws MissionMaterializationException {
public JdiMission materialize(Class<?> classType) throws MissionMaterializationException {
if (null == classType) {
throw new MissionMaterializationException(new IllegalArgumentException("Class type cannot be null"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
package cern.molr.commons.mission.impl;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;
import cern.molr.commons.mission.MissionMaterializer;
import cern.molr.commons.mission.MissionsDiscoverer;
import cern.molr.commons.mole.RunWithMole;
Expand All @@ -23,7 +23,7 @@

/**
* Implementation of {@link MissionsDiscoverer} which makes use of the {@link RunWithMole} annotation to discover
* {@link Mission}s using classpath scans
* {@link JdiMission}s using classpath scans
*
* @author jepeders
* @author tiagomr
Expand All @@ -40,7 +40,7 @@ public ClasspathMissionDiscoverer(MissionMaterializer materializer) {
}

@Override
public Set<Mission> availableMissions() {
public Set<JdiMission> availableMissions() {
final Set<Class<?>> missionClasses = new HashSet<>();
final Discoverer discoverer = new ClasspathDiscoverer();
discoverer.addAnnotationListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

package cern.molr.commons.mole;

import cern.molr.commons.domain.JdiMission;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Main entry point for the JVM's to execute {@link cern.molr.commons.domain.Mission}s
* Main entry point for the JVM's to execute {@link JdiMission}s
*
* @author jepeders
* @author tiagomr
Expand Down
10 changes: 5 additions & 5 deletions commons/src/main/java/cern/molr/commons/mole/Mole.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

package cern.molr.commons.mole;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;
import cern.molr.commons.exception.MissionExecutionException;

import java.lang.reflect.Method;
import java.util.List;

/**
* Interface that allows for the dynamic creation of {@link Mole}s. {@link Mole}s are responsible for the discovery and
* execution of {@link Mission}s
* execution of {@link JdiMission}s
*
* @author tiagomr
*/
Expand All @@ -29,10 +29,10 @@ public interface Mole {
List<Method> discover(Class<?> clazz);

/**
* Executes a {@link Mission}
* Executes a {@link JdiMission}
*
* @param missionContentClassName A {@link String} with the fully qualified domain name of the {@link Mission}s content class
* @param args An array of {@link Object}s to be passed as arguments to the {@link Mission}
* @param missionContentClassName A {@link String} with the fully qualified domain name of the {@link JdiMission}s content class
* @param args An array of {@link Object}s to be passed as arguments to the {@link JdiMission}
* @throws Exception Allows for any exception to be returned by the Mission execution behaviour, this is specific to
* the execution implementation
*/
Expand Down
4 changes: 2 additions & 2 deletions commons/src/main/java/cern/molr/commons/mole/RunWithMole.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*/
package cern.molr.commons.mole;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Provides information about which classes shall be exposed as {@link Mission}s and which {@link Mole} implementation must be
* Provides information about which classes shall be exposed as {@link JdiMission}s and which {@link Mole} implementation must be
* used to execute the discovery and execution methods.
*
* @author tiagomr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

package cern.molr.commons.registry.impl;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;
import cern.molr.commons.mission.MissionsDiscoverer;

/**
* In memory {@link Mission} registry that searches for {@link Mission}s on the construction phase using a
* In memory {@link JdiMission} registry that searches for {@link JdiMission}s on the construction phase using a
* {@link MissionsDiscoverer}.
*
* @see ObservableInMemoryEntriesRegistry
*/
public class InMemoryMissionsRegistry extends ObservableInMemoryEntriesRegistry<Mission> {
public class InMemoryMissionsRegistry extends ObservableInMemoryEntriesRegistry<JdiMission> {

public InMemoryMissionsRegistry() {
}
Expand Down
8 changes: 4 additions & 4 deletions commons/src/main/java/cern/molr/jvm/MoleSpawner.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package cern.molr.jvm;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;

/**
* Interface that is responsible for spawning JVMs executing cern.jarrace.mole.AgentRunner
Expand All @@ -17,12 +17,12 @@ public interface MoleSpawner<T> {
/**
* Spawns a mole in a new JVM with the same classpath as the calling JVM
*
* @param mission
* @param jdiMission
* @param args
* @return
* @throws Exception
*/
T spawnMoleRunner(Mission mission, String... args) throws Exception;
T spawnMoleRunner(JdiMission jdiMission, String... args) throws Exception;

/**
* Spawns a mole in a new JVM
Expand All @@ -33,5 +33,5 @@ public interface MoleSpawner<T> {
* @return
* @throws Exception
*/
T spawnMoleRunner(Mission service, String classpath, String... args) throws Exception;
T spawnMoleRunner(JdiMission service, String classpath, String... args) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package cern.molr.jvm.impl;

import cern.molr.commons.domain.Mission;
import cern.molr.commons.domain.JdiMission;
import cern.molr.commons.mole.GenericMoleRunner;
import cern.molr.jvm.JvmSpawnHelper;
import cern.molr.jvm.MoleSpawner;
Expand All @@ -31,13 +31,13 @@ public class SimpleMoleRunnerSpawner implements MoleSpawner<Void> {
private static final String CURRENT_CLASSPATH_VALUE = System.getProperty("java.class.path");

@Override
public Void spawnMoleRunner(Mission mission, String... args) throws IOException {
return spawnMoleRunner(mission, CURRENT_CLASSPATH_VALUE, args);
public Void spawnMoleRunner(JdiMission jdiMission, String... args) throws IOException {
return spawnMoleRunner(jdiMission, CURRENT_CLASSPATH_VALUE, args);
}

@Override
public Void spawnMoleRunner(Mission mission, String classpath, String... args) throws IOException {
if (null == mission) {
public Void spawnMoleRunner(JdiMission jdiMission, String classpath, String... args) throws IOException {
if (null == jdiMission) {
throw new IllegalArgumentException("The mission must not be null");
}
if(null == classpath) {
Expand All @@ -53,8 +53,8 @@ public Void spawnMoleRunner(Mission mission, String classpath, String... args) t
if(args != null) {
argsList.addAll(Arrays.asList(args));
}
argsList.add(mission.getMoleClassName());
argsList.add(mission.getMissionContentClassName());
argsList.add(jdiMission.getMoleClassName());
argsList.add(jdiMission.getMissionContentClassName());

ProcessBuilder processBuilder = JvmSpawnHelper.getProcessBuilder(
JvmSpawnHelper.appendToolsJarToClasspath(classpath),
Expand Down
Loading