Skip to content

Instantly share code, notes, and snippets.

@gastaldi
Last active February 5, 2016 16:02
Show Gist options
  • Save gastaldi/38c8885b64f909cc6684 to your computer and use it in GitHub Desktop.
Save gastaldi/38c8885b64f909cc6684 to your computer and use it in GitHub Desktop.
Scripts used in Wildfly Swarm presentation - Run inside JBDS (where the AngularJS addon is already installed)
project-new --named bookstore --stack JAVA_EE_7
jpa-new-entity --named Author
jpa-new-field --named name
jpa-new-entity --named Book
jpa-new-field --named title
jpa-new-field --named author --type org.bookstore.model.Author --relationship-type Many-to-One
jpa-new-entity --named Offer
jpa-new-field --named name
jpa-new-field --named description
scaffold-generate --provider AngularJS --generate-rest-resources --targets org.bookstore.model.*
insert into Offer (id, name, description, version) values (1000,'Offer 1', 'Description 1',0);
insert into Offer (id, name, description, version) values (1001,'Offer 2', 'Description 2',0);
insert into Offer (id, name, description, version) values (1002,'Offer 3', 'Description 3',0);
insert into Offer (id, name, description, version) values (1003,'Offer 4', 'Description 4',0);
# Installs the Wildfly Swarm addon
addon-install-from-git --url https://github.com/forge/wildfly-swarm-addon.git
# Creates a new project
project-new --named offer --stack JAVA_EE_7
# Setup Wildfly Swarm and adds fractions on-demand
wildfly-swarm-setup
# Creates a new entity and adds some fields
jpa-new-entity --named Offer
jpa-new-field --named name
jpa-new-field --named description
# Generate the JAX-RS endpoint for the Offer entity
rest-generate-endpoints-from-entities --targets org.offer.model.Offer
# Since we are running from a microservice, we need to enable CORS - Cross Origin Resource Sharing
rest-new-cross-origin-resource-sharing-filter
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>offer</display-name>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<mime-mapping>
<extension>ico</extension>
<mime-type>image/x-icon</mime-type>
</mime-mapping>
<login-config>
<auth-method>KEYCLOAK</auth-method>
<realm-name>master</realm-name>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>offers</web-resource-name>
<url-pattern>/rest/offers</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>user</role-name>
</security-role>
</web-app>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment