use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class CacheProperties method loadProperties.
private void loadProperties(EjbContainer ejbContainer, EjbDescriptor ejbDesc, BeanCacheDescriptor beanCacheDes) {
numberOfVictimsToSelect = Integer.parseInt(ejbContainer.getCacheResizeQuantity());
maxCacheSize = Integer.parseInt(ejbContainer.getMaxCacheSize());
cacheIdleTimeoutInSeconds = Integer.parseInt(ejbContainer.getCacheIdleTimeoutInSeconds());
removalTimeoutInSeconds = Integer.parseInt(ejbContainer.getRemovalTimeoutInSeconds());
victimSelectionPolicy = ejbContainer.getVictimSelectionPolicy();
// specified in sun-ejb-jar.xml, that has highest precedence.
if (ejbDesc instanceof EjbSessionDescriptor) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDesc;
if (sessionDesc.hasStatefulTimeout()) {
long value = sessionDesc.getStatefulTimeoutValue();
TimeUnit unit = sessionDesc.getStatefulTimeoutUnit();
value = TimeUnit.SECONDS.convert(value, unit);
if (value < 0) {
this.removalTimeoutInSeconds = -1;
this.cacheIdleTimeoutInSeconds = -1;
} else if (value == 0) {
this.removalTimeoutInSeconds = 1;
this.cacheIdleTimeoutInSeconds = 2;
} else {
this.removalTimeoutInSeconds = (int) value;
this.cacheIdleTimeoutInSeconds = (int) (value + 1);
}
}
/* lifespan of an idle sfsb is time-in-cache + time-on-disk, with cacheIdleTimeoutInSeconds setting
for the 1st interval and removalTimeoutInSeconds for the 2nd. So if you add them, the sfsb will stay
in the cache to the max possible interval, and because it'll be never written to disk,
there will be nothing to remove from there.
set cacheIdleTimeoutInSeconds and maxCacheSize will cause cache never overflow, and sfsb just be
removed from cache when cacheIdleTimeoutInSeconds arrives */
if (sessionDesc.isStateful() && !sessionDesc.isPassivationCapable()) {
cacheIdleTimeoutInSeconds = cacheIdleTimeoutInSeconds + removalTimeoutInSeconds;
maxCacheSize = -1;
}
}
if (beanCacheDes != null) {
int temp = 0;
if ((temp = beanCacheDes.getResizeQuantity()) != -1) {
this.numberOfVictimsToSelect = temp;
}
if ((temp = beanCacheDes.getMaxCacheSize()) != -1) {
this.maxCacheSize = temp;
}
if ((temp = beanCacheDes.getCacheIdleTimeoutInSeconds()) != -1) {
this.cacheIdleTimeoutInSeconds = temp;
}
if ((temp = beanCacheDes.getRemovalTimeoutInSeconds()) != -1) {
this.removalTimeoutInSeconds = temp;
}
if ((beanCacheDes.getVictimSelectionPolicy()) != null) {
this.victimSelectionPolicy = beanCacheDes.getVictimSelectionPolicy();
}
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class SafeProperties method setHomeTargetMethodInfo.
private void setHomeTargetMethodInfo(InvocationInfo invInfo, boolean isLocal) throws EJBException {
Class homeIntfClazz = isLocal ? javax.ejb.EJBLocalHome.class : javax.ejb.EJBHome.class;
Class methodClass = invInfo.method.getDeclaringClass();
Class[] paramTypes = invInfo.method.getParameterTypes();
String methodName = invInfo.method.getName();
try {
Method m = homeIntfClazz.getMethod(methodName, paramTypes);
// Attempt to override Home/LocalHome method. Print warning
// but don't treat it as a fatal error. At runtime,
// the EJBHome/EJBLocalHome method will be called.
String[] params = { m.toString(), invInfo.method.toString() };
_logger.log(Level.WARNING, ILLEGAL_EJB_INTERFACE_OVERRIDE, params);
invInfo.ejbIntfOverride = true;
return;
} catch (NoSuchMethodException nsme) {
}
try {
if (invInfo.startsWithCreate) {
String extraCreateChars = methodName.substring("create".length());
invInfo.targetMethod1 = ejbClass.getMethod("ejbCreate" + extraCreateChars, paramTypes);
adjustHomeTargetMethodInfo(invInfo, methodName, paramTypes);
} else if (invInfo.startsWithFind) {
String extraFinderChars = methodName.substring("find".length());
invInfo.targetMethod1 = ejbClass.getMethod("ejbFind" + extraFinderChars, paramTypes);
} else {
// HOME method
String upperCasedName = methodName.substring(0, 1).toUpperCase(Locale.US) + methodName.substring(1);
invInfo.targetMethod1 = ejbClass.getMethod("ejbHome" + upperCasedName, paramTypes);
}
} catch (NoSuchMethodException nsme) {
if ((methodClass == localBusinessHomeIntf) || (methodClass == remoteBusinessHomeIntf) || (methodClass == ejbOptionalLocalBusinessHomeIntf || (methodClass == GenericEJBHome.class))) {
// Not an error. This is the case where the EJB 3.0
// client view is being used and there is no corresponding
// create/init method.
} else if (isStatelessSession || isSingleton) {
// Ignore. Not an error.
// EJB 3.0 Stateless session ejbCreate/PostConstruct
// is decoupled from RemoteHome/LocalHome create().
} else {
Method initMethod = null;
if (isSession) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDescriptor;
for (EjbInitInfo next : sessionDesc.getInitMethods()) {
MethodDescriptor beanMethod = next.getBeanMethod();
Method m = beanMethod.getMethod(sessionDesc);
if (next.getCreateMethod().getName().equals(methodName) && TypeUtil.sameParamTypes(m, invInfo.method)) {
initMethod = m;
break;
}
}
}
if (initMethod != null) {
invInfo.targetMethod1 = initMethod;
} else {
Object[] params = { logParams[0], (isLocal ? "LocalHome" : "Home"), invInfo.method.toString() };
_logger.log(Level.WARNING, BEAN_CLASS_METHOD_NOT_FOUND, params);
// Treat this as a warning instead of a fatal error.
// That matches the behavior of the generated code.
// Mark the target methods as null. If this method is
// invoked at runtime it will be result in an exception
// from the invocation handlers.
invInfo.targetMethod1 = null;
invInfo.targetMethod2 = null;
}
}
}
}
use of org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor in project Payara by payara.
the class ExpiredSessionsRemovalTask method buildComponents.
public void buildComponents(byte[] ipAddress, int port, DeploymentContext dc) throws Exception {
if (availabilityService != null) {
this.HAEnabled = Boolean.valueOf(availabilityService.getAvailabilityEnabled());
_logger.log(Level.FINE, SFSB_BUILDER_TOP_LEVEL_AVAILABILITY_SERVICE_ENABLED, this.HAEnabled);
if ((this.HAEnabled) && (ejbAvailability != null)) {
this.HAEnabled = Boolean.valueOf(ejbAvailability.getAvailabilityEnabled());
_logger.log(Level.FINE, SFSB_BUILDER_EJB_AVAILABILITY_SERVICE_ENABLED, this.HAEnabled);
}
boolean appLevelHAEnabled = false;
try {
if (HAEnabled) {
if (dc != null) {
DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class);
if (params != null) {
appLevelHAEnabled = params.availabilityenabled;
asyncReplication = params.asyncreplication;
}
}
_logger.log(Level.FINE, SFSB_BUILDER_GLOBAL_AND_APP_AVAILABILITY_ENABLED, new Object[] { this.HAEnabled, appLevelHAEnabled });
}
} catch (Exception ex) {
_logger.log(Level.WARNING, SFSB_BUILDER_DETERMINE_AVAILABILITY_EXCEPTION, ex);
appLevelHAEnabled = false;
}
HAEnabled = HAEnabled && appLevelHAEnabled;
_logger.log(Level.FINE, SFSB_BUILDER_RESOLVED_AVAILABILITY_ENABLED, this.HAEnabled);
}
EjbSessionDescriptor sessionDescriptor = (EjbSessionDescriptor) ejbDescriptor;
// When passivation is disabled, we should also forbid ha.
if (!sessionDescriptor.isPassivationCapable() && HAEnabled) {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, SFSB_HA_DISABLED_BY_PASSIVATION_SETTING, ejbDescriptor.getEjbClassName());
}
HAEnabled = false;
}
buildCheckpointPolicy(this.HAEnabled);
buildSFSBUUIDUtil(ipAddress, port);
// First build BackingStore before Cache is built
if (sessionDescriptor.isPassivationCapable()) {
buildStoreManager();
} else {
if (_logger.isLoggable(TRACE_LEVEL)) {
_logger.log(TRACE_LEVEL, "Stateful session bean passivation is disabled, so do not create store manger");
}
}
buildCache();
scheduleTimerTasks(sfsbContainer);
}
Aggregations