Package javax.ws.rs.core

Examples of javax.ws.rs.core.Application


        }
    }
   
    protected void createServerFromApplication(String cName) throws ServletException {
        Class<?> appClass = loadClass(cName, "Application");
        Application app = null;
        try {
            app = (Application)appClass.newInstance();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
            throw new ServletException("Application class " + cName
                                       + " can not be instantiated");
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
            throw new ServletException("Application class " + cName
                                       + " can not be instantiated due to IllegalAccessException");
        }
       
        verifySingletons(app.getSingletons());
       
        List<Class> resourceClasses = new ArrayList<Class>();
        List<Object> providers = new ArrayList<Object>();
        Map<Class, ResourceProvider> map = new HashMap<Class, ResourceProvider>();
       
        // at the moment we don't support per-request providers, only resource classes
        // Note, app.getClasse() returns a list of per-resource classes
        for (Class<?> c : app.getClasses()) {
            if (isValidPerRequestResourceClass(c, app.getSingletons())) {
                resourceClasses.add(c);
                map.put(c, new PerRequestResourceProvider(c));
            }
        }
       
        // we can get either a provider or resource class here       
        for (Object o : app.getSingletons()) {
            boolean isProvider = o.getClass().getAnnotation(Provider.class) != null;
            if (isProvider) {
                providers.add(o);
            } else {
                resourceClasses.add(o.getClass());
View Full Code Here


            throw new ServletException("\"" + IGNORE_APP_PATH_PARAM
                + "\" parameter must be set to false for multiple Applications be supported");
        }
       
        for (String cName : classNames) {
            Application app = createApplicationInstance(cName, servletConfig);
           
            JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app,
                                                ignoreApplicationPath,
                                                getStaticSubResolutionValue(servletConfig));
            String splitChar = getParameterSplitChar(servletConfig);
View Full Code Here

    }
   
    protected void createServerFromApplication(String cName, ServletConfig servletConfig)
        throws ServletException {
        Class<?> appClass = loadClass(cName, "Application");
        Application app = null;
        try {
            app = (Application)appClass.newInstance();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
            throw new ServletException("Application class " + cName
View Full Code Here

         String application = servletConfig.getInitParameter("javax.ws.rs.Application");
         if (application != null)
         {
            try
            {
               Application app = (Application) Thread.currentThread().getContextClassLoader().loadClass(application.trim()).newInstance();
               processApplication(app);
            }
            catch (Exception e)
            {
               throw new RuntimeException(e);
View Full Code Here

      }

      ConstructorInjector constructorInjector = providerFactory.getInjectorFactory().createConstructor(clazz.getConstructors()[0]);
      PropertyInjector propertyInjector = providerFactory.getInjectorFactory().createPropertyInjector(clazz);

      Application application = (Application) constructorInjector.construct();
      propertyInjector.inject(application);
      return application;
   }
View Full Code Here

                        if (Modifier.isAbstract(clazz.getModifiers())) {
                            continue;
                        }

                        try {
                            final Application app = Application.class.cast(clazz.newInstance());
                            try {
                                if (!app.getClasses().isEmpty()) {
                                    classes.addAll(app.getClasses());
                                } else {
                                    addRestClassesToScannedClasses(webModule, classes, classLoader);
                                }
                            } catch (final RuntimeException npe) {
                                if (app == null) {
View Full Code Here

        assertEquals("test/bar", sub.getProduceMime().get(0).toString());
    }
   
    @Test
    public void testNameBindings() {
        Application app = new TestApplication();
        JAXRSServerFactoryBean bean = ResourceUtils.createApplication(app, true, true);
        ClassResourceInfo cri = bean.getServiceFactory().getClassResourceInfo().get(0);
        List<String> names = cri.getNameBindings();
        assertEquals(Collections.singletonList(CustomNameBinding.class.getName()), names);
    }
View Full Code Here

                }
                LOGGER.info("REST service deployed: " + clazz);
            }
        } else {
            for (String app : webApp.restApplications) { // normally a unique one but we support more
                Application appInstance;
                try {
                    appInstance = Application.class.cast(load(classLoader, app));
                } catch (ClassNotFoundException e) {
                    throw new OpenEJBRestRuntimeException("can't find class " + app, e);
                }

                for (Object o : appInstance.getSingletons()) {
                    deploySingleton(webApp.contextRoot, o, appInstance, classLoader);
                    LOGGER.info("deployed REST singleton: " + o);
                }
                for (Class<?> clazz : appInstance.getClasses()) {
                    deployPojo(webApp.contextRoot, clazz, appInstance, classLoader, injections, context);
                    LOGGER.info("deployed REST class: " + clazz);
                }

                LOGGER.info("REST application deployed: " + app);
View Full Code Here

       
    }
   
    protected void createServerFromApplication(String cName) throws ServletException {
        Class<?> appClass = loadClass(cName, "Application");
        Application app = null;
        try {
            app = (Application)appClass.newInstance();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
            throw new ServletException("Application class " + cName
                                       + " can not be instantiated");
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
            throw new ServletException("Application class " + cName
                                       + " can not be instantiated due to IllegalAccessException");
        }
       
        verifySingletons(app.getSingletons());
       
        List<Class> resourceClasses = new ArrayList<Class>();
        List<Object> providers = new ArrayList<Object>();
        Map<Class, ResourceProvider> map = new HashMap<Class, ResourceProvider>();
       
        // at the moment we don't support per-request providers, only resource classes
        // Note, app.getClasse() returns a list of per-resource classes
        for (Class<?> c : app.getClasses()) {
            if (isValidPerRequestResourceClass(c, app.getSingletons())) {
                resourceClasses.add(c);
                map.put(c, new PerRequestResourceProvider(c));
            }
        }
       
        // we can get either a provider or resource class here       
        for (Object o : app.getSingletons()) {
            boolean isProvider = o.getClass().getAnnotation(Provider.class) != null;
            if (isProvider) {
                providers.add(o);
            } else {
                resourceClasses.add(o.getClass());
View Full Code Here

                            classes.add(clazz);
                        } catch (ClassNotFoundException e) {
                            throw new OpenEJBException("Unable to load Application class: " + application, e);
                        }
                        try {
                            Application app = Application.class.cast(clazz.newInstance());
                            classes.addAll(app.getClasses());
                        } catch (InstantiationException e) {
                            throw new OpenEJBException("Unable to instantiate Application class: " + application, e);
                        } catch (IllegalAccessException e) {
                            throw new OpenEJBException("Unable to access Application class: " + application, e);
                        }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Application

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.