📄 namingresources.java
字号:
/*
* $Header: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/deploy/NamingResources.java,v 1.3 2003/01/27 23:45:19 costin Exp $
* $Revision: 1.3 $
* $Date: 2003/01/27 23:45:19 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* [Additional notices, if required by prior licensing conditions]
*
*/
package org.apache.catalina.deploy;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashMap;
import java.util.Hashtable;
import java.io.Serializable;
/**
* Holds and manages the naming resources defined in the J2EE Enterprise
* Naming Context and their associated JNDI context.
*
* @author Remy Maucherat
* @version $Revision: 1.3 $ $Date: 2003/01/27 23:45:19 $
*/
public final class NamingResources implements Serializable {
// ----------------------------------------------------------- Constructors
/**
* Create a new NamingResources instance.
*/
public NamingResources() {
}
// ----------------------------------------------------- Instance Variables
/**
* Associated container object.
*/
private Object container = null;
/**
* List of naming entries, keyed by name. The value is the entry type, as
* declared by the user.
*/
private Hashtable entries = new Hashtable();
/**
* The EJB resource references for this web application, keyed by name.
*/
private HashMap ejbs = new HashMap();
/**
* The environment entries for this web application, keyed by name.
*/
private HashMap envs = new HashMap();
/**
* The local EJB resource references for this web application, keyed by
* name.
*/
private HashMap localEjbs = new HashMap();
/**
* The message destination referencess for this web application,
* keyed by name.
*/
private HashMap mdrs = new HashMap();
/**
* The resource environment references for this web application,
* keyed by name.
*/
private HashMap resourceEnvRefs = new HashMap();
/**
* The resource references for this web application, keyed by name.
*/
private HashMap resources = new HashMap();
/**
* The resource links for this web application, keyed by name.
*/
private HashMap resourceLinks = new HashMap();
/**
* The resource parameters for this web application, keyed by name.
*/
private HashMap resourceParams = new HashMap();
/**
* The property change support for this component.
*/
protected PropertyChangeSupport support = new PropertyChangeSupport(this);
// ------------------------------------------------------------- Properties
/**
* Get the container with which the naming resources are associated.
*/
public Object getContainer() {
return container;
}
/**
* Set the container with which the naming resources are associated.
*/
public void setContainer(Object container) {
this.container = container;
}
/**
* Add an EJB resource reference for this web application.
*
* @param ejb New EJB resource reference
*/
public void addEjb(ContextEjb ejb) {
if (entries.containsKey(ejb.getName())) {
return;
} else {
entries.put(ejb.getName(), ejb.getType());
}
synchronized (ejbs) {
ejb.setNamingResources(this);
ejbs.put(ejb.getName(), ejb);
}
support.firePropertyChange("ejb", null, ejb);
}
/**
* Add an environment entry for this web application.
*
* @param environment New environment entry
*/
public void addEnvironment(ContextEnvironment environment) {
if (entries.containsKey(environment.getName())) {
return;
} else {
entries.put(environment.getName(), environment.getType());
}
synchronized (envs) {
environment.setNamingResources(this);
envs.put(environment.getName(), environment);
}
support.firePropertyChange("environment", null, environment);
}
/**
* Add resource parameters for this web application.
*
* @param resourceParameters New resource parameters
*/
public void addResourceParams(ResourceParams resourceParameters) {
synchronized (resourceParams) {
if (resourceParams.containsKey(resourceParameters.getName())) {
return;
}
resourceParameters.setNamingResources(this);
resourceParams.put(resourceParameters.getName(),
resourceParameters);
}
support.firePropertyChange("resourceParams", null, resourceParameters);
}
/**
* Add a local EJB resource reference for this web application.
*
* @param ejb New EJB resource reference
*/
public void addLocalEjb(ContextLocalEjb ejb) {
if (entries.containsKey(ejb.getName())) {
return;
} else {
entries.put(ejb.getName(), ejb.getType());
}
synchronized (localEjbs) {
ejb.setNamingResources(this);
localEjbs.put(ejb.getName(), ejb);
}
support.firePropertyChange("localEjb", null, ejb);
}
/**
* Add a message destination reference for this web application.
*
* @param mdr New message destination reference
*/
public void addMessageDestinationRef(MessageDestinationRef mdr) {
if (entries.containsKey(mdr.getName())) {
return;
} else {
entries.put(mdr.getName(), mdr.getType());
}
synchronized (mdrs) {
mdr.setNamingResources(this);
mdrs.put(mdr.getName(), mdr);
}
support.firePropertyChange("messageDestinationRef", null, mdr);
}
/**
* Add a property change listener to this component.
*
* @param listener The listener to add
*/
public void addPropertyChangeListener(PropertyChangeListener listener) {
support.addPropertyChangeListener(listener);
}
/**
* Add a resource reference for this web application.
*
* @param resource New resource reference
*/
public void addResource(ContextResource resource) {
if (entries.containsKey(resource.getName())) {
return;
} else {
entries.put(resource.getName(), resource.getType());
}
synchronized (resources) {
resource.setNamingResources(this);
resources.put(resource.getName(), resource);
}
support.firePropertyChange("resource", null, resource);
}
/**
* Add a resource environment reference for this web application.
*
* @param name The resource environment reference name
* @param type The resource environment reference type
*/
public void addResourceEnvRef(String name, String type) {
if (entries.containsKey(name)) {
return;
} else {
entries.put(name, type);
}
synchronized (resourceEnvRefs) {
resourceEnvRefs.put(name, type);
}
support.firePropertyChange("resourceEnvRef", null,
name + ":" + type);
}
/**
* Add a resource link for this web application.
*
* @param resource New resource link
*/
public void addResourceLink(ContextResourceLink resourceLink) {
if (entries.containsKey(resourceLink.getName())) {
return;
} else {
Object value = resourceLink.getType();
if (value == null) {
value = "";
}
entries.put(resourceLink.getName(), value);
}
synchronized (resourceLinks) {
resourceLink.setNamingResources(this);
resourceLinks.put(resourceLink.getName(), resourceLink);
}
support.firePropertyChange("resourceLink", null, resourceLink);
}
/**
* Return the EJB resource reference with the specified name, if any;
* otherwise, return <code>null</code>.
*
* @param name Name of the desired EJB resource reference
*/
public ContextEjb findEjb(String name) {
synchronized (ejbs) {
return ((ContextEjb) ejbs.get(name));
}
}
/**
* Return the defined EJB resource references for this application.
* If there are none, a zero-length array is returned.
*/
public ContextEjb[] findEjbs() {
synchronized (ejbs) {
ContextEjb results[] = new ContextEjb[ejbs.size()];
return ((ContextEjb[]) ejbs.values().toArray(results));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -