Java Code Examples for org.apache.cxf.common.util.ReflectionUtil#setAccessible()
The following examples show how to use
org.apache.cxf.common.util.ReflectionUtil#setAccessible() .
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: ResourceInjector.java From cxf with Apache License 2.0 | 6 votes |
public static boolean processable(Class<?> cls, Object o) { if (cls.getName().startsWith("java.") || cls.getName().startsWith("javax.")) { return false; } NoJSR250Annotations njsr = cls.getAnnotation(NoJSR250Annotations.class); if (njsr != null) { for (String s : njsr.unlessNull()) { try { Field f = getField(cls, s); ReflectionUtil.setAccessible(f); if (f.get(o) == null) { return true; } } catch (Exception ex) { return true; } } return false; } return true; }
Example 2
Source File: JAXBDataBinding.java From cxf with Apache License 2.0 | 5 votes |
private void hackInNewInternalizationLogic(SchemaCompiler schemaCompiler, final OASISCatalogManager catalog, Options opts) { try { Field f = schemaCompiler.getClass().getDeclaredField("forest"); ReflectionUtil.setAccessible(f); XMLSchemaInternalizationLogic logic = new XMLSchemaInternalizationLogic() { public XMLFilterImpl createExternalReferenceFinder(DOMForest parent) { return new ReferenceFinder(parent, catalog); } }; Constructor<DOMForest> c = null; DOMForest forest = null; try { c = DOMForest.class.getConstructor(InternalizationLogic.class, Options.class); forest = c.newInstance(logic, opts); } catch (Throwable t) { c = DOMForest.class.getConstructor(InternalizationLogic.class); forest = c.newInstance(logic); } forest.setErrorHandler((ErrorReceiver)schemaCompiler); f.set(schemaCompiler, forest); } catch (Throwable ex) { //ignore } }
Example 3
Source File: JAXWSProviderMethodDispatcher.java From cxf with Apache License 2.0 | 5 votes |
public JAXWSProviderMethodDispatcher(JaxWsImplementorInfo implInfo) { try { invoke = ReflectionUtil.getMethod(implInfo.getImplementorClass(), "invoke", new Class[] {implInfo.getProviderParameterType()}); ReflectionUtil.setAccessible(invoke); } catch (Exception e1) { //fall back to the raw Provider provided invoke method try { invoke = Provider.class.getMethod("invoke", new Class[] {Object.class}); } catch (Exception e) { throw new ServiceConstructionException(e); } } }
Example 4
Source File: PhaseInterceptorChainTest.java From cxf with Apache License 2.0 | 5 votes |
AbstractPhaseInterceptor<Message> setUpPhaseInterceptor(final String phase, final String id, Set<String> b, Set<String> a) throws Exception { AbstractPhaseInterceptor<Message> p = control .createMock(AbstractPhaseInterceptor.class); if (a == null) { a = new SortedArraySet<>(); } if (b == null) { b = new SortedArraySet<>(); } Field f = AbstractPhaseInterceptor.class.getDeclaredField("before"); ReflectionUtil.setAccessible(f); f.set(p, b); f = AbstractPhaseInterceptor.class.getDeclaredField("after"); ReflectionUtil.setAccessible(f); f.set(p, a); f = AbstractPhaseInterceptor.class.getDeclaredField("phase"); ReflectionUtil.setAccessible(f); f.set(p, phase); f = AbstractPhaseInterceptor.class.getDeclaredField("id"); ReflectionUtil.setAccessible(f); f.set(p, id); return p; }
Example 5
Source File: ClientServerMiscTest.java From cxf with Apache License 2.0 | 4 votes |
private void setASM(boolean b) throws Exception { Field f = ASMHelper.class.getDeclaredField("badASM"); ReflectionUtil.setAccessible(f); f.set(null, !b); }
Example 6
Source File: HttpsURLConnectionFactoryTest.java From cxf with Apache License 2.0 | 4 votes |
private void clearDefaults() throws IllegalAccessException { Field defaultManagers = ReflectionUtil.getDeclaredField(SSLUtils.class, "defaultManagers"); ReflectionUtil.setAccessible(defaultManagers); defaultManagers.set(SSLUtils.class, null); }