本文整理汇总了Java中org.apache.catalina.Service类的典型用法代码示例。如果您正苦于以下问题:Java Service类的具体用法?Java Service怎么用?Java Service使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Service类属于org.apache.catalina包,在下文中一共展示了Service类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServer
import org.apache.catalina.Service; //导入依赖的package包/类
private Server getServer() {
Container c = context;
while (c != null && !(c instanceof Engine)) {
c = c.getParent();
}
if (c == null) {
return null;
}
Service s = ((Engine)c).getService();
if (s == null) {
return null;
}
return s.getServer();
}
示例2: createConnector
import org.apache.catalina.Service; //导入依赖的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());
}
示例3: createStandardServiceEngine
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Creates a new StandardService and StandardEngine.
*
* @param domain Domain name for the container instance
* @param defaultHost Name of the default host to be used in the Engine
* @param baseDir Base directory value for Engine
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardServiceEngine(String domain,
String defaultHost, String baseDir) throws Exception{
if (!(container instanceof Server)) {
throw new Exception("Container not Server");
}
StandardEngine engine = new StandardEngine();
engine.setDomain(domain);
engine.setName(domain);
engine.setDefaultHost(defaultHost);
engine.setBaseDir(baseDir);
Service service = new StandardService();
service.setContainer(engine);
service.setName(domain);
((Server) container).addService(service);
return engine.getObjectName().toString();
}
示例4: destroyMBean
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Deregister the MBean for this
* <code>Service</code> object.
*
* @param service The Service to be managed
*
* @exception Exception if an MBean cannot be deregistered
* @deprecated Unused. Will be removed in Tomcat 8.0.x
*/
@Deprecated
static void destroyMBean(Service service)
throws Exception {
String mname = createManagedName(service);
ManagedBean managed = registry.findManagedBean(mname);
if (managed == null) {
return;
}
String domain = managed.getDomain();
if (domain == null)
domain = mserver.getDefaultDomain();
ObjectName oname = createObjectName(domain, service);
if( mserver.isRegistered(oname) )
mserver.unregisterMBean(oname);
}
示例5: getDomain
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Determine the name of the domain to register MBeans for from a given
* Service.
*
* @param service
*
* @deprecated To be removed since to creates a circular dependency. Will
* be replaced in Tomcat 8 by a new method on {@link
* Service}.
*/
@Deprecated
public static String getDomain(Service service) {
// Null service -> return null
if (service == null) {
return null;
}
String domain = null;
Container engine = service.getContainer();
// Use the engine name first
if (engine != null) {
domain = engine.getName();
}
// No engine or no engine name, use the service name
if (domain == null) {
domain = service.getName();
}
// No service name, use null
return domain;
}
示例6: getServer
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Return the Server object that is the ultimate parent for the container
* with which this Realm is associated. If the server cannot be found (eg
* because the container hierarchy is not complete), <code>null</code> is
* returned.
*/
protected Server getServer() {
Container c = container;
if (c instanceof Context) {
c = c.getParent();
}
if (c instanceof Host) {
c = c.getParent();
}
if (c instanceof Engine) {
Service s = ((Engine)c).getService();
if (s != null) {
return s.getServer();
}
}
return null;
}
示例7: addService
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Add a new Service to the set of defined Services.
*
* @param service The Service to be added
*/
@Override
public void addService(Service service) {
service.setServer(this);
synchronized (servicesLock) {
Service results[] = new Service[services.length + 1];
System.arraycopy(services, 0, results, 0, services.length);
results[services.length] = service;
services = results;
if (getState().isAvailable()) {
try {
service.start();
} catch (LifecycleException e) {
// Ignore
}
}
// Report this property change to interested listeners
support.firePropertyChange("service", null, service);
}
}
示例8: findService
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Return the specified Service (if it exists); otherwise return
* <code>null</code>.
*
* @param name Name of the Service to be returned
*/
@Override
public Service findService(String name) {
if (name == null) {
return (null);
}
synchronized (servicesLock) {
for (int i = 0; i < services.length; i++) {
if (name.equals(services[i].getName())) {
return (services[i]);
}
}
}
return (null);
}
示例9: populateSessionTrackingModes
import org.apache.catalina.Service; //导入依赖的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;
}
}
}
示例10: addService
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Add a new Service to the set of defined Services.
*
* @param service
* The Service to be added
*/
@Override
public void addService(Service service) {
service.setServer(this);
synchronized (servicesLock) {
Service results[] = new Service[services.length + 1];
System.arraycopy(services, 0, results, 0, services.length);
results[services.length] = service;
services = results;
if (getState().isAvailable()) {
try {
service.start();
} catch (LifecycleException e) {
// Ignore
}
}
// Report this property change to interested listeners
support.firePropertyChange("service", null, service);
}
}
示例11: createMBeans
import org.apache.catalina.Service; //导入依赖的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: populateSessionTrackingModes
import org.apache.catalina.Service; //导入依赖的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;
}
}
}
示例13: getServer
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Return the Server object that is the ultimate parent for the container
* with which this Realm is associated. If the server cannot be found (eg
* because the container hierarchy is not complete), <code>null</code> is
* returned.
*/
protected Server getServer() {
Container c = container;
if (c instanceof Context) {
c = c.getParent();
}
if (c instanceof Host) {
c = c.getParent();
}
if (c instanceof Engine) {
Service s = ((Engine) c).getService();
if (s != null) {
return s.getServer();
}
}
return null;
}
示例14: createMBean
import org.apache.catalina.Service; //导入依赖的package包/类
/**
* Create, register, and return an MBean for this
* <code>Service</code> object.
*
* @param service The Service to be managed
*
* @exception Exception if an MBean cannot be created or registered
*/
static DynamicMBean createMBean(Service service)
throws Exception {
String mname = createManagedName(service);
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(service);
ObjectName oname = createObjectName(domain, service);
if( mserver.isRegistered( oname )) {
mserver.unregisterMBean(oname);
}
mserver.registerMBean(mbean, oname);
return (mbean);
}
示例15: destroyMBean
import org.apache.catalina.Service; //导入依赖的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);
}
}