code
stringlengths 73
34.1k
| label
stringclasses 1
value |
|---|---|
public boolean containsValue(Object value) throws ObjectManagerException {
if (getRoot() != null)
return containsValue(getRoot(), value);
return false;
}
|
java
|
public Set entrySet() throws ObjectManagerException {
return new AbstractSetView() {
public long size() {
return size;
}
public boolean contains(Object object) throws ObjectManagerException {
if (object instanceof Map.Entry) {
Map.Entry entry = (Map.Entry) object;
Object v1 = get(entry.getKey()), v2 = entry.getValue();
return v1 == null ? v2 == null : v1.equals(v2);
}
return false;
}
public Iterator iterator() throws ObjectManagerException {
return makeTreeMapIterator(new AbstractMapEntry.Type() {
public Object get(AbstractMapEntry entry) {
return entry;
}
});
}
};
}
|
java
|
public Object get(Object key) throws ObjectManagerException {
Entry node = find(key);
if (node != null)
return node.value;
return null;
}
|
java
|
public SortedMap headMap(Object endKey) {
// Check for errors
if (comparator == null)
((Comparable) endKey).compareTo(endKey);
else
comparator.compare(endKey, endKey);
return makeSubMap(null, endKey);
}
|
java
|
public Collection keyCollection() {
if (keyCollection == null) {
keyCollection = new AbstractCollectionView() {
public long size() throws ObjectManagerException {
return AbstractTreeMap.this.size();
}
public Iterator iterator() throws ObjectManagerException {
return makeTreeMapIterator(
new AbstractMapEntry.Type() {
public Object get(AbstractMapEntry entry) {
return entry.key;
}
});
}
};
}
return keyCollection;
}
|
java
|
public Object remove(Object key) throws ObjectManagerException {
Entry node = find(key);
if (node == null)
return null;
Object result = node.value;
rbDelete(node);
return result;
}
|
java
|
public SortedMap subMap(Object startKey, Object endKey) {
if (comparator == null) {
if (((Comparable) startKey).compareTo(endKey) <= 0)
return makeSubMap(startKey, endKey);
} else {
if (comparator.compare(startKey, endKey) <= 0)
return makeSubMap(startKey, endKey);
}
throw new IllegalArgumentException();
}
|
java
|
public SortedMap tailMap(Object startKey) {
// Check for errors
if (comparator == null)
((Comparable) startKey).compareTo(startKey);
else
comparator.compare(startKey, startKey);
return makeSubMap(startKey, null);
}
|
java
|
public Collection values() {
if (values == null) {
values = new AbstractCollectionView() {
public long size() throws ObjectManagerException {
return AbstractTreeMap.this.size();
}
public Iterator iterator() throws ObjectManagerException {
return makeTreeMapIterator(new AbstractMapEntry.Type() {
public Object get(AbstractMapEntry entry) {
return entry.getValue();
}
});
}
};
}
return values;
}
|
java
|
public static void assignMongoServers(LibertyServer libertyServer) throws Exception {
MongoServerSelector mongoServerSelector = new MongoServerSelector(libertyServer);
mongoServerSelector.updateLibertyServerMongos();
}
|
java
|
private Map<String, List<MongoElement>> getMongoElements() throws Exception {
for (MongoElement mongo : serverConfig.getMongos()) {
addMongoElementToMap(mongo);
}
for (MongoDBElement mongoDB : serverConfig.getMongoDBs()) {
if (mongoDB.getMongo() != null) {
addMongoElementToMap(mongoDB.getMongo());
}
}
return mongoElements;
}
|
java
|
private void updateMongoElements(String serverPlaceholder, ExternalTestService mongoService) {
Integer[] port = { Integer.valueOf(mongoService.getPort()) };
for (MongoElement mongo : mongoElements.get(serverPlaceholder)) {
mongo.setHostNames(mongoService.getAddress());
mongo.setPorts(port);
String user = mongo.getUser();
if (user != null) {
String replacementPassword = mongoService.getProperties().get(user + "_password");
if (replacementPassword != null) {
mongo.setPassword(replacementPassword);
}
}
}
}
|
java
|
private static boolean validateMongoConnection(ExternalTestService mongoService) {
String method = "validateMongoConnection";
MongoClient mongoClient = null;
String host = mongoService.getAddress();
int port = mongoService.getPort();
File trustStore = null;
MongoClientOptions.Builder optionsBuilder = new MongoClientOptions.Builder().connectTimeout(30000);
try {
trustStore = File.createTempFile("mongoTrustStore", "jks");
Map<String, String> serviceProperties = mongoService.getProperties();
String password = serviceProperties.get(TEST_USERNAME + "_password"); // will be null if there's no auth for this server
SSLSocketFactory sslSocketFactory = null;
try {
mongoService.writePropertyAsFile("ca_truststore", trustStore);
sslSocketFactory = getSocketFactory(trustStore);
} catch (IllegalStateException e) {
// Ignore exception thrown if truststore is not present for this server
// This indicates that we are not using SSL for this server and sslSocketFactory will be null
}
if (sslSocketFactory != null) {
optionsBuilder.socketFactory(sslSocketFactory);
}
MongoClientOptions clientOptions = optionsBuilder.build();
List<MongoCredential> credentials = Collections.emptyList();
if (password != null) {
MongoCredential credential = MongoCredential.createCredential(TEST_USERNAME, TEST_DATABASE, password.toCharArray());
credentials = Collections.singletonList(credential);
}
Log.info(c, method,
"Attempting to contact server " + host + ":" + port + " with password " + (password != null ? "set" : "not set") + " and truststore "
+ (sslSocketFactory != null ? "set" : "not set"));
mongoClient = new MongoClient(new ServerAddress(host, port), credentials, clientOptions);
mongoClient.getDB("default").getCollectionNames();
mongoClient.close();
} catch (Exception e) {
Log.info(c, method, "Couldn't create a connection to " + mongoService.getServiceName() + " on " + mongoService.getAddress() + ". " + e.toString());
mongoService.reportUnhealthy("Couldn't connect to server. Exception: " + e.toString());
return false;
} finally {
if (trustStore != null) {
trustStore.delete();
}
}
return true;
}
|
java
|
private static SSLSocketFactory getSocketFactory(File trustStore) throws KeyStoreException, FileNotFoundException, IOException, NoSuchAlgorithmException, CertificateException, KeyManagementException {
KeyStore keystore = KeyStore.getInstance("JKS");
InputStream truststoreInputStream = null;
try {
truststoreInputStream = new FileInputStream(trustStore);
keystore.load(truststoreInputStream, KEYSTORE_PW);
} finally {
if (truststoreInputStream != null) {
truststoreInputStream.close();
}
}
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("PKIX");
trustManagerFactory.init(keystore);
TrustManager[] trustMangers = trustManagerFactory.getTrustManagers();
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, trustMangers, null);
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
return sslSocketFactory;
}
|
java
|
public static Locale converterTagLocaleFromString(String name)
{
try
{
Locale locale;
StringTokenizer st = new StringTokenizer(name, "_");
String language = st.nextToken();
if(st.hasMoreTokens())
{
String country = st.nextToken();
if(st.hasMoreTokens())
{
String variant = st.nextToken();
locale = new Locale(language, country, variant);
}
else
{
locale = new Locale(language, country);
}
}
else
{
locale = new Locale(language);
}
return locale;
}
catch(Exception e)
{
throw new IllegalArgumentException("Locale parsing exception - " +
"invalid string representation '" + name + "'");
}
}
|
java
|
public void incrementHeadSequenceNumber(ConcurrentSubList.Link link)
throws ObjectManagerException
{
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.entry(this,
cclass,
"incrementheadSequenceNumber",
new Object[] { link });
if (link.next == null) { // This subList is now empty.
headSequenceNumber++; // Look at another list next time.
} else { // Still more links in this subList.
ConcurrentSubList.Link nextLink = (ConcurrentSubList.Link) link.next.getManagedObject();
// If insertion into the body of the list has taken place,
// then a sequenceNumber will have been duplicated.
if (nextLink.sequenceNumber != headSequenceNumber)
headSequenceNumber++;
} // if( firstLink.next == null).
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.exit(this,
cclass,
"incrementHeadSequenceNumber",
new Object[] { new Long(headSequenceNumber) });
}
|
java
|
private void resetTailSequenceNumber()
throws ObjectManagerException
{
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.entry(this, cclass
, "resetTailSequenceNumber"
);
for (int i = 0; i < subListTokens.length; i++) {
subLists[i] = ((ConcurrentSubList) subListTokens[i].getManagedObject());
// In case another thread is currently removing the tail, take a safe copy.
Token tailToken = subLists[i].tail;
// Establish the highest existing tailSequenceNumber.
if (tailToken != null) {
ConcurrentSubList.Link tail = (ConcurrentSubList.Link) tailToken.getManagedObject();
tailSequenceNumber = Math.max(tailSequenceNumber,
tail.sequenceNumber);
} // if (tailToken != null).
} // for subList.
tailSequenceNumberSet = true;
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.exit(this, cclass
, "resetHeadSequenceNumber"
);
}
|
java
|
protected ConcurrentSubList.Link insert(Token token,
ConcurrentSubList.Link insertPoint,
Transaction transaction)
throws ObjectManagerException
{
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.entry(this, cclass,
"insert",
new Object[] { token, insertPoint, transaction });
ConcurrentSubList.Link newLink = null;
synchronized (transaction.internalTransaction) {
// Establish the sequenceNumber of this Object in the overall list,
// before the insert point.
long sequenceNumber = insertPoint.sequenceNumber;
sequenceNumber--;
// Figure out which subList the Object should be added to.
ConcurrentSubList list = getSublist(sequenceNumber);
// Add the link near the tail of the list according to its assigned
// sequence number.
tailSequenceNumberLock.lock();
try {
newLink = list.addEntry(token,
transaction,
sequenceNumber,
this);
} finally {
if (tailSequenceNumberLock.isHeldByCurrentThread())
tailSequenceNumberLock.unlock();
} // try (tailSequenceNumberLock).
} // synchronized (transaction.internalTransaction).
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.exit(this, cclass,
"insert",
new Object[] { newLink });
return newLink;
}
|
java
|
public void activate(ComponentContext compcontext, Map<String, Object> properties) {
String methodName = "activate";
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Activating the WebContainer bundle");
}
WebContainer.instance.set(this);
this.context = compcontext;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Default Port [ " + DEFAULT_PORT + " ]");
Tr.debug(tc, methodName, "Default Virtual Host [ " + DEFAULT_VHOST_NAME + " ]");
}
WebContainerConfiguration webconfig = new WebContainerConfiguration(DEFAULT_PORT);
webconfig.setDefaultVirtualHostName(DEFAULT_VHOST_NAME);
this.initialize(webconfig, properties);
this.classLoadingSRRef.activate(context);
this.sessionHelperSRRef.activate(context);
this.cacheManagerSRRef.activate(context);
this.injectionEngineSRRef.activate(context);
this.managedObjectServiceSRRef.activate(context);
this.servletContainerInitializers.activate(context);
this.transferContextServiceRef.activate(context);
this.webMBeanRuntimeServiceRef.activate(context);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Object mbeanService = context.locateService(REFERENCE_WEB_MBEAN_RUNTIME);
Tr.debug(tc, methodName, "Web MBean Runtime [ " + mbeanService + " ]");
Tr.debug(tc, methodName, "Web MBean Runtime Reference [ " + webMBeanRuntimeServiceRef.getReference() + " ]");
Tr.debug(tc, methodName, "Web MBean Runtime Service [ " + webMBeanRuntimeServiceRef.getService() + " ]");
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Posting STARTED_EVENT");
}
Event event = this.eventService.createEvent(WebContainerConstants.STARTED_EVENT);
this.eventService.postEvent(event);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Posted STARTED_EVENT");
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Activating the WebContainer bundle: Complete");
}
}
|
java
|
@FFDCIgnore(Exception.class)
public void deactivate(ComponentContext componentContext) {
String methodName = "deactivate";
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "Deactivating the WebContainer bundle");
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Posting STOPPED_EVENT");
}
Event event = this.eventService.createEvent(WebContainerConstants.STOPPED_EVENT);
this.eventService.postEvent(event);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Posted STOPPED_EVENT");
}
this.classLoadingSRRef.deactivate(componentContext);
this.sessionHelperSRRef.deactivate(componentContext);
this.cacheManagerSRRef.deactivate(componentContext);
this.injectionEngineSRRef.deactivate(componentContext);
this.managedObjectServiceSRRef.deactivate(context);
this.servletContainerInitializers.deactivate(componentContext);
this.transferContextServiceRef.deactivate(componentContext);
this.webMBeanRuntimeServiceRef.deactivate(componentContext);
// will now purge each host as it becomes redundant rather than all here.
//this.vhostManager.purge(); // Clear/purge all maps.
WebContainer.instance.compareAndSet(this, null);
extensionFactories.clear();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Deactivating the WebContainer bundle: Complete");
}
}
|
java
|
@Reference(service=ClassLoadingService.class, name="classLoadingService")
protected void setClassLoadingService(ServiceReference<ClassLoadingService> ref) {
classLoadingSRRef.setReference(ref);
}
|
java
|
@Reference(policy=ReferencePolicy.DYNAMIC)
protected void setEncodingService(EncodingUtils encUtils) {
encodingServiceRef.set(encUtils);
}
|
java
|
@Reference(service=SessionHelper.class, name="sessionHelper")
protected void setSessionHelper(ServiceReference<SessionHelper> ref) {
sessionHelperSRRef.setReference(ref);
}
|
java
|
@Override
public ModuleMetaData createModuleMetaData(ExtendedModuleInfo moduleInfo) throws MetaDataException {
WebModuleInfo webModule = (WebModuleInfo) moduleInfo;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "createModuleMetaData: " + webModule.getName() + " " + webModule.getContextRoot());
}
try {
com.ibm.wsspi.adaptable.module.Container webModuleContainer = webModule.getContainer();
WebAppConfiguration appConfig = webModuleContainer.adapt(WebAppConfiguration.class);
String appName = appConfig.getApplicationName();
String j2eeModuleName = appConfig.getJ2EEModuleName();
WebModuleMetaDataImpl wmmd = (WebModuleMetaDataImpl) appConfig.getMetaData();
wmmd.setJ2EEName(j2eeNameFactory.create(appName, j2eeModuleName, null));
appConfig.setWebApp(createWebApp(moduleInfo, appConfig));
return wmmd;
}
catch (Throwable e) {
Throwable cause = e.getCause();
MetaDataException m;
if ((cause!=null) && (cause instanceof MetaDataException)) {
m = (MetaDataException) cause;
//don't log a FFDC here as we already logged an exception
} else {
m = new MetaDataException(e);
FFDCWrapper.processException(e, getClass().getName(), "createModuleMetaData", new Object[] { webModule, this });//this throws the exception
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "createModuleMetaData: " + webModule.getName() + "; " + e);
}
throw m;
}
}
|
java
|
protected void registerMBeans(WebModuleMetaDataImpl webModule, com.ibm.wsspi.adaptable.module.Container container) {
String methodName = "registerMBeans";
String appName = webModule.getApplicationMetaData().getName();
String webAppName = webModule.getName();
String debugName;
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
debugName = appName + " " + webAppName;
} else {
debugName = null;
}
WebMBeanRuntime mBeanRuntime = webMBeanRuntimeServiceRef.getService();
if (mBeanRuntime == null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Web Module [ " + debugName + " ]: No MBean Runtime");
}
return;
} else {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Web Module [ " + debugName + " ]: MBean Runtime");
}
}
String ddPath = com.ibm.ws.javaee.dd.web.WebApp.DD_NAME; // This should be obtained by an adapt call.
Iterator<IServletConfig> servletConfigs = webModule.getConfiguration().getServletInfos();
webModule.mBeanServiceReg = mBeanRuntime.registerModuleMBean(appName, webAppName, container, ddPath, servletConfigs);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Web Module [ " + debugName + " ]: Registration [ " + webModule.mBeanServiceReg + " ]");
}
servletConfigs = webModule.getConfiguration().getServletInfos();
while (servletConfigs.hasNext()) {
IServletConfig servletConfig = servletConfigs.next();
String servletName = servletConfig.getServletName();
WebComponentMetaDataImpl wcmdi = (WebComponentMetaDataImpl) servletConfig.getMetaData();
wcmdi.mBeanServiceReg = mBeanRuntime.registerServletMBean(appName, webAppName, servletName);
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Web Module [ " + debugName + " ] Servlet [ " + servletName + " ]: Registration [ " + wcmdi.mBeanServiceReg + " ]");
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, methodName, "Web Module [ " + debugName + " ]: Completed registrations");
}
}
|
java
|
public void stopModule(ExtendedModuleInfo moduleInfo) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.entry(tc, "stopModule()",((WebModuleInfo)moduleInfo).getName());
}
WebModuleInfo webModule = (WebModuleInfo) moduleInfo;
try {
DeployedModule dMod = this.deployedModuleMap.remove(webModule);
if (null == dMod) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "stopModule()","DeployedModule not known");
}
return;
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "stopModule: " + webModule.getName() + " " + webModule.getContextRoot());
}
removeContextRootRequirement(dMod);
removeModule(dMod);
this.vhostManager.purgeHost(dMod.getVirtualHostName());
WebModuleMetaData wmmd = (WebModuleMetaData) ((ExtendedModuleInfo)webModule).getMetaData();
deregisterMBeans((WebModuleMetaDataImpl) wmmd);
WebAppConfiguration appConfig = (WebAppConfiguration) wmmd.getConfiguration();
for (Iterator<IServletConfig> servletConfigs = appConfig.getServletInfos(); servletConfigs.hasNext();) {
IServletConfig servletConfig = servletConfigs.next();
metaDataService.fireComponentMetaDataDestroyed(servletConfig.getMetaData());
}
metaDataService.fireComponentMetaDataDestroyed(appConfig.getDefaultComponentMetaData());
metaDataService.fireComponentMetaDataDestroyed(wmmd.getCollaboratorComponentMetaData());
} catch (Throwable e) {
FFDCWrapper.processException(e, getClass().getName(), "stopModule", new Object[] { webModule, this });
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "stopModule: " + webModule.getName() + "; " + e);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
Tr.exit(tc, "stopModule()");
}
}
|
java
|
@Reference(cardinality=ReferenceCardinality.MANDATORY, policy=ReferencePolicy.DYNAMIC, policyOption=ReferencePolicyOption.GREEDY)
protected void setConnContextPool(SRTConnectionContextPool pool) {
this.connContextPool = pool;
}
|
java
|
public void refreshEntry(com.ibm.wsspi.cache.CacheEntry ce){
cacheInstance.refreshEntry(ce.cacheEntry);
}
|
java
|
public CacheEntry getEntryDisk(Object cacheId) {
CacheEntry cacheEntry = new CacheEntry(cacheInstance.getEntryDisk(cacheId));
return cacheEntry;
}
|
java
|
public com.ibm.wsspi.cache.CacheEntry getEntry(Object cacheId){
CacheEntry cacheEntry = new CacheEntry(cacheInstance.getEntry(cacheId));
return cacheEntry;
}
|
java
|
public static Object[] getEncoding(JspInputSource inputSource)
throws IOException, JspCoreException
{
InputStream inStream = XMLEncodingDetector.getInputStream(inputSource);
//InputStream inStream = JspUtil.getInputStream(fname, jarFile, ctxt,
// err);
XMLEncodingDetector detector = new XMLEncodingDetector();
Object[] ret = detector.getEncoding(inStream);
inStream.close();
return ret;
}
|
java
|
private Reader createReader(InputStream inputStream, String encoding,
Boolean isBigEndian)
throws IOException, JspCoreException {
// normalize encoding name
if (encoding == null) {
encoding = "UTF-8";
}
// try to use an optimized reader
String ENCODING = encoding.toUpperCase(Locale.ENGLISH);
if (ENCODING.equals("UTF-8")) {
return new UTF8Reader(inputStream, fBufferSize);
}
if (ENCODING.equals("US-ASCII")) {
return new ASCIIReader(inputStream, fBufferSize);
}
if (ENCODING.equals("ISO-10646-UCS-4")) {
if (isBigEndian != null) {
boolean isBE = isBigEndian.booleanValue();
if (isBE) {
return new UCSReader(inputStream, UCSReader.UCS4BE);
} else {
return new UCSReader(inputStream, UCSReader.UCS4LE);
}
} else {
throw new JspCoreException("jsp.error.xml.encodingByteOrderUnsupported", new Object[] { encoding });
//err.jspError("jsp.error.xml.encodingByteOrderUnsupported",
// encoding);
}
}
if (ENCODING.equals("ISO-10646-UCS-2")) {
if (isBigEndian != null) { // sould never happen with this encoding...
boolean isBE = isBigEndian.booleanValue();
if (isBE) {
return new UCSReader(inputStream, UCSReader.UCS2BE);
} else {
return new UCSReader(inputStream, UCSReader.UCS2LE);
}
} else {
throw new JspCoreException("jsp.error.xml.encodingByteOrderUnsupported", new Object[] { encoding });
//err.jspError("jsp.error.xml.encodingByteOrderUnsupported",
// encoding);
}
}
// check for valid name
boolean validIANA = XMLChar.isValidIANAEncoding(encoding);
boolean validJava = XMLChar.isValidJavaEncoding(encoding);
if (!validIANA || (fAllowJavaEncodings && !validJava)) {
encoding = "ISO-8859-1";
throw new JspCoreException("jsp.error.xml.encodingDeclInvalid", new Object[] { encoding });
//err.jspError("jsp.error.xml.encodingDeclInvalid", encoding);
// NOTE: AndyH suggested that, on failure, we use ISO Latin 1
// because every byte is a valid ISO Latin 1 character.
// It may not translate correctly but if we failed on
// the encoding anyway, then we're expecting the content
// of the document to be bad. This will just prevent an
// invalid UTF-8 sequence to be detected. This is only
// important when continue-after-fatal-error is turned
// on. -Ac
}
// try to use a Java reader
String javaEncoding = EncodingMap.getIANA2JavaMapping(ENCODING);
if (javaEncoding == null) {
if (fAllowJavaEncodings) {
javaEncoding = encoding;
} else {
javaEncoding = "ISO8859_1";
throw new JspCoreException("jsp.error.xml.encodingDeclInvalid", new Object[] { encoding });
//err.jspError("jsp.error.xml.encodingDeclInvalid", encoding);
// see comment above.
}
}
return new InputStreamReader(inputStream, javaEncoding);
}
|
java
|
private Object[] getEncodingName(byte[] b4, int count) {
if (count < 2) {
return new Object[]{"UTF-8", null, Boolean.FALSE};
}
// UTF-16, with BOM
int b0 = b4[0] & 0xFF;
int b1 = b4[1] & 0xFF;
if (b0 == 0xFE && b1 == 0xFF) {
// UTF-16, big-endian
return new Object [] {"UTF-16BE", Boolean.TRUE};
}
if (b0 == 0xFF && b1 == 0xFE) {
// UTF-16, little-endian
return new Object [] {"UTF-16LE", Boolean.FALSE};
}
// default to UTF-8 if we don't have enough bytes to make a
// good determination of the encoding
if (count < 3) {
return new Object [] {"UTF-8", null, Boolean.FALSE};
}
// UTF-8 with a BOM
int b2 = b4[2] & 0xFF;
if (b0 == 0xEF && b1 == 0xBB && b2 == 0xBF) {
return new Object [] {"UTF-8", null};
}
// default to UTF-8 if we don't have enough bytes to make a
// good determination of the encoding
if (count < 4) {
return new Object [] {"UTF-8", null};
}
// other encodings
int b3 = b4[3] & 0xFF;
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x00 && b3 == 0x3C) {
// UCS-4, big endian (1234)
return new Object [] {"ISO-10646-UCS-4", new Boolean(true)};
}
if (b0 == 0x3C && b1 == 0x00 && b2 == 0x00 && b3 == 0x00) {
// UCS-4, little endian (4321)
return new Object [] {"ISO-10646-UCS-4", new Boolean(false)};
}
if (b0 == 0x00 && b1 == 0x00 && b2 == 0x3C && b3 == 0x00) {
// UCS-4, unusual octet order (2143)
// REVISIT: What should this be?
return new Object [] {"ISO-10646-UCS-4", null};
}
if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x00) {
// UCS-4, unusual octect order (3412)
// REVISIT: What should this be?
return new Object [] {"ISO-10646-UCS-4", null};
}
if (b0 == 0x00 && b1 == 0x3C && b2 == 0x00 && b3 == 0x3F) {
// UTF-16, big-endian, no BOM
// (or could turn out to be UCS-2...
// REVISIT: What should this be?
return new Object [] {"UTF-16BE", new Boolean(true)};
}
if (b0 == 0x3C && b1 == 0x00 && b2 == 0x3F && b3 == 0x00) {
// UTF-16, little-endian, no BOM
// (or could turn out to be UCS-2...
return new Object [] {"UTF-16LE", new Boolean(false)};
}
if (b0 == 0x4C && b1 == 0x6F && b2 == 0xA7 && b3 == 0x94) {
// EBCDIC
// a la xerces1, return CP037 instead of EBCDIC here
return new Object [] {"CP037", null};
}
// default encoding
return new Object [] {"UTF-8", null, Boolean.FALSE};
}
|
java
|
final boolean load(int offset, boolean changeEntity)
throws IOException {
// read characters
int length = fCurrentEntity.mayReadChunks?
(fCurrentEntity.ch.length - offset):
(DEFAULT_XMLDECL_BUFFER_SIZE);
int count = fCurrentEntity.reader.read(fCurrentEntity.ch, offset,
length);
// reset count and position
boolean entityChanged = false;
if (count != -1) {
if (count != 0) {
fCurrentEntity.count = count + offset;
fCurrentEntity.position = offset;
}
}
// end of this entity
else {
fCurrentEntity.count = offset;
fCurrentEntity.position = offset;
entityChanged = true;
if (changeEntity) {
endEntity();
if (fCurrentEntity == null) {
throw new EOFException();
}
// handle the trailing edges
if (fCurrentEntity.position == fCurrentEntity.count) {
load(0, false);
}
}
}
return entityChanged;
}
|
java
|
public String scanPseudoAttribute(boolean scanningTextDecl,
XMLString value)
throws IOException, JspCoreException {
String name = scanName();
if (name == null) {
throw new JspCoreException("jsp.error.xml.pseudoAttrNameExpected");
//err.jspError("jsp.error.xml.pseudoAttrNameExpected");
}
skipSpaces();
if (!skipChar('=')) {
reportFatalError(scanningTextDecl ?
"jsp.error.xml.eqRequiredInTextDecl"
: "jsp.error.xml.eqRequiredInXMLDecl",
name);
}
skipSpaces();
int quote = peekChar();
if (quote != '\'' && quote != '"') {
reportFatalError(scanningTextDecl ?
"jsp.error.xml.quoteRequiredInTextDecl"
: "jsp.error.xml.quoteRequiredInXMLDecl" ,
name);
}
scanChar();
int c = scanLiteral(quote, value);
if (c != quote) {
fStringBuffer2.clear();
do {
fStringBuffer2.append(value);
if (c != -1) {
if (c == '&' || c == '%' || c == '<' || c == ']') {
fStringBuffer2.append((char)scanChar());
}
else if (XMLChar.isHighSurrogate(c)) {
scanSurrogates(fStringBuffer2);
}
else if (XMLChar.isInvalid(c)) {
String key = scanningTextDecl
? "jsp.error.xml.invalidCharInTextDecl"
: "jsp.error.xml.invalidCharInXMLDecl";
reportFatalError(key, Integer.toString(c, 16));
scanChar();
}
}
c = scanLiteral(quote, value);
} while (c != quote);
fStringBuffer2.append(value);
value.setValues(fStringBuffer2);
}
if (!skipChar(quote)) {
reportFatalError(scanningTextDecl ?
"jsp.error.xml.closeQuoteMissingInTextDecl"
: "jsp.error.xml.closeQuoteMissingInXMLDecl",
name);
}
// return
return name;
}
|
java
|
private void reportFatalError(String msgId, String arg)
throws JspCoreException {
throw new JspCoreException(msgId, new Object[] { arg });
//err.jspError(msgId, arg);
}
|
java
|
@SuppressWarnings("unchecked")
public static <T> T coerceToType(FacesContext facesContext, Object value, Class<? extends T> desiredClass)
{
if (value == null)
{
return null;
}
try
{
ExpressionFactory expFactory = facesContext.getApplication().getExpressionFactory();
// Use coersion implemented by JSP EL for consistency with EL
// expressions. Additionally, it caches some of the coersions.
return (T)expFactory.coerceToType(value, desiredClass);
}
catch (ELException e)
{
String message = "Cannot coerce " + value.getClass().getName()
+ " to " + desiredClass.getName();
log.log(Level.SEVERE, message , e);
throw new FacesException(message, e);
}
}
|
java
|
private String getNarrowestScope(FacesContext facesContext, String valueExpression)
{
List<String> expressions = extractExpressions(valueExpression);
// exclude NONE scope, if there are more than one ValueExpressions (see Spec for details)
String narrowestScope = expressions.size() == 1 ? NONE : APPLICATION;
boolean scopeFound = false;
for (String expression : expressions)
{
String valueScope = getScope(facesContext, expression);
if (valueScope == null)
{
continue;
}
// we have found at least one valid scope at this point
scopeFound = true;
if (SCOPE_COMPARATOR.compare(valueScope, narrowestScope) < 0)
{
narrowestScope = valueScope;
}
}
return scopeFound ? narrowestScope : null;
}
|
java
|
private String getFirstSegment(String expression)
{
int indexDot = expression.indexOf('.');
int indexBracket = expression.indexOf('[');
if (indexBracket < 0)
{
return indexDot < 0 ? expression : expression.substring(0, indexDot);
}
if (indexDot < 0)
{
return expression.substring(0, indexBracket);
}
return expression.substring(0, Math.min(indexDot, indexBracket));
}
|
java
|
@SuppressWarnings("unchecked")
public <T> T get(EventLocal<T> key) {
EventLocalMap<EventLocal<?>, Object> map = getMap(key);
if (null == map) {
return key.initialValue();
}
return (T) map.get(key);
}
|
java
|
public <T> void set(EventLocal<T> key, Object value) {
EventLocalMap<EventLocal<?>, Object> map = getMap(key);
if (null == map) {
// the call to getMap would have created the inheritable map
// if appropriate, thus always create a disconnected map here
map = new EventLocalMap<EventLocal<?>, Object>();
if (key.isInheritable()) {
this.inheritableLocals = map;
} else {
this.locals = map;
}
}
map.put(key, value);
}
|
java
|
@SuppressWarnings("unchecked")
public <T> T remove(EventLocal<T> key) {
EventLocalMap<EventLocal<?>, Object> map = getMap(key);
if (null != map) {
return (T) map.remove(key);
}
return null;
}
|
java
|
@SuppressWarnings("unchecked")
public <T> T getContextData(String name) {
T rc = null;
if (null != this.inheritableLocals) {
rc = (T) this.inheritableLocals.get(name);
}
if (null == rc && null != this.locals) {
rc = (T) this.locals.get(name);
}
return rc;
}
|
java
|
private static void setSystemProperties() {
// KernelBootstrap also sets these properties in case the bootstrap
// agent wasn't used for some reason.
String loggingManager = System.getProperty("java.util.logging.manager");
//if (loggingManager == null)
// System.setProperty("java.util.logging.manager", "com.ibm.ws.kernel.boot.logging.WsLogManager");
String managementBuilderInitial = System.getProperty("javax.management.builder.initial");
if (managementBuilderInitial == null)
System.setProperty("javax.management.builder.initial", "com.ibm.ws.kernel.boot.jmx.internal.PlatformMBeanServerBuilder");
}
|
java
|
final void setBodyType(JmsBodyType value) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "setBodyType", value);
setSubtype(value.toByte());
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "setBodyType");
}
|
java
|
private final Set<String> getNonSmokeAndMirrorsPropertyNameSet() {
/* Get the names of all the properties in the JMS Property Maps */
/* We need a copy so that we can add extra items, and so can the caller */
Set<String> names = new HashSet<String>();
// Add the names for the two flavours of properties, without creating lists
// and maps unnecessarily.
if (mayHaveJmsUserProperties()) {
names.addAll(getJmsUserPropertyMap().keySet());
}
if (mayHaveMappedJmsSystemProperties()) {
names.addAll(getJmsSystemPropertyMap().keySet());
}
// The MQMD properties may be in the JmsSystemPropertyMap AND the MQMSetPropertiesMap
// however, the Set will cater for this as it doesn't allow duplicates.
if (hasMQMDPropertiesSet()) {
names.addAll(getMQMDSetPropertiesMap().keySet());
}
return names;
}
|
java
|
@Override
public Object getJMSXGroupSeq() {
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(this, tc, "getJMSXGroupSeq");
Object result = null;
if (mayHaveMappedJmsSystemProperties()) {
result = getObjectProperty(SIProperties.JMSXGroupSeq);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(this, tc, "getJMSXGroupSeq", result);
return result;
}
|
java
|
private void processSpecialSubjects(ConfigurationAdmin configAdmin,
String roleName,
Dictionary<String, Object> roleProps, Set<String> pids) {
String[] specialSubjectPids = (String[]) roleProps.get(CFG_KEY_SPECIAL_SUBJECT);
if (specialSubjectPids == null || specialSubjectPids.length == 0) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "No special subjects in role " + roleName);
}
} else {
Set<String> badSpecialSubjects = new HashSet<String>();
for (int i = 0; i < specialSubjectPids.length; i++) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "special subject pid " + i + ": " + specialSubjectPids[i]);
}
pids.add(specialSubjectPids[i]);
Configuration specialSubjectConfig = null;
try {
specialSubjectConfig = configAdmin.getConfiguration(specialSubjectPids[i], bundleLocation);
} catch (IOException ioe) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Invalid special subject entry " + specialSubjectPids[i]);
}
continue;
}
if (specialSubjectConfig == null || specialSubjectConfig.getProperties() == null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Null special subject element", specialSubjectPids[i]);
}
continue;
}
Dictionary<String, Object> specialSubjectProps = specialSubjectConfig.getProperties();
final String type = (String) specialSubjectProps.get("type");
if (type == null || type.trim().isEmpty()) {
continue;
}
if (badSpecialSubjects.contains(type)) {
// This special subject is already flagged as a duplicate
continue;
}
// TODO: check for invalid type
if (type.trim().isEmpty()) {
// Empty entry, ignoring
continue;
}
if (!specialSubjects.add(type)) {
Tr.error(tc, "AUTHZ_TABLE_DUPLICATE_ROLE_MEMBER", getRoleName(), CFG_KEY_SPECIAL_SUBJECT, type);
badSpecialSubjects.add(type);
specialSubjects.remove(type);
}
}
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Role " + roleName + " has special subjects:", specialSubjects);
}
}
}
|
java
|
@Override
public TxCollaboratorConfig preInvoke(final HttpServletRequest request, final boolean isServlet23)
throws ServletException {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Calling preInvoke. Request=" + request + " | isServlet23=" + isServlet23);
}
//First we check if there's a global transaction
try {
final EmbeddableWebSphereTransactionManager tranManager = getTranMgr();
if (tranManager != null) {
final Transaction incumbentTx = tranManager.getTransaction();
if (incumbentTx != null) {
TransactionImpl incumbentTxImpl = null;
if (incumbentTx instanceof TransactionImpl)
incumbentTxImpl = (TransactionImpl) incumbentTx;
if (incumbentTxImpl != null && incumbentTxImpl.getTxType() == UOWCoordinator.TXTYPE_NONINTEROP_GLOBAL)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "the tx is NONINTEROP_GLOBAL set it to null");
}
// The following call should nullify the current tx on the current thread (in this special case where the
// TxType is TXTYPE_NONINTEROP_GLOBAL
tranManager.suspend();
}
else
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Global transaction was present.");
}
//Yes! There's a global transaction. Check for timeout
checkGlobalTimeout();
//Create config return object
final TxCollaboratorConfig retConfig = new TxCollaboratorConfig();
retConfig.setIncumbentTx(incumbentTx);
return retConfig;
}
}
}
} catch (SystemException e) {
Tr.error(tc, "UNEXPECTED_TRAN_ERROR", e.toString());
ServletException se = new ServletException("Unexpected error during transaction fetching: ", e);
throw se;
}
//Ensure we have a LocalTransactionCurrent to work with
LocalTransactionCurrent ltCurrent = getLtCurrent();
if (ltCurrent == null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(this, tc, "Unable to resolve LocalTransactionCurrent");
}
return null;
}
//Create config return object
TxCollaboratorConfig retConfig = new TxCollaboratorConfig();
// see if there is a local transaction on the thread
LocalTransactionCoordinator ltCoord = ltCurrent.getLocalTranCoord();
if (ltCoord != null) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Suspending LTC's coord: " + ltCoord);
}
//there was a transaction! We need to suspend it and put its coordinator into the config
//so that we can resume it later
retConfig.setSuspendTx(ltCurrent.suspend());
}
//begin a new local transaction on the thread
ltCurrent.begin();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Began LTC's coord:" + ltCurrent.getLocalTranCoord());
}
return retConfig;
}
|
java
|
private void resumeSuspendedLTC(LocalTransactionCurrent ltCurrent, Object txConfig) throws ServletException {
//Check for any suspended LTC that needs to be resumed
if (txConfig instanceof TxCollaboratorConfig) {
Object suspended = ((TxCollaboratorConfig) txConfig).getSuspendTx();
if (suspended instanceof LocalTransactionCoordinator) {
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
Tr.debug(tc, "Resuming previously suspended LTC coord:" + suspended);
Tr.debug(tc, "Registering LTC callback");
}
try {
ltCurrent.resume(((LocalTransactionCoordinator) suspended));
} catch (IllegalStateException ex) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "IllegalStateException", ex);
}
try {
// Clean-up the Tx
ltCurrent.cleanup();
} catch (InconsistentLocalTranException iltex) {
// Absorb any exception from cleanup - it doesn't really
// matter if there are inconsistencies in cleanup.
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(tc, "InconsistentLocalTranException", iltex);
}
} catch (RolledbackException rbe) {
// We need to inform the user that completion
// was affected by a call to setRollbackOnly
// so rethrow as a ServletException.
ServletException se = new ServletException("LocalTransaction rolled-back due to setRollbackOnly", rbe);
throw se;
}
}
}
}
}
|
java
|
public SerializationObject getSerializationObject() {
SerializationObject object;
synchronized (ivListOfObjects) {
if (ivListOfObjects.isEmpty()) {
object = createNewObject();
} else {
object = ivListOfObjects.remove(ivListOfObjects.size() - 1);
}
}
return object;
}
|
java
|
public void returnSerializationObject(SerializationObject object) {
synchronized (ivListOfObjects) {
if (ivListOfObjects.size() < MAXIMUM_NUM_OF_OBJECTS) {
ivListOfObjects.add(object);
}
}
}
|
java
|
public void add(Object dependency, ValueSet valueSet) {
if (dependency == null) {
throw new IllegalArgumentException("dependency cannot be null");
}
if (valueSet != null) {
dependencyToEntryTable.put(dependency, valueSet);
}
}
|
java
|
public boolean removeEntry(Object dependency, Object entry) { //SKS-O
boolean found = false;
ValueSet valueSet = (ValueSet) dependencyToEntryTable.get(dependency);
if (valueSet == null) {
return found;
}
found = valueSet.remove(entry);
if (valueSet.size()==0)
removeDependency(dependency);
return found;
}
|
java
|
protected void modified(String id, Map<String, Object> properties) {
if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
Tr.event(this, tc, "modified " + id, properties);
}
config = properties;
myProps = null;
}
|
java
|
protected ReadableLogRecord getReadableLogRecord(long expectedSequenceNumber)
{
if (tc.isEntryEnabled())
Tr.entry(tc, "getReadableLogRecord", new java.lang.Object[] { this, new Long(expectedSequenceNumber) });
if (tc.isDebugEnabled())
Tr.debug(tc, "Creating readable log record to read from file " + _fileName);
final ReadableLogRecord readableLogRecord = ReadableLogRecord.read(_fileBuffer, expectedSequenceNumber, !_logFileHeader.wasShutdownClean());
if (tc.isEntryEnabled())
Tr.exit(tc, "getReadableLogRecord", readableLogRecord);
return readableLogRecord;
}
|
java
|
void fileClose() throws InternalLogException
{
if (tc.isEntryEnabled())
Tr.entry(tc, "fileClose", this);
if (_fileChannel != null)
{
try
{
// Don't close channel as it will free a lock - wait until file close
if (_outstandingWritableLogRecords.get() == 0 && !_exceptionInForce)
{
force(); // make sure all records really are on disk
// Now we know that there are no gaps in the records and none have failed
// to be written, byte by byte scanning at the next start can be avoided.
_logFileHeader.setCleanShutdown(); // set the fact that shutdown was clean
writeFileHeader(false); // write clean shutdown into header
force();
}
_file.close();
} catch (Throwable e)
{
FFDCFilter.processException(e, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileClose", "541", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "fileClose", "InternalLogException");
throw new InternalLogException(e);
}
_fileBuffer = null;
_file = null;
_fileChannel = null;
}
if (tc.isEntryEnabled())
Tr.exit(tc, "fileClose");
}
|
java
|
public WriteableLogRecord getWriteableLogRecord(int recordLength, long sequenceNumber) throws InternalLogException
{
if (!_headerFlushedFollowingRestart)
{
// ensure header is updated now we start to write records for the first time
// synchronization is assured through locks in LogHandle.getWriteableLogRecord
writeFileHeader(true);
_headerFlushedFollowingRestart = true;
}
if (tc.isEntryEnabled())
Tr.entry(tc, "getWriteableLogRecord", new Object[] { new Integer(recordLength), new Long(sequenceNumber), this });
// Create a slice of the file buffer and reset its limit to the size of the WriteableLogRecord.
// The view buffer's content is a shared subsequence of the file buffer.
// No other log records have access to this log record's view buffer.
ByteBuffer viewBuffer = (ByteBuffer) _fileBuffer.slice().limit(recordLength + WriteableLogRecord.HEADER_SIZE);
WriteableLogRecord writeableLogRecord = new WriteableLogRecord(viewBuffer, sequenceNumber, recordLength, _fileBuffer.position());
// Advance the file buffer's position to the end of the newly created WriteableLogRecord
_fileBuffer.position(_fileBuffer.position() + recordLength + WriteableLogRecord.HEADER_SIZE);
_outstandingWritableLogRecords.incrementAndGet();
if (tc.isEntryEnabled())
Tr.exit(tc, "getWriteableLogRecord", writeableLogRecord);
return writeableLogRecord;
}
|
java
|
private void writeFileHeader(boolean maintainPosition) throws InternalLogException
{
if (tc.isEntryEnabled())
Tr.entry(tc, "writeFileHeader", new java.lang.Object[] { this, new Boolean(maintainPosition) });
// Build the buffer that forms the major part of the file header and
// then convert this into a byte array.
try
{
if (tc.isDebugEnabled())
Tr.debug(tc, "Writing header for log file " + _fileName);
_logFileHeader.write(_fileBuffer, maintainPosition);
force();
} catch (InternalLogException exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.writeFileHeader", "706", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "writeFileHeader", exc);
throw exc;
} catch (Throwable exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.writeFileHeader", "712", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "writeFileHeader", "InternalLogException");
throw new InternalLogException(exc);
}
if (tc.isEntryEnabled())
Tr.exit(tc, "writeFileHeader");
}
|
java
|
private void writeFileStatus(boolean maintainPosition) throws InternalLogException
{
if (tc.isEntryEnabled())
Tr.entry(tc, "writeFileStatus", new java.lang.Object[] { this, new Boolean(maintainPosition) });
if (_logFileHeader.status() == LogFileHeader.STATUS_INVALID)
{
if (tc.isEntryEnabled())
Tr.exit(tc, "writeFileStatus", "InternalLogException");
throw new InternalLogException(null);
}
try
{
int currentFilePointer = 0;
if (maintainPosition)
{
// If the caller wishes the file pointer's current
// position to be maintained cache it's position
// here so that it can be reset once the header
// has been written.
currentFilePointer = _fileBuffer.position();
}
// Move the buffer's pointer to the header status
// field and perform a forced write of the new status
_fileBuffer.position(STATUS_FIELD_FILE_OFFSET);
_fileBuffer.putInt(_logFileHeader.status());
force();
if (maintainPosition)
{
// Reinstate the fileBuffer's pointer to its original position.
_fileBuffer.position(currentFilePointer);
}
} catch (Throwable exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.writeFileStatus", "797", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "writeFileStatus", "WriteOperationFailedException");
throw new WriteOperationFailedException(exc);
}
if (tc.isEntryEnabled())
Tr.exit(tc, "writeFileStatus");
}
|
java
|
protected LogFileHeader logFileHeader()
{
if (tc.isEntryEnabled())
Tr.entry(tc, "logFileHeader", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "logFileHeader", _logFileHeader);
return _logFileHeader;
}
|
java
|
public byte[] getServiceData()
{
if (tc.isEntryEnabled())
Tr.entry(tc, "getServiceData", this);
byte[] serviceData = null;
if (_logFileHeader != null)
{
serviceData = _logFileHeader.getServiceData();
}
if (tc.isEntryEnabled())
Tr.exit(tc, "getServiceData", RLSUtils.toHexString(serviceData, RLSUtils.MAX_DISPLAY_BYTES));
return serviceData;
}
|
java
|
public int freeBytes()
{
if (tc.isEntryEnabled())
Tr.entry(tc, "freeBytes", this);
int freeBytes = 0;
try
{
int currentCursorPosition = _fileBuffer.position();
int fileLength = _fileBuffer.capacity();
freeBytes = fileLength - currentCursorPosition;
if (freeBytes < 0)
{
freeBytes = 0;
}
} catch (Throwable exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.freeBytes", "956", this);
freeBytes = 0;
}
if (tc.isEntryEnabled())
Tr.exit(tc, "freeBytes", new Integer(freeBytes));
return freeBytes;
}
|
java
|
public String fileName()
{
if (tc.isEntryEnabled())
Tr.entry(tc, "fileName", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "fileName", _fileName);
return _fileName;
}
|
java
|
void keypointStarting(long nextRecordSequenceNumber) throws InternalLogException
{
if (tc.isEntryEnabled())
Tr.entry(tc, "keypointStarting", new Object[] { new Long(nextRecordSequenceNumber), this });
// Set the header to indicate a keypoint operation. This also marks the header
// as valid.
_logFileHeader.keypointStarting(nextRecordSequenceNumber);
try
{
writeFileHeader(false);
} catch (InternalLogException exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.keypointStarting", "1073", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "keypointStarting", exc);
throw exc;
} catch (Throwable exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.keypointStarting", "1079", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "keypointStarting", "InternalLogException");
throw new InternalLogException(exc);
}
if (tc.isEntryEnabled())
Tr.exit(tc, "keypointStarting");
}
|
java
|
void keypointComplete() throws InternalLogException
{
if (tc.isEntryEnabled())
Tr.entry(tc, "keypointComplete", this);
_logFileHeader.keypointComplete();
try
{
writeFileStatus(true);
} catch (InternalLogException exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.keypointComplete", "1117", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "keypointComplete", exc);
throw exc;
} catch (Throwable exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.keypointComplete", "1123", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "keypointComplete", "InternalLogException");
throw new InternalLogException(exc);
}
if (tc.isEntryEnabled())
Tr.exit(tc, "keypointComplete");
}
|
java
|
void becomeInactive() throws InternalLogException
{
if (tc.isEntryEnabled())
Tr.entry(tc, "becomeInactive", this);
_logFileHeader.changeStatus(LogFileHeader.STATUS_INACTIVE);
try
{
writeFileStatus(false);
} catch (InternalLogException exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.becomeInactive", "1161", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "becomeInactive", exc);
throw exc;
} catch (Throwable exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.becomeInactive", "1167", this);
if (tc.isEntryEnabled())
Tr.exit(tc, "becomeInactive", "InternalLogException");
throw new InternalLogException(exc);
}
if (tc.isEntryEnabled())
Tr.entry(tc, "becomeInactive", this);
}
|
java
|
public void fileExtend(int newFileSize) throws LogAllocationException
{
if (tc.isEntryEnabled())
Tr.entry(tc, "fileExtend", new Object[] { new Integer(newFileSize), this });
final int fileLength = _fileBuffer.capacity();
if (fileLength < newFileSize)
{
try
{
// Expand the file to the new size ensuring that its pointer
// remains in its current position.
int originalPosition = _fileBuffer.position();
// TODO
// Tr.uncondEvent(tc, "Expanding log file to size of " + newFileSize + " bytes.");
Tr.event(tc, "Expanding log file to size of " + newFileSize + " bytes.");
if (_isMapped)
{
_fileBuffer = _fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, newFileSize);
}
else
{
// The file is not mapped.
// Allocate a new DirectByteBuffer, copy the old ByteBuffer into the new one,
// then write the new ByteBuffer to the FileChannel (automatically expanding it).
if (tc.isDebugEnabled())
Tr.debug(tc, "File is NOT mapped. Allocating new DirectByteBuffer");
_fileBuffer.position(0);
final ByteBuffer newByteBuffer = ByteBuffer.allocateDirect(newFileSize);
newByteBuffer.put(_fileBuffer);
newByteBuffer.position(0);
_fileChannel.write(newByteBuffer, 0);
_fileBuffer = newByteBuffer;
}
_fileBuffer.position(originalPosition);
_fileSize = newFileSize;
} catch (Exception exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.fileExtend", "1266", this);
if (tc.isEntryEnabled())
Tr.event(tc, "Unable to extend file " + _fileName + " to " + newFileSize + " bytes");
if (tc.isEntryEnabled())
Tr.exit(tc, "fileExtend", "LogAllocationException");
throw new LogAllocationException(exc);
}
}
if (tc.isEntryEnabled())
Tr.exit(tc, "fileExtend");
}
|
java
|
protected void force() throws InternalLogException
{
if (tc.isEntryEnabled())
Tr.entry(tc, "force", this);
try
{
if (_isMapped)
{
// Note: on Win2K we can get an IOException from this even though it is not declared
((MappedByteBuffer) _fileBuffer).force();
}
else
{
// Write the "pending" WritableLogRecords.
writePendingToFile();
_fileChannel.force(false);
}
} catch (java.io.IOException ioe)
{
FFDCFilter.processException(ioe, "com.ibm.ws.recoverylog.spi.LogFileHandle.force", "1049", this);
_exceptionInForce = true;
if (tc.isEventEnabled())
Tr.event(tc, "Unable to force file " + _fileName);
// d453958: moved terminateserver code to MultiScopeRecoveryLog.markFailed method.
if (tc.isEntryEnabled())
Tr.exit(tc, "force", "InternalLogException");
throw new InternalLogException(ioe);
} catch (InternalLogException exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.force", "1056", this);
_exceptionInForce = true;
if (tc.isEventEnabled())
Tr.event(tc, "Unable to force file " + _fileName);
if (tc.isEntryEnabled())
Tr.exit(tc, "force", "InternalLogException");
throw exc;
} catch (LogIncompatibleException exc)
{
FFDCFilter.processException(exc, "com.ibm.ws.recoverylog.spi.LogFileHandle.force", "1096", this);
_exceptionInForce = true;
if (tc.isEventEnabled())
Tr.event(tc, "Unable to force file " + _fileName);
if (tc.isEntryEnabled())
Tr.exit(tc, "force", "InternalLogException");
throw new InternalLogException(exc);
}
if (tc.isEntryEnabled())
Tr.exit(tc, "force");
}
|
java
|
private String normalize(String alias) {
// replace all the '.'s to '\.'s
String regExp = alias.replaceAll("[\\.]", "\\\\\\.");
// replace all the '*'s to '.*'s
regExp = regExp.replaceAll("[*]", "\\.\\*");
// System.out.println("Normalized "+alias+" to "+regExp);
return regExp;
}
|
java
|
public Iterator targetMappings() {
// System.out.println("TargetMappings called");
// return vHostTable.values().iterator(); 316624
Collection vHosts = vHostTable.values(); // 316624
List l = new ArrayList(); // 316624
l.addAll(vHosts); // 316624
return l.listIterator(); // 316624
}
|
java
|
public final BehindRef insert(final AbstractItemLink insertAil)
{
final long insertPosition = insertAil.getPosition();
boolean inserted = false;
BehindRef addref = null;
// Loop backwards through the list in order of decreasing sequence number
// (addition usually near the end) until we have inserted the entry
BehindRef lookat = _lastLinkBehind;
while (!inserted && (lookat != null))
{
AbstractItemLink lookatAil = lookat.getAIL();
if (lookatAil != null)
{
long lookatPosition = lookatAil.getPosition();
if (insertPosition > lookatPosition)
{
// This is where it goes then
addref = new BehindRef(insertAil);
if (lookat._next == null)
{
// It's now the last one in the list
_lastLinkBehind = addref;
}
else
{
// It's going in the middle of the list
addref._next = lookat._next;
lookat._next._prev = addref;
}
addref._prev = lookat;
lookat._next = addref;
inserted = true;
}
else if (insertPosition == lookatPosition)
{
// A duplicate. OK, it's been made reavailable more than once
addref = lookat;
inserted = true;
}
else
{
// Need to move backwards
lookat = lookat._prev;
}
}
else
{
BehindRef newlookat = lookat._prev;
_remove(lookat);
lookat = newlookat;
}
}
// If we have not inserted it yet, it's going to be the first in the list
if (!inserted)
{
addref = new BehindRef(insertAil);
if (_firstLinkBehind != null)
{
addref._next = _firstLinkBehind;
_firstLinkBehind._prev = addref;
_firstLinkBehind = addref;
}
else
{
_firstLinkBehind = addref;
_lastLinkBehind = addref;
}
}
return addref;
}
|
java
|
private final void _remove(final BehindRef removeref)
{
if (_firstLinkBehind != null)
{
if (removeref == _firstLinkBehind)
{
// It's the first in the list ...
if (removeref == _lastLinkBehind)
{
// ... and the only entry, the list is now empty
_firstLinkBehind = null;
_lastLinkBehind = null;
}
else
{
// ... and there are more entries, the first will change
BehindRef nextref = removeref._next;
removeref._next = null;
nextref._prev = null;
_firstLinkBehind = nextref;
}
}
else if (removeref == _lastLinkBehind)
{
// It's the list in the list and not the first also, the last will change
BehindRef prevref = removeref._prev;
removeref._prev = null;
prevref._next = null;
_lastLinkBehind = prevref;
}
else
{
// It's in the middle of the list
BehindRef prevref = removeref._prev;
BehindRef nextref = removeref._next;
removeref._next = null;
removeref._prev = null;
prevref._next = nextref;
nextref._prev = prevref;
}
}
}
|
java
|
protected boolean invokeTraceRouters(RoutedMessage routedTrace) {
boolean retMe = true;
LogRecord logRecord = routedTrace.getLogRecord();
/*
* Avoid any feedback traces that are emitted after this point.
* The first time the counter increments is the first pass-through.
* The second time the counter increments is the second pass-through due
* to trace emitted. We do not want any more pass-throughs.
*/
try {
if (!(counterForTraceRouter.incrementCount() > 2)) {
if (logRecord != null) {
Level level = logRecord.getLevel();
int levelValue = level.intValue();
if (levelValue < Level.INFO.intValue()) {
String levelName = level.getName();
if (!(levelName.equals("SystemOut") || levelName.equals("SystemErr"))) { //SystemOut/Err=700
WsTraceRouter internalTrRouter = internalTraceRouter.get();
if (internalTrRouter != null) {
retMe &= internalTrRouter.route(routedTrace);
} else if (earlierTraces != null) {
synchronized (this) {
if (earlierTraces != null) {
earlierTraces.add(routedTrace);
}
}
}
}
}
}
}
} finally {
counterForTraceRouter.decrementCount();
}
return retMe;
}
|
java
|
protected void publishTraceLogRecord(TraceWriter detailLog, LogRecord logRecord, Object id, String formattedMsg, String formattedVerboseMsg) {
//check if tracefilename is stdout
if (formattedVerboseMsg == null) {
formattedVerboseMsg = formatter.formatVerboseMessage(logRecord, formattedMsg, false);
}
RoutedMessage routedTrace = new RoutedMessageImpl(formattedMsg, formattedVerboseMsg, null, logRecord);
invokeTraceRouters(routedTrace);
/*
* Avoid any feedback traces that are emitted after this point.
* The first time the counter increments is the first pass-through.
* The second time the counter increments is the second pass-through due
* to trace emitted. We do not want any more pass-throughs.
*/
try {
if (!(counterForTraceSource.incrementCount() > 2)) {
if (logRecord != null) {
Level level = logRecord.getLevel();
int levelValue = level.intValue();
if (levelValue < Level.INFO.intValue()) {
String levelName = level.getName();
if (!(levelName.equals("SystemOut") || levelName.equals("SystemErr"))) { //SystemOut/Err=700
if (traceSource != null) {
traceSource.publish(routedTrace, id);
}
}
}
}
}
} finally {
counterForTraceSource.decrementCount();
}
try {
if (!(counterForTraceWriter.incrementCount() > 1)) {
// write to trace.log
if (detailLog != systemOut) {
String traceDetail = formatter.traceLogFormat(logRecord, id, formattedMsg, formattedVerboseMsg);
detailLog.writeRecord(traceDetail);
}
}
} finally {
counterForTraceWriter.decrementCount();
}
}
|
java
|
@Override
public void setMessageRouter(MessageRouter msgRouter) {
externalMessageRouter.set(msgRouter);
if (msgRouter instanceof WsMessageRouter) {
setWsMessageRouter((WsMessageRouter) msgRouter);
}
}
|
java
|
@Override
public void unsetMessageRouter(MessageRouter msgRouter) {
externalMessageRouter.compareAndSet(msgRouter, null);
if (msgRouter instanceof WsMessageRouter) {
unsetWsMessageRouter((WsMessageRouter) msgRouter);
}
}
|
java
|
protected void initializeWriters(LogProviderConfigImpl config) {
// createFileLog may or may not return the original log holder..
messagesLog = FileLogHolder.createFileLogHolder(messagesLog,
newFileLogHeader(false, config),
config.getLogDirectory(),
config.getMessageFileName(),
config.getMaxFiles(),
config.getMaxFileBytes(),
config.getNewLogsOnStart());
// Always create a traceLog when using Tr -- this file won't actually be
// created until something is logged to it...
TraceWriter oldWriter = traceLog;
String fileName = config.getTraceFileName();
if (fileName.equals("stdout")) {
traceLog = systemOut;
LoggingFileUtils.tryToClose(oldWriter);
} else {
traceLog = FileLogHolder.createFileLogHolder(oldWriter == systemOut ? null : oldWriter,
newFileLogHeader(true, config),
config.getLogDirectory(),
config.getTraceFileName(),
config.getMaxFiles(),
config.getMaxFileBytes(),
config.getNewLogsOnStart());
if (!TraceComponent.isAnyTracingEnabled()) {
((FileLogHolder) traceLog).releaseFile();
}
}
}
|
java
|
@Override
public Object load(String batchId) {
Object loadedArtifact;
loadedArtifact = getArtifactById(batchId);
if (loadedArtifact != null) {
if (logger.isLoggable(Level.FINEST)) {
logger.finest("load: batchId: " + batchId
+ ", artifact: " + loadedArtifact
+ ", artifact class: " + loadedArtifact.getClass().getCanonicalName());
}
}
return loadedArtifact;
}
|
java
|
protected Bean<?> getUniqueBeanByBeanName(BeanManager bm, String batchId) {
Bean<?> match = null;
// Get all beans with the given EL name (id). EL names are applied via @Named.
// If the bean is not annotated with @Named, then it does not have an EL name
// and therefore can't be looked up that way.
Set<Bean<?>> beans = bm.getBeans(batchId);
try {
match = bm.resolve(beans);
} catch (AmbiguousResolutionException e) {
return null;
}
return match;
}
|
java
|
@FFDCIgnore(BatchCDIAmbiguousResolutionCheckedException.class)
protected Bean<?> getUniqueBeanForBatchXMLEntry(BeanManager bm, String batchId) {
ClassLoader loader = getContextClassLoader();
BatchXMLMapper batchXMLMapper = new BatchXMLMapper(loader);
Class<?> clazz = batchXMLMapper.getArtifactById(batchId);
if (clazz != null) {
try {
return findUniqueBeanForClass(bm, clazz);
} catch (BatchCDIAmbiguousResolutionCheckedException e) {
if (logger.isLoggable(Level.FINER)) {
logger.finer("getBeanForBatchXML: BatchCDIAmbiguousResolutionCheckedException: " + e.getMessage());
}
return null;
}
} else {
return null;
}
}
|
java
|
@FFDCIgnore({ ClassNotFoundException.class, BatchCDIAmbiguousResolutionCheckedException.class })
protected Bean<?> getUniqueBeanForClassName(BeanManager bm, String className) {
// Ignore exceptions since will just failover to another loading mechanism
try {
Class<?> clazz = getContextClassLoader().loadClass(className);
return findUniqueBeanForClass(bm, clazz);
} catch (BatchCDIAmbiguousResolutionCheckedException e) {
if (logger.isLoggable(Level.FINER)) {
logger.finer("getBeanForClassName: BatchCDIAmbiguousResolutionCheckedException: " + e.getMessage());
}
return null;
} catch (ClassNotFoundException cnfe) {
if (logger.isLoggable(Level.FINER)) {
logger.finer("getBeanForClassName: ClassNotFoundException for " + className + ": " + cnfe);
}
return null;
}
}
|
java
|
private synchronized void createExecutor() {
if (componentConfig == null) {
// this is a completely normal occurrence and can happen if a ThreadFactory is bound prior to
// component activation... the proper thing to do is to do nothing and wait for activation
return;
}
if (threadPoolController != null)
threadPoolController.deactivate();
ThreadPoolExecutor oldPool = threadPool;
poolName = (String) componentConfig.get("name");
String threadGroupName = poolName + " Thread Group";
int coreThreads = Integer.parseInt(String.valueOf(componentConfig.get("coreThreads")));
int maxThreads = Integer.parseInt(String.valueOf(componentConfig.get("maxThreads")));
if (maxThreads <= 0) {
maxThreads = Integer.MAX_VALUE;
}
if (coreThreads < 0) {
coreThreads = 2 * CpuInfo.getAvailableProcessors();
}
// Make sure coreThreads is not bigger than maxThreads, subject to MINIMUM_POOL_SIZE limit
coreThreads = Math.max(MINIMUM_POOL_SIZE, Math.min(coreThreads, maxThreads));
// ... and then make sure maxThreads is not smaller than coreThreads ...
maxThreads = Math.max(coreThreads, maxThreads);
BlockingQueue<Runnable> workQueue = new BoundedBuffer<Runnable>(java.lang.Runnable.class, 1000, 1000);
RejectedExecutionHandler rejectedExecutionHandler = new ExpandPolicy(workQueue, this);
threadPool = new ThreadPoolExecutor(coreThreads, maxThreads, 0, TimeUnit.MILLISECONDS, workQueue, threadFactory != null ? threadFactory : new ThreadFactoryImpl(poolName, threadGroupName), rejectedExecutionHandler);
threadPoolController = new ThreadPoolController(this, threadPool);
if (oldPool != null) {
softShutdown(oldPool);
}
}
|
java
|
private <T> Collection<? extends Callable<T>> wrap(Collection<? extends Callable<T>> tasks) {
List<Callable<T>> wrappedTasks = new ArrayList<Callable<T>>();
Iterator<? extends Callable<T>> i = tasks.iterator();
while (i.hasNext()) {
Callable<T> c = wrap(i.next());
if (serverStopping)
wrappedTasks.add(c);
else
wrappedTasks.add(new CallableWrapper<T>(c));
}
return wrappedTasks;
}
|
java
|
public JsMessage next()
throws MessageDecodeFailedException,
SISessionUnavailableException, SISessionDroppedException,
SIConnectionUnavailableException, SIConnectionDroppedException,
SIResourceException, SIConnectionLostException,
SIErrorException,
SINotAuthorizedException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "next");
JsMessage retMsg = null;
// begin D249096
retMsg = queue.get(proxyQueueId);
if (retMsg == null)
{
convHelper.flushConsumer();
retMsg = queue.get(proxyQueueId);
}
// end D249096
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "next", retMsg);
return retMsg;
}
|
java
|
public void close()
throws SIResourceException, SIConnectionLostException,
SIErrorException, SIConnectionDroppedException
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "close");
if (!closed)
{
// begin D249096
convHelper.closeSession();
queue.purge(proxyQueueId);
owningGroup.notifyClose(this);
closed = true;
// end D249096
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "close");
}
|
java
|
public void put(CommsByteBuffer msgBuffer, short msgBatch, boolean lastInBatch, boolean chunk)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "put", new Object[]{msgBuffer, msgBatch, lastInBatch, chunk});
QueueData queueData = null;
// If this data represents a chunk we need to read the flags from the buffer. This
// will indicate to us whether we need to create some new queue data to stash on the
// queue or
if (chunk)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Dealing with a chunked message");
// Get the flags from the buffer
byte flags = msgBuffer.get();
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Flags:", ""+flags);
// Is this the first chunk?
if ((flags & CommsConstants.CHUNKED_MESSAGE_FIRST) == CommsConstants.CHUNKED_MESSAGE_FIRST)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "First chunk received");
// If it is, create some new queue data to place on the queue with the initial
// chunk
queueData = new QueueData(this, lastInBatch, chunk, msgBuffer);
// Put the data to the queue
queue.put(queueData, msgBatch);
}
else
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Middle / Last chunk received");
// Otherwise, we need to append to the chunks already collected. We do this by
// finding the chunk to append to. This will be the last message on the queue
// (i.e. at the back). This works for all cases as an async consumer cannot be
// driven concurrently (so the last incomplete message on the queue will be the
// one we want).
boolean lastChunk = ((flags & CommsConstants.CHUNKED_MESSAGE_LAST) == CommsConstants.CHUNKED_MESSAGE_LAST);
queue.appendToLastMessage(msgBuffer, lastChunk);
}
}
else
{
if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "Dealing with the entire message");
queueData = new QueueData(this, lastInBatch, chunk, msgBuffer);
// Put the data to the queue
queue.put(queueData, msgBatch);
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "put");
}
|
java
|
public void setBrowserSession(BrowserSessionProxy browserSession)
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "setBrowserSession", browserSession);
if (this.browserSession != null)
{
// We are flagging this here as we should never call setBrowserSession() twice.
// A proxy queue is associated with a session for the lifetime of the session and calling
// it twice is badness.
SIErrorException e = new SIErrorException(
nls.getFormattedMessage("RESET_OF_BROWSER_SESSION_SICO1035", null, null)
);
FFDCFilter.processException(e, CLASS_NAME + ".setBrowserSession",
CommsConstants.BROWSERPQ_SETBROWSERSESS_01, this);
throw e;
}
if (browserSession == null)
{
// You can't pass in a null you complete badger
SIErrorException e = new SIErrorException(
nls.getFormattedMessage("NULL_BROWSER_SESSION_SICO1036", null, null)
);
FFDCFilter.processException(e, CLASS_NAME + ".setBrowserSession",
CommsConstants.BROWSERPQ_SETBROWSERSESS_02, this);
throw e;
}
this.browserSession = browserSession;
convHelper.setSessionId(browserSession.getProxyID());
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "setBrowserSession");
}
|
java
|
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
GetField fields = in.readFields();
principal = (String) fields.get(PRINCIPAL, null);
jwt = (String) fields.get(JWT, null);
type = (String) fields.get(TYPE, null);
handleClaims(jwt);
}
|
java
|
private void writeObject(ObjectOutputStream out) throws IOException {
PutField fields = out.putFields();
fields.put(PRINCIPAL, principal);
fields.put(JWT, jwt);
fields.put(TYPE, type);
out.writeFields();
}
|
java
|
private static JarFile _getAlternativeJarFile(URL url) throws IOException
{
String urlFile = url.getFile();
// Trim off any suffix - which is prefixed by "!/" on Weblogic
int separatorIndex = urlFile.indexOf("!/");
// OK, didn't find that. Try the less safe "!", used on OC4J
if (separatorIndex == -1)
{
separatorIndex = urlFile.indexOf('!');
}
if (separatorIndex != -1)
{
String jarFileUrl = urlFile.substring(0, separatorIndex);
// And trim off any "file:" prefix.
if (jarFileUrl.startsWith("file:"))
{
jarFileUrl = jarFileUrl.substring("file:".length());
}
return new JarFile(jarFileUrl);
}
return null;
}
|
java
|
private void requestProcessed(FacesContext facesContext)
{
if(!_firstRequestProcessed)
{
// The order here is important. First it is necessary to put
// the value on application map before change the value here.
// If multiple threads reach this point concurrently, the
// variable will be written on the application map at the same
// time but always with the same value.
facesContext.getExternalContext().getApplicationMap()
.put(FIRST_REQUEST_PROCESSED_PARAM, Boolean.TRUE);
_firstRequestProcessed = true;
}
}
|
java
|
@Generated(value = "com.ibm.jtc.jax.tools.xjc.Driver", date = "2014-06-11T05:49:00-04:00", comments = "JAXB RI v2.2.3-11/28/2011 06:21 AM(foreman)-")
public List<Property> getPropertyList() {
if (propertyList == null) {
propertyList = new ArrayList<Property>();
}
return this.propertyList;
}
|
java
|
protected Token current()
{
final String methodName = "current";
Token currentToken;
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.entry(this, cclass
, methodName
+ toString()
);
currentToken = objectStore.like(this);
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.exit(this, cclass
, methodName
, new Object[] { currentToken, Integer.toHexString(currentToken.hashCode()) });
return currentToken;
}
|
java
|
public final ManagedObject getManagedObject()
throws ObjectManagerException {
// final String methodName = "getManagedObject";
// if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
// trace.entry(this,
// cclass,
// methodName);
// Get the object if is already in memory.
ManagedObject managedObject = null;
if (managedObjectReference != null)
managedObject = (ManagedObject) managedObjectReference.get();
if (managedObject == null) { // See if we can avoid synchronizing.
synchronized (this) {
if (managedObjectReference != null)
managedObject = (ManagedObject) managedObjectReference.get();
if (managedObject == null) {
managedObject = objectStore.get(this);
if (managedObject != null) {
managedObject.owningToken = this; // PM22584 Set the owning token first
managedObjectReference = new java.lang.ref.WeakReference(managedObject);
} // if (managedObject != null).
} // if (managedObject == null).
} // synchronize (this).
} // if (managedObject == null).
// if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
// trace.exit(this,
// cclass,
// methodName,
// new Object[] {managedObject});
return managedObject;
}
|
java
|
protected synchronized ManagedObject setManagedObject(ManagedObject managedObject)
throws ObjectManagerException
{
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.entry(this, cclass
, "setManagedObject"
+ "managedObject=" + managedObject + "(ManagedObject)"
+ toString()
);
ManagedObject managedObjectSet; // For return.
// Has any ManagedObject ever been associated with tis Token?
if (managedObjectReference == null) {
// Nothing currently known so use the version given.
managedObject.owningToken = this; // PM22584 Set the owning token first
managedObjectReference = new java.lang.ref.WeakReference(managedObject);
managedObjectSet = managedObject;
} else {
ManagedObject existingManagedObject = (ManagedObject) managedObjectReference.get();
if (existingManagedObject == null) { // Is it still accessible?
managedObject.owningToken = this; // PM22584 Set the owning token first
managedObjectReference = new java.lang.ref.WeakReference(managedObject);
managedObjectSet = managedObject;
} else { // In memory and accessible.
// During recovery another object already recovered may have refered
// to this one causing it to already be resident in memory.
// Replace what we already have with this version.
existingManagedObject.becomeCloneOf(managedObject);
managedObjectSet = existingManagedObject;
} // if (existingManagedObject == null).
} // if(managedObjectReference == null).
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.exit(this, cclass
, "setManagedObject"
, new Object[] { managedObjectSet });
return managedObjectSet;
}
|
java
|
void invalidate()
{
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.entry(this, cclass
, "invalidate"
);
// Prevent any attempt to load the object.
objectStore = null;
// If the ManagedObject is already in memory access it, otherwise there is nothing
// we need to do to it.
if (managedObjectReference != null) {
ManagedObject managedObject = (ManagedObject) managedObjectReference.get();
if (managedObject != null)
managedObject.state = ManagedObject.stateError;
} // if (managedObjectReference != null).
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.exit(this, cclass
, "invalidate"
);
}
|
java
|
public static final Token restore(java.io.DataInputStream dataInputStream,
ObjectManagerState objectManagerState)
throws ObjectManagerException
{
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.entry(cclass
, "restore"
, new Object[] { dataInputStream, objectManagerState });
int objectStoreIdentifier;
long storedObjectIdentifier;
try {
byte version = dataInputStream.readByte();
if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
trace.debug(cclass,
"restore",
new Object[] { new Byte(version) });
objectStoreIdentifier = dataInputStream.readInt();
storedObjectIdentifier = dataInputStream.readLong();
} catch (java.io.IOException exception) {
// No FFDC Code Needed.
ObjectManager.ffdc.processException(cclass, "restore", exception, "1:400:1.14");
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.exit(cclass,
"restore",
"via PermanentIOException");
throw new PermanentIOException(cclass,
exception);
} // catch (java.io.IOException exception).
Token tokenToReturn = new Token(objectManagerState.getObjectStore(objectStoreIdentifier),
storedObjectIdentifier);
// Swap for the definitive Token.
// TODO should have a smarter version of like() which takes a storedObjectIdentifier,
// instead of requiring a new Token().
tokenToReturn = tokenToReturn.current();
if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
trace.exit(cclass
, "restore"
, "returns token=" + tokenToReturn + "(Token)"
);
return tokenToReturn;
}
|
java
|
public static HttpEndpointImpl findEndpoint(String endpointId) {
for (HttpEndpointImpl i : instance.get()) {
if (i.getName().equals(endpointId))
return i;
}
return null;
}
|
java
|
public synchronized List<Long> getTicksOnStream()
{
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.entry(tc, "getTicksOnStream");
List<Long> msgs = new ArrayList<Long>();
StateStream stateStream = getStateStream();
// Initial range in stream is always completed Range
stateStream.setCursor(0);
// skip this and move to next range
stateStream.getNext();
// Get the first TickRange after completed range and move cursor to the next one
TickRange tr = stateStream.getNext();
// Iterate until we reach final Unknown range
while (tr.endstamp < RangeList.INFINITY)
{
if( !(tr.type == TickRange.Completed) )
{
msgs.add(new Long(tr.startstamp));
}
tr = stateStream.getNext();
}
if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
SibTr.exit(tc, "getTicksOnStream", msgs);
return msgs;
}
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.