Skip to content

Commit

Permalink
various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Jun 3, 2010
1 parent b6589fc commit 43c7b47
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 30 deletions.
15 changes: 9 additions & 6 deletions impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
Expand Up @@ -335,13 +335,16 @@ private ServiceRegistry getImplementationServices(ResourceLoader resourceLoader)

public BeanManagerImpl getManager(BeanDeploymentArchive beanDeploymentArchive)
{
if (beanDeployments.containsKey(beanDeploymentArchive))
{
return beanDeployments.get(beanDeploymentArchive).getBeanManager();
}
else
synchronized (this)
{
return null;
if (beanDeployments.containsKey(beanDeploymentArchive))
{
return beanDeployments.get(beanDeploymentArchive).getBeanManager();
}
else
{
return null;
}
}
}

Expand Down
Expand Up @@ -38,6 +38,8 @@
import org.jboss.weld.serialization.spi.ContextualStore;
import org.slf4j.cal10n.LocLogger;

import edu.umd.cs.findbugs.annotations.SuppressWarnings;

/**
* Base for the Context implementations. Delegates calls to the abstract
* getBeanStorage and getActive to allow for different implementations (storage
Expand Down Expand Up @@ -75,6 +77,7 @@ public AbstractMapContext(Class<? extends Annotation> scopeType)
*
* @see javax.enterprise.context.spi.Context#get(BaseBean, boolean)
*/
@SuppressWarnings(value="UL_UNRELEASED_LOCK", justification="False positive from FindBugs")
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext)
{
if (!isActive())
Expand Down Expand Up @@ -102,6 +105,7 @@ else if (creationalContext != null)
{
if (needCreationLock)
{

creationLock.lock();
beanInstance = getBeanStore().get(id);
if (beanInstance != null)
Expand Down
Expand Up @@ -24,6 +24,8 @@
import org.jboss.weld.serialization.spi.ContextualStore;
import org.jboss.weld.serialization.spi.helpers.SerializableContextual;

import edu.umd.cs.findbugs.annotations.SuppressWarnings;

/**
* A serializable version of contextual that knows how to restore the
* original bean if necessary
Expand All @@ -44,7 +46,7 @@ protected Contextual<I> delegate()

// A directly serializable contextual
private C serialiazable;

@SuppressWarnings(value="SE_TRANSIENT_FIELD_NOT_RESTORED", justification="A cache which is lazily loaded")
// A cached, transient version of the contextual
private transient C cached;

Expand Down
Expand Up @@ -24,35 +24,35 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.PassivationCapable;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Maps;

import org.jboss.weld.context.SerializableContextualImpl;
import org.jboss.weld.context.SerializableContextualInstanceImpl;
import org.jboss.weld.serialization.spi.ContextualStore;
import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
import org.jboss.weld.context.SerializableContextualImpl;
import org.jboss.weld.context.SerializableContextualInstanceImpl;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.Maps;

/**
* Implementation of {@link org.jboss.weld.serialization.spi.ContextualStore}
*
*
* @author Pete Muir
*
*
*/
public class ContextualStoreImpl implements ContextualStore
{

private static final String GENERATED_ID_PREFIX = ContextualStoreImpl.class.getName();

// The map containing container-local contextuals
private final BiMap<Contextual<?>, String> contextuals;

// The map containing passivation capable contextuals
private final ConcurrentMap<String, Contextual<?>> passivationCapableContextuals;

private final AtomicInteger idGenerator;

public ContextualStoreImpl()
{
this.idGenerator = new AtomicInteger(0);
Expand Down Expand Up @@ -82,15 +82,16 @@ public <C extends Contextual<I>, I> C getContextual(String id)
return (C) passivationCapableContextuals.get(id);
}
}

/**
* Add a contextual (if not already present) to the store, and return
* it's id. If the contextual is passivation capable, it's id will
* be used, otherwise an id will be generated
* Add a contextual (if not already present) to the store, and return it's
* id. If the contextual is passivation capable, it's id will be used,
* otherwise an id will be generated
*
* @param contextual the contexutal to add
* @return the current id for the contextual
*/
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED", justification="Using non-standard semantics of putIfAbsent")
public String putIfAbsent(Contextual<?> contextual)
{
if (contextual instanceof PassivationCapable)
Expand Down
Expand Up @@ -26,7 +26,6 @@

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Collections;
Expand Down Expand Up @@ -190,11 +189,10 @@ private List<URL> loadServiceFiles()

private void loadServiceFile(URL serviceFile)
{
InputStream is = null;
BufferedReader reader = null;
try
{
is = serviceFile.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
reader = new BufferedReader(new InputStreamReader(serviceFile.openStream(), "UTF-8"));
String serviceClassName = null;
while ((serviceClassName = reader.readLine()) != null)
{
Expand All @@ -212,11 +210,11 @@ private void loadServiceFile(URL serviceFile)
}
finally
{
if (is != null)
if (reader != null)
{
try
{
is.close();
reader.close();
}
catch (IOException e)
{
Expand Down

0 comments on commit 43c7b47

Please sign in to comment.