use of org.jboss.weld.serialization.spi.BeanIdentifier in project core by weld.
the class ClientProxyProvider method createClientProxy.
private <T> T createClientProxy(Bean<T> bean, Set<Type> types) {
BeanIdentifier id = Container.instance(contextId).services().get(ContextualStore.class).putIfAbsent(bean);
if (id == null) {
throw BeanLogger.LOG.beanIdCreationFailed(bean);
}
BeanInstance beanInstance = new ContextBeanInstance<T>(bean, id, contextId);
TypeInfo typeInfo = TypeInfo.of(types);
T proxy = new ClientProxyFactory<T>(contextId, typeInfo.getSuperClass(), types, bean).create(beanInstance);
BeanLogger.LOG.createdNewClientProxyType(proxy.getClass(), bean, id);
return proxy;
}
use of org.jboss.weld.serialization.spi.BeanIdentifier in project core by weld.
the class AttributeBeanStore method attach.
/**
* <p>
* Attach the bean store, any updates from now on will be written through to
* the underlying store.
* </p>
* <p/>
* <p>
* When the bean store is attached, the detached state is assumed to be
* authoritative if there are any conflicts.
* </p>
*/
public boolean attach() {
if (!attached) {
attached = true;
if (isLocalBeanStoreSyncNeeded()) {
if (!beanStore.delegate().isEmpty()) {
// The local bean store is authoritative, so copy everything to the backing store
for (BeanIdentifier id : beanStore) {
ContextualInstance<?> instance = beanStore.get(id);
String prefixedId = getNamingScheme().prefix(id);
ContextLogger.LOG.updatingStoreWithContextualUnderId(instance, id);
setAttribute(prefixedId, instance);
}
}
if (!isAttributeLazyFetchingEnabled()) {
// Additionally copy anything not in the local bean store but in the backing store
fetchUninitializedAttributes();
}
}
return true;
} else {
return false;
}
}
use of org.jboss.weld.serialization.spi.BeanIdentifier in project core by weld.
the class AttributeBeanStore method clear.
public void clear() {
Iterator<BeanIdentifier> it = iterator();
while (it.hasNext()) {
BeanIdentifier id = it.next();
if (isAttached()) {
String prefixedId = namingScheme.prefix(id);
removeAttribute(prefixedId);
}
it.remove();
ContextLogger.LOG.contextualInstanceRemoved(id, this);
}
ContextLogger.LOG.contextCleared(this);
}
use of org.jboss.weld.serialization.spi.BeanIdentifier in project core by weld.
the class AbstractContext method destroy.
@Override
public void destroy(Contextual<?> contextual) {
if (!isActive()) {
throw new ContextNotActiveException();
}
checkContextInitialized();
if (contextual == null) {
throw ContextLogger.LOG.contextualIsNull();
}
final BeanStore beanStore = getBeanStore();
if (beanStore == null) {
throw ContextLogger.LOG.noBeanStoreAvailable(this);
}
BeanIdentifier id = getId(contextual);
ContextualInstance<?> beanInstance = beanStore.remove(id);
if (beanInstance != null) {
RequestScopedCache.invalidate();
destroyContextualInstance(beanInstance);
}
}
use of org.jboss.weld.serialization.spi.BeanIdentifier in project core by weld.
the class AbstractContext method destroy.
/**
* Destroys the context
*/
protected void destroy() {
ContextLogger.LOG.contextCleared(this);
final BeanStore beanStore = getBeanStore();
if (beanStore == null) {
throw ContextLogger.LOG.noBeanStoreAvailable(this);
}
for (BeanIdentifier id : beanStore) {
destroyContextualInstance(beanStore.get(id));
}
beanStore.clear();
}
Aggregations