use of java.util.concurrent.locks.Lock in project tomcat by apache.
the class ContainerBase method getCluster.
/**
* Return the Cluster with which this Container is associated. If there is
* no associated Cluster, return the Cluster associated with our parent
* Container (if any); otherwise return <code>null</code>.
*/
@Override
public Cluster getCluster() {
Lock readLock = clusterLock.readLock();
readLock.lock();
try {
if (cluster != null)
return cluster;
if (parent != null)
return parent.getCluster();
return null;
} finally {
readLock.unlock();
}
}
use of java.util.concurrent.locks.Lock in project tomcat by apache.
the class StandardContext method resourcesStop.
/**
* Deallocate resources and destroy proxy.
* @return <code>true</code> if no error occurred
*/
public boolean resourcesStop() {
boolean ok = true;
Lock writeLock = resourcesLock.writeLock();
writeLock.lock();
try {
if (resources != null) {
resources.stop();
}
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
log.error(sm.getString("standardContext.resourcesStop"), t);
ok = false;
} finally {
writeLock.unlock();
}
return ok;
}
use of java.util.concurrent.locks.Lock in project tomcat by apache.
the class StandardContext method setLoader.
@Override
public void setLoader(Loader loader) {
Lock writeLock = loaderLock.writeLock();
writeLock.lock();
Loader oldLoader = null;
try {
// Change components if necessary
oldLoader = this.loader;
if (oldLoader == loader)
return;
this.loader = loader;
// Stop the old component if necessary
if (getState().isAvailable() && (oldLoader != null) && (oldLoader instanceof Lifecycle)) {
try {
((Lifecycle) oldLoader).stop();
} catch (LifecycleException e) {
log.error("StandardContext.setLoader: stop: ", e);
}
}
// Start the new component if necessary
if (loader != null)
loader.setContext(this);
if (getState().isAvailable() && (loader != null) && (loader instanceof Lifecycle)) {
try {
((Lifecycle) loader).start();
} catch (LifecycleException e) {
log.error("StandardContext.setLoader: start: ", e);
}
}
} finally {
writeLock.unlock();
}
// Report this property change to interested listeners
support.firePropertyChange("loader", oldLoader, loader);
}
use of java.util.concurrent.locks.Lock in project tomcat by apache.
the class NotificationInfo method addNotifType.
// --------------------------------------------------------- Public Methods
/**
* Add a new notification type to the set managed by an MBean.
*
* @param notifType The new notification type
*/
public void addNotifType(String notifType) {
Lock writeLock = notifTypesLock.writeLock();
writeLock.lock();
try {
String[] results = new String[notifTypes.length + 1];
System.arraycopy(notifTypes, 0, results, 0, notifTypes.length);
results[notifTypes.length] = notifType;
notifTypes = results;
this.info = null;
} finally {
writeLock.unlock();
}
}
use of java.util.concurrent.locks.Lock in project tomcat by apache.
the class NotificationInfo method toString.
/**
* Return a string representation of this notification descriptor.
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder("NotificationInfo[");
sb.append("name=");
sb.append(name);
sb.append(", description=");
sb.append(description);
sb.append(", notifTypes=");
Lock readLock = notifTypesLock.readLock();
readLock.lock();
try {
sb.append(notifTypes.length);
} finally {
readLock.unlock();
}
sb.append("]");
return (sb.toString());
}
Aggregations