Package io.toro.martini
Class SpringMethods
java.lang.Object
io.toro.martini.SpringMethods
Provides one-liners for performing Spring specific operations.
Included in this class are one-liners for adding and removing
Spring context files in a MartiniPackage.
-
Constructor Summary
ConstructorsConstructorDescriptionSpringMethods(io.toro.martini.spring.PackageSpringContextConfigurer contextConfigurer, MartiniPackageProvider packageProvider) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddContextFile(String fileName, InputStream contents, String packageName, boolean replaceExisting) Creates a Spring context file from anInputStream.static voidaddContextFile(String fileName, String contents, String packageName, boolean replaceExisting) Creates a Spring context file with the providedcontents.static ObjectRetrieves a bean object from the Spring context.static voidremoveContextFile(String fileName, String packageName, boolean removeFiles) Removes an existing Spring context file a package.
-
Constructor Details
-
SpringMethods
@Autowired public SpringMethods(io.toro.martini.spring.PackageSpringContextConfigurer contextConfigurer, MartiniPackageProvider packageProvider)
-
-
Method Details
-
addContextFile
public static void addContextFile(@GloopParameter(defaultValue="spring-context.xml") String fileName, @GloopParameter(allowNull=false) String contents, String packageName, @GloopParameter(defaultValue="false") boolean replaceExisting) Creates a Spring context file with the providedcontents. Registers the context file to a package.- Parameters:
fileName- the name of to-be-created Spring context filecontents- theStringcontents of the context filepackageName- the name of the package where the Spring context will be added if empty, this will assume the name of the package where the service is invokedreplaceExisting- the flag to indicate whether to replace the existing file- Since:
- 1.1
-
addContextFile
public static void addContextFile(@GloopParameter(defaultValue="spring-context.xml") String fileName, @GloopParameter(allowNull=false) InputStream contents, String packageName, @GloopParameter(defaultValue="false") boolean replaceExisting) Creates a Spring context file from anInputStream. Registers the context file to a package.- Parameters:
fileName- the name of to-be-created Spring context filecontents- theInputStreamcontaining the contents of the context filepackageName- the name of the package where the Spring context will be added if empty, this will assume the name of the package where the service is invokedreplaceExisting- the flag to indicate whether to replace the existing file- Since:
- 1.1
-
removeContextFile
public static void removeContextFile(@GloopParameter(defaultValue="spring-context.xml") String fileName, String packageName, @GloopParameter(defaultValue="false") boolean removeFiles) Removes an existing Spring context file a package.- Parameters:
fileName- the name of the existing Spring context filepackageName- the name of the package where the Spring context will be added if empty, this will assume the name of the package where the service is invokedremoveFiles- the flag to indicate whether to delete the context files- Since:
- 1.1
-
getBean
Retrieves a bean object from the Spring context.- Parameters:
beanName- the name of the bean to retrievepackageName- the name of the package where the Spring context resides if empty, this will assume the name of the package where the service is invoked- Since:
- 1.1
-