KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > VirtualServer


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.web;
25
26 import com.sun.enterprise.web.stats.PWCRequestStatsImpl;
27 import java.io.File JavaDoc;
28 import java.text.MessageFormat JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.List JavaDoc;
31 import java.util.ResourceBundle JavaDoc;
32 import java.util.Set JavaDoc;
33 import java.util.Vector JavaDoc;
34 import java.util.logging.Level JavaDoc;
35 import java.util.logging.Logger JavaDoc;
36
37 import org.apache.catalina.Container;
38 import org.apache.catalina.LifecycleException;
39 import org.apache.catalina.core.StandardHost;
40
41 import com.sun.enterprise.config.ConfigException;
42 import com.sun.enterprise.config.ConfigContext;
43 import com.sun.enterprise.config.serverbeans.Applications;
44 import com.sun.enterprise.config.serverbeans.J2eeApplication;
45 import com.sun.enterprise.config.serverbeans.HttpService;
46 import com.sun.enterprise.config.serverbeans.Server;
47 import com.sun.enterprise.config.serverbeans.ApplicationRef;
48 //import com.sun.enterprise.config.serverbeans.VirtualServerClass;
49
import com.sun.enterprise.config.serverbeans.WebModule;
50 import com.sun.enterprise.config.serverbeans.ServerBeansFactory;
51 import com.sun.enterprise.instance.WebModulesManager;
52 import com.sun.enterprise.server.ApplicationRegistry;
53 import com.sun.enterprise.util.StringUtils;
54 import com.sun.enterprise.util.io.FileUtils;
55
56 import com.sun.enterprise.server.ApplicationServer;
57
58 import com.sun.enterprise.Switch;
59 import com.sun.enterprise.deployment.Application;
60 import com.sun.enterprise.deployment.WebBundleDescriptor;
61 import com.sun.enterprise.deployment.util.DOLLoadingContextFactory;
62 import com.sun.logging.LogDomains;
63
64 /**
65  * Standard implementation of a virtual server (aka virtual host) in
66  * the iPlanet Application Server.
67  */

