Package org.glassfish.hk2.api

Examples of org.glassfish.hk2.api.MultiException


                @Override
                public Class<?> loadClass(String className) throws MultiException {
                    try {
                        return binderClassLoader.loadClass(className);
                    } catch (ClassNotFoundException e) {
                        throw new MultiException(e);
                    }
                }
            };
        }
        return defaultLoader;
View Full Code Here


            if (retVal != null) return retVal;
           
            while (creatingDescriptors.containsKey(activeDescriptor)) {
                long holdingLock = creatingDescriptors.get(activeDescriptor);
                if (holdingLock == Thread.currentThread().getId()) {
                    throw new MultiException(new IllegalStateException(
                            "Circular dependency involving " + activeDescriptor.getImplementation() +
                            " was found.  Full descriptor is " + activeDescriptor));
                }
               
                if (throwWouldBlock) {
                    throw new MultiException(new WouldBlockException());
                }
               
                try {
                    this.wait();
                }
                catch (InterruptedException ie) {
                    throw new MultiException(ie);
                }
            }
           
            retVal = (U) backingMap.get(activeDescriptor);
            if (retVal != null) return retVal;
View Full Code Here

       
        try {
            future.get();
        }
        catch (InterruptedException e) {
            throw new MultiException(e);
        }
        catch (ExecutionException e) {
            Throwable cause = e.getCause();
            if (cause instanceof RuntimeException) {
                throw (RuntimeException) cause;
            }
           
            throw new MultiException(cause);
        }
    }
View Full Code Here

                        ErrorInformation.ErrorAction.GO_TO_NEXT_LOWER_LEVEL_AND_STOP, listeners);
               
                if (ErrorInformation.ErrorAction.IGNORE.equals(info.getAction())) return;
               
                if (exception == null) {
                    exception = new MultiException();
                }
               
                exception.addError(th);
            }
        }
View Full Code Here

        }
       
        private void fail(Throwable th) {
            synchronized (lock) {
                if (exception == null) {
                    exception = new MultiException(th);
                }
                else {
                    exception.addError(th);
                }
            }
View Full Code Here

                    try {
                        locator.getServiceHandle(removeMe).destroy();
                    }
                    catch (Throwable th) {
                        if (future != null) {
                          if (serviceDownErrors == null) serviceDownErrors = new MultiException();
                         
                          serviceDownErrors.addError(th);
                           
                        }
                    }
View Full Code Here

            if (retVal != null) return retVal;
           
            while (creatingDescriptors.containsKey(activeDescriptor)) {
                long holdingLock = creatingDescriptors.get(activeDescriptor);
                if (holdingLock == Thread.currentThread().getId()) {
                    throw new MultiException(new IllegalStateException(
                            "Circular dependency involving " + activeDescriptor.getImplementation() +
                            " was found.  Full descriptor is " + activeDescriptor));
                }
               
                if (!blockThread.get()) {
                    throw new MultiException(new WouldBlockException());
                }
               
                try {
                    this.wait();
                }
                catch (InterruptedException ie) {
                    throw new MultiException(ie);
                }
            }
           
            retVal = (U) backingMap.get(activeDescriptor);
            if (retVal != null) return retVal;
View Full Code Here

   
    private final static boolean isACertainException(Throwable th, Class<? extends Throwable> type) {
        Throwable cause = th;
        while (cause != null) {
            if (cause instanceof MultiException) {
                MultiException me = (MultiException) cause;
                for (Throwable innerMulti : me.getErrors()) {
                    if (isACertainException(innerMulti, type)) {
                        return true;
                    }
                }
            }
View Full Code Here

                        descriptor);
               
                if (ErrorInformation.ErrorAction.IGNORE.equals(info.getAction())) return;
               
                if (accumulatedExceptions == null) {
                    accumulatedExceptions = new MultiException();
                }
               
                accumulatedExceptions.addError(th);
            }
        }
View Full Code Here

            if (previousException != null) {
                throw previousException;
            }
           
            if (hardCancelledDescriptors.contains(activeDescriptor)) {
                throw new MultiException(new WasCancelledException(activeDescriptor));
            }
           
            while (creatingDescriptors.containsKey(activeDescriptor)) {
                long holdingLock = creatingDescriptors.get(activeDescriptor);
                if (holdingLock == Thread.currentThread().getId()) {
                    throw new MultiException(new IllegalStateException(
                            "Circular dependency involving " + activeDescriptor.getImplementation() +
                            " was found.  Full descriptor is " + activeDescriptor));
                }
               
                if (throwWouldBlock) {
                    throw new MultiException(new WouldBlockException(activeDescriptor));
                }
               
                try {
                    this.wait();
                }
                catch (InterruptedException ie) {
                    throw new MultiException(ie);
                }
            }
           
            retVal = (U) backingMap.get(activeDescriptor);
            if (retVal != null) return retVal;
           
            previousException = levelErrorMap.get(activeDescriptor);
            if (previousException != null) {
                throw previousException;
            }
           
            if (hardCancelledDescriptors.contains(activeDescriptor)) {
                throw new MultiException(new WasCancelledException(activeDescriptor));
            }
           
            creatingDescriptors.put(activeDescriptor, Thread.currentThread().getId());
           
            localCurrentLevel = currentLevel;
            if (currentTask != null && currentTask.isUp()) {
                localCurrentLevel++;
               
                if (localCurrentLevel > currentTask.getProposedLevel()) {
                    localCurrentLevel = currentTask.getProposedLevel();
                }
            }
        }
       
        RuntimeException error = null;
        try {
            int mode = Utilities.getRunLevelMode(activeDescriptor);

            if (mode == RunLevel.RUNLEVEL_MODE_VALIDATING) {
                validate(activeDescriptor, localCurrentLevel);
            }

            retVal = activeDescriptor.create(root);
           
            return retVal;
        }
        catch (RuntimeException th) {
            if (th instanceof MultiException) {
                if (!CurrentTaskFuture.isWouldBlock((MultiException) th)) {
                    error = th;
                }
               
                // We want WouldBlock rethrown
            }
            else {
                error = th;
            }
           
            throw th;
        }
        finally {
            synchronized (this) {
                boolean hardCancelled = hardCancelledDescriptors.remove(activeDescriptor);
               
                if (retVal != null) {
                    if (!hardCancelled) {
                        backingMap.put(activeDescriptor, retVal);
                        orderedCreationList.addFirst(activeDescriptor);
                    }
                   
                    if (wasCancelled || hardCancelled) {
                        // Even though this service actually ran to completion, we
                        // are going to pretend it failed.  Putting it in the lists
                        // above will ensure it gets properly shutdown
                       
                        MultiException cancelledException = new MultiException(new WasCancelledException(activeDescriptor));
                       
                        if (!hardCancelled) {
                            levelErrorMap.put(activeDescriptor, cancelledException);
                        }
                       
View Full Code Here

TOP

Related Classes of org.glassfish.hk2.api.MultiException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.