forked from Fruchuxs/RichWPS-Monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted for the new version of the monitor
* NotFound Exceptions added * New examples added to the main class
- Loading branch information
Showing
14 changed files
with
225 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,10 @@ | |
*/ | ||
package de.hsos.ecs.richwps.wpsmonitor.client; | ||
|
||
import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientCreateException; | ||
import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientException; | ||
import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientWpsProcessNotFoundException; | ||
import de.hsos.ecs.richwps.wpsmonitor.client.exception.WpsMonitorClientWpsNotFoundException; | ||
import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsMetricResource; | ||
import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsProcessResource; | ||
import de.hsos.ecs.richwps.wpsmonitor.client.resource.WpsResource; | ||
|
@@ -24,42 +28,99 @@ | |
import java.util.logging.Logger; | ||
|
||
/** | ||
* This is a simple Code Demonstration of the WpsMontiorClient. This Code also | ||
* serves as a TestCode. To use this Code as a Test you must registred the WPS | ||
* "http://localhost:8080/wps/WebProcessingService" and the Process | ||
* "SimpleBuffer" in the WPSMonitor or simply change the static members below. | ||
* | ||
* Make sure the monitor is started and avaible (see the monitorUrl static | ||
* Member). | ||
* | ||
* @author Florian Vogelpohl <[email protected]> | ||
*/ | ||
public class Main { | ||
|
||
private static URL monitorUrl; | ||
private static URL registredWpsUrl; | ||
private static URL nonExistsWpsUrl; | ||
private static String registredWpsProcess; | ||
private static String nonExistsWpsProcess; | ||
|
||
static { | ||
try { | ||
monitorUrl = new URL("http://localhost:1111/"); | ||
registredWpsUrl = new URL("http://localhost:8080/wps/WebProcessingService"); | ||
nonExistsWpsUrl = new URL("http://example.com/this/wps/should/not/be/exists"); | ||
registredWpsProcess = "SimpleBuffer"; | ||
nonExistsWpsProcess = "AnyProcessWhichShouldNotExists"; | ||
} catch (MalformedURLException ex) { | ||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
|
||
public void listWps(final WpsMonitorClient client) throws WpsMonitorClientException { | ||
for (final WpsResource wps : client.getAllWps()) { | ||
System.out.println(wps); | ||
} | ||
} | ||
|
||
public void wpsNotFound(final WpsMonitorClient client) throws WpsMonitorClientException { | ||
try { | ||
client.getWps(nonExistsWpsUrl); | ||
} catch (WpsMonitorClientWpsNotFoundException ex) { | ||
System.out.println(ex); | ||
} | ||
} | ||
|
||
public void wpsNotFound2(final WpsMonitorClient client) throws WpsMonitorClientException { | ||
try { | ||
client.getWpsProcess(nonExistsWpsUrl, registredWpsProcess); | ||
} catch (WpsMonitorClientWpsNotFoundException ex) { | ||
System.out.println(ex); | ||
} | ||
} | ||
|
||
public void wpsProcessNotFound(final WpsMonitorClient client) throws WpsMonitorClientException { | ||
try { | ||
client.getWpsProcess(registredWpsUrl, nonExistsWpsProcess); | ||
} catch (WpsMonitorClientWpsProcessNotFoundException ex) { | ||
System.out.println(ex); | ||
} | ||
} | ||
|
||
public void findWpsProcess(final WpsMonitorClient client) throws WpsMonitorClientException { | ||
WpsProcessResource wpsProcess = client.getWpsProcess(registredWpsUrl, registredWpsProcess); | ||
|
||
System.out.println("Wps Process:"); | ||
System.out.println(wpsProcess.toString()); | ||
System.out.println("Metrics:"); | ||
|
||
for (final WpsMetricResource metric : wpsProcess.getMetricsAsList()) { | ||
System.out.println(metric.toString()); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
try { | ||
WpsMonitorClient wpsMonitorClient = new WpsMonitorClientFactory().create(new URL("http://localhost:1111/")); | ||
|
||
System.out.println("List of WPS are available in the Monitor"); | ||
System.out.println("----"); | ||
|
||
for (final WpsResource wpsResource : wpsMonitorClient.getAllWps()) { | ||
System.out.println(wpsResource); | ||
} | ||
|
||
System.out.println("----"); | ||
|
||
WpsResource pickup = wpsMonitorClient.getWps(new URL("http://localhost:8080/wps/WebProcessingService")); | ||
|
||
if (pickup != null) { | ||
WpsProcessResource wpsProcess = wpsMonitorClient.getWpsProcess(pickup, "Blubb"); | ||
|
||
if (wpsProcess != null) { | ||
System.out.println("Metrics"); | ||
|
||
for(WpsMetricResource r : wpsProcess.getMetricsAsList()) { | ||
System.out.println(r); | ||
} | ||
} else { | ||
System.out.println("Can't demonstrate the getProcessMetrics method, because there are no WpsProcess with the name \"Blubb\" are registrated in the Monitor"); | ||
} | ||
} else { | ||
System.out.println("Can't demonstrate the metrics method, because there are no WPS registrated in the Monitor."); | ||
} | ||
} catch (MalformedURLException | WpsMonitorClientException | WpsMonitorClientCreateException ex) { | ||
WpsMonitorClient wpsMonitorClient = new WpsMonitorClientFactory().create(monitorUrl); | ||
|
||
Main main = new Main(); | ||
System.out.println("List WPS:"); | ||
main.listWps(wpsMonitorClient); | ||
|
||
System.out.println("WPS Not Found:"); | ||
main.wpsNotFound(wpsMonitorClient); | ||
|
||
System.out.println("WPS also Not Found:"); | ||
main.wpsNotFound2(wpsMonitorClient); | ||
|
||
System.out.println("WPS Process not found but the WPS endpoint is registred:"); | ||
main.wpsProcessNotFound(wpsMonitorClient); | ||
|
||
System.out.println("Show a registred WPS Process and the Metrics:"); | ||
main.findWpsProcess(wpsMonitorClient); | ||
|
||
} catch (WpsMonitorClientException | WpsMonitorClientCreateException ex) { | ||
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); | ||
} | ||
} | ||
|
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
20 changes: 20 additions & 0 deletions
20
...de/hsos/ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientWpsNotFoundException.java
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,20 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package de.hsos.ecs.richwps.wpsmonitor.client.exception; | ||
|
||
import java.net.URL; | ||
|
||
/** | ||
* | ||
* @author Florian Vogelpohl <[email protected]> | ||
*/ | ||
public class WpsMonitorClientWpsNotFoundException extends WpsMonitorClientException { | ||
|
||
public WpsMonitorClientWpsNotFoundException(final URL wpsEndpoint) { | ||
super("The WPS \"" + wpsEndpoint.toString() + "\" was not found within the WPSMonitor."); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
.../ecs/richwps/wpsmonitor/client/exception/WpsMonitorClientWpsProcessNotFoundException.java
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,20 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
package de.hsos.ecs.richwps.wpsmonitor.client.exception; | ||
|
||
import java.net.URL; | ||
|
||
/** | ||
* | ||
* @author Florian Vogelpohl <[email protected]> | ||
*/ | ||
public class WpsMonitorClientWpsProcessNotFoundException extends WpsMonitorClientException { | ||
|
||
public WpsMonitorClientWpsProcessNotFoundException(final String processIdentifier, final URL wpsEndpoint) { | ||
super("The Process \"" + processIdentifier + "\" of WPS \"" + wpsEndpoint.toString() + "\" was not found within the WPSMonitor."); | ||
} | ||
|
||
} |
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
Oops, something went wrong.