Permalink
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up
Find file
Copy path
microstarter/IntelliJ Live Templates/Micronaut/Micronaut-Java.xml
Find file
Copy path
Fetching contributors…
Cannot retrieve contributors at this time.
Cannot retrieve contributors at this time
| <templateSet group="Micronaut-Java"> | |
| <template name="mn-controller" value="package $PACKAGENAME$; import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Get; import io.micronaut.http.HttpStatus; @Controller("/$PATH$") public class $controllerName$ { @Get("/") public HttpStatus index() { return HttpStatus.OK; } }" description="Micronaut Controller" toReformat="false" toShortenFQNames="true"> | |
| <variable name="PACKAGENAME" expression="currentPackage()" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="PATH" expression="" defaultValue="HelloWorld" alwaysStopAt="false" /> | |
| <variable name="controllerName" expression="fileNameWithoutExtension()" defaultValue="MyContoller" alwaysStopAt="false" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-client" value="package $PACKAGENAME$; import io.micronaut.http.client.annotation.Client; import io.micronaut.http.annotation.Get; import io.micronaut.http.HttpStatus; @Client("/$PATH$") public interface $clientNAME$ { @Get("/") public HttpStatus index(); }" description="Micronaut Client" toReformat="false" toShortenFQNames="true" useStaticImport="true"> | |
| <variable name="PACKAGENAME" expression="currentPackage()" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="PATH" expression="" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="clientNAME" expression="fileNameWithoutExtension()" defaultValue="" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-controller-test" value="package $PACKAGENAME$; import io.micronaut.context.ApplicationContext; import io.micronaut.http.HttpStatus; import io.micronaut.http.client.RxHttpClient; import io.micronaut.runtime.server.EmbeddedServer; import io.micronaut.test.annotation.MicronautTest; import org.junit.jupiter.api.Test; import javax.inject.Inject; import static org.junit.jupiter.api.Assertions.assertEquals; @MicronautTest public class $controllerName$Test { @Inject EmbeddedServer embeddedServer; @Test public void testIndex() throws Exception { try(RxHttpClient client = embeddedServer.getApplicationContext().createBean(RxHttpClient.class, embeddedServer.getURL())) { assertEquals(HttpStatus.OK, client.toBlocking().exchange("/$Path$").status()); } } } " description="Micronaut Controller Test" toReformat="false" toShortenFQNames="true"> | |
| <variable name="PACKAGENAME" expression="currentPackage()" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="controllerName" expression="fileNameWithoutExtension()" defaultValue="Controller" alwaysStopAt="true" /> | |
| <variable name="Path" expression="" defaultValue="servicePATH" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-websocket-client" value="package $PACKAGENAME$; import io.micronaut.websocket.WebSocketSession; import io.micronaut.websocket.annotation.*; @ClientWebSocket("/$PATH$/$TOPIC$/") public abstract class $WebsocketClient$ implements AutoCloseable { private WebSocketSession session; @OnOpen public void onOpen(WebSocketSession session) { this.session = session; } @OnMessage public void onMessage() {} public WebSocketSession getSession() { return session; } }" description="Micronaut WebSocket Client" toReformat="false" toShortenFQNames="true"> | |
| <variable name="PACKAGENAME" expression="currentPackage()" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="PATH" expression="" defaultValue="PATH" alwaysStopAt="true" /> | |
| <variable name="TOPIC" expression="" defaultValue="TOPIC" alwaysStopAt="true" /> | |
| <variable name="WebsocketClient" expression="fileNameWithoutExtension()" defaultValue="WebSocketClient" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-websocket-server" value="import io.micronaut.websocket.WebSocketBroadcaster; import io.micronaut.websocket.WebSocketSession; import io.micronaut.websocket.annotation.*; @ServerWebSocket("/$PATH$/$TOPIC$") public class $CLASSNAME$ { private WebSocketBroadcaster broadcaster; public $CLASSNAME$(WebSocketBroadcaster broadcaster) { this.broadcaster = broadcaster; } @OnOpen public void onOpen() {} @OnMessage public void onMessage() {} @OnClose public void onClose() {} }" description="Micronaut Websocket Server" toReformat="false" toShortenFQNames="true"> | |
| <variable name="PATH" expression="" defaultValue="PATH" alwaysStopAt="true" /> | |
| <variable name="TOPIC" expression="" defaultValue="TOPIC" alwaysStopAt="true" /> | |
| <variable name="CLASSNAME" expression="fileNameWithoutExtension()" defaultValue="className" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-job" value="package $PACKAGENAME$; import javax.inject.Singleton; import io.micronaut.scheduling.annotation.Scheduled; @Singleton public class $ServiceName$ { @Scheduled(fixedRate = "5m") public void process() {} }" description="Micronaut Job" toReformat="false" toShortenFQNames="true"> | |
| <variable name="PACKAGENAME" expression="currentPackage()" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="ServiceName" expression="fileNameWithoutExtension()" defaultValue="ServiceName" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-singleton" value="package $PACKAGENAME$; import javax.inject.Singleton; @Singleton public class $ClassName$ { }" description="Micronaut Bean/Singleton/Service" toReformat="false" toShortenFQNames="true" useStaticImport="true"> | |
| <variable name="PACKAGENAME" expression="currentPackage" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="ClassName" expression="fileNameWithoutExtension()" defaultValue="ServiceName" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-test" value="package $PACKAGENAME$; import io.micronaut.runtime.server.EmbeddedServer; import io.micronaut.test.annotation.MicronautTest; import org.junit.jupiter.api.Test; import javax.inject.Inject; import static org.junit.jupiter.api.Assertions.assertTrue; @MicronautTest public class ${className}Test { @Inject EmbeddedServer embeddedServer; @Test void testItWorks() { assertTrue(embeddedServer.isRunning()); } } " description="Micronaut Test" toReformat="false" toShortenFQNames="true" useStaticImport="true"> | |
| <variable name="PACKAGENAME" expression="currentPackage()" defaultValue="" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-mongodb-service" value="package $PACKAGENAME$; import com.mongodb.reactivestreams.client.MongoClient; import com.mongodb.reactivestreams.client.MongoCollection; import io.hashimati.offerservice.domains.Offer; import io.hashimati.requestservice.domains.Request; import io.reactivex.Single; import org.bson.BsonDocument; import org.bson.BsonString; import javax.inject.Singleton; @Singleton public class $className$ { private final MongoClient mongoClient; public OfferServices(MongoClient mongoClient) { this.mongoClient = mongoClient; } public Single<$ObjType$> save($ObjType$ var){ return Single.fromPublisher(getCollection().insertOne(var)) .map(success->var); } private MongoCollection<$ObjType$> getCollection() { return mongoClient .getDatabase("$dbname$") .getCollection("$collectionName$", $ObjType$.class); } } " description="Mongodb Singleton Service" toReformat="false" toShortenFQNames="true"> | |
| <variable name="PACKAGENAME" expression="currentPackage()" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="className" expression="fileNameWithoutExtension()" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="ObjType" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" /> | |
| <variable name="dbname" expression="" defaultValue="databasename" alwaysStopAt="true" /> | |
| <variable name="collectionName" expression="" defaultValue="collectionname" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-authenticationProvider" value="package $PACKAGENAME$ import io.micronaut.security.authentication.*; import io.reactivex.Flowable; import org.reactivestreams.Publisher; import javax.inject.Inject; import javax.inject.Singleton; import java.util.Arrays; import java.util.stream.Collectors; @Singleton public class AuthenticationProviderUserPassword implements AuthenticationProvider { // change user repository with your service which retieives the user info @Inject private UserRepository userRepository; @Override public Publisher<AuthenticationResponse> authenticate(AuthenticationRequest authenticationRequest) { // replace this code with your code which retrieves the user information. User user = userRepository.findUserByUsernameAndPassword( authenticationRequest.getIdentity().toString(), authenticationRequest.getSecret().toString()); // if ( user !=null ) { return Flowable.just(new UserDetails(user.getUsername(), user.getRoles())); } return Flowable.just(new AuthenticationFailed()); } }" description="Authentication Provider Implemenation" toReformat="false" toShortenFQNames="true"> | |
| <variable name="PACKAGENAME" expression="" defaultValue="" alwaysStopAt="true" /> | |
| <context> | |
| <option name="JAVA_CODE" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-secured" value="@Secured(SecurityRule.IS_AUTHENTICATED) " description="Secured Annotiation" toReformat="false" toShortenFQNames="true"> | |
| <context> | |
| <option name="GROOVY" value="true" /> | |
| <option name="JAVA_CODE" value="true" /> | |
| <option name="KOTLIN" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-securedroles" value="@Secured({"ROLE_ADMIN", "ROLE_X"})" description="Secured Rolls Annotations" toReformat="false" toShortenFQNames="true"> | |
| <context> | |
| <option name="GROOVY" value="true" /> | |
| <option name="JAVA_CODE" value="true" /> | |
| <option name="KOTLIN" value="true" /> | |
| </context> | |
| </template> | |
| <template name="mn-rolesallowed" value="@RolesAllowed({"ROLE_ADMIN", "ROLE_X"})" description="Roles Allowed Annotiations" toReformat="false" toShortenFQNames="true"> | |
| <context> | |
| <option name="GROOVY" value="true" /> | |
| <option name="JAVA_CODE" value="true" /> | |
| <option name="KOTLIN" value="true" /> | |
| </context> | |
| </template> | |
| </templateSet> |