JDK-8153732 Add refresh prossibility for known printers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JDK-8153732 Add refresh prossibility for known printers

Patrick Reinhart
Hi everybody,

Now that the JDK 9 is out and the access for printing internal classes
will go away, our currently used work around to refresh the printers
known to the system will be no longer working.

In our case a reboot of our server is very difficult due the fact that
our customers work 24x7. So we would need to attach/detach printers
during a running system. The windows server, where we run our software
has those printers attached as network printers and such a change is not
recognised buy the current printing API.

It would be preferable to somehow signal that an printer change has been
taken place and the known printers to the system has to be refreshed on
the PrintServiceLookup class.

I know, that there are at least two questions around that:


How to handle an method call, that take a long time to complete?
- A possible way would be to pass some reference to an Executor for the
action being run within

What should be done in order such a method is invoked too many times?
- As this method is not be needed to be called a lot, I do not think
that this should be a problem. But if it would be done via an given
Executor, the caller would be responsible to execute

Cheers

Patrick



Reply | Threaded
Open this post in threaded view
|

Re: JDK-8153732 Add refresh prossibility for known printers

Phil Race
Hi,
I think this is the issue you raised last year in this thread, correct ?
http://mail.openjdk.java.net/pipermail/2d-dev/2016-May/006897.html

And the problem is that even though we use the Windows APIs to be notified of a change
in printers, for whatever reason (did we discuss the reasons ?, I don't see a reference but
I think we must have .. ) it is not informing us of changes of remote printers, only local ones.

So you would like an API that will refresh the list without any knowledge of whether it
is actually needed .. but you (somehow) will decide what is a reasonable policy for that.
But it would seem better if possible for Windows to tell us about the update.
I've re-read the docs for FindFirstPrinterChangeNotification
at https://msdn.microsoft.com/en-us/library/windows/desktop/dd162722(v=vs.85).aspx
and I wonder if we just need to include : PRINTER_CHANGE_SERVER in the bitfield ?
The docs there say it is Windows 7 .. and I see a list of unsupported versions here :
https://msdn.microsoft.com/en-us/library/cc244870.aspx#Appendix_A_139
which includes WIndows Server 2008 .. but perhaps anything later than that will be fine.

However the docs are very light on explaining what this bit actually means !
So I am kind of just hoping/guessing here.

What I see at https://stackoverflow.com/questions/14054935/im-getting-duplicated-print-job-on-windows-7-client-machine-for-shared-printer
suggests it might even be triggered for a Print Job arriving at the server which is NOT what
we'd want to hear about.

So can you add anything about your config etc and remind me if you filed a bug/rfe on this ?


-phil.

On 10/28/17, 3:59 AM, Patrick Reinhart wrote:
Hi everybody,

Now that the JDK 9 is out and the access for printing internal classes
will go away, our currently used work around to refresh the printers
known to the system will be no longer working.

In our case a reboot of our server is very difficult due the fact that
our customers work 24x7. So we would need to attach/detach printers
during a running system. The windows server, where we run our software
has those printers attached as network printers and such a change is not
recognised buy the current printing API.

It would be preferable to somehow signal that an printer change has been
taken place and the known printers to the system has to be refreshed on
the PrintServiceLookup class.

I know, that there are at least two questions around that:


How to handle an method call, that take a long time to complete?
- A possible way would be to pass some reference to an Executor for the
action being run within

What should be done in order such a method is invoked too many times?
- As this method is not be needed to be called a lot, I do not think
that this should be a problem. But if it would be done via an given
Executor, the caller would be responsible to execute

Cheers

Patrick



Reply | Threaded
Open this post in threaded view
|

Re: JDK-8153732 Add refresh prossibility for known printers

Patrick Reinhart
Hi Philip,

In advance, thanks for your quick response!

Am 28.10.2017 um 21:01 schrieb Philip Race:
> Hi,
> I think this is the issue you raised last year in this thread, correct ?
> http://mail.openjdk.java.net/pipermail/2d-dev/2016-May/006897.html
Yes, that is correct.

