Utility method used by UOWControl to determine if a
given BeanId corresponds to a stateful session bean. <p>
357402
public final boolean isStatefulSessionBean(BeanId id) {
        boolean result = id.getHome().isStatefulSessionHome();
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "isStatefulSessionBean : " + result + ", " + id);
        return result;
    }
737720
public synchronized boolean hasService(Class serviceClass) {

        // todo: for multithreaded usage this block needs to be synchronized
        ServiceProvider sp = _serviceProviders.get(serviceClass);
        if (sp != null && !sp.isRevoked()) {
            return true;
        }

        // if service not found locally check in nested context
        BeanContext bc = getBeanContext();
        if (bc instanceof BeanContextServices) {
            return ((BeanContextServices) bc).hasService(serviceClass);
        }
        return false;
        // end synchronized
    }
947318
private boolean isProtocolSwitch(String pURL, HttpServletRequest pRequest) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[IS_PROTOCOL_SWITCH]);
        }
        // Extract the protocol
        int ix = pURL.indexOf("://");
        if (ix < 0)
            return false;
        String protocol = pURL.substring(0, ix);

        // See if it's a switch between HTTP and HTTPS
        if (!((protocol.equalsIgnoreCase("http") && pRequest.getScheme().equalsIgnoreCase("https")) || (protocol.equalsIgnoreCase("https") && pRequest.getScheme().equalsIgnoreCase("http")))) {
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[IS_PROTOCOL_SWITCH], "false - No protocol switch.");
            }
            return false;
        }

        // Extract the host by searching for the first ':' or '/'
        int start = ix + 3;
        int end = start;
        int len = pURL.length();
        for (; end < len; end++) {
            char ch = pURL.charAt(end);
            if (ch == ':' || ch == '/')
                break;
        }
        String host = pURL.substring(start, end);

        // Get the IP address of the host
        InetAddress hostaddr;
        try {
            hostaddr = InetAddress.getByName(host);
        } catch (UnknownHostException exc) {
            com.ibm.ws.ffdc.FFDCFilter.processException(exc, "com.ibm.ws.session.SessionContext.isProtocolSwitch", "1760", this);
            LoggingUtil.SESSION_LOGGER_CORE.logp(Level.SEVERE, methodClassName, methodNames[IS_PROTOCOL_SWITCH], "CommonMessage.exception", exc);
            return false;
        }

        // See if it is not the same as this host
        if (!hostaddr.equals(getLocalHost())) {
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[IS_PROTOCOL_SWITCH], "false - Host Addresses are not equal");
            }
            return false;
        }
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[IS_PROTOCOL_SWITCH], "true");
        }
        return true;
    }
