org.apache.cxf.feature.Feature Java Examples
The following examples show how to use
org.apache.cxf.feature.Feature.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CXFNonSpringJaxrsServlet.java From JaxRSProviders with Apache License 2.0 | 6 votes |
protected void createServerFromApplication(ServletConfig servletConfig) throws ServletException { Application app = getApplication(); JAXRSServerFactoryBean bean = ResourceUtils.createApplication( app, isIgnoreApplicationPath(servletConfig), getStaticSubResolutionValue(servletConfig), isAppResourceLifecycleASingleton(app, servletConfig), getBus()); String splitChar = getParameterSplitChar(servletConfig); setAllInterceptors(bean, servletConfig, splitChar); setInvoker(bean, servletConfig); setExtensions(bean, servletConfig); setDocLocation(bean, servletConfig); setSchemasLocations(bean, servletConfig); List<?> providers = getProviders(servletConfig, splitChar); bean.setProviders(providers); List<? extends Feature> features = getFeatures(servletConfig, splitChar); bean.setFeatures(features); bean.setBus(getBus()); bean.setApplication(getApplication()); bean.create(); }
Example #2
Source File: BusDefinitionParserTest.java From cxf with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("deprecation") public void testFeatures() { String cfgFile = "org/apache/cxf/bus/spring/bus.xml"; Bus bus = new SpringBusFactory().createBus(cfgFile, true); List<Interceptor<? extends Message>> in = bus.getInInterceptors(); assertTrue("could not find logging interceptor.", in.stream().anyMatch(i -> i.getClass() == org.apache.cxf.interceptor.LoggingInInterceptor.class)); Collection<Feature> features = bus.getFeatures(); TestFeature tf = null; for (Feature f : features) { if (f instanceof TestFeature) { tf = (TestFeature)f; break; } } assertNotNull(tf); assertTrue("test feature has not been initialised", tf.initialised); assertNotNull("test feature has not been injected", tf.testBean); assertTrue("bean injected into test feature has not been initialised", tf.testBean.initialised); }
Example #3
Source File: CXFNonSpringJaxrsServlet.java From JaxRSProviders with Apache License 2.0 | 6 votes |
protected List<? extends Feature> getFeatures(ServletConfig servletConfig, String splitChar) throws ServletException { String featuresList = servletConfig.getInitParameter(FEATURES_PARAM); if (featuresList == null) { return Collections.< Feature >emptyList(); } String[] classNames = featuresList.split(splitChar); List< Feature > features = new ArrayList<>(); for (String cName : classNames) { Map<String, List<String>> props = new HashMap<>(); String theName = getClassNameAndProperties(cName, props); if (!theName.isEmpty()) { Class<?> cls = loadClass(theName); if (Feature.class.isAssignableFrom(cls)) { features.add((Feature)createSingletonInstance(cls, props, servletConfig)); } } } return features; }
Example #4
Source File: CXFNonSpringJaxrsServlet.java From cxf with Apache License 2.0 | 6 votes |
protected void createServerFromApplication(ServletConfig servletConfig) throws ServletException { Application app = getApplication(); JAXRSServerFactoryBean bean = ResourceUtils.createApplication( app, isIgnoreApplicationPath(servletConfig), getStaticSubResolutionValue(servletConfig), isAppResourceLifecycleASingleton(app, servletConfig), getBus()); String splitChar = getParameterSplitChar(servletConfig); setAllInterceptors(bean, servletConfig, splitChar); setInvoker(bean, servletConfig); setExtensions(bean, servletConfig); setDocLocation(bean, servletConfig); setSchemasLocations(bean, servletConfig); List<?> providers = getProviders(servletConfig, splitChar); bean.setProviders(providers); List<? extends Feature> features = getFeatures(servletConfig, splitChar); bean.getFeatures().addAll(features); bean.setBus(getBus()); bean.setApplication(getApplication()); bean.create(); }
Example #5
Source File: BraveTracingTest.java From cxf with Apache License 2.0 | 6 votes |
private BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Feature feature) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.setServiceClass(BookStoreService.class); factory.setAddress("http://localhost:" + PORT + "/BookStore"); if (feature != null) { factory.getFeatures().add(feature); } final BookStoreService service = (BookStoreService) factory.create(); final Client proxy = ClientProxy.getClient(service); proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); return service; }
Example #6
Source File: OpenTracingTracingTest.java From cxf with Apache License 2.0 | 6 votes |
private static BookStoreService createJaxWsService(final Map<String, List<String>> headers, final Feature feature) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.getOutInterceptors().add(new LoggingOutInterceptor()); factory.getInInterceptors().add(new LoggingInInterceptor()); factory.setServiceClass(BookStoreService.class); factory.setAddress("http://localhost:" + PORT + "/BookStore"); if (feature != null) { factory.getFeatures().add(feature); } final BookStoreService service = (BookStoreService) factory.create(); final Client proxy = ClientProxy.getClient(service); proxy.getRequestContext().put(Message.PROTOCOL_HEADERS, headers); return service; }
Example #7
Source File: AnnotationInterceptorTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testJaxwsFrontendWithAnnotationInImpl() throws Exception { jfb.setServiceClass(SayHi.class); SayHi implementor = new SayHiImplementation(); jfb.setServiceBean(implementor); jserver = jfb.create(); List<Interceptor<? extends Message>> interceptors = jserver.getEndpoint().getInInterceptors(); assertTrue(hasTestInterceptor(interceptors)); List<Interceptor<? extends Message>> inFaultInterceptors = jserver.getEndpoint().getInFaultInterceptors(); assertFalse(hasTestInterceptor(inFaultInterceptors)); assertTrue(hasTest2Interceptor(inFaultInterceptors)); List<Feature> features = jfb.getFeatures(); assertTrue(hasAnnotationFeature(features)); }
Example #8
Source File: JAXRSCdiResourceExtension.java From cxf with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public <T> void collect(@Observes final ProcessBean< T > event) { if (event.getAnnotated().isAnnotationPresent(ApplicationPath.class)) { applicationBeans.add(event.getBean()); } else if (event.getAnnotated().isAnnotationPresent(Path.class)) { serviceBeans.add(event.getBean()); } else if (event.getAnnotated().isAnnotationPresent(Provider.class)) { providerBeans.add(event.getBean()); } else if (event.getBean().getTypes().contains(javax.ws.rs.core.Feature.class)) { providerBeans.add(event.getBean()); } else if (event.getBean().getTypes().contains(Feature.class)) { featureBeans.add((Bean< ? extends Feature >)event.getBean()); } else if (CdiBusBean.CXF.equals(event.getBean().getName()) && Bus.class.isAssignableFrom(event.getBean().getBeanClass())) { hasBus = true; } else if (event.getBean().getQualifiers().contains(DEFAULT)) { event.getBean().getTypes().stream() .filter(e -> Object.class != e && InjectionUtils.STANDARD_CONTEXT_CLASSES.contains(e.getTypeName())) .findFirst() .ifPresent(type -> existingStandardClasses.add(type.getTypeName())); } }
Example #9
Source File: JAXRSCdiResourceExtension.java From cxf with Apache License 2.0 | 6 votes |
/** * Gets the references for all discovered CXF-specific features * @param beanManager bean manager instance * @return the references for all discovered CXF-specific features */ private List< Feature > loadFeatures(final BeanManager beanManager, Collection<Class<?>> limitedClasses) { final List< Feature > features = new ArrayList<>(); for (final Bean< ? extends Feature > bean: featureBeans) { if (limitedClasses.isEmpty() || limitedClasses.contains(bean.getBeanClass())) { features.add( (Feature) beanManager.getReference( bean, Feature.class, createCreationalContext(beanManager, bean) ) ); } } return features; }
Example #10
Source File: MAPAggregatorImpl.java From cxf with Apache License 2.0 | 5 votes |
private WSAddressingFeature getWSAddressingFeature(Message message) { if (message.getExchange() != null && message.getExchange().getEndpoint() != null) { Endpoint endpoint = message.getExchange().getEndpoint(); if (endpoint.getActiveFeatures() != null) { for (Feature feature : endpoint.getActiveFeatures()) { if (feature instanceof WSAddressingFeature) { return (WSAddressingFeature)feature; } } } } return null; }
Example #11
Source File: ExtensionManagerBus.java From cxf with Apache License 2.0 | 5 votes |
public synchronized void setFeatures(Collection<? extends Feature> features) { this.features.clear(); this.features.addAll(features); if (state == BusState.RUNNING) { initializeFeatures(); } }
Example #12
Source File: AnnotationInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSimpleFrontendWithNoAnnotation() throws Exception { fb.setServiceClass(HelloService.class); HelloService hello = new HelloServiceImplNoAnnotation(); fb.setServiceBean(hello); server = fb.create(); List<Interceptor<? extends Message>> interceptors = server.getEndpoint().getInInterceptors(); assertFalse(hasTestInterceptor(interceptors)); List<Feature> features = fb.getFeatures(); assertFalse(hasAnnotationFeature(features)); }
Example #13
Source File: AnnotationInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testJaxWsFrontendWithAnnotationInSEI() throws Exception { jfb.setServiceClass(SayHiInterfaceImpl.class); jfb.setServiceBean(new SayHiInterfaceImpl()); jserver = jfb.create(); List<Interceptor<? extends Message>> interceptors = jserver.getEndpoint().getInInterceptors(); assertTrue(hasTestInterceptor(interceptors)); List<Feature> features = jfb.getFeatures(); assertTrue(hasAnnotationFeature(features)); }
Example #14
Source File: OSGiBusListenerTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testRegistratioWithServices() throws Exception { setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null); setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null); Collection<Feature> lst = new ArrayList<>(); setFeatures(SERVICE_BUNDLE_NAMES, new String[]{null, null}, lst); control.replay(); new OSGIBusListener(bus, new Object[]{bundleContext}); assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{null, null}, null), lst.size()); control.verify(); }
Example #15
Source File: ProviderImpl.java From cxf with Apache License 2.0 | 5 votes |
public ServiceDelegate createServiceDelegate(URL wsdlDocumentLocation, QName serviceName, @SuppressWarnings("rawtypes") Class serviceClass, WebServiceFeature ... features) { for (WebServiceFeature f : features) { if (!f.getClass().getName().startsWith("javax.xml.ws") && !(f instanceof Feature)) { throw new WebServiceException("Unknown feature error: " + f.getClass().getName()); } } return new ServiceImpl(null, wsdlDocumentLocation, serviceName, serviceClass, features); }
Example #16
Source File: AbstractJaxRsClientConfiguration.java From cxf with Apache License 2.0 | 5 votes |
protected void addCxfProvider(JAXRSClientFactoryBean factory, Object provider) { org.apache.cxf.annotations.Provider ann = provider.getClass().getAnnotation(org.apache.cxf.annotations.Provider.class); if (ann.scope() == Scope.Server) { return; } if (ann.value() == org.apache.cxf.annotations.Provider.Type.Feature) { factory.getFeatures().add((Feature)provider); } else if (ann.value() == org.apache.cxf.annotations.Provider.Type.InInterceptor) { factory.getInInterceptors().add((Interceptor<?>)provider); } else if (ann.value() == org.apache.cxf.annotations.Provider.Type.OutInterceptor) { factory.getOutInterceptors().add((Interceptor<?>)provider); } }
Example #17
Source File: AnnotationInterceptorTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSimpleFrontendWithFeature() throws Exception { fb.setServiceClass(HelloService.class); HelloService hello = new HelloServiceImpl(); fb.setServiceBean(hello); server = fb.create(); List<Feature> features = fb.getFeatures(); assertTrue(hasAnnotationFeature(features)); }
Example #18
Source File: CXFNonSpringJaxrsServlet.java From JaxRSProviders with Apache License 2.0 | 5 votes |
protected void createServerFromApplication(String applicationNames, ServletConfig servletConfig) throws ServletException { boolean ignoreApplicationPath = isIgnoreApplicationPath(servletConfig); String[] classNames = applicationNames.split(getParameterSplitChar(servletConfig)); if (classNames.length > 1 && ignoreApplicationPath) { throw new ServletException("\"" + IGNORE_APP_PATH_PARAM + "\" parameter must be set to false for multiple Applications be supported"); } for (String cName : classNames) { ApplicationInfo providerApp = createApplicationInfo(cName, servletConfig); Application app = providerApp.getProvider(); JAXRSServerFactoryBean bean = ResourceUtils.createApplication( app, ignoreApplicationPath, getStaticSubResolutionValue(servletConfig), isAppResourceLifecycleASingleton(app, servletConfig), getBus()); String splitChar = getParameterSplitChar(servletConfig); setAllInterceptors(bean, servletConfig, splitChar); setInvoker(bean, servletConfig); setExtensions(bean, servletConfig); setDocLocation(bean, servletConfig); setSchemasLocations(bean, servletConfig); List<?> providers = getProviders(servletConfig, splitChar); bean.setProviders(providers); List<? extends Feature> features = getFeatures(servletConfig, splitChar); bean.setFeatures(features); bean.setBus(getBus()); bean.setApplicationInfo(providerApp); bean.create(); } }
Example #19
Source File: BasicNameManager.java From cxf with Apache License 2.0 | 5 votes |
private JavascriptOptionsFeature getOptions(Endpoint endpoint) { if (endpoint != null) { for (Feature feature : endpoint.getActiveFeatures()) { if (feature instanceof JavascriptOptionsFeature) { return (JavascriptOptionsFeature) feature; } } } return new JavascriptOptionsFeature(); // save work and return a default set of options. }
Example #20
Source File: BraveTraceTest.java From cxf with Apache License 2.0 | 5 votes |
private static MyService createProxy(Feature trace) { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); factory.setServiceClass(MyService.class); factory.setAddress(ADDRESS); factory.setFeatures(Arrays.asList(trace)); return (MyService)factory.create(); }
Example #21
Source File: OSGiBusListenerTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testRegistratioWithServicesExcludes() throws Exception { setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES); setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES); Collection<Feature> lst = new ArrayList<>(); setFeatures(SERVICE_BUNDLE_NAMES, new String[]{null, null}, lst); EasyMock.expect(bus.getProperty("bus.extension.bundles.excludes")).andReturn(EXCLUDES); control.replay(); new OSGIBusListener(bus, new Object[]{bundleContext}); assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{null, null}, EXCLUDES), lst.size()); control.verify(); }
Example #22
Source File: BookServerThrottled.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); sf.setResourceClasses(BookStore.class); List<Feature> features = new ArrayList<>(); ThrottlingFeature tf = new ThrottlingFeature(new ThrottlingManagerImpl()); features.add(tf); sf.setFeatures(features); sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), true)); sf.setAddress("http://localhost:" + PORT + "/"); server = sf.create(); }
Example #23
Source File: OSGIBusListener.java From cxf with Apache License 2.0 | 5 votes |
private void registerBusFeatures() { ServiceReference<?>[] refs = getServiceReferences(defaultContext, Feature.class); for (ServiceReference<?> ref : refs) { if (!isPrivate(ref) && !isExcluded(ref)) { Feature feature = (Feature)defaultContext.getService(ref); bus.getFeatures().add(feature); } } }
Example #24
Source File: JavaFirstSchemaValidationTest.java From cxf with Apache License 2.0 | 5 votes |
private static <T> T createClient(String port, Class<T> serviceClass, SchemaValidationType type, Feature ... features) { JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean(); clientFactory.setServiceClass(serviceClass); clientFactory.setAddress(getAddress(port, serviceClass)); if (features != null) { Collections.addAll(clientFactory.getFeatures(), features); } @SuppressWarnings("unchecked") T newClient = (T)clientFactory.create(); Client proxy = ClientProxy.getClient(newClient); if (type != null) { proxy.getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, type); } HTTPConduit conduit = (HTTPConduit) proxy.getConduit(); // give me longer debug times HTTPClientPolicy clientPolicy = new HTTPClientPolicy(); clientPolicy.setConnectionTimeout(1000000); clientPolicy.setReceiveTimeout(1000000); conduit.setClient(clientPolicy); return newClient; }
Example #25
Source File: OSGiBusListenerTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testRegistratioWithServicesExcludesAndRestricted() throws Exception { setUpClientLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES); setUpServerLifeCycleListeners(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES); Collection<Feature> lst = new ArrayList<>(); setFeatures(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, lst); EasyMock.expect(bus.getProperty("bus.extension.bundles.excludes")).andReturn(EXCLUDES); control.replay(); new OSGIBusListener(bus, new Object[]{bundleContext}); assertEquals(countServices(SERVICE_BUNDLE_NAMES, new String[]{RESTRICTED, null}, EXCLUDES), lst.size()); control.verify(); }
Example #26
Source File: ServerFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
protected void applyFeatures(Server server) { if (getFeatures() != null) { for (Feature feature : getFeatures()) { feature.initialize(server, getBus()); } } }
Example #27
Source File: BusDefinitionParser.java From cxf with Apache License 2.0 | 5 votes |
public void setFeatures(Collection<? extends Feature> features) { if (bus != null) { bus.setFeatures(features); } else { this.features = CastUtils.cast(features); } }
Example #28
Source File: AbstractSwagger2ServiceDescriptionTest.java From cxf with Apache License 2.0 | 5 votes |
protected WebClient createWebClient(final String url) { return WebClient .create("http://localhost:" + getPort() + url, Arrays.< Object >asList(new JacksonJsonProvider()), Arrays.< Feature >asList(new LoggingFeature()), null) .accept(MediaType.APPLICATION_JSON).accept("application/yaml"); }
Example #29
Source File: OpenApiContextBasedConfigApplicationOnlyTest.java From cxf with Apache License 2.0 | 5 votes |
protected WebClient createWebClient(final String url) { return WebClient .create(url, Arrays.< Object >asList(new JacksonJsonProvider()), Arrays.< Feature >asList(new LoggingFeature()), null) .accept(MediaType.APPLICATION_JSON).accept("application/yaml"); }
Example #30
Source File: OpenApiContextBasedConfigTest.java From cxf with Apache License 2.0 | 5 votes |
protected WebClient createWebClient(final String url) { return WebClient .create(url, Arrays.< Object >asList(new JacksonJsonProvider()), Arrays.< Feature >asList(new LoggingFeature()), null) .accept(MediaType.APPLICATION_JSON).accept("application/yaml"); }