code
stringlengths
73
34.1k
label
stringclasses
1 value
public boolean updateIOCounts(long byteCount, int type) { setLastIOAmt(byteCount); setIODoneAmount(getIODoneAmount() + byteCount); if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { String dbString = null; if (type == 0) { dbString = "Read "; } else { dbString = "Wrote "; } SocketIOChannel channel = getTCPConnLink().getSocketIOChannel(); Tr.event(tc, dbString + byteCount + "(" + +getIODoneAmount() + ")" + " bytes, " + getIOAmount() + " requested on local: " + channel.getSocket().getLocalSocketAddress() + " remote: " + channel.getSocket().getRemoteSocketAddress()); } boolean rc; if (getIODoneAmount() >= getIOAmount()) { // read is complete on current thread if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { if (type == 0) { Tr.debug(tc, "read complete, at least minimum amount of data read"); } else { Tr.debug(tc, "write complete, at least minimum amount of data written"); } } rc = true; } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { if (type == 0) { Tr.debug(tc, "read not complete, more data needed"); } else { Tr.debug(tc, "write not complete, more data needs to be written"); } } rc = false; } return rc; }
java
public ConversationReceiveListener acceptConnection(Conversation cfConversation) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "acceptConnection", cfConversation); // Add this conversation to our active conversations list synchronized (activeConversations) { Object connectionReference = cfConversation.getConnectionReference(); ArrayList list = (ArrayList) activeConversations.get(connectionReference); if (list == null) { list = new ArrayList(); activeConversations.put(connectionReference, list); } else { // This is mank - but if TRM does a redirect it is possible that we may get a // connection but then they close the Conversation directly without sending us any // kind of close flow. As such, every time we connect we should have a check on all // the conversations to ensure they are not closed, and if they are remove them from // the list. ArrayList removeList = new ArrayList(); for (int x = 0; x < list.size(); x++) { Conversation conv = (Conversation) list.get(x); if (conv.isClosed()) { removeList.add(conv); } } // Actually do the remove... for (int x = 0; x < removeList.size(); x++) { list.remove(removeList.get(x)); } } list.add(cfConversation); // At this point we have a look to see if the connection closed listener has been set. // If it has not been set then this is a new connection (or one with no active // Conversations on it. We must set ourselves as the listener in the event that the // socket terminates before any SI connections are established and so any cleanup // required. // Note that once a connection to the ME is established, this listener is overwritten // with one in ServerSideConnection. This also performs the same cleanup but also does // MFP cleanup as well (which is not appropriate if the connection goes down at this // stage). if (cfConversation.getConnectionClosedListener(ConversationUsageType.JFAP) == null) { cfConversation.addConnectionClosedListener(this, ConversationUsageType.JFAP); } } if (cfConversation.getAttachment() == null) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Creating conversation state"); cfConversation.setAttachment(new ConversationState()); } if (cfConversation.getLinkLevelAttachment() == null) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Creating link level state"); cfConversation.setLinkLevelAttachment(new ServerLinkLevelState()); } // Set a hint that this conversation is being used for ME to client communications. cfConversation.setConversationType(Conversation.CLIENT); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "acceptConnection", serverTransportReceiveListener); return serverTransportReceiveListener; }
java
public void removeConversation(Conversation conv) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "removeConversation", conv); synchronized (activeConversations) { Object connectionReference = conv.getConnectionReference(); ArrayList list = (ArrayList) activeConversations.get(connectionReference); if (list != null) { list.remove(conv); if (list.size() == 0) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "List is now empty, removing connection object"); activeConversations.remove(connectionReference); } } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "removeConversation"); }
java
public void connectionClosed(Object connectionReference) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "connectionClosed", connectionReference); removeAllConversations(connectionReference); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "connectionClosed"); }
java
public void removeAllConversations(Object connectionReference) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "removeAllConversations", connectionReference); final ArrayList list; synchronized (activeConversations) { list = (ArrayList) activeConversations.remove(connectionReference); } // Remove the connection reference from the list if (list != null) { try { for (int x = 0; x < list.size(); x++) { Conversation conv = (Conversation) list.get(x); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Found a Conversation in the table: ", conv); // Now call the server transport receive listener to clean up the resources serverTransportReceiveListener.cleanupConnection(conv); } } catch (Throwable t) { FFDCFilter.processException(t, CLASS_NAME + ".removeAllConversations", CommsConstants.SERVERTRANSPORTACCEPTLISTENER_REMOVEALL_01, this); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Caught an exception cleaning up a connection", t); } // Now clear the list list.clear(); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "removeAllConversations"); }
java
protected final ObjectFactoryInfo getObjectFactoryInfo(Class<?> klass, String className) // F743-32443 { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(tc, "getObjectFactory: " + klass + ", " + className); if (ivObjectFactoryMap == null) { if (isTraceOn && tc.isEntryEnabled()) Tr.exit(tc, "getObjectFactory: no factories"); return null; } if (klass != null && klass != Object.class) // d700708 { ObjectFactoryInfo result = ivObjectFactoryMap.get(klass); if (isTraceOn && tc.isEntryEnabled()) Tr.exit(tc, "getObjectFactory: " + result); return result; } if (ivObjectFactoryByNameMap == null) { ivObjectFactoryByNameMap = new HashMap<String, ObjectFactoryInfo>(); for (Map.Entry<Class<?>, ObjectFactoryInfo> entry : ivObjectFactoryMap.entrySet()) { ivObjectFactoryByNameMap.put(entry.getKey().getName(), entry.getValue()); } } ObjectFactoryInfo result = ivObjectFactoryByNameMap.get(className); if (isTraceOn && tc.isEntryEnabled()) Tr.exit(tc, "getObjectFactory (by-name): " + result); return result; }
java
private void updateInjectionBinding(String jndiName, InjectionBinding<A> injectionBinding) // d675172 { // If the annotation didn't have a name or the binding implementation // constructor did not set it, then the binding needs to be updated // with the default name or name (if not set by constructor). // d682415 if (!jndiName.equals(injectionBinding.getJndiName())) // d675172.1 { injectionBinding.setJndiName(jndiName); } }
java
private <P extends Annotation> InjectionBinding<?> addOrMergeOverrideInjectionBinding(Class<?> instanceClass, Member member, A annotation, String jndiName) // d675843.2 throws InjectionException { @SuppressWarnings("unchecked") InjectionProcessor<P, ?> processor = (InjectionProcessor<P, ?>) ivOverrideProcessor; if (processor != null) { // This logic is the same as addOrMergeInjectionBinding, except it // uses OverrideInjectionProcessor methods to create and merge // injection bindings rather than InjectionProcessor and // InjectionBinding methods. InjectionBinding<P> injectionBinding = processor.getInjectionBindingForAnnotation(jndiName); @SuppressWarnings("unchecked") OverrideInjectionProcessor<P, A> overrideProcessor = (OverrideInjectionProcessor<P, A>) processor; if (injectionBinding == null) { injectionBinding = overrideProcessor.createOverrideInjectionBinding(instanceClass, member, annotation, jndiName); if (injectionBinding != null) { processor.updateInjectionBinding(jndiName, injectionBinding); processor.addInjectionBinding(injectionBinding); return injectionBinding; } } else { overrideProcessor.mergeOverrideInjectionBinding(instanceClass, member, annotation, injectionBinding); return injectionBinding; } } return null; }
java
void performJavaNameSpaceBinding() throws InjectionException { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(tc, "performJavaNameSpaceBinding: " + this); for (InjectionBinding<A> injectionBinding : ivAllAnnotationsCollection.values()) { // F743-31682 - Only bind to java:global/:app/:module if needed. if (injectionBinding.getInjectionScope() == InjectionScope.COMP || ivContext.ivBindNonCompInjectionBindings) { if (injectionBinding.getBindingObject() == null) { if (isTraceOn && tc.isDebugEnabled()) Tr.debug(tc, "skipping empty " + injectionBinding); } else { injectionBinding.bindInjectedObject(); } } else { if (isTraceOn && tc.isEntryEnabled()) Tr.debug(tc, "skipping non-java:comp " + injectionBinding.toSimpleString()); } } if (isTraceOn && tc.isEntryEnabled()) Tr.exit(tc, "performJavaNameSpaceBinding"); }
java
public final void addInjectionBinding(InjectionBinding<A> injectionBinding) { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isDebugEnabled()) Tr.debug(tc, "addInjectionBinding: " + injectionBinding); // jndi name not found in collection, simple add ivAllAnnotationsCollection.put(injectionBinding.getJndiName(), injectionBinding); }
java
protected final String getJavaBeansPropertyName(Member fieldOrMethod) { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(tc, "getJavaBeansPropertyName : " + fieldOrMethod); String propertyName; if (fieldOrMethod instanceof Field) { Field field = (Field) fieldOrMethod; propertyName = field.getName(); } else { Method method = (Method) fieldOrMethod; String name = method.getName(); if (name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt(3))) { propertyName = Character.toLowerCase(name.charAt(3)) + (name.length() > 4 ? name.substring(4) : ""); } else { propertyName = null; } } if (isTraceOn && tc.isEntryEnabled()) Tr.exit(tc, "getJavaBeansPropertyName : " + propertyName); return propertyName; }
java
public Set<String> getServerFeatures() { ServerTask serverTask = runningServer.get(); try { if (serverTask != null) return serverTask.getServerFeatures(); } catch (InterruptedException e) { // nothing to do here, we couldn't get the results from the server } return Collections.emptySet(); }
java
protected Node findNode(int nodeStreamID) { // mainline debug in this recursive method is way to verbose, so only debug when we find what we are looking for if (nodeStreamID == this.streamID) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "findNode exit: bottom of recursion, found node: " + this); } return this; } else { Iterator<Node> iter = dependents.iterator(); Node found = null; while (iter.hasNext()) { found = iter.next().findNode(nodeStreamID); if (found != null) { return found; } } return null; } }
java
protected void addDependent(Node nodeToAdd) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "addDependent entry: node to add: " + nodeToAdd); } dependents.add(nodeToAdd); }
java
protected void removeDependent(Node nodeToRemove) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "removeDependent entry: node to remove: " + nodeToRemove); } dependents.remove(nodeToRemove); }
java
protected void clearDependentsWriteCount() { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "clearDependentsWriteCount entry: for this node: " + this); } dependentWriteCount = 0; if ((dependents == null) || (dependents.size() == 0)) { return; } for (int i = 0; i < dependents.size(); i++) { dependents.get(i).setWriteCount(0); } }
java
protected Node findNextWrite() { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "findNextWrite entry: on node " + this + "With status: " + status + "and positive ratio of: " + getPriorityRatioPositive()); } if (status == NODE_STATUS.REQUESTING_WRITE) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "findNextWrite exit: node to write next is: " + this.toStringDetails()); } return this; } else { // go through all dependents in order for (int i = 0; i < dependents.size(); i++) { Node n = dependents.get(i); Node nextWrite = n.findNextWrite(); if (nextWrite != null) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "findNextWrite exit: next write node found. stream-id: " + nextWrite.getStreamID() + " node hc: " + nextWrite.hashCode()); } return nextWrite; } } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "findNextWrite exit: null"); } return null; } }
java
protected int incrementDependentWriteCount() { dependentWriteCount++; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "incrementDependentWriteCount entry: new dependentWriteCount of: " + dependentWriteCount + " for node: " + this); } return dependentWriteCount; }
java
protected void setParent(Node newParent, boolean removeDep) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { Tr.debug(tc, "setParent entry: new parent will be: " + newParent + " for node: " + this); } Node oldParent = parent; parent = newParent; if (newParent != null) { parent.addDependent(this); } // removing dependents can cause ConcurrentModificationException if calling is iterating over a list of dependent nodes // therefore removeDep should be false if setParent is being called while iterating or looping over a list of // dependent nodes. if (removeDep) { // remove this node from the old parents list of dependents. if (oldParent != null) { if (newParent == null) { oldParent.removeDependent(this); } else if (oldParent.getStreamID() != parent.getStreamID()) { oldParent.removeDependent(this); } } } }
java
private final AbstractItemLink _next(long lockID) throws SevereMessageStoreException { // first look for an available link that we can lock. We scan the tree // removing each element as we find it. If we are able to lock the link // we use it. AbstractItemLink lockedMatchingLink = null; if (_jumpbackEnabled) { while (null == lockedMatchingLink) { AbstractItemLink link; // Get and remove the first AIL in the list of AILs behind the current position synchronized(this) { link = _behindList.getFirst(true); } if (link == null) { break; } else if (link.lockItemIfAvailable(lockID)) { lockedMatchingLink = link; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "using available: " + lockedMatchingLink); } } } if (null == lockedMatchingLink) { // we didn't find and lock an available link, so we must now resume // the traverse of the linked list AbstractItemLink lookAtLink; synchronized(this) { lookAtLink = (AbstractItemLink)advance(); } while (null != lookAtLink && null == lockedMatchingLink) { // update our position for each link we examine in the chain long pos = lookAtLink.getPosition(); synchronized(this) { if (pos > _highestPosition) { _highestPosition = pos; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "examine " + lookAtLink + "(seq = " + _highestPosition + ")"); } } // try to lock the link // // PAY ATTENTION // // This can read from the persistence layer so we MUST not be synchronized // on this subcursor for the sake of concurrency (although it will not deadlock). // Defect 298364 (sev 1) was raised to reflect a delay of several minutes due to this if (lookAtLink.lockIfMatches(_filter, lockID)) { // we matched and locked the link lockedMatchingLink = lookAtLink; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "found: " + lockedMatchingLink); } else { // we didn't get the link - it didn't match or didn't lock. Advance synchronized(this) { lookAtLink = (AbstractItemLink)advance(); } } } } return lockedMatchingLink; }
java
public final void available(AbstractItemLink link) throws SevereMessageStoreException { if (_jumpbackEnabled) { final long newPos = link.getPosition(); // we need to synchronize the read of the position // or we can miss out items when reading an empty queue fast. // More importantly, the removal of the next from the cursor cannot // happen while we are adding the available synchronized(this) { if (newPos <= _highestPosition) { // Only store matching links, 'coz its quicker if (null != link.matches(_filter)) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "availableLink adding: " + link); _behindList.insert(link); } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "availableLink does not match: " + link); } } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "availableLink seq(" + newPos + ") too large (" + _highestPosition + ")"); } } } else { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "available link - jumpbackDisabled: " + link); } }
java
public final AbstractItem next(long lockID) throws SevereMessageStoreException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "next", Long.valueOf(lockID)); final AbstractItemLink lockedMatchingLink = _next(lockID); // retrieve the item from the link AbstractItem lockedMatchingItem = null; if (null != lockedMatchingLink) { lockedMatchingItem = lockedMatchingLink.getItem(); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "next", lockedMatchingItem); return lockedMatchingItem; }
java
public final void finished() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "finished"); if (null != _lastLink) { _lastLink.cursorRemoved(); _lastLink = null; } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "finished"); }
java
private void callTransactionalLifecycleInterceptors(InterceptorProxy[] proxies, int methodId) throws RemoteException { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); LifecycleInterceptorWrapper wrapper = new LifecycleInterceptorWrapper(container, this); EJSDeployedSupport s = new EJSDeployedSupport(); // F743761.CodRv - Exceptions from lifecycle callback interceptors do not // throw application exceptions. s.ivIgnoreApplicationExceptions = true; try { container.preInvokeForLifecycleInterceptors(wrapper, methodId, s, this); // F743-1751CodRev - Inline callLifecycleInterceptors. We need to // manage HandleList separately. if (isTraceOn) // d527372 { if (TEBeanLifeCycleInfo.isTraceEnabled()) TEBeanLifeCycleInfo.traceEJBCallEntry(LifecycleInterceptorWrapper.TRACE_NAMES[methodId]); if (tc.isDebugEnabled()) Tr.debug(tc, "callLifecycleInterceptors"); } InvocationContextImpl<?> inv = getInvocationContext(); BeanMetaData bmd = home.beanMetaData; inv.doLifeCycle(proxies, bmd._moduleMetaData); // F743-14982 } catch (Throwable t) { s.setUncheckedLocalException(t); } finally { if (isTraceOn && TEBeanLifeCycleInfo.isTraceEnabled()) { TEBeanLifeCycleInfo.traceEJBCallExit(LifecycleInterceptorWrapper.TRACE_NAMES[methodId]); } container.postInvokeForLifecycleInterceptors(wrapper, methodId, s); } }
java
@Override public void postInvoke(int id, EJSDeployedSupport s) throws RemoteException { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) { Tr.entry(tc, "postInvoke"); } // Release lock acquired if container managed concurrency control. if (ivContainerManagedConcurrency && s.ivLockAcquired) { // Get the lock type to use for the method being invoked. EJBMethodInfoImpl mInfo = s.methodInfo; LockType lockType = mInfo.ivLockType; if (lockType == LockType.READ) { ivReadLock.unlock(); if (isTraceOn && tc.isDebugEnabled()) { Tr.debug(tc, "postInvoke released read lock: " + ivLock.toString()); } } else { ivWriteLock.unlock(); if (isTraceOn && tc.isDebugEnabled()) { Tr.debug(tc, "postInvoke released write lock: " + ivLock.toString()); } } } if (isTraceOn && tc.isEntryEnabled()) { Tr.exit(tc, "postInvoke"); } }
java
private Class<?> resolveClassWithCL(String name) throws ClassNotFoundException { SecurityManager security = System.getSecurityManager(); if (security != null) { return Class.forName(name, false, getClassLoader(thisClass)); } // The platform classloader is null if we failed to get it when using java 9, or if we are // running with a java level below 9. In those cases, the bootstrap classloader // is used to resolve the needed class. // Note that this change is being made to account for the fact that in java 9, classes // such as java.sql.* (java.sql module) are no longer discoverable through the bootstrap // classloader. Those classes are now discoverable through the java 9 platform classloader. // The platform classloader is between the bootstrap classloader and the app classloader. return Class.forName(name, false, platformClassloader); }
java
@Override protected Class<?> resolveProxyClass(String[] interfaceNames) throws ClassNotFoundException { ClassLoader proxyClassLoader = classLoader; Class<?>[] interfaces = new Class[interfaceNames.length]; Class<?> nonPublicInterface = null; for (int i = 0; i < interfaceNames.length; i++) { Class<?> intf = loadClass(interfaceNames[i]); if (!Modifier.isPublic(intf.getModifiers())) { ClassLoader classLoader = getClassLoader(intf); if (nonPublicInterface != null) { if (classLoader != proxyClassLoader) { throw new IllegalAccessError(nonPublicInterface + " and " + intf + " both declared non-public in different class loaders"); } } else { nonPublicInterface = intf; proxyClassLoader = classLoader; } } interfaces[i] = intf; } try { return Proxy.getProxyClass(proxyClassLoader, interfaces); } catch (IllegalArgumentException ex) { throw new ClassNotFoundException(null, ex); } }
java
private static ClassLoader getPlatformClassLoader() { if (JavaInfo.majorVersion() >= 9) { return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { @Override public ClassLoader run() { ClassLoader pcl = null; try { Method getPlatformClassLoader = ClassLoader.class.getMethod("getPlatformClassLoader"); pcl = (ClassLoader) getPlatformClassLoader.invoke(null); } catch (Throwable t) { // Log an FFDC. } return pcl; } }); } return null; }
java
@Override public void setAsynchConsumerCallback(int requestNumber, int maxActiveMessages, long messageLockExpiry, int batchsize, OrderingContext orderContext, boolean stoppable, int maxSequentialFailures, long hiddenMessageDelay) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "setAsynchConsumerCallback", new Object[] { requestNumber, maxActiveMessages, messageLockExpiry, batchsize, orderContext, stoppable, maxSequentialFailures, hiddenMessageDelay }); try { // Here we need to examine the config parameter that will denote whether we are telling // MP to inline our async callbacks or not. We will default to false, but this can // be overrideen. boolean inlineCallbacks = CommsUtils.getRuntimeBooleanProperty(CommsConstants.INLINE_ASYNC_CBACKS_KEY, CommsConstants.INLINE_ASYNC_CBACKS); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Inline async callbacks: " + inlineCallbacks); MPConsumerSession session = (MPConsumerSession) getConsumerSession(); if (stoppable) { session.registerStoppableAsynchConsumerCallback(this, maxActiveMessages, messageLockExpiry, batchsize, getUnrecoverableReliability(), inlineCallbacks, orderContext, maxSequentialFailures, hiddenMessageDelay); } else { session.registerAsynchConsumerCallback(this, maxActiveMessages, messageLockExpiry, batchsize, getUnrecoverableReliability(), inlineCallbacks, orderContext); } try { getConversation().send(poolManager.allocate(), JFapChannelConstants.SEG_REGISTER_ASYNC_CONSUMER_R, requestNumber, JFapChannelConstants.PRIORITY_MEDIUM, true, ThrottlingPolicy.BLOCK_THREAD, null); } catch (SIException e) { FFDCFilter.processException(e, CLASS_NAME + ".setAsynchConsumerCallback", CommsConstants.CATASYNCHCONSUMER_SETCALLBACK_01, this); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, e.getMessage(), e); SibTr.error(tc, "COMMUNICATION_ERROR_SICO2017", e); } // End d175222 } catch (SIException e) { //No FFDC code needed //Only FFDC if we haven't received a meTerminated event. if (!((ConversationState) getConversation().getAttachment()).hasMETerminated()) { FFDCFilter.processException(e, CLASS_NAME + ".setAsynchConsumerCallback", CommsConstants.CATASYNCHCONSUMER_SETCALLBACK_02, this); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, e.getMessage(), e); StaticCATHelper.sendExceptionToClient(e, CommsConstants.CATASYNCHCONSUMER_SETCALLBACK_02, getConversation(), requestNumber); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "setAsynchConsumerCallback"); }
java
@Override public void flush(int requestNumber) { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "flush", "" + requestNumber); try { // Make sure it is stopped before we activate it if (mainConsumer.isStarted()) getConsumerSession().stop(); getConsumerSession().activateAsynchConsumer(true); if (mainConsumer.isStarted()) getConsumerSession().start(false); short jfapPriority = JFapChannelConstants.getJFAPPriority(Integer.valueOf(mainConsumer.getLowestPriority())); // d172528 if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Sending with JFAP priority of " + jfapPriority); // d172528 try { getConversation().send(poolManager.allocate(), JFapChannelConstants.SEG_FLUSH_SESS_R, requestNumber, jfapPriority, true, ThrottlingPolicy.BLOCK_THREAD, null); } catch (SIException e) { FFDCFilter.processException(e, CLASS_NAME + ".flush", CommsConstants.CATASYNCHCONSUMER_FLUSH_01, this); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, e.getMessage(), e); SibTr.error(tc, "COMMUNICATION_ERROR_SICO2017", e); } } catch (SIException e) { //No FFDC code needed //Only FFDC if we haven't received a meTerminated event. if (!((ConversationState) getConversation().getAttachment()).hasMETerminated()) { FFDCFilter.processException(e, CLASS_NAME + ".flush", CommsConstants.CATASYNCHCONSUMER_FLUSH_02, this); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, e.getMessage(), e); StaticCATHelper.sendExceptionToClient(e, CommsConstants.CATASYNCHCONSUMER_FLUSH_02, getConversation(), requestNumber); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "flush"); }
java
private boolean sendMessage(SIBusMessage sibMessage, boolean lastMsg, Integer priority) throws MessageEncodeFailedException, IncorrectMessageTypeException, MessageCopyFailedException, UnsupportedEncodingException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "sendMessage", new Object[] { sibMessage, lastMsg, priority }); boolean ok = false; // If we are at FAP9 or above we can do a 'chunked' send of the message in seperate // slices to make life easier on the Java memory manager final HandshakeProperties props = getConversation().getHandshakeProperties(); if (props.getFapLevel() >= JFapChannelConstants.FAP_VERSION_9) { ok = sendChunkedMessage(sibMessage, lastMsg, priority); } else { ok = sendEntireMessage(sibMessage, null, lastMsg, priority); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "sendMessage", ok); return ok; }
java
private boolean sendEntireMessage(SIBusMessage sibMessage, List<DataSlice> messageSlices, boolean lastMsg, Integer priority) throws MessageEncodeFailedException, IncorrectMessageTypeException, MessageCopyFailedException, UnsupportedEncodingException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "sendEntireMessage", new Object[] { sibMessage, messageSlices, lastMsg, priority }); if (lastMsg) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Sending last in batch"); } ConversationState convState = (ConversationState) getConversation().getAttachment(); // Flag to indicate a Comms error so that we stop sending messages boolean ok = true; try { CommsServerByteBuffer byteBuffer = poolManager.allocate(); int msgLen = 0; short msgFlags = CommsConstants.ASYNC_START_OR_MID_BATCH; if (lastMsg) msgFlags |= CommsConstants.ASYNC_LAST_IN_BATCH; byteBuffer.putShort(convState.getConnectionObjectId()); byteBuffer.putShort(mainConsumer.getClientSessionId()); byteBuffer.putShort(msgFlags); byteBuffer.putShort(mainConsumer.getMessageBatchNumber()); // BIT16 Message Batch // Put the entire message into the buffer in whatever way is suitable if (messageSlices == null) { msgLen = byteBuffer.putMessage((JsMessage) sibMessage, convState.getCommsConnection(), getConversation()); } else { msgLen = byteBuffer.putMessgeWithoutEncode(messageSlices); } int jfapPriority = JFapChannelConstants.getJFAPPriority(priority); getConversation().send(byteBuffer, JFapChannelConstants.SEG_ASYNC_MESSAGE, 0, // No request number jfapPriority, false, ThrottlingPolicy.BLOCK_THREAD, null); } catch (SIException e) { FFDCFilter.processException(e, CLASS_NAME + ".sendEntireMessage", CommsConstants.CATASYNCHCONSUMER_SENDENTIREMESS_01, this); ok = false; SibTr.error(tc, "COMMUNICATION_ERROR_SICO2017", e); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "sendEntireMessage", ok); return ok; }
java
public void consumerSessionStopped() { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "consumerSessionStopped"); // Inform the main consumer instance that message processor has stopped the session, this will prevent any more // restart requests from the client starting the consumer session by mistake, instead we must wait for a start // request from the application. mainConsumer.stopStoppableSession(); //471642 ConversationState convState = (ConversationState) getConversation().getAttachment(); CommsServerByteBuffer buffer = poolManager.allocate(); // Put conversation id buffer.putShort(convState.getConnectionObjectId()); // Put session id buffer.putShort(getClientSessionId()); try { getConversation().send(buffer, JFapChannelConstants.SEG_ASYNC_SESSION_STOPPED_NOREPLY, 0, JFapChannelConstants.PRIORITY_MEDIUM, false, ThrottlingPolicy.BLOCK_THREAD, null); } catch (SIException e) { FFDCFilter.processException(e, CLASS_NAME + ".consumerSessionStopped", CommsConstants.CATASYNCHCONSUMER_SENSSION_STOPPED_01, this); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, e.getMessage(), e); SibTr.error(tc, "COMMUNICATION_ERROR_SICO2017", e); } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "consumerSessionStopped"); }
java
private void checkObjectFactoryAttributes(ResourceInjectionBinding resourceBinding, ObjectFactoryInfo extensionFactory) // d675976 throws InjectionConfigurationException { Resource resourceAnnotation = resourceBinding.getAnnotation(); if (!extensionFactory.isAttributeAllowed("authenticationType")) { checkObjectFactoryAttribute(resourceBinding, "authenticationType", resourceAnnotation.authenticationType(), AuthenticationType.CONTAINER); } if (!extensionFactory.isAttributeAllowed("shareable")) { checkObjectFactoryAttribute(resourceBinding, "shareable", resourceAnnotation.shareable(), true); } }
java
private Reference createExtensionFactoryReference(ObjectFactoryInfo extensionFactory, ResourceInjectionBinding resourceBinding) // F48603.9 { String className = extensionFactory.getObjectFactoryClass().getName(); Reference ref = new Reference(resourceBinding.getInjectionClassTypeName(), className, null); if (extensionFactory.isRefAddrNeeded()) // F48603 { ref.add(new ResourceInfoRefAddr(createResourceInfo(resourceBinding))); } return ref; }
java
private ResourceInfo createResourceInfo(ResourceInjectionBinding resourceBinding) // F48603.9 { J2EEName j2eeName = ivNameSpaceConfig.getJ2EEName(); Resource resourceAnnotation = resourceBinding.getAnnotation(); return new ResourceInfo(j2eeName == null ? null : j2eeName.getApplication(), j2eeName == null ? null : j2eeName.getModule(), // TODO: This should be j2eeName.getComponent(), but at least // SIP is known to improperly depend on this being the module // name without ".war". ivNameSpaceConfig.getDisplayName(), resourceBinding.getJndiName(), resourceBinding.getInjectionClassTypeName(), resourceAnnotation.authenticationType(), resourceAnnotation.shareable(), resourceBinding.ivLink, getResourceRefConfig(resourceBinding, resourceBinding.getJndiName(), null)); }
java
public HttpURLConnection createConnection(TLSClientParameters tlsClientParameters, Proxy proxy, URL url) throws IOException { HttpURLConnection connection = (HttpURLConnection) (proxy != null ? url.openConnection(proxy) : url.openConnection()); if (HTTPS_URL_PROTOCOL_ID.equals(url.getProtocol())) { if (tlsClientParameters == null) { tlsClientParameters = new TLSClientParameters(); } Exception ex = null; try { decorateWithTLS(tlsClientParameters, connection); } catch (Exception e) { ex = e; } finally { if (ex != null) { if (ex instanceof IOException) { throw (IOException) ex; } // use exception.initCause(ex) to be java 5 compatible IOException ioException = new IOException("Error while initializing secure socket"); ioException.initCause(ex); throw ioException; } } } return connection; }
java
public static List<Parameter> collectConstructorParameters(Class<?> cls, Components components, javax.ws.rs.Consumes classConsumes) { if (cls.isLocalClass() || (cls.isMemberClass() && !Modifier.isStatic(cls.getModifiers()))) { return Collections.emptyList(); } List<Parameter> selected = Collections.emptyList(); int maxParamsCount = 0; for (Constructor<?> constructor : cls.getDeclaredConstructors()) { if (!ReflectionUtils.isConstructorCompatible(constructor) && !ReflectionUtils.isInject(Arrays.asList(constructor.getDeclaredAnnotations()))) { continue; } final Type[] genericParameterTypes = constructor.getGenericParameterTypes(); final Annotation[][] annotations = constructor.getParameterAnnotations(); int paramsCount = 0; final List<Parameter> parameters = new ArrayList<Parameter>(); for (int i = 0; i < genericParameterTypes.length; i++) { final List<Annotation> tmpAnnotations = Arrays.asList(annotations[i]); if (isContext(tmpAnnotations)) { paramsCount++; } else { final Type genericParameterType = genericParameterTypes[i]; final List<Parameter> tmpParameters = collectParameters(genericParameterType, tmpAnnotations, components, classConsumes); if (tmpParameters.size() >= 1) { for (Parameter tmpParameter : tmpParameters) { if (ParameterProcessor.applyAnnotations( tmpParameter, genericParameterType, tmpAnnotations, components, classConsumes == null ? new String[0] : classConsumes.value(), null) != null) { parameters.add(tmpParameter); } } paramsCount++; } } } if (paramsCount >= maxParamsCount) { maxParamsCount = paramsCount; selected = parameters; } } return selected; }
java
public static List<Parameter> collectFieldParameters(Class<?> cls, Components components, javax.ws.rs.Consumes classConsumes) { final List<Parameter> parameters = new ArrayList<Parameter>(); for (Field field : ReflectionUtils.getDeclaredFields(cls)) { final List<Annotation> annotations = Arrays.asList(field.getAnnotations()); final Type genericType = field.getGenericType(); parameters.addAll(collectParameters(genericType, annotations, components, classConsumes)); } return parameters; }
java
public static String[] splitContentValues(String[] strings) { final Set<String> result = new LinkedHashSet<String>(); for (String string : strings) { if (string.isEmpty()) continue; String[] splitted = string.trim().split(","); for (String string2 : splitted) { result.add(string2); } } return result.toArray(new String[result.size()]); }
java
public static boolean objectsNotEqual(final Object one, final Object two) { return (one == null) ? (two != null) : (!one.equals(two)); }
java
public static void addFieldToString(final StringBuffer buffer, final String name, final Object value) { buffer.append(" <"); buffer.append(name); buffer.append("="); buffer.append(value); buffer.append(">"); }
java
public static void addPasswordFieldToString(final StringBuffer buffer, final String name, final Object value) { addFieldToString(buffer, name, (value == null) ? null : "*****"); }
java
public final void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { _jspService(request, response); }
java
public Object put(long key, Object value) { if (tc.isEntryEnabled()) Tr.entry(tc, "put", new Object[]{new Long(key), value, this}); if (value == null) { if (tc.isEntryEnabled()) Tr.exit(tc, "put", "IllegalArgumentException"); throw new IllegalArgumentException("Null is not a permitted value."); } // Find an empty bucket for the new value or // a bucket the contains an entry with the // same key. int hash = getHashForNewEntry(key); // Store the value previously held in the bucket // mapping DELETED to null so that it // can be returned to the caller. Object previous = _values[hash] == DELETED ? null : _values[hash]; // Add the new value and key to the map. _values[hash] = value; _keys[hash] = key; if (previous == null) { // This put resulted in a new entry being added to // the map rather than an existing entry being // updated. Increment the count of objects in the // map and rehash if necessary. _currentLoad++; if (_currentLoad == _resizeThreshold) { if (tc.isEntryEnabled()) Tr.entry(tc, "put", new Object[]{new Long(key), value, this}); // The current load of the map means that it // has reached the desired loadFactor. Increase // the size of the map and rehash all the entries. // Take a copy of the map's contents so that we // can add them back in once it's been resized. long[] oldKeys = new long[_mapSize]; Object[] oldValues = new Object[_mapSize]; System.arraycopy(_keys, 0, oldKeys, 0, oldKeys.length); System.arraycopy(_values, 0, oldValues, 0, oldValues.length); // We know that the inital size of the map // is a power of 2 so, by doubling it, we // can increase the map's capacity and // still be sure that it's size is a power // of two. _mapSize = (_mapSize * 2); if (tc.isDebugEnabled()) Tr.debug(tc, "mapSize = " + _mapSize); _resizeThreshold = (int)(((float)_mapSize) * ((float)_loadFactor) / 100f); if (tc.isDebugEnabled()) Tr.debug(tc, "resizeThreshold = " + _resizeThreshold); _values = new Object[_mapSize]; _keys = new long[_mapSize]; // Zero the count of objects in the map. This will // be incremented to the correct value as the // entries are added back into the resized map // below. _currentLoad = 0; // Loop through the old values adding live // entries back into the map. for (int i = 0; i < oldValues.length; i++) { Object oldValue = oldValues[i]; if (oldValue != null && oldValue != DELETED) { put(oldKeys[i], oldValue); } } } } if (tc.isEntryEnabled()) Tr.exit(tc, "put", previous); return previous; }
java
public Object remove(long key) { if (tc.isEntryEnabled()) Tr.entry(tc, "remove", new Object[]{new Long(key), this}); int hash = getHashForExistingEntry(key); Object result = null; if (hash >= 0) { result = _values[hash]; } if (result != null) { if (tc.isDebugEnabled()) Tr.debug(tc, "Entry found in map - removing"); _values[hash] = DELETED; _currentLoad--; } if (tc.isEntryEnabled()) Tr.exit(tc, "remove", result); return result; }
java
public Object get(long key) { if (tc.isEntryEnabled()) Tr.entry(tc, "get", new Object[]{new Long(key), this}); int hash = getHashForExistingEntry(key); Object value = null; if (hash >= 0) { value = _values[hash]; } if (tc.isEntryEnabled()) Tr.exit(tc, "get", value); return value; }
java
private int getHashForKey(long key) { if (tc.isEntryEnabled()) Tr.entry(tc, "getHashForKey", new Object[]{new Long(key), this}); int hash = (int) (key % _mapSize); if (hash < 0) hash = -hash; if (tc.isEntryEnabled()) Tr.exit(tc, "getHashForKey", new Integer(hash)); return hash; }
java
private void processConfigProps(Map<String, Object> props) { if (props == null || props.isEmpty()) return; id = (String) props.get(CFG_KEY_ID); if (id == null) { Tr.error(tc, "AUTHZ_ROLE_ID_IS_NULL"); return; } rolePids = (String[]) props.get(CFG_KEY_ROLE); // if (rolePids == null || rolePids.length < 1) // return; processRolePids(); }
java
private Configuration retrieveConfig(NestedConfigHelper configHelper, ConfigurationAdmin configAdmin) throws InitWithoutConfig { if (configHelper == null) throw new InitWithoutConfig("Configuration not found"); // We need configAdmin to list the configurations of nested classloader elements with this application as their parent if (configAdmin == null) throw new InitWithoutConfig("ConfigurationAdmin service not found"); String parentPid = (String) configHelper.get(Constants.SERVICE_PID); String sourcePid = (String) configHelper.get("ibm.extends.source.pid"); if (sourcePid != null) { parentPid = sourcePid; } try { StringBuilder filter = new StringBuilder(); filter.append("(&"); filter.append(FilterUtils.createPropertyFilter("service.factoryPid", "com.ibm.ws.classloading.classloader")); filter.append(FilterUtils.createPropertyFilter("config.parentPID", parentPid)); filter.append(")"); Configuration[] configs = configAdmin.listConfigurations(filter.toString()); if (configs == null || configs.length != 1) { throw new InitWithoutConfig("No classloader element found"); } Configuration config = configs[0]; if (config.getProperties() == null) { if (tc.isErrorEnabled()) Tr.error(tc, "cls.classloader.missing", config.getPid()); config.delete(); throw new InitWithoutConfig("Classloader config not found"); } return config; } catch (IOException e) { throw new InitWithoutConfig("Configuration for classloader not found, exception " + e); } catch (InvalidSyntaxException e) { throw new InitWithoutConfig("Configuration for classloader not found, exception " + e); } }
java
private List<String> getIds(ConfigurationAdmin ca, String[] pids) { final String methodName = "getIds(): "; if (pids == null) { return Collections.emptyList(); } List<String> ids = new ArrayList<String>(); for (String pid : pids) { try { String filter = "(" + org.osgi.framework.Constants.SERVICE_PID + "=" + pid + ")"; Configuration[] config = ca.listConfigurations(filter); if (config == null) { if (tc.isDebugEnabled()) Tr.debug(tc, methodName + "Configuration not found for pid " + pid); } else { if (tc.isDebugEnabled()) Tr.debug(tc, methodName + "Found config for " + pid); String id = (String) config[0].getProperties().get("id"); ids.add(id); } } catch (IOException e) { if (tc.isDebugEnabled()) Tr.debug(tc, methodName + "Configuration not found for " + pid, e); } catch (InvalidSyntaxException e) { if (tc.isDebugEnabled()) Tr.debug(tc, methodName + "Configuration not found for " + pid, e); } } return Collections.unmodifiableList(ids); }
java
private boolean folderContainsFiles(File folder) { if (folder != null) { File[] files = folder.listFiles(); for (File file : files) if (file.isFile()) return true; for (File file : files) if (file.isDirectory()) if (folderContainsFiles(file)) return true; } return false; }
java
public static ASN1Sequence getInstance( Object obj) { if (obj == null || obj instanceof ASN1Sequence) { return (ASN1Sequence)obj; } throw new IllegalArgumentException("unknown object in getInstance"); }
java
private static boolean markError(OverlayContainer overlay, String errorTag) { if ( overlay.getFromNonPersistentCache(errorTag, WebExtAdapter.class) == null ) { overlay.addToNonPersistentCache(errorTag, WebExtAdapter.class, errorTag); return true; } else { return false; } }
java
@Override @FFDCIgnore(ParseException.class) public com.ibm.ws.javaee.dd.webext.WebExt adapt( Container root, OverlayContainer rootOverlay, ArtifactContainer artifactContainer, Container containerToAdapt) throws UnableToAdaptException { // What web extension is stored depends on the web descriptor version: // either "ibm-web-ext.xmi" or "ibm-web-ext.xml". com.ibm.ws.javaee.dd.web.WebApp primary = containerToAdapt.adapt(com.ibm.ws.javaee.dd.web.WebApp.class); String primaryVersion = ((primary == null) ? null : primary.getVersion()); boolean xmi = ( "2.2".equals(primaryVersion) || "2.3".equals(primaryVersion) || "2.4".equals(primaryVersion) ); String ddEntryName; if ( xmi ) { ddEntryName = com.ibm.ws.javaee.dd.webext.WebExt.XMI_EXT_NAME; } else { ddEntryName = com.ibm.ws.javaee.dd.webext.WebExt.XML_EXT_NAME; } Entry ddEntry = containerToAdapt.getEntry(ddEntryName); com.ibm.ws.javaee.ddmodel.webext.WebExtComponentImpl fromConfig = getConfigOverrides(rootOverlay, artifactContainer); // Neither the web-extension nor the configuration override is available: // Answer null. if ( (ddEntry == null) && (fromConfig == null) ) { return null; } if ( ddEntry != null ) { com.ibm.ws.javaee.dd.webext.WebExt fromApp; try { fromApp = new com.ibm.ws.javaee.ddmodel.webext.WebExtDDParser(containerToAdapt, ddEntry, xmi).parse(); } catch ( ParseException e ) { throw new UnableToAdaptException(e); } if ( fromConfig == null ) { // Only the web extension is available. return fromApp; } else { // Both are available: Answer the configuration override, with the // web extension set as a delegate. fromConfig.setDelegate(fromApp); return fromConfig; } } else { // Only the configuration override is available. return fromConfig; } }
java
private String stripExtension(String moduleName) { if ( moduleName.endsWith(".war") || moduleName.endsWith(".jar") ) { return moduleName.substring(0, moduleName.length() - 4); } return moduleName; }
java
public final boolean isReconfigurable(WSConnectionRequestInfoImpl cri, boolean reauth) { // The CRI is only reconfigurable if all fields which cannot be changed already match. // Although sharding keys can sometimes be changed via connection.setShardingKey, // the spec does not guarantee that this method will allow all sharding keys // (even ones that are known to be valid) to be set on any connection. It leaves open // the possibility that the JDBC driver implementation can decide not to allow switching // between certain sharding keys. Given that we don't have any way of knowing in // advance that a switching will be accepted (without preemptively trying to change it), // we must consider sharding keys to be non-reconfigurable for the purposes of // selecting a connection from the pool. if (reauth) { return ivConfigID == cri.ivConfigID; } else { return match(ivUserName, cri.ivUserName) && match(ivPassword, cri.ivPassword) && match(ivShardingKey, cri.ivShardingKey) && match(ivSuperShardingKey, cri.ivSuperShardingKey) && ivConfigID == cri.ivConfigID; } }
java
private boolean matchKerberosIdentities(WSConnectionRequestInfoImpl cri) { boolean flag = false; final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(this, tc, "matchKerberosIdentities", this, cri); if (kerberosIdentityisSet && cri.kerberosIdentityisSet) { flag = AdapterUtil.matchGSSName(cri.gssName, gssName); } else if (kerberosIdentityisSet || cri.kerberosIdentityisSet) { // one of them is true, so no match flag = false; if (isTraceOn && tc.isDebugEnabled()) Tr.debug(this, tc, "only one has kerberos identity attributes set so no match"); } else {// else: both are are false thus, match if (isTraceOn && tc.isDebugEnabled()) Tr.debug(this, tc, "both have kerberos identity attributes not set so match"); flag = true; } if (isTraceOn && tc.isEntryEnabled()) Tr.exit(this, tc, "matchKerberosIdentities", flag); return flag; }
java
private static final boolean match(Object obj1, Object obj2) { return obj1 == obj2 || (obj1 != null && obj1.equals(obj2)); }
java
private final boolean matchCatalog(WSConnectionRequestInfoImpl cri) { // At least one of the CRIs should know the default value. String defaultValue = defaultCatalog == null ? cri.defaultCatalog : defaultCatalog; return match(ivCatalog, cri.ivCatalog) || ivCatalog == null && match(defaultValue, cri.ivCatalog) || cri.ivCatalog == null && match(ivCatalog, defaultValue); }
java
private final boolean matchSchema(WSConnectionRequestInfoImpl cri){ // At least one of the CRIs should know the default value. String defaultValue = defaultSchema == null ? cri.defaultSchema : defaultSchema; return match(ivSchema, cri.ivSchema) || ivSchema == null && match(defaultValue, cri.ivSchema) || cri.ivSchema == null && match(ivSchema, defaultValue); }
java
private final boolean matchNetworkTimeout(WSConnectionRequestInfoImpl cri){ // At least one of the CRIs should know the default value. int defaultValue = defaultNetworkTimeout == 0 ? cri.defaultNetworkTimeout : defaultNetworkTimeout; return ivNetworkTimeout == cri.ivNetworkTimeout || ivNetworkTimeout == 0 && (defaultValue == cri.ivNetworkTimeout) || cri.ivNetworkTimeout == 0 && ivNetworkTimeout == defaultValue; }
java
private final boolean matchHoldability(WSConnectionRequestInfoImpl cri) { // At least one of the CRIs should know the default value. int defaultValue = defaultHoldability == 0 ? cri.defaultHoldability : defaultHoldability; return ivHoldability == cri.ivHoldability || ivHoldability == 0 && match(defaultValue, cri.ivHoldability) || cri.ivHoldability == 0 && match(ivHoldability, defaultValue); }
java
private final boolean matchReadOnly(WSConnectionRequestInfoImpl cri) { // At least one of the CRIs should know the default value. Boolean defaultValue = defaultReadOnly == null ? cri.defaultReadOnly : defaultReadOnly; return match(ivReadOnly, cri.ivReadOnly) || ivReadOnly == null && match(defaultValue, cri.ivReadOnly) || cri.ivReadOnly == null && match(ivReadOnly, defaultValue); }
java
private final boolean matchTypeMap(WSConnectionRequestInfoImpl cri) { // At least one of the CRIs should know the default value. Map<String, Class<?>> defaultValue = defaultTypeMap == null ? cri.defaultTypeMap : defaultTypeMap; return matchTypeMap(ivTypeMap, cri.ivTypeMap) || ivTypeMap == null && matchTypeMap(defaultValue, cri.ivTypeMap) || cri.ivTypeMap == null && matchTypeMap(ivTypeMap, defaultValue); }
java
public static final boolean matchTypeMap(Map<String, Class<?>> m1, Map<String, Class<?>> m2) { final boolean isTraceOn = TraceComponent.isAnyTracingEnabled(); if (isTraceOn && tc.isEntryEnabled()) Tr.entry(tc, "matchTypeMap", new Object[] { m1, m2 }); boolean match = false; if (m1 == m2) match = true; else if (m1 != null && m1.equals(m2)) match = true; if (isTraceOn && tc.isEntryEnabled()) Tr.exit(tc, "matchTypeMap", match); return match; }
java
public void setDefaultValues(String catalog, int holdability, Boolean readOnly, Map<String, Class<?>> typeMap, String schema, int networkTimeout) { defaultCatalog = catalog; defaultHoldability = holdability; defaultReadOnly = readOnly; defaultTypeMap = typeMap; defaultSchema = schema; defaultNetworkTimeout = networkTimeout; }
java
public boolean isCRIChangable() { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "isCRIChangable :", changable); return changable; }
java
public void setCatalog(String catalog) throws SQLException { if (!changable) { throw new SQLException(AdapterUtil.getNLSMessage("WS_INTERNAL_ERROR", new Object[] { "ConnectionRequestInfo cannot be modified, doing so may result in corruption: catalog, cri", catalog, this })); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "Setting catalog on the CRI to: " + catalog); ivCatalog = catalog; }
java
public void setHoldability(int holdability) throws SQLException { if (!changable) { throw new SQLException(AdapterUtil.getNLSMessage("WS_INTERNAL_ERROR", new Object[] { "ConnectionRequestInfo cannot be modified, doing so may result in corruption: holdability, cri", holdability, this })); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "Setting holdability on the CRI to: " + holdability); ivHoldability = holdability; }
java
public void setTransactionIsolationLevel(int iso) throws SQLException { if (!changable) { throw new SQLException(AdapterUtil.getNLSMessage("WS_INTERNAL_ERROR", "ConnectionRequestInfo cannot be modified, doing so may result in corruption: iso , cri", iso, this)); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "Setting isolation level on the CRI to:", iso); ivIsoLevel = iso; }
java
public void setReadOnly(boolean readOnly) throws SQLException { if (!changable) { throw new SQLException(AdapterUtil.getNLSMessage("WS_INTERNAL_ERROR", new Object[] { "ConnectionRequestInfo cannot be modified, doing so may result in corruption: readOnly , cri", readOnly, this })); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "Setting read only on the CRI to:", readOnly); ivReadOnly = readOnly; }
java
public void setShardingKey(Object shardingKey) throws SQLException { if (!changable) throw new SQLException(AdapterUtil.getNLSMessage("WS_INTERNAL_ERROR", "ConnectionRequestInfo cannot be modified, doing so may result in corruption: shardingKey, cri", shardingKey, this)); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "Setting sharding key on the CRI to: " + shardingKey); ivShardingKey = shardingKey; }
java
public void setSuperShardingKey(Object superShardingKey) throws SQLException { if (!changable) throw new SQLException(AdapterUtil.getNLSMessage("WS_INTERNAL_ERROR", "ConnectionRequestInfo cannot be modified, doing so may result in corruption: superShardingKey, cri", superShardingKey, this)); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "Setting super sharding key on the CRI to: " + superShardingKey); ivSuperShardingKey = superShardingKey; }
java
public void setTypeMap(Map<String, Class<?>> map) throws SQLException { if (!changable) { throw new SQLException(AdapterUtil.getNLSMessage("WS_INTERNAL_ERROR", new Object[] { "ConnectionRequestInfo cannot be modified, doing so may result in corruption: type map, cri", map, this })); } if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(this, tc, "Setting the type map on the CRI to: " + map); ivTypeMap = map; }
java
public static WSConnectionRequestInfoImpl createChangableCRIFromNon(WSConnectionRequestInfoImpl oldCRI) { WSConnectionRequestInfoImpl connInfo = new WSConnectionRequestInfoImpl( oldCRI.getUserName(), oldCRI.getPassword(), oldCRI.getIsolationLevel(), oldCRI.getCatalog(), oldCRI.isReadOnly(), oldCRI.getShardingKey(), oldCRI.getSuperShardingKey(), oldCRI.getTypeMap(), oldCRI.getHoldability(), oldCRI.getSchema(), oldCRI.getNetworkTimeout(), oldCRI.getConfigID(), oldCRI.getSupportIsolvlSwitchingValue()); connInfo.setDefaultValues(oldCRI.defaultCatalog, oldCRI.defaultHoldability, oldCRI.defaultReadOnly, oldCRI.defaultTypeMap, oldCRI.defaultSchema, oldCRI.defaultNetworkTimeout); connInfo.markAsChangable(); return connInfo; }
java
@Override protected void processAnnotations(Object instance) throws IllegalAccessException, InvocationTargetException, NamingException { if (context == null) { // No resource injection return; } checkAnnotation(instance.getClass(), instance); /* * May be only check non private fields and methods * for @Resource (JSR 250), if used all superclasses MUST be examined * to discover all uses of this annotation. */ Class superclass = instance.getClass().getSuperclass(); while (superclass != null && (!superclass.equals(Object.class))) { checkAnnotation(superclass, instance); superclass = superclass.getSuperclass(); } }
java
protected static void lookupMethodResource(javax.naming.Context context, Object instance, Method method, String name) throws NamingException, IllegalAccessException, InvocationTargetException { if (!method.getName().startsWith("set") || method.getParameterTypes().length != 1 || !method.getReturnType().getName().equals("void")) { throw new IllegalArgumentException("Invalid method resource injection annotation"); } Object lookedupResource; if ((name != null) && (name.length() > 0)) { // TODO local or global JNDI lookedupResource = context.lookup(JAVA_COMP_ENV + name); } else { // TODO local or global JNDI lookedupResource = context.lookup(JAVA_COMP_ENV + instance.getClass().getName() + "/" + getFieldName(method)); } boolean accessibility = method.isAccessible(); method.setAccessible(true); method.invoke(instance, lookedupResource); method.setAccessible(accessibility); }
java
private void _send(SIBusMessage msg, SITransaction tran) throws SISessionUnavailableException, SISessionDroppedException, SIConnectionUnavailableException, SIConnectionDroppedException, SIResourceException, SIConnectionLostException, SILimitExceededException, SIErrorException, SINotAuthorizedException, SIIncorrectCallException, SINotPossibleInCurrentConfigurationException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "_send"); boolean sendSuccessful = false; // Get the message priority short jfapPriority = JFapChannelConstants.getJFAPPriority(msg.getPriority()); if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Sending with JFAP priority of " + jfapPriority); updateLowestPriority(jfapPriority); // *** Complex logic to determine if we can get away we need a reply to *** // *** this send operation. *** final boolean requireReply; if (tran != null && !exchangeTransactedSends) { // If there is a transaction, and we haven't been explicitly told to exchange // transacted sends - then a reply is NOT required. requireReply = false; } else if (exchangeExpressSends) { // We have been prohibited from sending (rather than exchanging) low // qualities of service - thus there is no way that we can avoid requiring // a reply. requireReply = true; } else { // We CAN perform the optimization where low qualities of service can be sent // without requiring a reply. Check the message quality of service. requireReply = (msg.getReliability() != Reliability.BEST_EFFORT_NONPERSISTENT) && (msg.getReliability() != Reliability.EXPRESS_NONPERSISTENT); } // *** end of "is a reply required" logic *** // If we are at FAP9 or above we can do a 'chunked' send of the message in seperate // slices to make life easier on the Java memory manager final HandshakeProperties props = getConversation().getHandshakeProperties(); if (props.getFapLevel() >= JFapChannelConstants.FAP_VERSION_9) { sendChunkedMessage(tran, msg, requireReply, jfapPriority); } else { sendEntireMessage(tran, msg, null, requireReply, jfapPriority); } sendSuccessful = true; if (TraceComponent.isAnyTracingEnabled()) CommsLightTrace.traceMessageId(tc, "SendMsgTrace", msg); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "_send"); }
java
private void sendEntireMessage(SITransaction tran, SIBusMessage msg, List<DataSlice> messageSlices, boolean requireReply, short jfapPriority) throws SIResourceException, SISessionUnavailableException, SINotPossibleInCurrentConfigurationException, SIIncorrectCallException, SIConnectionUnavailableException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "sendEntireMessage", new Object[]{tran, msg, messageSlices, requireReply, jfapPriority}); CommsByteBuffer request = getCommsByteBuffer(); request.putShort(getConnectionObjectID()); request.putShort(getProxyID()); request.putSITransaction(tran); if (messageSlices == null) { request.putClientMessage(msg, getCommsConnection(), getConversation()); } else { request.putMessgeWithoutEncode(messageSlices); } sendData(request, jfapPriority, requireReply, tran, JFapChannelConstants.SEG_SEND_SESS_MSG, JFapChannelConstants.SEG_SEND_SESS_MSG_NOREPLY, JFapChannelConstants.SEG_SEND_SESS_MSG_R); if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "sendEntireMessage"); }
java
private void sendData(CommsByteBuffer request, short jfapPriority, boolean requireReply, SITransaction tran, int outboundSegmentType, int outboundNoReplySegmentType, int replySegmentType) throws SIResourceException, SISessionUnavailableException, SINotPossibleInCurrentConfigurationException, SIIncorrectCallException, SIConnectionUnavailableException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "sendData", new Object[] { request, jfapPriority, requireReply, tran, outboundSegmentType, outboundNoReplySegmentType, replySegmentType }); if (requireReply) { // Pass on call to server CommsByteBuffer reply = jfapExchange(request, outboundSegmentType, jfapPriority, false); try { short err = reply.getCommandCompletionCode(replySegmentType); if (err != CommsConstants.SI_NO_EXCEPTION) { checkFor_SISessionUnavailableException(reply, err); checkFor_SISessionDroppedException(reply, err); checkFor_SIConnectionUnavailableException(reply, err); checkFor_SIConnectionDroppedException(reply, err); checkFor_SIResourceException(reply, err); checkFor_SIConnectionLostException(reply, err); checkFor_SILimitExceededException(reply, err); checkFor_SINotAuthorizedException(reply, err); checkFor_SIIncorrectCallException(reply, err); checkFor_SINotPossibleInCurrentConfigurationException(reply, err); checkFor_SIErrorException(reply, err); defaultChecker(reply, err); } } finally { if (reply != null) reply.release(); } } else { jfapSend(request, outboundNoReplySegmentType, jfapPriority, false, ThrottlingPolicy.BLOCK_THREAD); // Update the lowest priority if (tran != null) { ((Transaction) tran).updateLowestMessagePriority(jfapPriority); } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "sendData"); }
java
public void close() throws SIResourceException, SIConnectionLostException, SIErrorException, SIConnectionDroppedException { if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "close"); // Have we already been closed? if (!isClosed()) { try { closeLock.writeLock().lockInterruptibly(); try { CommsByteBuffer request = getCommsByteBuffer(); // Build Message Header request.putShort(getConnectionObjectID()); request.putShort(getProxyID()); // Pass on call to server CommsByteBuffer reply = jfapExchange(request, JFapChannelConstants.SEG_CLOSE_PRODUCER_SESS, lowestPriority, true); try { short err = reply.getCommandCompletionCode(JFapChannelConstants.SEG_CLOSE_PRODUCER_SESS_R); if (err != CommsConstants.SI_NO_EXCEPTION) { checkFor_SIConnectionDroppedException(reply, err); checkFor_SIResourceException(reply, err); checkFor_SIConnectionLostException(reply, err); checkFor_SIErrorException(reply, err); defaultChecker(reply, err); } } finally { if (reply != null) reply.release(); } setClosed(); if (oc != null) oc.decrementUseCount(); } finally { closeLock.writeLock().unlock(); } } catch (InterruptedException e) { // No FFDC code needed } } if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "close"); }
java
private static Object getFieldValue(FieldClassValue fieldClassValue, Object obj) { try { return fieldClassValue.get(obj.getClass()).get(obj); } catch (IllegalAccessException e) { // FieldClassValueFactory returns ClassValue that make the Field // accessible, so this should not happen. throw new IllegalStateException(e); } }
java
public static WrapperProxyState getLocalBeanWrapperProxyState(LocalBeanWrapperProxy obj) { // F58064 BusinessLocalWrapperProxy proxyStateHolder = (BusinessLocalWrapperProxy) getFieldValue(svLocalBeanWrapperProxyStateFieldClassValue, obj); return proxyStateHolder.ivState; }
java
protected void registerServant() { if (ivRemoteObjectWrapper != null) { // synchronized on the remote Wrapper to set the isRemoteRegistered flag synchronized (ivRemoteObjectWrapper) { if (!isRemoteRegistered) { try { if (!isZOS) // LIDB2775-23.9 { // Servant registration must be performed with the application classloader // in force. This is especially needed for JITDeploy since // the JIT pluggin will be on the application classloader. // Without the JIT pluggin the classloader will not trigger // JITDeploy to create the stub. //d521388 Object originalLoader = ThreadContextAccessor.UNCHANGED; try { if (ivBMD != null) // EJBFactories have no BMD d529446 { originalLoader = EJBThreadData.svThreadContextAccessor.pushContextClassLoaderForUnprivileged(ivBMD.classLoader); //PK83186 if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { if (originalLoader != ThreadContextAccessor.UNCHANGED) { Tr.debug(tc, "registerServant : old ClassLoader = " + originalLoader); Tr.debug(tc, "registerServant : new ClassLoader = " + ivBMD.classLoader); } else { Tr.debug(tc, "registerServant : current ClassLoader = " + ivBMD.classLoader); } } } ivRemoteObjectWrapper.container.getEJBRuntime().registerServant(ivRemoteObjectWrapper.beanId.getByteArray(), ivRemoteObjectWrapper); } finally { EJBThreadData.svThreadContextAccessor.popContextClassLoaderForUnprivileged(originalLoader); } // finally } // if( !isZOS ) isRemoteRegistered = true; } catch (Exception ex) { FFDCFilter.processException(ex, CLASS_NAME + ".registerServant", "184", this); if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(tc, "Failed to register wrapper instance", new Object[] { ivRemoteObjectWrapper, ex }); } } } // if ( !isRemoteRegistered ) } // synchronized( ivRemoteObject ) } // if ( ivRemoteObject != null ) }
java
private void registerServant(BusinessRemoteWrapper wrapper, int i) { // synchronized on the remote Wrapper to set the isRemoteRegistered flag synchronized (wrapper) { if (!ivBusinessRemoteRegistered[i]) { try { if (!isZOS) { // Since there may be multiple remote interfaces per bean // type, a unique WrapperId must be formed by combining the // BeanId with specific remote interface information. d419704 WrapperId wrapperId = new WrapperId (wrapper.beanId.getByteArrayBytes(), wrapper.bmd.ivBusinessRemoteInterfaceClasses[i].getName(), i); // Servant registration must be performed with the application classloader // in force. This is especially needed for JITDeploy since // the JIT pluggin will be on the application classloader. // Without the JIT pluggin the classloader will not trigger // JITDeploy to create the stub. //d521388 Object originalLoader = ThreadContextAccessor.UNCHANGED; try { if (ivBMD != null) // EJBFactories have no BMD. d529446 { originalLoader = EJBThreadData.svThreadContextAccessor.pushContextClassLoaderForUnprivileged(ivBMD.classLoader); //PK83186 if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { if (originalLoader != ThreadContextAccessor.UNCHANGED) { Tr.debug(tc, "registerServant : old ClassLoader = " + originalLoader); Tr.debug(tc, "registerServant : new ClassLoader = " + ivBMD.classLoader); } else { Tr.debug(tc, "registerServant : current ClassLoader = " + ivBMD.classLoader); } } } wrapper.container.getEJBRuntime().registerServant(wrapperId, wrapper); } finally { EJBThreadData.svThreadContextAccessor.popContextClassLoaderForUnprivileged(originalLoader); } // finally } // if( !isZOS ) ivBusinessRemoteRegistered[i] = true; } catch (Throwable ex) { FFDCFilter.processException(ex, CLASS_NAME + ".registerServant", "439", this); if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(tc, "Failed to register wrapper instance", new Object[] { wrapper, ex }); } } } // if ( ! ivBusinessRemoteRegistered[i] ) } //synchronized( wrapper ) }
java
protected void disconnect() { if (localWrapperProxyState != null) // F58064 { localWrapperProxyState.disconnect(); } if (ivBusinessLocalWrapperProxyStates != null) // F58064 { for (WrapperProxyState state : ivBusinessLocalWrapperProxyStates) { state.disconnect(); } } if (ivRemoteObjectWrapper != null) { // synchronized on the remote Wrapper to set the isRemoteRegistered flag synchronized (ivRemoteObjectWrapper) { if (isRemoteRegistered) { try { // @PQ98903A // On zOS even though we don't call the object // adapter to register the servant, we need // to call it to unregister it if the wrapper // is connected to the ORB (i.e. it has a Tie). if ((!isZOS) || (ivRemoteObjectWrapper.intie != null)) // @PQ98903C { ivRemoteObjectWrapper.container.getEJBRuntime().unregisterServant(ivRemoteObjectWrapper); } isRemoteRegistered = false; } catch (Exception ex) { FFDCFilter.processException(ex, CLASS_NAME + ".unregisterServant", "207", this); if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(tc, "Failed to unregister wrapper instance", new Object[] { ivRemoteObjectWrapper, ex }); } } } } } // d416391 start // Unregister any BusinessRemoteWrapper objects that are registered with ORB. if (ivBusinessRemote != null) // d416391 d424839 { int numWrappers = ivBusinessRemote.length; for (int i = 0; i < numWrappers; ++i) { BusinessRemoteWrapper wrapper = ivBusinessRemote[i]; synchronized (wrapper) { if (ivBusinessRemoteRegistered[i]) { try { // On zOS even though we don't call the object adapter to register // the servant, we need to call it to unregister it if the wrapper // is connected to the ORB (i.e. it has a Tie). if ((!isZOS) || (wrapper.intie != null)) { wrapper.container.getEJBRuntime().unregisterServant(wrapper); } ivBusinessRemoteRegistered[i] = false; } catch (Throwable ex) { FFDCFilter.processException(ex, CLASS_NAME + ".unregisterServant", "516", this); if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) { Tr.event(tc, "Failed to unregister wrapper instance", new Object[] { wrapper, ex }); } } } } // end synchronized } // end for } // d416391 end }
java
public EJBLocalObject getLocalObject() { if (localObject != null) { if (localWrapperProxyState != null && localWrapperProxyState.ivWrapper == null) { localWrapperProxyState.connect(ivBeanId, localWrapper); } return localObject; } throw new IllegalStateException("Local interface not defined"); }
java
public Object getBusinessObject(String interfaceName) throws RemoteException { int interfaceIndex = ivBMD.getLocalBusinessInterfaceIndex(interfaceName); if (interfaceIndex != -1) { return getLocalBusinessObject(interfaceIndex); } interfaceIndex = ivBMD.getRemoteBusinessInterfaceIndex(interfaceName); if (interfaceIndex != -1) { return getRemoteBusinessObject(interfaceIndex); } throw new IllegalStateException("Requested business interface not found : " + interfaceName); }
java
public Object getLocalBusinessObject(int interfaceIndex) { if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "getLocalBusinessObject : " + ivBusinessLocalProxies[interfaceIndex].getClass().getName()); if (ivBusinessLocalWrapperProxyStates != null && ivBusinessLocalWrapperProxyStates[interfaceIndex].ivWrapper == null) { ivBusinessLocalWrapperProxyStates[interfaceIndex].connect(ivBeanId, ivBusinessLocal[interfaceIndex]); } return ivBusinessLocalProxies[interfaceIndex]; }
java
public EJSWrapperBase getLocalBusinessWrapperBase(int interfaceIndex) { if (interfaceIndex == 0 && ivBMD.ivLocalBean) { return getLocalBeanWrapperBase((LocalBeanWrapper) ivBusinessLocal[0]); } return (EJSWrapperBase) ivBusinessLocal[0]; }
java
public Object getRemoteBusinessObject(int interfaceIndex) throws RemoteException { Class<?>[] bInterfaceClasses = ivBMD.ivBusinessRemoteInterfaceClasses; BusinessRemoteWrapper wrapper = ivBusinessRemote[interfaceIndex]; if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) Tr.debug(tc, "getRemoteBusinessObject : " + wrapper.getClass().getName()); registerServant(wrapper, interfaceIndex); ClassLoader moduleContextClassLoader = ivBMD.ivContextClassLoader; Object result = getRemoteBusinessReference(wrapper, moduleContextClassLoader, bInterfaceClasses[interfaceIndex]); return result; }
java
public BusinessRemoteWrapper getRemoteBusinessWrapper(WrapperId wrapperId) { int remoteIndex = wrapperId.ivInterfaceIndex; BusinessRemoteWrapper wrapper = null; String wrapperInterfaceName = ""; if (remoteIndex < ivBusinessRemote.length) { wrapper = ivBusinessRemote[remoteIndex]; wrapperInterfaceName = ivBMD.ivBusinessRemoteInterfaceClasses[remoteIndex].getName(); } // Is the BusinessRemoteWrapper for the correct interface name? String interfaceName = wrapperId.ivInterfaceClassName; if ((wrapper == null) || (!wrapperInterfaceName.equals(interfaceName))) { // Nope, index must be invalid, so we need to search the entire // array to find the one that matches the desired interface name. // Fix up the WrapperId with index that matches this server. wrapper = null; for (int i = 0; i < ivBusinessRemote.length; ++i) { wrapperInterfaceName = ivBMD.ivBusinessRemoteInterfaceClasses[i].getName(); if (wrapperInterfaceName.equals(interfaceName)) { // This is the correct wrapper. remoteIndex = i; wrapper = ivBusinessRemote[remoteIndex]; wrapperId.ivInterfaceIndex = remoteIndex; break; } } // d739542 Begin if (wrapper == null) { throw new IllegalStateException("Remote " + interfaceName + " interface not defined"); } // d739542 End } registerServant(wrapper, remoteIndex); return wrapper; }
java
private String getAliasToFinalize(CMConfigData cmConfigData) { String alias = null; if (cmConfigData == null) return alias; // Not expected, but being safe // Check for DefaultPrincipalMapping alias from res-ref: final String DEFAULT_PRINCIPAL_MAPPING = "DefaultPrincipalMapping"; final String MAPPING_ALIAS = "com.ibm.mapping.authDataAlias"; String loginConfigurationName = cmConfigData.getLoginConfigurationName(); if ((loginConfigurationName != null) && (!loginConfigurationName.equals(""))) { if (loginConfigurationName.equals(DEFAULT_PRINCIPAL_MAPPING)) { HashMap loginConfigProps = cmConfigData.getLoginConfigProperties(); if ((loginConfigProps != null) && (!loginConfigProps.isEmpty())) { alias = (String) loginConfigProps.get(MAPPING_ALIAS); } } } if (alias == null) { // Check for container-managed auth alias from CF/DS: alias = cmConfigData.getContainerAlias(); } return alias; }
java
private Set getPrivateGenericCredentials(final Subject subj) throws ResourceException { Set privateGenericCredentials = null; if (System.getSecurityManager() != null) { try { privateGenericCredentials = (Set) AccessController.doPrivileged( new PrivilegedExceptionAction() { @Override public Object run() throws Exception { return subj.getPrivateCredentials(GenericCredential.class); } }); } catch (PrivilegedActionException pae) { FFDCFilter.processException(pae, "com.ibm.ejs.j2c.ThreadIdentitySecurityHelper.beforeGettingConnection", "18", this); Tr.error(tc, "FAILED_DOPRIVILEGED_J2CA0060", pae); Exception e = pae.getException(); ResourceException re = new ResourceException("ThreadIdentitySecurityHelper failed attempting to access Subject's credentials"); re.initCause(e); throw re; } } else { privateGenericCredentials = subj.getPrivateCredentials(GenericCredential.class); } return privateGenericCredentials; }
java
private Object setJ2CThreadIdentity(final Subject subj) throws ResourceException { Object retObject = null; try { if (System.getSecurityManager() != null) { retObject = AccessController.doPrivileged( new PrivilegedExceptionAction() { @Override public Object run() throws Exception { return ThreadIdentityManager.setJ2CThreadIdentity(subj); } }); } else { retObject = ThreadIdentityManager.setJ2CThreadIdentity(subj); } } catch (PrivilegedActionException pae) { FFDCFilter.processException(pae, "com.ibm.ejs.j2c.ThreadIdentitySecurityHelper.beforeGettingConnection", "11", this); Tr.error(tc, "FAILED_DOPRIVILEGED_J2CA0060", pae); Exception e = pae.getException(); ResourceException re = new ResourceException("ThreadIdentitySecurityHelper.beforeGettingConnection() failed attempting to push the current user identity to the OS Thread"); re.initCause(e); throw re; } catch (IllegalStateException ise) { FFDCFilter.processException(ise, "com.ibm.ejs.j2c.ThreadIdentitySecurityHelper.beforeGettingConnection", "20", this); Object[] parms = new Object[] { "ThreadIdentitySecurityHelper.beforeGettingConnection()", ise }; Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", parms); ResourceException re = new ResourceException("ThreadIdentitySecurityHelper.beforeGettingConnection() failed attempting to push the current user identity to the OS Thread"); re.initCause(ise); throw re; } catch (ThreadIdentityException tie) { FFDCFilter.processException(tie, "com.ibm.ejs.j2c.ThreadIdentitySecurityHelper.beforeGettingConnection", "21", this); ResourceException re = new ResourceException("ThreadIdentitySecurityHelper.beforeGettingConnection() failed attempting to push the current user identity to the OS Thread"); re.initCause(tie); throw re; } return retObject; }
java
private void checkForUTOKENNotFoundError(Subject subj) throws ResourceException { // A Subject without a UTOKEN genericCredential can // legitimately occur in the case where the resource // adapter has indicated Thread Identity Support // is "ALLOWED, but a valid Container-managed alias // was specified. On the other hand, at this ponit, if // either of the following two cases exist when there is // no UTOKEN genericCredential, then we have an // unexpected error and need to throw an exception: // // 1. The resource adapter REQUIRES that Thread Identity // be used. // // 2. The Subject has no private credentials at all // // Check if ThreadIdentitySupport is "REQUIRED" if (m_ThreadIdentitySupport == AbstractConnectionFactoryService.THREAD_IDENTITY_REQUIRED) { // ThreadIdentitySupport indicates that the use of thread // identity is "REQUIRED" by the connector, but the // Subject doesn't contain a UTOKEN GenericCredential. // This should not ever occur because finalizeSubject() // should have created a Subject with a UTOKEN // GenericCredential when ThreadidentitySupport is // "REQUIRED". Thus, throw an exception to terminate // processing right here. // try { IllegalStateException e = new IllegalStateException("ThreadIdentitySecurityHelper.beforeGettingConnection() detected Subject not setup for using thread identity, but the connector requires thread identity be used."); Object[] parms = new Object[] { "ThreadIdentitySecurityHelper.beforeGettingConnection()", e }; Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", parms); throw e; } catch (IllegalStateException ise) { ResourceException re = new ResourceException("ThreadIdentitySecurityHelper.beforeGettingConnection() detected Subject with illegal state"); re.initCause(ise); throw re; } } // end if m_ThreadIdentitySupport.equals REQUIRED // Check if Subject has at least one a private credential Set privateCredentials = subj.getPrivateCredentials(); Iterator privateIterator = privateCredentials.iterator(); if (!privateIterator.hasNext()) { // if no private credentials // There is not only no UTOKEN generic credential, but // also, there are no private credentials at all. This // should not happen. If there are no private credentials, // the finalizeSubject() processing should have built // a UTOKEN generic credential. // try { IllegalStateException e = new IllegalStateException("ThreadIdentitySecurityHelper.beforeGettingConnection() detected Subject with no credentials."); Object[] parms = new Object[] { "ThreadIdentitySecurityHelper.beforeGettingConnection()", e }; Tr.error(tc, "ILLEGAL_STATE_EXCEPTION_J2CA0079", parms); throw e; } catch (IllegalStateException ise) { ResourceException re = new ResourceException("ThreadIdentitySecurityHelper.beforeGettingConnection() detected Subject with illegal state"); re.initCause(ise); throw re; } } // end if no private credentials }
java
protected void copyStreams(InputStream is, OutputStream os) throws IOException { byte[] buffer = new byte[1024]; try { int read; while ((read = is.read(buffer)) != -1) { os.write(buffer, 0, read); buffer = new byte[1024]; } } finally { if (null != os) os.close(); if (null != is) is.close(); } }
java
protected ExtractedFileInformation extractFileFromArchive(String fileName, String regex) throws RepositoryArchiveException, RepositoryArchiveEntryNotFoundException, RepositoryArchiveIOException { JarFile jarFile = null; ExtractedFileInformation result = null; File outputFile = null; File sourceArchive = new File(fileName); try { try { jarFile = new JarFile(sourceArchive); } catch (FileNotFoundException | NoSuchFileException fne) { throw new RepositoryArchiveException("Unable to locate archive " + fileName, sourceArchive, fne); } catch (IOException ioe) { throw new RepositoryArchiveIOException("Error opening archive ", sourceArchive, ioe); } Enumeration<JarEntry> enumEntries = jarFile.entries(); // Iterate through the files in the jar file searching for one we // are interested in while (enumEntries.hasMoreElements()) { JarEntry entry = enumEntries.nextElement(); String name = entry.getName(); if (Pattern.matches(regex, name)) { // Don't want to use the entire path to the file so create a // file // and then recreate it using just the "name" part of the // filename outputFile = new File(name); outputFile = new File(outputFile.getName()); outputFile.deleteOnExit(); try { copyStreams(jarFile.getInputStream(entry), new FileOutputStream(outputFile)); } catch (IOException ioe) { throw new RepositoryArchiveIOException("Failed to extract file " + name + " inside " + fileName + " to " + outputFile.getAbsolutePath(), sourceArchive, ioe); } result = new ExtractedFileInformation(outputFile, sourceArchive, name); break; } } } finally { try { if (null != jarFile) { jarFile.close(); } } catch (IOException e) { e.printStackTrace(); throw new RepositoryArchiveIOException("Error closing archive ", sourceArchive, e); } } // Make sure we have found a file if (null == outputFile) { throw new RepositoryArchiveEntryNotFoundException("Failed to find file matching regular expression <" + regex + "> inside archive " + fileName, sourceArchive, regex); } return result; }
java
protected void processLAandLI(File archive, RepositoryResourceWritable resource, ProvisioningFeatureDefinition feature) throws IOException, RepositoryException { String LAHeader = feature.getHeader(LA_HEADER_FEATURE); String LIHeader = feature.getHeader(LI_HEADER_FEATURE); processLAandLI(archive, resource, LAHeader, LIHeader); }
java