-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAY-2510 Create builder to load custom modules into plugins and modeler
- Loading branch information
Showing
19 changed files
with
344 additions
and
77 deletions.
There are no files selected for viewing
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
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
46 changes: 46 additions & 0 deletions
46
cayenne-cgen/src/main/java/org/apache/cayenne/gen/CgenToolsModuleProvider.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,46 @@ | ||
/***************************************************************** | ||
* 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.cayenne.gen; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import org.apache.cayenne.di.Module; | ||
import org.apache.cayenne.tools.CayenneToolsModuleProvider; | ||
|
||
/** | ||
* @since 4.2 | ||
*/ | ||
public class CgenToolsModuleProvider implements CayenneToolsModuleProvider { | ||
@Override | ||
public Module module() { | ||
return new CgenModule(); | ||
} | ||
|
||
@Override | ||
public Class<? extends Module> moduleType() { | ||
return CgenModule.class; | ||
} | ||
|
||
@Override | ||
public Collection<Class<? extends Module>> overrides() { | ||
return Collections.emptyList(); | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
cayenne-cgen/src/main/java/org/apache/cayenne/gen/ClassGenerationActionFactory.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,27 @@ | ||
/***************************************************************** | ||
* 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.cayenne.gen; | ||
|
||
/** | ||
* @since 4.2 | ||
*/ | ||
public interface ClassGenerationActionFactory { | ||
|
||
ClassGenerationAction createAction(CgenConfiguration cgenConfiguration); | ||
} |
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
36 changes: 36 additions & 0 deletions
36
cayenne-cgen/src/main/java/org/apache/cayenne/gen/DefaultClassGenerationActionFactory.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,36 @@ | ||
/***************************************************************** | ||
* 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.cayenne.gen; | ||
|
||
/** | ||
* @since 4.2 | ||
*/ | ||
public class DefaultClassGenerationActionFactory implements ClassGenerationActionFactory { | ||
|
||
@Override | ||
public ClassGenerationAction createAction(CgenConfiguration cgenConfiguration) { | ||
ClassGenerationAction classGenerationAction = cgenConfiguration.isClient() ? | ||
new ClientClassGenerationAction() : | ||
new ClassGenerationAction(); | ||
classGenerationAction.setCgenConfiguration(cgenConfiguration); | ||
return classGenerationAction; | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
cayenne-cgen/src/main/java/org/apache/cayenne/tools/CayenneToolsModuleProvider.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,28 @@ | ||
/***************************************************************** | ||
* 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.cayenne.tools; | ||
|
||
import org.apache.cayenne.di.spi.ModuleProvider; | ||
|
||
/** | ||
* @since 4.2 | ||
*/ | ||
public interface CayenneToolsModuleProvider extends ModuleProvider { | ||
} |
59 changes: 59 additions & 0 deletions
59
cayenne-cgen/src/main/java/org/apache/cayenne/tools/ToolsInjectorBuilder.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,59 @@ | ||
/***************************************************************** | ||
* 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.cayenne.tools; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
import org.apache.cayenne.di.DIBootstrap; | ||
import org.apache.cayenne.di.Injector; | ||
import org.apache.cayenne.di.Module; | ||
import org.apache.cayenne.di.spi.ModuleLoader; | ||
|
||
/** | ||
* @since 4.2 | ||
*/ | ||
public class ToolsInjectorBuilder { | ||
|
||
private Collection<Module> modules; | ||
|
||
public ToolsInjectorBuilder() { | ||
this.modules = new ArrayList<>(); | ||
} | ||
|
||
public ToolsInjectorBuilder addModule(Module module) { | ||
modules.add(module); | ||
return this; | ||
} | ||
|
||
public ToolsInjectorBuilder addModules(Collection<Module> modules) { | ||
this.modules.addAll(modules); | ||
return this; | ||
} | ||
|
||
private Collection<? extends Module> autoLoadedModules() { | ||
return new ModuleLoader().load(CayenneToolsModuleProvider.class); | ||
} | ||
|
||
public Injector create() { | ||
Collection<Module> allModules = new ArrayList<>(autoLoadedModules()); | ||
allModules.addAll(modules); | ||
return DIBootstrap.createInjector(allModules); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../src/main/resources/META-INF/services/org.apache.cayenne.tools.CayenneToolsModuleProvider
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,20 @@ | ||
################################################################## | ||
# 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. | ||
################################################################## | ||
|
||
org.apache.cayenne.gen.CgenToolsModuleProvider |
Oops, something went wrong.