AndreasFagschlunger / O2Xfs

Java API for accessing CEN/XFS API, EMV Level 2 Kernel
47 stars 28 forks source link

How to repeat to execute XfsStartUpTask and ShutdownTask #51

Closed jifffffy closed 6 years ago

jifffffy commented 6 years ago

Hi, I met a problem. I know the current version can not perform the XfsStartUpTask . So I made a few changes: 1、I add a MenuCommand in menu.xml

`

at.o2xfs.operator.task.xfs.XfsStartUpTask

`

so I can perform the XfsStartUpTask in the menu panel. 2、I commented ui.close in at.o2xfs.operator.O2XfsOperator#shutdown method :

   public void shutdown() {
    /*for (final UserInterface ui : userInterfaces) {
        ui.close();
    }*/
    XfsServiceManager.getInstance().shutdown();
}

3、I set next task in the ShutdownTask:


public void doExecute() { getCommands().clear(); O2XfsOperator.getInstance().shutdown();

    getCommands().setNextCommand(new DefaultTaskCommand(taskManager));

}

When I finished modifying. I lanuch O2XfsOperator. the XfsStartUpTask show success, then I click next and click ShutdownTask. finally I click the XfsStartUpTask. Unfortunately I got a mistake which shows a invalid hWnd in the XfsStartUpTask's panel .

So my question is whether the current version supports to repeat to execute XfsStartUpTask and ShutdownTask, If yes what should I do ?

AndreasFagschlunger commented 6 years ago

Hi James! The last time I checked XfsStartupTask did work, since it is vital for all other (Xfs) Tasks. And I don't see any scenario where someone would disconnect and reconnect to the XFS Manager in the same JVM. So I never tested the behavior in such a case. First problem I see, XfsServiceManager creates MessageHandler in its constructor. and closes it on shutdown. Since it's a singleton, MessageHandler never gets reinitialized and stays invalid afterwards.

There is also an open issue #35 where a service can't be closed and re-opened, which indeed is a valid use case.

Please also note that I currently don't have the intention to continue at.o2xfs.operator as it is, since it's very hard to maintain an customize. I'm currently working on a solution using a web based UI.

jifffffy commented 6 years ago

Thank you for your reply! Yes I know XfsServiceManager is a singleton. so I set instance is null when I shutdown, but since hWnd is stay the pre window, I can not RegisterClass a new hWnd in MessageHandler. Perhaps to provide a UnregisterClass in MessageHandler.cpp to work. I am developing a test program, I need to open and close service frequently . I am very interested in your web based UI, how is it going?

AndreasFagschlunger commented 6 years ago

Hello James!

I did some changes and following code:

        XfsServiceManager serviceManager = XfsServiceManager.getInstance();
        serviceManager.initialize();
        serviceManager.shutdown();
        serviceManager.initialize();
        serviceManager.shutdown();

Now runs without any errors:

DLL_PROCESS_ATTACH
MSG LOOP - START
WFSStartUp: 2.0 - 3.20
MSG LOOP - END
UnregisterClass successful.
MSG LOOP - START
WFSStartUp: 2.0 - 3.20
MSG LOOP - END
UnregisterClass successful.
DLL_PROCESS_DETACH

Related to the Web UI I'm currently working on the proof of concept and it is promising. I don't have much time to work on it, so it may take months until a first running demo.

As you mentioned testing, I once had the idea to provide a custom MessageHandler implementation. This would allow units tests to work without any real XFS Manager.

jifffffy commented 6 years ago

Thank you very much, I will try it!

jifffffy commented 6 years ago

Sorry , I found I can not build it. How do I get this function in the quickest way? I have pulled the develop brunch, I encountered a mistake when I build in the at.o2xfs.win32 > LPZZSTRTest.

java.lang.UnsatisfiedLinkError: at.o2xfs.win32.Sizeof.sizeofLpvoid()I at at.o2xfs.win32.Sizeof.sizeofLpvoid(Native Method) at at.o2xfs.win32.Sizeof.<clinit>(Sizeof.java:38) at at.o2xfs.win32.Pointer.<init>(Pointer.java:50) at at.o2xfs.win32.Pointer.<init>(Pointer.java:69) at at.o2xfs.win32.Pointer.<clinit>(Pointer.java:42) at at.o2xfs.win32.LPZZSTRTest.test(LPZZSTRTest.java:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy1.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748)

Since MessageHandler changes , I need a updated win32.dll as I can not compile native right now. What should I do? Thanks very much!

AndreasFagschlunger commented 6 years ago

Hi!

I've setup a CI build, so every change made will end up in a public repository:

https://repo.fagschlunger.co.at/

The build you need should be here.

jifffffy commented 6 years ago

Thank you very much! This is a cool feature!