Examples of Injection


Examples of org.mortbay.jetty.plus.annotation.Injection

                        &&
                        (!IntrospectionUtil.isTypeCompatible(type, resource.type(), false)))
                    throw new IllegalStateException("@Resource incompatible type="+resource.type()+ " with method param="+type+ " for "+m);
              
                //check if an injection has already been setup for this target by web.xml
                Injection webXmlInjection = webXmlInjections.getInjection(getTargetClass(), m);
               
                if (webXmlInjection == null)
                {
                    try
                    {
                        //try binding name to environment
                        //try the webapp's environment first
                        boolean bound = org.mortbay.jetty.plus.naming.NamingEntryUtil.bindToENC(_webApp, name, mappedName);
                       
                        //try the server's environment
                        if (!bound)
                            bound = org.mortbay.jetty.plus.naming.NamingEntryUtil.bindToENC(_webApp.getServer(), name, mappedName);
                       
                        //try the jvm's environment
                        if (!bound)
                            bound = org.mortbay.jetty.plus.naming.NamingEntryUtil.bindToENC(null, name, mappedName);
                       
                        //TODO if it is an env-entry from web.xml it can be injected, in which case there will be no
                        //NamingEntry, just a value bound in java:comp/env
                        if (!bound)
                        {
                            try
                            {
                                InitialContext ic = new InitialContext();
                                String nameInEnvironment = (mappedName!=null?mappedName:name);
                                ic.lookup("java:comp/env/"+nameInEnvironment);                              
                                bound = true;
                            }
                            catch (NameNotFoundException e)
                            {
                                bound = false;
                            }
                        }
                       
                        if (bound)
                        {
                            Log.debug("Bound "+(mappedName==null?name:mappedName) + " as "+ name);
                            //   Make the Injection for it
                            Injection injection = new Injection();
                            injection.setTargetClass(getTargetClass());
                            injection.setJndiName(name);
                            injection.setMappingName(mappedName);
                            injection.setTarget(m);
                            webXmlInjections.add(injection);
                        }
                        else if (!isEnvEntryType(type))
                        {
View Full Code Here

Examples of org.mortbay.jetty.plus.annotation.Injection

                //get other parts that can be specified in @Resource
                Resource.AuthenticationType auth = resource.authenticationType();
                boolean shareable = resource.shareable();
           
                //check if an injection has already been setup for this target by web.xml
                Injection webXmlInjection = webXmlInjections.getInjection(getTargetClass(), f);
                if (webXmlInjection == null)
                {
                    try
                    {
                        boolean bound = org.mortbay.jetty.plus.naming.NamingEntryUtil.bindToENC(_webApp, name, mappedName);
                        if (!bound)
                            bound = org.mortbay.jetty.plus.naming.NamingEntryUtil.bindToENC(_webApp.getServer(), name, mappedName);
                        if (!bound)
                            bound =  org.mortbay.jetty.plus.naming.NamingEntryUtil.bindToENC(null, name, mappedName);
                        if (!bound)
                        {
                            //see if there is an env-entry value been bound from web.xml
                            try
                            {
                                InitialContext ic = new InitialContext();
                                String nameInEnvironment = (mappedName!=null?mappedName:name);
                                ic.lookup("java:comp/env/"+nameInEnvironment);                              
                                bound = true;
                            }
                            catch (NameNotFoundException e)
                            {
                                bound = false;
                            }
                        }
                        //Check there is a JNDI entry for this annotation
                        if (bound)
                        {
                            Log.debug("Bound "+(mappedName==null?name:mappedName) + " as "+ name);
                            //   Make the Injection for it if the binding succeeded
                            Injection injection = new Injection();
                            injection.setTargetClass(getTargetClass());
                            injection.setJndiName(name);
                            injection.setMappingName(mappedName);
                            injection.setTarget(f);
                            webXmlInjections.add(injection);
                        }
                        else if (!isEnvEntryType(type))
                        {
                            //if this is an env-entry type resource and there is no value bound for it, it isn't
View Full Code Here

Examples of org.mortbay.jetty.plus.annotation.Injection

            // comments in the javaee_5.xsd file specify that the targetName is looked
            // for first as a java bean property, then if that fails, as a field
            try
            {
                Class clazz = getWebAppContext().loadClass(targetClassName);
                Injection injection = new Injection();
                injection.setTargetClass(clazz);
                injection.setJndiName(jndiName);
                injection.setTarget(clazz, targetName, valueClass);
                 _injections.add(injection);
            }
            catch (ClassNotFoundException e)
            {
                Log.warn("Couldn't load injection target class "+targetClassName);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.