747539
public static final void getActivitySessions(ActivitySessionAttribute[] asAttrs,
                                                 int type,
                                                 String[] methodNames,
                                                 Class<?>[][] methodParamTypes,
                                                 List<ActivitySessionMethod> asAttrList,
                                                 String ejbName,
                                                 boolean usesBeanManagedAS)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "getActivitySessions", (Object[])asAttrs);

        if (!usesBeanManagedAS) { // d127328

            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "Bean is CMAS");

            if (asAttrList != null) {
                if (isTraceOn && tc.isDebugEnabled())
                    Tr.debug(tc, "asAttrList non-null");

                // array to keep track of what kind of style last set the method-specific behavior
                int[] highestStyleOnMethod = new int[methodNames.length];

                // Elements of highestStyleOnMethod[] are initialized to zero by Java rules.

                // i : asAttrList loop
                // j : MethodElements loop
                // k : Method loop

                for (int i = 0; i < asAttrList.size(); ++i) {
                    ActivitySessionMethod asMethod = asAttrList.get(i);
                    ActivitySessionAttribute asAttr = asMethod.getActivitySessionAttribute();
                    @SuppressWarnings("unchecked")
                    List<com.ibm.ws.javaee.dd.ejb.Method> methodElements = asMethod.getMethodElements();
                    for (int j = 0; j < methodElements.size(); ++j) {
                        com.ibm.ws.javaee.dd.ejb.Method me = methodElements.get(j);
                        if (isTraceOn && tc.isDebugEnabled()) {
                            trace(me, me.getInterfaceTypeValue() == com.ibm.ws.javaee.dd.ejb.Method.INTERFACE_TYPE_UNSPECIFIED ?
                                            "Interface type unspecified" :
                                            "Interface type: " + me.getInterfaceTypeValue());
                        }
                        // Is this method element for the bean we are processing?
                        if ((me.getEnterpriseBeanName()).equals(ejbName)) {
                            String meName = me.getMethodName().trim();
                            int meType = me.getInterfaceTypeValue();

                            if (meName.equals("*")) {
                                if (meType == com.ibm.ws.javaee.dd.ejb.Method.INTERFACE_TYPE_UNSPECIFIED) {
                                    // style type 1 -- wildcard on all bean methods
                                    if (isTraceOn && tc.isDebugEnabled())
                                        Tr.debug(tc, "Style type 1 - all bean methods:", asAttr);
                                    for (int k = 0; k < methodNames.length; ++k) {
                                        if (highestStyleOnMethod[k] <= 1) {
                                            asAttrs[k] = asAttr;
                                            highestStyleOnMethod[k] = 1;
                                        }
                                    }

                                } else if (meType == type) { //LIDB2257.19
                                    // style type 2 -- wildcard on home or remote interface methods
                                    if (isTraceOn && tc.isDebugEnabled())
                                        Tr.debug(tc, "Style type 2 - home/remote methods only:", asAttr);
                                    for (int k = 0; k < methodNames.length; ++k) {
                                        if (highestStyleOnMethod[k] <= 2) {
                                            asAttrs[k] = asAttr;
                                            highestStyleOnMethod[k] = 2;
                                        }
                                    }
                                }
                            } else if (meType == com.ibm.ws.javaee.dd.ejb.Method.INTERFACE_TYPE_UNSPECIFIED || meType == type) { //LIDB2257.19
                                // It is not a wildcard, and either has an unspecified
                                // type, or is of the right type (Remote/Home/Local),
                                // so check for a method name match.             d123321
                                for (int k = 0; k < methodNames.length; ++k) {
                                    if (meName.equals(methodNames[k])) {
                                        List<String> meParms = me.getMethodParamList();
                                        if (meParms == null) {
                                            // style type 3 - matching method name, no signature
                                            //                specified
                                            if (isTraceOn && tc.isDebugEnabled())
                                                Tr.debug(tc, "Style type 3 - method name only:", asAttr);
                                            if (highestStyleOnMethod[k] <= 3) {
                                                asAttrs[k] = asAttr;
                                                highestStyleOnMethod[k] = 3;
                                            }
                                        } else {
                                            if (DDUtil.methodParamsMatch(meParms, methodParamTypes[k])) {
                                                // style type 4 - matching method name and signature
                                                if (isTraceOn && tc.isDebugEnabled())
                                                    Tr.debug(tc, "Style type 4 - method name and signature:", asAttr);
                                                asAttrs[k] = asAttr;
                                                highestStyleOnMethod[k] = 4;
                                            } // method parms match specified parms
                                        } // method parms were specified
                                    } // methodExtension name matches method name
                                } // method loop (k)
                            } // if/then/else for meName='*'
                        } // enterpriseBean name matches parm in methodExtension
                    } // methodElements loop (j)
                } // asAttrList loop (i)
            } // asAttrList != null

        } else if (usesBeanManagedAS) {
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "Bean is BMAS -- all methods will be set to AS_BEAN_MANAGED");
            for (int i = 0; i < asAttrs.length; i++) {
                asAttrs[i] = ActivitySessionAttribute.AS_BEAN_MANAGED;
            }
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "getActivitySessions");

        return;
    }
