List of usage examples for org.apache.wicket.proxy LazyInitProxyFactory createProxy
public static Object createProxy(final Class<?> type, final IProxyTargetLocator locator)
From source file:com.ttdev.wicketpagetest.MockedBeanFieldValueFactory.java
License:Open Source License
public Object getFieldValue(Field field, Object fieldOwner) { final String fieldName = field.getName(); if (!hasValueForField(fieldName)) { return null; }// w ww . jav a 2 s .c o m return LazyInitProxyFactory.createProxy(field.getType(), new IProxyTargetLocator() { private static final long serialVersionUID = 1L; public Object locateProxyTarget() { return mockedBeans.get(fieldName); } }); }
From source file:com.ttdev.wicketpagetest.SerializableProxyFactory.java
License:Open Source License
public <T> T createProxy(Class<T> iface, T original) { TargetLocatorUsingProxy locator = new TargetLocatorUsingProxy(); @SuppressWarnings("unchecked") T proxy = (T) LazyInitProxyFactory.createProxy(iface, locator); locator.resultedProxy = proxy;//from w ww . ja v a 2 s. com proxyToOriginal.put(proxy, original); return proxy; }
From source file:jp.comuri.wicket.PicoContainerComponentInjector.java
License:Apache License
public void inject(Object object) { Class<?> current = object.getClass(); do {//from w ww . ja va 2 s.c om Method[] methods = current.getDeclaredMethods(); for (Method method : methods) { if (Modifier.isStatic(method.getModifiers()) || method.getAnnotation(Inject.class) == null) continue; Class<?>[] paramTypes = method.getParameterTypes(); Object[] params = new Object[paramTypes.length]; for (int i = 0, n = paramTypes.length; i < n; i++) { params[i] = LazyInitProxyFactory.createProxy(paramTypes[i], new PicoContainerProxyTargetLocator(paramTypes[i])); } try { method.invoke(object, params); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } } current = current.getSuperclass(); } while (current != null && current != Object.class); }
From source file:jp.comuri.wicket.PicoContainerFieldValueFactory.java
License:Apache License
public Object getFieldValue(Field field, Object fieldOwner) { Class<?> type = field.getType(); return LazyInitProxyFactory.createProxy(type, new PicoContainerProxyTargetLocator(type)); }
From source file:org.artifactory.webapp.spring.ArtifactoryContextAnnotFieldValueFactory.java
License:Open Source License
@Override public Object getFieldValue(Field field, Object fieldOwner) { if (supportsField(field)) { IProxyTargetLocator locator = new ArtifactoryBeanLocator(field.getType(), contextLocator); Object proxy = LazyInitProxyFactory.createProxy(field.getType(), locator); return proxy; } else {//w ww. j a va2 s.c o m return null; } }
From source file:org.artifactory.webapp.wicket.application.ArtifactoryWebSession.java
License:Open Source License
public ArtifactoryWebSession(Request request) { super(request); authenticationManager = (AuthenticationManager) LazyInitProxyFactory .createProxy(AuthenticationManager.class, new SecurityServiceLocator()); }
From source file:org.projectforge.web.registry.WebRegistryEntry.java
License:Open Source License
/** * Creates a proxy via LazyInitProxyFactory. Use-full if needed in Wicket components. Avoids Wicket serialization of the dao. * @return// ww w . java 2 s .c o m */ public BaseDao<?> getProxyDao() { return (BaseDao<?>) LazyInitProxyFactory.createProxy(registryEntry.getDaoClassType(), new DaoLocator(registryEntry.getId())); }
From source file:org.seasar.framework.container.assembler.ProxyBindingTypeDef.java
License:Apache License
@Override protected Object getValue(ComponentDef componentDef, Object key, Object component, String propertyName) throws IllegalPropertyRuntimeException { if (key instanceof Class<?>) { // key?class???interface???????? // ????proxy?? return LazyInitProxyFactory.createProxy((Class<?>) key, new S2ProxyTargetLocator(key)); } else {//from ww w.jav a2 s. c o m // key????????????????? // ???????pxory? Object value = super.getValue(componentDef, key, component, propertyName); return LazyInitProxyFactory.createProxy(value.getClass(), new S2ProxyTargetLocator(key)); } }
From source file:org.wicketstuff.javaee.injection.JavaEEProxyFieldValueFactory.java
License:Apache License
/** * Gets the corresponding object (or its proxy) for the field from the cache, or if it's not * cached, then returns a newly created proxy or the object itself. * // ww w .j a v a 2 s .c o m * @param field * The field, in which we're trying to inject * @param locator * The locator, which will locate the corresponding object for the field * @return The injectable value */ private Object getCachedProxy(Field field, IProxyTargetLocator locator) { Class<?> type = field.getType(); if (locator == null) { return null; } // if the field contains the "stateful" description, or the field itself // is a no-interfaceview Stateful bean if ((field.isAnnotationPresent(EJB.class) && field.getAnnotation(EJB.class).description().equals("stateful") || field.getType().isAnnotationPresent(Stateful.class))) { // creates a session if there wasn't already HttpServletRequest httpServletRequest = (HttpServletRequest) RequestCycle.get().getRequest() .getContainerRequest(); HttpSession session = httpServletRequest.getSession(); // check if it's already cached Object retValue = session.getAttribute(type.getName()); if (retValue == null) { if (!Modifier.isFinal(type.getModifiers())) { retValue = LazyInitProxyFactory.createProxy(type, locator); } else { retValue = locator.locateProxyTarget(); } session.setAttribute(type.getName(), retValue); } return retValue; } else { if (cache.containsKey(locator)) { return cache.get(locator); } if (!Modifier.isFinal(type.getModifiers())) { Object proxy = LazyInitProxyFactory.createProxy(type, locator); cache.put(locator, proxy); return proxy; } else { Object value = locator.locateProxyTarget(); cache.put(locator, value); return value; } } }
From source file:org.xaloon.wicket.component.inject.j2ee.JavaWeldProxyFieldValueFactory.java
License:Apache License
private Object getCachedProxy(Field field, IProxyTargetLocator locator) { Class<?> type = field.getType(); if (locator == null) { return null; }/*from w ww .jav a 2 s . co m*/ if (cache.containsKey(locator)) { return cache.get(locator); } if (!Modifier.isFinal(type.getModifiers())) { Object proxy = LazyInitProxyFactory.createProxy(type, locator); cache.put(locator, proxy); return proxy; } else { Object value = locator.locateProxyTarget(); cache.put(locator, value); return value; } }