/** * 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; }