From db87c83a209c2520fc80b4ae57a51594b7c9e638 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Fri, 6 Oct 2017 15:17:58 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30552 --- client/DxPlay/DxPlayer.cs | 74 ++++++++++++++++++- client/DxPlay/FilterGraphTools.cs | 2 + ...eploy-skipinstall-mediacube-modules.launch | 19 +++++ .../run-mediacube-server-localhost.launch | 4 +- server/-configuration/start-mediacube.sh | 3 +- server/-configuration/stop-mediacube.sh | 3 + server/-dependencies/jobengine.target | 3 +- server/-product/mediacube-osgi.bat | 27 ------- server/-product/mediacube.product | 5 +- server/-product/pom.xml | 8 +- .../META-INF/MANIFEST.MF | 2 +- .../META-INF/MANIFEST.MF | 4 +- .../OSGI-INF/HaltCommandProvider.xml} | 2 +- .../WEB-INF/web.xml | 5 ++ .../osgi/console/HaltCommandProvider.java} | 6 +- .../jobengine/osgi/rest/ComponentBinder.java | 50 ++++++------- .../jobengine/osgi/rest/RESTApplications.java | 9 ++- .../rest/TextMessageBodyReaderWriter.java | 14 ++++ .../osgi/rest/jobengine/JobengineService.java | 47 ++++++++++-- 19 files changed, 209 insertions(+), 78 deletions(-) create mode 100644 server/-configuration/deploy-skipinstall-mediacube-modules.launch create mode 100644 server/-configuration/stop-mediacube.sh delete mode 100644 server/-product/mediacube-osgi.bat rename server/{user.jobengine.osgi.server/OSGI-INF/ConsoleCommandProvider.xml => user.jobengine.osgi.services/OSGI-INF/HaltCommandProvider.xml} (78%) rename server/{user.jobengine.osgi.server/src/user/jobengine/osgi/server/ConsoleCommandProvider.java => user.jobengine.osgi.services/src/user/jobengine/osgi/console/HaltCommandProvider.java} (90%) create mode 100644 server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/TextMessageBodyReaderWriter.java diff --git a/client/DxPlay/DxPlayer.cs b/client/DxPlay/DxPlayer.cs index 4ffb3db6..aadd6b52 100644 --- a/client/DxPlay/DxPlayer.cs +++ b/client/DxPlay/DxPlayer.cs @@ -204,7 +204,7 @@ namespace DxPlay { // Build the capture graph for grabber and renderer. // (Control to show video in, Filename to play) - private void SetupGraph(Control hWin) { + private void SetupGraphLAV(Control hWin) { int hr; m_videoWidth = MediaDescription.Resolution.Width; @@ -227,8 +227,8 @@ namespace DxPlay { hr = m_FilterGraph.AddSourceFilter(MediaDescription.FileName, MediaDescription.FileName, out sourceFilter); DsError.ThrowExceptionForHR(hr); - IBaseFilter splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "LAV Splitter"); - //IBaseFilter splitter = FilterGraphTools.AddFilterByDevicePath(graphBuilder, @"c:\Programs\LAVFilters\LAVSplitter.ax", "LAV Splitter"); + //IBaseFilter splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "LAV Splitter"); + IBaseFilter splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "SONY MXF Splitter"); if (splitter == null) throw new Exception("No splitter!"); @@ -280,6 +280,74 @@ namespace DxPlay { #endif } + private void SetupGraph(Control hWin) { + int hr; + + m_videoWidth = MediaDescription.Resolution.Width; + m_videoHeight = MediaDescription.Resolution.Height; + + try { + m_FilterGraph = new FilterGraph() as IFilterGraph2; + + IGraphBuilder graphBuilder = m_FilterGraph as IGraphBuilder; + m_mediaSeek = m_FilterGraph as IMediaSeeking; + m_mediaPosition = m_FilterGraph as IMediaPosition; + m_mediaEvent = m_FilterGraph as IMediaEvent; + m_mediaCtrl = m_FilterGraph as IMediaControl; + m_videoWindow = m_FilterGraph as IVideoWindow; + + IBaseFilter sourceFilter = null; + hr = m_FilterGraph.AddSourceFilter(MediaDescription.FileName, MediaDescription.FileName, out sourceFilter); + DsError.ThrowExceptionForHR(hr); + + //Type typeFromClsid = Type.GetTypeFromCLSID(new Guid("CCE7BD95-3BC4-4cfb-9664-0BF83201BE09")); + //IBaseFilter splitter = (IBaseFilter)Activator.CreateInstance(typeFromClsid); + + IBaseFilter splitter = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "Sony MXF Splitter"); + if (splitter == null) + throw new Exception("No splitter!"); + + FilterGraphTools.ConnectFilters(graphBuilder, sourceFilter, "Output", splitter, "Input", true); + + IBaseFilter videoDecoder = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "Sony MPEG Video Decoder Pro"); + if (videoDecoder == null) + throw new Exception("No video decoder!"); + + FilterGraphTools.ConnectFilters(graphBuilder, splitter, "Video", videoDecoder, "Input", true); + + IBaseFilter sampGrabber = (IBaseFilter)new SampleGrabber(); + ConfigureSampleGrabber((ISampleGrabber)sampGrabber); + hr = m_FilterGraph.AddFilter(sampGrabber, "Sample Grabber"); + DsError.ThrowExceptionForHR(hr); + + FilterGraphTools.ConnectFilters(graphBuilder, videoDecoder, "Output", sampGrabber, "Input", true); + + m_videoRenderer = (IBaseFilter)new VideoMixingRenderer9(); + hr = m_FilterGraph.AddFilter(m_videoRenderer, "Video Mixing Renderer 9"); + DsError.ThrowExceptionForHR(hr); + + FilterGraphTools.ConnectFilters(graphBuilder, sampGrabber, "Output", m_videoRenderer, "VMR Input0", true); + + ConfigureVideoWindow(hWin); + + if (DsFindPin.ByName(splitter, "Audio") != null) { + IBaseFilter audioDecoder = FilterGraphTools.AddFilterByName(graphBuilder, FilterCategory.LegacyAmFilterCategory, "SONY Audio Mixer"); + if (audioDecoder == null) + throw new Exception("No audio decoder!"); + + FilterGraphTools.ConnectFilters(graphBuilder, splitter, "Audio", audioDecoder, "Input", true); + FilterGraphTools.RenderPin(graphBuilder, audioDecoder, "Output"); + } + + SaveSizeInfo(sampGrabber as ISampleGrabber); + + } + catch (Exception e) { + Debug.WriteLine(e.Message); + } + finally { + } + } // Configure the video window private void ConfigureVideoWindow(Control hWin) { diff --git a/client/DxPlay/FilterGraphTools.cs b/client/DxPlay/FilterGraphTools.cs index 4a75a06d..f3a47197 100644 --- a/client/DxPlay/FilterGraphTools.cs +++ b/client/DxPlay/FilterGraphTools.cs @@ -11,6 +11,7 @@ using System.Runtime.InteropServices; using System.Security.Permissions; using DirectShowLib; +using System.Diagnostics; #if !USING_NET11 using System.Runtime.InteropServices.ComTypes; @@ -116,6 +117,7 @@ namespace DirectShowLib.Utils { DsDevice[] devices = DsDevice.GetDevicesOfCat(deviceCategory); for (int i = 0; i < devices.Length; i++) { + Debug.WriteLine("Found " + devices[i].Name); if (string.IsNullOrEmpty(devices[i].Name)) //if the name is empty ignore the filter continue; else { diff --git a/server/-configuration/deploy-skipinstall-mediacube-modules.launch b/server/-configuration/deploy-skipinstall-mediacube-modules.launch new file mode 100644 index 00000000..53673e00 --- /dev/null +++ b/server/-configuration/deploy-skipinstall-mediacube-modules.launch @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/server/-configuration/run-mediacube-server-localhost.launch b/server/-configuration/run-mediacube-server-localhost.launch index 1cbf6e74..842617af 100644 --- a/server/-configuration/run-mediacube-server-localhost.launch +++ b/server/-configuration/run-mediacube-server-localhost.launch @@ -19,10 +19,10 @@ - + - + diff --git a/server/-configuration/start-mediacube.sh b/server/-configuration/start-mediacube.sh index d0fbed97..da80980a 100644 --- a/server/-configuration/start-mediacube.sh +++ b/server/-configuration/start-mediacube.sh @@ -1,3 +1,4 @@ +cd /opt/mediacube export DSMI_CONFIG=/opt/mediacube/configuration/dsm.opt export DSMI_DIR=/opt/tivoli/tsm/client/api/bin64 export DSMI_LOG=/opt/mediacube/log @@ -8,4 +9,4 @@ export LIBPATH=/opt/tivoli/tsm/client/ba/bin:/opt/tivoli/tsm/client/api/bin64 export SHLIB_PATH=/opt/tivoli/tsm/client/ba/bin:/opt/tivoli/tsm/client/api/bin64 export TZ=NFT-1DFT,M3.5.0,M10.5.0 export PATH=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64/bin:$PATH -nohup ./mediacube & \ No newline at end of file +nohup ./mediacube /dev/null & diff --git a/server/-configuration/stop-mediacube.sh b/server/-configuration/stop-mediacube.sh new file mode 100644 index 00000000..d7f1a895 --- /dev/null +++ b/server/-configuration/stop-mediacube.sh @@ -0,0 +1,3 @@ +wget -qO- http://localhost:8080/services/rest/jobengine/halt +exit 0 + diff --git a/server/-dependencies/jobengine.target b/server/-dependencies/jobengine.target index 6552a7bb..a059c44e 100644 --- a/server/-dependencies/jobengine.target +++ b/server/-dependencies/jobengine.target @@ -1,5 +1,5 @@ - + @@ -106,6 +106,7 @@ + diff --git a/server/-product/mediacube-osgi.bat b/server/-product/mediacube-osgi.bat deleted file mode 100644 index 93154ce1..00000000 --- a/server/-product/mediacube-osgi.bat +++ /dev/null @@ -1,27 +0,0 @@ -java -jar plugins/org.eclipse.osgi_3.11.3.v20170209-1843.jar ^ --configuration configuration/config.ini ^ --console ^ --consoleLog ^ --Dorg.eclipse.equinox.http.jetty.http.port=8080 ^ --Dorg.eclipse.epp.logging.aeri.skipReports=true ^ --Declipse.ignoreApp=true ^ --Dosgi.noShutdown=true ^ --Djetty.home=./configuration/etc ^ --Djetty.etc.config.urls=user-jetty.xml,user-jetty-ssl.xml,user-jetty-ssl-context.xml,user-jetty-http.xml,user-jetty-https.xml ^ --Dlog4j.configuration=./configuration/log4j.properties ^ --Djobengine.loglevel=INFO ^ --Djobengine.jobsteps.root=./configuration/executors ^ --Djobengine.jobtemplates.root=./configuration/templates ^ --Djobengine.db.url=jdbc:db2://10.228.198.1:50000/mediaarc:retrieveMessagesFromServerOnGetMessage=true; ^ --Djobengine.db.user=db2admin ^ --Djobengine.db.password=password ^ --Djobengine.octopus.api.address=http://10.10.1.21/api/v1 ^ --Djobengine.octopus.api.user=mam ^ --Djobengine.octopus.api.password=napocska ^ --Djobengine.octopus.db.url=jdbc:db2://10.228.198.1:50000/mccache:retrieveMessagesFromServerOnGetMessage=true; ^ --Djobengine.octopus.db.user=db2admin ^ --Djobengine.octopus.db.password=password ^ --Djobengine.octopus.db.schema=test ^ --Djobengine.rcc.host=localhost ^ --Djobengine.rcc.defaultlowresprofile=MediaCube-H264 ^ --Djobengine.transcoder.source=c:\_Movie\hires\ diff --git a/server/-product/mediacube.product b/server/-product/mediacube.product index 28c4d974..a06024d9 100644 --- a/server/-product/mediacube.product +++ b/server/-product/mediacube.product @@ -154,8 +154,9 @@ - - + + + diff --git a/server/-product/pom.xml b/server/-product/pom.xml index d648665d..1bac3f52 100644 --- a/server/-product/pom.xml +++ b/server/-product/pom.xml @@ -229,6 +229,7 @@ ${basedir}/../-configuration start-mediacube.sh + stop-mediacube.sh @@ -247,6 +248,7 @@ ${basedir}/../-configuration start-mediacube.sh + stop-mediacube.sh @@ -272,10 +274,14 @@ /command "open ${remote.address} -hostkey=""${remote.hostkey}""" + "call ${remote.location}/stop-mediacube.sh 2>/dev/null" + "call rm -rf ${remote.location}" + "call mkdir ${remote.location}" "lcd ${local.location}" "cd ${remote.location}" - "synchronize remote" + "synchronize remote -criteria=size" "call chmod +x mediacube" + "call chmod +x stop-mediacube.sh" "call chmod +x start-mediacube.sh" "call ./start-mediacube.sh" "exit" diff --git a/server/user.jobengine.osgi.server/META-INF/MANIFEST.MF b/server/user.jobengine.osgi.server/META-INF/MANIFEST.MF index 51e7912d..4c2176b3 100644 --- a/server/user.jobengine.osgi.server/META-INF/MANIFEST.MF +++ b/server/user.jobengine.osgi.server/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Server Bundle-SymbolicName: user.jobengine.osgi.server;singleton:=true Bundle-Version: 1.0.0 -Service-Component: OSGI-INF/component.xml, OSGI-INF/ConsoleCommandProvider.xml +Service-Component: OSGI-INF/component.xml Import-Package: javax.servlet;version="3.1.0", javax.servlet.http;version="3.1.0", org.apache.logging.log4j.core;version="2.8.2", diff --git a/server/user.jobengine.osgi.services/META-INF/MANIFEST.MF b/server/user.jobengine.osgi.services/META-INF/MANIFEST.MF index 38f7ec1a..2737ccd1 100644 --- a/server/user.jobengine.osgi.services/META-INF/MANIFEST.MF +++ b/server/user.jobengine.osgi.services/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: Services Bundle-SymbolicName: user.jobengine.osgi.services;singleton:=true Bundle-Version: 1.0.0 Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Service-Component: OSGI-INF/component.xml +Service-Component: OSGI-INF/component.xml, OSGI-INF/HaltCommandProvider.xml Bundle-ActivationPolicy: lazy Web-ContextPath: /services Import-Package: com.fasterxml.jackson.annotation;version="2.4.5", @@ -23,9 +23,11 @@ Import-Package: com.fasterxml.jackson.annotation;version="2.4.5", javax.ws.rs.core;version="2.0.1", javax.ws.rs.ext;version="2.0.1", org.apache.logging.log4j;version="2.8.2", + org.eclipse.core.runtime.adaptor, org.eclipse.jetty.util;version="9.3.9", org.eclipse.jetty.websocket.api;version="9.3.9", org.eclipse.jetty.websocket.servlet;version="9.3.9", + org.eclipse.osgi.framework.console;version="1.1.0", org.joda.time;version="2.2.0", org.joda.time.base;version="2.2.0", org.osgi.framework;version="1.8.0", diff --git a/server/user.jobengine.osgi.server/OSGI-INF/ConsoleCommandProvider.xml b/server/user.jobengine.osgi.services/OSGI-INF/HaltCommandProvider.xml similarity index 78% rename from server/user.jobengine.osgi.server/OSGI-INF/ConsoleCommandProvider.xml rename to server/user.jobengine.osgi.services/OSGI-INF/HaltCommandProvider.xml index 7a46c0c5..50904575 100644 --- a/server/user.jobengine.osgi.server/OSGI-INF/ConsoleCommandProvider.xml +++ b/server/user.jobengine.osgi.services/OSGI-INF/HaltCommandProvider.xml @@ -3,5 +3,5 @@ - + \ No newline at end of file diff --git a/server/user.jobengine.osgi.services/WEB-INF/web.xml b/server/user.jobengine.osgi.services/WEB-INF/web.xml index cc895b43..8702cb52 100644 --- a/server/user.jobengine.osgi.services/WEB-INF/web.xml +++ b/server/user.jobengine.osgi.services/WEB-INF/web.xml @@ -14,6 +14,11 @@ user.jobengine.osgi.rest.RESTApplications + + + org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap + + resteasy.servlet.mapping.prefix /rest diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/osgi/server/ConsoleCommandProvider.java b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/console/HaltCommandProvider.java similarity index 90% rename from server/user.jobengine.osgi.server/src/user/jobengine/osgi/server/ConsoleCommandProvider.java rename to server/user.jobengine.osgi.services/src/user/jobengine/osgi/console/HaltCommandProvider.java index 36b6e265..63550af7 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/osgi/server/ConsoleCommandProvider.java +++ b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/console/HaltCommandProvider.java @@ -1,4 +1,4 @@ -package user.jobengine.osgi.server; +package user.jobengine.osgi.console; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -23,10 +23,10 @@ import user.jobengine.server.IJobEngine; // logger.info("Stopping {} ", b.getSymbolicName()); // b.stop(); // } -public class ConsoleCommandProvider implements CommandProvider { +@SuppressWarnings("restriction") +public class HaltCommandProvider implements CommandProvider { private static final Logger logger = LogManager.getLogger(); - @SuppressWarnings("restriction") public Object _halt(CommandInterpreter intp) { final StringBuffer buffer = new StringBuffer(); Thread shutdownThread = new Thread(() -> { diff --git a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/ComponentBinder.java b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/ComponentBinder.java index f3d1a61f..7a82199b 100644 --- a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/ComponentBinder.java +++ b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/ComponentBinder.java @@ -15,7 +15,28 @@ public class ComponentBinder { private static IOctopusAPI octopusService; private static INexioAPI nexioService; - public void start() { + public static IItemManager getItemManagerService() { + if (itemManagerService == null) + throw new RuntimeException("IItemManager is null"); + return itemManagerService; + } + + public static IJobEngine getJobengineService() { + if (jobengineService == null) + throw new RuntimeException("IJobEngine is null"); + return jobengineService; + } + + public static INexioAPI getNexioService() { + if (nexioService == null) + throw new RuntimeException("INexioAPI is null"); + return nexioService; + } + + public static IOctopusAPI getOctopusService() { + if (octopusService == null) + throw new RuntimeException("IOctopusAPI is null"); + return octopusService; } public synchronized void bindService(Object service) { @@ -41,6 +62,9 @@ public class ComponentBinder { } } + public void start() { + } + public synchronized void unbindService(Object service) { if (service instanceof IJobEngine) { jobengineService = null; @@ -63,28 +87,4 @@ public class ComponentBinder { return; } } - - public static IJobEngine getJobengineService() { - if (jobengineService == null) - throw new RuntimeException("IJobEngine is null"); - return jobengineService; - } - - public static IItemManager getItemManagerService() { - if (itemManagerService == null) - throw new RuntimeException("IItemManager is null"); - return itemManagerService; - } - - public static IOctopusAPI getOctopusService() { - if (octopusService == null) - throw new RuntimeException("IOctopusAPI is null"); - return octopusService; - } - - public static INexioAPI getNexioService() { - if (nexioService == null) - throw new RuntimeException("INexioAPI is null"); - return nexioService; - } } diff --git a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/RESTApplications.java b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/RESTApplications.java index cfc1d088..ab81c22f 100644 --- a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/RESTApplications.java +++ b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/RESTApplications.java @@ -11,9 +11,14 @@ import user.jobengine.osgi.rest.octopus.OctopusRESTService; public class RESTApplications extends Application { + public RESTApplications() { + // ResteasyProviderFactory instance = ResteasyProviderFactory.getInstance(); + // instance.registerProvider(DefaultTextPlain.class, true); + // System.out.println(""); + } + @Override public Set> getClasses() { - return new HashSet<>( - Arrays.asList(OctopusRESTService.class, JobengineService.class, JacksonJsonProvider.class)); + return new HashSet<>(Arrays.asList(OctopusRESTService.class, JobengineService.class, JacksonJsonProvider.class, TextMessageBodyReaderWriter.class)); } } diff --git a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/TextMessageBodyReaderWriter.java b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/TextMessageBodyReaderWriter.java new file mode 100644 index 00000000..e41e6da2 --- /dev/null +++ b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/TextMessageBodyReaderWriter.java @@ -0,0 +1,14 @@ +package user.jobengine.osgi.rest; + +import javax.ws.rs.Consumes; +import javax.ws.rs.Produces; +import javax.ws.rs.ext.Provider; + +import org.jboss.resteasy.plugins.providers.DefaultTextPlain; + +@Provider +@Produces({ "text/plain", "text/html" }) +@Consumes({ "text/plain" }) +public class TextMessageBodyReaderWriter extends DefaultTextPlain { + +} \ No newline at end of file diff --git a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/jobengine/JobengineService.java b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/jobengine/JobengineService.java index 142e244b..426ec305 100644 --- a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/jobengine/JobengineService.java +++ b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/jobengine/JobengineService.java @@ -10,13 +10,16 @@ import javax.ws.rs.core.Response; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.eclipse.core.runtime.adaptor.EclipseStarter; import user.jobengine.db.IItemManager; import user.jobengine.db.Item; import user.jobengine.db.JSONBase; import user.jobengine.osgi.rest.ComponentBinder; +import user.jobengine.server.IJobEngine; @Path("/jobengine") +@SuppressWarnings("restriction") public class JobengineService { private static final Logger logger = LogManager.getLogger(); @@ -26,6 +29,23 @@ public class JobengineService { logger.info("Created"); } + @POST + @Path("/create") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public Response create(JSONBase entity) { + Response result = null; + try { + if (itemManager == null) + throw new Exception("No ItemManager found"); + itemManager.add(entity); + result = Response.ok().entity(entity).build(); + } catch (Exception e) { + result = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); + } + return result; + } + @GET @Path("/item") @Consumes({ MediaType.APPLICATION_JSON }) @@ -43,17 +63,28 @@ public class JobengineService { return result; } - @POST - @Path("/create") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public Response create(JSONBase entity) { + @GET + @Path("/halt") + public Response halt() { Response result = null; try { - if (itemManager == null) + final IJobEngine jobEngine = ComponentBinder.getJobengineService(); + if (jobEngine == null) throw new Exception("No ItemManager found"); - itemManager.add(entity); - result = Response.ok().entity(entity).build(); + + Thread shutdownThread = new Thread(() -> { + try { + Thread.sleep(1000); + jobEngine.shutdown(); + EclipseStarter.shutdown(); + System.exit(0); + } catch (Exception e) { + logger.error("Error:", e); + } + }); + shutdownThread.start(); + + result = Response.ok().build(); } catch (Exception e) { result = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } -- 2.54.0