http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java index ed1ffab..71aa768 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionCachingFilter.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.filter; @@ -36,51 +34,48 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; /** - * Primary class which orchestrates everything. This is the class which gets - * configured in the web.xml. + * Primary class which orchestrates everything. This is the class which gets configured in the + * web.xml. */ public class SessionCachingFilter implements Filter { /** * Logger instance */ - private static final Logger LOG = - LoggerFactory.getLogger(SessionCachingFilter.class.getName()); + private static final Logger LOG = LoggerFactory.getLogger(SessionCachingFilter.class.getName()); /** - * The filter configuration object we are associated with. If this value is - * null, this filter instance is not currently configured. + * The filter configuration object we are associated with. If this value is null, this filter + * instance is not currently configured. */ private FilterConfig filterConfig = null; /** - * Some containers will want to instantiate multiple instances of this filter, - * but we only need one SessionManager + * Some containers will want to instantiate multiple instances of this filter, but we only need + * one SessionManager */ private static SessionManager manager = null; /** * Can be overridden during testing. */ - private static AtomicInteger started = - new AtomicInteger( - Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "override.session.manager.count", 1)); + private static AtomicInteger started = new AtomicInteger( + Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "override.session.manager.count", 1)); - private static int percentInactiveTimeTriggerRebuild = - Integer.getInteger(DistributionConfig.GEMFIRE_PREFIX + "session.inactive.trigger.rebuild", 80); + private static int percentInactiveTimeTriggerRebuild = Integer + .getInteger(DistributionConfig.GEMFIRE_PREFIX + "session.inactive.trigger.rebuild", 80); /** - * This latch ensures that at least one thread/instance has fired up the - * session manager before any other threads complete the init method. + * This latch ensures that at least one thread/instance has fired up the session manager before + * any other threads complete the init method. */ private static CountDownLatch startingLatch = new CountDownLatch(1); /** - * This request wrapper class extends the support class - * HttpServletRequestWrapper, which implements all the methods in the - * HttpServletRequest interface, as delegations to the wrapped request. You - * only need to override the methods that you need to change. You can get - * access to the wrapped request using the method getRequest() + * This request wrapper class extends the support class HttpServletRequestWrapper, which + * implements all the methods in the HttpServletRequest interface, as delegations to the wrapped + * request. You only need to override the methods that you need to change. You can get access to + * the wrapped request using the method getRequest() */ public static class RequestWrapper extends HttpServletRequestWrapper { @@ -105,8 +100,7 @@ public class SessionCachingFilter implements Filter { */ private HttpServletRequest originalRequest; - public RequestWrapper(SessionManager manager, - HttpServletRequest request, + public RequestWrapper(SessionManager manager, HttpServletRequest request, ResponseWrapper response) { super(request); @@ -117,14 +111,12 @@ public class SessionCachingFilter implements Filter { final Cookie[] cookies = request.getCookies(); if (cookies != null) { for (final Cookie cookie : cookies) { - if (cookie.getName().equalsIgnoreCase( - manager.getSessionCookieName()) && - cookie.getValue().endsWith("-GF")) { + if (cookie.getName().equalsIgnoreCase(manager.getSessionCookieName()) + && cookie.getValue().endsWith("-GF")) { requestedSessionId = cookie.getValue(); sessionFromCookie = true; - LOG.debug("Cookie contains sessionId: {}", - requestedSessionId); + LOG.debug("Cookie contains sessionId: {}", requestedSessionId); } } } @@ -156,16 +148,16 @@ public class SessionCachingFilter implements Filter { if (session != null && session.isValid()) { session.setIsNew(false); session.updateAccessTime(); - /* - * This is a massively gross hack. Currently, there is no way - * to actually update the last accessed time for a session, so - * what we do here is once we're into X% of the session's TTL - * we grab a new session from the container. - * - * (inactive * 1000) * (pct / 100) ==> (inactive * 10 * pct) - */ - if (session.getLastAccessedTime() - session.getCreationTime() > - (session.getMaxInactiveInterval() * 10 * percentInactiveTimeTriggerRebuild)) { + /* + * This is a massively gross hack. Currently, there is no way to actually update the last + * accessed time for a session, so what we do here is once we're into X% of the session's + * TTL we grab a new session from the container. + * + * (inactive * 1000) * (pct / 100) ==> (inactive * 10 * pct) + */ + if (session.getLastAccessedTime() + - session.getCreationTime() > (session.getMaxInactiveInterval() * 10 + * percentInactiveTimeTriggerRebuild)) { HttpSession nativeSession = super.getSession(); session.failoverSession(nativeSession); } @@ -173,8 +165,7 @@ public class SessionCachingFilter implements Filter { } if (requestedSessionId != null) { - session = (GemfireHttpSession) manager.getSession( - requestedSessionId); + session = (GemfireHttpSession) manager.getSession(requestedSessionId); if (session != null) { session.setIsNew(false); // This means we've failed over to another node @@ -231,8 +222,7 @@ public class SessionCachingFilter implements Filter { // Get the existing cookies Cookie[] cookies = getCookies(); - Cookie cookie = new Cookie(manager.getSessionCookieName(), - session.getId()); + Cookie cookie = new Cookie(manager.getSessionCookieName(), session.getId()); cookie.setPath("".equals(getContextPath()) ? "/" : getContextPath()); // Clear out all old cookies and just set ours response.addCookie(cookie); @@ -296,16 +286,14 @@ public class SessionCachingFilter implements Filter { } } - /* - * Hmmm... not sure if this is right or even good to do. So, in some - * cases - for ex. using a Spring security filter, we have 3 possible - * wrappers to deal with - the original, this one and one created by - * Spring. When a servlet or JSP is forwarded to the original request - * is passed in, but then this (the wrapped) request is used by the JSP. - * In some cases, the outer wrapper also contains information relevant - * to the request - in this case security info. So here we allow access - * to that. There's probably a better way.... - */ + /* + * Hmmm... not sure if this is right or even good to do. So, in some cases - for ex. using a + * Spring security filter, we have 3 possible wrappers to deal with - the original, this one and + * one created by Spring. When a servlet or JSP is forwarded to the original request is passed + * in, but then this (the wrapped) request is used by the JSP. In some cases, the outer wrapper + * also contains information relevant to the request - in this case security info. So here we + * allow access to that. There's probably a better way.... + */ /** * {@inheritDoc} @@ -370,11 +358,10 @@ public class SessionCachingFilter implements Filter { } /** - * This response wrapper class extends the support class - * HttpServletResponseWrapper, which implements all the methods in the - * HttpServletResponse interface, as delegations to the wrapped response. You - * only need to override the methods that you need to change. You can get - * access to the wrapped response using the method getResponse() + * This response wrapper class extends the support class HttpServletResponseWrapper, which + * implements all the methods in the HttpServletResponse interface, as delegations to the wrapped + * response. You only need to override the methods that you need to change. You can get access to + * the wrapped response using the method getResponse() */ class ResponseWrapper extends HttpServletResponseWrapper { @@ -401,27 +388,25 @@ public class SessionCachingFilter implements Filter { } - public SessionCachingFilter() { - } + public SessionCachingFilter() {} /** - * @param request The servlet request we are processing + * @param request The servlet request we are processing * @param response The servlet response we are creating - * @param chain The filter chain we are processing - * @throws IOException if an input/output error occurs + * @param chain The filter chain we are processing + * @throws IOException if an input/output error occurs * @throws ServletException if a servlet error occurs */ @Override - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest) request; HttpServletResponse httpResp = (HttpServletResponse) response; /** - * Early out if this isn't the right kind of request. We might see a - * RequestWrapper instance during a forward or include request. + * Early out if this isn't the right kind of request. We might see a RequestWrapper instance + * during a forward or include request. */ if (alreadyWrapped(httpReq)) { LOG.debug("Handling already-wrapped request"); @@ -439,8 +424,7 @@ public class SessionCachingFilter implements Filter { // include requests. ResponseWrapper wrappedResponse = new ResponseWrapper(httpResp); - final RequestWrapper wrappedRequest = - new RequestWrapper(manager, httpReq, wrappedResponse); + final RequestWrapper wrappedRequest = new RequestWrapper(manager, httpReq, wrappedResponse); Throwable problem = null; @@ -454,8 +438,7 @@ public class SessionCachingFilter implements Filter { LOG.error("Exception processing filter chain", t); } - GemfireHttpSession session = - (GemfireHttpSession) wrappedRequest.getSession(false); + GemfireHttpSession session = (GemfireHttpSession) wrappedRequest.getSession(false); // If there was a problem, we want to rethrow it if it is // a known type, otherwise log it. @@ -470,8 +453,8 @@ public class SessionCachingFilter implements Filter { } /** - * Commit any updates. What actually happens at that point is - * dependent on the type of attributes defined for use by the sessions. + * Commit any updates. What actually happens at that point is dependent on the type of + * attributes defined for use by the sessions. */ if (session != null) { session.commit(); @@ -479,21 +462,21 @@ public class SessionCachingFilter implements Filter { } /** - * Test if a request has been wrapped with RequestWrapper somewhere - * in the chain of wrapped requests. + * Test if a request has been wrapped with RequestWrapper somewhere in the chain of wrapped + * requests. */ private boolean alreadyWrapped(final ServletRequest request) { - if(request instanceof RequestWrapper) { + if (request instanceof RequestWrapper) { return true; } - if(!(request instanceof ServletRequestWrapper)) { + if (!(request instanceof ServletRequestWrapper)) { return false; } final ServletRequest nestedRequest = ((ServletRequestWrapper) request).getRequest(); - if(nestedRequest == request) { + if (nestedRequest == request) { return false; } @@ -541,8 +524,7 @@ public class SessionCachingFilter implements Filter { /** * Allow override for testing purposes */ - String managerClassStr = - config.getInitParameter("session-manager-class"); + String managerClassStr = config.getInitParameter("session-manager-class"); // Otherwise default if (managerClassStr == null) { @@ -550,8 +532,7 @@ public class SessionCachingFilter implements Filter { } try { - manager = (SessionManager) Class.forName( - managerClassStr).newInstance(); + manager = (SessionManager) Class.forName(managerClassStr).newInstance(); manager.start(config, this.getClass().getClassLoader()); } catch (Exception ex) { LOG.error("Exception creating Session Manager", ex); @@ -564,8 +545,7 @@ public class SessionCachingFilter implements Filter { } catch (InterruptedException iex) { } - LOG.debug("SessionManager and listener initialization skipped - " - + "already done."); + LOG.debug("SessionManager and listener initialization skipped - " + "already done."); } LOG.info("Session Filter initialization complete"); @@ -596,13 +576,12 @@ public class SessionCachingFilter implements Filter { response.setContentType("text/html"); PrintStream ps = new PrintStream(response.getOutputStream()); PrintWriter pw = new PrintWriter(ps); - pw.print( - "<html>\n<head>\n<title>Error</title>\n</head>\n<body>\n"); //NOI18N + pw.print("<html>\n<head>\n<title>Error</title>\n</head>\n<body>\n"); // NOI18N // PENDING! Localize this for next official release pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n"); pw.print(stackTrace); - pw.print("</pre></body>\n</html>"); //NOI18N + pw.print("</pre></body>\n</html>"); // NOI18N pw.close(); ps.close(); response.getOutputStream().close(); @@ -634,8 +613,7 @@ public class SessionCachingFilter implements Filter { } /** - * Retrieve the SessionManager. This is only here so that tests can get access - * to the cache. + * Retrieve the SessionManager. This is only here so that tests can get access to the cache. */ public static SessionManager getSessionManager() { return manager; @@ -644,16 +622,15 @@ public class SessionCachingFilter implements Filter { /** * Return the GemFire session which wraps a native session * - * @param nativeSession the native session for which the corresponding GemFire - * session should be returned. - * @return the GemFire session or null if no session maps to the native - * session + * @param nativeSession the native session for which the corresponding GemFire session should be + * returned. + * @return the GemFire session or null if no session maps to the native session */ public static HttpSession getWrappingSession(HttpSession nativeSession) { - /* - * This is a special case where the GemFire session has been set as a - * ThreadLocal during session creation. - */ + /* + * This is a special case where the GemFire session has been set as a ThreadLocal during session + * creation. + */ GemfireHttpSession gemfireSession = (GemfireHttpSession) ThreadLocalSession.get(); if (gemfireSession != null) { gemfireSession.setNativeSession(nativeSession);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionListener.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionListener.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionListener.java index 929740b..157566d 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionListener.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/filter/SessionListener.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.filter; @@ -26,11 +24,9 @@ import javax.servlet.http.HttpSessionListener; public class SessionListener implements HttpSessionListener { - private static final Logger LOG = - LoggerFactory.getLogger(SessionListener.class.getName()); + private static final Logger LOG = LoggerFactory.getLogger(SessionListener.class.getName()); - public void sessionCreated(HttpSessionEvent httpSessionEvent) { - } + public void sessionCreated(HttpSessionEvent httpSessionEvent) {} /** * This will receive events from the container using the native sessions. @@ -38,14 +34,11 @@ public class SessionListener implements HttpSessionListener { public void sessionDestroyed(HttpSessionEvent event) { String nativeId = event.getSession().getId(); try { - String sessionId = SessionCachingFilter.getSessionManager().destroyNativeSession( - nativeId); - LOG.debug( - "Received sessionDestroyed event for native session {} (wrapped by {})", - nativeId, sessionId); + String sessionId = SessionCachingFilter.getSessionManager().destroyNativeSession(nativeId); + LOG.debug("Received sessionDestroyed event for native session {} (wrapped by {})", nativeId, + sessionId); } catch (DistributedSystemDisconnectedException dex) { - LOG.debug("Cache disconnected - unable to destroy native session {0}", - nativeId); + LOG.debug("Cache disconnected - unable to destroy native session {0}", nativeId); } } } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/Installer.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/Installer.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/Installer.java index 2343c5b..b2d0bd0 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/Installer.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/Installer.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer; @@ -53,25 +51,19 @@ public class Installer { private ArgumentValues argValues; private static final Argument ARG_HELP = - new Argument("-h", false). - setDescription("Displays this help message."); - - private static Argument ARG_GEMFIRE_PARAMETERS = - new Argument("-p", false, "param=value"). - setDescription("Specific parameter for inclusion into the " - + "session filter definition as a regular " - + "init-param. Can be given multiple times."); - - private static Argument ARG_CACHE_TYPE = - new Argument("-t", false, "cache-type"). - setDescription( - "Type of cache. Must be one of 'peer-to-peer' or " - + "'client-server'. Default is peer-to-peer."). - setDefaults("peer-to-peer"); + new Argument("-h", false).setDescription("Displays this help message."); + + private static Argument ARG_GEMFIRE_PARAMETERS = new Argument("-p", false, "param=value") + .setDescription("Specific parameter for inclusion into the " + + "session filter definition as a regular " + "init-param. Can be given multiple times."); + + private static Argument ARG_CACHE_TYPE = new Argument("-t", false, "cache-type") + .setDescription("Type of cache. Must be one of 'peer-to-peer' or " + + "'client-server'. Default is peer-to-peer.") + .setDefaults("peer-to-peer"); private static Argument ARG_WEB_XML_FILE = - new Argument("-w", true, "web.xml file"). - setDescription("The web.xml file to be modified."); + new Argument("-w", true, "web.xml file").setDescription("The web.xml file to be modified."); /** @@ -102,18 +94,15 @@ public class Installer { processor.setUnknownArgumentHandler(new UnknownArgumentHandler() { @Override - public void handleUnknownArgument( - final String form, final String[] params) { - log("Unknown argument being ignored: " - + form + " (" + params.length + " params)"); + public void handleUnknownArgument(final String form, final String[] params) { + log("Unknown argument being ignored: " + form + " (" + params.length + " params)"); log("Use '-h' argument to display usage"); } }); argValues = processor.process(args); if (argValues.isDefined(ARG_HELP)) { - final UsageException usageException = - new UsageException("Usage requested by user"); + final UsageException usageException = new UsageException("Usage requested by user"); usageException.setUsage(processor.getUsage()); throw (usageException); } @@ -151,8 +140,7 @@ public class Installer { } - public void processWebXml(final InputStream webXml, - final OutputStream out) throws Exception { + public void processWebXml(final InputStream webXml, final OutputStream out) throws Exception { Document doc = createWebXmlDoc(webXml); mangleWebXml(doc); @@ -161,11 +149,9 @@ public class Installer { } - private Document createWebXmlDoc(final InputStream webXml) - throws Exception { + private Document createWebXmlDoc(final InputStream webXml) throws Exception { Document doc; - final DocumentBuilderFactory factory = - DocumentBuilderFactory.newInstance(); + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); final DocumentBuilder builder = factory.newDocumentBuilder(); doc = builder.parse(webXml); @@ -205,8 +191,7 @@ public class Installer { // Set the type of cache initParam = append(doc, filter, "init-param", null); append(doc, initParam, "param-name", "cache-type"); - append(doc, initParam, "param-value", - argValues.getFirstResult(ARG_CACHE_TYPE)); + append(doc, initParam, "param-value", argValues.getFirstResult(ARG_CACHE_TYPE)); if (argValues.isDefined(ARG_GEMFIRE_PARAMETERS)) { @@ -235,8 +220,7 @@ public class Installer { final Element contextListener = doc.createElement("listener"); append(doc, contextListener, "listener-class", GEMFIRE_LISTENER_CLASS); docElement.insertBefore(filterMapping, after(docElement, "filter")); - docElement.insertBefore(contextListener, - after(docElement, "filter-mapping")); + docElement.insertBefore(contextListener, after(docElement, "filter-mapping")); return doc; } @@ -258,8 +242,7 @@ public class Installer { return null; } - private Node append(final Document doc, final Node parent, - final String element, + private Node append(final Document doc, final Node parent, final String element, final String value) { final Element child = doc.createElement(element); if (value != null) @@ -279,8 +262,7 @@ public class Installer { transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, systemId); } transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", - "4"); + transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); final DOMSource source = new DOMSource(doc); final StreamResult result = new StreamResult(out); transformer.transform(source, result); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/JarClassLoader.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/JarClassLoader.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/JarClassLoader.java index 4ddb278..5a27378 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/JarClassLoader.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/JarClassLoader.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer; @@ -30,8 +28,8 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; /** - * Classloader, which allows finding classes in jars within jars. This is used to check - * whether a listener, as found in web.xml, is a ServletContextListener + * Classloader, which allows finding classes in jars within jars. This is used to check whether a + * listener, as found in web.xml, is a ServletContextListener */ @SuppressWarnings("deprecation") public class JarClassLoader extends URLClassLoader { @@ -90,21 +88,18 @@ public class JarClassLoader extends URLClassLoader { } private static boolean isJar(String fileName) { - return fileName != null && (fileName.toLowerCase().endsWith(".jar") || - fileName.toLowerCase().endsWith(".war") || - fileName.toLowerCase().endsWith(".ear")); + return fileName != null && (fileName.toLowerCase().endsWith(".jar") + || fileName.toLowerCase().endsWith(".war") || fileName.toLowerCase().endsWith(".ear")); } - private static File jarEntryAsFile(JarFile jarFile, - JarEntry jarEntry) throws IOException { + private static File jarEntryAsFile(JarFile jarFile, JarEntry jarEntry) throws IOException { InputStream input = null; OutputStream output = null; try { String name = jarEntry.getName().replace('/', '_'); int i = name.lastIndexOf("."); String extension = i > -1 ? name.substring(i) : ""; - File file = File.createTempFile( - name.substring(0, name.length() - extension.length()) + ".", + File file = File.createTempFile(name.substring(0, name.length() - extension.length()) + ".", extension); file.deleteOnExit(); input = jarFile.getInputStream(jarEntry); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/Argument.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/Argument.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/Argument.java index 82ed232..53a6f77 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/Argument.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/Argument.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer.args; @@ -36,9 +34,8 @@ public class Argument { private String[] defaults; /** - * Environment variable names forfor each parameter where values will be - * pulled in, if not explicitly provided and if the environment variable - * exists. + * Environment variable names forfor each parameter where values will be pulled in, if not + * explicitly provided and if the environment variable exists. */ private String[] envVars; @@ -68,16 +65,12 @@ public class Argument { /** * Contructor to create an argument definition. * - * @param primaryForm the form of the argument (e.g., --foo). Should start - * with a dash. - * @param argRequired flag indicating whether or not the argument is - * required to be onthe command line - * @param parameterNames names of the parameters to this argument for use in - * the usage generation + * @param primaryForm the form of the argument (e.g., --foo). Should start with a dash. + * @param argRequired flag indicating whether or not the argument is required to be onthe command + * line + * @param parameterNames names of the parameters to this argument for use in the usage generation */ - public Argument( - final String primaryForm, - final boolean argRequired, + public Argument(final String primaryForm, final boolean argRequired, final String... parameterNames) { forms.add(primaryForm); paramNames = parameterNames; @@ -225,8 +218,8 @@ public class Argument { } /** - * Sets the environment variables which will be checked for values before - * falling back on the default values. + * Sets the environment variables which will be checked for values before falling back on the + * default values. * * @param newEnvVars environment variable name array * @return this argument (for chained calls) @@ -234,8 +227,7 @@ public class Argument { public Argument setEnvVars(final String... newEnvVars) { if (newEnvVars.length != paramNames.length) { throw (new IllegalArgumentException( - "Environment variables array length provided is not " - + "the correct size")); + "Environment variables array length provided is not " + "the correct size")); } envVars = newEnvVars; return this; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentHandler.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentHandler.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentHandler.java index 28887d8..f9d457a 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentHandler.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentHandler.java @@ -1,38 +1,35 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer.args; /** - * Interface specifying the requirements for objects wiching to be able to - * examine arguments (potentially tweaking parameters) at the time of parsing, - * thereby allowing for usage display to occur automatically. + * Interface specifying the requirements for objects wiching to be able to examine arguments + * (potentially tweaking parameters) at the time of parsing, thereby allowing for usage display to + * occur automatically. */ public interface ArgumentHandler { /** * Process the argument values specified. * - * @param arg argument definition - * @param form form which was used on the command line + * @param arg argument definition + * @param form form which was used on the command line * @param params parameters supplied to the argument * @throws UsageException when usage was suboptimal */ - void handleArgument(Argument arg, String form, String[] params) - throws UsageException; + void handleArgument(Argument arg, String form, String[] params) throws UsageException; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentProcessor.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentProcessor.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentProcessor.java index 4ed3061..43df4ac 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentProcessor.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentProcessor.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer.args; @@ -22,15 +20,14 @@ import java.util.List; import java.util.logging.Logger; /** - * This class is used to process command line arguments for Java programs in a - * flexible and powerful manner. + * This class is used to process command line arguments for Java programs in a flexible and powerful + * manner. */ public class ArgumentProcessor { /** * Logger. */ - private static final Logger LOG = - Logger.getLogger(ArgumentProcessor.class.getName()); + private static final Logger LOG = Logger.getLogger(ArgumentProcessor.class.getName()); /** * Description line length. @@ -78,12 +75,10 @@ public class ArgumentProcessor { * Constructor. * * @param theArgument the argument which matched - * @param theForm the form used - * @param theParams the parameters supplied + * @param theForm the form used + * @param theParams the parameters supplied */ - public Match( - final Argument theArgument, - final String theForm, final String[] theParams) { + public Match(final Argument theArgument, final String theForm, final String[] theParams) { arg = theArgument; form = theForm; params = theParams; @@ -147,8 +142,7 @@ public class ArgumentProcessor { * * @param aHandler unknown arg handler, or null to unset */ - public void setUnknownArgumentHandler( - final UnknownArgumentHandler aHandler) { + public void setUnknownArgumentHandler(final UnknownArgumentHandler aHandler) { handler = aHandler; } @@ -159,8 +153,7 @@ public class ArgumentProcessor { * @return argument values parsed out of command line * @throws UsageException when usge sucked */ - public ArgumentValues process(final String[] programArgs) - throws UsageException { + public ArgumentValues process(final String[] programArgs) throws UsageException { ArgumentHandler argHandler; final ArgumentValues result = new ArgumentValues(); List<Argument> unmatched; @@ -179,8 +172,8 @@ public class ArgumentProcessor { // Error on unmatched yet required args for (Argument arg : unmatched) { if (arg.isRequired() && !arg.isDefinedInEnv()) { - final UsageException usageException = new UsageException( - "Required argument not provided: " + arg); + final UsageException usageException = + new UsageException("Required argument not provided: " + arg); usageException.setUsage(getUsage()); throw usageException; } @@ -191,8 +184,7 @@ public class ArgumentProcessor { final Argument arg = match.getArgument(); argHandler = arg.getArgumentHandler(); if (argHandler != null) { - argHandler.handleArgument( - arg, match.getForm(), match.getParams()); + argHandler.handleArgument(arg, match.getForm(), match.getParams()); } result.addResult(arg, match.getParams()); } @@ -234,8 +226,7 @@ public class ArgumentProcessor { builder.append("\n"); } - descriptionLines = - breakupString(arg.getDescription(), LINE_LENGTH); + descriptionLines = breakupString(arg.getDescription(), LINE_LENGTH); if (descriptionLines.isEmpty()) { builder.append(blank20); builder.append("No argument description provided."); @@ -263,12 +254,11 @@ public class ArgumentProcessor { * Builds a listof all argument matches and sets the postArgs array. * * @param programArgs command line arguments to search through - * @param values values object in which to store results + * @param values values object in which to store results * @return list of matches * @throws UsageException when there is EBKAC */ - private List<Match> checkMatches( - final String[] programArgs, final ArgumentValues values) + private List<Match> checkMatches(final String[] programArgs, final ArgumentValues values) throws UsageException { final List<Match> result = new ArrayList<Match>(); Match match; @@ -282,8 +272,7 @@ public class ArgumentProcessor { if ("--".equals(programArgs[idx])) { if (++idx < programArgs.length) { postArgs = new String[programArgs.length - idx]; - System.arraycopy(programArgs, idx, - postArgs, 0, postArgs.length); + System.arraycopy(programArgs, idx, postArgs, 0, postArgs.length); values.setPostArgs(postArgs); } // We're done processing args' @@ -292,8 +281,7 @@ public class ArgumentProcessor { // Determine parameter count idx2 = idx; - while ((idx2 + 1) < programArgs.length - && programArgs[idx2 + 1].charAt(0) != '-') { + while ((idx2 + 1) < programArgs.length && programArgs[idx2 + 1].charAt(0) != '-') { idx2++; } @@ -319,8 +307,7 @@ public class ArgumentProcessor { if (match == null) { if (handler == null) { final UsageException usageException = new UsageException( - "Unknown argument: " + programArgs[idx] - + " with " + params.length + " parameters."); + "Unknown argument: " + programArgs[idx] + " with " + params.length + " parameters."); usageException.setUsage(getUsage()); throw (usageException); } else { @@ -338,17 +325,14 @@ public class ArgumentProcessor { * Checks to see if an rgument form matches the suppies parameter list. * * @param argName argument name - * @param arg argument - * @param params parameters supplied + * @param arg argument + * @param params parameters supplied * @return match object on match, null otherwise */ - private Match checkMatch( - final String argName, final Argument arg, final String[] params) { + private Match checkMatch(final String argName, final Argument arg, final String[] params) { // Look for a matching form for (String form : arg.getForms()) { - if ( - form.equals(argName) - && arg.getParameterCount() == params.length) { + if (form.equals(argName) && arg.getParameterCount() == params.length) { return new Match(arg, form, params); } } @@ -357,15 +341,14 @@ public class ArgumentProcessor { } /** - * Breaks up a string into sub-strings, each with a length equal to or less - * than the max length specified. + * Breaks up a string into sub-strings, each with a length equal to or less than the max length + * specified. * - * @param str string to break up + * @param str string to break up * @param maxLength maximum line length to use * @return broken up string */ - private List<String> breakupString( - final String str, final int maxLength) { + private List<String> breakupString(final String str, final int maxLength) { final List<String> result = new ArrayList<String>(); int startIdx = -1; int lastIdx; @@ -380,8 +363,7 @@ public class ArgumentProcessor { do { lastIdx = idx; idx = str.indexOf(' ', lastIdx + 1); - LOG.fine("startIdx=" + startIdx + " lastIdx=" + lastIdx - + " idx=" + idx); + LOG.fine("startIdx=" + startIdx + " lastIdx=" + lastIdx + " idx=" + idx); if (idx < 0) { // Canot break line up any further result.add(str.substring(startIdx + 1)); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentValues.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentValues.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentValues.java index 22ab124..2c8a1b5 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentValues.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/ArgumentValues.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer.args; @@ -31,7 +29,7 @@ public class ArgumentValues { /** * Storage location for all arguments found after the "--" pseudo-arg. */ - private String[] postArgs = new String[]{}; + private String[] postArgs = new String[] {}; /** * Storage location for the command line argument values. @@ -56,9 +54,9 @@ public class ArgumentValues { } /** - * After processing the command line arguments, this method may be used to - * return all arguments which were excluded from processing by their placement - * after the "<code>--</code>" psuedo-argument. + * After processing the command line arguments, this method may be used to return all arguments + * which were excluded from processing by their placement after the "<code>--</code>" + * psuedo-argument. * * @return all unprocess arguments */ @@ -69,7 +67,7 @@ public class ArgumentValues { /** * Sets the data values found for a specific argument. * - * @param arg argument + * @param arg argument * @param paramValues parameter values for the argument */ public void addResult(final Argument arg, final String[] paramValues) { @@ -93,11 +91,9 @@ public class ArgumentValues { } /** - * Counts the number of arguments defined on the command line which are in the - * list provided. + * Counts the number of arguments defined on the command line which are in the list provided. * - * @param ofThese the arguments to search for, or null to count all supplied - * arguments + * @param ofThese the arguments to search for, or null to count all supplied arguments * @return count of the defined arguments */ public int getDefinedCount(Argument... ofThese) { @@ -119,12 +115,10 @@ public class ArgumentValues { } /** - * Returns whetheror not the command line argument was actually provided on - * the command line. + * Returns whetheror not the command line argument was actually provided on the command line. * * @param arg argument to query - * @return true if the argument is defined by the command line, false - * otherwise + * @return true if the argument is defined by the command line, false otherwise */ public boolean isDefined(final Argument arg) { final List<String[]> result = values.get(arg); @@ -132,8 +126,8 @@ public class ArgumentValues { } /** - * Returns all results for the specified argument. If a command line option - * is specified more than once, this is the method to use to get all values. + * Returns all results for the specified argument. If a command line option is specified more than + * once, this is the method to use to get all values. * * @param arg argument to query * @return list of all parameter lists defined for this argument @@ -169,8 +163,7 @@ public class ArgumentValues { } /** - * Convenience method to retrieve the first instance of the command line - * argument's values. + * Convenience method to retrieve the first instance of the command line argument's values. * * @param arg argument to query * @return first parameter list defined for this argument @@ -185,8 +178,8 @@ public class ArgumentValues { } /** - * Convenience method to return the first value of the first instance of the - * command line argument values for the specified argument. + * Convenience method to return the first value of the first instance of the command line argument + * values for the specified argument. * * @param arg argument to query * @return first parameter of the first list of parameters supplied @@ -201,16 +194,13 @@ public class ArgumentValues { } /** - * Convenience method to return the result of getFirstResult method as an - * integer. + * Convenience method to return the result of getFirstResult method as an integer. * - * @param arg argument to query - * @param undefinedValue value to return when argument is not defined or is - * illegally defined + * @param arg argument to query + * @param undefinedValue value to return when argument is not defined or is illegally defined * @return value specified, or default value provided */ - public int getFirstResultAsInt( - final Argument arg, final int undefinedValue) { + public int getFirstResultAsInt(final Argument arg, final int undefinedValue) { final String value = getFirstResult(arg); if (value == null) { return undefinedValue; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/URLArgumentHandler.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/URLArgumentHandler.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/URLArgumentHandler.java index 78082ce..313f469 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/URLArgumentHandler.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/URLArgumentHandler.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer.args; @@ -24,31 +22,26 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Argument handler implementation which accepts file paths or URLs and - * normalizes the parameters to URLs. + * Argument handler implementation which accepts file paths or URLs and normalizes the parameters to + * URLs. */ public class URLArgumentHandler implements ArgumentHandler { /** * Logger. */ - private static final Logger LOG = - Logger.getLogger(URLArgumentHandler.class.getName()); + private static final Logger LOG = Logger.getLogger(URLArgumentHandler.class.getName()); /** - * Ensure that the argument is either a file path or a properly formatted URL. - * If it is a file path, convert to a URL. If neither, throws a - * UsageException. + * Ensure that the argument is either a file path or a properly formatted URL. If it is a file + * path, convert to a URL. If neither, throws a UsageException. * - * @param arg argument - * @param form form used + * @param arg argument + * @param form form used * @param parameters parameters supplied * @throws UsageException when file not found or not a workable URL */ - public void handleArgument( - final Argument arg, - final String form, - final String[] parameters) + public void handleArgument(final Argument arg, final String form, final String[] parameters) throws UsageException { final File file = new File(parameters[0]); URL result = null; @@ -69,8 +62,7 @@ public class URLArgumentHandler implements ArgumentHandler { } if (result == null) { throw (new UsageException( - "Argument parameter value is not a valid file " - + "path or URL: " + arg)); + "Argument parameter value is not a valid file " + "path or URL: " + arg)); } parameters[0] = result.toString(); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UnknownArgumentHandler.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UnknownArgumentHandler.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UnknownArgumentHandler.java index 968a008..251aee4 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UnknownArgumentHandler.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UnknownArgumentHandler.java @@ -1,36 +1,33 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.modules.session.installer.args; /** - * Interface defining unknown argument handlers, given the opportunity to either - * ignore the issue or force the parameter to be dealt with. + * Interface defining unknown argument handlers, given the opportunity to either ignore the issue or + * force the parameter to be dealt with. */ public interface UnknownArgumentHandler { /** * Called when an unknown argument is supplied. * - * @param form argument name used + * @param form argument name used * @param params parameters passed into it * @throws UsageException when the user needs to fix it */ - void handleUnknownArgument(String form, String[] params) - throws UsageException; + void handleUnknownArgument(String form, String[] params) throws UsageException; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UsageException.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UsageException.java b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UsageException.java index 21dc9c3..cafacda 100644 --- a/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UsageException.java +++ b/extensions/geode-modules-session/src/main/java/org/apache/geode/modules/session/installer/args/UsageException.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer.args; @@ -52,7 +50,7 @@ public class UsageException extends Exception { * Creates a new UsageException. * * @param message description of exceptional condition - * @param cause provoking exception + * @param cause provoking exception */ public UsageException(final String message, final Throwable cause) { super(message, cause); @@ -71,8 +69,8 @@ public class UsageException extends Exception { /** * Attaches a usage message to the exception for later consumption. * - * @param usageText text to display to user to guide them to correct usage. - * This is generated and set by the <code>ArgsProcessor</code>. + * @param usageText text to display to user to guide them to correct usage. This is generated and + * set by the <code>ArgsProcessor</code>. */ public void setUsage(final String usageText) { usage = usageText; http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/installer/InstallerJUnitTest.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/installer/InstallerJUnitTest.java b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/installer/InstallerJUnitTest.java index 272e6de..0d02198 100644 --- a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/installer/InstallerJUnitTest.java +++ b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/installer/InstallerJUnitTest.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.installer; import static org.junit.Assert.*; @@ -45,13 +43,10 @@ public class InstallerJUnitTest { private void testTransformation(final String name) throws Exception { File webXmlFile = temporaryFolder.newFile(); FileUtil.copy(getClass().getResource(name), webXmlFile); - final String[] args = { - "-t", "peer-to-peer", - "-w", webXmlFile.getAbsolutePath() - }; + final String[] args = {"-t", "peer-to-peer", "-w", webXmlFile.getAbsolutePath()}; ByteArrayOutputStream output = new ByteArrayOutputStream(); - try(InputStream input = new FileInputStream(webXmlFile)){ + try (InputStream input = new FileInputStream(webXmlFile)) { new Installer(args).processWebXml(input, output); } @@ -59,4 +54,4 @@ public class InstallerJUnitTest { assertEquals(expected, output.toString()); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/AbstractListener.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/AbstractListener.java b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/AbstractListener.java index de0d1c3..6e5a9c1 100644 --- a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/AbstractListener.java +++ b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/AbstractListener.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.internal.filter; @@ -26,8 +24,7 @@ import java.util.concurrent.TimeUnit; */ public abstract class AbstractListener { - protected final List<ListenerEventType> events = - new ArrayList<ListenerEventType>(); + protected final List<ListenerEventType> events = new ArrayList<ListenerEventType>(); protected CountDownLatch latch; @@ -45,8 +42,7 @@ public abstract class AbstractListener { events.clear(); } - public boolean await(long timeout, - TimeUnit unit) throws InterruptedException { + public boolean await(long timeout, TimeUnit unit) throws InterruptedException { return latch.await(timeout, unit); } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/BasicServlet.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/BasicServlet.java b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/BasicServlet.java index 32ddc42..c1fd5a2 100644 --- a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/BasicServlet.java +++ b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/BasicServlet.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.internal.filter; @@ -25,6 +23,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.servlet.DefaultServlet; + /** * */ http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/Callback.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/Callback.java b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/Callback.java index 044a364..0f40c10 100644 --- a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/Callback.java +++ b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/Callback.java @@ -1,18 +1,16 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. */ package org.apache.geode.modules.session.internal.filter; @@ -26,5 +24,6 @@ import java.io.IOException; * Interface which, when implemented, can be put into a servlet context and executed by the servlet. */ public interface Callback { - void call(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException; + void call(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8bf39571/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/CallbackServlet.java ---------------------------------------------------------------------- diff --git a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/CallbackServlet.java b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/CallbackServlet.java index 89287b2..d14b111 100644 --- a/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/CallbackServlet.java +++ b/extensions/geode-modules-session/src/test/java/org/apache/geode/modules/session/internal/filter/CallbackServlet.java @@ -1,19 +1,17 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ package org.apache.geode.modules.session.internal.filter; @@ -28,16 +26,14 @@ public class CallbackServlet extends HttpServlet { private Callback callback; /** - * Processes requests for both HTTP <code>GET</code> and <code>POST</code> - * methods. + * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * - * @param request servlet request + * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs + * @throws IOException if an I/O error occurs */ - protected void processRequest(HttpServletRequest request, - HttpServletResponse response) + protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (callback != null) { @@ -52,10 +48,10 @@ public class CallbackServlet extends HttpServlet { /** * Handles the HTTP <code>GET</code> method. * - * @param request servlet request + * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs + * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) @@ -66,14 +62,13 @@ public class CallbackServlet extends HttpServlet { /** * Handles the HTTP <code>POST</code> method. * - * @param request servlet request + * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs - * @throws IOException if an I/O error occurs + * @throws IOException if an I/O error occurs */ @Override - protected void doPost(HttpServletRequest request, - HttpServletResponse response) + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); }
