Skip to content

Commit

Permalink
reduce usage of inner classes
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Jan 8, 2010
1 parent 98623e3 commit ee10f47
Show file tree
Hide file tree
Showing 18 changed files with 304 additions and 280 deletions.
52 changes: 3 additions & 49 deletions impl/src/main/java/org/jboss/weld/Container.java
Expand Up @@ -41,52 +41,6 @@
public class Container
{

/**
* Container status
* @author pmuir
*
*/
public enum Status
{
/**
* The container has not been started
*/
STOPPED(false),
/**
* The container is starting
*/
STARTING(false),
/**
* The container has started and beans have been deployed
*/
INITIALIZED(true),
/**
* The deployment has been validated
*/
VALIDATED(true),
/**
* The container has been shutdown
*/
SHUTDOWN(false);

private Status(boolean available)
{
this.available = available;
}

final boolean available;

/**
* Whether the container is available for use
*
* @return
*/
public boolean isAvailable()
{
return available;
}
}

private final static Singleton<Container> instance;

static
Expand Down Expand Up @@ -132,7 +86,7 @@ public static void initialize(BeanManagerImpl deploymentManager, ServiceRegistry

private final ServiceRegistry deploymentServices;

private Status status = Status.STOPPED;
private ContainerState status = ContainerState.STOPPED;

public Container(BeanManagerImpl deploymentManager, ServiceRegistry deploymentServices)
{
Expand Down Expand Up @@ -230,12 +184,12 @@ public void putBeanDeployments(Map<BeanDeploymentArchive, BeanDeployment> beanDe
}
}

public Status getStatus()
public ContainerState getStatus()
{
return status;
}

public void setStatus(Status status)
public void setStatus(ContainerState status)
{
this.status = status;
}
Expand Down
47 changes: 47 additions & 0 deletions impl/src/main/java/org/jboss/weld/ContainerState.java
@@ -0,0 +1,47 @@
package org.jboss.weld;

/**
* Container status
* @author pmuir
*
*/
public enum ContainerState
{
/**
* The container has not been started
*/
STOPPED(false),
/**
* The container is starting
*/
STARTING(false),
/**
* The container has started and beans have been deployed
*/
INITIALIZED(true),
/**
* The deployment has been validated
*/
VALIDATED(true),
/**
* The container has been shutdown
*/
SHUTDOWN(false);

private ContainerState(boolean available)
{
this.available = available;
}

final boolean available;

/**
* Whether the container is available for use
*
* @return
*/
public boolean isAvailable()
{
return available;
}
}
Expand Up @@ -60,6 +60,7 @@
import org.jboss.weld.exceptions.WeldException;
import org.jboss.weld.introspector.WeldMember;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.manager.DummyInjectionPoint;
import org.jboss.weld.metadata.cache.MetaAnnotationStore;
import org.jboss.weld.util.Beans;
import org.jboss.weld.util.Names;
Expand Down Expand Up @@ -248,7 +249,7 @@ else if (instance != null)
throw new IllegalProductException(NON_SERIALIZABLE_PRODUCT_ERROR, getProducer());
}
InjectionPoint injectionPoint = manager.getCurrentInjectionPoint();
if (injectionPoint == null || injectionPoint.equals(BeanManagerImpl.DUMMY_INJECTION_POINT))
if (injectionPoint == null || injectionPoint.equals(DummyInjectionPoint.INSTANCE))
{
return;
}
Expand Down
Expand Up @@ -30,19 +30,15 @@

import org.jboss.weld.literal.AnyLiteral;
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resolution.ResolvableTransformer;
import org.jboss.weld.util.collections.Arrays2;

public class InstanceBean extends AbstractFacadeBean<Instance<?>>
{

private static final Class<Instance<?>> INSTANCE_TYPE = new TypeLiteral<Instance<?>>() {}.getRawType();
private static final Class<Provider<?>> PROVIDER_TYPE = new TypeLiteral<Provider<?>>() {}.getRawType();
private static final Set<Type> DEFAULT_TYPES = Arrays2.<Type>asSet(INSTANCE_TYPE, PROVIDER_TYPE, Object.class);
private static final Any ANY = new AnyLiteral();
private static final Set<Annotation> DEFAULT_BINDINGS = new HashSet<Annotation>(Arrays.asList(ANY));
public static final ResolvableTransformer INSTANCE_TRANSFORMER = new FacadeBeanResolvableTransformer(INSTANCE_TYPE);
public static final ResolvableTransformer PROVIDER_TRANSFORMER = new FacadeBeanResolvableTransformer(PROVIDER_TYPE);

public InstanceBean(BeanManagerImpl manager)
{
Expand Down
10 changes: 5 additions & 5 deletions impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
Expand Up @@ -40,7 +40,7 @@

import org.jboss.weld.Container;
import org.jboss.weld.ContextualStoreImpl;
import org.jboss.weld.Container.Status;
import org.jboss.weld.ContainerState;
import org.jboss.weld.bean.builtin.BeanManagerBean;
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environment;
Expand Down Expand Up @@ -288,7 +288,7 @@ public Bootstrap startContainer(Environment environment, Deployment deployment,
this.deploymentManager = BeanManagerImpl.newRootManager("deployment", deploymentServices);

Container.initialize(deploymentManager, ServiceRegistries.unmodifiableServiceRegistry(deployment.getServices()));
Container.instance().setStatus(Status.STARTING);
Container.instance().setStatus(ContainerState.STARTING);

createContexts();
initializeContexts();
Expand Down Expand Up @@ -381,7 +381,7 @@ public Bootstrap deployBeans()
// Re-read the deployment structure, this will be the physical structure, extensions, classes, and any beans added using addBean outside the physical structure
beanDeployments = deploymentVisitor.visit();
Container.instance().putBeanDeployments(beanDeployments);
Container.instance().setStatus(Status.INITIALIZED);
Container.instance().setStatus(ContainerState.INITIALIZED);
}
return this;
}
Expand All @@ -406,7 +406,7 @@ public Bootstrap endInitialization()
synchronized (this)
{
// Register the managers so external requests can handle them
Container.instance().setStatus(Status.VALIDATED);
Container.instance().setStatus(ContainerState.VALIDATED);
}
return this;
}
Expand Down Expand Up @@ -442,7 +442,7 @@ public void shutdown()
}
finally
{
Container.instance().setStatus(Status.SHUTDOWN);
Container.instance().setStatus(ContainerState.SHUTDOWN);
Container.instance().deploymentServices().get(ContextLifecycle.class).endApplication();
}
}
Expand Down
30 changes: 1 addition & 29 deletions impl/src/main/java/org/jboss/weld/ejb/EjbDescriptors.java
Expand Up @@ -28,7 +28,6 @@
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.ejb.spi.EjbDescriptor;
import org.jboss.weld.exceptions.ForbiddenStateException;
import org.jboss.weld.exceptions.InvalidOperationException;

import com.google.common.base.Supplier;
import com.google.common.collect.Multimaps;
Expand All @@ -47,34 +46,7 @@ public class EjbDescriptors implements Service, Iterable<InternalEjbDescriptor<?

private final SetMultimap<Class<?>, String> ejbByClass;

public static final EjbDescriptors EMPTY = new EjbDescriptors()
{
@Override
public <T> void add(EjbDescriptor<T> ejbDescriptor)
{
throw new InvalidOperationException();
}

@Override
public void addAll(Iterable<EjbDescriptor<?>> ejbDescriptors)
{
throw new InvalidOperationException();
}

@Override
public void cleanup()
{
throw new InvalidOperationException();
}

@Override
public void clear()
{
throw new InvalidOperationException();
}


};
public static final EjbDescriptors EMPTY = new EjbDescriptors();

/**
* Constructor
Expand Down

0 comments on commit ee10f47

Please sign in to comment.