1 /*
2 * Copyright (c) 2005, 2013, 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
333 try {
334 loader = ServiceLoader.load(Processor.class, classLoader);
335 this.iterator = loader.iterator();
336 } catch (Exception e) {
337 // Fail softly if a loader is not actually needed.
338 this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
339 }
340 } catch (Throwable t) {
341 log.error("proc.service.problem");
342 throw new Abort(t);
343 }
344 }
345
346 public boolean hasNext() {
347 try {
348 return iterator.hasNext();
349 } catch(ServiceConfigurationError sce) {
350 log.error("proc.bad.config.file", sce.getLocalizedMessage());
351 throw new Abort(sce);
352 } catch (Throwable t) {
353 throw new Abort(t);
354 }
355 }
356
357 public Processor next() {
358 try {
359 return iterator.next();
360 } catch (ServiceConfigurationError sce) {
361 log.error("proc.bad.config.file", sce.getLocalizedMessage());
362 throw new Abort(sce);
363 } catch (Throwable t) {
364 throw new Abort(t);
365 }
366 }
367
368 public void remove() {
369 throw new UnsupportedOperationException();
370 }
371
372 public void close() {
373 if (loader != null) {
374 try {
375 loader.reload();
376 } catch(Exception e) {
377 ; // Ignore problems during a call to reload.
378 }
379 }
380 }
381 }
382
383
|
1 /*
2 * Copyright (c) 2005, 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
333 try {
334 loader = ServiceLoader.load(Processor.class, classLoader);
335 this.iterator = loader.iterator();
336 } catch (Exception e) {
337 // Fail softly if a loader is not actually needed.
338 this.iterator = handleServiceLoaderUnavailability("proc.no.service", null);
339 }
340 } catch (Throwable t) {
341 log.error("proc.service.problem");
342 throw new Abort(t);
343 }
344 }
345
346 public boolean hasNext() {
347 try {
348 return iterator.hasNext();
349 } catch(ServiceConfigurationError sce) {
350 log.error("proc.bad.config.file", sce.getLocalizedMessage());
351 throw new Abort(sce);
352 } catch (Throwable t) {
353 log.error("proc.bad.config.file", t.getLocalizedMessage());
354 throw new Abort(t);
355 }
356 }
357
358 public Processor next() {
359 try {
360 return iterator.next();
361 } catch (ServiceConfigurationError sce) {
362 log.error("proc.bad.config.file", sce.getLocalizedMessage());
363 throw new Abort(sce);
364 } catch (UnsupportedClassVersionError ucve) {
365 log.error("proc.cant.load.class", ucve.getLocalizedMessage());
366 throw new Abort(ucve);
367 } catch (ClassFormatError cfe) {
368 log.error("proc.cant.load.class", cfe.getLocalizedMessage());
369 throw new Abort(cfe);
370 } catch (Throwable t) {
371 log.error("proc.bad.config.file", t.getLocalizedMessage());
372 throw new Abort(t);
373 }
374 }
375
376 public void remove() {
377 throw new UnsupportedOperationException();
378 }
379
380 public void close() {
381 if (loader != null) {
382 try {
383 loader.reload();
384 } catch(Exception e) {
385 ; // Ignore problems during a call to reload.
386 }
387 }
388 }
389 }
390
391
|