/** * Returns the component. It creates a new one if none exists. * * @return The component. */ public Component getComponent() { Component result = this.component; if (result == null) { synchronized (ServerServlet.class) { if (result == null) { // Find the attribute name to use to store the component final String componentAttributeName = getInitParameter( NAME_COMPONENT_ATTRIBUTE, NAME_COMPONENT_ATTRIBUTE_DEFAULT); // Look up the attribute for a target result = (Component) getServletContext().getAttribute( componentAttributeName); if (result == null) { result = createComponent(); getServletContext().setAttribute( componentAttributeName, result); } } this.component = result; } } return result; }
final String serverAttributeName = getInitParameter( NAME_SERVER_ATTRIBUTE, NAME_SERVER_ATTRIBUTE_DEFAULT);
final String applicationAttributeName = getInitParameter( NAME_APPLICATION_ATTRIBUTE, NAME_APPLICATION_ATTRIBUTE_DEFAULT);
final String applicationClassName = getInitParameter(APPLICATION_KEY, null);
final String componentClassName = getInitParameter(COMPONENT_KEY, null); final String clientProtocolsString = getInitParameter(CLIENTS_KEY, null); if (clientProtocolsString != null) {
/** * Indicates if the Component hosted by this Servlet is the default one or * one provided by the user. * * @return True if the Component is the default one, false otherwise. */ private boolean isDefaultComponent() { // The Component is provided via an XML configuration file. Client client = createWarClient(new Context(), getServletConfig()); Response response = client.get("war:///WEB-INF/restlet.xml"); if (response.getStatus().isSuccess() && response.isEntityAvailable()) { return false; } // The Component is provided via a context parameter in the "web.xml" // file. final String componentAttributeName = getInitParameter(COMPONENT_KEY, null); if (componentAttributeName != null) { return false; } return true; }
final String autoWire = getInitParameter(AUTO_WIRE_KEY, AUTO_WIRE_KEY_DEFAULT); if (AUTO_WIRE_KEY_DEFAULT.equalsIgnoreCase(autoWire)) {