Java Code Examples for javassist.util.proxy.ProxyFactory#isProxyClass()
The following examples show how to use
javassist.util.proxy.ProxyFactory#isProxyClass() .
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: JavassistClientProxyFactory.java From bowman with Apache License 2.0 | 6 votes |
private static <T> T createProxyInstance(Class<T> entityType, MethodHandlerChain handlerChain) { ProxyFactory factory = new ProxyFactory(); if (ProxyFactory.isProxyClass(entityType)) { factory.setInterfaces(getNonProxyInterfaces(entityType)); factory.setSuperclass(entityType.getSuperclass()); } else { factory.setSuperclass(entityType); } factory.setFilter(handlerChain); Class<?> clazz = factory.createClass(); T proxy = instantiateClass(clazz); ((Proxy) proxy).setHandler(handlerChain); return proxy; }
Example 2
Source File: AbstractPropertyAwareMethodHandler.java From bowman with Apache License 2.0 | 5 votes |
private static Class getBeanType(Class clazz) { if (!ProxyFactory.isProxyClass(clazz)) { return clazz; } return clazz.getSuperclass(); }
Example 3
Source File: DefaultLinkService.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private <T> void generateHref( T object, String hrefBase ) { if ( object == null || getSetter( object.getClass() ) == null ) { return; } Class<?> klass = object.getClass(); if ( ProxyFactory.isProxyClass( klass ) ) { klass = klass.getSuperclass(); } Schema schema = schemaService.getDynamicSchema( klass ); if ( !schema.haveApiEndpoint() || schema.getProperty( "id" ) == null || schema.getProperty( "id" ).getGetterMethod() == null ) { return; } Property id = schema.getProperty( "id" ); try { Object value = id.getGetterMethod().invoke( object ); if ( !String.class.isInstance( value ) ) { log.warn( "id on object of type " + object.getClass().getName() + " does not return a String." ); return; } Method setHref = getSetter( object.getClass() ); setHref.invoke( object, hrefBase + schema.getRelativeApiEndpoint() + "/" + value ); } catch ( InvocationTargetException | IllegalAccessException ignored ) { } }
Example 4
Source File: TrackerPreheat.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Class<?> getRealClass( Class<?> klass ) { if ( ProxyFactory.isProxyClass( klass ) ) { klass = klass.getSuperclass(); } return klass; }
Example 5
Source File: Preheat.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Class<?> getRealClass( Class<?> klass ) { if ( ProxyFactory.isProxyClass( klass ) ) { klass = klass.getSuperclass(); } return klass; }
Example 6
Source File: AuditLogUtil.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static void infoWrapper( Logger log, String username, Object object, String action ) { if ( log.isInfoEnabled() ) { if ( username != null && object instanceof IdentifiableObject ) { IdentifiableObject idObject = (IdentifiableObject) object; StringBuilder builder = new StringBuilder(); builder.append( "'" ).append( username ).append( "' " ).append( action ); if ( !ProxyFactory.isProxyClass( object.getClass() ) ) { builder.append( " " ).append( object.getClass().getName() ); } else { builder.append( " " ).append( object.getClass().getSuperclass().getName() ); } if ( idObject.getName() != null && !idObject.getName().isEmpty() ) { builder.append( ", name: " ).append( idObject.getName() ); } if ( idObject.getUid() != null && !idObject.getUid().isEmpty() ) { builder.append( ", uid: " ).append( idObject.getUid() ); } log.info( builder.toString() ); } } }
Example 7
Source File: ReflectionUtils.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Class<?> getRealClass( Class<?> klass ) { if ( ProxyFactory.isProxyClass( klass ) ) { klass = klass.getSuperclass(); } while ( PersistentCollection.class.isAssignableFrom( klass ) ) { klass = klass.getSuperclass(); } return klass; }