@Test public void unproxy() { final JAXRSServerFactoryBean bean = new CxfJaxrsServiceRegistrator( null, null, emptyMap(), null ).createEndpoint(new Application() { @Override public Set<Object> getSingletons() { return singleton(new MyResource$$Proxy()); } }, JAXRSServerFactoryBean.class); bean.setStart(false); bean.create(); assertEquals(singletonList(MyResource.class), bean.getResourceClasses()); final ClassResourceInfo cri = bean.getServiceFactory().getClassResourceInfo().iterator().next(); assertEquals(MyResource.class, cri.getServiceClass()); assertEquals(MyResource.class, cri.getResourceClass()); assertTrue(SingletonResourceProvider.class.isInstance(cri.getResourceProvider())); }
public <T> T createEndpoint(Application app, Class<T> endpointType) { final JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean(); Set<Object> singletons = app.getSingletons(); if (!singletons.isEmpty() && singletons.stream().map(Object::getClass).count() < singletons.size()) { throw new IllegalArgumentException("More than one instance of the same singleton class is available: " + singletons); } final List<Class<?>> resourceClasses = new ArrayList<>(); final List<Object> providers = new ArrayList<>(); final List<org.apache.cxf.feature.Feature> features = new ArrayList<>(); final Map<Class<?>, ResourceProvider> map = new HashMap<>(); for (Class<?> cls : app.getClasses()) { if (!cls.isInterface() && !Modifier.isAbstract(cls.getModifiers())) { if (isProvider(cls)) { providers.add(ResourceUtils.createProviderInstance(cls)); } else if (org.apache.cxf.feature.Feature.class.isAssignableFrom(cls)) { features.add(ResourceUtils.createFeatureInstance((Class<? extends org.apache.cxf.feature.Feature>) cls)); } else { resourceClasses.add(cls); map.put(cls, new PerRequestResourceProvider(cls)); } } } for (final Object o : singletons) { if (isProvider(o.getClass())) { providers.add(o); } else if (o instanceof org.apache.cxf.feature.Feature) { features.add((org.apache.cxf.feature.Feature) o); } else { final Class<?> unwrapped = Proxies.unwrap(o.getClass()); resourceClasses.add(unwrapped); map.put(unwrapped, new SingletonResourceProvider(o)); } } String address = "/"; bean.setAddress(address); bean.setStaticSubresourceResolution(false); bean.setResourceClasses(resourceClasses); bean.setProviders(providers); bean.getFeatures().addAll(features); for (Map.Entry<Class<?>, ResourceProvider> entry : map.entrySet()) { bean.setResourceProvider(entry.getKey(), entry.getValue()); } Map<String, Object> appProps = app.getProperties(); if (appProps != null) { bean.getProperties(true).putAll(appProps); } bean.setApplication(app); if (_bus != null) { bean.setBus(_bus); } if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) { return endpointType.cast(bean); } bean.setApplication(app); bean.setStart(false); final Server server = bean.create(); return endpointType.cast(server); }
CxfJaxrsServiceRegistrator { public <T> T createEndpoint(Application app, Class<T> endpointType) { final JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean(); Set<Object> singletons = app.getSingletons(); if (!singletons.isEmpty() && singletons.stream().map(Object::getClass).count() < singletons.size()) { throw new IllegalArgumentException("More than one instance of the same singleton class is available: " + singletons); } final List<Class<?>> resourceClasses = new ArrayList<>(); final List<Object> providers = new ArrayList<>(); final List<org.apache.cxf.feature.Feature> features = new ArrayList<>(); final Map<Class<?>, ResourceProvider> map = new HashMap<>(); for (Class<?> cls : app.getClasses()) { if (!cls.isInterface() && !Modifier.isAbstract(cls.getModifiers())) { if (isProvider(cls)) { providers.add(ResourceUtils.createProviderInstance(cls)); } else if (org.apache.cxf.feature.Feature.class.isAssignableFrom(cls)) { features.add(ResourceUtils.createFeatureInstance((Class<? extends org.apache.cxf.feature.Feature>) cls)); } else { resourceClasses.add(cls); map.put(cls, new PerRequestResourceProvider(cls)); } } } for (final Object o : singletons) { if (isProvider(o.getClass())) { providers.add(o); } else if (o instanceof org.apache.cxf.feature.Feature) { features.add((org.apache.cxf.feature.Feature) o); } else { final Class<?> unwrapped = Proxies.unwrap(o.getClass()); resourceClasses.add(unwrapped); map.put(unwrapped, new SingletonResourceProvider(o)); } } String address = "/"; bean.setAddress(address); bean.setStaticSubresourceResolution(false); bean.setResourceClasses(resourceClasses); bean.setProviders(providers); bean.getFeatures().addAll(features); for (Map.Entry<Class<?>, ResourceProvider> entry : map.entrySet()) { bean.setResourceProvider(entry.getKey(), entry.getValue()); } Map<String, Object> appProps = app.getProperties(); if (appProps != null) { bean.getProperties(true).putAll(appProps); } bean.setApplication(app); if (_bus != null) { bean.setBus(_bus); } if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) { return endpointType.cast(bean); } bean.setApplication(app); bean.setStart(false); final Server server = bean.create(); return endpointType.cast(server); } }
CxfJaxrsServiceRegistrator { public <T> T createEndpoint(Application app, Class<T> endpointType) { final JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean(); Set<Object> singletons = app.getSingletons(); if (!singletons.isEmpty() && singletons.stream().map(Object::getClass).count() < singletons.size()) { throw new IllegalArgumentException("More than one instance of the same singleton class is available: " + singletons); } final List<Class<?>> resourceClasses = new ArrayList<>(); final List<Object> providers = new ArrayList<>(); final List<org.apache.cxf.feature.Feature> features = new ArrayList<>(); final Map<Class<?>, ResourceProvider> map = new HashMap<>(); for (Class<?> cls : app.getClasses()) { if (!cls.isInterface() && !Modifier.isAbstract(cls.getModifiers())) { if (isProvider(cls)) { providers.add(ResourceUtils.createProviderInstance(cls)); } else if (org.apache.cxf.feature.Feature.class.isAssignableFrom(cls)) { features.add(ResourceUtils.createFeatureInstance((Class<? extends org.apache.cxf.feature.Feature>) cls)); } else { resourceClasses.add(cls); map.put(cls, new PerRequestResourceProvider(cls)); } } } for (final Object o : singletons) { if (isProvider(o.getClass())) { providers.add(o); } else if (o instanceof org.apache.cxf.feature.Feature) { features.add((org.apache.cxf.feature.Feature) o); } else { final Class<?> unwrapped = Proxies.unwrap(o.getClass()); resourceClasses.add(unwrapped); map.put(unwrapped, new SingletonResourceProvider(o)); } } String address = "/"; bean.setAddress(address); bean.setStaticSubresourceResolution(false); bean.setResourceClasses(resourceClasses); bean.setProviders(providers); bean.getFeatures().addAll(features); for (Map.Entry<Class<?>, ResourceProvider> entry : map.entrySet()) { bean.setResourceProvider(entry.getKey(), entry.getValue()); } Map<String, Object> appProps = app.getProperties(); if (appProps != null) { bean.getProperties(true).putAll(appProps); } bean.setApplication(app); if (_bus != null) { bean.setBus(_bus); } if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) { return endpointType.cast(bean); } bean.setApplication(app); bean.setStart(false); final Server server = bean.create(); return endpointType.cast(server); } CxfJaxrsServiceRegistrator(
        Bus bus, ServiceTuple<Application> applicationTuple,
        Map<String, ?> properties,
        AriesJaxrsServiceRuntime ariesJaxrsServiceRuntime); }
