Package com.sun.enterprise.container.common.spi.util

Examples of com.sun.enterprise.container.common.spi.util.InjectionException


            JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());

            if( componentEnv != null ) {
                inject(instance.getClass(), instance, componentEnv, null, invokePostConstruct);
            } else {
                throw new InjectionException(localStrings.getLocalString(
                        "injection-manager.no-descriptor-registered-for-invocation",
                        "No descriptor registered for current invocation: {0}", inv));
            }

        } else {
            throw new InjectionException(localStrings.getLocalString(
                    "injection-manager.null-invocation-context", "Null invocation context"));
        }

    }
View Full Code Here


                compEnvManager.getJndiNameEnvironment(componentId);

            if( componentEnv != null ) {
                inject(instance.getClass(), instance, componentEnv, componentId, invokePostConstruct);
            } else {
                throw new InjectionException(localStrings.getLocalString(
                        "injection-manager.no-descriptor-registered-for-component",
                        "No descriptor registered for componentId: {0}", componentId));
            }
        } else {
            throw new InjectionException(localStrings.getLocalString(
                    "injection-manager.null-invocation-context", "Null invocation context"));
        }
    }
View Full Code Here

            } else if (validate || _logger.isLoggable(Level.FINE)) {
                String msg1 = localStrings.getLocalString(
                        "injection-manager.no-descriptor-registered-for-invocation",
                        "No descriptor registered for current invocation: {0}", inv);
                if (validate) {
                    throw new InjectionException(msg1);
                }
                _logger.log(Level.FINE, msg1);
            }
        } else if (validate || _logger.isLoggable(Level.FINE)) {
            String msg2 = localStrings.getLocalString(
                    "injection-manager.null-invocation-context", "Null invocation context");
            if (validate) {
                throw new InjectionException(msg2);
            }
            _logger.log(Level.FINE, msg2);
        }
    }
View Full Code Here

                    injectInstance(managedObject);

                }
            }
        } catch(Exception e) {
            throw new InjectionException(localStrings.getLocalString(
                    "injection-manager.error-creating-managed-object",
                    "Error creating managed object for class: {0}", clazz), e);
        }

        return managedObject;
View Full Code Here

                }
            }

        } catch(Exception e) {
            throw new InjectionException(localStrings.getLocalString(
                    "injection-manager.error-creating-managed-object",
                    "Error creating managed object for class: {0}", clazz), e);
        }

        return managedObject;
View Full Code Here

                       
                        final Field f = getField(target, clazz);
                       
                        if( Modifier.isStatic(f.getModifiers()) &&
                            (instance != null) ) {
                            throw new InjectionException(localStrings.getLocalString(
                                "injection-manager.illegal-use-of-static-field",
                                "Illegal use of static field on class that only supports instance-based injection: {0}",
                                f));
                        }

                        if( (instance == null) &&
                            !Modifier.isStatic(f.getModifiers()) ) {
                            throw new InjectionException(localStrings.getLocalString(
                                "injection-manager.appclient-injected-field-must-be-static",
                                "Injected field: {0} on Application Client class: {1} must be declared static",
                                f, clazz));
                        }


                        if(_logger.isLoggable(Level.FINE)) {
                            _logger.fine(localStrings.getLocalString(
                                "injection-manager.injecting-dependency-field",
                                "Injecting dependency with logical name: {0} into field: {1} on class: {2}",
                                next.getComponentEnvName(), f, clazz));
                        }
                       
                        // Wrap actual value insertion in doPrivileged to
                        // allow for private/protected field access.
                        if( System.getSecurityManager() != null ) {
                            java.security.AccessController.doPrivileged(
                             new java.security.PrivilegedExceptionAction() {
                               public java.lang.Object run() throws Exception {
                                 f.set(instance, value);
                                 return null;
                               }
                             });
                        } else {
                            f.set(instance, value);
                        }
                    } else if( target.isMethodInjectable() ) {
                       
                        final Method m = getMethod(next, target, clazz);

                        if( Modifier.isStatic(m.getModifiers()) &&
                            (instance != null) ) {
                            throw new InjectionException(localStrings.getLocalString(
                                "injection-manager.illegal-use-of-static-method",
                                "Illegal use of static method on class that only supports instance-based injection: {0}",
                                m));
                        }

                        if( (instance == null) &&
                            !Modifier.isStatic(m.getModifiers()) ) {
                            throw new InjectionException(localStrings.getLocalString(
                                "injection-manager.appclient-injected-method-must-be-static",
                                "Injected method: {0} on Application Client class: {1} must be declared static",
                                m, clazz));
                        }
                       
                        if(_logger.isLoggable(Level.FINE)) {
                            _logger.fine(localStrings.getLocalString(
                                "injection-manager.injecting-dependency-method",
                                "Injecting dependency with logical name: {0} into method: {1} on class: {2}",
                                next.getComponentEnvName(), m, clazz));
                        }

                        if( System.getSecurityManager() != null ) {
                          // Wrap actual value insertion in doPrivileged to
                          // allow for private/protected field access.
                          java.security.AccessController.doPrivileged(
                                new java.security.PrivilegedExceptionAction() {
                            public java.lang.Object run() throws Exception {
                                m.invoke(instance, new Object[] { value });
                                return null;
                            }});
                        } else {
                            m.invoke(instance, new Object[] { value });
                        }
                       
                    }
                }
            } catch(Throwable t) {
                Throwable cause = (t instanceof InvocationTargetException) ?
                    ((InvocationTargetException)t).getCause() : t;
                String msg = localStrings.getLocalString(
                        "injection-manager.exception-to-inject",
                        "Exception attempting to inject {0} into {1}: {2}",
                        next, clazz, cause.getMessage());
                _logger.log(Level.FINE, msg, t);
                throw new InjectionException(msg, cause);
            }
        }
    }
View Full Code Here

        } catch( Throwable t) {
            String msg = localStrings.getLocalString(
                    "injection-manager.exception-invoke-lifecycle-method",
                    "Exception attempting invoke lifecycle method: {0}", lifecycleMethod);
            _logger.log(Level.FINE, msg, t);
            InjectionException ie = new InjectionException(msg);
            Throwable cause = (t instanceof InvocationTargetException) ?
                ((InvocationTargetException)t).getCause() : t;
            ie.initCause( cause );
            throw ie;
        }
       
        return;
View Full Code Here

                }
            }
        }

        if( m == null ) {
            throw new InjectionException(localStrings.getLocalString(
                "injection-manager.postconstruct-not-found",
                "InjectionManager exception. PostConstruct method: {0} not found in class: {1}",
                injInfo.getPostConstructMethodName(), injInfo.getClassName()));
        }
View Full Code Here

                }
            }
        }

        if( m == null ) {
            throw new InjectionException(localStrings.getLocalString(
                "injection-manager.predestroy-not-found",
                "InjectionManager exception. PreDestroy method: {0} not found in class: {1}",
                injInfo.getPreDestroyMethodName(), injInfo.getClassName()));
        }
View Full Code Here

            JndiNameEnvironment componentEnv = compEnvManager.getJndiNameEnvironment(inv.getComponentId());

            if( componentEnv != null ) {
                inject(instance.getClass(), instance, componentEnv, null, invokePostConstruct);
            } else {
                throw new InjectionException(localStrings.getLocalString(
                        "injection-manager.no-descriptor-registered-for-invocation",
                        "No descriptor registered for current invocation: {0}", inv));
            }

        } else {
            throw new InjectionException(localStrings.getLocalString(
                    "injection-manager.null-invocation-context", "Null invocation context"));
        }

    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.container.common.spi.util.InjectionException

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.