init
This commit is contained in:
96
java/org/apache/catalina/storeconfig/CatalinaClusterSF.java
Normal file
96
java/org/apache/catalina/storeconfig/CatalinaClusterSF.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.Valve;
|
||||
import org.apache.catalina.ha.CatalinaCluster;
|
||||
import org.apache.catalina.ha.ClusterDeployer;
|
||||
import org.apache.catalina.ha.ClusterListener;
|
||||
import org.apache.catalina.ha.ClusterManager;
|
||||
import org.apache.catalina.ha.tcp.SimpleTcpCluster;
|
||||
import org.apache.catalina.tribes.Channel;
|
||||
|
||||
/**
|
||||
* Generate Cluster Element with Membership,Sender,Receiver,Deployer and
|
||||
* ReplicationValve
|
||||
*/
|
||||
public class CatalinaClusterSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified Cluster children.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aCluster
|
||||
* Cluster whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aCluster,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aCluster instanceof CatalinaCluster) {
|
||||
CatalinaCluster cluster = (CatalinaCluster) aCluster;
|
||||
if (cluster instanceof SimpleTcpCluster) {
|
||||
SimpleTcpCluster tcpCluster = (SimpleTcpCluster) cluster;
|
||||
// Store nested <Manager> element
|
||||
ClusterManager manager = tcpCluster.getManagerTemplate();
|
||||
if (manager != null) {
|
||||
storeElement(aWriter, indent, manager);
|
||||
}
|
||||
}
|
||||
// Store nested <Channel> element
|
||||
Channel channel = cluster.getChannel();
|
||||
if (channel != null) {
|
||||
storeElement(aWriter, indent, channel);
|
||||
}
|
||||
// Store nested <Deployer> element
|
||||
ClusterDeployer deployer = cluster.getClusterDeployer();
|
||||
if (deployer != null) {
|
||||
storeElement(aWriter, indent, deployer);
|
||||
}
|
||||
// Store nested <Valve> element
|
||||
// ClusterValve are not store at Hosts element, see
|
||||
Valve valves[] = cluster.getValves();
|
||||
storeElementArray(aWriter, indent, valves);
|
||||
|
||||
if (aCluster instanceof SimpleTcpCluster) {
|
||||
// Store nested <Listener> elements
|
||||
LifecycleListener listeners[] = ((SimpleTcpCluster)cluster).findLifecycleListeners();
|
||||
storeElementArray(aWriter, indent, listeners);
|
||||
// Store nested <ClusterListener> elements
|
||||
ClusterListener mlisteners[] = ((SimpleTcpCluster)cluster).findClusterListeners();
|
||||
List<ClusterListener> clusterListeners = new ArrayList<>();
|
||||
for (ClusterListener clusterListener : mlisteners) {
|
||||
if (clusterListener != deployer) {
|
||||
clusterListeners.add(clusterListener);
|
||||
}
|
||||
}
|
||||
storeElementArray(aWriter, indent, clusterListeners.toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
|
||||
import org.apache.tomcat.util.IntrospectionUtils;
|
||||
|
||||
/**
|
||||
* Store the Certificate attributes.
|
||||
*/
|
||||
public class CertificateStoreAppender extends StoreAppender {
|
||||
|
||||
@Override
|
||||
protected Object checkAttribute(StoreDescription desc,
|
||||
PropertyDescriptor descriptor, String attributeName, Object bean,
|
||||
Object bean2) {
|
||||
if (attributeName.equals("type")) {
|
||||
return IntrospectionUtils.getProperty(bean, descriptor.getName());
|
||||
} else {
|
||||
return super.checkAttribute(desc, descriptor, attributeName, bean, bean2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
78
java/org/apache/catalina/storeconfig/ChannelSF.java
Normal file
78
java/org/apache/catalina/storeconfig/ChannelSF.java
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.catalina.tribes.Channel;
|
||||
import org.apache.catalina.tribes.ChannelInterceptor;
|
||||
import org.apache.catalina.tribes.ChannelReceiver;
|
||||
import org.apache.catalina.tribes.ChannelSender;
|
||||
import org.apache.catalina.tribes.ManagedChannel;
|
||||
import org.apache.catalina.tribes.MembershipService;
|
||||
|
||||
/**
|
||||
* Generate Channel Element
|
||||
*/
|
||||
public class ChannelSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified Channel children.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aChannel
|
||||
* Channel whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aChannel,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aChannel instanceof Channel) {
|
||||
Channel channel = (Channel) aChannel;
|
||||
if (channel instanceof ManagedChannel) {
|
||||
ManagedChannel managedChannel = (ManagedChannel) channel;
|
||||
// Store nested <Membership> element
|
||||
MembershipService service = managedChannel.getMembershipService();
|
||||
if (service != null) {
|
||||
storeElement(aWriter, indent, service);
|
||||
}
|
||||
// Store nested <Sender> element
|
||||
ChannelSender sender = managedChannel.getChannelSender();
|
||||
if (sender != null) {
|
||||
storeElement(aWriter, indent, sender);
|
||||
}
|
||||
// Store nested <Receiver> element
|
||||
ChannelReceiver receiver = managedChannel.getChannelReceiver();
|
||||
if (receiver != null) {
|
||||
storeElement(aWriter, indent, receiver);
|
||||
}
|
||||
Iterator<ChannelInterceptor> interceptors = managedChannel.getInterceptors();
|
||||
while (interceptors.hasNext()) {
|
||||
ChannelInterceptor interceptor = interceptors.next();
|
||||
storeElement(aWriter, indent, interceptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
java/org/apache/catalina/storeconfig/ConnectorSF.java
Normal file
76
java/org/apache/catalina/storeconfig/ConnectorSF.java
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.apache.coyote.UpgradeProtocol;
|
||||
import org.apache.tomcat.util.net.SSLHostConfig;
|
||||
|
||||
/**
|
||||
* Store Connector and Listeners
|
||||
*/
|
||||
public class ConnectorSF extends StoreFactoryBase {
|
||||
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aConnector,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
|
||||
if (aConnector instanceof Connector) {
|
||||
Connector connector = (Connector) aConnector;
|
||||
// Store nested <Listener> elements
|
||||
LifecycleListener listeners[] = connector.findLifecycleListeners();
|
||||
storeElementArray(aWriter, indent, listeners);
|
||||
// Store nested <UpgradeProtocol> elements
|
||||
UpgradeProtocol[] upgradeProtocols = connector.findUpgradeProtocols();
|
||||
storeElementArray(aWriter, indent, upgradeProtocols);
|
||||
if (Boolean.TRUE.equals(connector.getProperty("SSLEnabled"))) {
|
||||
// Store nested <SSLHostConfig> elements
|
||||
SSLHostConfig[] hostConfigs = connector.findSslHostConfigs();
|
||||
storeElementArray(aWriter, indent, hostConfigs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void printOpenTag(PrintWriter aWriter, int indent, Object bean,
|
||||
StoreDescription aDesc) throws Exception {
|
||||
aWriter.print("<");
|
||||
aWriter.print(aDesc.getTag());
|
||||
storeConnectorAttributes(aWriter, indent, bean, aDesc);
|
||||
aWriter.println(">");
|
||||
}
|
||||
|
||||
protected void storeConnectorAttributes(PrintWriter aWriter, int indent,
|
||||
Object bean, StoreDescription aDesc) throws Exception {
|
||||
if (aDesc.isAttributes()) {
|
||||
getStoreAppender().printAttributes(aWriter, indent, false, bean,
|
||||
aDesc);
|
||||
}
|
||||
}
|
||||
|
||||
protected void printTag(PrintWriter aWriter, int indent, Object bean,
|
||||
StoreDescription aDesc) throws Exception {
|
||||
aWriter.print("<");
|
||||
aWriter.print(aDesc.getTag());
|
||||
storeConnectorAttributes(aWriter, indent, bean, aDesc);
|
||||
aWriter.println("/>");
|
||||
}
|
||||
|
||||
}
|
||||
300
java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
Normal file
300
java/org/apache/catalina/storeconfig/ConnectorStoreAppender.java
Normal file
@@ -0,0 +1,300 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.beans.IndexedPropertyDescriptor;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.apache.coyote.ProtocolHandler;
|
||||
import org.apache.tomcat.util.IntrospectionUtils;
|
||||
import org.apache.tomcat.util.net.SocketProperties;
|
||||
|
||||
/**
|
||||
* Store the Connector attributes. Connector has really special design. A
|
||||
* Connector is only a startup Wrapper for a ProtocolHandler. This meant that
|
||||
* ProtocolHandler get all there attributes from the Connector attribute map.
|
||||
* Strange is that some attributes change there name and the attribute
|
||||
* sslProtocol need a special handling
|
||||
*/
|
||||
public class ConnectorStoreAppender extends StoreAppender {
|
||||
|
||||
protected static final HashMap<String, String> replacements = new HashMap<>();
|
||||
static {
|
||||
replacements.put("backlog", "acceptCount");
|
||||
replacements.put("soLinger", "connectionLinger");
|
||||
replacements.put("soTimeout", "connectionTimeout");
|
||||
replacements.put("timeout", "connectionUploadTimeout");
|
||||
replacements.put("clientauth", "clientAuth");
|
||||
replacements.put("keystore", "keystoreFile");
|
||||
replacements.put("randomfile", "randomFile");
|
||||
replacements.put("rootfile", "rootFile");
|
||||
replacements.put("keypass", "keystorePass");
|
||||
replacements.put("keytype", "keystoreType");
|
||||
replacements.put("protocol", "sslProtocol");
|
||||
replacements.put("protocols", "sslProtocols");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printAttributes(PrintWriter writer, int indent,
|
||||
boolean include, Object bean, StoreDescription desc)
|
||||
throws Exception {
|
||||
|
||||
// Render a className attribute if requested
|
||||
if (include && desc != null && !desc.isStandard()) {
|
||||
writer.print(" className=\"");
|
||||
writer.print(bean.getClass().getName());
|
||||
writer.print("\"");
|
||||
}
|
||||
|
||||
Connector connector = (Connector) bean;
|
||||
String protocol = connector.getProtocol();
|
||||
List<String> propertyKeys = getPropertyKeys(connector);
|
||||
// Create blank instance
|
||||
Object bean2 = new Connector(protocol);//defaultInstance(bean);
|
||||
for (String key : propertyKeys) {
|
||||
Object value = IntrospectionUtils.getProperty(bean, key);
|
||||
if (desc.isTransientAttribute(key)) {
|
||||
continue; // Skip the specified exceptions
|
||||
}
|
||||
if (value == null) {
|
||||
continue; // Null values are not persisted
|
||||
}
|
||||
if (!isPersistable(value.getClass())) {
|
||||
continue;
|
||||
}
|
||||
Object value2 = IntrospectionUtils.getProperty(bean2, key);
|
||||
if (value.equals(value2)) {
|
||||
// The property has its default value
|
||||
continue;
|
||||
}
|
||||
if (isPrintValue(bean, bean2, key, desc)) {
|
||||
printValue(writer, indent, key, value);
|
||||
}
|
||||
}
|
||||
if (protocol != null && !"HTTP/1.1".equals(protocol))
|
||||
super.printValue(writer, indent, "protocol", protocol);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all properties from Connector and current ProtocolHandler.
|
||||
*
|
||||
* @param bean The connector
|
||||
* @return List of Connector property names
|
||||
* @throws IntrospectionException Error intropecting connector
|
||||
*/
|
||||
protected List<String> getPropertyKeys(Connector bean)
|
||||
throws IntrospectionException {
|
||||
ArrayList<String> propertyKeys = new ArrayList<>();
|
||||
// Acquire the list of properties for this bean
|
||||
ProtocolHandler protocolHandler = bean.getProtocolHandler();
|
||||
// Acquire the list of properties for this bean
|
||||
PropertyDescriptor descriptors[] = Introspector.getBeanInfo(
|
||||
bean.getClass()).getPropertyDescriptors();
|
||||
if (descriptors == null) {
|
||||
descriptors = new PropertyDescriptor[0];
|
||||
}
|
||||
for (PropertyDescriptor descriptor : descriptors) {
|
||||
if (descriptor instanceof IndexedPropertyDescriptor) {
|
||||
continue; // Indexed properties are not persisted
|
||||
}
|
||||
if (!isPersistable(descriptor.getPropertyType())
|
||||
|| (descriptor.getReadMethod() == null)
|
||||
|| (descriptor.getWriteMethod() == null)) {
|
||||
continue; // Must be a read-write primitive or String
|
||||
}
|
||||
if ("protocol".equals(descriptor.getName())
|
||||
|| "protocolHandlerClassName".equals(descriptor
|
||||
.getName()))
|
||||
continue;
|
||||
propertyKeys.add(descriptor.getName());
|
||||
}
|
||||
// Add the properties of the protocol handler
|
||||
descriptors = Introspector.getBeanInfo(
|
||||
protocolHandler.getClass()).getPropertyDescriptors();
|
||||
if (descriptors == null) {
|
||||
descriptors = new PropertyDescriptor[0];
|
||||
}
|
||||
for (PropertyDescriptor descriptor : descriptors) {
|
||||
if (descriptor instanceof IndexedPropertyDescriptor) {
|
||||
continue; // Indexed properties are not persisted
|
||||
}
|
||||
if (!isPersistable(descriptor.getPropertyType())
|
||||
|| (descriptor.getReadMethod() == null)
|
||||
|| (descriptor.getWriteMethod() == null)) {
|
||||
continue; // Must be a read-write primitive or String
|
||||
}
|
||||
String key = descriptor.getName();
|
||||
if (replacements.get(key) != null) {
|
||||
key = replacements.get(key);
|
||||
}
|
||||
if (!propertyKeys.contains(key)) {
|
||||
propertyKeys.add(key);
|
||||
}
|
||||
}
|
||||
// Add the properties for the socket
|
||||
final String socketName = "socket.";
|
||||
descriptors = Introspector.getBeanInfo(
|
||||
SocketProperties.class).getPropertyDescriptors();
|
||||
if (descriptors == null) {
|
||||
descriptors = new PropertyDescriptor[0];
|
||||
}
|
||||
for (PropertyDescriptor descriptor : descriptors) {
|
||||
if (descriptor instanceof IndexedPropertyDescriptor) {
|
||||
continue; // Indexed properties are not persisted
|
||||
}
|
||||
if (!isPersistable(descriptor.getPropertyType())
|
||||
|| (descriptor.getReadMethod() == null)
|
||||
|| (descriptor.getWriteMethod() == null)) {
|
||||
continue; // Must be a read-write primitive or String
|
||||
}
|
||||
String key = descriptor.getName();
|
||||
if (replacements.get(key) != null) {
|
||||
key = replacements.get(key);
|
||||
}
|
||||
if (!propertyKeys.contains(key)) {
|
||||
// Add socket.[original name] if this is not a property
|
||||
// that could be set elsewhere
|
||||
propertyKeys.add(socketName + descriptor.getName());
|
||||
}
|
||||
}
|
||||
return propertyKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print Attributes for the connector
|
||||
*
|
||||
* @param aWriter Current writer
|
||||
* @param indent Indentation level
|
||||
* @param bean The connector bean
|
||||
* @param aDesc The connector description
|
||||
* @throws Exception Store error occurred
|
||||
*/
|
||||
protected void storeConnectorAttributes(PrintWriter aWriter, int indent,
|
||||
Object bean, StoreDescription aDesc) throws Exception {
|
||||
if (aDesc.isAttributes()) {
|
||||
printAttributes(aWriter, indent, false, bean, aDesc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the open tag for connector attributes (override).
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.StoreAppender#printOpenTag(java.io.PrintWriter,
|
||||
* int, java.lang.Object,
|
||||
* org.apache.catalina.storeconfig.StoreDescription)
|
||||
*/
|
||||
@Override
|
||||
public void printOpenTag(PrintWriter aWriter, int indent, Object bean,
|
||||
StoreDescription aDesc) throws Exception {
|
||||
aWriter.print("<");
|
||||
aWriter.print(aDesc.getTag());
|
||||
storeConnectorAttributes(aWriter, indent, bean, aDesc);
|
||||
aWriter.println(">");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a tag for connector attributes (override).
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.StoreAppender#printTag(java.io.PrintWriter,
|
||||
* int, java.lang.Object,
|
||||
* org.apache.catalina.storeconfig.StoreDescription)
|
||||
*/
|
||||
@Override
|
||||
public void printTag(PrintWriter aWriter, int indent, Object bean,
|
||||
StoreDescription aDesc) throws Exception {
|
||||
aWriter.print("<");
|
||||
aWriter.print(aDesc.getTag());
|
||||
storeConnectorAttributes(aWriter, indent, bean, aDesc);
|
||||
aWriter.println("/>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a value but replace certain attribute names.
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.StoreAppender#printValue(java.io.PrintWriter,
|
||||
* int, java.lang.String, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void printValue(PrintWriter writer, int indent, String name,
|
||||
Object value) {
|
||||
String repl = name;
|
||||
if (replacements.get(name) != null) {
|
||||
repl = replacements.get(name);
|
||||
}
|
||||
super.printValue(writer, indent, repl, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print Connector Values. <ul><li> Special handling to default jkHome.
|
||||
* </li><li> Don't save catalina.base path at server.xml</li><li></ul>
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.StoreAppender#isPrintValue(java.lang.Object,
|
||||
* java.lang.Object, java.lang.String,
|
||||
* org.apache.catalina.storeconfig.StoreDescription)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPrintValue(Object bean, Object bean2, String attrName,
|
||||
StoreDescription desc) {
|
||||
boolean isPrint = super.isPrintValue(bean, bean2, attrName, desc);
|
||||
if (isPrint) {
|
||||
if ("jkHome".equals(attrName)) {
|
||||
Connector connector = (Connector) bean;
|
||||
File catalinaBase = getCatalinaBase();
|
||||
File jkHomeBase = getJkHomeBase((String) connector
|
||||
.getProperty("jkHome"), catalinaBase);
|
||||
isPrint = !catalinaBase.equals(jkHomeBase);
|
||||
|
||||
}
|
||||
}
|
||||
return isPrint;
|
||||
}
|
||||
|
||||
protected File getCatalinaBase() {
|
||||
|
||||
File file = new File(System.getProperty("catalina.base"));
|
||||
try {
|
||||
file = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
protected File getJkHomeBase(String jkHome, File appBase) {
|
||||
|
||||
File jkHomeBase;
|
||||
File file = new File(jkHome);
|
||||
if (!file.isAbsolute())
|
||||
file = new File(appBase, jkHome);
|
||||
try {
|
||||
jkHomeBase = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
jkHomeBase = file;
|
||||
}
|
||||
return jkHomeBase;
|
||||
}
|
||||
|
||||
}
|
||||
24
java/org/apache/catalina/storeconfig/Constants.java
Normal file
24
java/org/apache/catalina/storeconfig/Constants.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String Package = "org.apache.catalina.storeconfig";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.CredentialHandler;
|
||||
import org.apache.catalina.realm.NestedCredentialHandler;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Store server.xml Element CredentialHandler
|
||||
*/
|
||||
public class CredentialHandlerSF extends StoreFactoryBase {
|
||||
|
||||
private static Log log = LogFactory.getLog(CredentialHandlerSF.class);
|
||||
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
if (aElement instanceof NestedCredentialHandler) {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass());
|
||||
|
||||
if (elementDesc != null) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug(sm.getString("factory.storeTag",
|
||||
elementDesc.getTag(), aElement));
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printOpenTag(aWriter, indent + 2, aElement,
|
||||
elementDesc);
|
||||
storeChildren(aWriter, indent + 2, aElement, elementDesc);
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printCloseTag(aWriter, elementDesc);
|
||||
} else {
|
||||
if (log.isWarnEnabled())
|
||||
log.warn(sm.getString("factory.storeNoDescriptor",
|
||||
aElement.getClass()));
|
||||
}
|
||||
} else {
|
||||
super.store(aWriter, indent, aElement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the specified CredentialHandler properties and child (CredentialHandler)
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aCredentialHandler
|
||||
* CredentialHandler whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aCredentialHandler,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aCredentialHandler instanceof NestedCredentialHandler) {
|
||||
NestedCredentialHandler nestedCredentialHandler = (NestedCredentialHandler) aCredentialHandler;
|
||||
|
||||
// Store nested <CredentialHandler> element
|
||||
CredentialHandler[] credentialHandlers = nestedCredentialHandler.getCredentialHandlers();
|
||||
storeElementArray(aWriter, indent, credentialHandlers);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.deploy.NamingResourcesImpl;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* store server.xml GlobalNamingResource.
|
||||
*/
|
||||
public class GlobalNamingResourcesSF extends StoreFactoryBase {
|
||||
private static Log log = LogFactory.getLog(GlobalNamingResourcesSF.class);
|
||||
|
||||
/*
|
||||
* Store with NamingResource Factory
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter,
|
||||
* int, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
|
||||
if (aElement instanceof NamingResourcesImpl) {
|
||||
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
NamingResourcesImpl.class.getName()
|
||||
+ ".[GlobalNamingResources]");
|
||||
|
||||
if (elementDesc != null) {
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printOpenTag(aWriter, indent + 2, aElement,
|
||||
elementDesc);
|
||||
NamingResourcesImpl resources = (NamingResourcesImpl) aElement;
|
||||
StoreDescription resourcesdesc = getRegistry().findDescription(
|
||||
NamingResourcesImpl.class.getName());
|
||||
if (resourcesdesc != null) {
|
||||
resourcesdesc.getStoreFactory().store(aWriter, indent + 2,
|
||||
resources);
|
||||
} else {
|
||||
if(log.isWarnEnabled())
|
||||
log.warn("Can't find NamingResources Store Factory!");
|
||||
}
|
||||
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printCloseTag(aWriter, elementDesc);
|
||||
} else {
|
||||
if (log.isWarnEnabled())
|
||||
log.warn("Descriptor for element" + aElement.getClass()
|
||||
+ " not configured!");
|
||||
}
|
||||
} else {
|
||||
if (log.isWarnEnabled())
|
||||
log.warn("wrong element " + aElement.getClass());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
132
java/org/apache/catalina/storeconfig/IStoreConfig.java
Normal file
132
java/org/apache/catalina/storeconfig/IStoreConfig.java
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Host;
|
||||
import org.apache.catalina.Server;
|
||||
import org.apache.catalina.Service;
|
||||
|
||||
public interface IStoreConfig {
|
||||
|
||||
/**
|
||||
* Get Configuration Registry
|
||||
*
|
||||
* @return aRegistry that handle the store operations
|
||||
*/
|
||||
StoreRegistry getRegistry();
|
||||
|
||||
/**
|
||||
* Set Configuration Registry
|
||||
*
|
||||
* @param aRegistry
|
||||
* aregistry that handle the store operations
|
||||
*/
|
||||
void setRegistry(StoreRegistry aRegistry);
|
||||
|
||||
/**
|
||||
* Get associated server
|
||||
*
|
||||
* @return aServer the associated server
|
||||
*/
|
||||
Server getServer();
|
||||
|
||||
/**
|
||||
* Set associated server
|
||||
*
|
||||
* @param aServer the associated server
|
||||
*/
|
||||
void setServer(Server aServer);
|
||||
|
||||
/**
|
||||
* Store the current StoreFactory Server.
|
||||
*/
|
||||
void storeConfig();
|
||||
|
||||
/**
|
||||
* Store the specified Server properties.
|
||||
*
|
||||
* @param aServer
|
||||
* Object to be stored
|
||||
* @return <code>true</code> if the store operation was successful
|
||||
*/
|
||||
boolean store(Server aServer);
|
||||
|
||||
/**
|
||||
* Store the specified Server properties.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aServer
|
||||
* Object to be stored
|
||||
* @throws Exception Store error occurred
|
||||
*/
|
||||
void store(PrintWriter aWriter, int indent, Server aServer) throws Exception;
|
||||
|
||||
/**
|
||||
* Store the specified Service properties.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aService
|
||||
* Object to be stored
|
||||
* @throws Exception Store error occurred
|
||||
*/
|
||||
void store(PrintWriter aWriter, int indent, Service aService) throws Exception;
|
||||
|
||||
/**
|
||||
* Store the specified Host properties.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aHost
|
||||
* Object to be stored
|
||||
* @throws Exception Store error occurred
|
||||
*/
|
||||
void store(PrintWriter aWriter, int indent, Host aHost) throws Exception;
|
||||
|
||||
/**
|
||||
* Store the specified Context properties.
|
||||
*
|
||||
* @param aContext
|
||||
* Object to be stored
|
||||
* @return <code>true</code> if the store operation was successful
|
||||
*/
|
||||
boolean store(Context aContext);
|
||||
|
||||
/**
|
||||
* Store the specified Context properties.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aContext
|
||||
* Object to be stored
|
||||
* @throws Exception Store error occurred
|
||||
*/
|
||||
void store(PrintWriter aWriter, int indent, Context aContext) throws Exception;
|
||||
}
|
||||
34
java/org/apache/catalina/storeconfig/IStoreFactory.java
Normal file
34
java/org/apache/catalina/storeconfig/IStoreFactory.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
public interface IStoreFactory {
|
||||
StoreAppender getStoreAppender();
|
||||
|
||||
void setStoreAppender(StoreAppender storeWriter);
|
||||
|
||||
void setRegistry(StoreRegistry aRegistry);
|
||||
|
||||
StoreRegistry getRegistry();
|
||||
|
||||
void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception;
|
||||
|
||||
void storeXMLHead(PrintWriter aWriter);
|
||||
}
|
||||
83
java/org/apache/catalina/storeconfig/InterceptorSF.java
Normal file
83
java/org/apache/catalina/storeconfig/InterceptorSF.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.tribes.ChannelInterceptor;
|
||||
import org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Generate Interceptor Element
|
||||
*/
|
||||
public class InterceptorSF extends StoreFactoryBase {
|
||||
|
||||
private static Log log = LogFactory.getLog(InterceptorSF.class);
|
||||
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
if (aElement instanceof StaticMembershipInterceptor) {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass());
|
||||
|
||||
if (elementDesc != null) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug(sm.getString("factory.storeTag",
|
||||
elementDesc.getTag(), aElement));
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printOpenTag(aWriter, indent + 2, aElement,
|
||||
elementDesc);
|
||||
storeChildren(aWriter, indent + 2, aElement, elementDesc);
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printCloseTag(aWriter, elementDesc);
|
||||
} else {
|
||||
if (log.isWarnEnabled())
|
||||
log.warn(sm.getString("factory.storeNoDescriptor",
|
||||
aElement.getClass()));
|
||||
}
|
||||
} else {
|
||||
super.store(aWriter, indent, aElement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the specified Interceptor child.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aInterceptor
|
||||
* Channel whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aInterceptor,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aInterceptor instanceof StaticMembershipInterceptor) {
|
||||
ChannelInterceptor interceptor = (ChannelInterceptor) aInterceptor;
|
||||
// Store nested <Member> elements
|
||||
storeElementArray(aWriter, indent + 2, interceptor.getMembers());
|
||||
}
|
||||
}
|
||||
}
|
||||
57
java/org/apache/catalina/storeconfig/JarScannerSF.java
Normal file
57
java/org/apache/catalina/storeconfig/JarScannerSF.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.tomcat.JarScanFilter;
|
||||
import org.apache.tomcat.JarScanner;
|
||||
|
||||
/**
|
||||
* Store server.xml Element JarScanner
|
||||
*/
|
||||
public class JarScannerSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified JarScanner properties and children
|
||||
* (JarScannerFilter)
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aJarScanner
|
||||
* JarScanner whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aJarScanner,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aJarScanner instanceof JarScanner) {
|
||||
JarScanner jarScanner = (JarScanner) aJarScanner;
|
||||
// Store nested <JarScanFilter> element
|
||||
JarScanFilter jarScanFilter = jarScanner.getJarScanFilter();
|
||||
if (jarScanFilter != null) {
|
||||
storeElement(aWriter, indent, jarScanFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
85
java/org/apache/catalina/storeconfig/LoaderSF.java
Normal file
85
java/org/apache/catalina/storeconfig/LoaderSF.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.Loader;
|
||||
import org.apache.catalina.loader.WebappLoader;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Store Loader Element.
|
||||
*/
|
||||
public class LoaderSF extends StoreFactoryBase {
|
||||
|
||||
private static Log log = LogFactory.getLog(LoaderSF.class);
|
||||
|
||||
/**
|
||||
* Store the only the Loader elements, when not default
|
||||
*
|
||||
* @see NamingResourcesSF#storeChildren(PrintWriter, int, Object, StoreDescription)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass());
|
||||
if (elementDesc != null) {
|
||||
Loader loader = (Loader) aElement;
|
||||
if (!isDefaultLoader(loader)) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("store " + elementDesc.getTag() + "( " + aElement
|
||||
+ " )");
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printTag(aWriter, indent + 2, loader,
|
||||
elementDesc);
|
||||
}
|
||||
} else {
|
||||
if (log.isWarnEnabled()) {
|
||||
log
|
||||
.warn("Descriptor for element"
|
||||
+ aElement.getClass()
|
||||
+ " not configured or element class not StandardManager!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an instance of the default <code>Loader</code> configuration,
|
||||
* with all-default properties?
|
||||
*
|
||||
* @param loader
|
||||
* Loader to be tested
|
||||
* @return <code>true</code> if this is an instance of the default loader
|
||||
*/
|
||||
protected boolean isDefaultLoader(Loader loader) {
|
||||
|
||||
if (!(loader instanceof WebappLoader)) {
|
||||
return false;
|
||||
}
|
||||
WebappLoader wloader = (WebappLoader) loader;
|
||||
if ((wloader.getDelegate() != false)
|
||||
|| !wloader.getLoaderClass().equals(
|
||||
"org.apache.catalina.loader.WebappClassLoader")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
25
java/org/apache/catalina/storeconfig/LocalStrings.properties
Normal file
25
java/org/apache/catalina/storeconfig/LocalStrings.properties
Normal file
@@ -0,0 +1,25 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
config.storeContextError=Error storing context [{0}]
|
||||
config.storeServerError=Error storing server
|
||||
|
||||
factory.storeNoDescriptor=Descriptor for element class [{0}] not configured!
|
||||
factory.storeTag=store tag [{0}] ( Object: [{1}] )
|
||||
|
||||
storeConfigListener.notServer=The listener was added to component other than the Server and will therefore be ignored
|
||||
|
||||
storeFileMover.directoryCreationError=Cannot create directory [{0}]
|
||||
storeFileMover.renameError=Cannot rename [{0}] to [{1}]
|
||||
@@ -0,0 +1,25 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
config.storeContextError=Erreur d''enregistrement du contexte [{0}]
|
||||
config.storeServerError=Erreur d'enregistrement de la configuration du serveur
|
||||
|
||||
factory.storeNoDescriptor=Le descripteur pour l''élément de la classe [{0}] n''est pas configuré
|
||||
factory.storeTag=enregistrement du tag [{0}] (objet: [{1}])
|
||||
|
||||
storeConfigListener.notServer=L'écouteur a été ajouté à un composant autre que le Server et sera donc ignoré
|
||||
|
||||
storeFileMover.directoryCreationError=Impossible de créer le répertoire [{0}]
|
||||
storeFileMover.renameError=Impossible de renommer [{0}] en [{1}]
|
||||
@@ -0,0 +1,25 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
config.storeContextError=コンテキスト[{0}]を格納中にエラーが発生しました。
|
||||
config.storeServerError=サーバ停止エラー
|
||||
|
||||
factory.storeNoDescriptor=要素クラス[{0}]の記述子が構成されていません!
|
||||
factory.storeTag=ストアタグ[{0}](オブジェクト:[{1}])
|
||||
|
||||
storeConfigListener.notServer=Server 以外のコンポーネントに指定されたリスナーは無視します。
|
||||
|
||||
storeFileMover.directoryCreationError=ディレクトリを作成できません。[{0}]
|
||||
storeFileMover.renameError=ファイル名 [{0}] を [{1}] に変更できません。
|
||||
@@ -0,0 +1,25 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
config.storeContextError=컨텍스트 [{0}]을(를) 저장하는 중 오류 발생
|
||||
config.storeServerError=서버를 중지시키는 중 오류 발생
|
||||
|
||||
factory.storeNoDescriptor=엘리먼트 클래스 [{0}]을(를) 위한 descriptor가 설정되지 않았습니다!
|
||||
factory.storeTag=태그 [{0}]을(를) 저장합니다. ( 객체: [{1}] )
|
||||
|
||||
storeConfigListener.notServer=서버가 아닌 다른 구성요소에 리스너가 추가되었으므로, 이 리스너는 무시될 것입니다.
|
||||
|
||||
storeFileMover.directoryCreationError=디렉토리 [{0}]을(를) 생성할 수 없습니다.
|
||||
storeFileMover.renameError=[{0}]을(를) [{1}](으)로 이름을 변경할 수 없습니다.
|
||||
@@ -0,0 +1,17 @@
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
storeFileMover.directoryCreationError=无法创建目录 [{0}]
|
||||
storeFileMover.renameError=无法将 [{0}] 重命名为 [{1}]
|
||||
95
java/org/apache/catalina/storeconfig/ManagerSF.java
Normal file
95
java/org/apache/catalina/storeconfig/ManagerSF.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.Manager;
|
||||
import org.apache.catalina.SessionIdGenerator;
|
||||
import org.apache.catalina.session.StandardManager;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Store server.xml Manager element
|
||||
*/
|
||||
public class ManagerSF extends StoreFactoryBase {
|
||||
|
||||
private static Log log = LogFactory.getLog(ManagerSF.class);
|
||||
|
||||
/**
|
||||
* Store the only the Manager elements
|
||||
*
|
||||
* @see NamingResourcesSF#storeChildren(PrintWriter, int, Object, StoreDescription)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass());
|
||||
if (elementDesc != null) {
|
||||
if (aElement instanceof StandardManager) {
|
||||
StandardManager manager = (StandardManager) aElement;
|
||||
if (!isDefaultManager(manager)) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug(sm.getString("factory.storeTag", elementDesc
|
||||
.getTag(), aElement));
|
||||
super.store(aWriter, indent, aElement);
|
||||
}
|
||||
} else {
|
||||
super.store(aWriter, indent, aElement);
|
||||
}
|
||||
} else {
|
||||
if (log.isWarnEnabled())
|
||||
log.warn(sm.getString("factory.storeNoDescriptor", aElement
|
||||
.getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this an instance of the default <code>Manager</code> configuration,
|
||||
* with all-default properties?
|
||||
*
|
||||
* @param smanager
|
||||
* Manager to be tested
|
||||
* @return <code>true</code> if this is an instance of the default manager
|
||||
*/
|
||||
protected boolean isDefaultManager(StandardManager smanager) {
|
||||
|
||||
if (!"SESSIONS.ser".equals(smanager.getPathname())
|
||||
|| (smanager.getMaxActiveSessions() != -1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aManager,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aManager instanceof Manager) {
|
||||
Manager manager = (Manager) aManager;
|
||||
// Store nested <SessionIdGenerator> element;
|
||||
SessionIdGenerator sessionIdGenerator = manager.getSessionIdGenerator();
|
||||
if (sessionIdGenerator != null) {
|
||||
storeElement(aWriter, indent, sessionIdGenerator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
107
java/org/apache/catalina/storeconfig/NamingResourcesSF.java
Normal file
107
java/org/apache/catalina/storeconfig/NamingResourcesSF.java
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.deploy.NamingResourcesImpl;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.descriptor.web.ContextEjb;
|
||||
import org.apache.tomcat.util.descriptor.web.ContextEnvironment;
|
||||
import org.apache.tomcat.util.descriptor.web.ContextLocalEjb;
|
||||
import org.apache.tomcat.util.descriptor.web.ContextResource;
|
||||
import org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef;
|
||||
import org.apache.tomcat.util.descriptor.web.ContextResourceLink;
|
||||
|
||||
/**
|
||||
* Store server.xml elements Resources at context and GlobalNamingResources
|
||||
*/
|
||||
public class NamingResourcesSF extends StoreFactoryBase {
|
||||
private static Log log = LogFactory.getLog(NamingResourcesSF.class);
|
||||
|
||||
/**
|
||||
* Store the only the NamingResources elements
|
||||
*
|
||||
* @see NamingResourcesSF#storeChildren(PrintWriter, int, Object, StoreDescription)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass());
|
||||
if (elementDesc != null) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("store " + elementDesc.getTag() + "( " + aElement
|
||||
+ " )");
|
||||
storeChildren(aWriter, indent, aElement, elementDesc);
|
||||
} else {
|
||||
if (log.isWarnEnabled())
|
||||
log.warn("Descriptor for element" + aElement.getClass()
|
||||
+ " not configured!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the specified NamingResources properties.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aElement
|
||||
* Object whose properties are being stored
|
||||
* @param elementDesc
|
||||
* element descriptor
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.StoreFactoryBase#storeChildren(java.io.PrintWriter,
|
||||
* int, java.lang.Object, StoreDescription)
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aElement,
|
||||
StoreDescription elementDesc) throws Exception {
|
||||
|
||||
if (aElement instanceof NamingResourcesImpl) {
|
||||
NamingResourcesImpl resources = (NamingResourcesImpl) aElement;
|
||||
// Store nested <Ejb> elements
|
||||
ContextEjb[] ejbs = resources.findEjbs();
|
||||
storeElementArray(aWriter, indent, ejbs);
|
||||
// Store nested <Environment> elements
|
||||
ContextEnvironment[] envs = resources.findEnvironments();
|
||||
storeElementArray(aWriter, indent, envs);
|
||||
// Store nested <LocalEjb> elements
|
||||
ContextLocalEjb[] lejbs = resources.findLocalEjbs();
|
||||
storeElementArray(aWriter, indent, lejbs);
|
||||
|
||||
// Store nested <Resource> elements
|
||||
ContextResource[] dresources = resources.findResources();
|
||||
storeElementArray(aWriter, indent, dresources);
|
||||
|
||||
// Store nested <ResourceEnvRef> elements
|
||||
ContextResourceEnvRef[] resEnv = resources.findResourceEnvRefs();
|
||||
storeElementArray(aWriter, indent, resEnv);
|
||||
|
||||
// Store nested <ResourceLink> elements
|
||||
ContextResourceLink[] resourceLinks = resources.findResourceLinks();
|
||||
storeElementArray(aWriter, indent, resourceLinks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
java/org/apache/catalina/storeconfig/OpenSSLConfSF.java
Normal file
45
java/org/apache/catalina/storeconfig/OpenSSLConfSF.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.tomcat.util.net.openssl.OpenSSLConf;
|
||||
import org.apache.tomcat.util.net.openssl.OpenSSLConfCmd;
|
||||
|
||||
/**
|
||||
* Store OpenSSLConf
|
||||
*/
|
||||
public class OpenSSLConfSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store nested OpenSSLConfCmd elements.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aOpenSSLConf,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aOpenSSLConf instanceof OpenSSLConf) {
|
||||
OpenSSLConf openSslConf = (OpenSSLConf) aOpenSSLConf;
|
||||
// Store nested <OpenSSLConfCmd> elements
|
||||
OpenSSLConfCmd[] openSSLConfCmds = openSslConf.getCommands().toArray(new OpenSSLConfCmd[0]);
|
||||
storeElementArray(aWriter, indent + 2, openSSLConfCmds);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.SessionIdGenerator;
|
||||
import org.apache.catalina.Store;
|
||||
import org.apache.catalina.session.PersistentManager;
|
||||
|
||||
/**
|
||||
* store server.xml PersistentManager element with nested "Store"
|
||||
*/
|
||||
public class PersistentManagerSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified PersistentManager properties.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aManager
|
||||
* PersistentManager whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aManager,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aManager instanceof PersistentManager) {
|
||||
PersistentManager manager = (PersistentManager) aManager;
|
||||
|
||||
// Store nested <Store> element
|
||||
Store store = manager.getStore();
|
||||
storeElement(aWriter, indent, store);
|
||||
|
||||
// Store nested <SessionIdGenerator> element
|
||||
SessionIdGenerator sessionIdGenerator = manager.getSessionIdGenerator();
|
||||
if (sessionIdGenerator != null) {
|
||||
storeElement(aWriter, indent, sessionIdGenerator);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
92
java/org/apache/catalina/storeconfig/RealmSF.java
Normal file
92
java/org/apache/catalina/storeconfig/RealmSF.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.CredentialHandler;
|
||||
import org.apache.catalina.Realm;
|
||||
import org.apache.catalina.realm.CombinedRealm;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Store server.xml Element Realm
|
||||
*/
|
||||
public class RealmSF extends StoreFactoryBase {
|
||||
|
||||
private static Log log = LogFactory.getLog(RealmSF.class);
|
||||
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
if (aElement instanceof CombinedRealm) {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass());
|
||||
|
||||
if (elementDesc != null) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug(sm.getString("factory.storeTag",
|
||||
elementDesc.getTag(), aElement));
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printOpenTag(aWriter, indent + 2, aElement,
|
||||
elementDesc);
|
||||
storeChildren(aWriter, indent + 2, aElement, elementDesc);
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printCloseTag(aWriter, elementDesc);
|
||||
} else {
|
||||
if (log.isWarnEnabled())
|
||||
log.warn(sm.getString("factory.storeNoDescriptor",
|
||||
aElement.getClass()));
|
||||
}
|
||||
} else {
|
||||
super.store(aWriter, indent, aElement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the specified Realm properties and child (Realm)
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aRealm
|
||||
* Realm whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aRealm,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aRealm instanceof CombinedRealm) {
|
||||
CombinedRealm combinedRealm = (CombinedRealm) aRealm;
|
||||
|
||||
// Store nested <Realm> element
|
||||
Realm[] realms = combinedRealm.getNestedRealms();
|
||||
storeElementArray(aWriter, indent, realms);
|
||||
}
|
||||
// Store nested <CredentialHandler> element
|
||||
CredentialHandler credentialHandler = ((Realm) aRealm).getCredentialHandler();
|
||||
if (credentialHandler != null) {
|
||||
storeElement(aWriter, indent, credentialHandler);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
61
java/org/apache/catalina/storeconfig/SSLHostConfigSF.java
Normal file
61
java/org/apache/catalina/storeconfig/SSLHostConfigSF.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.tomcat.util.net.SSLHostConfig;
|
||||
import org.apache.tomcat.util.net.SSLHostConfigCertificate;
|
||||
import org.apache.tomcat.util.net.SSLHostConfigCertificate.Type;
|
||||
import org.apache.tomcat.util.net.openssl.OpenSSLConf;
|
||||
|
||||
/**
|
||||
* Store SSLHostConfig
|
||||
*/
|
||||
public class SSLHostConfigSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store nested SSLHostConfigCertificate elements.
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aSSLHostConfig,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aSSLHostConfig instanceof SSLHostConfig) {
|
||||
SSLHostConfig sslHostConfig = (SSLHostConfig) aSSLHostConfig;
|
||||
// Store nested <SSLHostConfigCertificate> elements
|
||||
SSLHostConfigCertificate[] hostConfigsCertificates = sslHostConfig.getCertificates().toArray(new SSLHostConfigCertificate[0]);
|
||||
// Remove a possible default UNDEFINED certificate
|
||||
if (hostConfigsCertificates.length > 1) {
|
||||
ArrayList<SSLHostConfigCertificate> certificates = new ArrayList<>();
|
||||
for (SSLHostConfigCertificate certificate : hostConfigsCertificates) {
|
||||
if (Type.UNDEFINED != certificate.getType()) {
|
||||
certificates.add(certificate);
|
||||
}
|
||||
}
|
||||
hostConfigsCertificates = certificates.toArray(new SSLHostConfigCertificate[0]);
|
||||
}
|
||||
storeElementArray(aWriter, indent, hostConfigsCertificates);
|
||||
// Store nested <OpenSSLConf> element
|
||||
OpenSSLConf openSslConf = sslHostConfig.getOpenSslConf();
|
||||
storeElement(aWriter, indent, openSslConf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
55
java/org/apache/catalina/storeconfig/SenderSF.java
Normal file
55
java/org/apache/catalina/storeconfig/SenderSF.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.tribes.transport.MultiPointSender;
|
||||
import org.apache.catalina.tribes.transport.ReplicationTransmitter;
|
||||
|
||||
/**
|
||||
* Generate Sender Element
|
||||
*/
|
||||
public class SenderSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified Sender child.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aSender
|
||||
* Channel whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aSender,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aSender instanceof ReplicationTransmitter) {
|
||||
ReplicationTransmitter transmitter = (ReplicationTransmitter) aSender;
|
||||
// Store nested <Transport> element
|
||||
MultiPointSender transport = transmitter.getTransport();
|
||||
if (transport != null) {
|
||||
storeElement(aWriter, indent, transport);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
369
java/org/apache/catalina/storeconfig/StandardContextSF.java
Normal file
369
java/org/apache/catalina/storeconfig/StandardContextSF.java
Normal file
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.catalina.Container;
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Engine;
|
||||
import org.apache.catalina.Host;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.Loader;
|
||||
import org.apache.catalina.Manager;
|
||||
import org.apache.catalina.Realm;
|
||||
import org.apache.catalina.Valve;
|
||||
import org.apache.catalina.WebResourceRoot;
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.catalina.core.ThreadLocalLeakPreventionListener;
|
||||
import org.apache.catalina.deploy.NamingResourcesImpl;
|
||||
import org.apache.catalina.util.ContextName;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.JarScanner;
|
||||
import org.apache.tomcat.util.descriptor.web.ApplicationParameter;
|
||||
import org.apache.tomcat.util.http.CookieProcessor;
|
||||
|
||||
/**
|
||||
* Store server.xml Context element with all children
|
||||
* <ul>
|
||||
* <li>Store all context at server.xml</li>
|
||||
* <li>Store existing app.xml context a conf/enginename/hostname/app.xml</li>
|
||||
* <li>Store with backup</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class StandardContextSF extends StoreFactoryBase {
|
||||
|
||||
private static Log log = LogFactory.getLog(StandardContextSF.class);
|
||||
|
||||
/**
|
||||
* Store a Context as Separate file as configFile value from context exists.
|
||||
* filename can be relative to catalina.base.
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter,
|
||||
* int, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aContext)
|
||||
throws Exception {
|
||||
|
||||
if (aContext instanceof StandardContext) {
|
||||
StoreDescription desc = getRegistry().findDescription(
|
||||
aContext.getClass());
|
||||
if (desc.isStoreSeparate()) {
|
||||
URL configFile = ((StandardContext) aContext)
|
||||
.getConfigFile();
|
||||
if (configFile != null) {
|
||||
if (desc.isExternalAllowed()) {
|
||||
if (desc.isBackup())
|
||||
storeWithBackup((StandardContext) aContext);
|
||||
else
|
||||
storeContextSeparate(aWriter, indent,
|
||||
(StandardContext) aContext);
|
||||
return;
|
||||
}
|
||||
} else if (desc.isExternalOnly()) {
|
||||
// Set a configFile so that the configuration is actually saved
|
||||
Context context = ((StandardContext) aContext);
|
||||
Host host = (Host) context.getParent();
|
||||
File configBase = host.getConfigBaseFile();
|
||||
ContextName cn = new ContextName(context.getName(), false);
|
||||
String baseName = cn.getBaseName();
|
||||
File xml = new File(configBase, baseName + ".xml");
|
||||
context.setConfigFile(xml.toURI().toURL());
|
||||
if (desc.isBackup())
|
||||
storeWithBackup((StandardContext) aContext);
|
||||
else
|
||||
storeContextSeparate(aWriter, indent,
|
||||
(StandardContext) aContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.store(aWriter, indent, aContext);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a Context without backup add separate file or when configFile =
|
||||
* null a aWriter.
|
||||
*
|
||||
* @param aWriter Current output writer
|
||||
* @param indent Indentation level
|
||||
* @param aContext The context which will be stored
|
||||
* @throws Exception Configuration storing error
|
||||
*/
|
||||
protected void storeContextSeparate(PrintWriter aWriter, int indent,
|
||||
StandardContext aContext) throws Exception {
|
||||
URL configFile = aContext.getConfigFile();
|
||||
if (configFile != null) {
|
||||
File config = new File(configFile.toURI());
|
||||
if (!config.isAbsolute()) {
|
||||
config = new File(System.getProperty("catalina.base"),
|
||||
config.getPath());
|
||||
}
|
||||
if( (!config.isFile()) || (!config.canWrite())) {
|
||||
log.error("Cannot write context output file at "
|
||||
+ configFile + ", not saving.");
|
||||
throw new IOException("Context save file at "
|
||||
+ configFile
|
||||
+ " not a file, or not writable.");
|
||||
}
|
||||
if (log.isInfoEnabled())
|
||||
log.info("Store Context " + aContext.getPath()
|
||||
+ " separate at file " + config);
|
||||
try (FileOutputStream fos = new FileOutputStream(config);
|
||||
PrintWriter writer = new PrintWriter(new OutputStreamWriter(
|
||||
fos , getRegistry().getEncoding()))) {
|
||||
storeXMLHead(writer);
|
||||
super.store(writer, -2, aContext);
|
||||
}
|
||||
} else {
|
||||
super.store(aWriter, indent, aContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the Context with a Backup.
|
||||
*
|
||||
* @param aContext The context which will be stored
|
||||
* @throws Exception Configuration storing error
|
||||
*/
|
||||
protected void storeWithBackup(StandardContext aContext) throws Exception {
|
||||
StoreFileMover mover = getConfigFileWriter(aContext);
|
||||
if (mover != null) {
|
||||
// Bugzilla 37781 Check to make sure we can write this output file
|
||||
if ((mover.getConfigOld() == null)
|
||||
|| (mover.getConfigOld().isDirectory())
|
||||
|| (mover.getConfigOld().exists() &&
|
||||
!mover.getConfigOld().canWrite())) {
|
||||
log.error("Cannot move orignal context output file at "
|
||||
+ mover.getConfigOld());
|
||||
throw new IOException("Context original file at "
|
||||
+ mover.getConfigOld()
|
||||
+ " is null, not a file or not writable.");
|
||||
}
|
||||
File dir = mover.getConfigSave().getParentFile();
|
||||
if (dir != null && dir.isDirectory() && (!dir.canWrite())) {
|
||||
log.error("Cannot save context output file at "
|
||||
+ mover.getConfigSave());
|
||||
throw new IOException("Context save file at "
|
||||
+ mover.getConfigSave() + " is not writable.");
|
||||
}
|
||||
if (log.isInfoEnabled())
|
||||
log.info("Store Context " + aContext.getPath()
|
||||
+ " separate with backup (at file "
|
||||
+ mover.getConfigSave() + " )");
|
||||
|
||||
try (PrintWriter writer = mover.getWriter()) {
|
||||
storeXMLHead(writer);
|
||||
super.store(writer, -2, aContext);
|
||||
}
|
||||
mover.move();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get explicit writer for context (context.getConfigFile()).
|
||||
*
|
||||
* @param context The context which will be stored
|
||||
* @return The file mover
|
||||
* @throws Exception Error getting a writer for the configuration file
|
||||
*/
|
||||
protected StoreFileMover getConfigFileWriter(Context context)
|
||||
throws Exception {
|
||||
URL configFile = context.getConfigFile();
|
||||
StoreFileMover mover = null;
|
||||
if (configFile != null) {
|
||||
File config = new File(configFile.toURI());
|
||||
if (!config.isAbsolute()) {
|
||||
config = new File(System.getProperty("catalina.base"),
|
||||
config.getPath());
|
||||
}
|
||||
// Open an output writer for the new configuration file
|
||||
mover = new StoreFileMover("", config.getCanonicalPath(),
|
||||
getRegistry().getEncoding());
|
||||
}
|
||||
return mover;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the specified context element children.
|
||||
*
|
||||
* @param aWriter Current output writer
|
||||
* @param indent Indentation level
|
||||
* @param aContext Context to store
|
||||
* @param parentDesc The element description
|
||||
* @throws Exception Configuration storing error
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aContext,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aContext instanceof StandardContext) {
|
||||
StandardContext context = (StandardContext) aContext;
|
||||
// Store nested <Listener> elements
|
||||
LifecycleListener listeners[] = context.findLifecycleListeners();
|
||||
ArrayList<LifecycleListener> listenersArray = new ArrayList<>();
|
||||
for (LifecycleListener listener : listeners) {
|
||||
if (!(listener instanceof ThreadLocalLeakPreventionListener)) {
|
||||
listenersArray.add(listener);
|
||||
}
|
||||
}
|
||||
storeElementArray(aWriter, indent, listenersArray.toArray());
|
||||
|
||||
// Store nested <Valve> elements
|
||||
Valve valves[] = context.getPipeline().getValves();
|
||||
storeElementArray(aWriter, indent, valves);
|
||||
|
||||
// Store nested <Loader> elements
|
||||
Loader loader = context.getLoader();
|
||||
storeElement(aWriter, indent, loader);
|
||||
|
||||
// Store nested <Manager> elements
|
||||
if (context.getCluster() == null || !context.getDistributable()) {
|
||||
Manager manager = context.getManager();
|
||||
storeElement(aWriter, indent, manager);
|
||||
}
|
||||
|
||||
// Store nested <Realm> element
|
||||
Realm realm = context.getRealm();
|
||||
if (realm != null) {
|
||||
Realm parentRealm = null;
|
||||
// @TODO is this case possible?
|
||||
if (context.getParent() != null) {
|
||||
parentRealm = context.getParent().getRealm();
|
||||
}
|
||||
if (realm != parentRealm) {
|
||||
storeElement(aWriter, indent, realm);
|
||||
}
|
||||
}
|
||||
// Store nested resources
|
||||
WebResourceRoot resources = context.getResources();
|
||||
storeElement(aWriter, indent, resources);
|
||||
|
||||
// Store nested <WrapperListener> elements
|
||||
String wLifecycles[] = context.findWrapperLifecycles();
|
||||
getStoreAppender().printTagArray(aWriter, "WrapperListener",
|
||||
indent + 2, wLifecycles);
|
||||
// Store nested <WrapperLifecycle> elements
|
||||
String wListeners[] = context.findWrapperListeners();
|
||||
getStoreAppender().printTagArray(aWriter, "WrapperLifecycle",
|
||||
indent + 2, wListeners);
|
||||
|
||||
// Store nested <Parameter> elements
|
||||
ApplicationParameter[] appParams = context
|
||||
.findApplicationParameters();
|
||||
storeElementArray(aWriter, indent, appParams);
|
||||
|
||||
// Store nested naming resources elements (EJB,Resource,...)
|
||||
NamingResourcesImpl nresources = context.getNamingResources();
|
||||
storeElement(aWriter, indent, nresources);
|
||||
|
||||
// Store nested watched resources <WatchedResource>
|
||||
String[] wresources = context.findWatchedResources();
|
||||
wresources = filterWatchedResources(context, wresources);
|
||||
getStoreAppender().printTagArray(aWriter, "WatchedResource",
|
||||
indent + 2, wresources);
|
||||
|
||||
// Store nested <JarScanner> elements
|
||||
JarScanner jarScanner = context.getJarScanner();
|
||||
storeElement(aWriter, indent, jarScanner);
|
||||
|
||||
// Store nested <CookieProcessor> elements
|
||||
CookieProcessor cookieProcessor = context.getCookieProcessor();
|
||||
storeElement(aWriter, indent, cookieProcessor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a File object representing the "configuration root" directory for
|
||||
* our associated Host.
|
||||
* @param context The context instance
|
||||
* @return a file to the configuration base path
|
||||
*/
|
||||
protected File configBase(Context context) {
|
||||
|
||||
File file = new File(System.getProperty("catalina.base"), "conf");
|
||||
Container host = context.getParent();
|
||||
|
||||
if (host instanceof Host) {
|
||||
Container engine = host.getParent();
|
||||
if (engine instanceof Engine) {
|
||||
file = new File(file, engine.getName());
|
||||
}
|
||||
file = new File(file, host.getName());
|
||||
try {
|
||||
file = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
return file;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out the default watched resources, to remove standard ones.
|
||||
*
|
||||
* @param context The context instance
|
||||
* @param wresources The raw watched resources list
|
||||
* @return The filtered watched resources
|
||||
* @throws Exception Configuration storing error
|
||||
* TODO relative watched resources
|
||||
* TODO absolute handling configFile
|
||||
* TODO Filename case handling for Windows?
|
||||
* TODO digester variable substitution $catalina.base, $catalina.home
|
||||
*/
|
||||
protected String[] filterWatchedResources(StandardContext context,
|
||||
String[] wresources) throws Exception {
|
||||
File configBase = configBase(context);
|
||||
String confContext = new File(System.getProperty("catalina.base"),
|
||||
"conf/context.xml").getCanonicalPath();
|
||||
String confWeb = new File(System.getProperty("catalina.base"),
|
||||
"conf/web.xml").getCanonicalPath();
|
||||
String confHostDefault = new File(configBase, "context.xml.default")
|
||||
.getCanonicalPath();
|
||||
String configFile = (context.getConfigFile() != null ? new File(context.getConfigFile().toURI()).getCanonicalPath() : null);
|
||||
String webxml = "WEB-INF/web.xml" ;
|
||||
|
||||
List<String> resource = new ArrayList<>();
|
||||
for (int i = 0; i < wresources.length; i++) {
|
||||
|
||||
if (wresources[i].equals(confContext))
|
||||
continue;
|
||||
if (wresources[i].equals(confWeb))
|
||||
continue;
|
||||
if (wresources[i].equals(confHostDefault))
|
||||
continue;
|
||||
if (wresources[i].equals(configFile))
|
||||
continue;
|
||||
if (wresources[i].equals(webxml))
|
||||
continue;
|
||||
resource.add(wresources[i]);
|
||||
}
|
||||
return resource.toArray(new String[resource.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
95
java/org/apache/catalina/storeconfig/StandardEngineSF.java
Normal file
95
java/org/apache/catalina/storeconfig/StandardEngineSF.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.catalina.Cluster;
|
||||
import org.apache.catalina.Container;
|
||||
import org.apache.catalina.Lifecycle;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.Realm;
|
||||
import org.apache.catalina.Valve;
|
||||
import org.apache.catalina.core.StandardEngine;
|
||||
import org.apache.catalina.ha.ClusterValve;
|
||||
|
||||
/**
|
||||
* Store server.xml Element Engine
|
||||
*/
|
||||
public class StandardEngineSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified Engine properties.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aEngine
|
||||
* Object whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aEngine,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aEngine instanceof StandardEngine) {
|
||||
StandardEngine engine = (StandardEngine) aEngine;
|
||||
// Store nested <Listener> elements
|
||||
LifecycleListener listeners[] = ((Lifecycle) engine)
|
||||
.findLifecycleListeners();
|
||||
storeElementArray(aWriter, indent, listeners);
|
||||
|
||||
// Store nested <Realm> element
|
||||
Realm realm = engine.getRealm();
|
||||
Realm parentRealm = null;
|
||||
// TODO is this case possible? (see it a old Server 5.0 impl)
|
||||
if (engine.getParent() != null) {
|
||||
parentRealm = engine.getParent().getRealm();
|
||||
}
|
||||
if (realm != parentRealm) {
|
||||
storeElement(aWriter, indent, realm);
|
||||
|
||||
}
|
||||
|
||||
// Store nested <Valve> elements
|
||||
Valve valves[] = engine.getPipeline().getValves();
|
||||
if(valves != null && valves.length > 0 ) {
|
||||
List<Valve> engineValves = new ArrayList<>() ;
|
||||
for(int i = 0 ; i < valves.length ; i++ ) {
|
||||
if(!( valves[i] instanceof ClusterValve))
|
||||
engineValves.add(valves[i]);
|
||||
}
|
||||
storeElementArray(aWriter, indent, engineValves.toArray());
|
||||
}
|
||||
|
||||
// store all <Cluster> elements
|
||||
Cluster cluster = engine.getCluster();
|
||||
if (cluster != null) {
|
||||
storeElement(aWriter, indent, cluster);
|
||||
}
|
||||
// store all <Host> elements
|
||||
Container children[] = engine.findChildren();
|
||||
storeElementArray(aWriter, indent, children);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
108
java/org/apache/catalina/storeconfig/StandardHostSF.java
Normal file
108
java/org/apache/catalina/storeconfig/StandardHostSF.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.catalina.Cluster;
|
||||
import org.apache.catalina.Container;
|
||||
import org.apache.catalina.Lifecycle;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.Realm;
|
||||
import org.apache.catalina.Valve;
|
||||
import org.apache.catalina.core.StandardHost;
|
||||
import org.apache.catalina.ha.ClusterValve;
|
||||
|
||||
/**
|
||||
* Store server.xml Element Host
|
||||
*/
|
||||
public class StandardHostSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified Host properties and children
|
||||
* (Listener,Alias,Realm,Valve,Cluster, Context)
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aHost
|
||||
* Host whose properties are being stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aHost,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aHost instanceof StandardHost) {
|
||||
StandardHost host = (StandardHost) aHost;
|
||||
// Store nested <Listener> elements
|
||||
LifecycleListener listeners[] = ((Lifecycle) host)
|
||||
.findLifecycleListeners();
|
||||
storeElementArray(aWriter, indent, listeners);
|
||||
|
||||
// Store nested <Alias> elements
|
||||
String aliases[] = host.findAliases();
|
||||
getStoreAppender().printTagArray(aWriter, "Alias", indent + 2,
|
||||
aliases);
|
||||
|
||||
// Store nested <Realm> element
|
||||
Realm realm = host.getRealm();
|
||||
if (realm != null) {
|
||||
Realm parentRealm = null;
|
||||
if (host.getParent() != null) {
|
||||
parentRealm = host.getParent().getRealm();
|
||||
}
|
||||
if (realm != parentRealm) {
|
||||
storeElement(aWriter, indent, realm);
|
||||
}
|
||||
}
|
||||
|
||||
// Store nested <Valve> elements
|
||||
Valve valves[] = host.getPipeline().getValves();
|
||||
if(valves != null && valves.length > 0 ) {
|
||||
List<Valve> hostValves = new ArrayList<>() ;
|
||||
for(int i = 0 ; i < valves.length ; i++ ) {
|
||||
if(!( valves[i] instanceof ClusterValve))
|
||||
hostValves.add(valves[i]);
|
||||
}
|
||||
storeElementArray(aWriter, indent, hostValves.toArray());
|
||||
}
|
||||
|
||||
// store all <Cluster> elements
|
||||
Cluster cluster = host.getCluster();
|
||||
if (cluster != null) {
|
||||
Cluster parentCluster = null;
|
||||
if (host.getParent() != null) {
|
||||
parentCluster = host.getParent().getCluster();
|
||||
}
|
||||
if (cluster != parentCluster) {
|
||||
storeElement(aWriter, indent, cluster);
|
||||
}
|
||||
}
|
||||
|
||||
// store all <Context> elements
|
||||
Container children[] = host.findChildren();
|
||||
storeElementArray(aWriter, indent, children);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
104
java/org/apache/catalina/storeconfig/StandardServerSF.java
Normal file
104
java/org/apache/catalina/storeconfig/StandardServerSF.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.Lifecycle;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.Service;
|
||||
import org.apache.catalina.core.StandardServer;
|
||||
import org.apache.catalina.deploy.NamingResourcesImpl;
|
||||
|
||||
/**
|
||||
* Store server.xml Server element and children (
|
||||
* Listener,GlobalNamingResource,Service)
|
||||
*/
|
||||
public class StandardServerSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified Server properties.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
* @param aServer
|
||||
* Object to be stored
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
* @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter,
|
||||
* int, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aServer)
|
||||
throws Exception {
|
||||
storeXMLHead(aWriter);
|
||||
super.store(aWriter, indent, aServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the specified server element children.
|
||||
*
|
||||
* @param aWriter Current output writer
|
||||
* @param indent Indentation level
|
||||
* @param aObject Server to store
|
||||
* @param parentDesc The element description
|
||||
* @throws Exception Configuration storing error
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aObject,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aObject instanceof StandardServer) {
|
||||
StandardServer server = (StandardServer) aObject;
|
||||
// Store nested <Listener> elements
|
||||
LifecycleListener listeners[] = ((Lifecycle) server)
|
||||
.findLifecycleListeners();
|
||||
storeElementArray(aWriter, indent, listeners);
|
||||
/*LifecycleListener listener = null;
|
||||
for (int i = 0; listener == null && i < listeners.length; i++)
|
||||
if (listeners[i] instanceof ServerLifecycleListener)
|
||||
listener = listeners[i];
|
||||
if (listener != null) {
|
||||
StoreDescription elementDesc = getRegistry()
|
||||
.findDescription(
|
||||
StandardServer.class.getName()
|
||||
+ ".[ServerLifecycleListener]");
|
||||
if (elementDesc != null) {
|
||||
elementDesc.getStoreFactory().store(aWriter, indent,
|
||||
listener);
|
||||
}
|
||||
}*/
|
||||
// Store nested <GlobalNamingResources> element
|
||||
NamingResourcesImpl globalNamingResources = server
|
||||
.getGlobalNamingResources();
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
NamingResourcesImpl.class.getName()
|
||||
+ ".[GlobalNamingResources]");
|
||||
if (elementDesc != null) {
|
||||
elementDesc.getStoreFactory().store(aWriter, indent,
|
||||
globalNamingResources);
|
||||
}
|
||||
// Store nested <Service> elements
|
||||
Service services[] = server.findServices();
|
||||
storeElementArray(aWriter, indent, services);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
71
java/org/apache/catalina/storeconfig/StandardServiceSF.java
Normal file
71
java/org/apache/catalina/storeconfig/StandardServiceSF.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.Engine;
|
||||
import org.apache.catalina.Executor;
|
||||
import org.apache.catalina.Lifecycle;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.connector.Connector;
|
||||
import org.apache.catalina.core.StandardService;
|
||||
|
||||
/**
|
||||
* Store server.xml Element Service and all children
|
||||
*/
|
||||
public class StandardServiceSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified service element children.
|
||||
*
|
||||
* @param aWriter Current output writer
|
||||
* @param indent Indentation level
|
||||
* @param aService Service to store
|
||||
* @param parentDesc The element description
|
||||
* @throws Exception Configuration storing error
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aService,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aService instanceof StandardService) {
|
||||
StandardService service = (StandardService) aService;
|
||||
// Store nested <Listener> elements
|
||||
LifecycleListener listeners[] = ((Lifecycle) service)
|
||||
.findLifecycleListeners();
|
||||
storeElementArray(aWriter, indent, listeners);
|
||||
|
||||
// Store nested <Executor> elements
|
||||
Executor[] executors = service.findExecutors();
|
||||
storeElementArray(aWriter, indent, executors);
|
||||
|
||||
Connector connectors[] = service.findConnectors();
|
||||
storeElementArray(aWriter, indent, connectors);
|
||||
|
||||
// Store nested <Engine> element
|
||||
Engine container = service.getContainer();
|
||||
if (container != null) {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(container.getClass());
|
||||
if (elementDesc != null) {
|
||||
IStoreFactory factory = elementDesc.getStoreFactory();
|
||||
factory.store(aWriter, indent, container);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
414
java/org/apache/catalina/storeconfig/StoreAppender.java
Normal file
414
java/org/apache/catalina/storeconfig/StoreAppender.java
Normal file
@@ -0,0 +1,414 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.beans.IndexedPropertyDescriptor;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.tomcat.util.IntrospectionUtils;
|
||||
import org.apache.tomcat.util.descriptor.web.ResourceBase;
|
||||
import org.apache.tomcat.util.security.Escape;
|
||||
|
||||
/**
|
||||
* StoreAppends generate really the xml tag elements
|
||||
*/
|
||||
public class StoreAppender {
|
||||
|
||||
/**
|
||||
* The set of classes that represent persistable properties.
|
||||
*/
|
||||
private static Class<?> persistables[] = { String.class, Integer.class,
|
||||
Integer.TYPE, Boolean.class, Boolean.TYPE, Byte.class, Byte.TYPE,
|
||||
Character.class, Character.TYPE, Double.class, Double.TYPE,
|
||||
Float.class, Float.TYPE, Long.class, Long.TYPE, Short.class,
|
||||
Short.TYPE, InetAddress.class };
|
||||
|
||||
private int pos = 0;
|
||||
|
||||
/**
|
||||
* Print the closing tag.
|
||||
*
|
||||
* @param aWriter The output writer
|
||||
* @param aDesc Store description of the current element
|
||||
* @throws Exception A store error occurred
|
||||
*/
|
||||
public void printCloseTag(PrintWriter aWriter, StoreDescription aDesc)
|
||||
throws Exception {
|
||||
aWriter.print("</");
|
||||
aWriter.print(aDesc.getTag());
|
||||
aWriter.println(">");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print only the open tag with all attributes.
|
||||
*
|
||||
* @param aWriter The output writer
|
||||
* @param indent Indentation level
|
||||
* @param bean The current bean that is stored
|
||||
* @param aDesc Store description of the current element
|
||||
* @throws Exception A store error occurred
|
||||
*/
|
||||
public void printOpenTag(PrintWriter aWriter, int indent, Object bean,
|
||||
StoreDescription aDesc) throws Exception {
|
||||
aWriter.print("<");
|
||||
aWriter.print(aDesc.getTag());
|
||||
if (aDesc.isAttributes() && bean != null)
|
||||
printAttributes(aWriter, indent, bean, aDesc);
|
||||
aWriter.println(">");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print tag with all attributes
|
||||
*
|
||||
* @param aWriter The output writer
|
||||
* @param indent Indentation level
|
||||
* @param bean The current bean that is stored
|
||||
* @param aDesc Store description of the current element
|
||||
* @throws Exception A store error occurred
|
||||
*/
|
||||
public void printTag(PrintWriter aWriter, int indent, Object bean,
|
||||
StoreDescription aDesc) throws Exception {
|
||||
aWriter.print("<");
|
||||
aWriter.print(aDesc.getTag());
|
||||
if (aDesc.isAttributes() && bean != null)
|
||||
printAttributes(aWriter, indent, bean, aDesc);
|
||||
aWriter.println("/>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the value from tag as content.
|
||||
*
|
||||
* @param aWriter The output writer
|
||||
* @param tag The element name
|
||||
* @param content Element content
|
||||
* @throws Exception A store error occurred
|
||||
*/
|
||||
public void printTagContent(PrintWriter aWriter, String tag, String content)
|
||||
throws Exception {
|
||||
aWriter.print("<");
|
||||
aWriter.print(tag);
|
||||
aWriter.print(">");
|
||||
aWriter.print(Escape.xml(content));
|
||||
aWriter.print("</");
|
||||
aWriter.print(tag);
|
||||
aWriter.println(">");
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an array of values.
|
||||
*
|
||||
* @param aWriter The output writer
|
||||
* @param tag The element name
|
||||
* @param indent Indentation level
|
||||
* @param elements Array of element values
|
||||
*/
|
||||
public void printTagValueArray(PrintWriter aWriter, String tag, int indent,
|
||||
String[] elements) {
|
||||
if (elements != null && elements.length > 0) {
|
||||
printIndent(aWriter, indent + 2);
|
||||
aWriter.print("<");
|
||||
aWriter.print(tag);
|
||||
aWriter.print(">");
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
printIndent(aWriter, indent + 4);
|
||||
aWriter.print(elements[i]);
|
||||
if (i + 1 < elements.length)
|
||||
aWriter.println(",");
|
||||
}
|
||||
printIndent(aWriter, indent + 2);
|
||||
aWriter.print("</");
|
||||
aWriter.print(tag);
|
||||
aWriter.println(">");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an array of elements.
|
||||
*
|
||||
* @param aWriter The output writer
|
||||
* @param tag The element name
|
||||
* @param indent Indentation level
|
||||
* @param elements Array of elements
|
||||
* @throws Exception Store error occurred
|
||||
*/
|
||||
public void printTagArray(PrintWriter aWriter, String tag, int indent,
|
||||
String[] elements) throws Exception {
|
||||
if (elements != null) {
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
printIndent(aWriter, indent);
|
||||
printTagContent(aWriter, tag, elements[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print some spaces.
|
||||
*
|
||||
* @param aWriter The output writer
|
||||
* @param indent The number of spaces
|
||||
*/
|
||||
public void printIndent(PrintWriter aWriter, int indent) {
|
||||
for (int i = 0; i < indent; i++) {
|
||||
aWriter.print(' ');
|
||||
}
|
||||
pos = indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the relevant attributes of the specified JavaBean, plus a
|
||||
* <code>className</code> attribute defining the fully qualified Java
|
||||
* class name of the bean.
|
||||
*
|
||||
* @param writer PrintWriter to which we are storing
|
||||
* @param indent Indentation level
|
||||
* @param bean
|
||||
* Bean whose properties are to be rendered as attributes,
|
||||
* @param desc Store description of the current element
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
public void printAttributes(PrintWriter writer, int indent, Object bean,
|
||||
StoreDescription desc) throws Exception {
|
||||
|
||||
printAttributes(writer, indent, true, bean, desc);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the relevant attributes of the specified JavaBean.
|
||||
*
|
||||
* @param writer PrintWriter to which we are storing
|
||||
* @param indent Indentation level
|
||||
* @param include
|
||||
* Should we include a <code>className</code> attribute?
|
||||
* @param bean
|
||||
* Bean whose properties are to be rendered as attributes,
|
||||
* @param desc
|
||||
* RegistryDescriptor from this bean
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
public void printAttributes(PrintWriter writer, int indent,
|
||||
boolean include, Object bean, StoreDescription desc)
|
||||
throws Exception {
|
||||
|
||||
// Render a className attribute if requested
|
||||
if (include && desc != null && !desc.isStandard()) {
|
||||
writer.print(" className=\"");
|
||||
writer.print(bean.getClass().getName());
|
||||
writer.print("\"");
|
||||
}
|
||||
|
||||
// Acquire the list of properties for this bean
|
||||
PropertyDescriptor descriptors[] = Introspector.getBeanInfo(
|
||||
bean.getClass()).getPropertyDescriptors();
|
||||
if (descriptors == null) {
|
||||
descriptors = new PropertyDescriptor[0];
|
||||
}
|
||||
|
||||
// Create blank instance
|
||||
Object bean2 = defaultInstance(bean);
|
||||
for (int i = 0; i < descriptors.length; i++) {
|
||||
Object value = checkAttribute(desc, descriptors[i], descriptors[i].getName(), bean, bean2);
|
||||
if (value != null) {
|
||||
printAttribute(writer, indent, bean, desc, descriptors[i].getName(), bean2, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (bean instanceof ResourceBase) {
|
||||
ResourceBase resource = (ResourceBase) bean;
|
||||
for (Iterator<String> iter = resource.listProperties(); iter.hasNext();) {
|
||||
String name = iter.next();
|
||||
Object value = resource.getProperty(name);
|
||||
if (!isPersistable(value.getClass())) {
|
||||
continue;
|
||||
}
|
||||
if (desc.isTransientAttribute(name)) {
|
||||
continue; // Skip the specified exceptions
|
||||
}
|
||||
printValue(writer, indent, name, value);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the attribute should be printed.
|
||||
* @param desc RegistryDescriptor from this bean
|
||||
* @param descriptor PropertyDescriptor from this bean property
|
||||
* @param attributeName The attribute name to store
|
||||
* @param bean The current bean
|
||||
* @param bean2 A default instance of the bean for comparison
|
||||
* @return null if the value should be skipped, the value to print otherwise
|
||||
*/
|
||||
protected Object checkAttribute(StoreDescription desc, PropertyDescriptor descriptor, String attributeName, Object bean, Object bean2) {
|
||||
if (descriptor instanceof IndexedPropertyDescriptor) {
|
||||
return null; // Indexed properties are not persisted
|
||||
}
|
||||
if (!isPersistable(descriptor.getPropertyType())
|
||||
|| (descriptor.getReadMethod() == null)
|
||||
|| (descriptor.getWriteMethod() == null)) {
|
||||
return null; // Must be a read-write primitive or String
|
||||
}
|
||||
if (desc.isTransientAttribute(descriptor.getName())) {
|
||||
return null; // Skip the specified exceptions
|
||||
}
|
||||
Object value = IntrospectionUtils.getProperty(bean, descriptor.getName());
|
||||
if (value == null) {
|
||||
return null; // Null values are not persisted
|
||||
}
|
||||
Object value2 = IntrospectionUtils.getProperty(bean2, descriptor.getName());
|
||||
if (value.equals(value2)) {
|
||||
// The property has its default value
|
||||
return null;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the specified of the specified JavaBean.
|
||||
*
|
||||
* @param writer PrintWriter to which we are storing
|
||||
* @param indent Indentation level
|
||||
* @param bean The current bean
|
||||
* @param desc RegistryDescriptor from this bean
|
||||
* @param attributeName The attribute name to store
|
||||
* @param bean2 A default instance of the bean for comparison
|
||||
* @param value The attribute value
|
||||
*/
|
||||
protected void printAttribute(PrintWriter writer, int indent, Object bean, StoreDescription desc, String attributeName, Object bean2, Object value) {
|
||||
if (isPrintValue(bean, bean2, attributeName, desc))
|
||||
printValue(writer, indent, attributeName, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the attribute value needs to be stored.
|
||||
*
|
||||
* @param bean
|
||||
* original bean
|
||||
* @param bean2
|
||||
* default bean
|
||||
* @param attrName
|
||||
* attribute name
|
||||
* @param desc
|
||||
* StoreDescription from bean
|
||||
* @return <code>true</code> if the value should be stored
|
||||
*/
|
||||
public boolean isPrintValue(Object bean, Object bean2, String attrName,
|
||||
StoreDescription desc) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate default Instance for the specified bean.
|
||||
*
|
||||
* @param bean The bean
|
||||
* @return an object from same class as bean parameter
|
||||
* @throws ReflectiveOperationException Error creating a new instance
|
||||
*/
|
||||
public Object defaultInstance(Object bean) throws ReflectiveOperationException {
|
||||
return bean.getClass().getConstructor().newInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an attribute value.
|
||||
*
|
||||
* @param writer PrintWriter to which we are storing
|
||||
* @param indent Indentation level
|
||||
* @param name Attribute name
|
||||
* @param value Attribute value
|
||||
*/
|
||||
public void printValue(PrintWriter writer, int indent, String name,
|
||||
Object value) {
|
||||
// Convert IP addresses to strings so they will be persisted
|
||||
if (value instanceof InetAddress) {
|
||||
value = ((InetAddress) value).getHostAddress();
|
||||
}
|
||||
if (!(value instanceof String)) {
|
||||
value = value.toString();
|
||||
}
|
||||
String strValue = Escape.xml((String) value);
|
||||
pos = pos + name.length() + strValue.length();
|
||||
if (pos > 60) {
|
||||
writer.println();
|
||||
printIndent(writer, indent + 4);
|
||||
} else {
|
||||
writer.print(' ');
|
||||
}
|
||||
writer.print(name);
|
||||
writer.print("=\"");
|
||||
writer.print(strValue);
|
||||
writer.print("\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a string, this method replaces all occurrences of '<', '>',
|
||||
* '&', and '"'.
|
||||
* @param input The string to escape
|
||||
* @return the escaped string
|
||||
* @deprecated This method will be removed in Tomcat 9
|
||||
*/
|
||||
@Deprecated
|
||||
public String convertStr(String input) {
|
||||
|
||||
StringBuffer filtered = new StringBuffer(input.length());
|
||||
char c;
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
c = input.charAt(i);
|
||||
if (c == '<') {
|
||||
filtered.append("<");
|
||||
} else if (c == '>') {
|
||||
filtered.append(">");
|
||||
} else if (c == '\'') {
|
||||
filtered.append("'");
|
||||
} else if (c == '"') {
|
||||
filtered.append(""");
|
||||
} else if (c == '&') {
|
||||
filtered.append("&");
|
||||
} else {
|
||||
filtered.append(c);
|
||||
}
|
||||
}
|
||||
return filtered.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the specified property type one for which we should generate a
|
||||
* persistence attribute?
|
||||
*
|
||||
* @param clazz
|
||||
* Java class to be tested
|
||||
* @return <code>true</code> if the specified class should be stored
|
||||
*/
|
||||
protected boolean isPersistable(Class<?> clazz) {
|
||||
|
||||
for (int i = 0; i < persistables.length; i++) {
|
||||
if (persistables[i] == clazz || persistables[i].isAssignableFrom(clazz)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
336
java/org/apache/catalina/storeconfig/StoreConfig.java
Normal file
336
java/org/apache/catalina/storeconfig/StoreConfig.java
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Host;
|
||||
import org.apache.catalina.Server;
|
||||
import org.apache.catalina.Service;
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.catalina.mbeans.MBeanUtils;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
/**
|
||||
* Store Server/Service/Host/Context at file or PrintWriter. Default server.xml
|
||||
* is at $catalina.base/conf/server.xml
|
||||
*/
|
||||
public class StoreConfig implements IStoreConfig {
|
||||
private static Log log = LogFactory.getLog(StoreConfig.class);
|
||||
protected static final StringManager sm = StringManager
|
||||
.getManager(Constants.Package);
|
||||
|
||||
private String serverFilename = "conf/server.xml";
|
||||
|
||||
private StoreRegistry registry;
|
||||
|
||||
private Server server;
|
||||
|
||||
/**
|
||||
* Get server.xml location
|
||||
*
|
||||
* @return The server file name
|
||||
*/
|
||||
public String getServerFilename() {
|
||||
return serverFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new server.xml location.
|
||||
*
|
||||
* @param string The server.xml location
|
||||
*/
|
||||
public void setServerFilename(String string) {
|
||||
serverFilename = string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the StoreRegistry with all factory to generate the
|
||||
* server.xml/context.xml files.
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.IStoreConfig#getRegistry()
|
||||
*/
|
||||
@Override
|
||||
public StoreRegistry getRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setServer(Server aServer) {
|
||||
server = aServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* set StoreRegistry
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.IStoreConfig#setRegistry(org.apache.catalina.storeconfig.StoreRegistry)
|
||||
*/
|
||||
@Override
|
||||
public void setRegistry(StoreRegistry aRegistry) {
|
||||
registry = aRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store current Server.
|
||||
*/
|
||||
@Override
|
||||
public void storeConfig() {
|
||||
store(server);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store Server from Object Name (Catalina:type=Server).
|
||||
*
|
||||
* @param aServerName Server ObjectName
|
||||
* @param backup <code>true</code> to backup existing configuration files
|
||||
* before rewriting them
|
||||
* @param externalAllowed <code>true</code> to allow saving webapp
|
||||
* configuration for webapps that are not inside the host's app
|
||||
* directory
|
||||
* @throws MalformedObjectNameException Bad MBean name
|
||||
*/
|
||||
public synchronized void storeServer(String aServerName, boolean backup,
|
||||
boolean externalAllowed) throws MalformedObjectNameException {
|
||||
if (aServerName == null || aServerName.length() == 0) {
|
||||
if (log.isErrorEnabled())
|
||||
log.error("Please, call with a correct server ObjectName!");
|
||||
return;
|
||||
}
|
||||
MBeanServer mserver = MBeanUtils.createServer();
|
||||
ObjectName objectName = new ObjectName(aServerName);
|
||||
if (mserver.isRegistered(objectName)) {
|
||||
try {
|
||||
Server aServer = (Server) mserver.getAttribute(objectName,
|
||||
"managedResource");
|
||||
StoreDescription desc = null;
|
||||
desc = getRegistry().findDescription(StandardContext.class);
|
||||
if (desc != null) {
|
||||
boolean oldSeparate = desc.isStoreSeparate();
|
||||
boolean oldBackup = desc.isBackup();
|
||||
boolean oldExternalAllowed = desc.isExternalAllowed();
|
||||
try {
|
||||
desc.setStoreSeparate(true);
|
||||
desc.setBackup(backup);
|
||||
desc.setExternalAllowed(externalAllowed);
|
||||
store(aServer);
|
||||
} finally {
|
||||
desc.setStoreSeparate(oldSeparate);
|
||||
desc.setBackup(oldBackup);
|
||||
desc.setExternalAllowed(oldExternalAllowed);
|
||||
}
|
||||
} else {
|
||||
store(aServer);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (log.isInfoEnabled())
|
||||
log.info("Object " + aServerName
|
||||
+ " is no a Server instance or store exception", e);
|
||||
}
|
||||
} else if (log.isInfoEnabled())
|
||||
log.info("Server " + aServerName + " not found!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a Context from ObjectName.
|
||||
*
|
||||
* @param aContextName MBean ObjectName
|
||||
* @param backup <code>true</code> to backup existing configuration files
|
||||
* before rewriting them
|
||||
* @param externalAllowed <code>true</code> to allow saving webapp
|
||||
* configuration for webapps that are not inside the host's app
|
||||
* directory
|
||||
* @throws MalformedObjectNameException Bad MBean name
|
||||
*/
|
||||
public synchronized void storeContext(String aContextName, boolean backup,
|
||||
boolean externalAllowed) throws MalformedObjectNameException {
|
||||
if (aContextName == null || aContextName.length() == 0) {
|
||||
if (log.isErrorEnabled())
|
||||
log.error("Please, call with a correct context ObjectName!");
|
||||
return;
|
||||
}
|
||||
MBeanServer mserver = MBeanUtils.createServer();
|
||||
ObjectName objectName = new ObjectName(aContextName);
|
||||
if (mserver.isRegistered(objectName)) {
|
||||
try {
|
||||
Context aContext = (Context) mserver.getAttribute(objectName,
|
||||
"managedResource");
|
||||
URL configFile = aContext.getConfigFile();
|
||||
if (configFile != null) {
|
||||
try {
|
||||
StoreDescription desc = null;
|
||||
desc = getRegistry().findDescription(
|
||||
aContext.getClass());
|
||||
if (desc != null) {
|
||||
boolean oldSeparate = desc.isStoreSeparate();
|
||||
boolean oldBackup = desc.isBackup();
|
||||
boolean oldExternalAllowed = desc
|
||||
.isExternalAllowed();
|
||||
try {
|
||||
desc.setStoreSeparate(true);
|
||||
desc.setBackup(backup);
|
||||
desc.setExternalAllowed(externalAllowed);
|
||||
desc.getStoreFactory()
|
||||
.store(null, -2, aContext);
|
||||
} finally {
|
||||
desc.setStoreSeparate(oldSeparate);
|
||||
desc.setBackup(oldBackup);
|
||||
desc.setBackup(oldExternalAllowed);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
} else
|
||||
log.error("Missing configFile at Context "
|
||||
+ aContext.getPath() + " to store!");
|
||||
} catch (Exception e) {
|
||||
if (log.isInfoEnabled())
|
||||
log
|
||||
.info(
|
||||
"Object "
|
||||
+ aContextName
|
||||
+ " is no a context instance or store exception",
|
||||
e);
|
||||
}
|
||||
} else if (log.isInfoEnabled())
|
||||
log.info("Context " + aContextName + " not found!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the configuration information for this entire <code>Server</code>
|
||||
* out to the server.xml configuration file.
|
||||
*
|
||||
* @param aServer Server instance
|
||||
* @return <code>true</code> if the store operation was successful
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean store(Server aServer) {
|
||||
StoreFileMover mover = new StoreFileMover(System
|
||||
.getProperty("catalina.base"), getServerFilename(),
|
||||
getRegistry().getEncoding());
|
||||
// Open an output writer for the new configuration file
|
||||
try {
|
||||
try (PrintWriter writer = mover.getWriter()) {
|
||||
store(writer, -2, aServer);
|
||||
}
|
||||
mover.move();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error(sm.getString("config.storeServerError"), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.catalina.storeconfig.IStoreConfig#store(org.apache.catalina.Context)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean store(Context aContext) {
|
||||
URL configFile = aContext.getConfigFile();
|
||||
if (configFile != null) {
|
||||
try {
|
||||
StoreDescription desc = null;
|
||||
desc = getRegistry().findDescription(aContext.getClass());
|
||||
if (desc != null) {
|
||||
boolean old = desc.isStoreSeparate();
|
||||
try {
|
||||
desc.setStoreSeparate(true);
|
||||
desc.getStoreFactory().store(null, -2, aContext);
|
||||
} finally {
|
||||
desc.setStoreSeparate(old);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error(sm.getString("config.storeContextError", aContext.getName()), e);
|
||||
}
|
||||
} else {
|
||||
log.error("Missing configFile at Context " + aContext.getPath());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.catalina.storeconfig.IStoreConfig#store(java.io.PrintWriter,
|
||||
* int, org.apache.catalina.Context)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent,
|
||||
Context aContext) throws Exception {
|
||||
boolean oldSeparate = true;
|
||||
StoreDescription desc = null;
|
||||
try {
|
||||
desc = getRegistry().findDescription(aContext.getClass());
|
||||
oldSeparate = desc.isStoreSeparate();
|
||||
desc.setStoreSeparate(false);
|
||||
desc.getStoreFactory().store(aWriter, indent, aContext);
|
||||
} finally {
|
||||
if (desc != null)
|
||||
desc.setStoreSeparate(oldSeparate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.catalina.storeconfig.IStoreConfig#store(java.io.PrintWriter,
|
||||
* int, org.apache.catalina.Host)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Host aHost)
|
||||
throws Exception {
|
||||
StoreDescription desc = getRegistry().findDescription(
|
||||
aHost.getClass());
|
||||
desc.getStoreFactory().store(aWriter, indent, aHost);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.catalina.storeconfig.IStoreConfig#store(java.io.PrintWriter,
|
||||
* int, org.apache.catalina.Service)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent,
|
||||
Service aService) throws Exception {
|
||||
StoreDescription desc = getRegistry().findDescription(
|
||||
aService.getClass());
|
||||
desc.getStoreFactory().store(aWriter, indent, aService);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.catalina.storeconfig.IStoreConfig#store(java.io.PrintWriter,
|
||||
* int, org.apache.catalina.Server)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter writer, int indent,
|
||||
Server aServer) throws Exception {
|
||||
StoreDescription desc = getRegistry().findDescription(
|
||||
aServer.getClass());
|
||||
desc.getStoreFactory().store(writer, indent, aServer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import javax.management.DynamicMBean;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.catalina.Lifecycle;
|
||||
import org.apache.catalina.LifecycleEvent;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.Server;
|
||||
import org.apache.catalina.mbeans.MBeanUtils;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.modeler.ManagedBean;
|
||||
import org.apache.tomcat.util.modeler.Registry;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
/**
|
||||
* Loads and registers a StoreConfig MBean with the name
|
||||
* <i>Catalina:type=StoreConfig</i>. This listener should only be used with a
|
||||
* {@link Server}.
|
||||
*/
|
||||
public class StoreConfigLifecycleListener implements LifecycleListener {
|
||||
|
||||
private static Log log = LogFactory.getLog(StoreConfigLifecycleListener.class);
|
||||
private static StringManager sm = StringManager.getManager(StoreConfigLifecycleListener.class);
|
||||
|
||||
/**
|
||||
* The configuration information registry for our managed beans.
|
||||
*/
|
||||
protected final Registry registry = MBeanUtils.createRegistry();
|
||||
|
||||
|
||||
IStoreConfig storeConfig;
|
||||
|
||||
private String storeConfigClass = "org.apache.catalina.storeconfig.StoreConfig";
|
||||
|
||||
private String storeRegistry = null;
|
||||
private ObjectName oname = null;
|
||||
|
||||
/**
|
||||
* Register StoreRegistry after Start the complete Server.
|
||||
*
|
||||
* @see org.apache.catalina.LifecycleListener#lifecycleEvent(org.apache.catalina.LifecycleEvent)
|
||||
*/
|
||||
@Override
|
||||
public void lifecycleEvent(LifecycleEvent event) {
|
||||
if (Lifecycle.AFTER_START_EVENT.equals(event.getType())) {
|
||||
if (event.getSource() instanceof Server) {
|
||||
createMBean((Server) event.getSource());
|
||||
} else {
|
||||
log.warn(sm.getString("storeConfigListener.notServer"));
|
||||
}
|
||||
} else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
|
||||
if (oname != null) {
|
||||
registry.unregisterComponent(oname);
|
||||
oname = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create StoreConfig MBean and load StoreRegistry MBeans name is
|
||||
* <code>Catalina:type=StoreConfig</code>.
|
||||
* @param server The Server instance
|
||||
*/
|
||||
protected void createMBean(Server server) {
|
||||
StoreLoader loader = new StoreLoader();
|
||||
try {
|
||||
Class<?> clazz = Class.forName(getStoreConfigClass(), true, this
|
||||
.getClass().getClassLoader());
|
||||
storeConfig = (IStoreConfig) clazz.getConstructor().newInstance();
|
||||
if (null == getStoreRegistry())
|
||||
// default Loading
|
||||
loader.load();
|
||||
else
|
||||
// load a special file registry (url)
|
||||
loader.load(getStoreRegistry());
|
||||
// use the loader Registry
|
||||
storeConfig.setRegistry(loader.getRegistry());
|
||||
storeConfig.setServer(server);
|
||||
} catch (Exception e) {
|
||||
log.error("createMBean load", e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Note: Hard-coded domain used since this object is per Server/JVM
|
||||
oname = new ObjectName("Catalina:type=StoreConfig" );
|
||||
registry.registerComponent(storeConfig, oname, "StoreConfig");
|
||||
} catch (Exception ex) {
|
||||
log.error("createMBean register MBean", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ManagedBean (StoreConfig).
|
||||
*
|
||||
* @param object The object to manage
|
||||
* @return an MBean wrapping the object
|
||||
* @throws Exception if an error occurred
|
||||
*/
|
||||
protected DynamicMBean getManagedBean(Object object) throws Exception {
|
||||
ManagedBean managedBean = registry.findManagedBean("StoreConfig");
|
||||
return managedBean.createMBean(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the store config instance
|
||||
*/
|
||||
public IStoreConfig getStoreConfig() {
|
||||
return storeConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storeConfig
|
||||
* The storeConfig to set.
|
||||
*/
|
||||
public void setStoreConfig(IStoreConfig storeConfig) {
|
||||
this.storeConfig = storeConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the main store config class name
|
||||
*/
|
||||
public String getStoreConfigClass() {
|
||||
return storeConfigClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storeConfigClass
|
||||
* The storeConfigClass to set.
|
||||
*/
|
||||
public void setStoreConfigClass(String storeConfigClass) {
|
||||
this.storeConfigClass = storeConfigClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the store registry
|
||||
*/
|
||||
public String getStoreRegistry() {
|
||||
return storeRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storeRegistry
|
||||
* The storeRegistry to set.
|
||||
*/
|
||||
public void setStoreRegistry(String storeRegistry) {
|
||||
this.storeRegistry = storeRegistry;
|
||||
}
|
||||
}
|
||||
173
java/org/apache/catalina/storeconfig/StoreContextAppender.java
Normal file
173
java/org/apache/catalina/storeconfig/StoreContextAppender.java
Normal file
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.Container;
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.catalina.core.StandardHost;
|
||||
|
||||
/**
|
||||
* store StandardContext Attributes ...
|
||||
*/
|
||||
public class StoreContextAppender extends StoreAppender {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Adds special handling for <code>docBase</code>.
|
||||
*/
|
||||
@Override
|
||||
protected void printAttribute(PrintWriter writer, int indent, Object bean, StoreDescription desc, String attributeName, Object bean2, Object value) {
|
||||
if (isPrintValue(bean, bean2, attributeName, desc)) {
|
||||
if(attributeName.equals("docBase")) {
|
||||
if(bean instanceof StandardContext) {
|
||||
String docBase = ((StandardContext)bean).getOriginalDocBase() ;
|
||||
if(docBase != null)
|
||||
value = docBase ;
|
||||
}
|
||||
}
|
||||
printValue(writer, indent, attributeName, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print Context Values. <ul><li> Special handling to default workDir.
|
||||
* </li><li> Don't save path at external context.xml </li><li> Don't
|
||||
* generate docBase for host.appBase webapps <LI></ul>
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.StoreAppender#isPrintValue(java.lang.Object,
|
||||
* java.lang.Object, java.lang.String,
|
||||
* org.apache.catalina.storeconfig.StoreDescription)
|
||||
*/
|
||||
@Override
|
||||
public boolean isPrintValue(Object bean, Object bean2, String attrName,
|
||||
StoreDescription desc) {
|
||||
boolean isPrint = super.isPrintValue(bean, bean2, attrName, desc);
|
||||
if (isPrint) {
|
||||
StandardContext context = ((StandardContext) bean);
|
||||
if ("workDir".equals(attrName)) {
|
||||
String defaultWorkDir = getDefaultWorkDir(context);
|
||||
isPrint = !defaultWorkDir.equals(context.getWorkDir());
|
||||
} else if ("path".equals(attrName)) {
|
||||
isPrint = desc.isStoreSeparate()
|
||||
&& desc.isExternalAllowed()
|
||||
&& context.getConfigFile() == null;
|
||||
} else if ("docBase".equals(attrName)) {
|
||||
Container host = context.getParent();
|
||||
if (host instanceof StandardHost) {
|
||||
File appBase = getAppBase(((StandardHost) host));
|
||||
File docBase = getDocBase(context,appBase);
|
||||
isPrint = !appBase.equals(docBase.getParentFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
return isPrint;
|
||||
}
|
||||
|
||||
protected File getAppBase(StandardHost host) {
|
||||
|
||||
File appBase;
|
||||
File file = new File(host.getAppBase());
|
||||
if (!file.isAbsolute())
|
||||
file = new File(System.getProperty("catalina.base"), host
|
||||
.getAppBase());
|
||||
try {
|
||||
appBase = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
appBase = file;
|
||||
}
|
||||
return appBase;
|
||||
|
||||
}
|
||||
|
||||
protected File getDocBase(StandardContext context, File appBase) {
|
||||
File docBase;
|
||||
String contextDocBase = context.getOriginalDocBase() ;
|
||||
if(contextDocBase == null)
|
||||
contextDocBase = context.getDocBase() ;
|
||||
File file = new File(contextDocBase);
|
||||
if (!file.isAbsolute())
|
||||
file = new File(appBase, contextDocBase);
|
||||
try {
|
||||
docBase = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
docBase = file;
|
||||
}
|
||||
return docBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make default Work Dir.
|
||||
*
|
||||
* @param context The context
|
||||
* @return The default working directory for the context.
|
||||
*/
|
||||
protected String getDefaultWorkDir(StandardContext context) {
|
||||
String defaultWorkDir = null;
|
||||
String contextWorkDir = context.getName();
|
||||
if (contextWorkDir.length() == 0)
|
||||
contextWorkDir = "_";
|
||||
if (contextWorkDir.startsWith("/"))
|
||||
contextWorkDir = contextWorkDir.substring(1);
|
||||
|
||||
Container host = context.getParent();
|
||||
if (host instanceof StandardHost) {
|
||||
String hostWorkDir = ((StandardHost) host).getWorkDir();
|
||||
if (hostWorkDir != null) {
|
||||
defaultWorkDir = hostWorkDir + File.separator + contextWorkDir;
|
||||
} else {
|
||||
String engineName = context.getParent().getParent().getName();
|
||||
String hostName = context.getParent().getName();
|
||||
defaultWorkDir = "work" + File.separator + engineName
|
||||
+ File.separator + hostName + File.separator
|
||||
+ contextWorkDir;
|
||||
}
|
||||
}
|
||||
return defaultWorkDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a real default StandardContext TODO read and interpret the
|
||||
* default context.xml and context.xml.default TODO Cache a Default
|
||||
* StandardContext ( with reloading strategy) TODO remove really all
|
||||
* elements, but detection is hard... To Listener or Valve from same class?
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.StoreAppender#defaultInstance(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public Object defaultInstance(Object bean) throws ReflectiveOperationException {
|
||||
if (bean instanceof StandardContext) {
|
||||
StandardContext defaultContext = new StandardContext();
|
||||
/*
|
||||
* if (!((StandardContext) bean).getOverride()) {
|
||||
* defaultContext.setParent(((StandardContext)bean).getParent());
|
||||
* ContextConfig contextConfig = new ContextConfig();
|
||||
* defaultContext.addLifecycleListener(contextConfig);
|
||||
* contextConfig.setContext(defaultContext);
|
||||
* contextConfig.processContextConfig(new File(contextConfig
|
||||
* .getBaseDir(), "conf/context.xml"));
|
||||
* contextConfig.processContextConfig(new File(contextConfig
|
||||
* .getConfigBase(), "context.xml.default")); }
|
||||
*/
|
||||
return defaultContext;
|
||||
} else
|
||||
return super.defaultInstance(bean);
|
||||
}
|
||||
}
|
||||
371
java/org/apache/catalina/storeconfig/StoreDescription.java
Normal file
371
java/org/apache/catalina/storeconfig/StoreDescription.java
Normal file
@@ -0,0 +1,371 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Bean of a StoreDescription
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* <Description
|
||||
* tag="Context"
|
||||
* standard="true"
|
||||
* default="true"
|
||||
* externalAllowed="true"
|
||||
* storeSeparate="true"
|
||||
* backup="true"
|
||||
* children="true"
|
||||
* tagClass="org.apache.catalina.core.StandardContext"
|
||||
* storeFactoryClass="org.apache.catalina.storeconfig.StandardContextSF"
|
||||
* storeAppenderClass="org.apache.catalina.storeconfig.StoreContextAppender">
|
||||
* <TransientAttribute>available</TransientAttribute>
|
||||
* <TransientAttribute>configFile</TransientAttribute>
|
||||
* <TransientAttribute>configured</TransientAttribute>
|
||||
* <TransientAttribute>displayName</TransientAttribute>
|
||||
* <TransientAttribute>distributable</TransientAttribute>
|
||||
* <TransientAttribute>domain</TransientAttribute>
|
||||
* <TransientAttribute>engineName</TransientAttribute>
|
||||
* <TransientAttribute>name</TransientAttribute>
|
||||
* <TransientAttribute>publicId</TransientAttribute>
|
||||
* <TransientAttribute>replaceWelcomeFiles</TransientAttribute>
|
||||
* <TransientAttribute>saveConfig</TransientAttribute>
|
||||
* <TransientAttribute>sessionTimeout</TransientAttribute>
|
||||
* <TransientAttribute>startupTime</TransientAttribute>
|
||||
* <TransientAttribute>tldScanTime</TransientAttribute>
|
||||
* </Description>
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
public class StoreDescription {
|
||||
|
||||
private String id;
|
||||
|
||||
private String tag;
|
||||
|
||||
private String tagClass;
|
||||
|
||||
private boolean standard = false;
|
||||
|
||||
private boolean backup = false;
|
||||
|
||||
private boolean externalAllowed = false;
|
||||
|
||||
private boolean externalOnly = false;
|
||||
|
||||
private boolean myDefault = false;
|
||||
|
||||
private boolean attributes = true;
|
||||
|
||||
private String storeFactoryClass;
|
||||
|
||||
private IStoreFactory storeFactory;
|
||||
|
||||
private String storeWriterClass;
|
||||
|
||||
private boolean children = false;
|
||||
|
||||
private List<String> transientAttributes;
|
||||
|
||||
private List<String> transientChildren;
|
||||
|
||||
private boolean storeSeparate = false;
|
||||
|
||||
/**
|
||||
* @return Returns the external.
|
||||
*/
|
||||
public boolean isExternalAllowed() {
|
||||
return externalAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param external
|
||||
* The external to set.
|
||||
*/
|
||||
public void setExternalAllowed(boolean external) {
|
||||
this.externalAllowed = external;
|
||||
}
|
||||
|
||||
public boolean isExternalOnly() {
|
||||
return externalOnly;
|
||||
}
|
||||
|
||||
public void setExternalOnly(boolean external) {
|
||||
this.externalOnly = external;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the standard.
|
||||
*/
|
||||
public boolean isStandard() {
|
||||
return standard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param standard
|
||||
* The standard to set.
|
||||
*/
|
||||
public void setStandard(boolean standard) {
|
||||
this.standard = standard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the backup.
|
||||
*/
|
||||
public boolean isBackup() {
|
||||
return backup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param backup
|
||||
* The backup to set.
|
||||
*/
|
||||
public void setBackup(boolean backup) {
|
||||
this.backup = backup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the myDefault.
|
||||
*/
|
||||
public boolean isDefault() {
|
||||
return myDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param aDefault
|
||||
* The myDefault to set.
|
||||
*/
|
||||
public void setDefault(boolean aDefault) {
|
||||
this.myDefault = aDefault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the storeFactory.
|
||||
*/
|
||||
public String getStoreFactoryClass() {
|
||||
return storeFactoryClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storeFactoryClass
|
||||
* The storeFactory to set.
|
||||
*/
|
||||
public void setStoreFactoryClass(String storeFactoryClass) {
|
||||
this.storeFactoryClass = storeFactoryClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the storeFactory.
|
||||
*/
|
||||
public IStoreFactory getStoreFactory() {
|
||||
return storeFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storeFactory
|
||||
* The storeFactory to set.
|
||||
*/
|
||||
public void setStoreFactory(IStoreFactory storeFactory) {
|
||||
this.storeFactory = storeFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the storeWriterClass.
|
||||
*/
|
||||
public String getStoreWriterClass() {
|
||||
return storeWriterClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storeWriterClass
|
||||
* The storeWriterClass to set.
|
||||
*/
|
||||
public void setStoreWriterClass(String storeWriterClass) {
|
||||
this.storeWriterClass = storeWriterClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the tagClass.
|
||||
*/
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tag
|
||||
* The tag to set.
|
||||
*/
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the tagClass.
|
||||
*/
|
||||
public String getTagClass() {
|
||||
return tagClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tagClass
|
||||
* The tagClass to set.
|
||||
*/
|
||||
public void setTagClass(String tagClass) {
|
||||
this.tagClass = tagClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the transientAttributes.
|
||||
*/
|
||||
public List<String> getTransientAttributes() {
|
||||
return transientAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param transientAttributes
|
||||
* The transientAttributes to set.
|
||||
*/
|
||||
public void setTransientAttributes(List<String> transientAttributes) {
|
||||
this.transientAttributes = transientAttributes;
|
||||
}
|
||||
|
||||
public void addTransientAttribute(String attribute) {
|
||||
if (transientAttributes == null)
|
||||
transientAttributes = new ArrayList<>();
|
||||
transientAttributes.add(attribute);
|
||||
}
|
||||
|
||||
public void removeTransientAttribute(String attribute) {
|
||||
if (transientAttributes != null)
|
||||
transientAttributes.remove(attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the transientChildren.
|
||||
*/
|
||||
public List<String> getTransientChildren() {
|
||||
return transientChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param transientChildren
|
||||
* The transientChildren to set.
|
||||
*/
|
||||
public void setTransientChildren(List<String> transientChildren) {
|
||||
this.transientChildren = transientChildren;
|
||||
}
|
||||
|
||||
public void addTransientChild(String classname) {
|
||||
if (transientChildren == null)
|
||||
transientChildren = new ArrayList<>();
|
||||
transientChildren.add(classname);
|
||||
}
|
||||
|
||||
public void removeTransientChild(String classname) {
|
||||
if (transientChildren != null)
|
||||
transientChildren.remove(classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is child transient, please don't save this.
|
||||
*
|
||||
* @param classname The class name to check
|
||||
* @return is classname attribute?
|
||||
*/
|
||||
public boolean isTransientChild(String classname) {
|
||||
if (transientChildren != null)
|
||||
return transientChildren.contains(classname);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is attribute transient, please don't save this.
|
||||
*
|
||||
* @param attribute The attribute name to check
|
||||
* @return is transient attribute?
|
||||
*/
|
||||
public boolean isTransientAttribute(String attribute) {
|
||||
if (transientAttributes != null)
|
||||
return transientAttributes.contains(attribute);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the real id or TagClass
|
||||
*
|
||||
* @return Returns the id.
|
||||
*/
|
||||
public String getId() {
|
||||
if (id != null)
|
||||
return id;
|
||||
else
|
||||
return getTagClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* The id to set.
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the attributes.
|
||||
*/
|
||||
public boolean isAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param attributes
|
||||
* The attributes to set.
|
||||
*/
|
||||
public void setAttributes(boolean attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if it's a separate store
|
||||
*/
|
||||
public boolean isStoreSeparate() {
|
||||
return storeSeparate;
|
||||
}
|
||||
|
||||
public void setStoreSeparate(boolean storeSeparate) {
|
||||
this.storeSeparate = storeSeparate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the children.
|
||||
*/
|
||||
public boolean isChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param children
|
||||
* The children to set.
|
||||
*/
|
||||
public void setChildren(boolean children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
198
java/org/apache/catalina/storeconfig/StoreFactoryBase.java
Normal file
198
java/org/apache/catalina/storeconfig/StoreFactoryBase.java
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
/**
|
||||
* StoreFactory saves special elements.
|
||||
* Output was generate with StoreAppenders.
|
||||
*/
|
||||
public class StoreFactoryBase implements IStoreFactory {
|
||||
private static Log log = LogFactory.getLog(StoreFactoryBase.class);
|
||||
|
||||
private StoreRegistry registry;
|
||||
|
||||
private StoreAppender storeAppender = new StoreAppender();
|
||||
|
||||
/**
|
||||
* The string manager for this package.
|
||||
*/
|
||||
protected static final StringManager sm = StringManager
|
||||
.getManager(Constants.Package);
|
||||
|
||||
/**
|
||||
* The descriptive information string for this implementation.
|
||||
*/
|
||||
private static final String info = "org.apache.catalina.config.StoreFactoryBase/1.0";
|
||||
|
||||
/**
|
||||
* @return descriptive information about this Factory implementation and the
|
||||
* corresponding version number, in the format
|
||||
* <code><description>/<version></code>.
|
||||
*/
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the storeAppender.
|
||||
*/
|
||||
@Override
|
||||
public StoreAppender getStoreAppender() {
|
||||
return storeAppender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param storeAppender
|
||||
* The storeAppender to set.
|
||||
*/
|
||||
@Override
|
||||
public void setStoreAppender(StoreAppender storeAppender) {
|
||||
this.storeAppender = storeAppender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Registry
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.IStoreFactory#setRegistry(org.apache.catalina.storeconfig.StoreRegistry)
|
||||
*/
|
||||
@Override
|
||||
public void setRegistry(StoreRegistry aRegistry) {
|
||||
registry = aRegistry;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* get Registry
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.IStoreFactory#getRegistry()
|
||||
*/
|
||||
@Override
|
||||
public StoreRegistry getRegistry() {
|
||||
|
||||
return registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeXMLHead(PrintWriter aWriter) {
|
||||
// Store the beginning of this element
|
||||
aWriter.print("<?xml version=\"1.0\" encoding=\"");
|
||||
aWriter.print(getRegistry().getEncoding());
|
||||
aWriter.println("\"?>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a server.xml element with attributes and children
|
||||
*
|
||||
* @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter,
|
||||
* int, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass());
|
||||
|
||||
if (elementDesc != null) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug(sm.getString("factory.storeTag",
|
||||
elementDesc.getTag(), aElement));
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
if (!elementDesc.isChildren()) {
|
||||
getStoreAppender().printTag(aWriter, indent, aElement,
|
||||
elementDesc);
|
||||
} else {
|
||||
getStoreAppender().printOpenTag(aWriter, indent + 2, aElement,
|
||||
elementDesc);
|
||||
storeChildren(aWriter, indent + 2, aElement, elementDesc);
|
||||
getStoreAppender().printIndent(aWriter, indent + 2);
|
||||
getStoreAppender().printCloseTag(aWriter, elementDesc);
|
||||
}
|
||||
} else
|
||||
log.warn(sm.getString("factory.storeNoDescriptor", aElement
|
||||
.getClass()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Must Implement at subclass for custom store children handling.
|
||||
*
|
||||
* @param aWriter Current output writer
|
||||
* @param indent Indentation level
|
||||
* @param aElement Current element
|
||||
* @param elementDesc The element description
|
||||
* @throws Exception Configuration storing error
|
||||
*/
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aElement,
|
||||
StoreDescription elementDesc) throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Store only elements from storeChildren methods that are not a transient
|
||||
* child.
|
||||
*
|
||||
* @param aWriter Current output writer
|
||||
* @param indent Indentation level
|
||||
* @param aTagElement Current element
|
||||
* @throws Exception Configuration storing error
|
||||
*/
|
||||
protected void storeElement(PrintWriter aWriter, int indent,
|
||||
Object aTagElement) throws Exception {
|
||||
if (aTagElement != null) {
|
||||
IStoreFactory elementFactory = getRegistry().findStoreFactory(
|
||||
aTagElement.getClass());
|
||||
|
||||
if (elementFactory != null) {
|
||||
StoreDescription desc = getRegistry().findDescription(
|
||||
aTagElement.getClass());
|
||||
if (!desc.isTransientChild(aTagElement.getClass().getName()))
|
||||
elementFactory.store(aWriter, indent, aTagElement);
|
||||
} else {
|
||||
log.warn(sm.getString("factory.storeNoDescriptor", aTagElement
|
||||
.getClass()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a array of elements.
|
||||
* @param aWriter Current output writer
|
||||
* @param indent Indentation level
|
||||
* @param elements Array of elements
|
||||
* @throws Exception Configuration storing error
|
||||
*/
|
||||
protected void storeElementArray(PrintWriter aWriter, int indent,
|
||||
Object[] elements) throws Exception {
|
||||
if (elements != null) {
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
try {
|
||||
storeElement(aWriter, indent, elements[i]);
|
||||
} catch (IOException ioe) {
|
||||
// ignore children report error them self!
|
||||
// see StandardContext.storeWithBackup()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
123
java/org/apache/catalina/storeconfig/StoreFactoryRule.java
Normal file
123
java/org/apache/catalina/storeconfig/StoreFactoryRule.java
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import org.apache.tomcat.util.digester.Rule;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Rule that creates a new <code>IStoreFactory</code> instance, and associates
|
||||
* it with the top object on the stack (which must implement
|
||||
* <code>IStoreFactory</code>).
|
||||
* </p>
|
||||
*/
|
||||
|
||||
public class StoreFactoryRule extends Rule {
|
||||
|
||||
// ----------------------------------------------------------- Constructors
|
||||
|
||||
/**
|
||||
* Construct a new instance of this Rule.
|
||||
*
|
||||
* @param storeFactoryClass
|
||||
* Default name of the StoreFactory implementation class to be
|
||||
* created
|
||||
* @param attributeName
|
||||
* Name of the attribute that optionally includes an override
|
||||
* name of the IStoreFactory class
|
||||
* @param storeAppenderClass The store appender class
|
||||
* @param appenderAttributeName The attribute name for the store
|
||||
* appender class
|
||||
*/
|
||||
public StoreFactoryRule(String storeFactoryClass, String attributeName,
|
||||
String storeAppenderClass, String appenderAttributeName) {
|
||||
|
||||
this.storeFactoryClass = storeFactoryClass;
|
||||
this.attributeName = attributeName;
|
||||
this.appenderAttributeName = appenderAttributeName;
|
||||
this.storeAppenderClass = storeAppenderClass;
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------- Instance Variables
|
||||
|
||||
/**
|
||||
* The attribute name of an attribute that can override the implementation
|
||||
* class name.
|
||||
*/
|
||||
private String attributeName;
|
||||
|
||||
private String appenderAttributeName;
|
||||
|
||||
/**
|
||||
* The name of the <code>IStoreFactory</code> implementation class.
|
||||
*/
|
||||
private String storeFactoryClass;
|
||||
|
||||
private String storeAppenderClass;
|
||||
|
||||
// --------------------------------------------------------- Public Methods
|
||||
|
||||
/**
|
||||
* Handle the beginning of an XML element.
|
||||
*
|
||||
* @param namespace XML namespace
|
||||
* @param name The element name
|
||||
* @param attributes The attributes of this element
|
||||
* @exception Exception if a processing error occurs
|
||||
*/
|
||||
@Override
|
||||
public void begin(String namespace, String name, Attributes attributes)
|
||||
throws Exception {
|
||||
|
||||
IStoreFactory factory = (IStoreFactory) newInstance(attributeName,
|
||||
storeFactoryClass, attributes);
|
||||
StoreAppender storeAppender = (StoreAppender) newInstance(
|
||||
appenderAttributeName, storeAppenderClass, attributes);
|
||||
factory.setStoreAppender(storeAppender);
|
||||
|
||||
// Add this StoreFactory to our associated component
|
||||
StoreDescription desc = (StoreDescription) digester.peek(0);
|
||||
StoreRegistry registry = (StoreRegistry) digester.peek(1);
|
||||
factory.setRegistry(registry);
|
||||
desc.setStoreFactory(factory);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create new instance from attribute className!
|
||||
*
|
||||
* @param attr class Name attribute
|
||||
* @param defaultName Default Class
|
||||
* @param attributes current digester attribute elements
|
||||
* @return new configured object instance
|
||||
* @throws ReflectiveOperationException Error creating an instance
|
||||
*/
|
||||
protected Object newInstance(String attr, String defaultName,
|
||||
Attributes attributes) throws ReflectiveOperationException {
|
||||
String className = defaultName;
|
||||
if (attr != null) {
|
||||
String value = attributes.getValue(attr);
|
||||
if (value != null)
|
||||
className = value;
|
||||
}
|
||||
Class<?> clazz = Class.forName(className);
|
||||
return clazz.getConstructor().newInstance();
|
||||
}
|
||||
}
|
||||
214
java/org/apache/catalina/storeconfig/StoreFileMover.java
Normal file
214
java/org/apache/catalina/storeconfig/StoreFileMover.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
/**
|
||||
* Move server.xml or context.xml as backup
|
||||
*
|
||||
* TODO Get Encoding from Registry
|
||||
*/
|
||||
public class StoreFileMover {
|
||||
|
||||
protected static final StringManager sm = StringManager.getManager(Constants.Package);
|
||||
|
||||
private String filename = "conf/server.xml";
|
||||
|
||||
private String encoding = "UTF-8";
|
||||
|
||||
private String basename = System.getProperty("catalina.base");
|
||||
|
||||
private File configOld;
|
||||
|
||||
private File configNew;
|
||||
|
||||
private File configSave;
|
||||
|
||||
/**
|
||||
* @return Returns the configNew.
|
||||
*/
|
||||
public File getConfigNew() {
|
||||
return configNew;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the configOld.
|
||||
*/
|
||||
public File getConfigOld() {
|
||||
return configOld;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the configSave.
|
||||
*/
|
||||
public File getConfigSave() {
|
||||
return configSave;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the basename.
|
||||
*/
|
||||
public String getBasename() {
|
||||
return basename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param basename
|
||||
* The basename to set.
|
||||
*/
|
||||
public void setBasename(String basename) {
|
||||
this.basename = basename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The file name
|
||||
*/
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string The file name
|
||||
*/
|
||||
public void setFilename(String string) {
|
||||
filename = string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The encoding
|
||||
*/
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string The encoding
|
||||
*/
|
||||
public void setEncoding(String string) {
|
||||
encoding = string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate file objects for the old and new configuration files.
|
||||
* @param basename The base path
|
||||
* @param encoding The encoding of the file
|
||||
* @param filename The file name
|
||||
*/
|
||||
public StoreFileMover(String basename, String filename, String encoding) {
|
||||
setBasename(basename);
|
||||
setEncoding(encoding);
|
||||
setFilename(filename);
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate file objects for the old and new configuration files.
|
||||
*/
|
||||
public StoreFileMover() {
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the Filename to new with TimeStamp.
|
||||
*/
|
||||
public void init() {
|
||||
String configFile = getFilename();
|
||||
configOld = new File(configFile);
|
||||
if (!configOld.isAbsolute()) {
|
||||
configOld = new File(getBasename(), configFile);
|
||||
}
|
||||
configNew = new File(configFile + ".new");
|
||||
if (!configNew.isAbsolute()) {
|
||||
configNew = new File(getBasename(), configFile + ".new");
|
||||
}
|
||||
if (!configNew.getParentFile().exists()) {
|
||||
if (!configNew.getParentFile().mkdirs()) {
|
||||
throw new IllegalStateException(sm.getString("storeFileMover.directoryCreationError", configNew));
|
||||
}
|
||||
}
|
||||
String sb = getTimeTag();
|
||||
configSave = new File(configFile + sb);
|
||||
if (!configSave.isAbsolute()) {
|
||||
configSave = new File(getBasename(), configFile + sb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuffle old->save and new->old.
|
||||
*
|
||||
* @throws IOException a file operation error occurred
|
||||
*/
|
||||
public void move() throws IOException {
|
||||
if (configOld.renameTo(configSave)) {
|
||||
if (!configNew.renameTo(configOld)) {
|
||||
configSave.renameTo(configOld);
|
||||
throw new IOException(sm.getString("storeFileMover.renameError",
|
||||
configNew.getAbsolutePath(), configOld.getAbsolutePath()));
|
||||
}
|
||||
} else {
|
||||
if (!configOld.exists()) {
|
||||
if (!configNew.renameTo(configOld)) {
|
||||
throw new IOException(sm.getString("storeFileMover.renameError",
|
||||
configNew.getAbsolutePath(), configOld.getAbsolutePath()));
|
||||
}
|
||||
} else {
|
||||
throw new IOException(sm.getString("storeFileMover.renameError",
|
||||
configOld.getAbsolutePath(), configSave.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open an output writer for the new configuration file.
|
||||
*
|
||||
* @return The writer
|
||||
* @throws IOException Failed opening a writer to the new file
|
||||
*/
|
||||
public PrintWriter getWriter() throws IOException {
|
||||
return new PrintWriter(new OutputStreamWriter(
|
||||
new FileOutputStream(configNew), getEncoding()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Time value for backup yyyy-mm-dd.hh-mm-ss.
|
||||
*
|
||||
* @return The time
|
||||
*/
|
||||
protected String getTimeTag() {
|
||||
String ts = (new Timestamp(System.currentTimeMillis())).toString();
|
||||
// yyyy-mm-dd hh:mm:ss
|
||||
// 0123456789012345678
|
||||
StringBuffer sb = new StringBuffer(".");
|
||||
sb.append(ts.substring(0, 10));
|
||||
sb.append('.');
|
||||
sb.append(ts.substring(11, 13));
|
||||
sb.append('-');
|
||||
sb.append(ts.substring(14, 16));
|
||||
sb.append('-');
|
||||
sb.append(ts.substring(17, 19));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
284
java/org/apache/catalina/storeconfig/StoreLoader.java
Normal file
284
java/org/apache/catalina/storeconfig/StoreLoader.java
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.digester.Digester;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* <b>XML Format </b>
|
||||
*
|
||||
* <pre>
|
||||
* {@code
|
||||
* <Registry name="" encoding="UTF-8" >
|
||||
* <Description
|
||||
* tag="Server"
|
||||
* standard="true"
|
||||
* default="true"
|
||||
* tagClass="org.apache.catalina.core.StandardServer"
|
||||
* storeFactoryClass="org.apache.catalina.storeconfig.StandardServerSF">
|
||||
* <TransientAttributes>
|
||||
* <Attribute></Attribute>
|
||||
* </TransientAttributes>
|
||||
* <TransientChildren>
|
||||
* <Child></Child>
|
||||
* </TransientChildren>
|
||||
* </Description>
|
||||
* ...
|
||||
* </Registry>
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* Convention:
|
||||
* <ul>
|
||||
* <li>Factories at subpackage <i>org.apache.catalina.core.storeconfig.xxxSF
|
||||
* </i>.</li>
|
||||
* <li>Element name are the unique Class name</li>
|
||||
* <li>SF for StoreFactory</li>
|
||||
* <li>standard implementation is false</li>
|
||||
* </ul>
|
||||
* other things:
|
||||
* <ul>
|
||||
* <li>Registry XML format is a very good option</li>
|
||||
* <li>Store format is not fix</li>
|
||||
* <li>We hope with the parent declaration we can build recursive child store
|
||||
* operation //dream</li>
|
||||
* <li>Problem is to access child data from array,collections or normal detail
|
||||
* object</li>
|
||||
* <li>Default definitions for Listener, Valve Resource? - Based on interface
|
||||
* type!</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class StoreLoader {
|
||||
private static Log log = LogFactory.getLog(StoreLoader.class);
|
||||
|
||||
/**
|
||||
* The <code>Digester</code> instance used to parse registry descriptors.
|
||||
*/
|
||||
protected static final Digester digester = createDigester();
|
||||
|
||||
private StoreRegistry registry;
|
||||
|
||||
private URL registryResource ;
|
||||
|
||||
/**
|
||||
* @return Returns the registry.
|
||||
*/
|
||||
public StoreRegistry getRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param registry
|
||||
* The registry to set.
|
||||
*/
|
||||
public void setRegistry(StoreRegistry registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and configure the Digester we will be using for setup store
|
||||
* registry.
|
||||
* @return the XML digester that will be used to parse the configuration
|
||||
*/
|
||||
protected static Digester createDigester() {
|
||||
long t1 = System.currentTimeMillis();
|
||||
// Initialize the digester
|
||||
Digester digester = new Digester();
|
||||
digester.setValidating(false);
|
||||
digester.setClassLoader(StoreRegistry.class.getClassLoader());
|
||||
|
||||
// Configure the actions we will be using
|
||||
digester.addObjectCreate("Registry",
|
||||
"org.apache.catalina.storeconfig.StoreRegistry", "className");
|
||||
digester.addSetProperties("Registry");
|
||||
digester
|
||||
.addObjectCreate("Registry/Description",
|
||||
"org.apache.catalina.storeconfig.StoreDescription",
|
||||
"className");
|
||||
digester.addSetProperties("Registry/Description");
|
||||
digester.addRule("Registry/Description", new StoreFactoryRule(
|
||||
"org.apache.catalina.storeconfig.StoreFactoryBase",
|
||||
"storeFactoryClass",
|
||||
"org.apache.catalina.storeconfig.StoreAppender",
|
||||
"storeAppenderClass"));
|
||||
digester.addSetNext("Registry/Description", "registerDescription",
|
||||
"org.apache.catalina.storeconfig.StoreDescription");
|
||||
digester.addCallMethod("Registry/Description/TransientAttribute",
|
||||
"addTransientAttribute", 0);
|
||||
digester.addCallMethod("Registry/Description/TransientChild",
|
||||
"addTransientChild", 0);
|
||||
|
||||
long t2 = System.currentTimeMillis();
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Digester for server-registry.xml created " + (t2 - t1));
|
||||
return digester;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find main configuration file.
|
||||
* @param aFile File name, absolute or relative
|
||||
* to <code>${catalina.base}/conf</code>, if not specified
|
||||
* <code>server-registry.xml</code> is used
|
||||
* @return The file
|
||||
*/
|
||||
protected File serverFile(String aFile) {
|
||||
|
||||
if (aFile == null || aFile.length() < 1)
|
||||
aFile = "server-registry.xml";
|
||||
File file = new File(aFile);
|
||||
if (!file.isAbsolute())
|
||||
file = new File(System.getProperty("catalina.base") + "/conf",
|
||||
aFile);
|
||||
try {
|
||||
file = file.getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
log.error(e);
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load main configuration file from external source.
|
||||
*
|
||||
* @param aURL URL to the configuration file
|
||||
*/
|
||||
public void load(String aURL) {
|
||||
synchronized (digester) {
|
||||
File aRegistryFile = serverFile(aURL);
|
||||
try {
|
||||
registry = (StoreRegistry) digester.parse(aRegistryFile);
|
||||
registryResource = aRegistryFile.toURI().toURL();
|
||||
} catch (IOException e) {
|
||||
log.error(e);
|
||||
} catch (SAXException e) {
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load from defaults
|
||||
* <ul>
|
||||
* <li>System Property URL catalina.storeregistry</li>
|
||||
* <li>File ${catalina.base}/conf/server-registry.xml</li>
|
||||
* <li>class resource org/apache/catalina/storeconfig/server-registry.xml
|
||||
* </li>
|
||||
* </ul>
|
||||
*/
|
||||
public void load() {
|
||||
|
||||
InputStream is = null;
|
||||
registryResource = null ;
|
||||
try {
|
||||
String configUrl = getConfigUrl();
|
||||
if (configUrl != null) {
|
||||
is = (new URL(configUrl)).openStream();
|
||||
if (log.isInfoEnabled())
|
||||
log.info("Find registry server-registry.xml from system property at url "
|
||||
+ configUrl);
|
||||
registryResource = new URL(configUrl);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// Ignore
|
||||
}
|
||||
if (is == null) {
|
||||
try {
|
||||
File home = new File(getCatalinaBase());
|
||||
File conf = new File(home, "conf");
|
||||
File reg = new File(conf, "server-registry.xml");
|
||||
is = new FileInputStream(reg);
|
||||
if (log.isInfoEnabled())
|
||||
log.info("Find registry server-registry.xml at file "
|
||||
+ reg.getCanonicalPath());
|
||||
registryResource = reg.toURI().toURL();
|
||||
} catch (Throwable t) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (is == null) {
|
||||
try {
|
||||
is = StoreLoader.class
|
||||
.getResourceAsStream("/org/apache/catalina/storeconfig/server-registry.xml");
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("Find registry server-registry.xml at classpath resource");
|
||||
registryResource = StoreLoader.class
|
||||
.getResource("/org/apache/catalina/storeconfig/server-registry.xml");
|
||||
|
||||
} catch (Throwable t) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (is != null) {
|
||||
try {
|
||||
synchronized (digester) {
|
||||
registry = (StoreRegistry) digester.parse(is);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
log.error(t);
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is == null) {
|
||||
log.error("Failed to load server-registry.xml");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the catalina.home environment variable.
|
||||
*/
|
||||
private static String getCatalinaHome() {
|
||||
return System.getProperty("catalina.home", System
|
||||
.getProperty("user.dir"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the catalina.base environment variable.
|
||||
*/
|
||||
private static String getCatalinaBase() {
|
||||
return System.getProperty("catalina.base", getCatalinaHome());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the configuration URL.
|
||||
*/
|
||||
private static String getConfigUrl() {
|
||||
return System.getProperty("catalina.storeconfig");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the registryResource.
|
||||
*/
|
||||
public URL getRegistryResource() {
|
||||
return registryResource;
|
||||
}
|
||||
}
|
||||
220
java/org/apache/catalina/storeconfig/StoreRegistry.java
Normal file
220
java/org/apache/catalina/storeconfig/StoreRegistry.java
Normal file
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
import org.apache.catalina.CredentialHandler;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.Manager;
|
||||
import org.apache.catalina.Realm;
|
||||
import org.apache.catalina.Valve;
|
||||
import org.apache.catalina.WebResourceRoot;
|
||||
import org.apache.catalina.WebResourceSet;
|
||||
import org.apache.catalina.ha.CatalinaCluster;
|
||||
import org.apache.catalina.ha.ClusterDeployer;
|
||||
import org.apache.catalina.ha.ClusterListener;
|
||||
import org.apache.catalina.tribes.Channel;
|
||||
import org.apache.catalina.tribes.ChannelInterceptor;
|
||||
import org.apache.catalina.tribes.ChannelReceiver;
|
||||
import org.apache.catalina.tribes.ChannelSender;
|
||||
import org.apache.catalina.tribes.Member;
|
||||
import org.apache.catalina.tribes.MembershipService;
|
||||
import org.apache.catalina.tribes.MessageListener;
|
||||
import org.apache.catalina.tribes.transport.DataSender;
|
||||
import org.apache.coyote.UpgradeProtocol;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.http.CookieProcessor;
|
||||
|
||||
/**
|
||||
* Central StoreRegistry for all server.xml elements
|
||||
*/
|
||||
public class StoreRegistry {
|
||||
private static Log log = LogFactory.getLog(StoreRegistry.class);
|
||||
|
||||
private Map<String, StoreDescription> descriptors = new HashMap<>();
|
||||
|
||||
private String encoding = "UTF-8";
|
||||
|
||||
private String name;
|
||||
|
||||
private String version;
|
||||
|
||||
// Access Information
|
||||
private static Class<?> interfaces[] = { CatalinaCluster.class,
|
||||
ChannelSender.class, ChannelReceiver.class, Channel.class,
|
||||
MembershipService.class, ClusterDeployer.class, Realm.class,
|
||||
Manager.class, DirContext.class, LifecycleListener.class,
|
||||
Valve.class, ClusterListener.class, MessageListener.class,
|
||||
DataSender.class, ChannelInterceptor.class, Member.class,
|
||||
WebResourceRoot.class, WebResourceSet.class,
|
||||
CredentialHandler.class, UpgradeProtocol.class,
|
||||
CookieProcessor.class };
|
||||
|
||||
/**
|
||||
* @return Returns the name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* The name to set.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the version.
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version
|
||||
* The version to set.
|
||||
*/
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a description for id. Handle interface search when no direct match
|
||||
* found.
|
||||
*
|
||||
* @param id The class name
|
||||
* @return The description
|
||||
*/
|
||||
public StoreDescription findDescription(String id) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("search descriptor " + id);
|
||||
StoreDescription desc = descriptors.get(id);
|
||||
if (desc == null) {
|
||||
Class<?> aClass = null;
|
||||
try {
|
||||
aClass = Class.forName(id, true, this.getClass()
|
||||
.getClassLoader());
|
||||
} catch (ClassNotFoundException e) {
|
||||
log.error("ClassName:" + id, e);
|
||||
}
|
||||
if (aClass != null) {
|
||||
desc = descriptors.get(aClass.getName());
|
||||
for (int i = 0; desc == null && i < interfaces.length; i++) {
|
||||
if (interfaces[i].isAssignableFrom(aClass)) {
|
||||
desc = descriptors.get(interfaces[i].getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (log.isDebugEnabled())
|
||||
if (desc != null)
|
||||
log.debug("find descriptor " + id + "#" + desc.getTag() + "#"
|
||||
+ desc.getStoreFactoryClass());
|
||||
else
|
||||
log.debug(("Can't find descriptor for key " + id));
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find Description by class.
|
||||
*
|
||||
* @param aClass The class
|
||||
* @return The description
|
||||
*/
|
||||
public StoreDescription findDescription(Class<?> aClass) {
|
||||
return findDescription(aClass.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find factory from class name.
|
||||
*
|
||||
* @param aClassName The class name
|
||||
* @return The factory
|
||||
*/
|
||||
public IStoreFactory findStoreFactory(String aClassName) {
|
||||
StoreDescription desc = findDescription(aClassName);
|
||||
if (desc != null)
|
||||
return desc.getStoreFactory();
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Find factory from class.
|
||||
*
|
||||
* @param aClass The class
|
||||
* @return The factory
|
||||
*/
|
||||
public IStoreFactory findStoreFactory(Class<?> aClass) {
|
||||
return findStoreFactory(aClass.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new description.
|
||||
*
|
||||
* @param desc New description
|
||||
*/
|
||||
public void registerDescription(StoreDescription desc) {
|
||||
String key = desc.getId();
|
||||
if (key == null || "".equals(key))
|
||||
key = desc.getTagClass();
|
||||
descriptors.put(key, desc);
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("register store descriptor " + key + "#" + desc.getTag()
|
||||
+ "#" + desc.getTagClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a description.
|
||||
*
|
||||
* @param desc The description
|
||||
* @return the description, or <code>null</code> if it was not registered
|
||||
*/
|
||||
public StoreDescription unregisterDescription(StoreDescription desc) {
|
||||
String key = desc.getId();
|
||||
if (key == null || "".equals(key))
|
||||
key = desc.getTagClass();
|
||||
return descriptors.remove(key);
|
||||
}
|
||||
|
||||
// Attributes
|
||||
|
||||
/**
|
||||
* @return The encoding
|
||||
*/
|
||||
public String getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the encoding to use when writing the configuration files.
|
||||
* @param string The encoding
|
||||
*/
|
||||
public void setEncoding(String string) {
|
||||
encoding = string;
|
||||
}
|
||||
|
||||
}
|
||||
54
java/org/apache/catalina/storeconfig/WatchedResourceSF.java
Normal file
54
java/org/apache/catalina/storeconfig/WatchedResourceSF.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
public class WatchedResourceSF extends StoreFactoryBase {
|
||||
private static Log log = LogFactory.getLog(WatchedResourceSF.class);
|
||||
|
||||
/*
|
||||
* Store nested Element Value Arrays WatchedResource
|
||||
*
|
||||
* @see org.apache.catalina.config.IStoreFactory#store(java.io.PrintWriter,
|
||||
* int, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
if (aElement instanceof StandardContext) {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass().getName() + ".[WatchedResource]");
|
||||
String[] resources = ((StandardContext) aElement)
|
||||
.findWatchedResources();
|
||||
if (elementDesc != null) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("store " + elementDesc.getTag() + "( " + aElement
|
||||
+ " )");
|
||||
getStoreAppender().printTagArray(aWriter, "WatchedResource",
|
||||
indent, resources);
|
||||
}
|
||||
} else
|
||||
log.warn("Descriptor for element" + aElement.getClass()
|
||||
+ ".[WatchedResource] not configured!");
|
||||
}
|
||||
}
|
||||
85
java/org/apache/catalina/storeconfig/WebResourceRootSF.java
Normal file
85
java/org/apache/catalina/storeconfig/WebResourceRootSF.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.WebResourceRoot;
|
||||
import org.apache.catalina.WebResourceSet;
|
||||
|
||||
/**
|
||||
* Generate Resources element
|
||||
*/
|
||||
public class WebResourceRootSF extends StoreFactoryBase {
|
||||
|
||||
/**
|
||||
* Store the specified Resources children.
|
||||
*
|
||||
* @param aWriter
|
||||
* PrintWriter to which we are storing
|
||||
* @param indent
|
||||
* Number of spaces to indent this element
|
||||
*
|
||||
* @exception Exception
|
||||
* if an exception occurs while storing
|
||||
*/
|
||||
@Override
|
||||
public void storeChildren(PrintWriter aWriter, int indent, Object aResourceRoot,
|
||||
StoreDescription parentDesc) throws Exception {
|
||||
if (aResourceRoot instanceof WebResourceRoot) {
|
||||
WebResourceRoot resourceRoot = (WebResourceRoot) aResourceRoot;
|
||||
|
||||
// Store nested <PreResources> elements
|
||||
WebResourceSet[] preResourcesArray = resourceRoot.getPreResources();
|
||||
StoreDescription preResourcesElementDesc = getRegistry().findDescription(
|
||||
WebResourceSet.class.getName()
|
||||
+ ".[PreResources]");
|
||||
if (preResourcesElementDesc != null) {
|
||||
for (WebResourceSet preResources : preResourcesArray) {
|
||||
preResourcesElementDesc.getStoreFactory().store(aWriter, indent,
|
||||
preResources);
|
||||
}
|
||||
}
|
||||
|
||||
// Store nested <JarResources> elements
|
||||
WebResourceSet[] jarResourcesArray = resourceRoot.getJarResources();
|
||||
StoreDescription jarResourcesElementDesc = getRegistry().findDescription(
|
||||
WebResourceSet.class.getName()
|
||||
+ ".[JarResources]");
|
||||
if (jarResourcesElementDesc != null) {
|
||||
for (WebResourceSet jarResources : jarResourcesArray) {
|
||||
jarResourcesElementDesc.getStoreFactory().store(aWriter, indent,
|
||||
jarResources);
|
||||
}
|
||||
}
|
||||
|
||||
// Store nested <PostResources> elements
|
||||
WebResourceSet[] postResourcesArray = resourceRoot.getPostResources();
|
||||
StoreDescription postResourcesElementDesc = getRegistry().findDescription(
|
||||
WebResourceSet.class.getName()
|
||||
+ ".[PostResources]");
|
||||
if (postResourcesElementDesc != null) {
|
||||
for (WebResourceSet postResources : postResourcesArray) {
|
||||
postResourcesElementDesc.getStoreFactory().store(aWriter, indent,
|
||||
postResources);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
54
java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java
Normal file
54
java/org/apache/catalina/storeconfig/WrapperLifecycleSF.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
public class WrapperLifecycleSF extends StoreFactoryBase {
|
||||
private static Log log = LogFactory.getLog(WrapperLifecycleSF.class);
|
||||
|
||||
/*
|
||||
* Store nested Element Value Arrays
|
||||
*
|
||||
* @see org.apache.catalina.config.IStoreFactory#store(java.io.PrintWriter,
|
||||
* int, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
if (aElement instanceof StandardContext) {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass().getName() + ".[WrapperLifecycle]");
|
||||
String[] listeners = ((StandardContext) aElement)
|
||||
.findWrapperLifecycles();
|
||||
if (elementDesc != null) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("store " + elementDesc.getTag() + "( " + aElement
|
||||
+ " )");
|
||||
getStoreAppender().printTagArray(aWriter, "WrapperLifecycle",
|
||||
indent, listeners);
|
||||
}
|
||||
} else
|
||||
log.warn("Descriptor for element" + aElement.getClass()
|
||||
+ ".[WrapperLifecycle] not configured!");
|
||||
}
|
||||
}
|
||||
54
java/org/apache/catalina/storeconfig/WrapperListenerSF.java
Normal file
54
java/org/apache/catalina/storeconfig/WrapperListenerSF.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.catalina.storeconfig;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import org.apache.catalina.core.StandardContext;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
|
||||
public class WrapperListenerSF extends StoreFactoryBase {
|
||||
private static Log log = LogFactory.getLog(WrapperListenerSF.class);
|
||||
|
||||
/*
|
||||
* Store nested Element Value Arrays
|
||||
*
|
||||
* @see org.apache.catalina.config.IStoreFactory#store(java.io.PrintWriter,
|
||||
* int, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void store(PrintWriter aWriter, int indent, Object aElement)
|
||||
throws Exception {
|
||||
if (aElement instanceof StandardContext) {
|
||||
StoreDescription elementDesc = getRegistry().findDescription(
|
||||
aElement.getClass().getName() + ".[WrapperListener]");
|
||||
String[] listeners = ((StandardContext) aElement)
|
||||
.findWrapperListeners();
|
||||
if (elementDesc != null) {
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("store " + elementDesc.getTag() + "( " + aElement
|
||||
+ " )");
|
||||
getStoreAppender().printTagArray(aWriter, "WrapperListener",
|
||||
indent, listeners);
|
||||
}
|
||||
} else
|
||||
log.warn("Descriptor for element" + aElement.getClass()
|
||||
+ ".[WrapperListener] not configured!");
|
||||
}
|
||||
}
|
||||
94
java/org/apache/catalina/storeconfig/mbeans-descriptors.xml
Normal file
94
java/org/apache/catalina/storeconfig/mbeans-descriptors.xml
Normal file
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<mbeans-descriptors>
|
||||
|
||||
<mbean name="StoreConfig"
|
||||
className="org.apache.catalina.mbeans.ClassNameMBean"
|
||||
description="Implementation of a store server.xml config"
|
||||
domain="Catalina"
|
||||
group="StoreConfig"
|
||||
type="org.apache.catalina.storeconfig.StoreConfig">
|
||||
<operation name="storeConfig"
|
||||
description="Store Server"
|
||||
impact="ACTION" returnType="void" />
|
||||
<operation name="storeServer"
|
||||
description="Store Server from ObjectName"
|
||||
impact="ACTION" returnType="void" >
|
||||
<parameter name="objectname"
|
||||
description="Objectname from Server"
|
||||
type="java.lang.String"
|
||||
default="Catalina:type=Server"/>
|
||||
<parameter name="backup"
|
||||
description="store Context with backup"
|
||||
type="boolean"/>
|
||||
<parameter name="externalAllowed"
|
||||
description="store all Context external that have a configFile"
|
||||
type="boolean"/>
|
||||
</operation>
|
||||
|
||||
<!--
|
||||
Catalina:j2eeType=WebModule,name=//localhost/manager,J2EEApplication=none,J2EEServer=none
|
||||
-->
|
||||
<operation name="storeContext"
|
||||
description="Store Context from ObjectName"
|
||||
impact="ACTION" returnType="void" >
|
||||
<parameter name="objectname"
|
||||
description="ObjectName from Context"
|
||||
type="java.lang.String"/>
|
||||
<parameter name="backup"
|
||||
description="store with Backup"
|
||||
type="boolean"/>
|
||||
<parameter name="externalAllowed"
|
||||
description="store all or store only internal server.xml context (configFile == null)"
|
||||
type="boolean"/>
|
||||
</operation>
|
||||
<operation name="store"
|
||||
description="Store Server"
|
||||
impact="ACTION" returnType="void" >
|
||||
<parameter name="server"
|
||||
description="Server"
|
||||
type="org.apache.catalina.Server"
|
||||
/>
|
||||
</operation>
|
||||
<operation name="store"
|
||||
description="Store Context"
|
||||
impact="ACTION" returnType="void" >
|
||||
<parameter name="context"
|
||||
description="Context"
|
||||
type="org.apache.catalina.context"/>
|
||||
</operation>
|
||||
<operation name="store"
|
||||
description="Store Host"
|
||||
impact="ACTION" returnType="void" >
|
||||
<parameter name="host"
|
||||
description="Host"
|
||||
type="org.apache.catalina.Host"/>
|
||||
</operation>
|
||||
<operation name="store"
|
||||
description="Store Service"
|
||||
impact="ACTION" returnType="void" >
|
||||
<parameter name="service"
|
||||
description="service"
|
||||
type="org.apache.catalina.Service"/>
|
||||
</operation>
|
||||
|
||||
</mbean>
|
||||
|
||||
</mbeans-descriptors>
|
||||
|
||||
|
||||
543
java/org/apache/catalina/storeconfig/server-registry.xml
Normal file
543
java/org/apache/catalina/storeconfig/server-registry.xml
Normal file
@@ -0,0 +1,543 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<Registry name="Tomcat" version="6.0.35" encoding="UTF-8" >
|
||||
<Description
|
||||
tag="Server"
|
||||
standard="true"
|
||||
default="true"
|
||||
externalAllowed="true"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.core.StandardServer"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StandardServerSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Service"
|
||||
standard="true"
|
||||
default="true"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.core.StandardService"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StandardServiceSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Engine"
|
||||
standard="true"
|
||||
default="true"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.core.StandardEngine"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StandardEngineSF">
|
||||
<TransientAttribute>domain</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="Host"
|
||||
standard="true"
|
||||
default="true"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.core.StandardHost"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StandardHostSF">
|
||||
<TransientAttribute>domain</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="Context"
|
||||
standard="true"
|
||||
default="true"
|
||||
externalAllowed="true"
|
||||
externalOnly="true"
|
||||
storeSeparate="true"
|
||||
backup="true"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.core.StandardContext"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StandardContextSF"
|
||||
storeAppenderClass="org.apache.catalina.storeconfig.StoreContextAppender">
|
||||
<TransientAttribute>available</TransientAttribute>
|
||||
<TransientAttribute>configFile</TransientAttribute>
|
||||
<TransientAttribute>configured</TransientAttribute>
|
||||
<TransientAttribute>displayName</TransientAttribute>
|
||||
<TransientAttribute>distributable</TransientAttribute>
|
||||
<TransientAttribute>domain</TransientAttribute>
|
||||
<TransientAttribute>name</TransientAttribute>
|
||||
<TransientAttribute>publicId</TransientAttribute>
|
||||
<TransientAttribute>originalDocBase</TransientAttribute>
|
||||
<TransientAttribute>replaceWelcomeFiles</TransientAttribute>
|
||||
<TransientAttribute>sessionTimeout</TransientAttribute>
|
||||
<TransientAttribute>startupTime</TransientAttribute>
|
||||
<TransientAttribute>tldScanTime</TransientAttribute>
|
||||
<TransientAttribute>effectiveMajorVersion</TransientAttribute>
|
||||
<TransientAttribute>effectiveMinorVersion</TransientAttribute>
|
||||
<TransientAttribute>webappVersion</TransientAttribute>
|
||||
<TransientAttribute>ignoreAnnotations</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
id="org.apache.catalina.deploy.NamingResourcesImpl.[GlobalNamingResources]"
|
||||
tag="GlobalNamingResources"
|
||||
standard="true"
|
||||
default="false"
|
||||
attributes="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.deploy.NamingResourcesImpl"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.GlobalNamingResourcesSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Connector"
|
||||
standard="true"
|
||||
default="true"
|
||||
tagClass="org.apache.catalina.connector.Connector"
|
||||
children="true"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.ConnectorSF"
|
||||
storeAppenderClass="org.apache.catalina.storeconfig.ConnectorStoreAppender">
|
||||
<TransientAttribute>URIEncoding</TransientAttribute>
|
||||
<TransientAttribute>maxProcessor</TransientAttribute>
|
||||
<TransientAttribute>minProcessor</TransientAttribute>
|
||||
<!-- All attribute duplicated from the SSLHostConfig, removed in Tomcat 10 -->
|
||||
<TransientAttribute>SSLProtocol</TransientAttribute>
|
||||
<TransientAttribute>sslEnabledProtocols</TransientAttribute>
|
||||
<TransientAttribute>SSLCipherSuite</TransientAttribute>
|
||||
<TransientAttribute>ciphers</TransientAttribute>
|
||||
<TransientAttribute>SSLCertificateChainFile</TransientAttribute>
|
||||
<TransientAttribute>SSLCertificateFile</TransientAttribute>
|
||||
<TransientAttribute>keyAlias</TransientAttribute>
|
||||
<TransientAttribute>SSLCertificateKeyFile</TransientAttribute>
|
||||
<TransientAttribute>keyPass</TransientAttribute>
|
||||
<TransientAttribute>SSLPassword</TransientAttribute>
|
||||
<TransientAttribute>keystoreFile</TransientAttribute>
|
||||
<TransientAttribute>keystorePass</TransientAttribute>
|
||||
<TransientAttribute>keystoreProvider</TransientAttribute>
|
||||
<TransientAttribute>keystoreType</TransientAttribute>
|
||||
<TransientAttribute>SSLCACertificateFile</TransientAttribute>
|
||||
<TransientAttribute>SSLCACertificatePath</TransientAttribute>
|
||||
<TransientAttribute>crlFile</TransientAttribute>
|
||||
<TransientAttribute>SSLCARevocationFile</TransientAttribute>
|
||||
<TransientAttribute>SSLCARevocationPath</TransientAttribute>
|
||||
<TransientAttribute>SSLDisableCompression</TransientAttribute>
|
||||
<TransientAttribute>SSLDisableSessionTickets</TransientAttribute>
|
||||
<TransientAttribute>SSLDisableCompression</TransientAttribute>
|
||||
<TransientAttribute>SSLHonorCipherOrder</TransientAttribute>
|
||||
<TransientAttribute>useServerCipherSuitesOrder</TransientAttribute>
|
||||
<TransientAttribute>algorithm</TransientAttribute>
|
||||
<TransientAttribute>sslContext</TransientAttribute>
|
||||
<TransientAttribute>sessionCacheSize</TransientAttribute>
|
||||
<TransientAttribute>sessionTimeout</TransientAttribute>
|
||||
<TransientAttribute>sslProtocol</TransientAttribute>
|
||||
<TransientAttribute>trustManagerClassName</TransientAttribute>
|
||||
<TransientAttribute>truststoreAlgorithm</TransientAttribute>
|
||||
<TransientAttribute>truststoreFile</TransientAttribute>
|
||||
<TransientAttribute>truststorePass</TransientAttribute>
|
||||
<TransientAttribute>truststoreProvider</TransientAttribute>
|
||||
<TransientAttribute>truststoreType</TransientAttribute>
|
||||
<!-- All attribute duplicated from the AbstractHttp11Protocol, removed in Tomcat 10 -->
|
||||
<TransientAttribute>clientAuth</TransientAttribute>
|
||||
<TransientAttribute>SSLVerifyClient</TransientAttribute>
|
||||
<TransientAttribute>trustMaxCertLength</TransientAttribute>
|
||||
<TransientAttribute>SSLVerifyDepth</TransientAttribute>
|
||||
<TransientAttribute>useServerCipherSuitesOrder</TransientAttribute>
|
||||
<TransientAttribute>SSLHonorCipherOrder</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="UpgradeProtocol"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.coyote.UpgradeProtocol"
|
||||
children="false"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="SSLHostConfig"
|
||||
standard="true"
|
||||
default="true"
|
||||
tagClass="org.apache.tomcat.util.net.SSLHostConfig"
|
||||
children="true"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.SSLHostConfigSF">
|
||||
<TransientAttribute>openSslContext</TransientAttribute>
|
||||
<TransientAttribute>openSslConfContext</TransientAttribute>
|
||||
<!-- All attribute duplicated from the Certificate, may be removed in Tomcat 10 -->
|
||||
<TransientAttribute>certificateChainFile</TransientAttribute>
|
||||
<TransientAttribute>certificateFile</TransientAttribute>
|
||||
<TransientAttribute>certificateKeyAlias</TransientAttribute>
|
||||
<TransientAttribute>certificateKeyFile</TransientAttribute>
|
||||
<TransientAttribute>certificateKeyPassword</TransientAttribute>
|
||||
<TransientAttribute>certificateKeystoreFile</TransientAttribute>
|
||||
<TransientAttribute>certificateKeystorePassword</TransientAttribute>
|
||||
<TransientAttribute>certificateKeystoreProvider</TransientAttribute>
|
||||
<TransientAttribute>certificateKeystoreType</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="Certificate"
|
||||
standard="true"
|
||||
default="true"
|
||||
tagClass="org.apache.tomcat.util.net.SSLHostConfigCertificate"
|
||||
children="false"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase"
|
||||
storeAppenderClass="org.apache.catalina.storeconfig.CertificateStoreAppender">
|
||||
</Description>
|
||||
<Description
|
||||
tag="OpenSSLConf"
|
||||
standard="true"
|
||||
default="true"
|
||||
tagClass="org.apache.tomcat.util.net.openssl.OpenSSLConf"
|
||||
children="true"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.OpenSSLConfSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="OpenSSLConfCmd"
|
||||
standard="true"
|
||||
default="true"
|
||||
tagClass="org.apache.tomcat.util.net.openssl.OpenSSLConfCmd"
|
||||
children="false"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="NamingResources"
|
||||
standard="true"
|
||||
default="false"
|
||||
attributes="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.deploy.NamingResourcesImpl"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.NamingResourcesSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Manager"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.Manager"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.ManagerSF">
|
||||
<TransientAttribute>domain</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="Manager"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.session.PersistentManager"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.PersistentManagerSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Store"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.session.FileStore"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Store"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.session.JDBCStore"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Cluster"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.ha.CatalinaCluster"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.CatalinaClusterSF">
|
||||
<TransientAttribute>clusterName</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="Realm"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.Realm"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.RealmSF">
|
||||
<TransientAttribute>domain</TransientAttribute>
|
||||
<TransientAttribute>realmPath</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="CredentialHandler"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.CredentialHandler"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.CredentialHandlerSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Parameter"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.descriptor.web.ApplicationParameter"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Loader"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.loader.WebappLoader"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.LoaderSF">
|
||||
<TransientAttribute>domain</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="Listener"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.LifecycleListener"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
<TransientChild>org.apache.catalina.mbeans.ServerLifecycleListener</TransientChild>
|
||||
<TransientChild>org.apache.catalina.core.NamingContextListener</TransientChild>
|
||||
<TransientChild>org.apache.catalina.startup.ContextConfig</TransientChild>
|
||||
<TransientChild>org.apache.catalina.startup.EngineConfig</TransientChild>
|
||||
<TransientChild>org.apache.catalina.startup.HostConfig</TransientChild>
|
||||
<TransientChild>org.apache.catalina.core.StandardHost$MemoryLeakTrackingListener</TransientChild>
|
||||
<TransientChild>org.apache.catalina.mapper.MapperListener</TransientChild>
|
||||
<TransientChild>org.apache.catalina.core.StandardEngine$AccessLogListener</TransientChild>
|
||||
</Description>
|
||||
<Description
|
||||
id="org.apache.catalina.core.StandardServer.[ServerLifecycleListener]"
|
||||
tag="Listener"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.mbeans.ServerLifecycleListener"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Valve"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.Valve"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
<TransientChild>org.apache.catalina.authenticator.BasicAuthenticator</TransientChild>
|
||||
<TransientChild>org.apache.catalina.authenticator.DigestAuthenticator</TransientChild>
|
||||
<TransientChild>org.apache.catalina.authenticator.FormAuthenticator</TransientChild>
|
||||
<TransientChild>org.apache.catalina.authenticator.NonLoginAuthenticator</TransientChild>
|
||||
<TransientChild>org.apache.catalina.authenticator.SSLAuthenticator</TransientChild>
|
||||
<TransientChild>org.apache.catalina.core.StandardContextValve</TransientChild>
|
||||
<TransientChild>org.apache.catalina.core.StandardEngineValve</TransientChild>
|
||||
<TransientChild>org.apache.catalina.core.StandardHostValve</TransientChild>
|
||||
<TransientChild>org.apache.catalina.valves.CertificatesValve</TransientChild>
|
||||
<TransientChild>org.apache.catalina.valves.ErrorReportValve</TransientChild>
|
||||
<TransientChild>org.apache.catalina.valves.RequestListenerValve</TransientChild>
|
||||
</Description>
|
||||
<Description
|
||||
tag="Environment"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.descriptor.web.ContextEnvironment"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="EJB"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.descriptor.web.ContextEjb"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="LocalEjb"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.descriptor.web.ContextLocalEjb"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Resource"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.descriptor.web.ContextResource"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Resources"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.WebResourceRoot"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.WebResourceRootSF">
|
||||
<TransientAttribute>allowLinking</TransientAttribute>
|
||||
<TransientAttribute>cachingAllowed</TransientAttribute>
|
||||
<TransientAttribute>cacheTtl</TransientAttribute>
|
||||
<TransientAttribute>cacheMaxSize</TransientAttribute>
|
||||
<TransientAttribute>cacheObjectMaxSize</TransientAttribute>
|
||||
<TransientAttribute>cached</TransientAttribute>
|
||||
<TransientAttribute>caseSensitive</TransientAttribute>
|
||||
<TransientAttribute>domain</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
id="org.apache.catalina.WebResourceSet.[PreResources]"
|
||||
tag="PreResources"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.WebResourceSet"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
id="org.apache.catalina.WebResourceSet.[JarResources]"
|
||||
tag="JarResources"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.WebResourceSet"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
id="org.apache.catalina.WebResourceSet.[PostResources]"
|
||||
tag="PostResources"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.WebResourceSet"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="ResourceEnvRef"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.descriptor.web.ContextResourceEnvRef"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="ResourceLink"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.descriptor.web.ContextResourceLink"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Transaction"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.descriptor.web.ContextTransaction"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
id="org.apache.catalina.core.StandardContext.[WrapperLifecycle]"
|
||||
tag="WrapperLifecycle"
|
||||
standard="true"
|
||||
default="false"
|
||||
attributes="false"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.WrapperLifecycleSF">
|
||||
</Description>
|
||||
<Description
|
||||
id="org.apache.catalina.core.StandardContext.[WrapperListener]"
|
||||
tag="WrapperListener"
|
||||
standard="true"
|
||||
default="false"
|
||||
attributes="false"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.WrapperListenerSF">
|
||||
</Description>
|
||||
<Description
|
||||
id="org.apache.catalina.core.StandardContext.[WatchedResource]"
|
||||
tag="WatchedResource"
|
||||
standard="true"
|
||||
default="false"
|
||||
attributes="false"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.WatchedResourceSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Sender"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.tribes.ChannelSender"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.SenderSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Transport"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.tribes.transport.DataSender"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Receiver"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.tribes.ChannelReceiver"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
<TransientAttribute>bind</TransientAttribute>
|
||||
<TransientAttribute>host</TransientAttribute>
|
||||
</Description>
|
||||
<Description
|
||||
tag="Membership"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.tribes.MembershipService"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Deployer"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.ha.ClusterDeployer"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="ClusterListener"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.ha.ClusterListener"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Channel"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.catalina.tribes.Channel"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.ChannelSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Interceptor"
|
||||
standard="false"
|
||||
default="false"
|
||||
children="false"
|
||||
tagClass="org.apache.catalina.tribes.ChannelInterceptor"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.InterceptorSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Member"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.tribes.Member"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="Executor"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.core.StandardThreadExecutor"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="JarScanner"
|
||||
standard="true"
|
||||
default="false"
|
||||
children="true"
|
||||
tagClass="org.apache.tomcat.util.scan.StandardJarScanner"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.JarScannerSF">
|
||||
</Description>
|
||||
<Description
|
||||
tag="JarScanFilter"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.scan.StandardJarScanFilter"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="CookieProcessor"
|
||||
standard="false"
|
||||
default="false"
|
||||
tagClass="org.apache.tomcat.util.http.CookieProcessor"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
<Description
|
||||
tag="SessionIdGenerator"
|
||||
standard="true"
|
||||
default="false"
|
||||
tagClass="org.apache.catalina.util.StandardSessionIdGenerator"
|
||||
storeFactoryClass="org.apache.catalina.storeconfig.StoreFactoryBase">
|
||||
</Description>
|
||||
</Registry>
|
||||
|
||||
Reference in New Issue
Block a user