CxfJaxrsServiceRegistrator { public <T> T createEndpoint(Application app, Class<T> endpointType) { final JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean(); Set<Object> singletons = app.getSingletons(); if (!singletons.isEmpty() && singletons.stream().map(Object::getClass).count() < singletons.size()) { throw new IllegalArgumentException("More than one instance of the same singleton class is available: " + singletons); } final List<Class<?>> resourceClasses = new ArrayList<>(); final List<Object> providers = new ArrayList<>(); final List<org.apache.cxf.feature.Feature> features = new ArrayList<>(); final Map<Class<?>, ResourceProvider> map = new HashMap<>(); for (Class<?> cls : app.getClasses()) { if (!cls.isInterface() && !Modifier.isAbstract(cls.getModifiers())) { if (isProvider(cls)) { providers.add(ResourceUtils.createProviderInstance(cls)); } else if (org.apache.cxf.feature.Feature.class.isAssignableFrom(cls)) { features.add(ResourceUtils.createFeatureInstance((Class<? extends org.apache.cxf.feature.Feature>) cls)); } else { resourceClasses.add(cls); map.put(cls, new PerRequestResourceProvider(cls)); } } } for (final Object o : singletons) { if (isProvider(o.getClass())) { providers.add(o); } else if (o instanceof org.apache.cxf.feature.Feature) { features.add((org.apache.cxf.feature.Feature) o); } else { final Class<?> unwrapped = Proxies.unwrap(o.getClass()); resourceClasses.add(unwrapped); map.put(unwrapped, new SingletonResourceProvider(o)); } } String address = "/"; bean.setAddress(address); bean.setStaticSubresourceResolution(false); bean.setResourceClasses(resourceClasses); bean.setProviders(providers); bean.getFeatures().addAll(features); for (Map.Entry<Class<?>, ResourceProvider> entry : map.entrySet()) { bean.setResourceProvider(entry.getKey(), entry.getValue()); } Map<String, Object> appProps = app.getProperties(); if (appProps != null) { bean.getProperties(true).putAll(appProps); } bean.setApplication(app); if (_bus != null) { bean.setBus(_bus); } if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) { return endpointType.cast(bean); } bean.setApplication(app); bean.setStart(false); final Server server = bean.create(); return endpointType.cast(server); } CxfJaxrsServiceRegistrator(
        Bus bus, ServiceTuple<Application> applicationTuple,
        Map<String, ?> properties,
        AriesJaxrsServiceRuntime ariesJaxrsServiceRuntime); Map<String, ?> getProperties(); synchronized void add(ResourceProvider resourceProvider); synchronized void addProvider(ServiceTuple<?> tuple); void enable(); void close(); T createEndpoint(Application app, Class<T> endpointType); Bus getBus(); Iterable<Class<?>> getStaticResourceClasses(); void registerExtension(
        CachingServiceReference<?> serviceReference); synchronized void remove(ResourceProvider resourceProvider); synchronized void removeProvider(ServiceTuple<?> tuple); synchronized void rewire(); void unregisterExtension(
        CachingServiceReference<?> serviceReference); OSGi<CachingServiceReference<?>> waitForExtension(
        String extensionDependency); }
