Methods Summary |
---|
public java.lang.Object | construct()
Interceptor[] cInterceptors = constructorInterceptors[defaultConstructorIndex];
if (cInterceptors == null)
{
try
{
return constructors[defaultConstructorIndex].newInstance();
}
catch (InstantiationException e)
{
throw new RuntimeException(e);
}
catch (IllegalAccessException e)
{
throw new RuntimeException(e);
}
catch (InvocationTargetException e)
{
throw new RuntimeException(e);
}
}
ConstructorInvocation invocation = new ConstructorInvocation(
cInterceptors);
invocation.setAdvisor(this);
invocation.setConstructor(constructors[defaultConstructorIndex]);
try
{
return invocation.invokeNext();
}
catch (Throwable throwable)
{
throw new RuntimeException(throwable);
}
|
public void | create()
// EJBTHREE-655: we need an instance after create
initializeClassContainer();
for (int i = 0; i < constructors.length; i++)
{
if (constructors[i].getParameterTypes().length == 0)
{
defaultConstructorIndex = i;
break;
}
}
|
protected void | createCallbackHandler()
try
{
callbackHandler = new LifecycleInterceptorHandler(this,
getHandledCallbacks());
}
catch (Exception e)
{
throw new RuntimeException("Error creating callback handler for bean "
+ beanClassName, e);
}
|
public void | destroy()
super.cleanup();
|
protected void | findPartitionName()
Clustered clustered = (Clustered) resolveAnnotation(Clustered.class);
if (clustered == null)
{
partitionName = null;
return;
}
String value = clustered.partition();
try
{
String replacedValue = StringPropertyReplacer.replaceProperties(value);
if (value != replacedValue)
{
log.debug("Replacing @Clustered partition attribute " + value + " with " + replacedValue);
value = replacedValue;
}
}
catch (Exception e)
{
log.warn("Unable to replace @Clustered partition attribute " + value +
". Caused by " + e.getClass() + " " + e.getMessage());
}
partitionName = value;
|
public T | getAnnotation(java.lang.Class annotationType, java.lang.Class clazz)
if (clazz == this.getBeanClass())
{
return (T) resolveAnnotation(annotationType);
}
return clazz.getAnnotation(annotationType);
|
public T | getAnnotation(java.lang.Class annotationType, java.lang.Class clazz, java.lang.reflect.Method method)
if (clazz == this.getBeanClass())
{
return (T) resolveAnnotation(method, annotationType);
}
return method.getAnnotation(annotationType);
|
public T | getAnnotation(java.lang.Class annotationType, java.lang.reflect.Method method)
return (T) resolveAnnotation(method, annotationType);
|
public T | getAnnotation(java.lang.Class annotationType, java.lang.Class clazz, java.lang.reflect.Field field)
if (clazz == this.getBeanClass())
{
return (T) resolveAnnotation(field, annotationType);
}
return field.getAnnotation(annotationType);
|
public T | getAnnotation(java.lang.Class annotationType, java.lang.reflect.Field field)
return (T) resolveAnnotation(field, annotationType);
|
public java.util.HashSet | getApplicableInterceptors()
initialiseInterceptors();
return applicableInterceptors;
|
public org.jboss.ejb3.metamodel.AssemblyDescriptor | getAssemblyDescriptor()
return assembly;
|
public java.lang.Class | getBeanClass()
return clazz;
|
public java.lang.String | getBeanClassName()
return beanClassName;
|
protected java.lang.Object | getBridgedAnnotation(java.lang.reflect.Method bridgeMethod, java.lang.Class annotation)
Method[] methods = bridgeMethod.getDeclaringClass().getMethods();
int i = 0;
boolean found = false;
Class[] bridgeParams = bridgeMethod.getParameterTypes();
while (i < methods.length && !found)
{
if (!methods[i].isBridge() && methods[i].getName().equals(bridgeMethod.getName()))
{
Class[] params = methods[i].getParameterTypes();
if (params.length == bridgeParams.length)
{
int j = 0;
boolean matches = true;
while (j < params.length && matches)
{
if (!bridgeParams[j].isAssignableFrom(params[j]))
matches = false;
++j;
}
if (matches)
return resolveAnnotation(methods[i], annotation);
}
}
++i;
}
return null;
|
public java.lang.Object | getBusinessObject(BeanContext beanContext, java.lang.Class businessObject)
throw new IllegalStateException("Not implemented");
|
public java.util.List | getClassInterceptors()
initialiseInterceptors();
return classInterceptors;
|
public java.lang.ClassLoader | getClassloader()
return classloader;
|
public DependencyPolicy | getDependencyPolicy()
return dependencyPolicy;
|
public Ejb3Deployment | getDeployment()
return deployment;
|
public java.lang.String | getDeploymentDescriptorType()
return "ejb-jar.xml";
|
public java.lang.String | getDeploymentQualifiedName()Returns a String identifier for this bean that is qualified by the
deployment, and hence should be unique across deployments. Name is of the
form "ear=foo.ear,jar=foo.jar,name=Bar", where "Bar" is the value
returned by {@link #getEjbName()}. The "ear=foo.ear" portion is ommitted
if the bean is not packaged in an ear.
DeploymentScope ear = deployment.getEar();
DeploymentUnit unit = deployment.getDeploymentUnit();
StringBuilder sb = new StringBuilder();
if (ear != null)
{
sb.append("ear=");
sb.append(ear.getShortName());
sb.append(",");
}
sb.append("jar=");
sb.append(unit.getShortName());
sb.append(",name=");
sb.append(getEjbName());
return sb.toString();
|
public DeploymentUnit | getDeploymentUnit()
return deployment.getDeploymentUnit();
|
public java.lang.String | getEjbJndiName(java.lang.Class businessInterface)
return deployment.getEjbJndiName(businessInterface);
|
public java.lang.String | getEjbJndiName(java.lang.String link, java.lang.Class businessInterface)
return deployment.getEjbJndiName(link, businessInterface);
|
public java.lang.String | getEjbName()
return ejbName;
|
public javax.naming.Context | getEnc()
// if (enc == null)
// {
// enc = encFactory.getEnc(this);
// }
return enc;
|
public java.util.Map | getEncInjections()
return encInjections;
|
public java.util.Map | getEncInjectors()
return encInjectors;
|
public org.jboss.metamodel.descriptor.EnvironmentRefGroup | getEnvironmentRefGroup()
return xml;
|
protected java.lang.Class[] | getHandledCallbacks()
return new Class[]
{PostConstruct.class, PreDestroy.class, Timeout.class};
|
public java.lang.String | getIdentifier()
return getEjbName();
|
public javax.naming.InitialContext | getInitialContext()
try
{
if (initialContextProperties == null)
return new InitialContext();
else
return new InitialContext(initialContextProperties);
}
catch (NamingException e)
{
throw new RuntimeException(e);
}
|
public java.util.Hashtable | getInitialContextProperties()
return initialContextProperties;
|
public java.util.List | getInjectors()
return injectors;
|
public java.util.HashMap | getInterceptorInjectors()
initialiseInterceptors();
return interceptorInjectors;
|
public org.jboss.ejb3.interceptor.InterceptorInfoRepository | getInterceptorRepository()
return interceptorRepository;
|
public org.jboss.ejb3.statistics.InvocationStatistics | getInvokeStats()
return invokeStats;
|
public java.lang.Object | getInvokedBusinessInterface(BeanContext beanContext)
throw new IllegalStateException("Not implemented");
|
protected java.lang.Object | getInvokedInterface(java.lang.reflect.Method method)
Remote remoteAnnotation = (Remote) resolveAnnotation(Remote.class);
if (remoteAnnotation != null)
{
Class[] remotes = remoteAnnotation.value();
for (int i = 0; i < remotes.length; ++i)
{
try
{
remotes[i].getMethod(method.getName(), method.getParameterTypes());
return remotes[i];
}
catch (NoSuchMethodException e)
{
}
}
}
Local localAnnotation = (Local) resolveAnnotation(Local.class);
if (localAnnotation != null)
{
Class[] locals = localAnnotation.value();
for (int i = 0; i < locals.length; ++i)
{
Method[] interfaceMethods = locals[i].getMethods();
for (int j = 0; j < interfaceMethods.length; ++j)
{
if (interfaceMethods[j].equals(method))
return locals[i];
}
}
}
return null;
|
public java.lang.String | getJaccContextId()
return jaccContextId;
|
public org.jboss.aop.MethodInfo | getMethodInfo(java.lang.reflect.Method method)
long hash = MethodHashing.calculateHash(method);
MethodInfo info = (MethodInfo) methodInterceptors.get(hash);
if (info == null)
{
throw new RuntimeException("Could not resolve beanClass method from proxy call: " + method.toString());
}
return info;
|
public javax.management.ObjectName | getObjectName()
return objectName;
|
public java.lang.String | getPartitionName()Gets the name of the cluster partition with which this container is
associated. Not available until EJBContainer.start()
is completed.
return partitionName;
|
public org.jboss.ejb3.entity.PersistenceUnitDeployment | getPersistenceUnitDeployment(java.lang.String unitName)
return deployment.getPersistenceUnitDeployment(unitName);
|
public Pool | getPool()
return pool;
|
public org.jboss.ejb3.metamodel.EnterpriseBean | getXml()
return xml;
|
public boolean | hasAnnotation(java.lang.Class tgt, java.lang.String annotation)
if (annotations.hasClassAnnotation(annotation)) return true;
if (tgt == null) return false;
try
{
Class ann = loadPublicAnnotation(annotation);
// it is metadata or CLASS annotation
if (ann == null) return AnnotationElement.isAnyAnnotationPresent(tgt, annotation);
return tgt.isAnnotationPresent(ann);
}
catch (Exception e)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
|
public boolean | hasAnnotation(java.lang.reflect.Method m, java.lang.String annotation)
if (annotations.hasAnnotation(m, annotation)) return true;
try
{
Class ann = loadPublicAnnotation(annotation);
// it is metadata or CLASS annotation
if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
return m.isAnnotationPresent(ann);
}
catch (Exception e)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
|
public boolean | hasAnnotation(java.lang.reflect.Field m, java.lang.String annotation)
if (annotations.hasAnnotation(m, annotation)) return true;
try
{
Class ann = loadPublicAnnotation(annotation);
// it is metadata or CLASS annotation
if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
return m.isAnnotationPresent(ann);
}
catch (Exception e)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
|
public boolean | hasAnnotation(java.lang.reflect.Constructor m, java.lang.String annotation)
if (annotations.hasAnnotation(m, annotation)) return true;
try
{
Class ann = loadPublicAnnotation(annotation);
// it is metadata or CLASS annotation
if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
return m.isAnnotationPresent(ann);
}
catch (Exception e)
{
throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
}
|
private void | initialiseInterceptors()
if (applicableInterceptors == null)
{
log.debug("Initialising interceptors for " + getEjbName() + "...");
HashSet<InterceptorInfo> defaultInterceptors = interceptorRepository.getDefaultInterceptors();
log.debug("Default interceptors: " + defaultInterceptors);
classInterceptors = interceptorRepository.getClassInterceptors(this);
log.debug("Class interceptors: " + classInterceptors);
applicableInterceptors = new LinkedHashSet<InterceptorInfo>();
if (defaultInterceptors != null) applicableInterceptors.addAll(defaultInterceptors);
if (classInterceptors != null) applicableInterceptors.addAll(classInterceptors);
Method[] methods = clazz.getMethods();
for (int i = 0; i < methods.length; i++)
{
List methodIcptrs = interceptorRepository.getMethodInterceptors(this, methods[i]);
if (methodIcptrs != null && methodIcptrs.size() > 0)
{
log.debug("Method interceptors for " + methods[i] + ": " + methodIcptrs);
applicableInterceptors.addAll(methodIcptrs);
}
}
log.debug("All applicable interceptor classes: " + applicableInterceptors);
}
|
protected void | initializePool()
PoolClass poolClass = (PoolClass) resolveAnnotation(PoolClass.class);
Class<? extends Pool> poolClazz = poolClass.value();
int maxSize = poolClass.maxSize();
long timeout = poolClass.timeout();
pool = poolClazz.newInstance();
pool.initialize(this, beanContextClass, clazz, maxSize, timeout);
resolveInjectors();
pool.setInjectors(injectors.toArray(new Injector[injectors.size()]));
|
public void | instantiated()EJBContainer has finished with all metadata initialization from XML files and such.
this is really a hook to do some processing after XML has been set up and before
and processing of dependencies and such.
|
public void | invokeInit(java.lang.Object bean)
|
public void | invokeInit(java.lang.Object bean, java.lang.Class[] initParameterTypes, java.lang.Object[] initParameterValues)
|
public void | invokePostActivate(BeanContext beanContext)
throw new RuntimeException("PostActivate not implemented for container");
|
public void | invokePostConstruct(BeanContext beanContext)
callbackHandler.postConstruct(beanContext);
|
public void | invokePreDestroy(BeanContext beanContext)
callbackHandler.preDestroy(beanContext);
|
public void | invokePrePassivate(BeanContext beanContext)
throw new RuntimeException("PrePassivate not implemented for container");
|
private java.lang.Class | loadPublicAnnotation(java.lang.String annotation)
try
{
Class ann = classloader.loadClass(annotation);
if (!ann.isAnnotation()) return null;
Retention retention = (Retention) ann.getAnnotation(Retention.class);
if (retention != null && retention.value() == RetentionPolicy.RUNTIME) return ann;
}
catch (ClassNotFoundException ignored)
{
}
return null;
|
public void | popEnc()Pops EJB's ENC from the stack. Delegates to whatever implementation
is used to pop the EJB's ENC from the stock
ThreadLocalENCFactory.pop();
// encFactory.popEnc(this);
|
public void | processMetadata(DependencyPolicy dependencyPolicy)introspects EJB container to find all dependencies
and initialize any extra metadata.
This must be called before container is registered with any microcontainer
this.dependencyPolicy = dependencyPolicy;
// XML must be done first so that any annotation overrides are initialized
// todo injection handlers should be pluggable from XML
Collection<InjectionHandler> handlers = new ArrayList<InjectionHandler>();
handlers.add(new EJBHandler());
handlers.add(new DependsHandler());
handlers.add(new JndiInjectHandler());
handlers.add(new PersistenceContextHandler());
handlers.add(new PersistenceUnitHandler());
handlers.add(new ResourceHandler());
handlers.add(new WebServiceRefHandler());
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classloader);
try
{
// EJB container's XML must be processed before interceptor's as it may override interceptor's references
for (InjectionHandler handler : handlers) handler.loadXml(xml, this);
Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getBeanClass());
injectors.addAll(tmp.values());
initialiseInterceptors();
for (InterceptorInfo interceptorInfo : applicableInterceptors)
{
for (InjectionHandler handler : handlers)
{
handler.loadXml(interceptorInfo.getXml(), this);
}
}
for (InterceptorInfo interceptorInfo : applicableInterceptors)
{
Map<AccessibleObject, Injector> tmpInterceptor = InjectionUtil.processAnnotations(this, handlers, interceptorInfo.getClazz());
InterceptorInjector injector = new InterceptorInjector(this, interceptorInfo, tmpInterceptor);
interceptorInjectors.put(interceptorInfo.getClazz(), injector);
}
}
finally
{
Thread.currentThread().setContextClassLoader(old);
}
|
public void | pushEnc()Makes sure that EJB's ENC is available
Delegates to whatever implementation is used to push the ENC of the EJB
onto the stack
ThreadLocalENCFactory.push(enc);
// encFactory.pushEnc(this);
|
public java.lang.Object | resolveAnnotation(java.lang.reflect.Method m, java.lang.Class annotation)
Object value = super.resolveAnnotation(m, annotation);
if (value == null && m.isBridge()) value = getBridgedAnnotation(m, annotation);
return value;
|
public java.lang.Object | resolveAnnotation(java.lang.reflect.Method m, java.lang.Class[] annotationChoices)
Object value = null;
int i = 0;
while (value == null && i < annotationChoices.length){
value = resolveAnnotation(m, annotationChoices[i++]);
}
return value;
|
public Container | resolveEjbContainer(java.lang.String link, java.lang.Class businessIntf)
return deployment.getEjbContainer(link, businessIntf);
|
public Container | resolveEjbContainer(java.lang.Class businessIntf)
return deployment.getEjbContainer(businessIntf);
|
protected void | resolveInjectors()
pushEnc();
try
{
Thread.currentThread().setContextClassLoader(classloader);
try
{
Util.rebind(getEnc(), "UserTransaction", new UserTransactionImpl());
}
catch (NamingException e)
{
NamingException namingException = new NamingException("Could not bind user transaction for ejb name " + ejbName + " into JNDI under jndiName: " + getEnc().getNameInNamespace() + "/" + "UserTransaction");
namingException.setRootCause(e);
throw namingException;
}
}
finally
{
popEnc();
}
|
public void | setAssemblyDescriptor(org.jboss.ejb3.metamodel.AssemblyDescriptor assembly)
this.assembly = assembly;
|
public void | setJaccContextId(java.lang.String jaccContextId)
this.jaccContextId = jaccContextId;
|
public void | setXml(org.jboss.ejb3.metamodel.EnterpriseBean xml)
this.xml = xml;
|
public void | start()
initializePool();
for (EncInjector injector : encInjectors.values())
{
injector.inject(this);
}
// creating of injector array should come after injection into ENC as an ENC injector
// may add additional injectors into the injector list. An example is an extended persistence
// context which mush be created and added to the SFSB bean context.
Injector[] injectors2 = injectors.toArray(new Injector[injectors.size()]);
if (pool != null) pool.setInjectors(injectors2);
createCallbackHandler();
JaccHelper.configureContainer(jaccContextId, this);
// If we're clustered, find our partition name
findPartitionName();
log.info("STARTED EJB: " + clazz.getName() + " ejbName: " + ejbName);
|
public void | stop()
// encFactory.cleanupEnc(this);
if (pool != null)
{
pool.destroy();
pool = null;
}
log.info("STOPPED EJB: " + clazz.getName() + " ejbName: " + ejbName);
|