319980
static AbstractBeanDefinition findServerForSpecialEnvironment() {
        boolean weblogicPresent = ClassUtils.isPresent("weblogic.management.Helper",
                ServletContextAwareMBeanServerDefinitionParser.class.getClassLoader());

        boolean webspherePresent = ClassUtils.isPresent("com.ibm.websphere.management.AdminServiceFactory",
                ServletContextAwareMBeanServerDefinitionParser.class.getClassLoader());

        if (weblogicPresent) {
            RootBeanDefinition bd = new RootBeanDefinition(JndiObjectFactoryBean.class);
            bd.getPropertyValues().add("jndiName", "java:comp/env/jmx/runtime");
            return bd;
        } else if (webspherePresent) {
            return new RootBeanDefinition(WebSphereMBeanServerFactoryBean.class);
        } else {
            return null;
        }
    }
147628
private void createServantRoutingAffinity() throws BeanNotReentrantException {
        if (!ivServantRoutingAffinity && container.ivStatefulBeanEnqDeq != null) {
            StatefulSessionKey sskey = (StatefulSessionKey) beanId.getPrimaryKey();
            byte[] pKeyBytes = sskey.getBytes();

            int retcode = container.ivStatefulBeanEnqDeq.SSBeanEnq(pKeyBytes, !home.beanMetaData.sessionActivateTran, true);
            if (retcode != 0) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
                    Tr.event(tc, "Could not ENQ session bean with key = " + sskey);
                throw new BeanNotReentrantException("Could not ENQ session bean with key = " + sskey);
            }

            ivServantRoutingAffinity = true;
        }
    }
664808
@Nullable
    protected <T> BeanRegistration<T> getActiveBeanRegistration(BeanDefinition<T> beanDefinition, Qualifier qualifier) {
        if (beanDefinition == null) {
            return null;
        }
        return singletonObjects.get(new BeanKey(beanDefinition, qualifier));
    }
1137080
boolean handlePropertyHits(BackedSession d2, Thread t, int buflen) {
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[HANDLE_PROPERTY_HITS]);
        }
        boolean rc = true;

        if (buflen <= smallColSize) {
            d2.update.append(smallCol).append(equals).append(comma).append(setMediumNull).append(comma).append(setLargeNull);
        } else {
            if (buflen <= mediumColSize) {
                d2.update.append(setSmallNull).append(comma).append(medCol).append(equals).append(comma).append(setLargeNull);
            } else {
                if (buflen <= largeColSize) {
                    d2.update.append(setSmallNull).append(comma).append(setMediumNull).append(comma).append(lgCol).append(equals);
                } else {
                    rc = false;
                    LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[HANDLE_PROPERTY_HITS], "DatabaseHashMap.db2LongVarCharErr");
                }
            }
        }
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[HANDLE_PROPERTY_HITS], Boolean.valueOf(rc));
        }
        return rc;
    }
3382
private boolean checkLock(CmsResource resource) throws CmsException {

        CmsLock lock = m_cms.getLock(resource);
        return lock.isUnlocked() || lock.getUserId().equals(m_cms.getRequestContext().getCurrentUser().getId());
    }
504756
public static boolean isAllowed(ServletContext servletContext, ServletRequest request) {
		return
			Boolean.parseBoolean(servletContext.getInitParameter(ENABLE_INIT_PARAM))
			&& isAllowedAddr(request.getRemoteAddr())
		;
	}
236393
private void registerJsfCdiToSpring(BeanDefinition definition) {

		if (definition instanceof AnnotatedBeanDefinition) {
			AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;

			String scopeName = null;
			// firstly check whether bean is defined via configuration
			if (annDef.getFactoryMethodMetadata() != null) {
				scopeName = deduceScopeName(annDef.getFactoryMethodMetadata());
			}
			else {
				// fallback to type
				scopeName = deduceScopeName(annDef.getMetadata());
			}

			if (scopeName != null) {
				definition.setScope(scopeName);

				log.debug("{} - Scope({})", definition.getBeanClassName(), scopeName.toUpperCase());
			}
		}
	}