CxfJaxrsServiceRegistrator { public <T> T createEndpoint(Application app, Class<T> endpointType) { final JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean(); Set<Object> singletons = app.getSingletons(); if (!singletons.isEmpty() && singletons.stream().map(Object::getClass).count() < singletons.size()) { throw new IllegalArgumentException("More than one instance of the same singleton class is available: " + singletons); } final List<Class<?>> resourceClasses = new ArrayList<>(); final List<Object> providers = new ArrayList<>(); final List<org.apache.cxf.feature.Feature> features = new ArrayList<>(); final Map<Class<?>, ResourceProvider> map = new HashMap<>(); for (Class<?> cls : app.getClasses()) { if (!cls.isInterface() && !Modifier.isAbstract(cls.getModifiers())) { if (isProvider(cls)) { providers.add(ResourceUtils.createProviderInstance(cls)); } else if (org.apache.cxf.feature.Feature.class.isAssignableFrom(cls)) { features.add(ResourceUtils.createFeatureInstance((Class<? extends org.apache.cxf.feature.Feature>) cls)); } else { resourceClasses.add(cls); map.put(cls, new PerRequestResourceProvider(cls)); } } } for (final Object o : singletons) { if (isProvider(o.getClass())) { providers.add(o); } else if (o instanceof org.apache.cxf.feature.Feature) { features.add((org.apache.cxf.feature.Feature) o); } else { final Class<?> unwrapped = Proxies.unwrap(o.getClass()); resourceClasses.add(unwrapped); map.put(unwrapped, new SingletonResourceProvider(o)); } } String address = "/"; bean.setAddress(address); bean.setStaticSubresourceResolution(false); bean.setResourceClasses(resourceClasses); bean.setProviders(providers); bean.getFeatures().addAll(features); for (Map.Entry<Class<?>, ResourceProvider> entry : map.entrySet()) { bean.setResourceProvider(entry.getKey(), entry.getValue()); } Map<String, Object> appProps = app.getProperties(); if (appProps != null) { bean.getProperties(true).putAll(appProps); } bean.setApplication(app); if (_bus != null) { bean.setBus(_bus); } if (JAXRSServerFactoryBean.class.isAssignableFrom(endpointType)) { return endpointType.cast(bean); } bean.setApplication(app); bean.setStart(false); final Server server = bean.create(); return endpointType.cast(server); } CxfJaxrsServiceRegistrator(
        Bus bus, ServiceTuple<Application> applicationTuple,
        Map<String, ?> properties,
        AriesJaxrsServiceRuntime ariesJaxrsServiceRuntime); Map<String, ?> getProperties(); synchronized void add(ResourceProvider resourceProvider); synchronized void addProvider(ServiceTuple<?> tuple); void enable(); void close(); T createEndpoint(Application app, Class<T> endpointType); Bus getBus(); Iterable<Class<?>> getStaticResourceClasses(); void registerExtension(
        CachingServiceReference<?> serviceReference); synchronized void remove(ResourceProvider resourceProvider); synchronized void removeProvider(ServiceTuple<?> tuple); synchronized void rewire(); void unregisterExtension(
        CachingServiceReference<?> serviceReference); OSGi<CachingServiceReference<?>> waitForExtension(
        String extensionDependency);  }