code
stringlengths
73
34.1k
label
stringclasses
1 value
public final void insertNullElementsAt(int index, int count) { if (tc.isEntryEnabled()) SibTr.entry( tc, "insertNullElementsAt", new Object[] { new Integer(index), new Integer(count)}); for (int i = index; i < index + count; i++) add(i, null); if (tc.isEntryEnabled()) SibTr.exit(tc, "insertNullElementsAt"); }
java
protected void validatePattern() { if (pattern.length() == 0) { throw new IllegalArgumentException(Tr.formatMessage(tc, "OPENTRACING_FILTER_PATTERN_BLANK")); } if (!regex) { try { URI.create(pattern); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(Tr.formatMessage(tc, "OPENTRACING_FILTER_PATTERN_INVALID", pattern), e); } } }
java
protected final String prepareUri(final URI uri) { if (compareRelative) { final String path = uri.getRawPath(); final String query = uri.getRawQuery(); final String fragment = uri.getRawFragment(); if (query != null && fragment != null) { return path + "?" + query + "#" + fragment; } else if (query != null) { return path + "?" + query; } else if (fragment != null) { return path + "#" + fragment; } else { return path; } } else { return uri.toString(); } }
java
public String readText(String prompt) { if (!isInputStreamAvailable()) { return null; } try { return console.readLine(prompt); } catch (IOError e) { stderr.println("Exception while reading stdin: " + e.getMessage()); e.printStackTrace(stderr); } return null; }
java
public synchronized int add(E object) { if (object == null) throw new NullPointerException("FastList add called with null"); if ((count + 1) >= maxCount) resize(capacity * 2); int initialAddIndex = addIndex; // find right spot to add to - start with addIndex and look // for first open spot. give up if we get back to initialAddIndex while (listElements[addIndex] != null) { addIndex++; if (addIndex == capacity) addIndex = 0; if (addIndex == initialAddIndex) { // should not happen - we should have resized if we needed more // capacity throw new RuntimeException("FastList out of space"); } } count++; listElements[addIndex] = object; return addIndex; }
java
public synchronized List<E> getAll() { ArrayList<E> list = new ArrayList<E>(); for (E element : listElements) { if (element != null) { list.add(element); } } return list; }
java
public Object[] addAll(CacheMap c) { LinkedList<Object> discards = new LinkedList<Object>(); Object discard; for (int bucketIndex = c.next[c.BEFORE_LRU]; bucketIndex != c.AFTER_MRU; bucketIndex = c.next[bucketIndex]) for (int i = 0; i < c.bucketSizes[bucketIndex]; i++) if ((discard = add(c.keys[bucketIndex][i], c.values[bucketIndex][i])) != null) discards.add(discard); return discards.toArray(); }
java
private Object discardFromBucket(int bucketIndex, int entryIndex) { numDiscards++; bucketSizes[bucketIndex]--; numEntries--; return values[bucketIndex][entryIndex]; }
java
int addRef() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "addRef"); int ret = NOP; // If this is a new subscription, then the operation is to subscribe. if (_refCount++ == 0) ret = SUBSCRIBE; checkRefCount(); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "addRef", String.valueOf(ret) +":"+ String.valueOf(_refCount)); return ret; }
java
int removeRef() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "removeRef"); int ret = NOP; // If this is the last reference, then the operation is unsubscribe. if (--_refCount == 0) ret = UNSUBSCRIBE; checkRefCount(); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeRef", String.valueOf(ret) +":"+ String.valueOf(_refCount)); return ret; }
java
final String getTopic() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "getTopic"); SibTr.exit(tc, "getTopic", _topic); } return _topic; }
java
final SIBUuid12 getTopicSpaceUuid() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "getTopicSpaceUuid"); SibTr.exit(tc, "getTopicSpaceUuid", _topicSpaceUuid); } return _topicSpaceUuid; }
java
final String getTopicSpaceName() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "getTopicSpaceName"); SibTr.exit(tc, "getTopicSpaceName", _topicSpaceName); } return _topicSpaceName; }
java
final String getMESubUserId() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "getMESubUserId"); SibTr.exit(tc, "getMESubUserId", _meSubUserId); } return _meSubUserId; }
java
final boolean isForeignSecuredProxy() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "isForeignSecuredProxy"); SibTr.exit(tc, "isForeignSecuredProxy", new Boolean(_foreignSecuredProxy)); } return _foreignSecuredProxy; }
java
void mark() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "mark"); SibTr.exit(tc, "mark"); } _marked = true; }
java
void unmark() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "unmark"); SibTr.exit(tc, "unmark"); } _marked = false; }
java
boolean isMarked() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "isMarked"); SibTr.exit(tc, "isMarked", new Boolean(_marked)); } return _marked; }
java
protected void registerForPostCommit(MultiMEProxyHandler proxyHandler, DestinationHandler destination, PubSubOutputHandler handler, Neighbour neighbour) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "registerForPostCommit", new Object[] { proxyHandler, destination, handler, neighbour }); _proxyHandler = proxyHandler; _destination = destination; _handler = handler; _neighbour = neighbour; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "registerForPostCommit"); }
java
protected void registerForPostCommit(Neighbour neighbour, Neighbours neighbours) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "registerForPostCommit", new Object[] { neighbour, neighbours }); _proxyHandler = null; _destination = null; _handler = null; _neighbour = neighbour; _neighbours = neighbours; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "registerForPostCommit"); }
java
public void eventPostRollbackAdd(Transaction transaction) throws SevereMessageStoreException { super.eventPostRollbackAdd(transaction); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "eventPostRollbackAdd", transaction); if (_handler != null) { _handler.removeTopic(_topic); // If this was the last topic reference, then delete the PubSub output // handler. if (_handler.getTopics()== null || _handler.getTopics().length == 0) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Deleting PubSubOutputHandler " + _handler); _destination.deletePubSubOutputHandler(_neighbour.getUUID()); } } else if (_neighbours!=null) _neighbours.removeTopicSpaceReference(_neighbour.getUUID(), this, _topicSpaceUuid, _topic); // Remove the subscription from the list. _neighbour.removeSubscription(_topicSpaceUuid, _topic); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "eventPostRollbackAdd"); }
java
public void eventPostCommitUpdate(Transaction transaction) throws SevereMessageStoreException { super.eventPostCommitAdd(transaction); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "eventPostCommitUpdate", transaction); // Remove the current CPS from the MatchSpace if (_proxyHandler != null) { _destination.getSubscriptionIndex().remove(_controllableProxySubscription); _proxyHandler .getMessageProcessor() .getMessageProcessorMatching() .removePubSubOutputHandlerMatchTarget(_controllableProxySubscription); } // Add the CPS to the MatchSpace. try { if (_proxyHandler != null) { _controllableProxySubscription = _proxyHandler .getMessageProcessor() .getMessageProcessorMatching() .addPubSubOutputHandlerMatchTarget( _handler, _topicSpaceUuid, _topic, _foreignSecuredProxy, _meSubUserId); } } catch (SIException e) { // FFDC FFDCFilter.processException( e, "com.ibm.ws.sib.processor.proxyhandler.MESubscription.eventPostCommitUpdate", "1:738:1.55", this); SibTr.exception(tc, e); SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0002", new Object[] { "com.ibm.ws.sib.processor.proxyhandler.MESubscription", "1:745:1.55", e }); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "eventPostCommitUpdate", "SIErrorException"); // An error at this point is very bad ! throw new SIErrorException(nls.getFormattedMessage( "INTERNAL_MESSAGING_ERROR_CWSIP0002", new Object[] { "com.ibm.ws.sib.processor.proxyhandler.MESubscription", "1:755:1.55", e }, null), e); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "eventPostCommitUpdate"); }
java
public void setMatchspaceSub(ControllableProxySubscription sub) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "setMatchspaceSub", sub); _controllableProxySubscription = sub; if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "setMatchspaceSub"); }
java
public ControllableProxySubscription getMatchspaceSub() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) { SibTr.entry(tc, "getMatchspaceSub"); SibTr.exit(tc, "getMatchspaceSub", _controllableProxySubscription); } return _controllableProxySubscription; }
java
public final AbstractItem findById(long itemId) throws SevereMessageStoreException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "findById", Long.valueOf(itemId)); AbstractItem item = null; ReferenceCollection ic = ((ReferenceCollection) _getMembership()); if (null == ic) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "findById"); throw new NotInMessageStore(); // Defect 489210 } item = ic.findById(itemId); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "findById", item); return item; }
java
public final ItemReference findOldestReference() throws MessageStoreException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "findOldestReference"); ReferenceCollection ic = ((ReferenceCollection) _getMembership()); if (null == ic) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "findOldestReference"); throw new NotInMessageStore(); } ItemReference item = null; if (ic != null) { item = (ItemReference) ic.findOldestItem(); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "findOldestReference", item); return item; }
java
private void publishEvent(WSJobExecution jobEx, String topicToPublish, String correlationId) { if (eventsPublisher != null) { eventsPublisher.publishJobExecutionEvent(jobEx, topicToPublish, correlationId); } }
java
private void publishEvent(WSJobInstance jobInst, String topicToPublish, String correlationId) { if (eventsPublisher != null) { eventsPublisher.publishJobInstanceEvent(jobInst, topicToPublish, correlationId); } }
java
private long restartInternal(long oldExecutionId, Properties restartParameters) throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException { if (authService != null) { authService.authorizedJobRestartByExecution(oldExecutionId); } if (logger.isLoggable(Level.FINE)) { logger.fine("JobOperator restart, with old executionId = " + oldExecutionId + "\n" + traceJobParameters(restartParameters)); } //Check if there are no job executions and step executions running. BatchStatusValidator.validateStatusAtExecutionRestart(oldExecutionId, restartParameters); //Set instance state to submitted to be consistent with start long instanceId = getPersistenceManagerService().getJobInstanceIdFromExecutionId(oldExecutionId); getPersistenceManagerService().updateJobInstanceOnRestart(instanceId, new Date()); WSJobExecution jobExecution = getPersistenceManagerService().createJobExecution(instanceId, restartParameters, new Date()); long newExecutionId = getBatchKernelService().restartJob(jobExecution.getExecutionId(), restartParameters).getKey(); if (logger.isLoggable(Level.FINE)) { logger.fine("Restarted job with new executionId: " + newExecutionId + ", and old executionID: " + oldExecutionId); } return newExecutionId; }
java
private void getMessageDigestMD5() throws AttributeNotFoundException { if (MBeans.messageDigestMD5 == null) { try { MBeans.messageDigestMD5 = MessageDigestUtility.createMessageDigest("MD5"); } catch (NoSuchAlgorithmException e) { Tr.error(tc, "DYNA1044E", new Object[] { e.getMessage() }); throw new AttributeNotFoundException("Message digest for MD5 is not available. " + e.getMessage()); } } }
java
@Override @Trivial public Map<String, ExtendedAttributeDefinition> getAttributeMap() { Map<String, ExtendedAttributeDefinition> map = null; AttributeDefinition[] attrDefs = getAttributeDefinitions(ObjectClassDefinition.ALL); if (attrDefs != null) { map = new HashMap<String, ExtendedAttributeDefinition>(); for (AttributeDefinition attrDef : attrDefs) { map.put(attrDef.getID(), new ExtendedAttributeDefinitionImpl(attrDef)); } } else { map = Collections.emptyMap(); } return map; }
java
private static String getAliasName(String alias, String bundleLocation) { String newAlias = alias; if (alias != null && !alias.isEmpty()) { try { if (bundleLocation != null && !bundleLocation.isEmpty()) { if (bundleLocation.startsWith(XMLConfigConstants.BUNDLE_LOC_KERNEL_TAG)) { // nothing to do. The alias is returned. } else if (bundleLocation.startsWith(XMLConfigConstants.BUNDLE_LOC_FEATURE_TAG)) { // Check for the presence of a product extension location. int index = bundleLocation.indexOf(XMLConfigConstants.BUNDLE_LOC_PROD_EXT_TAG); if (index != -1) { index += XMLConfigConstants.BUNDLE_LOC_PROD_EXT_TAG.length(); int endIndex = bundleLocation.indexOf(":", index); String productName = bundleLocation.substring(index, endIndex); newAlias = productName + "_" + alias; } } else if (bundleLocation.startsWith(XMLConfigConstants.BUNDLE_LOC_CONNECTOR_TAG)) { // nothing to do. The alias is returned. } else { // Unknown location. Ignore the alias. If bundles are installed through fileInstall, // bundle resolution should happen through the pid or factoryPid. newAlias = null; } } } catch (Throwable t) { // An exception here would be bad. Need an ffdc. } } return newAlias; }
java
@Trivial private static byte[] getBytes(InputStream stream, int knownSize) throws IOException { try { if (knownSize == -1) { ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); try { byte[] bytes = new byte[1024]; int read; while (0 <= (read = stream.read(bytes))) byteOut.write(bytes, 0, read); return byteOut.toByteArray(); } finally { Util.tryToClose(byteOut); } } else { byte[] bytes = new byte[knownSize]; int read; int offset = 0; while (knownSize > 0 && (read = stream.read(bytes, offset, knownSize)) > 0) { offset += read; knownSize -= read; } return bytes; } } finally { Util.tryToClose(stream); } }
java
static URL getSharedClassCacheURL(URL resourceURL, String resourceName) { URL sharedClassCacheURL; if (resourceURL == null) { sharedClassCacheURL = null; } else { String protocol = resourceURL.getProtocol(); if ("jar".equals(protocol)) { sharedClassCacheURL = resourceURL; } else if ("wsjar".equals(protocol)) { try { sharedClassCacheURL = new URL(resourceURL.toExternalForm().substring(2)); } catch (MalformedURLException e) { sharedClassCacheURL = null; } } else if (!"file".equals(protocol)) { sharedClassCacheURL = null; } else { String externalForm = resourceURL.toExternalForm(); if (externalForm.endsWith(resourceName)) { try { sharedClassCacheURL = new URL(externalForm.substring(0, externalForm.length() - resourceName.length())); } catch (MalformedURLException e) { sharedClassCacheURL = null; } } else { sharedClassCacheURL = null; } } } return sharedClassCacheURL; }
java
public Package definePackage(String name, Manifest manifest, URL sealBase) throws IllegalArgumentException { Attributes mA = manifest.getMainAttributes(); String specTitle = mA.getValue(Name.SPECIFICATION_TITLE); String specVersion = mA.getValue(Name.SPECIFICATION_VERSION); String specVendor = mA.getValue(Name.SPECIFICATION_VENDOR); String implTitle = mA.getValue(Name.IMPLEMENTATION_TITLE); String implVersion = mA.getValue(Name.IMPLEMENTATION_VERSION); String implVendor = mA.getValue(Name.IMPLEMENTATION_VENDOR); String sealedString = mA.getValue(Name.SEALED); Boolean sealed = (sealedString == null ? Boolean.FALSE : sealedString.equalsIgnoreCase("true")); //now overwrite global attributes with the specific attributes String unixName = name.replaceAll("\\.", "/") + "/"; //replace all dots with slash and add trailing slash mA = manifest.getAttributes(unixName); if (mA != null) { String s = mA.getValue(Name.SPECIFICATION_TITLE); if (s != null) specTitle = s; s = mA.getValue(Name.SPECIFICATION_VERSION); if (s != null) specVersion = s; s = mA.getValue(Name.SPECIFICATION_VENDOR); if (s != null) specVendor = s; s = mA.getValue(Name.IMPLEMENTATION_TITLE); if (s != null) implTitle = s; s = mA.getValue(Name.IMPLEMENTATION_VERSION); if (s != null) implVersion = s; s = mA.getValue(Name.IMPLEMENTATION_VENDOR); if (s != null) implVendor = s; s = mA.getValue(Name.SEALED); if (s != null) sealed = s.equalsIgnoreCase("true"); } if (!sealed) sealBase = null; return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); }
java
protected void addToClassPath(Iterable<ArtifactContainer> artifacts) { for (ArtifactContainer art : artifacts) { smartClassPath.addArtifactContainer(art); } }
java
@FFDCIgnore(NullPointerException.class) protected void addLibraryFile(File f) { if (!!!f.exists()) { if (tc.isWarningEnabled()) { Tr.warning(tc, "cls.library.archive", f, new FileNotFoundException(f.getName())); } return; } // Skip files that are not archives of some sort. if (!f.isDirectory() && !isArchive(f)) return; //this area subject to refactor following shared lib rework.. //ideally the shared lib code will start passing us ArtifactContainers, and it //will own the management of the ACF via DS. //NASTY.. need to use DS to get the ACF, not OSGi backdoor ;p BundleContext bc = FrameworkUtil.getBundle(ContainerClassLoader.class).getBundleContext(); ServiceReference<ArtifactContainerFactory> acfsr = bc.getServiceReference(ArtifactContainerFactory.class); if (acfsr != null) { ArtifactContainerFactory acf = bc.getService(acfsr); if (acf != null) { //NASTY.. using this bundle as the cache dir location for the data file.. try { ArtifactContainer ac = acf.getContainer(bc.getBundle().getDataFile(""), f); smartClassPath.addArtifactContainer(ac); } catch (NullPointerException e) { // TODO completed under task 74097 if (tc.isDebugEnabled()) { Tr.debug(tc, "Exception while adding files to classpath", e); } if (tc.isInfoEnabled()) { Tr.info(tc, "cls.library.file.forbidden", f); } } } } }
java
@FFDCIgnore(PrivilegedActionException.class) private boolean isArchive(File f) { final File target = f; try { AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { @Override public Void run() throws IOException { new ZipFile(target).close(); return null; } }); } catch (PrivilegedActionException e) { Exception innerException = e.getException(); if (tc.isDebugEnabled()) { Tr.debug(tc, "The following file can not be added to the classpath " + f + " due to error ", innerException); } return false; } return true; }
java
public static ComponentMetaData getComponentMetaData(JavaColonNamespace namespace, String name) throws NamingException { ComponentMetaData cmd = ComponentMetaDataAccessorImpl.getComponentMetaDataAccessor().getComponentMetaData(); if (cmd == null) { String fullName = name.isEmpty() ? namespace.toString() : namespace + "/" + name; String msg = Tr.formatMessage(tc, "JNDI_NON_JEE_THREAD_CWWKN0100E", fullName); NamingException nex = new NamingException(msg); throw nex; } return cmd; }
java
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE) protected Map<String, Object> setConfiguration(ServiceReference<SecurityConfiguration> ref) { String id = (String) ref.getProperty(KEY_ID); if (id != null) { configs.putReference(id, ref); } else { Tr.error(tc, "SECURITY_SERVICE_REQUIRED_SERVICE_WITHOUT_ID", "securityConfiguration"); } return getServiceProperties(); }
java
protected Map<String, Object> unsetConfiguration(ServiceReference<SecurityConfiguration> ref) { configs.removeReference((String) ref.getProperty(KEY_ID), ref); return getServiceProperties(); }
java
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE) protected Map<String, Object> setAuthentication(ServiceReference<AuthenticationService> ref) { if (hasPropertiesFromFile(ref)) { String id = (String) ref.getProperty(KEY_ID); if (id != null) { authentication.putReference(id, ref); } else { Tr.error(tc, "SECURITY_SERVICE_REQUIRED_SERVICE_WITHOUT_ID", KEY_AUTHENTICATION); } } else { authentication.putReference(String.valueOf(ref.getProperty(KEY_SERVICE_ID)), ref); } // determine a new authentication service authnService.set(null); return getServiceProperties(); }
java
protected Map<String, Object> unsetAuthentication(ServiceReference<AuthenticationService> ref) { authentication.removeReference((String) ref.getProperty(KEY_ID), ref); authentication.removeReference(String.valueOf(ref.getProperty(KEY_SERVICE_ID)), ref); // determine a new authentication service authnService.set(null); return getServiceProperties(); }
java
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE) protected Map<String, Object> setAuthorization(ServiceReference<AuthorizationService> ref) { if (hasPropertiesFromFile(ref)) { String id = (String) ref.getProperty(KEY_ID); if (id != null) { authorization.putReference(id, ref); } else { Tr.error(tc, "SECURITY_SERVICE_REQUIRED_SERVICE_WITHOUT_ID", KEY_AUTHORIZATION); } } else { authorization.putReference(String.valueOf(ref.getProperty(KEY_SERVICE_ID)), ref); } // determine a new authorization service authzService.set(null); return getServiceProperties(); }
java
protected Map<String, Object> unsetAuthorization(ServiceReference<AuthorizationService> ref) { authorization.removeReference((String) ref.getProperty(KEY_ID), ref); authorization.removeReference(String.valueOf(ref.getProperty(KEY_SERVICE_ID)), ref); // determine a new authorization service authzService.set(null); return getServiceProperties(); }
java
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE, target = "(config.displayId=*)") protected Map<String, Object> setUserRegistry(ServiceReference<UserRegistryService> ref) { adjustUserRegistryServiceRef(ref); // determine a new user registry service userRegistryService.set(null); return getServiceProperties(); }
java
protected Map<String, Object> unsetUserRegistry(ServiceReference<UserRegistryService> ref) { userRegistry.removeReference((String) ref.getProperty(KEY_ID), ref); userRegistry.removeReference(String.valueOf(ref.getProperty(KEY_SERVICE_ID)), ref); // determine a new user registry service userRegistryService.set(null); return getServiceProperties(); }
java
private SecurityConfiguration getEffectiveSecurityConfiguration() { SecurityConfiguration effectiveConfig = configs.getService(cfgSystemDomain); if (effectiveConfig == null) { Tr.error(tc, "SECURITY_SERVICE_ERROR_BAD_DOMAIN", cfgSystemDomain, CFG_KEY_SYSTEM_DOMAIN); throw new IllegalArgumentException(Tr.formatMessage(tc, "SECURITY_SERVICE_ERROR_BAD_DOMAIN", cfgSystemDomain, CFG_KEY_SYSTEM_DOMAIN)); } return effectiveConfig; }
java
private <V> V autoDetectService(String serviceName, ConcurrentServiceReferenceMap<String, V> map) { Iterator<V> services = map.getServices(); if (services.hasNext() == false) { Tr.error(tc, "SECURITY_SERVICE_NO_SERVICE_AVAILABLE", serviceName); throw new IllegalStateException(Tr.formatMessage(tc, "SECURITY_SERVICE_NO_SERVICE_AVAILABLE", serviceName)); } V service = services.next(); if (services.hasNext()) { Tr.error(tc, "SECURITY_SERVICE_MULTIPLE_SERVICE_AVAILABLE", serviceName); throw new IllegalStateException(Tr.formatMessage(tc, "SECURITY_SERVICE_MULTIPLE_SERVICE_AVAILABLE", serviceName)); } return service; }
java
private AuthenticationService getAuthenticationService(String id) { AuthenticationService service = authentication.getService(id); if (service == null) { throwIllegalArgumentExceptionInvalidAttributeValue(SecurityConfiguration.CFG_KEY_AUTHENTICATION_REF, id); } return service; }
java
private AuthorizationService getAuthorizationService(String id) { AuthorizationService service = authorization.getService(id); if (service == null) { throwIllegalArgumentExceptionInvalidAttributeValue(SecurityConfiguration.CFG_KEY_AUTHORIZATION_REF, id); } return service; }
java
private UserRegistryService getUserRegistryService(String id) { UserRegistryService service = userRegistry.getService(id); if (service == null) { throwIllegalArgumentExceptionInvalidAttributeValue(SecurityConfiguration.CFG_KEY_USERREGISTRY_REF, id); } return service; }
java
protected final String getFacetName(FaceletContext ctx, UIComponent parent) { // TODO: REFACTOR - "facelets.FACET_NAME" should be a constant somewhere, used to be in FacetHandler // from real Facelets return (String) parent.getAttributes().get("facelets.FACET_NAME"); }
java
public void completeTxTimeout() throws TransactionRolledbackException { final boolean traceOn = TraceComponent.isAnyTracingEnabled(); if (traceOn && tc.isEntryEnabled()) Tr.entry(tc, "completeTxTimeout"); if (tx != null && tx.isTimedOut()) { if (traceOn && tc.isEventEnabled()) Tr.event(tc, "Transaction has timed out. The transaction will be rolled back now"); Tr.info(tc, "WTRN0041_TXN_ROLLED_BACK", tx.getTranName()); ((EmbeddableTransactionImpl) tx).rollbackResources(); final TransactionRolledbackException rbe = new TransactionRolledbackException("Transaction is ended due to timeout"); FFDCFilter.processException(rbe, "com.ibm.tx.jta.embeddable.impl.EmbeddableTranManagerImpl.completeTxTimeout", "100", this); if (traceOn && tc.isEntryEnabled()) Tr.exit(tc, "completeTxTimeout", rbe); throw rbe; } if (traceOn && tc.isEntryEnabled()) Tr.exit(tc, "completeTxTimeout"); }
java
public void addConsumer(DispatchableConsumerPoint lcp) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "addConsumer", lcp); // WARNING: We mustn't hold the LCP lock of the consumer at this point synchronized(consumerList) { consumerList.add(lcp); } if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "addConsumer"); }
java
public void removeConsumer(DispatchableConsumerPoint lcp) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "removeConsumer", lcp); // WARNING: We mustn't hold the LCP lock of the consumer at this point synchronized(consumerList) { consumerList.remove(lcp); } if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "removeConsumer"); }
java
public int getGetCursorIndex(SIMPMessage msg) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getGetCursorIndex"); // The zeroth index is reserved for non-classified messages int classPos = 0; synchronized(classifications) { if(classifications.getNumberOfClasses()>0) { // Need to get the classification out of the message String keyClassification = msg.getMessageControlClassification(true); // In the special case where the weighting for the classification in the // message was zero, we use the Default cursor if(keyClassification != null && classifications.getWeight(keyClassification) > 0) // Get the position of the classification classPos = classifications.getPosition(keyClassification); } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getGetCursorIndex", classPos); return classPos; }
java
public synchronized int chooseGetCursorIndex(int previous) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "chooseGetCursorIndex", new Object[] {Integer.valueOf(previous)}); // The zeroth index represents the default cursor for non-classified messages. int classPos = 0; if(classifications.getNumberOfClasses()>0) { // Need to determine the class of message to process if(previous == -1) { // First time through, get the initial weightings table weightMap = classifications.getWeightings(); } else { // Need to remove previous entries from the weightMap weightMap.remove(Integer.valueOf(previous)); } if(!weightMap.isEmpty()) { classPos = classifications.findClassIndex(weightMap); } // eof non-empty weightmap else if(unitTestOperation) { // In a production environment we'd return zero in this case so that the // default cursor would be used. In a Unit test environment, where we are // classifying messages and where we have configured the test so that a // cursor associated with a specific classification should be used then // we'll alert the test to an error by throwing this exception. if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "chooseGetCursorIndex", "SIErrorException"); throw new SIErrorException(); } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "chooseGetCursorIndex", classPos); return classPos; }
java
public JSConsumerClassifications getClassifications() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "getClassifications"); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "getClassifications", classifications); // TODO No synchronization? return classifications; }
java
public boolean prepareAddActiveMessage() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this,tc, "prepareAddActiveMessage"); boolean messageAccepted = false; boolean limitReached = false; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "maxActiveMessagePrepareReadLock.lock(): " + maxActiveMessagePrepareLock); // Add us as a reader - this will block if a writer currently holds the lock. maxActiveMessagePrepareReadLock.lock(); // Lock the actual message counters - to prevent other 'readers' concurrently making // changes. synchronized(maxActiveMessageLock) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Active Messages: current: " + currentActiveMessages + ", prepared: " + preparedActiveMessages + ", maximum: " + maxActiveMessages + " (suspended: " + consumerSetSuspended + ")"); // If we're already suspended we'll simply unlock the prepare and reject the message, // causing the consumer to suspend itself. // Otherwise, we need to check the current number of active messages... if(!consumerSetSuspended) { // If adding this message would cause us to reach the limit then we need to // drop out of this synchronize and re-take the prepare lock as a write lock. if((currentActiveMessages + preparedActiveMessages) == (maxActiveMessages - 1)) { limitReached = true; } // Otherwise, we're safe to accept the message and add this message to the // prepare counter else { preparedActiveMessages++; messageAccepted = true; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Prepare added"); } } // If the message hasn't been accepted yet (because we're suspended or we // have to take the write lock) then release the read lock if(!messageAccepted) { maxActiveMessagePrepareReadLock.unlock(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "maxActiveMessagePrepareReadLock.unlock(): " + maxActiveMessagePrepareLock); } } // synchronize // If this message would cause us to reach the limit then we must take the write // lock to prevent others preparing messages while we're in the middle of this // threashold-case. We also need to block until any existing prepares complete to // ensure that we really are on the brink of suspending the set if(limitReached) { boolean releaseWriteLock = true; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "maxActiveMessagePrepareWriteLock.lock(): " + maxActiveMessagePrepareLock); // Take the write lock and hold it until the commit/rollback maxActiveMessagePrepareWriteLock.lock(); // Re-take the active message counter lock synchronized(maxActiveMessageLock) { // We could have been suspended between us releasing the locks above // and re-taking them here, if that's the case we simply release the // write lock and reject the message add. if(!consumerSetSuspended) { // We're not suspended yet so accept this message and add the prepared // message messageAccepted = true; preparedActiveMessages++; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Prepare added"); // If we're still in the position where committing this add would make // us hit the limit then we need to hold onto the write lock until the // commit/rollback. if((currentActiveMessages + preparedActiveMessages) == maxActiveMessages) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Write lock held until commit/rollback"); releaseWriteLock = false; } // Otherwise, someone must have got in while we'd released the locks and // removed one or more of the active messages. In which case this add won't // make us hit the limit so we downgrade the prepare lock to a read and release // the write lock once we've done it. else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "maxActiveMessagePrepareReadLock.lock(): " + maxActiveMessagePrepareLock); maxActiveMessagePrepareReadLock.lock(); } } // If we were told to release the write lock do it now. if(releaseWriteLock) { maxActiveMessagePrepareWriteLock.unlock(); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "maxActiveMessagePrepareWriteLock.unlock(): " + maxActiveMessagePrepareLock); } } } if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "prepareAddActiveMessage", Boolean.valueOf(messageAccepted)); return messageAccepted; }
java
public void takeClassificationReadLock() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "takeClassificationReadLock"); classificationReadLock.lock(); if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "takeClassificationReadLock"); }
java
public void freeClassificationReadLock() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "freeClassificationReadLock"); classificationReadLock.unlock(); if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "freeClassificationReadLock"); }
java
public void registerSynchronization(Synchronization s) throws CPIException { try { ivContainer.uowCtrl.enlistWithSession(s); // enlistSession(s) } catch (CSIException e) { throw new CPIException(e.toString()); } }
java
private EJBKey[] getEJBKeys(BeanO[] beans) { EJBKey result[] = null; if (beans != null) { result = new EJBKey[beans.length]; for (int i = 0; i < beans.length; ++i) { result[i] = beans[i].getId(); } } return result; }
java
private BeanO[] getBeanOs() { BeanO result[]; result = new BeanO[ivBeanOs.size()]; Iterator<BeanO> iter = ivBeanOs.values().iterator(); int i = 0; while (iter.hasNext()) { result[i++] = iter.next(); } return result; }
java
@Override public void scanClasses( ClassSource_Streamer streamer, Set<String> i_seedClassNamesSet, ScanPolicy scanPolicy) { throw new UnsupportedOperationException(); }
java
public List<com.ibm.wsspi.security.wim.model.PartyRole> getPartyRoles() { if (partyRoles == null) { partyRoles = new ArrayList<com.ibm.wsspi.security.wim.model.PartyRole>(); } return this.partyRoles; }
java
public JSchema getExpectedSchema(Map context) { if (expectedSchema != null) return expectedSchema; if (expectedType == null) return null; expectedSchema = (JSchema)context.get(expectedType); if (expectedSchema != null) return expectedSchema; expectedSchema = new JSchema(expectedType, context); return expectedSchema; }
java
@Override public void taskStarting() { final boolean trace = TraceComponent.isAnyTracingEnabled(); prevInvocationSubject = subjectManager.getInvocationSubject(); prevCallerSubject = subjectManager.getCallerSubject(); if (trace && tc.isEntryEnabled()) Tr.entry(this, tc, "taskStarting", "previous caller/invocation subjects", prevCallerSubject, prevInvocationSubject); subjectManager.setInvocationSubject(invocationSubject); subjectManager.setCallerSubject(callerSubject); if (trace && tc.isEntryEnabled()) Tr.exit(this, tc, "taskStarting", new Object[] { "new caller/invocation subjects", callerSubject, invocationSubject }); }
java
@Override public void taskStopping() { final boolean trace = TraceComponent.isAnyTracingEnabled(); if (trace && tc.isEntryEnabled()) Tr.entry(this, tc, "taskStopping", "restore caller/invocation subjects", prevCallerSubject, prevInvocationSubject); subjectManager.setCallerSubject(prevCallerSubject); subjectManager.setInvocationSubject(prevInvocationSubject); if (trace && tc.isEntryEnabled()) Tr.exit(this, tc, "taskStopping"); }
java
private void readState(GetField fields) throws IOException { //get caller principal callerPrincipal = (WSPrincipal) fields.get(CALLER_PRINCIPAL, null); //get boolean marking if subjects are equal subjectsAreEqual = fields.get(SUBJECTS_ARE_EQUAL, false); //only deserialize invocation principal if it's different from the caller if (!subjectsAreEqual) { //get invocation principal invocationPrincipal = (WSPrincipal) fields.get(INVOCATION_PRINCIPAL, null); } else { invocationPrincipal = callerPrincipal; } jaasLoginContextEntry = (String) fields.get(JAAS_LOGIN_CONTEXT, null); callerSubjectCacheKey = (String) fields.get(CALLER_SUBJECT_CACHE_KEY, null); invocationSubjectCacheKey = (String) fields.get(INVOCATION_SUBJECT_CACHE_KEY, null); }
java
@FFDCIgnore(AuthenticationException.class) protected Subject recreateFullSubject(WSPrincipal wsPrincipal, SecurityService securityService, AtomicServiceReference<UnauthenticatedSubjectService> unauthenticatedSubjectServiceRef, String customCacheKey) { Subject subject = null; if (wsPrincipal != null) { String userName = wsPrincipal.getName(); AuthenticateUserHelper authHelper = new AuthenticateUserHelper(); if (jaasLoginContextEntry == null) { jaasLoginContextEntry = DESERIALIZE_LOGINCONTEXT_DEFAULT; } try { subject = authHelper.authenticateUser(securityService.getAuthenticationService(), userName, jaasLoginContextEntry, customCacheKey); } catch (AuthenticationException e) { Tr.error(tc, "SEC_CONTEXT_DESERIALIZE_AUTHN_ERROR", new Object[] { e.getLocalizedMessage() }); } } if (subject == null) { subject = unauthenticatedSubjectServiceRef.getService().getUnauthenticatedSubject(); } return subject; }
java
protected WSPrincipal getWSPrincipal(Subject subject) throws IOException { WSPrincipal wsPrincipal = null; Set<WSPrincipal> principals = (subject != null) ? subject.getPrincipals(WSPrincipal.class) : null; if (principals != null && !principals.isEmpty()) { if (principals.size() > 1) { // Error - too many principals String principalNames = null; for (WSPrincipal principal : principals) { if (principalNames == null) principalNames = principal.getName(); else principalNames = principalNames + ", " + principal.getName(); } throw new IOException(Tr.formatMessage(tc, "SEC_CONTEXT_DESERIALIZE_TOO_MANY_PRINCIPALS", principalNames)); } else { wsPrincipal = principals.iterator().next(); } } return wsPrincipal; }
java
private void serializeSubjectCacheKey(PutField fields) throws Exception { if (callerSubject != null) { Hashtable<String, ?> hashtable = subjectHelper.getHashtableFromSubject(callerSubject, new String[] { AttributeNameConstants.WSCREDENTIAL_CACHE_KEY }); if (hashtable != null) { callerSubjectCacheKey = (String) hashtable.get(AttributeNameConstants.WSCREDENTIAL_CACHE_KEY); /* * 12/08/14 RZ: Removed after discussions with Ajay and Ut. This is an unwanted functionality. * * if (callerSubjectCacheKey != null && authCache != null) { * Subject lookedUpSubject = authCache.getSubject(callerSubjectCacheKey); * * // If we looked up the wrong subject, then create a BasicAuthCacheKey * if (!lookedUpSubject.equals(callerSubject)) { * hashtable = subjectHelper.getHashtableFromSubject(callerSubject, new String[] { AttributeNameConstants.WSCREDENTIAL_USERID, * AttributeNameConstants.WSCREDENTIAL_PASSWORD }); * * if (hashtable != null) { * String userid = (String) hashtable.get(AttributeNameConstants.WSCREDENTIAL_USERID); * String password = (String) hashtable.get(AttributeNameConstants.WSCREDENTIAL_PASSWORD); * * if (password != null) { * callerSubjectCacheKey = BasicAuthCacheKeyProvider.createLookupKey(subjectHelper.getRealm(callerSubject), userid, password); * } else { * callerSubjectCacheKey = BasicAuthCacheKeyProvider.createLookupKey(subjectHelper.getRealm(callerSubject), userid); * } * } * } * } */ } } if (callerSubjectCacheKey != null) fields.put(CALLER_SUBJECT_CACHE_KEY, callerSubjectCacheKey); //only serialize invocation subject if it's different from the caller if (!subjectsAreEqual) { if (invocationSubject != null) { Hashtable<String, ?> hashtable = subjectHelper.getHashtableFromSubject(invocationSubject, new String[] { AttributeNameConstants.WSCREDENTIAL_CACHE_KEY }); if (hashtable != null) { invocationSubjectCacheKey = (String) hashtable.get(AttributeNameConstants.WSCREDENTIAL_CACHE_KEY); /* * 12/08/14 RZ: Removed after discussions with Ajay and Ut. This is an unwanted functionality. * * if (invocationSubjectCacheKey != null && authCache != null) { * Subject lookedUpSubject = authCache.getSubject(invocationSubjectCacheKey); * * // If we looked up the wrong subject, then create a BasicAuthCacheKey * if (!lookedUpSubject.equals(invocationSubject)) { * hashtable = subjectHelper.getHashtableFromSubject(invocationSubject, new String[] { AttributeNameConstants.WSCREDENTIAL_USERID, * AttributeNameConstants.WSCREDENTIAL_PASSWORD }); * * if (hashtable != null) { * String userid = (String) hashtable.get(AttributeNameConstants.WSCREDENTIAL_USERID); * String password = (String) hashtable.get(AttributeNameConstants.WSCREDENTIAL_PASSWORD); * * if (password != null) { * invocationSubjectCacheKey = BasicAuthCacheKeyProvider.createLookupKey(subjectHelper.getRealm(invocationSubject), userid, password); * } else { * invocationSubjectCacheKey = BasicAuthCacheKeyProvider.createLookupKey(subjectHelper.getRealm(invocationSubject), userid); * } * } * } * } */ } } } if (invocationSubjectCacheKey != null) fields.put(INVOCATION_SUBJECT_CACHE_KEY, invocationSubjectCacheKey); }
java
public void clear() throws IOException { if (writer != null) { throw new IOException(); } else { nextChar = 0; if (limitBuffer && (strBuffer.length() > this.bodyContentBuffSize)){ //PK95332 - starts if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINE)){ logger.logp(Level.FINE, CLASS_NAME, "BodyContentImpl", "clear buffer, create new one with buffer size ["+ this.bodyContentBuffSize +"]"); } strBuffer = new StringBuffer(this.bodyContentBuffSize); } else if (strBuffer != null) { // PI24001 //PK95332 - ends strBuffer.setLength(0); // PK33136 } //PK95332 } }
java
public void writeOut(Writer out) throws IOException { if (writer == null) { out.write(strBuffer.toString()); // PK33136 // Flush not called as the writer passed could be a BodyContent and // it doesn't allow to flush. } }
java
void setWriter(Writer writer) { // PM12137 - starts if (closed) { if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINE)){ logger.logp(Level.FINE, CLASS_NAME, "setWriter", "resetting closed to false for this=["+this+"]"); } closed = false; strBuffer = new StringBuffer(this.bodyContentBuffSize); } // PM12137 - ends this.writer = writer; if (writer != null) { // According to the spec, the JspWriter returned by // JspContext.pushBody(java.io.Writer writer) must behave as // though it were unbuffered. This means that its getBufferSize() // must always return 0. The implementation of // JspWriter.getBufferSize() returns the value of JspWriter's // 'bufferSize' field, which is inherited by this class. // Therefore, we simply save the current 'bufferSize' (so we can // later restore it should this BodyContentImpl ever be reused by // a call to PageContext.pushBody()) before setting it to 0. if (bufferSize != 0) { if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINE)){ logger.logp(Level.FINE, CLASS_NAME, "setWriter", "BodyContentImpl setWriter A. bufferSize=["+bufferSize+"] this=["+this+"]"); } bufferSizeSave = bufferSize; bufferSize = 0; } } else { bufferSize = bufferSizeSave; if(com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINE)){ logger.logp(Level.FINE, CLASS_NAME, "setWriter", "BodyContentImpl setWriter B. bufferSize=["+bufferSize+"] this=["+this+"]"); } clearBody(); } }
java
@Trivial public final Map<String, String> getExecutionProperties() { TreeMap<String, String> copy = null; if (internalPropNames != null) { copy = new TreeMap<String, String>(threadContextDescriptor.getExecutionProperties()); for (String name : internalPropNames) copy.remove(name); } return copy; }
java
public TimerWorkItem createTimeoutRequest(long timeoutTime, TimerCallback _callback, IAbstractAsyncFuture _future) { TimerWorkItem wi = new TimerWorkItem(timeoutTime, _callback, _future, _future.getReuseCount()); _future.setTimeoutWorkItem(wi); // put this to the Timer's work queue. Use the queue that the Timer // thread is not using. if ((this.queueToUse == 1) || (numQueues == 1)) { synchronized (this.requestQueue1) { // add the request to the Timer work queue this.requestQueue1.add(wi); } } else { synchronized (this.requestQueue2) { // add the request to the Timer work queue this.requestQueue2.add(wi); } } return wi; }
java
public void timeSlotPruning(long curTime) { // if a bucket has not been accessed in a while, and it only has // dead entries then get rid of it TimeSlot slotEntry = this.firstSlot; TimeSlot nextSlot = null; int endIndex = 0; int i; while (slotEntry != null) { nextSlot = slotEntry.nextEntry; if (curTime - slotEntry.mostRecentlyAccessedTime > TIMESLOT_PRUNING_THRESHOLD) { endIndex = slotEntry.lastEntryIndex; // entries added last are more likely to be active, so // go from last to first for (i = endIndex; i >= 0; i--) { if (slotEntry.entries[i].state == TimerWorkItem.ENTRY_ACTIVE) { break; } } if (i < 0) { // no entries are active removeSlot(slotEntry); } } slotEntry = nextSlot; } }
java
public void insertWorkItem(TimerWorkItem work, long curTime) { // find the time slot, or create a new one long insertTime = work.timeoutTime; TimeSlot nextSlot = this.firstSlot; while (nextSlot != null) { if ((insertTime == nextSlot.timeoutTime) && (nextSlot.lastEntryIndex != TimeSlot.TIMESLOT_LAST_ENTRY)) { nextSlot.addEntry(work, curTime); break; } else if (insertTime < nextSlot.timeoutTime) { nextSlot = insertSlot(insertTime, nextSlot); nextSlot.addEntry(work, curTime); break; } else { nextSlot = nextSlot.nextEntry; } } if (nextSlot == null) { nextSlot = insertSlotAtEnd(insertTime); nextSlot.addEntry(work, curTime); } }
java
public TimeSlot insertSlot(long newSlotTimeout, TimeSlot slot) { // this routine assumes the list is not empty TimeSlot retSlot = new TimeSlot(newSlotTimeout); retSlot.nextEntry = slot; retSlot.prevEntry = slot.prevEntry; if (retSlot.prevEntry != null) { retSlot.prevEntry.nextEntry = retSlot; } else { // no prev, so this is now the first slot this.firstSlot = retSlot; } slot.prevEntry = retSlot; return retSlot; }
java
public TimeSlot insertSlotAtEnd(long newSlotTimeout) { // this routine assumes that list could be empty TimeSlot retSlot = new TimeSlot(newSlotTimeout); if (this.lastSlot == null) { // list was empty this.lastSlot = retSlot; this.firstSlot = retSlot; } else { retSlot.prevEntry = this.lastSlot; this.lastSlot.nextEntry = retSlot; this.lastSlot = retSlot; } return retSlot; }
java
public void removeSlot(TimeSlot oldSlot) { if (oldSlot.nextEntry != null) { oldSlot.nextEntry.prevEntry = oldSlot.prevEntry; } else { // old slot was tail. this.lastSlot = oldSlot.prevEntry; } if (oldSlot.prevEntry != null) { oldSlot.prevEntry.nextEntry = oldSlot.nextEntry; } else { // oldSlot was head. this.firstSlot = oldSlot.nextEntry; } }
java
public void checkForTimeouts(long checkTime) { TimeSlot nextSlot = this.firstSlot; TimerWorkItem entry = null; TimeSlot oldSlot = null; while (nextSlot != null && checkTime >= nextSlot.timeoutTime) { // Timeout all entries here int endIndex = nextSlot.lastEntryIndex; for (int i = 0; i <= endIndex; i++) { // invoke callback if not already cancelled entry = nextSlot.entries[i]; if (entry.state == TimerWorkItem.ENTRY_ACTIVE) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "Found a timeout, calling timerTriggered"); } entry.state = TimerWorkItem.ENTRY_CANCELLED; entry.callback.timerTriggered(entry); } } // since we timed out all slot entries, remove it oldSlot = nextSlot; removeSlot(oldSlot); nextSlot = nextSlot.nextEntry; } }
java
public static List<String> getMatchingFileNames(String root, String filterExpr, boolean fullPath) { List<File> fileList = getMatchingFiles(root, filterExpr); List<String> list = new ArrayList<String>(fileList.size()); for (File f : fileList) { if (fullPath) list.add(f.getAbsolutePath()); else list.add(f.getName()); } return list; }
java
public PartnerLogData getEntry(int index) { if (tc.isEntryEnabled()) Tr.entry(tc, "getEntry", index); _pltReadLock.lock(); try { final PartnerLogData entry = _partnerLogTable.get(index - 1); if (tc.isEntryEnabled()) Tr.exit(tc, "getEntry", entry); return entry; } catch (IndexOutOfBoundsException ioobe) { // The index was invalid; return null. FFDCFilter.processException(ioobe, "com.ibm.ws.Transaction.JTA.PartnerLogTable.getEntry", "122", this); } finally { _pltReadLock.unlock(); } if (tc.isEntryEnabled()) Tr.exit(tc, "getEntry", null); return null; }
java
public void addEntry(PartnerLogData logData) { if (tc.isEntryEnabled()) Tr.entry(tc, "addEntry", logData); _pltWriteLock.lock(); try { addPartnerEntry(logData); } finally { _pltWriteLock.unlock(); } if (tc.isEntryEnabled()) Tr.exit(tc, "addEntry"); }
java
public PartnerLogData findEntry(RecoveryWrapper rw) { if (tc.isEntryEnabled()) Tr.entry(tc, "findEntry", rw); PartnerLogData entry; _pltWriteLock.lock(); try { // Search the partner log table... for (PartnerLogData pld : _partnerLogTable) { final RecoveryWrapper nextWrapper = pld.getLogData(); if (rw.isSameAs(nextWrapper)) { if (tc.isDebugEnabled()) Tr.debug(tc, "Found entry in table"); if (tc.isEntryEnabled()) Tr.exit(tc, "findEntry", pld.getIndex()); return pld; } } // // We have never seen this wrapper before, // so we need to add it to the recoveryTable // entry = rw.container(_failureScopeController); addPartnerEntry(entry); } finally { _pltWriteLock.unlock(); } if (tc.isEntryEnabled()) Tr.exit(tc, "findEntry", entry); return entry; }
java
public void clearUnused() { if (tc.isEntryEnabled()) Tr.entry(tc, "clearUnused"); final RecoveryLog partnerLog = _failureScopeController.getPartnerLog(); _pltWriteLock.lock(); try { boolean cleared = false; for (PartnerLogData pld : _partnerLogTable) { cleared |= pld.clearIfNotInUse(); } try { if (cleared) { ((DistributedRecoveryLog) partnerLog).keypoint(); } } catch (Exception exc) { // The keypoint operation has failed. There is very little we can do // other than continue with the close logic. This should be the the // that access to the log. There is nothing helpfull we can do at // this point. } } finally { _pltWriteLock.unlock(); } if (tc.isEntryEnabled()) Tr.exit(tc, "clearUnused"); }
java
public boolean recover(RecoveryManager recoveryManager, ClassLoader cl, Xid[] xids) { boolean success = true; // flag to indicate that we recovered all RMs if (tc.isEntryEnabled()) Tr.entry(tc, "recover", new Object[] { this, _failureScopeController.serverName() }); final int restartEpoch = recoveryManager.getCurrentEpoch(); final byte[] cruuid = recoveryManager.getApplId(); for (PartnerLogData pld : _partnerLogTable) { if (!pld.recover(cl, xids, null, cruuid, restartEpoch)) { success = false; } // Determine if shutdown processing started on another thread. // If it has, no further action can be taken. if (recoveryManager.shutdownInProgress()) { success = false; break; } } if (tc.isEntryEnabled()) Tr.exit(tc, "recover", success); return success; }
java
private <T> ServiceRegistration<T> registerMBean(ObjectName on, Class<T> type, T o) { Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put("jmx.objectname", on.toString()); return context.registerService(type, o, props); }
java
public void startReadListener(ThreadContextManager tcm, SRTInputStream31 inputStream) throws Exception{ try { ReadListenerRunnable rlRunnable = new ReadListenerRunnable(tcm, inputStream, this); this.setReadListenerRunning(true); com.ibm.ws.webcontainer.osgi.WebContainer.getExecutorService().execute(rlRunnable); // The read listener will now be invoked on another thread. Call pre-join to // notify interested components that this will be happening. It's possible that // the read listener may run before the pre-join is complete, and callers need to // be able to cope with that. notifyITransferContextPreProcessWorkState(); } catch (Exception e) { this.setReadListenerRunning(false); throw e; } }
java
public ThreadPool getThreadPool(String threadPoolName, int minSize, int maxSize) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getThreadPool", new Object[]{threadPoolName, minSize, maxSize}); ThreadPool threadPool = null; if (RuntimeInfo.isThinClient()) { try { Class clazz = Class.forName(JFapChannelConstants.THIN_CLIENT_THREADPOOL_CLASS); threadPool = (ThreadPool) clazz.newInstance(); } catch (Exception e) { FFDCFilter.processException(e, CLASS_NAME + ".getInstance", JFapChannelConstants.FRAMEWORK_GETTHREADPOOL_01, JFapChannelConstants.THIN_CLIENT_THREADPOOL_CLASS); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Unable to instantiate thin client thread pool", e); // Nothin we can do throw this on... throw new SIErrorException(e); } } else { try { Class clazz = Class.forName(JFapChannelConstants.RICH_CLIENT_THREADPOOL_CLASS); threadPool = (ThreadPool) clazz.newInstance(); } catch (Exception e) { FFDCFilter.processException(e, CLASS_NAME + ".getInstance", JFapChannelConstants.FRAMEWORK_GETTHREADPOOL_02, JFapChannelConstants.RICH_CLIENT_THREADPOOL_CLASS); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Unable to instantiate rich client thread pool", e); // Nothin we can do throw this on... throw new SIErrorException(e); } } threadPool.initialise(threadPoolName, minSize, maxSize); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getThreadPool", threadPool); return threadPool; }
java
private void cleanup() { StatsDataReference ref = null; while ((ref = (StatsDataReference) statisticsReferenceQueue.poll()) != null) { StatsData oldStats = null; StatsData updatedStats = null; do { oldStats = terminatedThreadStats.get(); updatedStats = aggregateStats(oldStats, ref.statsData); } while (!terminatedThreadStats.compareAndSet(oldStats, updatedStats)); allReferences.remove(ref); } }
java
public Expectations goodAppExpectations(String theUrl, String appClass) throws Exception { Expectations expectations = new Expectations(); expectations.addExpectations(CommonExpectations.successfullyReachedUrl(theUrl)); expectations.addExpectation(new ResponseFullExpectation(MpJwtFatConstants.STRING_CONTAINS, appClass, "Did not invoke the app " + appClass + ".")); return expectations; }
java
public Expectations badAppExpectations(String errorMessage) throws Exception { Expectations expectations = new Expectations(); expectations.addExpectation(new ResponseStatusExpectation(HttpServletResponse.SC_UNAUTHORIZED)); expectations.addExpectation(new ResponseMessageExpectation(MpJwtFatConstants.STRING_CONTAINS, errorMessage, "Did not find the error message: " + errorMessage)); return expectations; }
java
public String buildAppUrl(LibertyServer theServer, String root, String app) throws Exception { return SecurityFatHttpUtils.getServerUrlBase(theServer) + root + "/rest/" + app + "/" + MpJwtFatConstants.MPJWT_GENERIC_APP_NAME; }
java
public String buildAppSecureUrl(LibertyServer theServer, String root, String app) throws Exception { return SecurityFatHttpUtils.getServerSecureUrlBase(theServer) + root + "/rest/" + app + "/" + MpJwtFatConstants.MPJWT_GENERIC_APP_NAME; }
java
public Expectations setBadIssuerExpectations(LibertyServer server) throws Exception { Expectations expectations = new Expectations(); expectations.addExpectation(new ResponseStatusExpectation(HttpServletResponse.SC_UNAUTHORIZED)); expectations.addExpectation(new ServerMessageExpectation(server, MpJwtMessageConstants.CWWKS5523E_ERROR_CREATING_JWT_USING_TOKEN_IN_REQ, "Messagelog did not contain an error indicating a problem authenticating the request with the provided token.")); expectations.addExpectation(new ServerMessageExpectation(server, MpJwtMessageConstants.CWWKS6022E_ISSUER_NOT_TRUSTED, "Messagelog did not contain an exception indicating that the issuer is NOT valid.")); return expectations; }
java