use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class StatefulHandler method setEjbDescriptorInfo.
/**
* Set Annotation information to Descriptor.
* This method will also be invoked for an existing descriptor with
* annotation as user may not specific a complete xml.
* @param ejbDesc
* @param ainfo
* @return HandlerProcessingResult
*/
protected HandlerProcessingResult setEjbDescriptorInfo(EjbDescriptor ejbDesc, AnnotationInfo ainfo) throws AnnotationProcessorException {
EjbSessionDescriptor ejbSessionDesc = (EjbSessionDescriptor) ejbDesc;
// set session bean type in case it wasn't set in a sparse ejb-jar.xml.
if (!ejbSessionDesc.isSessionTypeSet()) {
ejbSessionDesc.setSessionType(EjbSessionDescriptor.STATEFUL);
}
Stateful sful = (Stateful) ainfo.getAnnotation();
doDescriptionProcessing(sful.description(), ejbDesc);
doMappedNameProcessing(sful.mappedName(), ejbDesc);
// set passivation capable property in case it wasn't set in ejb-jar.xml
if (!ejbSessionDesc.isPassivationCapableSet()) {
ejbSessionDesc.setPassivationCapable(sful.passivationCapable());
}
return setBusinessAndHomeInterfaces(ejbDesc, ainfo);
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class StatelessHandler method setEjbDescriptorInfo.
/**
* Set Annotation information to Descriptor.
* This method will also be invoked for an existing descriptor with
* annotation as user may not specific a complete xml.
* @param ejbDesc
* @param ainfo
* @return HandlerProcessingResult
*/
protected HandlerProcessingResult setEjbDescriptorInfo(EjbDescriptor ejbDesc, AnnotationInfo ainfo) throws AnnotationProcessorException {
EjbSessionDescriptor ejbSessionDesc = (EjbSessionDescriptor) ejbDesc;
// set session bean type in case it wasn't set in a sparse ejb-jar.xml.
if (!ejbSessionDesc.isSessionTypeSet()) {
ejbSessionDesc.setSessionType(EjbSessionDescriptor.STATELESS);
}
Stateless sless = (Stateless) ainfo.getAnnotation();
doDescriptionProcessing(sless.description(), ejbDesc);
doMappedNameProcessing(sless.mappedName(), ejbDesc);
return setBusinessAndHomeInterfaces(ejbDesc, ainfo);
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class StatelessHandler method createEjbDescriptor.
/**
* Create a new EjbDescriptor for a given elementName and AnnotationInfo.
* @param elementName
* @param ainfo
* @return a new EjbDescriptor
*/
protected EjbDescriptor createEjbDescriptor(String elementName, AnnotationInfo ainfo) throws AnnotationProcessorException {
AnnotatedElement ae = ainfo.getAnnotatedElement();
Class ejbClass = (Class) ae;
EjbSessionDescriptor newDescriptor = new EjbSessionDescriptor();
newDescriptor.setName(elementName);
newDescriptor.setEjbClassName(ejbClass.getName());
newDescriptor.setSessionType(EjbSessionDescriptor.STATELESS);
return newDescriptor;
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class EjbApplication method loadContainers.
/**
* Initial phase of continer initialization. This creates the concrete container
* instance for each EJB component, registers JNDI entries, etc. However, no
* EJB bean instances or invocations occur during this phase. Those must be
* delayed until start() is called.
* @param startupContext
* @return
*/
boolean loadContainers(ApplicationContext startupContext) {
DeploymentContext dc = (DeploymentContext) startupContext;
String dcMapToken = "org.glassfish.ejb.startup.SingletonLCM";
singletonLCM = dc.getTransientAppMetaData(dcMapToken, SingletonLifeCycleManager.class);
if (singletonLCM == null) {
singletonLCM = new SingletonLifeCycleManager(initializeInOrder);
dc.addTransientAppMetaData(dcMapToken, singletonLCM);
}
if (!initializeInOrder) {
dc.addTransientAppMetaData(EJB_APP_MARKED_AS_STARTED_STATUS, Boolean.FALSE);
List<EjbApplication> ejbAppList = dc.getTransientAppMetaData(CONTAINER_LIST_KEY, List.class);
if (ejbAppList == null) {
ejbAppList = new ArrayList<EjbApplication>();
dc.addTransientAppMetaData(CONTAINER_LIST_KEY, ejbAppList);
}
ejbAppList.add(this);
}
try {
policyLoader.loadPolicy();
for (EjbDescriptor desc : ejbs) {
// Initialize each ejb container (setup component environment, register JNDI objects, etc.)
// Any instance instantiation , timer creation/restoration, message inflow is delayed until
// start phase.
ContainerFactory ejbContainerFactory = services.getService(ContainerFactory.class, desc.getContainerFactoryQualifier());
if (ejbContainerFactory == null) {
String errMsg = localStrings.getLocalString("invalid.container.module", "Container module is not available", desc.getEjbTypeForDisplay());
throw new RuntimeException(errMsg);
}
Container container = ejbContainerFactory.createContainer(desc, ejbAppClassLoader, dc);
containers.add(container);
if (desc instanceof EjbSessionDescriptor && ((EjbSessionDescriptor) desc).isSingleton()) {
singletonLCM.addSingletonContainer(this, (AbstractSingletonContainer) container);
}
}
} catch (Throwable t) {
abortInitializationAfterException();
throw new RuntimeException("EJB Container initialization error", t);
} finally {
// clean up the thread local current classloader after codegen to ensure it isn't
// referencing the deployed application
CurrentClassLoader.set(this.getClass().getClassLoader());
Wrapper._clear();
}
return true;
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class SingletonLifeCycleManager method doStartup.
void doStartup(EjbApplication ejbApp) {
Collection<EjbDescriptor> ejbs = ejbApp.getEjbBundleDescriptor().getEjbs();
for (EjbDescriptor desc : ejbs) {
if (desc instanceof EjbSessionDescriptor) {
EjbSessionDescriptor sdesc = (EjbSessionDescriptor) desc;
if ((sdesc.isSingleton())) {
if (sdesc.getInitOnStartup()) {
String normalizedSingletonName = normalizeSingletonName(sdesc.getName(), sdesc);
initializeSingleton(name2Container.get(normalizedSingletonName));
}
}
}
}
}
Aggregations