1 /*
2 * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
487 } catch (ClassNotFoundException e) {
488 newAWTError(e, "Assistive Technology not found: " + atName);
489 } catch (InstantiationException e) {
490 newAWTError(e, "Could not instantiate Assistive Technology: " + atName);
491 } catch (IllegalAccessException e) {
492 newAWTError(e, "Could not access Assistive Technology: " + atName);
493 } catch (Exception e) {
494 newAWTError(e, "Error trying to install Assistive Technology: " + atName);
495 }
496 }
497
498 /**
499 * Loads accessibility support using the property assistive_technologies.
500 * The form is assistive_technologies= followed by a comma-separated list of
501 * assistive technology providers to load. The order in which providers are
502 * loaded is determined by the order in which the ServiceLoader discovers
503 * implementations of the AccessibilityProvider interface, not by the order
504 * of provider names in the property list. When a provider is found its
505 * accessibility implementation will be started by calling the provider's
506 * activate method. All errors are handled via an AWTError exception.
507 */
508 private static void loadAssistiveTechnologies() {
509 // Load any assistive technologies
510 if (atNames != null) {
511 ClassLoader cl = ClassLoader.getSystemClassLoader();
512 Set<String> names = Arrays.stream(atNames.split(","))
513 .map(String::trim)
514 .collect(Collectors.toSet());
515 final Map<String, AccessibilityProvider> providers = new HashMap<>();
516 AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
517 try {
518 for (AccessibilityProvider p : ServiceLoader.load(AccessibilityProvider.class, cl)) {
519 String name = p.getName();
520 if (names.contains(name) && !providers.containsKey(name)) {
521 p.activate();
522 providers.put(name, p);
523 }
524 }
525 } catch (java.util.ServiceConfigurationError | Exception e) {
526 newAWTError(e, "Could not load or activate service provider");
527 }
528 return null;
529 });
530 names.stream()
|
1 /*
2 * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
487 } catch (ClassNotFoundException e) {
488 newAWTError(e, "Assistive Technology not found: " + atName);
489 } catch (InstantiationException e) {
490 newAWTError(e, "Could not instantiate Assistive Technology: " + atName);
491 } catch (IllegalAccessException e) {
492 newAWTError(e, "Could not access Assistive Technology: " + atName);
493 } catch (Exception e) {
494 newAWTError(e, "Error trying to install Assistive Technology: " + atName);
495 }
496 }
497
498 /**
499 * Loads accessibility support using the property assistive_technologies.
500 * The form is assistive_technologies= followed by a comma-separated list of
501 * assistive technology providers to load. The order in which providers are
502 * loaded is determined by the order in which the ServiceLoader discovers
503 * implementations of the AccessibilityProvider interface, not by the order
504 * of provider names in the property list. When a provider is found its
505 * accessibility implementation will be started by calling the provider's
506 * activate method. All errors are handled via an AWTError exception.
507 *
508 * Additionally, if the provided assistive technology providers list is empty
509 * then none of the assistive technology providers will be loaded and
510 * will return without error.
511 */
512 private static void loadAssistiveTechnologies() {
513 // Load any assistive technologies
514 if (atNames != null && !atNames.isEmpty()) {
515 ClassLoader cl = ClassLoader.getSystemClassLoader();
516 Set<String> names = Arrays.stream(atNames.split(","))
517 .map(String::trim)
518 .collect(Collectors.toSet());
519 final Map<String, AccessibilityProvider> providers = new HashMap<>();
520 AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
521 try {
522 for (AccessibilityProvider p : ServiceLoader.load(AccessibilityProvider.class, cl)) {
523 String name = p.getName();
524 if (names.contains(name) && !providers.containsKey(name)) {
525 p.activate();
526 providers.put(name, p);
527 }
528 }
529 } catch (java.util.ServiceConfigurationError | Exception e) {
530 newAWTError(e, "Could not load or activate service provider");
531 }
532 return null;
533 });
534 names.stream()
|