-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ServiceLoader for GroovyShellFactory
- Loading branch information
1 parent
0c0acb8
commit e504d49
Showing
12 changed files
with
269 additions
and
50 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
tis-console/src/main/java/com/qlangtech/tis/util/groovy/ConsoleGroovyShellFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* 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 | ||
* <p> | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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 com.qlangtech.tis.util.groovy; | ||
|
||
import com.qlangtech.tis.extension.util.impl.DefaultGroovyShellFactory; | ||
import com.qlangtech.tis.util.PluginItems; | ||
|
||
/** | ||
* | ||
*/ | ||
public class ConsoleGroovyShellFactory extends DefaultGroovyShellFactory { | ||
|
||
public ConsoleGroovyShellFactory() { | ||
super(PluginItems.class.getClassLoader()); | ||
} | ||
|
||
@Override | ||
public boolean isInConsoleModule() { | ||
return true; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../src/main/resources/META-INF/services/com.qlangtech.tis.extension.util.GroovyShellFactory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
## | ||
# 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:https://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. | ||
# | ||
|
||
com.qlangtech.tis.util.groovy.ConsoleGroovyShellFactory |
32 changes: 32 additions & 0 deletions
32
tis-console/src/test/java/com/qlangtech/tis/util/groovy/TestConsoleGroovyShellFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* 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 | ||
* <p> | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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 com.qlangtech.tis.util.groovy; | ||
|
||
import com.qlangtech.tis.common.utils.Assert; | ||
import com.qlangtech.tis.extension.util.GroovyShellFactory; | ||
import com.qlangtech.tis.extension.util.GroovyShellUtil; | ||
import junit.framework.TestCase; | ||
|
||
public class TestConsoleGroovyShellFactory extends TestCase { | ||
|
||
public void testGetInstance() { | ||
GroovyShellFactory groovyShellFactory = GroovyShellUtil.getGroovyShellFactory(); | ||
Assert.assertEquals(true, groovyShellFactory.isInConsoleModule()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,9 @@ | |
* @author: 百岁([email protected]) | ||
* @create: 2024-01-12 10:02 | ||
**/ | ||
final class CustomerGroovyClassLoader extends GroovyClassLoader { | ||
public CustomerGroovyClassLoader() { | ||
super(new ClassLoader(GroovyShellEvaluate.class.getClassLoader()) { | ||
public final class CustomerGroovyClassLoader extends GroovyClassLoader { | ||
public CustomerGroovyClassLoader(ClassLoader parent) { | ||
super(new ClassLoader(parent) { | ||
@Override | ||
protected Class<?> findClass(String name) throws ClassNotFoundException { | ||
// return super.findClass(name); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tis-plugin/src/main/java/com/qlangtech/tis/extension/util/GroovyShellFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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 | ||
* <p> | ||
* http:https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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 com.qlangtech.tis.extension.util; | ||
|
||
|
||
import groovy.lang.GroovyShell; | ||
|
||
/** | ||
* | ||
*/ | ||
public interface GroovyShellFactory { | ||
|
||
|
||
CustomerGroovyClassLoader createGroovyLoader(); | ||
|
||
GroovyShell createGroovyShell(); | ||
|
||
boolean isInConsoleModule(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.