Skip to content

Commit

Permalink
use an object factory
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2322 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Apr 6, 2009
1 parent 1a685a1 commit 50dcbb7
Showing 1 changed file with 18 additions and 13 deletions.
Expand Up @@ -22,6 +22,8 @@
import java.util.List;

import javax.inject.ExecutionException;
import javax.inject.manager.Manager;
import javax.naming.Reference;

import org.jboss.webbeans.BeanValidator;
import org.jboss.webbeans.CurrentManager;
Expand Down Expand Up @@ -59,6 +61,7 @@
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.resources.DefaultNamingContext;
import org.jboss.webbeans.resources.DefaultResourceLoader;
import org.jboss.webbeans.resources.ManagerObjectFactory;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
import org.jboss.webbeans.servlet.HttpSessionManager;
Expand Down Expand Up @@ -101,17 +104,7 @@ public void initialize()
}
addImplementationServices();
this.manager = ManagerImpl.newRootManager(ServiceRegistries.unmodifiableServiceRegistry(getServices()));
try
{
getServices().get(NamingContext.class).unbind(ManagerImpl.JNDI_KEY);
}
catch (ExecutionException e)
{
}
finally
{
getServices().get(NamingContext.class).bind(ManagerImpl.JNDI_KEY, getManager());
}
bindManagerIntoJndi();
CurrentManager.setRootManager(manager);
initializeContexts();
}
Expand All @@ -126,8 +119,20 @@ private void addImplementationServices()
// TODO expose AnnotatedClass on SPI and allow container to provide impl of this via ResourceLoader
getServices().add(ClassTransformer.class, new ClassTransformer());
getServices().add(MetaDataCache.class, new MetaDataCache(getServices().get(ClassTransformer.class)));


}

private void bindManagerIntoJndi()
{
try
{
getServices().get(NamingContext.class).unbind(ManagerImpl.JNDI_KEY);
}
catch (ExecutionException e) {}
finally
{
Reference managerReference = new Reference(Manager.class.getName(), ManagerObjectFactory.class.getName(), null);
getServices().get(NamingContext.class).bind(ManagerImpl.JNDI_KEY, managerReference);
}
}

public ManagerImpl getManager()
Expand Down

0 comments on commit 50dcbb7

Please sign in to comment.