diff --git a/src/java/net/brutex/xservices/types/RuntimeInfoType.java b/src/java/net/brutex/xservices/types/RuntimeInfoType.java new file mode 100644 index 0000000..2bf70d6 --- /dev/null +++ b/src/java/net/brutex/xservices/types/RuntimeInfoType.java @@ -0,0 +1,63 @@ +/* + * Copyright 2012 Brian Rosenberger (Brutex Network) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.brutex.xservices.types; + +import javax.xml.bind.annotation.XmlElement; + +/* + * Information about processors and memory + */ +public class RuntimeInfoType { + + private final Runtime runtime = Runtime.getRuntime(); + + @XmlElement + public int getAvailableProcessors() { + return runtime.availableProcessors(); + } + + @XmlElement + public long getFreeMemory() { + return runtime.freeMemory(); + } + + @XmlElement + public long getFreeMemoryMB() { + return runtime.freeMemory() / 1024; + } + + @XmlElement + public long getMaxMemory() { + return runtime.maxMemory(); + } + + @XmlElement + public long getMaxMemoryMB() { + return runtime.maxMemory() / 1024; + } + + @XmlElement + public long getTotalMemory() { + return runtime.totalMemory(); + } + + @XmlElement + public long getTotalMemoryMB() { + return runtime.totalMemory() / 1024; + } + +} diff --git a/src/java/net/brutex/xservices/types/SchedulerStatisticsType.java b/src/java/net/brutex/xservices/types/SchedulerStatisticsType.java new file mode 100644 index 0000000..41fa750 --- /dev/null +++ b/src/java/net/brutex/xservices/types/SchedulerStatisticsType.java @@ -0,0 +1,50 @@ +/* + * Copyright 2012 Brian Rosenberger (Brutex Network) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.brutex.xservices.types; + +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.TimeZone; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlList; +import javax.xml.bind.annotation.XmlType; + +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.core.QuartzScheduler; + +@XmlType +public class SchedulerStatisticsType { + + private final Scheduler scheduler; + + public SchedulerStatisticsType() { + scheduler = null; + } + + public SchedulerStatisticsType(Scheduler scheduler2) { + this.scheduler = scheduler2; + } + + @XmlList + public List getCalendarNames() throws SchedulerException { + return scheduler.getCalendarNames(); + } + +} diff --git a/src/java/net/brutex/xservices/ws/JobService.java b/src/java/net/brutex/xservices/ws/JobService.java index 11898fe..d565b93 100644 --- a/src/java/net/brutex/xservices/ws/JobService.java +++ b/src/java/net/brutex/xservices/ws/JobService.java @@ -24,6 +24,7 @@ import javax.jws.WebService; import javax.xml.bind.annotation.XmlElement; import net.brutex.xservices.types.ScheduledJob; +import net.brutex.xservices.types.SchedulerStatisticsType; import net.brutex.xservices.util.BrutexNamespaces; import org.apache.cxf.annotations.WSDLDocumentation; @@ -42,7 +43,7 @@ public interface JobService { final String OPERATION_SCHEDULEJOB = "scheduleJob"; final String OPERATION_GETJOB = "getJob"; final String OPERATION_DELETEJOB = "deleteJob"; - + final String OPERATION_GETSTATISTICS = "getStatistics"; final String PARAM_JOB = "job"; @@ -92,6 +93,12 @@ public interface JobService { public abstract void deleteJob( @WebParam(name="id") @XmlElement(required=true) String uuid) throws XServicesFault; - + /** + * Get statisctis about the scheduler + * @throws XServicesFault + */ + @WebMethod(operationName=OPERATION_GETSTATISTICS) + @WSDLDocumentation(value="Get scheduler statistics") + public abstract SchedulerStatisticsType getStatistics() throws XServicesFault; } diff --git a/src/java/net/brutex/xservices/ws/MiscService.java b/src/java/net/brutex/xservices/ws/MiscService.java index d472b7e..bafe1a5 100644 --- a/src/java/net/brutex/xservices/ws/MiscService.java +++ b/src/java/net/brutex/xservices/ws/MiscService.java @@ -22,6 +22,7 @@ import net.brutex.xservices.types.HostConnection; import net.brutex.xservices.types.HostinfoType; import net.brutex.xservices.types.MailMimeType; import net.brutex.xservices.types.ReturnCode; +import net.brutex.xservices.types.RuntimeInfoType; import net.brutex.xservices.types.ant.FileSetResource; import net.brutex.xservices.util.BrutexNamespaces; @@ -38,6 +39,8 @@ import org.apache.cxf.annotations.WSDLDocumentation; @WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES) @WSDLDocumentation("Various service operations.") public interface MiscService { + + public static final String OPERATION_GETMEMORY = "getMemory"; /** * Get IP address from host name. @@ -80,4 +83,11 @@ public interface MiscService { @WSDLDocumentation(value = "Generate a UUID.") public String generateUUID(); + /** + * Get Memory information + */ + @WebMethod(operationName = MiscService.OPERATION_GETMEMORY) + @WSDLDocumentation(value = "Get memory and processor information") + public RuntimeInfoType getMemory(); + } diff --git a/src/java/net/brutex/xservices/ws/impl/JobServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/JobServiceImpl.java index 846d966..bc92e05 100644 --- a/src/java/net/brutex/xservices/ws/impl/JobServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/JobServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2011 Brian Rosenberger (Brutex Network) + * Copyright 2012 Brian Rosenberger (Brutex Network) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ */ package net.brutex.xservices.ws.impl; -import static org.quartz.TriggerBuilder.newTrigger; import java.util.ArrayList; import java.util.GregorianCalendar; @@ -37,8 +36,9 @@ import org.quartz.Trigger; import org.quartz.TriggerKey; import org.quartz.impl.StdSchedulerFactory; import org.quartz.impl.matchers.GroupMatcher; - +import static org.quartz.TriggerBuilder.*; import net.brutex.xservices.types.ScheduledJob; +import net.brutex.xservices.types.SchedulerStatisticsType; import net.brutex.xservices.util.BrutexNamespaces; import net.brutex.xservices.util.JobWrapper; import net.brutex.xservices.ws.JobService; @@ -148,4 +148,14 @@ public class JobServiceImpl implements JobService { } } + + public SchedulerStatisticsType getStatistics() throws XServicesFault { + try { + Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); + return new SchedulerStatisticsType(scheduler); + } catch (SchedulerException e) { + throw new XServicesFault(e); + } + } + } diff --git a/src/java/net/brutex/xservices/ws/impl/MiscServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/MiscServiceImpl.java index 99fc030..f70b9df 100644 --- a/src/java/net/brutex/xservices/ws/impl/MiscServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/MiscServiceImpl.java @@ -25,6 +25,7 @@ import net.brutex.xservices.types.HostConnection; import net.brutex.xservices.types.HostinfoType; import net.brutex.xservices.types.MailMimeType; import net.brutex.xservices.types.ReturnCode; +import net.brutex.xservices.types.RuntimeInfoType; import net.brutex.xservices.types.ant.FileSetResource; import net.brutex.xservices.util.BrutexNamespaces; import net.brutex.xservices.util.RunTask; @@ -155,4 +156,8 @@ public class MiscServiceImpl implements MiscService { sleep.setMilliseconds(milliseconds); return runner.postTask(); } + + public RuntimeInfoType getMemory() { + return new RuntimeInfoType(); + } } diff --git a/src/java/net/brutex/xservices/ws/impl/StorageServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/StorageServiceImpl.java index a88ae37..215b97b 100644 --- a/src/java/net/brutex/xservices/ws/impl/StorageServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/StorageServiceImpl.java @@ -34,11 +34,13 @@ public class StorageServiceImpl implements StorageService { public String storeText(String text) throws XServicesFault { // TODO Auto-generated method stub + System.err.println("storeText is not yet implemented"); return null; } public String storeBinary(AttachmentType binary) throws XServicesFault { // TODO Auto-generated method stub + System.err.println("storeBinary is not yet implemented"); return null; } @@ -50,7 +52,7 @@ public class StorageServiceImpl implements StorageService { public void deliverCollection(CollectionType collection, TargetNodeType targetnode, boolean isFiring) throws XServicesFault { // TODO Auto-generated method stub - + System.err.println("deliverCollection is not yet implemented"); } } diff --git a/src/java/net/brutex/xservices/ws/impl/StringServiceImpl.java b/src/java/net/brutex/xservices/ws/impl/StringServiceImpl.java index 37f0a63..1abf394 100644 --- a/src/java/net/brutex/xservices/ws/impl/StringServiceImpl.java +++ b/src/java/net/brutex/xservices/ws/impl/StringServiceImpl.java @@ -15,8 +15,6 @@ */ package net.brutex.xservices.ws.impl; - - import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -35,27 +33,31 @@ import net.brutex.xservices.ws.XServicesFault; @WebService(targetNamespace = BrutexNamespaces.WS_XSERVICES, endpointInterface = "net.brutex.xservices.ws.StringService", serviceName = StringService.SERVICE_NAME) public class StringServiceImpl implements StringService { - public StringReplaceType replaceRegEx(String res, String search, String replace, - String flags) throws XServicesFault { - - int allflags = 0; - if(flags.contains("i")) { - allflags = allflags + Pattern.CASE_INSENSITIVE; + public StringReplaceType replaceRegEx(String res, String search, + String replace, String flags) throws XServicesFault { + try { + int allflags = 0; + if (flags.contains("i")) { + allflags = allflags + Pattern.CASE_INSENSITIVE; + } + Pattern pattern = Pattern.compile(search, allflags); + Matcher matcher = pattern.matcher(res); + int count = 0; + while (matcher.find()) { + count++; + } + if (flags.contains("g")) { + return new StringReplaceType(matcher.replaceAll(replace), count); + } else { + if (count > 1) + count = 1; + return new StringReplaceType(matcher.replaceFirst(replace), + count); + } + } catch (Exception e) { + throw new XServicesFault(e); } - Pattern pattern = Pattern.compile(search, allflags); - Matcher matcher = pattern.matcher(res); - int count = 0; - while( matcher.find()) { - count++; - } - if(flags.contains("g")) { - return new StringReplaceType(matcher.replaceAll(replace), count); - } else { - if(count>1) count = 1; - return new StringReplaceType(matcher.replaceFirst(replace), count); - } - + } - } diff --git a/test/JobServices-soapui-project.xml b/test/JobServices-soapui-project.xml index f642edd..22e62ae 100644 --- a/test/JobServices-soapui-project.xml +++ b/test/JobServices-soapui-project.xml @@ -1,180 +1,234 @@ -http://localhost:8080/XServices/JobServices?wsdl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Get list of scheduled jobs - - - - - - Get a job by id - - - - - - Delete a scheduled job. - - - - - - Schedule a job - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +http://localhost:8080/XServices/JobServices?wsdl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get list of scheduled jobs + + + + + + Get a job by id + + + + + + Get scheduler statistics + + + + + + Delete a scheduled job. + + + + + + Schedule a job + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]>http://schemas.xmlsoap.org/wsdl/http://localhost:8080/XServices/JobServices<xml-fragment/>UTF-8http://localhost:8080/XServices/JobServices @@ -193,7 +247,7 @@ - 2011-12-12T17:00:00+02:00 + 2012-05-14T07:52:00+02:00