Skip to content

Commit

Permalink
More performance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Apr 8, 2012
1 parent 0d5f532 commit 30589f4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 39 deletions.
53 changes: 29 additions & 24 deletions impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@
*/
package org.jboss.weld.bean;

import java.beans.Introspector;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.enterprise.context.Dependent;
import javax.enterprise.context.NormalScope;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
import javax.inject.Scope;

import javassist.util.proxy.ProxyObject;
import org.jboss.weld.bean.interceptor.CustomInterceptorMetadata;
import org.jboss.weld.bean.interceptor.SerializableContextualInterceptorReference;
Expand Down Expand Up @@ -56,29 +80,6 @@
import org.jboss.weld.util.reflection.SecureReflections;
import org.slf4j.cal10n.LocLogger;

import javax.enterprise.context.Dependent;
import javax.enterprise.context.NormalScope;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
import javax.inject.Scope;
import java.beans.Introspector;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.jboss.weld.logging.Category.BEAN;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
import static org.jboss.weld.logging.messages.BeanMessage.CONFLICTING_INTERCEPTOR_BINDINGS;
Expand Down Expand Up @@ -147,6 +148,8 @@ private static <T> InterceptorMetadata<T>[] emptyInterceptorMetadataArray() {
*/
protected ProxyFactory<T> decoratorProxyFactory;

private boolean hasInterceptors;

/**
* Constructor
*
Expand All @@ -172,6 +175,7 @@ public void initialize(BeanDeployerEnvironment environment) {
initTargetClassInterceptors();
}


@Override
public void initializeAfterBeanDiscovery() {
initInterceptorsIfNeeded();
Expand All @@ -190,6 +194,7 @@ protected void initInterceptorsIfNeeded() {
if (isInterceptionCandidate() && !beanManager.getInterceptorModelRegistry().containsKey(getType())) {
new InterceptionModelInitializer().init();
}
hasInterceptors = this.isInterceptionCandidate() && (hasSerializationOrInvocationInterceptorMethods || beanManager.getInterceptorModelRegistry().get(getType()) != null);
}

public void initDecorators() {
Expand Down Expand Up @@ -397,7 +402,7 @@ protected void defaultPostConstruct(T instance) {
}

public boolean hasInterceptors() {
return this.isInterceptionCandidate() && (hasSerializationOrInvocationInterceptorMethods || beanManager.getInterceptorModelRegistry().get(getType()) != null);
return hasInterceptors;
}

private void initTargetClassInterceptors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public Bootstrap startContainer(Environment environment, Deployment deployment)
deploymentServices.add(ClassTransformer.class, implementationServices.get(ClassTransformer.class));
deploymentServices.add(MetaAnnotationStore.class, implementationServices.get(MetaAnnotationStore.class));
deploymentServices.add(TypeStore.class, implementationServices.get(TypeStore.class));
deploymentServices.add(ContextualStore.class, implementationServices.get(ContextualStore.class));

this.environment = environment;
this.deploymentManager = BeanManagerImpl.newRootManager("deployment", deploymentServices, EMPTY_ENABLED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
*/
package org.jboss.weld.context;

import edu.umd.cs.findbugs.annotations.SuppressWarnings;
import org.jboss.weld.context.api.ContextualInstance;
import org.jboss.weld.util.reflection.Reflections;

import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;

import edu.umd.cs.findbugs.annotations.SuppressWarnings;
import org.jboss.weld.context.api.ContextualInstance;
import org.jboss.weld.util.reflection.Reflections;

/**
* @author Pete Muir
* @author Ales Justin
Expand Down Expand Up @@ -91,9 +92,6 @@ public void release(Contextual<T> contextual, T instance) {
if (contextual == null || (dependentInstance.getContextual().equals(contextual) == false))
destroy(dependentInstance);
}
if (incompleteInstances != null) {
incompleteInstances.clear();
}
}

private static <T> void destroy(ContextualInstance<T> beanInstance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
*/
package org.jboss.weld.context;

import java.io.Serializable;

import javax.enterprise.context.spi.Contextual;

import edu.umd.cs.findbugs.annotations.SuppressWarnings;
import org.jboss.weld.Container;
import org.jboss.weld.serialization.spi.ContextualStore;
import org.jboss.weld.serialization.spi.helpers.SerializableContextual;

import javax.enterprise.context.spi.Contextual;
import java.io.Serializable;

/**
* A serializable version of contextual that knows how to restore the
* original bean if necessary
Expand Down Expand Up @@ -61,7 +62,7 @@ public SerializableContextualImpl(C contextual, ContextualStore contextualStore)
this.serialiazable = contextual;
} else {
// otherwise, generate an id (may not be portable between container instances)
this.id = getContextualStore().putIfAbsent(contextual);
this.id = contextualStore.putIfAbsent(contextual);
}
// cache the contextual
this.cached = contextual;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public Set<Bean<?>> getBeans(InjectionPoint injectionPoint) {
boolean registerInjectionPoint = !injectionPoint.getType().equals(InjectionPoint.class);
CurrentInjectionPoint currentInjectionPoint = null;
if (registerInjectionPoint) {
currentInjectionPoint = Container.instance().services().get(CurrentInjectionPoint.class);
currentInjectionPoint = services.get(CurrentInjectionPoint.class);
}
try {
if (registerInjectionPoint) {
Expand Down Expand Up @@ -683,7 +683,7 @@ public Object getReference(InjectionPoint injectionPoint, Bean<?> resolvedBean,
boolean delegateInjectionPoint = injectionPoint != null && injectionPoint.isDelegate();
CurrentInjectionPoint currentInjectionPoint = null;
if (registerInjectionPoint) {
currentInjectionPoint = Container.instance().services().get(CurrentInjectionPoint.class);
currentInjectionPoint = services.get(CurrentInjectionPoint.class);
}
try {
if (registerInjectionPoint) {
Expand Down

0 comments on commit 30589f4

Please sign in to comment.