>
> And the problem is that even though we use the Windows APIs to be
> notified of a change
> in printers, for whatever reason (did we discuss the reasons ?, I
> don't see a reference but
> I think we must have .. ) it is not informing us of changes of remote
> printers, only local ones.
>
Exactly, the Windows API that is currently in use does only notify
changes within local printers.
And at the time I raised the issue, there was still code for pre Windows
2000 used. That seems
not be able to catch also changes for remote printers added/removed.

We were searching for an alternative Windows API to achieve this
behaviour, at that time but we
did not found any with support for that need.

> So you would like an API that will refresh the list without any
> knowledge of whether it
> is actually needed .. but you (somehow) will decide what is a
> reasonable policy for that.
That's correct. Our use case is basically that if we need to add/remove
a printer during the
business hours (could be one of those needed printing delivery papers or
so) And for this reason
a manual refresh would be triggered in order to get access for the newly
added printer.

If there is a way to get the current implementation to be notified by
Windows API, then it would
be of course OK too.
But it would seem better if possible for Windows to tell us about the
update.

> I've re-read the docs for FindFirstPrinterChangeNotification
> at
> https://msdn.microsoft.com/en-us/library/windows/desktop/dd162722(v=vs.85).aspx
> and I wonder if we just need to include : PRINTER_CHANGE_SERVER in the
> bitfield ?

Hmm, that could possibly be. I have to say that I do not know if that is
correct. Also I'm not that
familiar with the Windows side of it. But I could certainly try out a
build containing that change
to see if that would work.

> The docs there say it is Windows 7 .. and I see a list of unsupported
> versions here :
> https://msdn.microsoft.com/en-us/library/cc244870.aspx#Appendix_A_139
> which includes WIndows Server 2008 .. but perhaps anything later than
> that will be fine.
>
> However the docs are very light on explaining what this bit actually
> means !
> So I am kind of just hoping/guessing here.

That was also our impression, when we were searching for a potential
solution. But as I said
before, I would be happy to test that part of it. Also if that would
need an installation prior
Windows Server 2008 or (I'm guessing here) Windows 10 would be also OK
in our case, because
the affected customers already use Windows Server 2012.

> What I see at
> https://stackoverflow.com/questions/14054935/im-getting-duplicated-print-job-on-windows-7-client-machine-for-shared-printer
> suggests it might even be triggered for a Print Job arriving at the
> server which is NOT what
> we'd want to hear about.
>
> So can you add anything about your config etc and remind me if you
> filed a bug/rfe on this ?

The problem behaviour is the same as described in JDK-4744405 just using
an Network Printer
instead of an local one. I can raise an Bug for it next Monday as soon I
got hold to our bug
tracking system.

Cheers

Patrick


>
>
> -phil.
>
> On 10/28/17, 3:59 AM, Patrick Reinhart wrote:
>> Hi everybody,
>>
>> Now that the JDK 9 is out and the access for printing internal classes
>> will go away, our currently used work around to refresh the printers
>> known to the system will be no longer working.
>>
>> In our case a reboot of our server is very difficult due the fact that
>> our customers work 24x7. So we would need to attach/detach printers
>> during a running system. The windows server, where we run our software
>> has those printers attached as network printers and such a change is not
>> recognised buy the current printing API.
>>
>> It would be preferable to somehow signal that an printer change has been
>> taken place and the known printers to the system has to be refreshed on
>> the PrintServiceLookup class.
>>
>> I know, that there are at least two questions around that:
>>
>>
>> How to handle an method call, that take a long time to complete?
>> - A possible way would be to pass some reference to an Executor for the
>> action being run within
>>
>> What should be done in order such a method is invoked too many times?
>> - As this method is not be needed to be called a lot, I do not think
>> that this should be a problem. But if it would be done via an given
>> Executor, the caller would be responsible to execute
>>
>> Cheers
>>
>> Patrick
>>
>>
>>


signature.asc (523 bytes) Download Attachment