public static Object createProxy(BaseProxyBean baseProxyBean) { Class<?> beanClass = baseProxyBean.getClass(); Thread currentThread = Thread.currentThread(); return ProxyUtil.newProxyInstance( currentThread.getContextClassLoader(), beanClass.getInterfaces(), new MessagingProxyInvocationHandler(baseProxyBean)); }
private Class<?> _getModelClass(ModelListener<?> modelListener) { Class<?> clazz = modelListener.getClass(); if (ProxyUtil.isProxyClass(clazz)) { InvocationHandler invocationHandler = ProxyUtil.getInvocationHandler(modelListener); if (invocationHandler instanceof ClassLoaderBeanHandler) { ClassLoaderBeanHandler classLoaderBeanHandler = (ClassLoaderBeanHandler)invocationHandler; Object bean = classLoaderBeanHandler.getBean(); clazz = bean.getClass(); } } return _getGenericSuperType(clazz); }
public static Object newProxyInstance( ClassLoader classLoader, Class<?>[] interfaces, InvocationHandler invocationHandler) { Constructor<?> constructor = _constructors.get( getProxyClass(classLoader, interfaces)); try { return constructor.newInstance(new Object[] {invocationHandler}); } catch (Exception e) { throw new InternalError(e.toString()); } }
public static InvocationHandler getInvocationHandler(Object proxy) { if (!isProxyClass(proxy.getClass())) { throw new IllegalArgumentException("Not a proxy instance"); } try { return (InvocationHandler)_invocationHandlerField.get(proxy); } catch (Exception e) { throw new IllegalArgumentException(e); } }
protected Class<?> getTargetClass(Object service) throws Exception { Class<?> clazz = service.getClass(); if (ProxyUtil.isProxyClass(clazz)) { AdvisedSupport advisedSupport = ServiceBeanAopProxy.getAdvisedSupport(service); TargetSource targetSource = advisedSupport.getTargetSource(); Object target = targetSource.getTarget(); clazz = target.getClass(); } return clazz; }
/** * @deprecated As of Judson (7.1.x), replaced by {@link * #newServiceTrackedInstance(Class, Class, String)} */ @Deprecated public static <T> T newServiceTrackedInstance(Class<T> interfaceClass) { return (T)ProxyUtil.newProxyInstance( interfaceClass.getClassLoader(), new Class<?>[] {interfaceClass}, new ServiceTrackedInvocationHandler<>(interfaceClass)); }
Object service = _field.get(null); if (!ProxyUtil.isProxyClass(service.getClass()) || (ProxyUtil.getInvocationHandler(service) != this)) {
public QueuingSearchEngine(int capacity) { _queuingInvocationHandler = new QueuingInvocationHandler(capacity); Class<?> clazz = getClass(); _indexWriter = (IndexWriter)ProxyUtil.newProxyInstance( clazz.getClassLoader(), new Class<?>[] {IndexWriter.class}, _queuingInvocationHandler); }
@Override public LayoutSetStagingHandler getLayoutSetStagingHandler( LayoutSet layoutSet) { if (!ProxyUtil.isProxyClass(layoutSet.getClass())) { return null; } InvocationHandler invocationHandler = ProxyUtil.getInvocationHandler( layoutSet); if (!(invocationHandler instanceof LayoutSetStagingHandler)) { return null; } return (LayoutSetStagingHandler)invocationHandler; }
public static <T> T newDummyInstance(Class<T> interfaceClass) { return (T)ProxyUtil.newProxyInstance( interfaceClass.getClassLoader(), new Class<?>[] {interfaceClass}, new DummyInvocationHandler<T>()); }
@Override public LayoutStagingHandler getLayoutStagingHandler(Layout layout) { if (layout == null) { return null; } if (!ProxyUtil.isProxyClass(layout.getClass())) { return null; } InvocationHandler invocationHandler = ProxyUtil.getInvocationHandler( layout); if (!(invocationHandler instanceof LayoutStagingHandler)) { return null; } return (LayoutStagingHandler)invocationHandler; }
protected Object newProxyInstance(Object bean, Class<?> clazz) { if (bean == null) { return null; } return ProxyUtil.newProxyInstance( _classLoader, new Class<?>[] {clazz}, new ClassLoaderBeanHandler(bean, _classLoader)); }
InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(journalArticleLocalization.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler(journalArticleLocalization);
/** * @deprecated As of Judson (7.1.x), replaced by {@link * #newServiceTrackedInstance(Class, Class, String, String)} */ @Deprecated public static <T> T newServiceTrackedInstance( Class<T> interfaceClass, String filterString) { return (T)ProxyUtil.newProxyInstance( interfaceClass.getClassLoader(), new Class<?>[] {interfaceClass}, new ServiceTrackedInvocationHandler<>( interfaceClass, filterString)); }
InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(ddmTemplateLink.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler(ddmTemplateLink);
public static PreparedStatement concurrentAutoBatch( Connection connection, String sql) throws SQLException { DatabaseMetaData databaseMetaData = connection.getMetaData(); if (databaseMetaData.supportsBatchUpdates()) { return (PreparedStatement)ProxyUtil.newProxyInstance( ClassLoader.getSystemClassLoader(), _INTERFACES, new ConcurrentBatchInvocationHandler(connection, sql)); } return (PreparedStatement)ProxyUtil.newProxyInstance( ClassLoader.getSystemClassLoader(), _INTERFACES, new ConcurrentNoBatchInvocationHandler(connection, sql)); }
InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(ddmDataProviderInstanceLink.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler(ddmDataProviderInstanceLink);
public static PreparedStatement autoBatch( PreparedStatement preparedStatement) throws SQLException { Connection connection = preparedStatement.getConnection(); DatabaseMetaData databaseMetaData = connection.getMetaData(); if (databaseMetaData.supportsBatchUpdates()) { return (PreparedStatement)ProxyUtil.newProxyInstance( ClassLoader.getSystemClassLoader(), _INTERFACES, new BatchInvocationHandler(preparedStatement)); } return (PreparedStatement)ProxyUtil.newProxyInstance( ClassLoader.getSystemClassLoader(), _INTERFACES, new NoBatchInvocationHandler(preparedStatement)); }
InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(ddmStructureVersion.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler(ddmStructureVersion);
private LayoutType _getLayoutType() { return LayoutTypePortletFactoryUtil.create( (Layout)ProxyUtil.newProxyInstance( PortalClassLoaderUtil.getClassLoader(), new Class<?>[] {Layout.class}, new LayoutStagingHandler(_layout, _layoutRevision))); }