Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from codehaus-plexus/update-component
Changes: * update parent (spotless applied as well) * drop p-c-d * make it JSR330 * drop plexus XML mumbo jumbo
- Loading branch information
Showing
10 changed files
with
195 additions
and
214 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
83 changes: 0 additions & 83 deletions
83
src/main/java/org/codehaus/plexus/velocity/DefaultVelocityComponent.java
This file was deleted.
Oops, something went wrong.
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
29 changes: 29 additions & 0 deletions
29
src/main/java/org/codehaus/plexus/velocity/VelocityComponentConfigurator.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,29 @@ | ||
package org.codehaus.plexus.velocity; | ||
|
||
/* | ||
* Copyright 2001-2016 Codehaus Foundation. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
import java.util.Properties; | ||
|
||
/** | ||
* The VelocityComponent configuration that may configure {@link java.util.Properties} prior having them used to init | ||
* Velocity Engine. This component is optional, is not needed if default are sufficient. | ||
* | ||
* @since TBD | ||
*/ | ||
public interface VelocityComponentConfigurator { | ||
void configure(Properties properties); | ||
} |
73 changes: 73 additions & 0 deletions
73
src/main/java/org/codehaus/plexus/velocity/internal/DefaultVelocityComponent.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,73 @@ | ||
package org.codehaus.plexus.velocity.internal; | ||
|
||
/* | ||
* Copyright 2001-2016 Codehaus Foundation. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import java.util.Properties; | ||
|
||
import org.apache.velocity.app.VelocityEngine; | ||
import org.codehaus.plexus.velocity.VelocityComponent; | ||
import org.codehaus.plexus.velocity.VelocityComponentConfigurator; | ||
import org.eclipse.sisu.Nullable; | ||
|
||
/** | ||
* Default component implementation. The presence of {@link VelocityComponentConfigurator} is optional. | ||
*/ | ||
@Singleton | ||
@Named | ||
public class DefaultVelocityComponent implements VelocityComponent { | ||
private final VelocityEngine engine; | ||
|
||
@Inject | ||
public DefaultVelocityComponent(@Nullable VelocityComponentConfigurator componentConfigurator) { | ||
Properties properties = new Properties(); | ||
|
||
// fill in defaults | ||
properties.setProperty("resource.loaders", "classpath,file"); | ||
properties.setProperty( | ||
"resource.loader.classpath.class", | ||
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); | ||
properties.setProperty( | ||
"resource.loader.file.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); | ||
properties.setProperty("resource.loader.file.path", ""); | ||
properties.setProperty("runtime.log.log_invalid_references", "false"); | ||
properties.setProperty("resource.manager.log_when_found", "false"); | ||
properties.setProperty( | ||
"event_handler.include.class", "org.apache.velocity.app.event.implement.IncludeRelativePath"); | ||
properties.setProperty("velocimacro.inline.replace_global", "true"); | ||
properties.setProperty("parser.space_gobbling", "bc"); | ||
|
||
// customize if needed | ||
if (componentConfigurator != null) { | ||
componentConfigurator.configure(properties); | ||
} | ||
|
||
VelocityEngine engine = new VelocityEngine(); | ||
engine.setProperties(properties); | ||
engine.init(); | ||
|
||
this.engine = engine; | ||
} | ||
|
||
@Override | ||
public VelocityEngine getEngine() { | ||
return engine; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
e0c3648
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid merge commits. They add zero benefit, just clutter.