789228
private boolean isUUID(String uuid) {
        try {
            UUID.fromString(uuid);
            return true;
        } catch (Exception ex) {
            return false;
        }
    }
181634
@Override
    public boolean isPortletRenderHeaderRequested(
            IPortletWindowId portletWindowId,
            HttpServletRequest request,
            HttpServletResponse response) {
        final Map<IPortletWindowId, IPortletRenderExecutionWorker> portletRenderingMap =
                this.getPortletHeaderRenderingMap(request);
        final IPortletRenderExecutionWorker tracker = portletRenderingMap.get(portletWindowId);

        return tracker != null;
    }
497209
public void add(StatefulBeanO beanO) {
        BeanId id = beanO.beanId;
        TimeoutElement elt = beanO.ivTimeoutElement;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "add " + beanO.beanId + ", " + elt.timeout);

        // LIDB2775-23.4 Begins
        Object obj = ivStatefulBeanList.put(id, elt);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, (obj != null) ? "Stateful bean information replaced" : "Stateful bean information added");
        // LIDB2775-23.4 Ends

        synchronized (this) {
            if (numObjects == 0 && !ivIsCanceled) // F743-33394
            {
                startAlarm();
            }

            numObjects++;
            numAdds++;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "add");
    }
231458
private void lookupBeanScopeAndName(HttpServletRequest request, ServletContext servletContext)
            throws JspException
    {
        // Look up the application module configuration information we need
        _appConfig = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
        if (_appConfig == null) { // Backwards compatibility hack
            _appConfig = (ModuleConfig) servletContext.getAttribute(Globals.MODULE_KEY);
        }
        if (_appConfig == null) {
            registerTagError(Bundle.getString("Tags_FormNoApplicationConfig"), null);
            return;
        }
        _servlet = (ActionServlet) servletContext.getAttribute(Globals.ACTION_SERVLET_KEY);
        _flowController = PageFlowUtils.getCurrentPageFlow(request, pageContext.getServletContext());

        // check to see if this is a bad action
        
        PageFlowTagUtils.MappingAndController mac = PageFlowTagUtils.getActionMapping(request, _flowController, _state.action);
        if (mac == null) {
            FlowController globalApp = PageFlowUtils.getSharedFlow(InternalConstants.GLOBALAPP_CLASSNAME, request);
            mac = PageFlowTagUtils.getActionMapping(request, globalApp, _state.action);
        }
        if (mac == null) {
            registerTagError(Bundle.getString("Tags_BadAction", _state.action), null);
            return;
        }

        _flowController = mac.controller;
        _mapping = mac.mapping;
        assert (_mapping != null) : "Mapping not found for controller";
        _appConfig = _mapping.getModuleConfig();

        // Were the required values already specified?
        if (_beanName != null) {
            if (!_explicitBeanType) {
                registerTagError(Bundle.getString("Tags_FormNameNoType"), null);
                return;
            }
            if (_beanScope == null)
                _beanScope = "session";
            return;
        }

        // Look up the form bean definition
        FormBeanConfig formBeanConfig = _appConfig.findFormBeanConfig(_mapping.getName());
        if (formBeanConfig == null) {
            // clear any _beanType
            _beanType = null;
        }
        else {
            // Calculate the required values
            _beanName = _mapping.getAttribute();
            _beanScope = _mapping.getScope();
            _beanType = formBeanConfig.getType();
        }
    }
425160
public static boolean isPassivationCapableDependency(Bean<?> bean) {
        if (bean instanceof RIBean<?>) {
            return ((RIBean<?>) bean).isPassivationCapableDependency();
        }
        return bean instanceof PassivationCapable;
    }
942064
private Map<String, ComponentDto> indexExistingDtosByUuids(DbSession session) {
    return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getDbKey())
      .stream()
      .collect(Collectors.toMap(ComponentDto::uuid, Function.identity()));
  }