use of org.apache.tapestry5.commons.services.PlasticProxyFactory in project tapestry-5 by apache.
the class ApplicationMessageCatalogObjectProvider method createProxy.
private void createProxy() {
try {
upgradeReadLockToWriteLock();
this.messagesSource = objectLocator.getService(ComponentMessagesSource.class);
this.threadLocale = objectLocator.getService(ThreadLocale.class);
PlasticProxyFactory proxyFactory = objectLocator.getService("PlasticProxyFactory", PlasticProxyFactory.class);
proxy = proxyFactory.createProxy(Messages.class, new ApplicationMessagesObjectCreator(), "<ApplicationMessagesProxy>");
// Listen for invalidations; clear our cache of localized Messages bundles when
// an invalidation occurs.
messagesSource.getInvalidationEventHub().clearOnInvalidation(localeToMessages);
} finally {
downgradeWriteLockToReadLock();
}
}
use of org.apache.tapestry5.commons.services.PlasticProxyFactory in project tapestry-5 by apache.
the class EntityManagerObjectProvider method getOrCreateProxy.
@SuppressWarnings({ "unchecked", "rawtypes" })
private EntityManager getOrCreateProxy(final AnnotationProvider annotationProvider, final ObjectLocator objectLocator) {
final PersistenceContext annotation = annotationProvider.getAnnotation(PersistenceContext.class);
final String unitName = annotation == null ? null : annotation.unitName();
EntityManager proxy = emProxyByName.get(unitName);
if (proxy == null)
synchronized (this) {
final PlasticProxyFactory proxyFactory = objectLocator.getService("PlasticProxyFactory", PlasticProxyFactory.class);
proxy = proxyFactory.createProxy(EntityManager.class, new ObjectCreator() {
@Override
public Object createObject() {
final EntityManagerManager entityManagerManager = objectLocator.getService(EntityManagerManager.class);
return JpaInternalUtils.getEntityManager(entityManagerManager, annotation);
}
}, "<EntityManagerProxy>");
emProxyByName.put(unitName, proxy);
}
return proxy;
}
use of org.apache.tapestry5.commons.services.PlasticProxyFactory in project tapestry-5 by apache.
the class EnvironmentalShadowBuilderImplTest method proxy_class.
@Test
public void proxy_class() {
JavaScriptSupport delegate = newMock(JavaScriptSupport.class);
Environment env = mockEnvironment();
train_peekRequired(env, JavaScriptSupport.class, delegate);
expect(delegate.allocateClientId("fred")).andReturn("barney");
replay();
EnvironmentalShadowBuilder builder = new EnvironmentalShadowBuilderImpl(getService("PlasticProxyFactory", PlasticProxyFactory.class), env);
JavaScriptSupport proxy = builder.build(JavaScriptSupport.class);
assertEquals(proxy.allocateClientId("fred"), "barney");
verify();
}
Aggregations