init
This commit is contained in:
26
java/org/apache/catalina/mapper/Constants.java
Normal file
26
java/org/apache/catalina/mapper/Constants.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.mapper;
|
||||
|
||||
/**
|
||||
* Static constants for this package.
|
||||
*/
|
||||
public final class Constants {
|
||||
|
||||
public static final String Package = "org.apache.catalina.mapper";
|
||||
|
||||
}
|
||||
31
java/org/apache/catalina/mapper/LocalStrings.properties
Normal file
31
java/org/apache/catalina/mapper/LocalStrings.properties
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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.
|
||||
|
||||
mapper.addHost.sameHost=Duplicate registration of the same host [{0}]. Ignored.
|
||||
mapper.addHost.success=Registered host [{0}]
|
||||
mapper.addHostAlias.sameHost=Duplicate registration of alias [{0}] for the same host [{1}]. Ignored.
|
||||
mapper.addHostAlias.success=Registered alias [{0}] for host [{1}]
|
||||
mapper.duplicateHost=Duplicate Host [{0}]. The name is already used by Host [{1}]. This Host will be ignored.
|
||||
mapper.duplicateHostAlias=Duplicate host Alias [{0}] in Host [{1}]. The name is already used by Host [{2}]. This Alias will be ignored.
|
||||
mapper.removeWrapper=Removing wrapper from Context [{0}] with path [{1}]
|
||||
|
||||
mapperListener.pauseContext=Register Context [{0}] as being reloaded for service [{1}]
|
||||
mapperListener.registerContext=Register Context [{0}] for service [{1}]
|
||||
mapperListener.registerHost=Register host [{0}] at domain [{1}] for service [{2}]
|
||||
mapperListener.registerWrapper=Register Wrapper [{0}] in Context [{1}] for service [{2}]
|
||||
mapperListener.unknownDefaultHost=Unknown default host [{0}] for service [{1}]. Tomcat will not be able process HTTP/1.0 requests that do not specify a host name.
|
||||
mapperListener.unregisterContext=Unregister Context [{0}] for service [{1}]
|
||||
mapperListener.unregisterHost=Unregister host [{0}] at domain [{1}] for service [{2}]
|
||||
mapperListener.unregisterWrapper=Unregister Wrapper [{0}] in Context [{1}] for service [{2}]
|
||||
19
java/org/apache/catalina/mapper/LocalStrings_de.properties
Normal file
19
java/org/apache/catalina/mapper/LocalStrings_de.properties
Normal file
@@ -0,0 +1,19 @@
|
||||
# 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.
|
||||
|
||||
mapper.addHostAlias.success=Alias [{0}] für Host [{1}] registriert
|
||||
|
||||
mapperListener.pauseContext=Registriere Context [{0}] als neu geladen für Service [{1}]
|
||||
mapperListener.registerWrapper=Registriere Wrapper [{0}] im Context [{1}] für Service [{2}]
|
||||
22
java/org/apache/catalina/mapper/LocalStrings_es.properties
Normal file
22
java/org/apache/catalina/mapper/LocalStrings_es.properties
Normal file
@@ -0,0 +1,22 @@
|
||||
# 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.
|
||||
|
||||
mapper.addHostAlias.success=Alias [{0}] registrado para el servidor [{1}]
|
||||
|
||||
mapperListener.pauseContext=El registro de contexto [{0}] como siendo recargado para el servicio [{1}]\n
|
||||
mapperListener.registerHost=Registrar máquina [{0}] en dominio [{1}] para el conector [{2}]
|
||||
mapperListener.registerWrapper=Registre la envoltura [{0}] en el contexto [{1}] para el servicio [{2}]
|
||||
mapperListener.unknownDefaultHost=Máquina por defecto desconocida: [{0}] para el conector [{1}]
|
||||
mapperListener.unregisterHost=Desregistrar máquina [{0}] en dominio [{1}] para el conector [{2}]
|
||||
31
java/org/apache/catalina/mapper/LocalStrings_fr.properties
Normal file
31
java/org/apache/catalina/mapper/LocalStrings_fr.properties
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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.
|
||||
|
||||
mapper.addHost.sameHost=L''enregistrement en double de l''hôte [{0}] est ignoré
|
||||
mapper.addHost.success=Enregistré l''hôte [{0}]
|
||||
mapper.addHostAlias.sameHost=L''enregistrement en double de l''alias [{0}] de l''hôte [{1}] est ignoré
|
||||
mapper.addHostAlias.success=L''alias [{0}] pour le hôte [{1}] a été enregistré
|
||||
mapper.duplicateHost=L''hôte [{0}] est en double et sera ignoré, le nom est déjà utilisé par l''hôte [{1}]
|
||||
mapper.duplicateHostAlias=L''alias [{0}] de l''hôte [{1}] est en double et sera ignoré, le nom est déjà utilisé par l''hôte [{2}]
|
||||
mapper.removeWrapper=Retire l''enrobeur du contexte [{0}] avec le chemin [{1}]
|
||||
|
||||
mapperListener.pauseContext=Enregistrement du contexte [{0}] comme étant en cours de rechargement dans le service [{1}]
|
||||
mapperListener.registerContext=Enregistrement du contexte [{0}] pour le service [{1}]
|
||||
mapperListener.registerHost=Enregistrement de l''hôte [{0}] dans le domaine [{1}] pour le service [{2}]
|
||||
mapperListener.registerWrapper=Enregistrement du wrapper [{0}] dans le contexte [{1}] pour le service [{2}]
|
||||
mapperListener.unknownDefaultHost=L''hôte par défaut [{0}] est inconnu dans le service [{1}], Tomcat ne sera pas capable de traiter les requêtes HTTP/1.0 qui ne spécifient pas de nom d''hôte
|
||||
mapperListener.unregisterContext=Retrait du Context [{0}] pour le service [{1}]
|
||||
mapperListener.unregisterHost=Retrait de l''hôte [{0}] dans le domaine [{1}] pour le service [{2}]
|
||||
mapperListener.unregisterWrapper=Désenregitrement du wrapper [{0}] dans le contexte [{1}] pour le service [{2}]
|
||||
31
java/org/apache/catalina/mapper/LocalStrings_ja.properties
Normal file
31
java/org/apache/catalina/mapper/LocalStrings_ja.properties
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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.
|
||||
|
||||
mapper.addHost.sameHost=同じホスト[{0}]の登録が重複しています。 無視されます。
|
||||
mapper.addHost.success=登録されたホスト[{0}]
|
||||
mapper.addHostAlias.sameHost=ホスト [{1}] にエイリアス [{0}] が重複して登録されました。無視します。
|
||||
mapper.addHostAlias.success=ホスト [{1}] のエイリアス [{0}] を登録しました。
|
||||
mapper.duplicateHost=Host名の重複 [{0}]。この名前はHost[{1}] で使用されているため無視されます。
|
||||
mapper.duplicateHostAlias=Host [{1}]のホストエイリアス[{0}]が重複しています。 名前はすでにHost [{2}]によって使用されています。 このエイリアスは無視されます。
|
||||
mapper.removeWrapper=コンテキスト[{0}]からパス[{1}]を使用してラッパーを削除します
|
||||
|
||||
mapperListener.pauseContext=コンテキスト[{0}]をサービス[{1}]のために再ロードするものとして登録します。
|
||||
mapperListener.registerContext=コンテキスト [{0}] にサービス [{1}] を登録します。
|
||||
mapperListener.registerHost=サービス[{2}]のドメイン[{1}]にホスト[{0}]を登録
|
||||
mapperListener.registerWrapper=サービス [{2}] のコンテキスト [{1}] にラッパー [{0}] を登録しました。
|
||||
mapperListener.unknownDefaultHost=サービス [{1}] にデフォルトホスト [{0}] は存在しません。Tomcat はホスト名を指定しない HTTP/1.0 のリクエストを処理できません。
|
||||
mapperListener.unregisterContext=サービス[{1}]のコンテキスト[{0}]の登録を解除します。
|
||||
mapperListener.unregisterHost=サービス[{2}]のドメイン[{1}]のホスト[{0}]の登録を解除します。
|
||||
mapperListener.unregisterWrapper=サービス[{2}]のContext [{1}]のWrapper [{0}]の登録を解除します。
|
||||
31
java/org/apache/catalina/mapper/LocalStrings_ko.properties
Normal file
31
java/org/apache/catalina/mapper/LocalStrings_ko.properties
Normal file
@@ -0,0 +1,31 @@
|
||||
# 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.
|
||||
|
||||
mapper.addHost.sameHost=동일한 호스트 [{0}]을(를) 중복하여 등록을 시도했는데, 이는 무시됩니다.
|
||||
mapper.addHost.success=등록된 호스트 [{0}]
|
||||
mapper.addHostAlias.sameHost=동일한 호스트 [{1}]을(를) 위한 별칭 [{0}]이(가) 중복해서 등록 시도 되었는데, 이는 무시됩니다.
|
||||
mapper.addHostAlias.success=호스트 [{1}]을(를) 위해 별칭 [{0}]이(가) 등록되었습니다.
|
||||
mapper.duplicateHost=중복된 호스트 [{0}]. 해당 이름은 이미 호스트 [{1}]에 의해 사용되고 있습니다. 이 호스트는 무시될 것입니다.
|
||||
mapper.duplicateHostAlias=호스트 [{1}] 내에 중복된 호스트 별칭 [{0}]. 해당 이름이 이미 호스트 [{2}]에 의해 사용되고 있습니다. 이 별칭은 무시될 것입니다.
|
||||
mapper.removeWrapper=경로 [{1}]의 컨텍스트 [{0}](으)로부터 wapper를 제거합니다.
|
||||
|
||||
mapperListener.pauseContext=컨텍스트 [{0}]을(를), 서비스 [{1}]을(를) 위해 다시 로드되고 있는 것으로 등록합니다.
|
||||
mapperListener.registerContext=서비스 [{1}]을(를) 위한 컨텍스트 [{0}]을(를) 등록합니다.
|
||||
mapperListener.registerHost=서비스 [{2}]을(를) 위해 도메인 [{1}]에 있는 호스트 [{0}]을(를) 등록합니다.
|
||||
mapperListener.registerWrapper=서비스 [{2}]을(를) 위한 컨텍스트 [{1}]에서 Wrapper [{0}]을(를) 등록합니다.
|
||||
mapperListener.unknownDefaultHost=서비스 [{1}]을(를) 위해, 알 수 없는 기본 호스트 [{0}]. Tomcat은 호스트 이름을 지정하지 않은 HTTP/1.0 요청들을 처리할 수 없을 것입니다.
|
||||
mapperListener.unregisterContext=서비스 [{1}]을(를) 위한 컨텍스트 [{0}]에 대한 등록을 제거합니다.
|
||||
mapperListener.unregisterHost=서비스 [{2}]을(를) 위한 도메인 [{1}]에서 호스트 [{0}]의 등록을 제거합니다.
|
||||
mapperListener.unregisterWrapper=서비스 [{2}]을(를) 위한 컨텍스트 [{1}] 내의 Wrapper [{0}]에 대한 등록을 제거합니다.
|
||||
@@ -0,0 +1,23 @@
|
||||
# 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.
|
||||
|
||||
mapper.addHostAlias.success=为虚拟主机 [{1}] 注册了别名 [{0}]
|
||||
|
||||
mapperListener.pauseContext=根据服务需要,注册内容[{0}]已经重新加载
|
||||
mapperListener.registerHost=这域名[{1}]注册主机[{0}],服务:[{2}]
|
||||
mapperListener.registerWrapper=为服务Service[{2}]在上下文Context[{1}]注册Wrapper[{0}]
|
||||
mapperListener.unregisterContext=注销服务[{1}]的上下文[{0}]
|
||||
mapperListener.unregisterHost=在域[{1}]中.,不能注册主机[{0}]为服务[{2}]
|
||||
mapperListener.unregisterWrapper=在上下文[{1}]中注销服务[{2}]的包装程序[{0}]
|
||||
1752
java/org/apache/catalina/mapper/Mapper.java
Normal file
1752
java/org/apache/catalina/mapper/Mapper.java
Normal file
File diff suppressed because it is too large
Load Diff
532
java/org/apache/catalina/mapper/MapperListener.java
Normal file
532
java/org/apache/catalina/mapper/MapperListener.java
Normal file
@@ -0,0 +1,532 @@
|
||||
/*
|
||||
* 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.mapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.catalina.Container;
|
||||
import org.apache.catalina.ContainerEvent;
|
||||
import org.apache.catalina.ContainerListener;
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Engine;
|
||||
import org.apache.catalina.Host;
|
||||
import org.apache.catalina.Lifecycle;
|
||||
import org.apache.catalina.LifecycleEvent;
|
||||
import org.apache.catalina.LifecycleException;
|
||||
import org.apache.catalina.LifecycleListener;
|
||||
import org.apache.catalina.LifecycleState;
|
||||
import org.apache.catalina.Service;
|
||||
import org.apache.catalina.WebResourceRoot;
|
||||
import org.apache.catalina.Wrapper;
|
||||
import org.apache.catalina.util.LifecycleMBeanBase;
|
||||
import org.apache.juli.logging.Log;
|
||||
import org.apache.juli.logging.LogFactory;
|
||||
import org.apache.tomcat.util.res.StringManager;
|
||||
|
||||
|
||||
/**
|
||||
* Mapper listener.
|
||||
*
|
||||
* @author Remy Maucherat
|
||||
* @author Costin Manolache
|
||||
*/
|
||||
public class MapperListener extends LifecycleMBeanBase
|
||||
implements ContainerListener, LifecycleListener {
|
||||
|
||||
|
||||
private static final Log log = LogFactory.getLog(MapperListener.class);
|
||||
|
||||
|
||||
// ----------------------------------------------------- Instance Variables
|
||||
/**
|
||||
* Associated mapper.
|
||||
*/
|
||||
private final Mapper mapper;
|
||||
|
||||
/**
|
||||
* Associated service
|
||||
*/
|
||||
private final Service service;
|
||||
|
||||
|
||||
/**
|
||||
* The string manager for this package.
|
||||
*/
|
||||
private static final StringManager sm =
|
||||
StringManager.getManager(Constants.Package);
|
||||
|
||||
/**
|
||||
* The domain (effectively the engine) this mapper is associated with
|
||||
*/
|
||||
private final String domain = null;
|
||||
|
||||
|
||||
// ----------------------------------------------------------- Constructors
|
||||
|
||||
/**
|
||||
* Create mapper listener.
|
||||
*
|
||||
* @param service The service this listener is associated with
|
||||
*/
|
||||
public MapperListener(Service service) {
|
||||
this.service = service;
|
||||
this.mapper = service.getMapper();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------- Lifecycle Methods
|
||||
|
||||
@Override
|
||||
public void startInternal() throws LifecycleException {
|
||||
|
||||
setState(LifecycleState.STARTING);
|
||||
|
||||
Engine engine = service.getContainer();
|
||||
if (engine == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
findDefaultHost();
|
||||
|
||||
addListeners(engine);
|
||||
|
||||
Container[] conHosts = engine.findChildren();
|
||||
for (Container conHost : conHosts) {
|
||||
Host host = (Host) conHost;
|
||||
if (!LifecycleState.NEW.equals(host.getState())) {
|
||||
// Registering the host will register the context and wrappers
|
||||
registerHost(host);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stopInternal() throws LifecycleException {
|
||||
setState(LifecycleState.STOPPING);
|
||||
|
||||
Engine engine = service.getContainer();
|
||||
if (engine == null) {
|
||||
return;
|
||||
}
|
||||
removeListeners(engine);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getDomainInternal() {
|
||||
if (service instanceof LifecycleMBeanBase) {
|
||||
return ((LifecycleMBeanBase) service).getDomain();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getObjectNameKeyProperties() {
|
||||
// Same as connector but Mapper rather than Connector
|
||||
return ("type=Mapper");
|
||||
}
|
||||
|
||||
// --------------------------------------------- Container Listener methods
|
||||
|
||||
@Override
|
||||
public void containerEvent(ContainerEvent event) {
|
||||
|
||||
if (Container.ADD_CHILD_EVENT.equals(event.getType())) {
|
||||
Container child = (Container) event.getData();
|
||||
addListeners(child);
|
||||
// If child is started then it is too late for life-cycle listener
|
||||
// to register the child so register it here
|
||||
if (child.getState().isAvailable()) {
|
||||
if (child instanceof Host) {
|
||||
registerHost((Host) child);
|
||||
} else if (child instanceof Context) {
|
||||
registerContext((Context) child);
|
||||
} else if (child instanceof Wrapper) {
|
||||
// Only if the Context has started. If it has not, then it
|
||||
// will have its own "after_start" life-cycle event later.
|
||||
if (child.getParent().getState().isAvailable()) {
|
||||
registerWrapper((Wrapper) child);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Container.REMOVE_CHILD_EVENT.equals(event.getType())) {
|
||||
Container child = (Container) event.getData();
|
||||
removeListeners(child);
|
||||
// No need to unregister - life-cycle listener will handle this when
|
||||
// the child stops
|
||||
} else if (Host.ADD_ALIAS_EVENT.equals(event.getType())) {
|
||||
// Handle dynamically adding host aliases
|
||||
mapper.addHostAlias(((Host) event.getSource()).getName(),
|
||||
event.getData().toString());
|
||||
} else if (Host.REMOVE_ALIAS_EVENT.equals(event.getType())) {
|
||||
// Handle dynamically removing host aliases
|
||||
mapper.removeHostAlias(event.getData().toString());
|
||||
} else if (Wrapper.ADD_MAPPING_EVENT.equals(event.getType())) {
|
||||
// Handle dynamically adding wrappers
|
||||
Wrapper wrapper = (Wrapper) event.getSource();
|
||||
Context context = (Context) wrapper.getParent();
|
||||
String contextPath = context.getPath();
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
String version = context.getWebappVersion();
|
||||
String hostName = context.getParent().getName();
|
||||
String wrapperName = wrapper.getName();
|
||||
String mapping = (String) event.getData();
|
||||
boolean jspWildCard = ("jsp".equals(wrapperName)
|
||||
&& mapping.endsWith("/*"));
|
||||
mapper.addWrapper(hostName, contextPath, version, mapping, wrapper,
|
||||
jspWildCard, context.isResourceOnlyServlet(wrapperName));
|
||||
} else if (Wrapper.REMOVE_MAPPING_EVENT.equals(event.getType())) {
|
||||
// Handle dynamically removing wrappers
|
||||
Wrapper wrapper = (Wrapper) event.getSource();
|
||||
|
||||
Context context = (Context) wrapper.getParent();
|
||||
String contextPath = context.getPath();
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
String version = context.getWebappVersion();
|
||||
String hostName = context.getParent().getName();
|
||||
|
||||
String mapping = (String) event.getData();
|
||||
|
||||
mapper.removeWrapper(hostName, contextPath, version, mapping);
|
||||
} else if (Context.ADD_WELCOME_FILE_EVENT.equals(event.getType())) {
|
||||
// Handle dynamically adding welcome files
|
||||
Context context = (Context) event.getSource();
|
||||
|
||||
String hostName = context.getParent().getName();
|
||||
|
||||
String contextPath = context.getPath();
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
|
||||
String welcomeFile = (String) event.getData();
|
||||
|
||||
mapper.addWelcomeFile(hostName, contextPath,
|
||||
context.getWebappVersion(), welcomeFile);
|
||||
} else if (Context.REMOVE_WELCOME_FILE_EVENT.equals(event.getType())) {
|
||||
// Handle dynamically removing welcome files
|
||||
Context context = (Context) event.getSource();
|
||||
|
||||
String hostName = context.getParent().getName();
|
||||
|
||||
String contextPath = context.getPath();
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
|
||||
String welcomeFile = (String) event.getData();
|
||||
|
||||
mapper.removeWelcomeFile(hostName, contextPath,
|
||||
context.getWebappVersion(), welcomeFile);
|
||||
} else if (Context.CLEAR_WELCOME_FILES_EVENT.equals(event.getType())) {
|
||||
// Handle dynamically clearing welcome files
|
||||
Context context = (Context) event.getSource();
|
||||
|
||||
String hostName = context.getParent().getName();
|
||||
|
||||
String contextPath = context.getPath();
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
|
||||
mapper.clearWelcomeFiles(hostName, contextPath,
|
||||
context.getWebappVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------ Protected Methods
|
||||
|
||||
private void findDefaultHost() {
|
||||
|
||||
Engine engine = service.getContainer();
|
||||
String defaultHost = engine.getDefaultHost();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
if (defaultHost != null && defaultHost.length() >0) {
|
||||
Container[] containers = engine.findChildren();
|
||||
|
||||
for (Container container : containers) {
|
||||
Host host = (Host) container;
|
||||
if (defaultHost.equalsIgnoreCase(host.getName())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
String[] aliases = host.findAliases();
|
||||
for (String alias : aliases) {
|
||||
if (defaultHost.equalsIgnoreCase(alias)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(found) {
|
||||
mapper.setDefaultHostName(defaultHost);
|
||||
} else {
|
||||
log.warn(sm.getString("mapperListener.unknownDefaultHost",
|
||||
defaultHost, service));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register host.
|
||||
*/
|
||||
private void registerHost(Host host) {
|
||||
|
||||
String[] aliases = host.findAliases();
|
||||
mapper.addHost(host.getName(), aliases, host);
|
||||
|
||||
for (Container container : host.findChildren()) {
|
||||
if (container.getState().isAvailable()) {
|
||||
registerContext((Context) container);
|
||||
}
|
||||
}
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("mapperListener.registerHost",
|
||||
host.getName(), domain, service));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregister host.
|
||||
*/
|
||||
private void unregisterHost(Host host) {
|
||||
|
||||
String hostname = host.getName();
|
||||
|
||||
mapper.removeHost(hostname);
|
||||
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("mapperListener.unregisterHost", hostname,
|
||||
domain, service));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregister wrapper.
|
||||
*/
|
||||
private void unregisterWrapper(Wrapper wrapper) {
|
||||
|
||||
Context context = ((Context) wrapper.getParent());
|
||||
String contextPath = context.getPath();
|
||||
String wrapperName = wrapper.getName();
|
||||
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
String version = context.getWebappVersion();
|
||||
String hostName = context.getParent().getName();
|
||||
|
||||
String[] mappings = wrapper.findMappings();
|
||||
|
||||
for (String mapping : mappings) {
|
||||
mapper.removeWrapper(hostName, contextPath, version, mapping);
|
||||
}
|
||||
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("mapperListener.unregisterWrapper",
|
||||
wrapperName, contextPath, service));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register context.
|
||||
*/
|
||||
private void registerContext(Context context) {
|
||||
|
||||
String contextPath = context.getPath();
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
Host host = (Host)context.getParent();
|
||||
|
||||
WebResourceRoot resources = context.getResources();
|
||||
String[] welcomeFiles = context.findWelcomeFiles();
|
||||
List<WrapperMappingInfo> wrappers = new ArrayList<>();
|
||||
|
||||
for (Container container : context.findChildren()) {
|
||||
prepareWrapperMappingInfo(context, (Wrapper) container, wrappers);
|
||||
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("mapperListener.registerWrapper",
|
||||
container.getName(), contextPath, service));
|
||||
}
|
||||
}
|
||||
|
||||
mapper.addContextVersion(host.getName(), host, contextPath,
|
||||
context.getWebappVersion(), context, welcomeFiles, resources,
|
||||
wrappers);
|
||||
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("mapperListener.registerContext",
|
||||
contextPath, service));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unregister context.
|
||||
*/
|
||||
private void unregisterContext(Context context) {
|
||||
|
||||
String contextPath = context.getPath();
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
String hostName = context.getParent().getName();
|
||||
|
||||
if (context.getPaused()) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("mapperListener.pauseContext",
|
||||
contextPath, service));
|
||||
}
|
||||
|
||||
mapper.pauseContextVersion(context, hostName, contextPath,
|
||||
context.getWebappVersion());
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("mapperListener.unregisterContext",
|
||||
contextPath, service));
|
||||
}
|
||||
|
||||
mapper.removeContextVersion(context, hostName, contextPath,
|
||||
context.getWebappVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register wrapper.
|
||||
*/
|
||||
private void registerWrapper(Wrapper wrapper) {
|
||||
|
||||
Context context = (Context) wrapper.getParent();
|
||||
String contextPath = context.getPath();
|
||||
if ("/".equals(contextPath)) {
|
||||
contextPath = "";
|
||||
}
|
||||
String version = context.getWebappVersion();
|
||||
String hostName = context.getParent().getName();
|
||||
|
||||
List<WrapperMappingInfo> wrappers = new ArrayList<>();
|
||||
prepareWrapperMappingInfo(context, wrapper, wrappers);
|
||||
mapper.addWrappers(hostName, contextPath, version, wrappers);
|
||||
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug(sm.getString("mapperListener.registerWrapper",
|
||||
wrapper.getName(), contextPath, service));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate <code>wrappers</code> list with information for registration of
|
||||
* mappings for this wrapper in this context.
|
||||
*
|
||||
* @param context
|
||||
* @param wrapper
|
||||
* @param wrappers
|
||||
*/
|
||||
private void prepareWrapperMappingInfo(Context context, Wrapper wrapper,
|
||||
List<WrapperMappingInfo> wrappers) {
|
||||
String wrapperName = wrapper.getName();
|
||||
boolean resourceOnly = context.isResourceOnlyServlet(wrapperName);
|
||||
String[] mappings = wrapper.findMappings();
|
||||
for (String mapping : mappings) {
|
||||
boolean jspWildCard = (wrapperName.equals("jsp")
|
||||
&& mapping.endsWith("/*"));
|
||||
wrappers.add(new WrapperMappingInfo(mapping, wrapper, jspWildCard,
|
||||
resourceOnly));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lifecycleEvent(LifecycleEvent event) {
|
||||
if (event.getType().equals(Lifecycle.AFTER_START_EVENT)) {
|
||||
Object obj = event.getSource();
|
||||
if (obj instanceof Wrapper) {
|
||||
Wrapper w = (Wrapper) obj;
|
||||
// Only if the Context has started. If it has not, then it will
|
||||
// have its own "after_start" event later.
|
||||
if (w.getParent().getState().isAvailable()) {
|
||||
registerWrapper(w);
|
||||
}
|
||||
} else if (obj instanceof Context) {
|
||||
Context c = (Context) obj;
|
||||
// Only if the Host has started. If it has not, then it will
|
||||
// have its own "after_start" event later.
|
||||
if (c.getParent().getState().isAvailable()) {
|
||||
registerContext(c);
|
||||
}
|
||||
} else if (obj instanceof Host) {
|
||||
registerHost((Host) obj);
|
||||
}
|
||||
} else if (event.getType().equals(Lifecycle.BEFORE_STOP_EVENT)) {
|
||||
Object obj = event.getSource();
|
||||
if (obj instanceof Wrapper) {
|
||||
unregisterWrapper((Wrapper) obj);
|
||||
} else if (obj instanceof Context) {
|
||||
unregisterContext((Context) obj);
|
||||
} else if (obj instanceof Host) {
|
||||
unregisterHost((Host) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add this mapper to the container and all child containers
|
||||
*
|
||||
* @param container
|
||||
*/
|
||||
private void addListeners(Container container) {
|
||||
container.addContainerListener(this);
|
||||
container.addLifecycleListener(this);
|
||||
for (Container child : container.findChildren()) {
|
||||
addListeners(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove this mapper from the container and all child containers
|
||||
*
|
||||
* @param container
|
||||
*/
|
||||
private void removeListeners(Container container) {
|
||||
container.removeContainerListener(this);
|
||||
container.removeLifecycleListener(this);
|
||||
for (Container child : container.findChildren()) {
|
||||
removeListeners(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
68
java/org/apache/catalina/mapper/MappingData.java
Normal file
68
java/org/apache/catalina/mapper/MappingData.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.mapper;
|
||||
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.catalina.Host;
|
||||
import org.apache.catalina.Wrapper;
|
||||
import org.apache.catalina.servlet4preview.http.MappingMatch;
|
||||
import org.apache.tomcat.util.buf.MessageBytes;
|
||||
|
||||
/**
|
||||
* Mapping data.
|
||||
*
|
||||
* @author Remy Maucherat
|
||||
*/
|
||||
public class MappingData {
|
||||
|
||||
public Host host = null;
|
||||
public Context context = null;
|
||||
public int contextSlashCount = 0;
|
||||
public Context[] contexts = null;
|
||||
public Wrapper wrapper = null;
|
||||
public boolean jspWildCard = false;
|
||||
|
||||
/**
|
||||
* @deprecated Unused. This will be removed in Tomcat 10.
|
||||
*/
|
||||
@Deprecated
|
||||
public final MessageBytes contextPath = MessageBytes.newInstance();
|
||||
public final MessageBytes requestPath = MessageBytes.newInstance();
|
||||
public final MessageBytes wrapperPath = MessageBytes.newInstance();
|
||||
public final MessageBytes pathInfo = MessageBytes.newInstance();
|
||||
|
||||
public final MessageBytes redirectPath = MessageBytes.newInstance();
|
||||
|
||||
// Fields used by ApplicationMapping to implement javax.servlet.http.HttpServletMapping
|
||||
public MappingMatch matchType = null;
|
||||
|
||||
public void recycle() {
|
||||
host = null;
|
||||
context = null;
|
||||
contextSlashCount = 0;
|
||||
contexts = null;
|
||||
wrapper = null;
|
||||
jspWildCard = false;
|
||||
contextPath.recycle();
|
||||
requestPath.recycle();
|
||||
wrapperPath.recycle();
|
||||
pathInfo.recycle();
|
||||
redirectPath.recycle();
|
||||
matchType = null;
|
||||
}
|
||||
}
|
||||
55
java/org/apache/catalina/mapper/WrapperMappingInfo.java
Normal file
55
java/org/apache/catalina/mapper/WrapperMappingInfo.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.mapper;
|
||||
|
||||
import org.apache.catalina.Wrapper;
|
||||
|
||||
/**
|
||||
* Encapsulates information used to register a Wrapper mapping.
|
||||
*/
|
||||
public class WrapperMappingInfo {
|
||||
|
||||
private final String mapping;
|
||||
private final Wrapper wrapper;
|
||||
private final boolean jspWildCard;
|
||||
private final boolean resourceOnly;
|
||||
|
||||
public WrapperMappingInfo(String mapping, Wrapper wrapper,
|
||||
boolean jspWildCard, boolean resourceOnly) {
|
||||
this.mapping = mapping;
|
||||
this.wrapper = wrapper;
|
||||
this.jspWildCard = jspWildCard;
|
||||
this.resourceOnly = resourceOnly;
|
||||
}
|
||||
|
||||
public String getMapping() {
|
||||
return mapping;
|
||||
}
|
||||
|
||||
public Wrapper getWrapper() {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
public boolean isJspWildCard() {
|
||||
return jspWildCard;
|
||||
}
|
||||
|
||||
public boolean isResourceOnly() {
|
||||
return resourceOnly;
|
||||
}
|
||||
|
||||
}
|
||||
37
java/org/apache/catalina/mapper/mbeans-descriptors.xml
Normal file
37
java/org/apache/catalina/mapper/mbeans-descriptors.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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="Mapper"
|
||||
description="Maps requests received by the associated connector to Hosts, Contexts and Wrappers"
|
||||
domain="Catalina"
|
||||
group="Mapper"
|
||||
type="org.apache.catalina.mapper.MapperListener">
|
||||
|
||||
<attribute name="stateName"
|
||||
description="The name of the LifecycleState that this component is currently in"
|
||||
type="java.lang.String"
|
||||
writeable="false"/>
|
||||
|
||||
<operation name="start" description="Start" impact="ACTION" returnType="void" />
|
||||
<operation name="stop" description="Stop" impact="ACTION" returnType="void" />
|
||||
<operation name="init" description="Init" impact="ACTION" returnType="void" />
|
||||
<operation name="destroy" description="Destroy" impact="ACTION" returnType="void" />
|
||||
|
||||
</mbean>
|
||||
</mbeans-descriptors>
|
||||
Reference in New Issue
Block a user