Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First implementation of passive probes
- Loading branch information
1 parent
1c09873
commit 21db61c
Showing
15 changed files
with
406 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!ELEMENT listener (attr*)> | ||
<!ATTLIST listener | ||
class CDATA #REQUIRED | ||
name CDATA #IMPLIED | ||
> | ||
<!ELEMENT attr (#PCDATA)> | ||
<!ATTLIST attr | ||
name CDATA #REQUIRED | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package jrds.starter; | ||
|
||
import org.apache.log4j.Level; | ||
import org.apache.log4j.Logger; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import jrds.Tools; | ||
import jrds.factories.ProbeBean; | ||
import jrds.probe.PassiveProbe; | ||
|
||
public class ListenerTest { | ||
@ProbeBean({"dummy"}) | ||
public static final class PassiveListener extends Listener { | ||
|
||
@Override | ||
public void register(PassiveProbe p) { | ||
} | ||
|
||
public void setDummy(String dummy) { | ||
|
||
} | ||
|
||
public String getDummy() { | ||
return "dummy"; | ||
} | ||
|
||
@Override | ||
public void listen() throws Exception { | ||
} | ||
|
||
@Override | ||
protected String identifyHost(Object message) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String identifyProbe(Object message) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String getHost(PassiveProbe pp) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
}; | ||
|
||
static Logger logger = Logger.getLogger(ListenerTest.class); | ||
|
||
@BeforeClass | ||
static public void configure() throws Exception { | ||
Tools.configure(); | ||
|
||
logger.setLevel(Level.TRACE); | ||
Tools.setLevel(new String[] {StarterNode.class.toString(), Starter.class.toString()}, logger.getLevel()); | ||
} | ||
|
||
@Test | ||
public void test1() { | ||
PassiveProbe pp = new PassiveProbe(); | ||
pp.setListener(new PassiveListener()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE listener PUBLIC "-//jrds//DTD Listener//EN" | ||
"urn:jrds:listner"> | ||
<listener class="jrds.starter.ListnerTest.PassiveListener"> | ||
<attr name="dummy">dummy</attr> | ||
</listener> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package jrds.configuration; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
|
||
import jrds.factories.xml.JrdsDocument; | ||
import jrds.factories.xml.JrdsElement; | ||
import jrds.starter.Listener; | ||
|
||
@SuppressWarnings("rawtypes") | ||
public class ListenerBuilder extends ConfigObjectBuilder<Listener<?,?>> { | ||
|
||
private ClassLoader classLoader = ListenerBuilder.class.getClassLoader(); | ||
|
||
protected ListenerBuilder() { | ||
super(ConfigType.LISTENER); | ||
} | ||
|
||
@Override | ||
Listener build(JrdsDocument n) throws InvocationTargetException { | ||
JrdsElement root = n.getRootElement(); | ||
String className = root.getAttribute("class"); | ||
if(className != null) | ||
className = className.trim(); | ||
if(className.isEmpty()) | ||
return null; | ||
try { | ||
@SuppressWarnings("unchecked") | ||
Class<? extends Listener> starterClass = (Class<? extends Listener>) classLoader.loadClass(className); | ||
Listener s = starterClass.newInstance(); | ||
return s; | ||
} catch (Exception e) { | ||
throw new InvocationTargetException(e, ListenerBuilder.class.getName()); | ||
} | ||
} | ||
|
||
/** | ||
* @param classLoader the classLoader to set | ||
*/ | ||
void setClassLoader(ClassLoader classLoader) { | ||
this.classLoader = classLoader; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.