本文整理汇总了Java中org.apache.catalina.connector.Connector类的典型用法代码示例。如果您正苦于以下问题:Java Connector类的具体用法?Java Connector怎么用?Java Connector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Connector类属于org.apache.catalina.connector包,在下文中一共展示了Connector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: httpConnector
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
public Connector httpConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
// Connector监听的http的端口号
connector.setPort(80);
connector.setSecure(false);
// 监听到http的端口号后转向到的https的端口号
connector.setRedirectPort(8443);
return connector;
}
示例2: addConnector
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Add a new Connector to the set of defined Connectors. The newly
* added Connector will be associated with the most recently added Engine.
*
* @param connector The connector to be added
*
* @exception IllegalStateException if no engines have been added yet
*/
@Override
public synchronized void addConnector(Connector connector) {
if( log.isDebugEnabled() ) {
log.debug("Adding connector (" + connector.getInfo() + ")");
}
// Make sure we have a Container to send requests to
if (engines.length < 1)
throw new IllegalStateException
(sm.getString("embedded.noEngines"));
/*
* Add the connector. This will set the connector's container to the
* most recently added Engine
*/
super.addConnector(connector);
}
示例3: createConnector
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Create a new Connector
*
* @param parent MBean Name of the associated parent component
* @param address The IP address on which to bind
* @param port TCP port number to listen on
* @param isAjp Create a AJP/1.3 Connector
* @param isSSL Create a secure Connector
*
* @exception Exception if an MBean cannot be created or registered
*/
private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL)
throws Exception {
Connector retobj = new Connector();
if ((address!=null) && (address.length()>0)) {
retobj.setProperty("address", address);
}
// Set port number
retobj.setPort(port);
// Set the protocol
retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
// Set SSL
retobj.setSecure(isSSL);
retobj.setScheme(isSSL ? "https" : "http");
// Add the new instance to its parent component
// FIX ME - addConnector will fail
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
service.addConnector(retobj);
// Return the corresponding MBean name
ObjectName coname = retobj.getObjectName();
return (coname.toString());
}
示例4: populateSessionTrackingModes
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
private void populateSessionTrackingModes() {
// URL re-writing is always enabled by default
defaultSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
supportedSessionTrackingModes = EnumSet.of(SessionTrackingMode.URL);
if (context.getCookies()) {
defaultSessionTrackingModes.add(SessionTrackingMode.COOKIE);
supportedSessionTrackingModes.add(SessionTrackingMode.COOKIE);
}
// SSL not enabled by default as it can only used on its own
// Context > Host > Engine > Service
Service s = ((Engine) context.getParent().getParent()).getService();
Connector[] connectors = s.findConnectors();
// Need at least one SSL enabled connector to use the SSL session ID.
for (Connector connector : connectors) {
if (Boolean.TRUE.equals(connector.getAttribute("SSLEnabled"))) {
supportedSessionTrackingModes.add(SessionTrackingMode.SSL);
break;
}
}
}
示例5: getPort
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
public static int getPort(Host h) {
int port = -1;
StandardHost host = (StandardHost) h;
CatalinaUtil.host = (StandardHost) h;
StandardEngine se = (StandardEngine) host.getParent();
StandardService ss = (StandardService) se.getService();
Connector[] cs = ss.findConnectors();
for (Connector c : cs) {
if (c.getProtocolHandlerClassName().contains("Http11Protocol"))
port = c.getPort();
}
return port;
}
示例6: addConnector
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Add a new Connector to the set of defined Connectors, and associate it
* with this Service's Container.
*
* @param connector The Connector to be added
*/
@Override
public void addConnector(Connector connector) {
synchronized (connectorsLock) {
connector.setService(this);
Connector results[] = new Connector[connectors.length + 1];
System.arraycopy(connectors, 0, results, 0, connectors.length);
results[connectors.length] = connector;
connectors = results;
if (getState().isAvailable()) {
try {
connector.start();
} catch (LifecycleException e) {
log.error(sm.getString(
"standardService.connector.startFailed",
connector), e);
}
}
// Report this property change to interested listeners
support.firePropertyChange("connector", null, connector);
}
}
示例7: destroyInternal
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
@Override
protected void destroyInternal() throws LifecycleException {
// Destroy our defined Connectors
synchronized (connectorsLock) {
for (Connector connector : connectors) {
try {
connector.destroy();
} catch (Exception e) {
log.error(sm.getString(
"standardService.connector.destroyFailed",
connector), e);
}
}
}
// Destroy any Executors
for (Executor executor : findExecutors()) {
executor.destroy();
}
if (container != null) {
container.destroy();
}
super.destroyInternal();
}
示例8: createConnector
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Create a new Connector
*
* @param parent
* MBean Name of the associated parent component
* @param address
* The IP address on which to bind
* @param port
* TCP port number to listen on
* @param isAjp
* Create a AJP/1.3 Connector
* @param isSSL
* Create a secure Connector
*
* @exception Exception
* if an MBean cannot be created or registered
*/
private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL)
throws Exception {
Connector retobj = new Connector();
if ((address != null) && (address.length() > 0)) {
retobj.setProperty("address", address);
}
// Set port number
retobj.setPort(port);
// Set the protocol
retobj.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
// Set SSL
retobj.setSecure(isSSL);
retobj.setScheme(isSSL ? "https" : "http");
// Add the new instance to its parent component
// FIX ME - addConnector will fail
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
service.addConnector(retobj);
// Return the corresponding MBean name
ObjectName coname = retobj.getObjectName();
return (coname.toString());
}
示例9: setConnector
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
private void setConnector(Connector connector)
{
if( maxThreads != -2 )
{
connector.setAttribute("maxThreads", maxThreads);
}
connector.setURIEncoding("UTF-8");
connector.setUseBodyEncodingForURI(true);
tomcat.getService().addConnector(connector);
tomcat.setConnector(connector);
}
示例10: addConnector
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Add a new Connector to the set of defined Connectors. The newly
* added Connector will be associated with the most recently added Engine.
*
* @param connector The connector to be added
*
* @exception IllegalStateException if no engines have been added yet
*/
public synchronized void addConnector(Connector connector) {
if( log.isDebugEnabled() ) {
log.debug("Adding connector (" + connector.getInfo() + ")");
}
// Make sure we have a Container to send requests to
if (engines.length < 1)
throw new IllegalStateException
(sm.getString("embedded.noEngines"));
/*
* Add the connector. This will set the connector's container to the
* most recently added Engine
*/
super.addConnector(connector);
}
示例11: createMBeans
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Create the MBeans for the specified Service and its nested components.
*
* @param service Service for which to create MBeans
*
* @exception Exception if an exception is thrown during MBean creation
*/
protected void createMBeans(Service service) throws Exception {
// Create the MBean for the Service itself
if (log.isDebugEnabled())
log.debug("Creating MBean for Service " + service);
//MBeanUtils.createMBean(service);
if (service instanceof StandardService) {
((StandardService) service).addPropertyChangeListener(this);
}
// Create the MBeans for the corresponding Connectors
Connector connectors[] = service.findConnectors();
for (int j = 0; j < connectors.length; j++) {
createMBeans(connectors[j]);
}
// Create the MBean for the associated Engine and friends
Engine engine = (Engine) service.getContainer();
if (engine != null) {
createMBeans(engine);
}
}
示例12: destroyInternal
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
@Override
protected void destroyInternal() throws LifecycleException {
// Destroy our defined Connectors
synchronized (connectorsLock) {
for (Connector connector : connectors) {
try {
connector.destroy();
} catch (Exception e) {
log.error(sm.getString("standardService.connector.destroyFailed", connector), e);
}
}
}
// Destroy any Executors
for (Executor executor : findExecutors()) {
executor.destroy();
}
if (container != null) {
container.destroy();
}
super.destroyInternal();
}
示例13: createMBean
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>Connector</code> object.
*
* @param connector The Connector to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Connector connector)
throws Exception {
String mname = createManagedName(connector);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
Exception e = new Exception("ManagedBean is not found with "+mname);
throw new MBeanException(e);
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
DynamicMBean mbean = managed.createMBean(connector);
ObjectName oname = createObjectName(domain, connector);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例14: destroyMBean
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Deregister the MBean for this
* <code>Connector</code> object.
*
* @param connector The Connector to be managed
*
* @exception Exception if an MBean cannot be deregistered
*/
static void destroyMBean(Connector connector, Service service)
throws Exception {
connector.setService(service);
String mname = createManagedName(connector);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
return;
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, connector);
connector.setService(null);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
}
示例15: findProxyConnector
import org.apache.catalina.connector.Connector; //导入依赖的package包/类
/**
* Find the most likely connector the proxy server should connect to, or
* accept connections from.
*
* @param connectors
* @return
*/
protected Connector findProxyConnector(Connector[] connectors) {
int pos = 0;
int maxThreads = 0;
for (int i = 0; i < connectors.length; i++) {
if (connectors[i].getProtocol().startsWith("AJP")) {
// Return any AJP connector found
return connectors[i];
}
if (Boolean.TRUE.equals(IntrospectionUtils.getProperty(connectors[i].getProtocolHandler(), "reverseConnection"))) {
return connectors[i];
}
Integer mt = (Integer) IntrospectionUtils.getProperty(connectors[i].getProtocolHandler(), "maxThreads");
if (mt.intValue() > maxThreads) {
maxThreads = mt.intValue();
pos = i;
}
}
// If no AJP connector and no reverse, return the connector with the most threads
return connectors[pos];
}