68
69 public class VirtualServer extends StandardHost {
70
71     // ------------------------------------------------------------ Constructor
72

73     /**
74      * Default constructor that simply gets a handle to the web container
75      * subsystem's logger.
76      */

77     public VirtualServer() {
78         super();
79
80         setPipeline(new VirtualServerPipeline(this));
81
82         // XXX logger initialization should probably be done in
83
// in LogServiceLifecycle.onInitialization()
84
if (_logger == null) {
85             _logger = LogDomains.getLogger(LogDomains.WEB_LOGGER);
86             _rb = _logger.getResourceBundle();
87         }
88         _debug = _logger.isLoggable(Level.FINE);
89     }
90
91     // ----------------------------------------------------- Instance Variables
92

93     /**
94      * The id of this virtual server as specified in the configuration.
95      */

96     private String JavaDoc _id = null;
97
98     /**
99      * The logger to use for logging ALL web container related messages.
100      */

101     protected static Logger JavaDoc _logger = null;
102
103     /**
104      * The resource bundle containing the message strings for _logger.
105      */

106     protected static ResourceBundle JavaDoc _rb = null;
107
108     /**
109      * Indicates whether the logger level is set to any one of
110      * FINE/FINER/FINEST.
111      *
112      * This flag is used to avoid incurring a perf penalty by making
113      * logging calls for debug messages when the logger level is
114      * INFO or higher.
115      */

116     protected boolean _debug = false;
117
118     /**
119      * The descriptive information about this implementation.
120      */

121     private static final String JavaDoc _info =
122         "com.sun.enterprise.web.VirtualServer/1.0";
123
124     /**
125      * The config bean associated with this VirtualServer
126      */

127     private com.sun.enterprise.config.serverbeans.VirtualServer vsBean;
128
129     /**
130      * The mime mapping associated with this VirtualServer
131      */

132     private MimeMap mimeMap;
133
134     /*
135      * Indicates whether symbolic links from this virtual server's docroot
136      * are followed. This setting is inherited by all web modules deployed on
137      * this virtual server, unless overridden by a web modules allowLinking
138      * property in sun-web.xml.
139      */

140     private boolean allowLinking = true;
141     
142     /*
143      * default-web.xml location
144      */

145     private String JavaDoc defaultWebXmlLocation;
146
147
148     private String JavaDoc[] cacheControls;
149
150
151     // Is this virtual server active?
152
private boolean isActive;
153
154     
155     /**
156      * The Stats holder used by this virtual-server.
157      */

158     private PWCRequestStatsImpl pwcRequestStatsImpl;
159     // ------------------------------------------------------------- Properties
160

161     /**
162      * Return the virtual server identifier.
163      */

164     public String JavaDoc getID() {
165         return _id;
166     }
167
168     /**
169      * Set the virtual server identifier string.
170      *
171      * @param id New identifier for this virtual server
172      */

173     public void setID(String JavaDoc id) {
174         _id = id;
175     }
176
177     /**
178      * @return true if this virtual server is active, false otherwise
179      */

180     public boolean isActive() {
181         return isActive;
182     }
183
184     /**
185      * Sets the state of this virtual server.
186      *
187      * @param isActive true if this virtual server is active, false otherwise
188      */

189     public void setIsActive(boolean isActive) {
190         this.isActive = isActive;
191     }
192
193     /**
194      * Gets the default-web.xml location of web modules deployed on this
195      * virtual server.
196      *
197      * @return default-web.xml location of web modules deployed on this
198      * virtual server
199      */

200     public String JavaDoc getDefaultWebXmlLocation() {
201         return defaultWebXmlLocation;
202     }
203
204     /**
205      * Sets the default-web.xml location for web modules deployed on this
206      * virtual server.
207      *
208      * @param defaultWebXmlLocation default-web.xml location for web modules
209      * deployed on this virtual server
210      */

211     public void setDefaultWebXmlLocation(String JavaDoc defaultWebXmlLocation) {
212         this.defaultWebXmlLocation = defaultWebXmlLocation;
213     }
214
215     /**
216      * Gets the value of the allowLinking property of this virtual server.
217      *
218      * @return true if symbolic links from this virtual server's docroot (as
219      * well as symbolic links from archives of web modules deployed on this
220      * virtual server) are followed, false otherwise
221      */

222     public boolean getAllowLinking() {
223         return allowLinking;
224     }
225
226     /**
227      * Sets the allowLinking property of this virtual server, which determines
228      * whether symblic links from this virtual server's docroot are followed.
229      *
230      * This property is inherited by all web modules deployed on this virtual
231      * server, unless overridden by the allowLinking property in a web module's
232      * sun-web.xml.
233      *
234      * @param allowLinking Value of allowLinking property
235      */

236     public void setAllowLinking(boolean allowLinking) {
237         this.allowLinking = allowLinking;
238     }
239
240     /**
241      * Gets the config bean associated with this VirtualServer.
242      */

243     public com.sun.enterprise.config.serverbeans.VirtualServer getBean(){
244         return vsBean;
245     }
246
247     /**
248      * Sets the config bean for this VirtualServer
249      */

250      public void setBean(com.sun.enterprise.config.serverbeans.VirtualServer vsBean){
251         this.vsBean = vsBean;
252      }
253
254     /**
255      * Gets the mime map associated with this VirtualServer.
256      */

257     public MimeMap getMimeMap(){
258         return mimeMap;
259     }
260
261     /**
262      * Sets the mime map for this VirtualServer
263      */

264     public void setMimeMap(MimeMap mimeMap){
265         this.mimeMap = mimeMap;
266     }
267
268     /**
269      * Gets the Cache-Control configuration of this VirtualServer.
270      *
271      * @return Cache-Control configuration of this VirtualServer, or null if
272      * no such configuration exists for this VirtualServer
273      */

274     public String JavaDoc[] getCacheControls() {
275         return cacheControls;
276     }
277
278     /**
279      * Sets the Cache-Control configuration for this VirtualServer
280      *
281      * @param cacheControls Cache-Control configuration settings for this
282      * VirtualServer
283      */

284     public void setCacheControls(String JavaDoc[] cacheControls) {
285         this.cacheControls = cacheControls;
286     }
287
288
289     // --------------------------------------------------------- Public Methods
290

291     /**
292      * Return descriptive information about this Container implementation and
293      * the corresponding version number, in the format
294      * <code>&lt;description&gt;/&lt;version&gt;</code>.
295      */

296     public String JavaDoc getInfo() {
297         return _info;
298     }
299
300
301     // ------------------------------------------------------ Lifecycle Methods
302

303     /**
304      * Gracefully shut down active use of the public methods of this Component.
305      *
306      * @exception IllegalStateException if this component has not been started
307      * @exception LifecycleException if this component detects a fatal error
308      * that needs to be reported
309      */

310     public synchronized void stop() throws LifecycleException {
311
312         // Remove the descriptor bindings for all the web applications
313
// in this virtual server
314
Switch sw = Switch.getSwitch();
315         Container children[] = findChildren();
316         if (children != null) {
317             for (int i = 0; i < children.length; i++) {
318                 sw.removeDescriptorFor(children[i]);
319             }
320         }
321         super.stop();
322     }
323
324     // ------------------------------------------------------ Protected Methods
325

326     /**
327      * Return the list of enabled web-modules configured for this
328      * virtual server.
329      *
330      * @return The list of WebModuleConfig objects for all enabled
331      * web-modules hosted under the specified virtual server.
332      */

333     protected List JavaDoc getWebModules(Server serverBean, String JavaDoc modulesRoot) {
334
335         List JavaDoc modules = new Vector JavaDoc();
336         
337         //ROB: config changes
338
//Applications appsBean = serverBean.getApplications();
339
Applications appsBean = null;
340         try {
341             appsBean = ServerBeansFactory.getApplicationsBean(serverBean.getConfigContext());
342         } catch (ConfigException e) {
343             String JavaDoc msg = _rb.getString("vs.appsConfigError");
344             Object JavaDoc[] params = { getID() };
345             msg = MessageFormat.format(msg, params);
346             _logger.log(Level.SEVERE, msg, e);
347         }
348
349         if (appsBean != null) {
350             WebModule[] wmBeans = appsBean.getWebModule();
351             if (wmBeans != null && wmBeans.length > 0) {
352                 for (int i = 0; i < wmBeans.length; i++) {
353                     WebModule wm = wmBeans[i];
354                     if (isActive(wm)) {
355                         // skips if the web module is not referenced by
356
// this server
357
ApplicationRef ref =
358                             serverBean.getApplicationRefByRef(wm.getName());
359                         if (ref == null) {
360                             continue;
361                         }
362
363                         String JavaDoc location = wm.getLocation();
364                         // If module root is relative then prefix it with the
365
// location of where all the standalone modules for
366
// this server instance are deployed
367
File JavaDoc moduleBase = new File JavaDoc(location);
368                         if (!moduleBase.isAbsolute()) {
369                             location = modulesRoot+File.separator+location;
370                             wm.setLocation(location);
371                         }
372                         WebModuleConfig wmInfo = loadWebModuleConfig(wm);
373                         if (wmInfo != null)
374                             modules.add(wmInfo);
375                     } else {
376                         if (_debug) {
377                             _logger.finer("Web Module [" + wm.getName() +
378                                           "] is not applicable for virtual " +
379                                           " server [" + getID() + "]");
380                         }
381                     }
382                 }
383             }
384         }
385         return modules;
386     }
387
388     /**
389      * Loads and returns the configuration information associated with
390      * the web module that the user/configuration has designated to be the
391      * default web module for this virtual server.
392      *
393      * The default web module for a virtual server is specified via the
394      * 'default-web-module' attribute of the 'virtual-server' element in
395      * server.xml. This is an optional attribute and if the configuration
396      * does not specify another web module (standalone or part of a
397      * j2ee-application) that is configured at a context-root="", then
398      * a default web module will be created and loaded. The value for this
399      * attribute is either "${standalone-web-module-name}" or
400      * "${j2ee-app-name}:${web-module-uri}".
401      *
402      * @return null if the default-web-module has not been specified or
403      * if the web module specified either could not be found or
404      * is disabled or does not specify this virtual server (if
405      * it specifies a value for the virtual-servers attribute) or
406      * if there was an error loading its deployment descriptors.
407      */

408     protected WebModuleConfig getUserDefaultWebModuleConfig(Server serverBean) {
409
410         WebModuleConfig wmInfo = null;
411         Applications appsBean = null;
412         try{
413             appsBean = ServerBeansFactory.getApplicationsBean(serverBean.getConfigContext());
414         } catch (ConfigException e) {
415             String JavaDoc msg = _rb.getString("vs.appsConfigError");
416             Object JavaDoc[] params = { getID() };
417             msg = MessageFormat.format(msg, params);
418             _logger.log(Level.SEVERE, msg, e);
419         }
420
421         String JavaDoc wmID = getDefaultWebModuleID();
422         if (wmID != null) {
423             // Check if the default-web-module is part of a
424
// j2ee-application
425
wmInfo = findWebModuleInJ2eeApp(appsBean, wmID);
426
427             // Look up the list of standalone web modules
428
if (wmInfo == null) {
429                 WebModule wm = appsBean.getWebModuleByName(wmID);
430                 if (wm != null) {
431                     if (isActive(wm, false)) {
432                         // Create a copy as we need to change the name
433
// and context root to indicate that this web module
434
// is to be loaded as the 'default' web module for
435
// the virtual server
436
// WebModule wmCopy = (WebModule) wm.clone();
437
WebModule wmCopy = new WebModule();
438                         wmCopy.setName(wm.getName());
439                         wmCopy.setLocation(wm.getLocation());
440                         wmCopy.setEnabled(wm.isEnabled());
441                         wmCopy.setContextRoot(wm.getContextRoot());
442                         //wmCopy.setVirtualServers(_id);
443
wmInfo = loadWebModuleConfig(wmCopy);
444                         wmInfo.setVirtualServers(_id);
445                         wmCopy.setName(Constants.DEFAULT_WEB_MODULE_PREFIX +
446                                        wmCopy.getName());
447                         wmCopy.setContextRoot("");
448                         wmCopy.setObjectType(wm.getObjectType());
449                     } else {
450                         Object JavaDoc[] params = { wmID, getID() };
451                         _logger.log(Level.SEVERE, "vs.defaultWebModuleDisabled",
452                                     params);
453                         wm = null;
454                     }
455                 }
456             } else {
457                 WebModule wm = wmInfo.getBean();
458                 wmInfo.setVirtualServers(_id);
459                 wm.setName(Constants.DEFAULT_WEB_MODULE_PREFIX + wm.getName());
460                 wm.setContextRoot("");
461             }
462
463             if (wmInfo == null) {
464                 Object JavaDoc[] params = { wmID, getID() };
465                 _logger.log(Level.SEVERE, "vs.defaultWebModuleNotFound",
466                             params);
467             }
468         }
469         return wmInfo;
470     }
471
472     /**
473      * If a default web module has not yet been configured and added to this
474      * virtual server's list of web modules then return the configuration
475      * information needed in order to create a default web module for this
476      * virtual server.
477      *
478      * This method should be invoked only after all the standalone modules
479      * and the modules within j2ee-application elements have been added to
480      * this virtual server's list of modules (only then will one know whether
481      * the user has already configured a default web module or not).
482      */

483     protected WebModuleConfig createSystemDefaultWebModuleIfNecessary() {
484
485         WebModuleConfig wmInfo = null;
486         //
487
// Add a default context only if one hasn't already been loaded
488
// and then too only if docroot is not null
489
//
490
String JavaDoc docroot = getAppBase();
491         if ((findChild("") == null) && (docroot != null)) {
492             wmInfo = new WebModuleConfig();
493             WebModule wm = new WebModule();
494             wm.setName(Constants.DEFAULT_WEB_MODULE_NAME);
495             wm.setContextRoot("");
496             wm.setLocation(docroot);
497             wmInfo.setBean(wm);
498             
499             wmInfo.setDescriptor(DOLLoadingContextFactory.getDefaultWebBundleDescriptor());
500  
501             WebBundleDescriptor wbd = wmInfo.getDescriptor();
502             if ( wbd.getApplication() == null ) {
503                 Application application = new Application();
504                 application.setVirtual(true);
505                 application.setName(Constants.DEFAULT_WEB_MODULE_NAME);
506                 wbd.setApplication(application);
507             }
508              
509         }
510         return wmInfo;
511     }
512
513
514     /**
515      * Creates and returns an object that contains information about
516      * the web module's configuration such as the information specified
517      * in server.xml, the deployment descriptor objects etc.
518      *
519      * @return null if an error occured while reading/parsing the
520      * deployment descriptors.
521      */

522     protected WebModuleConfig loadWebModuleConfig(WebModule wm) {
523
524         WebModuleConfig wmInfo = new WebModuleConfig();
525         wmInfo.setBean(wm);
526         String JavaDoc wmID = wm.getName();
527         String JavaDoc location = wm.getLocation();
528         try {
529             WebModulesManager webModulesManager = new WebModulesManager(
530                 ApplicationServer.getServerContext().getInstanceEnvironment());
531         Application app = webModulesManager.getDescriptor(wmID, location);
532             WebBundleDescriptor wbd = (WebBundleDescriptor) app.getStandaloneBundleDescriptor();
533             wmInfo.setDescriptor(wbd);
534         } catch (ConfigException ce) {
535             wmInfo = null;
536             String JavaDoc msg = _rb.getString("vs.moduleConfigError");
537             Object JavaDoc[] params = { wmID, getID() };
538             msg = MessageFormat.format(msg, params);
539             _logger.log(Level.SEVERE, msg, ce);
540         }
541         return wmInfo;
542     }
543
544     /**
545      * Determines whether the specified web module is "active" under this
546      * virtual server.
547      */

548     private boolean isActive(WebModule wm) {
549         return isActive(wm, true);
550     }
551
552     /**
553      * Determines whether the specified web module is "active" under this
554      * virtual server.
555      *
556      * A web module is active if it meets ALL of the following conditions:
557      * - wm is not null
558      * - the enabled attribute of the web-module element is true
559      * If matchVSID is true then the following additional condition must be
560      * satisfied.
561      * - the virtual-servers attribute of the web-module element is either
562      * empty/not-specified or if specified then this virtual server's
563      * name/ID is one of the virtual servers specified in the list
564      *
565      * @param wm The bean containing the web module configuration
566      * information as specified in server.xml
567      * @param matchVSID This is set to false when testing to see if a
568      * web module that has been configured to be the
569      * default-web-module for a VS is active or not. In this
570      * case the only test is to check if the web module
571      * is enabled or not. When set to true, the virtual
572      * server list is examined to ensure that the web
573      * module has been configured to run on this virtual
574      * server.
575      * @return <code>true</code> if all the criteria are satisfied and
576      * <code>false</code> otherwise.
577      */

578     protected boolean isActive(WebModule wm, boolean matchVSID) {
579
580         String JavaDoc vsID = getID();
581
582         boolean active = ((vsID != null) && (vsID.length() > 0));
583         active &= (wm != null);
584
585         if (active) {
586             // Check if the web module is enabled
587
active &= wm.isEnabled();
588
589             //
590
// Check if vsID is one of the virtual servers specified
591
// in the list of virtual servers that the web module is to
592
// be loaded on. If the virtual-servers attribute of the
593
// <web-module> element is missing or empty then the implied
594
// behaviour is that the web module is active on every virtual
595
// server.
596
//
597
String JavaDoc vsIDs = getVirtualServers(wm.getName());
598
599             //
600
// fix for bug# 4913636
601
// so that for PE if the vsList is null and the virtual server is
602
// admin-vs then return false because we don't want to load user apps
603
// on admin-vs
604
//
605
if (getID().equals(WebContainer.ADMIN_VS) && matchVSID
606                                    && ((vsIDs == null) || (vsIDs.length() == 0 ))) {
607                 return false;
608             }
609
610
611             if ((vsIDs != null) && matchVSID) {
612                 List JavaDoc vsList = StringUtils.parseStringList(vsIDs, " ,");
613                 if (vsList != null)
614                     active &= vsList.contains(vsID.trim());
615                 else
616                     active &= true;
617             } else
618                 active &= true;
619         }
620         return active;
621     }
622
623     /**
624      * Returns the id of the default web module for this virtual server
625      * as specified in the 'default-web-module' attribute of the
626      * 'virtual-server' element.
627      *
628      * This is an optional attribute.
629      */

630     protected String JavaDoc getDefaultWebModuleID() {
631         String JavaDoc wmID = null;
632         
633         if (vsBean != null) {
634             wmID = vsBean.getDefaultWebModule();
635             if (wmID != null && _debug) {
636                 Object JavaDoc[] params = { wmID, _id };
637                 _logger.log(Level.FINE, "vs.defaultWebModule", params);
638             }
639         } else {
640             _logger.log(Level.SEVERE, "vs.configError", _id);
641         }
642
643         return wmID;
644     }
645
646     /**
647      * Finds and returns information about a web module embedded within a
648      * J2EE application, which is identified by a string of the form
649      * <code>a:b</code> or <code>a#b</code>, where <code>a</code> is the name
650      * of the J2EE application and <code>b</code> is the name of the embedded
651      * web module.
652      *
653      * @return null if <code>id</code> does not identify a web module embedded
654      * within a J2EE application.
655      */

656     protected WebModuleConfig findWebModuleInJ2eeApp(Applications appsBean,
657                                                    String JavaDoc id) {
658         WebModuleConfig wmInfo = null;
659
660         int length = id.length();
661         // Check for ':' separator
662
int separatorIndex = id.indexOf(Constants.NAME_SEPARATOR);
663         if (separatorIndex == -1) {
664             // Check for '#' separator
665
separatorIndex = id.indexOf('#');
666         }
667         if (separatorIndex != -1) {
668             String JavaDoc appID = id.substring(0, separatorIndex);
669             String JavaDoc moduleID = id.substring(separatorIndex + 1);
670             J2eeApplication j2eeApp = appsBean.getJ2eeApplicationByName(appID);
671             if ((j2eeApp != null) && j2eeApp.isEnabled()) {
672                 String JavaDoc location = j2eeApp.getLocation();
673                 String JavaDoc moduleDir = FileUtils.makeFriendlyFilename(moduleID);
674                 ApplicationRegistry registry =
675                     ApplicationRegistry.getInstance();
676                 ClassLoader JavaDoc appLoader =
677                     registry.getClassLoaderForApplication(appID);
678                 if (appLoader != null) {
679                     Application appDesc = registry.getApplication(appLoader);
680                     if (appDesc != null) {
681                         Set JavaDoc wbds = appDesc.getWebBundleDescriptors();
682                         WebBundleDescriptor wbd = null;
683                         for (Iterator JavaDoc itr = wbds.iterator(); itr.hasNext(); ) {
684                             wbd = (WebBundleDescriptor) itr.next();
685                             String JavaDoc webUri = wbd.getModuleDescriptor().getArchiveUri();
686                             if (moduleID.equals(webUri)) {
687                                 StringBuffer JavaDoc dir = new StringBuffer JavaDoc(location);
688                                 dir.append(File.separator);
689                                 dir.append(moduleDir);
690                                 WebModule wm = new WebModule();
691                                 wm.setName(moduleID);
692                                 wm.setContextRoot(wbd.getContextRoot());
693                                 wm.setLocation(dir.toString());
694                                 wm.setEnabled(true);
695                                 String JavaDoc vsList = getVirtualServers(j2eeApp.getName());
696                                 wmInfo = new WebModuleConfig();
697                                 wmInfo.setBean(wm);
698                                 wmInfo.setDescriptor(wbd);
699                                 wmInfo.setParentLoader(appLoader);
700                                 wmInfo.setVirtualServers(vsList);
701                                 break;
702                             }
703                         }
704                     }
705                 }
706             } else {
707                 Object JavaDoc[] params = { id, getID() };
708                 _logger.log(Level.SEVERE, "vs.defaultWebModuleDisabled",
709                             params);
710             }
711         }
712         return wmInfo;
713     }
714     
715     /**
716      * Virtual servers are maintained in the reference contained
717      * in Server element. First, we need to find the server
718      * and then get the virtual server from the correct reference
719      *
720      * @param appName Name of the app to get vs
721      *
722      * @return virtual servers as a string (separated by space or comma)
723      */

724     private String JavaDoc getVirtualServers(String JavaDoc appName) {
725         String JavaDoc ret = null;
726         try {
727             ConfigContext ctx =
728                 ApplicationServer.getServerContext().getConfigContext();
729             ret = ServerBeansFactory
730                     .getVirtualServersByAppName(ctx, appName);
731         } catch (ConfigException ce) {
732             _logger.log(Level.FINE, "Cannot get virtual server for " + appName, ce);
733         }
734         
735         return ret;
736     }
737     
738     
739     /**
740      * Delete all aliases.
741      */

742     public void clearAliases(){
743         aliases = new String JavaDoc[0];
744     }
745
746
747     void setIsDisabled(boolean isDisabled) {
748         ((VirtualServerPipeline) getPipeline()).setIsDisabled(isDisabled);
749     }
750
751
752     void setIsOff(boolean isOff) {
753         ((VirtualServerPipeline) getPipeline()).setIsOff(isOff);
754     }
755
756
757     /**
758      * Adds the given redirect instruction to this virtual server.
759      *
760      * @param from URI prefix to match
761      * @param url Redirect URL to return to the client
762      * @param urlPrefix New URL prefix to return to the client
763      * @param escape true if redirect URL returned to the client is to be
764      * escaped, false otherwise
765      */

766     void addRedirect(String JavaDoc from, String JavaDoc url, String JavaDoc urlPrefix,
767                      boolean escape) {
768
769         ((VirtualServerPipeline) getPipeline()).addRedirect(
770             from, url, urlPrefix, escape);
771     }
772     
773     
774     /**
775      * Set the Stat holder.
776      */

777     public void setPWCRequestStatsImpl(PWCRequestStatsImpl pwcRequestStatsImpl){
778         this.pwcRequestStatsImpl = pwcRequestStatsImpl;
779     }
780
781     
782     /**
783      * Get the Stat holder.
784      */

785     public PWCRequestStatsImpl getPWCRequestStatsImpl(){
786         return pwcRequestStatsImpl;
787     }
788 }
789
Popular Tags