[ 
https://issues.apache.org/jira/browse/KNOX-3051?focusedWorklogId=946594&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-946594
 ]

ASF GitHub Bot logged work on KNOX-3051:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Dec/24 22:42
            Start Date: 03/Dec/24 22:42
    Worklog Time Spent: 10m 
      Work Description: pzampino commented on code in PR #971:
URL: https://github.com/apache/knox/pull/971#discussion_r1868453631


##########
gateway-util-launcher/src/main/java/org/apache/knox/gateway/launcher/Extender.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.knox.gateway.launcher;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Extender {
+
+    private static final String CLASSPATH_EXTENSION_PROPERTY = 
"gateway.server.classpath.extension";
+    private static final String CLASSPATH_PROPERTY_PATTERN = 
"<property>\\s*<name>" + CLASSPATH_EXTENSION_PROPERTY + 
"</name>\\s*<value>(.*?)</value>\\s*</property>";
+    private static final String CONFIG_FILE = "gateway-site.xml";
+    private static final String CONFIG_PATH = "../conf/" + CONFIG_FILE;
+    private static final String CLASS_PATH_PROPERTY = "class.path";
+    private static final String MAIN_CLASS_PROPERTY = "main.class";
+    private static final String GATEWAY_SERVER_MAIN_CLASS = 
"org.apache.knox.gateway.GatewayServer";
+    private static final String[] CLASS_PATH_DELIMITERS = new String[]{",", 
";"};
+
+    private final File base;
+    private final Properties properties;
+    private final Pattern pattern = 
Pattern.compile(CLASSPATH_PROPERTY_PATTERN, Pattern.DOTALL);
+
+    public Extender(File base, Properties properties) {
+        this.base = base;
+        this.properties = properties;
+    }
+
+    public void extendClassPathProperty() throws IOException {

Review Comment:
   Is there any reason why this could not be done automatically when the object 
is created, rather than requiring another method invocation? There is no case 
for which this method would not be invoked, and probably not any cases where it 
would be meaningful to invoke it more than once, correct? 
   
   Alternatively, you could pass in the properties at the time of the extension 
method, rather than the constructor, if you feel they should be separate 
actions. 
   
   I guess my question ultimately is does this class need to retain a copy of 
all the properties? Or, could it rather process them once and be done with them?



##########
gateway-util-launcher/src/main/java/org/apache/knox/gateway/launcher/Extender.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.knox.gateway.launcher;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class Extender {

Review Comment:
   Since this only applies to GatewayServer, perhaps it should be named more 
explicitly...something like GatewayServerClasspathExtender?





Issue Time Tracking
-------------------

    Worklog Id:     (was: 946594)
    Time Spent: 1.5h  (was: 1h 20m)

> Add a classpath location for patches
> ------------------------------------
>
>                 Key: KNOX-3051
>                 URL: https://issues.apache.org/jira/browse/KNOX-3051
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: Server
>    Affects Versions: 2.0.0
>            Reporter: Philip Zampino
>            Priority: Minor
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> It would be convenient to have the ability to easily pre-pend classes to the 
> Knox classpath for quickly applying/testing patches.
> If this could be configurable, that would be ideal, though I'm not sure it's 
> possible.
> If hard-coded, we should consider whether or not this location should be 
> within the Knox installation directory or external to it. There are pros and 
> cons to both, especially when considering upgrades in managed environments.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to