Here are the examples of the java api org.apache.juli.logging.Log.error() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
648 Examples
19
Source : ChatAnnotation.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
@OnError
public void onError(Throwable t) throws Throwable {
log.error("Chat Error: " + t.toString(), t);
}
19
Source : PooledConnection.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Validates a connection.
* @param validateAction the action used. One of {@link #VALIDATE_BORROW}, {@link #VALIDATE_IDLE},
* {@link #VALIDATE_INIT} or {@link #VALIDATE_RETURN}
* @param sql the SQL to be used during validation. If the {@link PoolConfiguration#setInitSQL(String)} has been called with a non null
* value and the action is {@link #VALIDATE_INIT} the init SQL will be used for validation.
*
* @return true if the connection was validated successfully. It returns true even if validation was not performed, such as when
* {@link PoolConfiguration#setValidationInterval(long)} has been called with a positive value.
* <p>
* false if the validation failed. The caller should close the connection if false is returned since a session could have been left in
* an unknown state during initialization.
*/
public boolean validate(int validateAction, String sql) {
if (this.isDiscarded()) {
return false;
}
if (!doValidate(validateAction)) {
// no validation required, no init sql and props not set
return true;
}
// Don't bother validating if already have recently enough
long now = System.currentTimeMillis();
if (validateAction != VALIDATE_INIT && poolProperties.getValidationInterval() > 0 && (now - this.lastValidated) < poolProperties.getValidationInterval()) {
return true;
}
if (poolProperties.getValidator() != null) {
if (poolProperties.getValidator().validate(connection, validateAction)) {
this.lastValidated = now;
return true;
} else {
if (getPoolProperties().getLogValidationErrors()) {
log.error("Custom validation through " + poolProperties.getValidator() + " failed.");
}
return false;
}
}
String query = sql;
if (validateAction == VALIDATE_INIT && poolProperties.getInitSQL() != null) {
query = poolProperties.getInitSQL();
}
if (query == null) {
query = poolProperties.getValidationQuery();
}
Statement stmt = null;
try {
stmt = connection.createStatement();
int validationQueryTimeout = poolProperties.getValidationQueryTimeout();
if (validationQueryTimeout > 0) {
stmt.setQueryTimeout(validationQueryTimeout);
}
stmt.execute(query);
stmt.close();
this.lastValidated = now;
return true;
} catch (Exception ex) {
if (getPoolProperties().getLogValidationErrors()) {
log.warn("SQL Validation error", ex);
} else if (log.isDebugEnabled()) {
log.debug("Unable to validate object:", ex);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception ignore2) {
/*NOOP*/
}
}
return false;
}
19
Source : SlowQueryReportJmx.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
protected void registerJmx() {
try {
// only if we notify the pool itself
if (isNotifyPool()) {
} else if (getCompositeType() != null) {
ObjectName oname = getObjectName(getClreplaced(), poolName);
if (mbeans.putIfAbsent(poolName, this) == null) {
ManagementFactory.getPlatformMBeanServer().registerMBean(this, oname);
}
} else {
log.warn(SlowQueryReport.clreplaced.getName() + "- No JMX support, composite type was not found.");
}
} catch (MalformedObjectNameException e) {
log.error("Jmx registration failed, no JMX data will be exposed for the query stats.", e);
} catch (RuntimeOperationsException e) {
log.error("Jmx registration failed, no JMX data will be exposed for the query stats.", e);
} catch (MBeanException e) {
log.error("Jmx registration failed, no JMX data will be exposed for the query stats.", e);
} catch (InstanceAlreadyExistsException e) {
log.error("Jmx registration failed, no JMX data will be exposed for the query stats.", e);
} catch (NotCompliantMBeanException e) {
log.error("Jmx registration failed, no JMX data will be exposed for the query stats.", e);
}
}
19
Source : DataSourceProxy.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
public void purgeOnReturn() {
try {
createPool().purgeOnReturn();
} catch (SQLException x) {
log.error("Unable to purge pool.", x);
}
}
19
Source : DataSourceProxy.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
public void purge() {
try {
createPool().purge();
} catch (SQLException x) {
log.error("Unable to purge pool.", x);
}
}
19
Source : JIoEndpoint.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Deallocate APR memory pools, and close server socket.
*/
@Override
public void unbind() throws Exception {
if (running) {
stop();
}
if (serverSocket != null) {
try {
if (serverSocket != null)
serverSocket.close();
} catch (Exception e) {
log.error(sm.getString("endpoint.err.close"), e);
}
serverSocket = null;
}
handler.recycle();
}
19
Source : JIoEndpoint.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Process an existing async connection. If processing is required, preplacedes
* the wrapped socket to an executor for processing.
*
* @param socket The socket replacedociated with the client.
* @param status Only OPEN and TIMEOUT are used. The others are used for
* Comet requests that are not supported by the BIO (JIO)
* Connector.
*/
@Override
public void processSocketAsync(SocketWrapper<Socket> socket, SocketStatus status) {
try {
synchronized (socket) {
if (waitingRequests.remove(socket)) {
SocketProcessor proc = new SocketProcessor(socket, status);
ClreplacedLoader loader = Thread.currentThread().getContextClreplacedLoader();
try {
// threads should not be created by the webapp clreplacedloader
if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(getClreplaced().getClreplacedLoader());
AccessController.doPrivileged(pa);
} else {
Thread.currentThread().setContextClreplacedLoader(getClreplaced().getClreplacedLoader());
}
// During shutdown, executor may be null - avoid NPE
if (!running) {
return;
}
getExecutor().execute(proc);
// TODO gotta catch RejectedExecutionException and properly handle it
} finally {
if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(loader);
AccessController.doPrivileged(pa);
} else {
Thread.currentThread().setContextClreplacedLoader(loader);
}
}
}
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
// This means we got an OOM or similar creating a thread, or that
// the pool and its queue are full
log.error(sm.getString("endpoint.process.fail"), t);
}
}
19
Source : Registry.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Register a component
* XXX make it private
*
* @param bean
* @param oname
* @param type
* @throws Exception
*/
public void registerComponent(Object bean, ObjectName oname, String type) throws Exception {
if (log.isDebugEnabled()) {
log.debug("Managed= " + oname);
}
if (bean == null) {
log.error("Null component " + oname);
return;
}
try {
if (type == null) {
type = bean.getClreplaced().getName();
}
ManagedBean managed = findManagedBean(bean.getClreplaced(), type);
// The real mbean is created and registered
DynamicMBean mbean = managed.createMBean(bean);
if (getMBeanServer().isRegistered(oname)) {
if (log.isDebugEnabled()) {
log.debug("Unregistering existing component " + oname);
}
getMBeanServer().unregisterMBean(oname);
}
getMBeanServer().registerMBean(mbean, oname);
} catch (Exception ex) {
log.error("Error registering " + oname, ex);
throw ex;
}
}
19
Source : Registry.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Unregister a component. This is just a helper that
* avoids exceptions by checking if the mbean is already registered
*
* @param oname
*/
public void unregisterComponent(ObjectName oname) {
try {
if (getMBeanServer().isRegistered(oname)) {
getMBeanServer().unregisterMBean(oname);
}
} catch (Throwable t) {
log.error("Error unregistering mbean ", t);
}
}
19
Source : Http11Processor.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
@Override
protected boolean prepareSendfile(OutputFilter[] outputFilters) {
// Should never, ever call this code
Exception e = new Exception();
log.error(sm.getString("http11processor.neverused"), e);
return false;
}
19
Source : AjpMessage.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
public int processHeader(boolean toContainer) {
pos = 0;
int mark = getInt();
len = getInt();
// Verify message signature
if ((toContainer && mark != 0x1234) || (!toContainer && mark != 0x4142)) {
log.error(sm.getString("ajpmessage.invalid", "" + mark));
if (log.isDebugEnabled()) {
dump("In: ");
}
return -1;
}
if (log.isDebugEnabled()) {
log.debug("Received " + len + " " + buf[0]);
}
return len;
}
19
Source : AjpMessage.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Copy a chunk of bytes into the packet, starting at the current
* write position. The chunk of bytes is encoded with the length
* in two bytes first, then the data itself, and finally a
* terminating \0 (which is <B>not</B> included in the encoded
* length).
*
* @param b The array from which to copy bytes.
* @param off The offset into the array at which to start copying
* @param numBytes The number of bytes to copy.
*/
public void appendBytes(byte[] b, int off, int numBytes) {
if (pos + numBytes + 3 > buf.length) {
log.error(sm.getString("ajpmessage.overflow", "" + numBytes, "" + pos), new ArrayIndexOutOfBoundsException());
if (log.isDebugEnabled()) {
dump("Overflow/coBytes");
}
return;
}
appendInt(numBytes);
System.arraycopy(b, off, buf, pos, numBytes);
pos += numBytes;
appendByte(0);
}
19
Source : AjpMessage.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Write a ByteChunk out at the current write position.
* A null ByteChunk is encoded as a string with length 0.
*/
public void appendByteChunk(ByteChunk bc) {
if (bc == null) {
log.error(sm.getString("ajpmessage.null"), new NullPointerException());
appendInt(0);
appendByte(0);
return;
}
appendBytes(bc.getBytes(), bc.getStart(), bc.getLength());
}
19
Source : AjpMessage.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Write a String out at the current write position. Strings are
* encoded with the length in two bytes first, then the string, and
* then a terminating \0 (which is <B>not</B> included in the
* encoded length). The terminator is for the convenience of the C
* code, where it saves a round of copying. A null string is
* encoded as a string with length 0.
*/
public void appendString(String str) {
if (str == null) {
log.error(sm.getString("ajpmessage.null"), new NullPointerException());
appendInt(0);
appendByte(0);
return;
}
int len = str.length();
appendInt(len);
for (int i = 0; i < len; i++) {
char c = str.charAt(i);
// Note: This is clearly incorrect for many strings,
// but is the only consistent approach within the current
// servlet framework. It must suffice until servlet output
// streams properly encode their output.
if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
c = ' ';
}
appendByte(c);
}
appendByte(0);
}
19
Source : ExtendedAccessLogValve.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
protected AccessLogElement getProxyElement(PatternTokenizer tokenizer) throws IOException {
String token = null;
if (tokenizer.hreplacedubToken()) {
tokenizer.getToken();
return new StringElement("-");
} else if (tokenizer.hasParameter()) {
tokenizer.getParameter();
return new StringElement("-");
}
log.error("The next characters couldn't be decoded: " + token);
return null;
}
19
Source : ExtendedAccessLogValve.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
protected AccessLogElement getClientToServerElement(PatternTokenizer tokenizer) throws IOException {
if (tokenizer.hreplacedubToken()) {
String token = tokenizer.getToken();
if ("method".equals(token)) {
return new MethodElement();
} else if ("uri".equals(token)) {
if (tokenizer.hreplacedubToken()) {
token = tokenizer.getToken();
if ("stem".equals(token)) {
return new RequestURIElement();
} else if ("query".equals(token)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
String query = request.getQueryString();
if (query != null) {
buf.append(query);
} else {
buf.append('-');
}
}
};
}
} else {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
String query = request.getQueryString();
if (query == null) {
buf.append(request.getRequestURI());
} else {
buf.append(request.getRequestURI());
buf.append('?');
buf.append(request.getQueryString());
}
}
};
}
}
} else if (tokenizer.hasParameter()) {
String parameter = tokenizer.getParameter();
if (parameter == null) {
log.error("No closing ) found for in decode");
return null;
}
return new RequestHeaderElement(parameter);
}
log.error("The next characters couldn't be decoded: " + tokenizer.getRemains());
return null;
}
19
Source : ExtendedAccessLogValve.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
protected AccessLogElement getServerToClientElement(PatternTokenizer tokenizer) throws IOException {
if (tokenizer.hreplacedubToken()) {
String token = tokenizer.getToken();
if ("status".equals(token)) {
return new HttpStatusCodeElement();
} else if ("comment".equals(token)) {
return new StringElement("?");
}
} else if (tokenizer.hasParameter()) {
String parameter = tokenizer.getParameter();
if (parameter == null) {
log.error("No closing ) found for in decode");
return null;
}
return new ResponseHeaderElement(parameter);
}
log.error("The next characters couldn't be decoded: " + tokenizer.getRemains());
return null;
}
19
Source : ExtendedAccessLogValve.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
protected AccessLogElement getXParameterElement(PatternTokenizer tokenizer) throws IOException {
if (!tokenizer.hreplacedubToken()) {
log.error("x param in wrong format. Needs to be 'x-#(...)' read the docs!");
return null;
}
String token = tokenizer.getToken();
if ("threadname".equals(token)) {
return new ThreadNameElement();
}
if (!tokenizer.hasParameter()) {
log.error("x param in wrong format. Needs to be 'x-#(...)' read the docs!");
return null;
}
String parameter = tokenizer.getParameter();
if (parameter == null) {
log.error("No closing ) found for in decode");
return null;
}
if ("A".equals(token)) {
return new ServletContextElement(parameter);
} else if ("C".equals(token)) {
return new CookieElement(parameter);
} else if ("R".equals(token)) {
return new RequestAttributeElement(parameter);
} else if ("S".equals(token)) {
return new SessionAttributeElement(parameter);
} else if ("H".equals(token)) {
return getServletRequestElement(parameter);
} else if ("P".equals(token)) {
return new RequestParameterElement(parameter);
} else if ("O".equals(token)) {
return new ResponseAllHeaderElement(parameter);
}
log.error("x param for servlet request, couldn't decode value: " + token);
return null;
}
19
Source : ExtendedAccessLogValve.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
protected AccessLogElement getServletRequestElement(String parameter) {
if ("authType".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap(request.getAuthType()));
}
};
} else if ("remoteUser".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap(request.getRemoteUser()));
}
};
} else if ("requestedSessionId".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap(request.getRequestedSessionId()));
}
};
} else if ("requestedSessionIdFromCookie".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap("" + request.isRequestedSessionIdFromCookie()));
}
};
} else if ("requestedSessionIdValid".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap("" + request.isRequestedSessionIdValid()));
}
};
} else if ("contentLength".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap("" + request.getContentLength()));
}
};
} else if ("characterEncoding".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap(request.getCharacterEncoding()));
}
};
} else if ("locale".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap(request.getLocale()));
}
};
} else if ("protocol".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap(request.getProtocol()));
}
};
} else if ("scheme".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(request.getScheme());
}
};
} else if ("secure".equals(parameter)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
buf.append(wrap("" + request.isSecure()));
}
};
}
log.error("x param for servlet request, couldn't decode value: " + parameter);
return null;
}
19
Source : ExtendedAccessLogValve.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
protected AccessLogElement getLogElement(String token, PatternTokenizer tokenizer) throws IOException {
if ("date".equals(token)) {
return new DateElement();
} else if ("time".equals(token)) {
if (tokenizer.hreplacedubToken()) {
String nextToken = tokenizer.getToken();
if ("taken".equals(nextToken)) {
return new ElapsedTimeElement(false);
}
} else {
return new TimeElement();
}
} else if ("bytes".equals(token)) {
return new ByteSentElement(true);
} else if ("cached".equals(token)) {
/* I don't know how to evaluate this! */
return new StringElement("-");
} else if ("c".equals(token)) {
String nextToken = tokenizer.getToken();
if ("ip".equals(nextToken)) {
return new RemoteAddrElement();
} else if ("dns".equals(nextToken)) {
return new HostElement();
}
} else if ("s".equals(token)) {
String nextToken = tokenizer.getToken();
if ("ip".equals(nextToken)) {
return new LocalAddrElement();
} else if ("dns".equals(nextToken)) {
return new AccessLogElement() {
@Override
public void addElement(StringBuilder buf, Date date, Request request, Response response, long time) {
String value;
try {
value = InetAddress.getLocalHost().getHostName();
} catch (Throwable e) {
ExceptionUtils.handleThrowable(e);
value = "localhost";
}
buf.append(value);
}
};
}
} else if ("cs".equals(token)) {
return getClientToServerElement(tokenizer);
} else if ("sc".equals(token)) {
return getServerToClientElement(tokenizer);
} else if ("sr".equals(token) || "rs".equals(token)) {
return getProxyElement(tokenizer);
} else if ("x".equals(token)) {
return getXParameterElement(tokenizer);
}
log.error("unable to decode with rest of chars starting: " + token);
return null;
}
19
Source : ReceiverBase.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* @return Returns the bind.
*/
public InetAddress getBind() {
if (bind == null) {
try {
if ("auto".equals(host)) {
host = java.net.InetAddress.getLocalHost().getHostAddress();
}
if (log.isDebugEnabled())
log.debug("Starting replication listener on address:" + host);
bind = java.net.InetAddress.getByName(host);
} catch (IOException ioe) {
log.error("Failed bind replication listener on address:" + host, ioe);
}
}
return bind;
}
19
Source : BioReceiver.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
@Override
public void run() {
try {
listen();
} catch (Exception x) {
log.error("Unable to run replication listener.", x);
}
}
19
Source : GzipInterceptor.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
@Override
public void messageReceived(ChannelMessage msg) {
try {
byte[] data = decompress(msg.getMessage().getBytes());
msg.getMessage().trim(msg.getMessage().getLength());
msg.getMessage().append(data, 0, data.length);
getPrevious().messageReceived(msg);
} catch (IOException x) {
log.error("Unable to decompress byte contents", x);
}
}
19
Source : GzipInterceptor.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
try {
byte[] data = compress(msg.getMessage().getBytes());
msg.getMessage().trim(msg.getMessage().getLength());
msg.getMessage().append(data, 0, data.length);
getNext().sendMessage(destination, msg, payload);
} catch (IOException x) {
log.error("Unable to compress byte contents");
throw new ChannelException(x);
}
}
19
Source : GroupChannel.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Sends a <code>NoRpcChannelReply</code> message to a member<br>
* This method gets invoked by the channel if a RPC message comes in
* and no channel listener accepts the message. This avoids timeout
* @param msg RpcMessage
* @param destination Member - the destination for the reply
*/
protected void sendNoRpcChannelReply(RpcMessage msg, Member destination) {
try {
// avoid circular loop
if (msg instanceof RpcMessage.NoRpcChannelReply)
return;
RpcMessage.NoRpcChannelReply reply = new RpcMessage.NoRpcChannelReply(msg.rpcId, msg.uuid);
send(new Member[] { destination }, reply, Channel.SEND_OPTIONS_ASYNCHRONOUS);
} catch (Exception x) {
log.error("Unable to find rpc channel, failed to send NoRpcChannelReply.", x);
}
}
19
Source : Bootstrap.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
// -------------------------------------------------------- Private Methods
private void initClreplacedLoaders() {
try {
commonLoader = createClreplacedLoader("common", null);
if (commonLoader == null) {
// no config file, default to this loader - we might be in a 'single' env.
commonLoader = this.getClreplaced().getClreplacedLoader();
}
catalinaLoader = createClreplacedLoader("server", commonLoader);
sharedLoader = createClreplacedLoader("shared", commonLoader);
} catch (Throwable t) {
handleThrowable(t);
log.error("Clreplaced loader creation threw exception", t);
System.exit(1);
}
}
19
Source : PersistentManagerBase.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Check, whether a session is loaded in memory
*
* @param id The session id for the session to be searched for
* @return {@code true}, if the session id is loaded in memory
* otherwise {@code false} is returned
*/
public boolean isLoaded(String id) {
try {
if (super.findSession(id) != null)
return true;
} catch (IOException e) {
log.error("checking isLoaded for id, " + id + ", " + e.getMessage(), e);
}
return false;
}
19
Source : JAASRealm.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Parses a comma-delimited list of clreplaced names, and store the clreplaced names
* in the provided List. Each clreplaced must implement
* <code>java.security.Principal</code>.
*
* @param clreplacedNamesString a comma-delimited list of fully qualified clreplaced names.
* @param clreplacedNamesList the list in which the clreplaced names will be stored.
* The list is cleared before being populated.
*/
protected void parseClreplacedNames(String clreplacedNamesString, List<String> clreplacedNamesList) {
clreplacedNamesList.clear();
if (clreplacedNamesString == null)
return;
ClreplacedLoader loader = this.getClreplaced().getClreplacedLoader();
if (isUseContextClreplacedLoader())
loader = Thread.currentThread().getContextClreplacedLoader();
String[] clreplacedNames = clreplacedNamesString.split("[ ]*,[ ]*");
for (int i = 0; i < clreplacedNames.length; i++) {
if (clreplacedNames[i].length() == 0)
continue;
try {
Clreplaced<?> principalClreplaced = Clreplaced.forName(clreplacedNames[i], false, loader);
if (Principal.clreplaced.isreplacedignableFrom(principalClreplaced)) {
clreplacedNamesList.add(clreplacedNames[i]);
} else {
log.error("Clreplaced " + clreplacedNames[i] + " is not implementing " + "java.security.Principal! Clreplaced not added.");
}
} catch (ClreplacedNotFoundException e) {
log.error("Clreplaced " + clreplacedNames[i] + " not found! Clreplaced not added.");
}
}
}
19
Source : CombinedRealm.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
@Override
protected String getPreplacedword(String username) {
// This method should never be called
// Stack trace will show where this was called from
UnsupportedOperationException uoe = new UnsupportedOperationException(sm.getString("combinedRealm.getPreplacedword"));
log.error(sm.getString("combinedRealm.unexpectedMethod"), uoe);
throw uoe;
}
19
Source : CombinedRealm.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
@Override
protected Principal getPrincipal(String username) {
// This method should never be called
// Stack trace will show where this was called from
UnsupportedOperationException uoe = new UnsupportedOperationException(sm.getString("combinedRealm.getPrincipal"));
log.error(sm.getString("combinedRealm.unexpectedMethod"), uoe);
throw uoe;
}
19
Source : BackupManager.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Start this component and implement the requirements
* of {@link org.apache.catalina.util.LifecycleBase#startInternal()}.
*
* Starts the cluster communication channel, this will connect with the
* other nodes in the cluster, and request the current session state to be
* transferred to this node.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
super.startInternal();
try {
if (cluster == null)
throw new LifecycleException(sm.getString("backupManager.noCluster", getName()));
LazyReplicatedMap<String, Session> map = new LazyReplicatedMap<String, Session>(this, cluster.getChannel(), rpcTimeout, getMapName(), getClreplacedLoaders(), terminateOnStartFailure);
map.setChannelSendOptions(mapSendOptions);
this.sessions = map;
} catch (Exception x) {
log.error(sm.getString("backupManager.startUnable", getName()), x);
throw new LifecycleException(sm.getString("backupManager.startFailed", getName()), x);
}
setState(LifecycleState.STARTING);
}
19
Source : FarmWarDeployer.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Delete the specified directory, including all of its contents and
* subdirectories recursively.
*
* @param dir
* File object representing the directory to be deleted
*/
protected void undeployDir(File dir) {
String[] files = dir.list();
if (files == null) {
files = new String[0];
}
for (int i = 0; i < files.length; i++) {
File file = new File(dir, files[i]);
if (file.isDirectory()) {
undeployDir(file);
} else {
if (!file.delete()) {
log.error(sm.getString("farmWarDeployer.deleteFail", file));
}
}
}
if (!dir.delete()) {
log.error(sm.getString("farmWarDeployer.deleteFail", dir));
}
}
19
Source : FarmWarDeployer.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Copy a file to the specified temp directory.
* @param from copy from temp
* @param to to host appBase directory
* @return true, copy successful
*/
protected boolean copy(File from, File to) {
java.io.FileInputStream is = null;
java.io.FileOutputStream os = null;
try {
if (!to.exists()) {
if (!to.createNewFile()) {
log.error(sm.getString("fileNewFail", to));
return false;
}
}
is = new java.io.FileInputStream(from);
os = new java.io.FileOutputStream(to, false);
byte[] buf = new byte[4096];
while (true) {
int len = is.read(buf);
if (len < 0)
break;
os.write(buf, 0, len);
}
} catch (IOException e) {
log.error(sm.getString("farmWarDeployer.fileCopyFail", from, to), e);
return false;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
log.debug(sm.getString("farmWarDeployer.streamCannotBeClosed", "InputStream", from), e);
}
}
if (os != null) {
try {
os.close();
} catch (IOException e) {
log.debug(sm.getString("farmWarDeployer.streamCannotBeClosed", "OutputStream", to), e);
}
}
}
return true;
}
19
Source : StandardService.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Remove the specified Connector from the set replacedociated from this
* Service. The removed Connector will also be disreplacedociated from our
* Container.
*
* @param connector The Connector to be removed
*/
@Override
public void removeConnector(Connector connector) {
synchronized (connectorsLock) {
int j = -1;
for (int i = 0; i < connectors.length; i++) {
if (connector == connectors[i]) {
j = i;
break;
}
}
if (j < 0)
return;
if (connectors[j].getState().isAvailable()) {
try {
connectors[j].stop();
} catch (LifecycleException e) {
log.error(sm.getString("standardService.connector.stopFailed", connectors[j]), e);
}
}
connector.setService(null);
int k = 0;
Connector[] results = new Connector[connectors.length - 1];
for (int i = 0; i < connectors.length; i++) {
if (i != j)
results[k++] = connectors[i];
}
connectors = results;
// Report this property change to interested listeners
support.firePropertyChange("connector", connector, null);
}
}
19
Source : StandardService.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Invoke a pre-startup initialization. This is used to allow connectors
* to bind to restricted ports under Unix operating environments.
*/
@Override
protected void initInternal() throws LifecycleException {
super.initInternal();
if (container != null) {
container.init();
}
// Initialize any Executors
for (Executor executor : findExecutors()) {
if (executor instanceof LifecycleMBeanBase) {
((LifecycleMBeanBase) executor).setDomain(getDomain());
}
executor.init();
}
// Initialize our defined Connectors
synchronized (connectorsLock) {
for (Connector connector : connectors) {
try {
connector.init();
} catch (Exception e) {
String message = sm.getString("standardService.connector.initFailed", connector);
log.error(message, e);
if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE"))
throw new LifecycleException(message);
}
}
}
}
19
Source : StandardService.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Removes an executor from the service
* @param ex Executor
*/
@Override
public void removeExecutor(Executor ex) {
synchronized (executors) {
if (executors.remove(ex) && getState().isAvailable()) {
try {
ex.stop();
} catch (LifecycleException e) {
log.error("Executor.stop", e);
}
}
}
}
19
Source : StandardService.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Adds a named executor to the service
* @param ex Executor
*/
@Override
public void addExecutor(Executor ex) {
synchronized (executors) {
if (!executors.contains(ex)) {
executors.add(ex);
if (getState().isAvailable())
try {
ex.start();
} catch (LifecycleException x) {
log.error("Executor.start", x);
}
}
}
}
19
Source : StandardService.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
@Override
protected void destroyInternal() throws LifecycleException {
// Destroy our defined Connectors
synchronized (connectorsLock) {
for (Connector connector : connectors) {
try {
connector.destroy();
} catch (Exception e) {
log.error(sm.getString("standardService.connector.destroyFailed", connector), e);
}
}
}
// Destroy any Executors
for (Executor executor : findExecutors()) {
executor.destroy();
}
if (container != null) {
container.destroy();
}
super.destroyInternal();
}
19
Source : StandardService.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Stop nested components ({@link Executor}s, {@link Connector}s and
* {@link Container}s) and implement the requirements of
* {@link org.apache.catalina.util.LifecycleBase#stopInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that needs to be reported
*/
@Override
protected void stopInternal() throws LifecycleException {
// Pause connectors first
synchronized (connectorsLock) {
for (Connector connector : connectors) {
try {
connector.pause();
} catch (Exception e) {
log.error(sm.getString("standardService.connector.pauseFailed", connector), e);
}
}
}
if (log.isInfoEnabled())
log.info(sm.getString("standardService.stop.name", this.name));
setState(LifecycleState.STOPPING);
// Stop our defined Container second
if (container != null) {
synchronized (container) {
container.stop();
}
}
// Now stop the connectors
synchronized (connectorsLock) {
for (Connector connector : connectors) {
if (!LifecycleState.STARTED.equals(connector.getState())) {
// Connectors only need stopping if they are currently
// started. They may have failed to start or may have been
// stopped (e.g. via a JMX call)
continue;
}
try {
connector.stop();
} catch (Exception e) {
log.error(sm.getString("standardService.connector.stopFailed", connector), e);
}
}
}
synchronized (executors) {
for (Executor executor : executors) {
executor.stop();
}
}
}
19
Source : StandardPipeline.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* <p>Add a new Valve to the end of the pipeline replacedociated with this
* Container. Prior to adding the Valve, the Valve's
* <code>setContainer()</code> method will be called, if it implements
* <code>Contained</code>, with the owning Container as an argument.
* The method may throw an
* <code>IllegalArgumentException</code> if this Valve chooses not to
* be replacedociated with this Container, or <code>IllegalStateException</code>
* if it is already replacedociated with a different Container.</p>
*
* @param valve Valve to be added
*
* @exception IllegalArgumentException if this Container refused to
* accept the specified Valve
* @exception IllegalArgumentException if the specified Valve refuses to be
* replacedociated with this Container
* @exception IllegalStateException if the specified Valve is already
* replacedociated with a different Container
*
* 责任链添加处理Value
*/
@Override
public void addValve(Valve valve) {
// Validate that we can add this Valve
if (valve instanceof Contained)
((Contained) valve).setContainer(this.container);
// Start the new component if necessary
if (getState().isAvailable()) {
if (valve instanceof Lifecycle) {
try {
((Lifecycle) valve).start();
} catch (LifecycleException e) {
log.error("StandardPipeline.addValve: start: ", e);
}
}
}
// Add this Valve to the set replacedociated with this Pipeline
if (first == null) {
first = valve;
valve.setNext(basic);
} else {
Valve current = first;
while (current != null) {
if (current.getNext() == basic) {
current.setNext(valve);
valve.setNext(basic);
break;
}
current = current.getNext();
}
}
container.fireContainerEvent(Container.ADD_VALVE_EVENT, valve);
}
19
Source : StandardPipeline.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Remove the specified Valve from the pipeline replacedociated with this
* Container, if it is found; otherwise, do nothing. If the Valve is
* found and removed, the Valve's <code>setContainer(null)</code> method
* will be called if it implements <code>Contained</code>.
*
* @param valve Valve to be removed
*/
@Override
public void removeValve(Valve valve) {
Valve current;
if (first == valve) {
first = first.getNext();
current = null;
} else {
current = first;
}
while (current != null) {
if (current.getNext() == valve) {
current.setNext(valve.getNext());
break;
}
current = current.getNext();
}
if (first == basic)
first = null;
if (valve instanceof Contained)
((Contained) valve).setContainer(null);
if (valve instanceof Lifecycle) {
// Stop this valve if necessary
if (getState().isAvailable()) {
try {
((Lifecycle) valve).stop();
} catch (LifecycleException e) {
log.error("StandardPipeline.removeValve: stop: ", e);
}
}
try {
((Lifecycle) valve).destroy();
} catch (LifecycleException e) {
log.error("StandardPipeline.removeValve: destroy: ", e);
}
}
container.fireContainerEvent(Container.REMOVE_VALVE_EVENT, valve);
}
19
Source : StandardPipeline.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* <p>Set the Valve instance that has been distinguished as the basic
* Valve for this Pipeline (if any). Prior to setting the basic Valve,
* the Valve's <code>setContainer()</code> will be called, if it
* implements <code>Contained</code>, with the owning Container as an
* argument. The method may throw an <code>IllegalArgumentException</code>
* if this Valve chooses not to be replacedociated with this Container, or
* <code>IllegalStateException</code> if it is already replacedociated with
* a different Container.</p>
*
* @param valve Valve to be distinguished as the basic Valve
*/
@Override
public void setBasic(Valve valve) {
// Change components if necessary
Valve oldBasic = this.basic;
if (oldBasic == valve)
return;
// Stop the old component if necessary
if (oldBasic != null) {
if (getState().isAvailable() && (oldBasic instanceof Lifecycle)) {
try {
((Lifecycle) oldBasic).stop();
} catch (LifecycleException e) {
log.error("StandardPipeline.setBasic: stop", e);
}
}
if (oldBasic instanceof Contained) {
try {
((Contained) oldBasic).setContainer(null);
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
}
}
}
// Start the new component if necessary
if (valve == null)
return;
if (valve instanceof Contained) {
((Contained) valve).setContainer(this.container);
}
if (getState().isAvailable() && valve instanceof Lifecycle) {
try {
((Lifecycle) valve).start();
} catch (LifecycleException e) {
log.error("StandardPipeline.setBasic: start", e);
return;
}
}
// Update the pipeline
Valve current = first;
while (current != null) {
if (current.getNext() == oldBasic) {
current.setNext(valve);
break;
}
current = current.getNext();
}
this.basic = valve;
}
19
Source : ContainerBase.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
// 添加子容器
private void addChildInternal(Container child) {
if (log.isDebugEnabled())
log.debug("Add child " + child + " " + this);
synchronized (children) {
if (children.get(child.getName()) != null)
throw new IllegalArgumentException("addChild: Child name '" + child.getName() + "' is not unique");
// May throw IAE
child.setParent(this);
children.put(child.getName(), child);
}
// Start child
// Don't do this inside sync block - start can be a slow process and
// locking the children object can cause problems elsewhere
try {
if ((getState().isAvailable() || LifecycleState.STARTING_PREP.equals(getState())) && startChildren) {
// 就是指调用StandardContext的start方法。
child.start();
}
} catch (LifecycleException e) {
log.error("ContainerBase.addChild: start: ", e);
throw new IllegalStateException("ContainerBase.addChild: start: " + e);
} finally {
fireContainerEvent(ADD_CHILD_EVENT, child);
}
}
19
Source : AprLifecycleListener.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
private static void initializeSSL() throws Exception {
if ("off".equalsIgnoreCase(SSLEngine)) {
return;
}
if (sslInitialized) {
// only once per VM
return;
}
sslInitialized = true;
String methodName = "randSet";
Clreplaced<?>[] paramTypes = new Clreplaced[1];
paramTypes[0] = String.clreplaced;
Object[] paramValues = new Object[1];
paramValues[0] = SSLRandomSeed;
Clreplaced<?> clazz = Clreplaced.forName("org.apache.tomcat.jni.SSL");
Method method = clazz.getMethod(methodName, paramTypes);
method.invoke(null, paramValues);
methodName = "initialize";
paramValues[0] = "on".equalsIgnoreCase(SSLEngine) ? null : SSLEngine;
method = clazz.getMethod(methodName, paramTypes);
method.invoke(null, paramValues);
if (!(null == FIPSMode || "off".equalsIgnoreCase(FIPSMode))) {
fipsModeActive = false;
final boolean enterFipsMode;
int fipsModeState = SSL.fipsModeGet();
if (log.isDebugEnabled()) {
log.debug(sm.getString("aprListener.currentFIPSMode", Integer.valueOf(fipsModeState)));
}
if ("on".equalsIgnoreCase(FIPSMode)) {
if (fipsModeState == FIPS_ON) {
log.info(sm.getString("aprListener.skipFIPSInitialization"));
fipsModeActive = true;
enterFipsMode = false;
} else {
enterFipsMode = true;
}
} else if ("require".equalsIgnoreCase(FIPSMode)) {
if (fipsModeState == FIPS_ON) {
fipsModeActive = true;
enterFipsMode = false;
} else {
throw new IllegalStateException(sm.getString("aprListener.requireNotInFIPSMode"));
}
} else if ("enter".equalsIgnoreCase(FIPSMode)) {
if (fipsModeState == FIPS_OFF) {
enterFipsMode = true;
} else {
throw new IllegalStateException(sm.getString("aprListener.enterAlreadyInFIPSMode", Integer.valueOf(fipsModeState)));
}
} else {
throw new IllegalArgumentException(sm.getString("aprListener.wrongFIPSMode", FIPSMode));
}
if (enterFipsMode) {
log.info(sm.getString("aprListener.initializingFIPS"));
fipsModeState = SSL.fipsModeSet(FIPS_ON);
if (fipsModeState != FIPS_ON) {
// This case should be handled by the native method,
// but we'll make absolutely sure, here.
String message = sm.getString("aprListener.initializeFIPSFailed");
log.error(message);
throw new IllegalStateException(message);
}
fipsModeActive = true;
log.info(sm.getString("aprListener.initializeFIPSSuccess"));
}
}
log.info(sm.getString("aprListener.initializedOpenSSL", SSL.versionString()));
sslAvailable = true;
}
19
Source : Connector.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Pause the connector.
*/
public void resume() {
try {
protocolHandler.resume();
} catch (Exception e) {
log.error(sm.getString("coyoteConnector.protocolHandlerResumeFailed"), e);
}
}
19
Source : Connector.java
with Apache License 2.0
from wangyingjie
with Apache License 2.0
from wangyingjie
/**
* Pause the connector.
*/
public void pause() {
try {
protocolHandler.pause();
} catch (Exception e) {
log.error(sm.getString("coyoteConnector.protocolHandlerPauseFailed"), e);
}
}
19
Source : 839.java
with MIT License
from masud-technope
with MIT License
from masud-technope
/**
* Validates a connection.
* @param validateAction the action used. One of {@link #VALIDATE_BORROW}, {@link #VALIDATE_IDLE},
* {@link #VALIDATE_INIT} or {@link #VALIDATE_RETURN}
* @param sql the SQL to be used during validation. If the {@link PoolConfiguration#setInitSQL(String)} has been called with a non null
* value and the action is {@link #VALIDATE_INIT} the init SQL will be used for validation.
*
* @return true if the connection was validated successfully. It returns true even if validation was not performed, such as when
* {@link PoolConfiguration#setValidationInterval(long)} has been called with a positive value.
* <p>
* false if the validation failed. The caller should close the connection if false is returned since a session could have been left in
* an unknown state during initialization.
*/
public boolean validate(int validateAction, String sql) {
if (this.isDiscarded()) {
return false;
}
if (!doValidate(validateAction)) {
// no validation required, no init sql and props not set
return true;
}
// Don't bother validating if already have recently enough
long now = System.currentTimeMillis();
if (validateAction != VALIDATE_INIT && poolProperties.getValidationInterval() > 0 && (now - this.lastValidated) < poolProperties.getValidationInterval()) {
return true;
}
if (poolProperties.getValidator() != null) {
if (poolProperties.getValidator().validate(connection, validateAction)) {
this.lastValidated = now;
return true;
} else {
if (getPoolProperties().getLogValidationErrors()) {
log.error("Custom validation through " + poolProperties.getValidator() + " failed.");
}
return false;
}
}
String query = sql;
if (validateAction == VALIDATE_INIT && poolProperties.getInitSQL() != null) {
query = poolProperties.getInitSQL();
}
if (query == null) {
query = poolProperties.getValidationQuery();
}
Statement stmt = null;
try {
stmt = connection.createStatement();
int validationQueryTimeout = poolProperties.getValidationQueryTimeout();
if (validationQueryTimeout > 0) {
stmt.setQueryTimeout(validationQueryTimeout);
}
stmt.execute(query);
stmt.close();
this.lastValidated = now;
return true;
} catch (Exception ex) {
if (getPoolProperties().getLogValidationErrors()) {
log.warn("SQL Validation error", ex);
} else if (log.isDebugEnabled()) {
log.debug("Unable to validate object:", ex);
}
if (stmt != null)
try {
stmt.close();
} catch (Exception ignore2) {
}
}
return false;
}
19
Source : 1710.java
with MIT License
from masud-technope
with MIT License
from masud-technope
/**
* Write a String out at the current write position. Strings are
* encoded with the length in two bytes first, then the string, and
* then a terminating \0 (which is <B>not</B> included in the
* encoded length). The terminator is for the convenience of the C
* code, where it saves a round of copying. A null string is
* encoded as a string with length 0.
*/
public void appendString(String str) {
if (str == null) {
log.error(sm.getString("ajpmessage.null"), new NullPointerException());
appendInt(0);
appendByte(0);
return;
}
int len = str.length();
appendInt(len);
for (int i = 0; i < len; i++) {
char c = str.charAt(i);
// streams properly encode their output.
if (((c <= 31) && (c != 9)) || c == 127 || c > 255) {
c = ' ';
}
appendByte(c);
}
appendByte(0);
}
19
Source : 1399.java
with MIT License
from masud-technope
with MIT License
from masud-technope
/**
* Process an existing async connection. If processing is required, preplacedes
* the wrapped socket to an executor for processing.
*
* @param socket The socket replacedociated with the client.
* @param status Only OPEN and TIMEOUT are used. The others are used for
* Comet requests that are not supported by the BIO (JIO)
* Connector.
*/
@Override
public void processSocketAsync(SocketWrapper<Socket> socket, SocketStatus status) {
try {
synchronized (socket) {
if (waitingRequests.remove(socket)) {
SocketProcessor proc = new SocketProcessor(socket, status);
ClreplacedLoader loader = Thread.currentThread().getContextClreplacedLoader();
try {
// threads should not be created by the webapp clreplacedloader
if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(getClreplaced().getClreplacedLoader());
AccessController.doPrivileged(pa);
} else {
Thread.currentThread().setContextClreplacedLoader(getClreplaced().getClreplacedLoader());
}
// During shutdown, executor may be null - avoid NPE
if (!running) {
return;
}
getExecutor().execute(proc);
// TODO gotta catch RejectedExecutionException and properly handle it
} finally {
if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(loader);
AccessController.doPrivileged(pa);
} else {
Thread.currentThread().setContextClreplacedLoader(loader);
}
}
}
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.error(sm.getString("endpoint.process.fail"), t);
}
}
19
Source : JIoEndpoint.java
with Apache License 2.0
from how2j
with Apache License 2.0
from how2j
/**
* Process an existing async connection. If processing is required, preplacedes
* the wrapped socket to an executor for processing.
*
* @param socket
* The socket replacedociated with the client.
* @param status
* Only OPEN and TIMEOUT are used. The others are used for Comet
* requests that are not supported by the BIO (JIO) Connector.
*/
@Override
public void processSocketAsync(SocketWrapper<Socket> socket, SocketStatus status) {
try {
synchronized (socket) {
if (waitingRequests.remove(socket)) {
SocketProcessor proc = new SocketProcessor(socket, status);
ClreplacedLoader loader = Thread.currentThread().getContextClreplacedLoader();
try {
// threads should not be created by the webapp
// clreplacedloader
if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(getClreplaced().getClreplacedLoader());
AccessController.doPrivileged(pa);
} else {
Thread.currentThread().setContextClreplacedLoader(getClreplaced().getClreplacedLoader());
}
// During shutdown, executor may be null - avoid NPE
if (!running) {
return;
}
getExecutor().execute(proc);
// TODO gotta catch RejectedExecutionException and
// properly handle it
} finally {
if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(loader);
AccessController.doPrivileged(pa);
} else {
Thread.currentThread().setContextClreplacedLoader(loader);
}
}
}
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
// This means we got an OOM or similar creating a thread, or that
// the pool and its queue are full
log.error(sm.getString("endpoint.process.fail"), t);
}
}
See More Examples