本文整理汇总了Java中org.apache.catalina.LifecycleListener类的典型用法代码示例。如果您正苦于以下问题:Java LifecycleListener类的具体用法?Java LifecycleListener怎么用?Java LifecycleListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LifecycleListener类属于org.apache.catalina包,在下文中一共展示了LifecycleListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeLifecycleListener
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Remove a lifecycle event listener from this component.
*
* @param listener The listener to remove
*/
public void removeLifecycleListener(LifecycleListener listener) {
synchronized (listenersLock) {
int n = -1;
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
n = i;
break;
}
}
if (n < 0)
return;
LifecycleListener results[] =
new LifecycleListener[listeners.length - 1];
int j = 0;
for (int i = 0; i < listeners.length; i++) {
if (i != n)
results[j++] = listeners[i];
}
listeners = results;
}
}
示例2: removeLifecycleListener
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Remove a lifecycle event listener from this component.
*
* @param listener
* The listener to remove
*/
public void removeLifecycleListener(LifecycleListener listener) {
synchronized (listenersLock) {
int n = -1;
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
n = i;
break;
}
}
if (n < 0)
return;
LifecycleListener results[] = new LifecycleListener[listeners.length - 1];
int j = 0;
for (int i = 0; i < listeners.length; i++) {
if (i != n)
results[j++] = listeners[i];
}
listeners = results;
}
}
示例3: begin
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Handle the beginning of an XML element.
*
* @param attributes The attributes of this element
*
* @exception Exception if a processing error occurs
*/
public void begin(Attributes attributes) throws Exception {
// Instantiate a new LifecyleListener implementation object
String className = listenerClass;
if (attributeName != null) {
String value = attributes.getValue(attributeName);
if (value != null)
className = value;
}
Class clazz = Class.forName(className);
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
// Add this LifecycleListener to our associated component
Lifecycle lifecycle = (Lifecycle) digester.peek();
lifecycle.addLifecycleListener(listener);
}
示例4: fireLifecycleEvent
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Notify all lifecycle event listeners that a particular event has
* occurred for this Container. The default implementation performs
* this notification synchronously using the calling thread.
*
* @param type Event type
* @param data Event data
*/
public void fireLifecycleEvent(String type, Object data) {
LifecycleEvent event = new LifecycleEvent(lifecycle, type, data);
LifecycleListener interested[] = null;
synchronized (listeners) {
interested = (LifecycleListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].lifecycleEvent(event);
}
示例5: addLifecycleListener
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* 增加生命周期的监听,用数组存储
* Add a lifecycle event listener to this component.
*
* @param listener The listener to add
*/
public void addLifecycleListener(LifecycleListener listener) {
synchronized (listenersLock) {
LifecycleListener results[] =
new LifecycleListener[listeners.length + 1];
for (int i = 0; i < listeners.length; i++)
results[i] = listeners[i];
results[listeners.length] = listener;
listeners = results;
}
}
示例6: ListenersInfo
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
public ListenersInfo(Container container,
ContainerListener[] containerListeners,
LifecycleListener[] lifecycleListeners) {
this.container = container;
this.containerListeners = containerListeners;
this.lifecycleListeners = lifecycleListeners;
}
示例7: deploy
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Deploy a web application for the specified user if they have such an
* application in the defined directory within their home directory.
*
* @param user Username owning the application to be deployed
* @param home Home directory of this user
*/
private void deploy(String user, String home) {
// Does this user have a web application to be deployed?
String contextPath = "/~" + user;
if (host.findChild(contextPath) != null)
return;
File app = new File(home, directoryName);
if (!app.exists() || !app.isDirectory())
return;
/*
File dd = new File(app, "/WEB-INF/web.xml");
if (!dd.exists() || !dd.isFile() || !dd.canRead())
return;
*/
host.getLogger().info(sm.getString("userConfig.deploy", user));
// Deploy the web application for this user
try {
Class clazz = Class.forName(contextClass);
Context context =
(Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(app.toString());
if (context instanceof Lifecycle) {
clazz = Class.forName(configClass);
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);
}
host.addChild(context);
} catch (Exception e) {
host.getLogger().error(sm.getString("userConfig.error", user), e);
}
}
示例8: fireLifecycleEvent
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Notify all lifecycle event listeners that a particular event has
* occurred for this Container. The default implementation performs
* this notification synchronously using the calling thread.
*
* @param type Event type
* @param data Event data
*/
public void fireLifecycleEvent(String type, Object data) {
LifecycleEvent event = new LifecycleEvent(lifecycle, type, data);
LifecycleListener interested[] = listeners;
for (int i = 0; i < interested.length; i++)
interested[i].lifecycleEvent(event);
}
示例9: addLifecycleListener
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Add a lifecycle event listener to this component.
*
* @param listener The listener to add
*/
public void addLifecycleListener(LifecycleListener listener) {
synchronized (listenersLock) {
LifecycleListener results[] =
new LifecycleListener[listeners.length + 1];
for (int i = 0; i < listeners.length; i++)
results[i] = listeners[i];
results[listeners.length] = listener;
listeners = results;
}
}
示例10: addLifecycleListener
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Add a lifecycle event listener to this component.
*
* @param listener
* The listener to add
*/
public void addLifecycleListener(LifecycleListener listener) {
synchronized (listenersLock) {
LifecycleListener results[] = new LifecycleListener[listeners.length + 1];
for (int i = 0; i < listeners.length; i++)
results[i] = listeners[i];
results[listeners.length] = listener;
listeners = results;
}
}
示例11: addLifecycleListener
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Add a lifecycle event listener to this component.
*
* @param listener The listener to add
*/
public void addLifecycleListener(LifecycleListener listener) {
synchronized (listeners) {
LifecycleListener results[] =
new LifecycleListener[listeners.length + 1];
for (int i = 0; i < listeners.length; i++)
results[i] = listeners[i];
results[listeners.length] = listener;
listeners = results;
}
}
示例12: deploy
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Deploy a web application for the specified user if they have such an
* application in the defined directory within their home directory.
*
* @param user
* Username owning the application to be deployed
* @param home
* Home directory of this user
*/
private void deploy(String user, String home) {
// Does this user have a web application to be deployed?
String contextPath = "/~" + user;
if (host.findChild(contextPath) != null)
return;
File app = new File(home, directoryName);
if (!app.exists() || !app.isDirectory())
return;
/*
* File dd = new File(app, "/WEB-INF/web.xml"); if (!dd.exists() ||
* !dd.isFile() || !dd.canRead()) return;
*/
host.getLogger().info(sm.getString("userConfig.deploy", user));
// Deploy the web application for this user
try {
Class<?> clazz = Class.forName(contextClass);
Context context = (Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(app.toString());
clazz = Class.forName(configClass);
LifecycleListener listener = (LifecycleListener) clazz.newInstance();
context.addLifecycleListener(listener);
host.addChild(context);
} catch (Exception e) {
host.getLogger().error(sm.getString("userConfig.error", user), e);
}
}
示例13: storeServer
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Store the specified Server properties.
*
* @param writer PrintWriter to which we are storing
* @param indent Number of spaces to indent this element
* @param server Object to be stored
*
* @exception Exception if an exception occurs while storing
*/
private void storeServer(PrintWriter writer, int indent,
Server server) throws Exception {
// Store the beginning of this element
writer.println("<?xml version='1.0' encoding='utf-8'?>");
for (int i = 0; i < indent; i++) {
writer.print(' ');
}
writer.print("<Server");
storeAttributes(writer, server);
writer.println(">");
// Store nested <Listener> elements
if (server instanceof Lifecycle) {
LifecycleListener listeners[] =
((Lifecycle) server).findLifecycleListeners();
for (int i = 0; i < listeners.length; i++) {
storeListener(writer, indent + 2, listeners[i]);
}
}
// Store nested <GlobalNamingResources> element
NamingResources globalNamingResources =
server.getGlobalNamingResources();
if (globalNamingResources != null) {
for (int i = 0; i < indent + 2; i++) {
writer.print(' ');
}
writer.println("<GlobalNamingResources>");
storeNamingResources(writer, indent + 4, globalNamingResources);
for (int i = 0; i < indent + 2; i++) {
writer.print(' ');
}
writer.println("</GlobalNamingResources>");
}
// Store nested <Service> elements
Service services[] = server.findServices();
for (int i = 0; i < services.length; i++) {
storeService(writer, indent + 2, services[i]);
}
// Store the ending of this element
for (int i = 0; i < indent; i++) {
writer.print(' ');
}
writer.println("</Server>");
}
示例14: deploy
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Deploy a web application for the specified user if they have such an
* application in the defined directory within their home directory.
*
* @param user Username owning the application to be deployed
* @param home Home directory of this user
*/
private void deploy(String user, String home) {
// Does this user have a web application to be deployed?
String contextPath = "/~" + user;
if (host.findChild(contextPath) != null)
return;
File app = new File(home, directoryName);
if (!app.exists() || !app.isDirectory())
return;
/*
File dd = new File(app, "/WEB-INF/web.xml");
if (!dd.exists() || !dd.isFile() || !dd.canRead())
return;
*/
log(sm.getString("userConfig.deploy", user));
// Deploy the web application for this user
try {
Class clazz = Class.forName(contextClass);
Context context =
(Context) clazz.newInstance();
context.setPath(contextPath);
context.setDocBase(app.toString());
if (context instanceof Lifecycle) {
clazz = Class.forName(configClass);
LifecycleListener listener =
(LifecycleListener) clazz.newInstance();
((Lifecycle) context).addLifecycleListener(listener);
}
host.addChild(context);
} catch (Exception e) {
log(sm.getString("userConfig.error", user), e);
}
}
示例15: findLifecycleListeners
import org.apache.catalina.LifecycleListener; //导入依赖的package包/类
/**
* Get the lifecycle listeners associated with this lifecycle. If this
* Lifecycle has no listeners registered, a zero-length array is returned.
*/
@Override
public LifecycleListener[] findLifecycleListeners() {
return new LifecycleListener[0];
}