Thanks Joao, this helps the maven plugin. I will use REST as endpoint for 
communication layer between angular and server side as shown in the sample 
enroute project.

From: João Assunção [mailto:joao.assun...@exploitsys.com]
Sent: Monday, August 06, 2018 12:12 PM
To: OSGi Developer Mail List
Cc: Matthews, Kevin; David Leangen
Subject: Re: [osgi-dev] Angular New Enroute

As David mentioned you will need to include the "ng build" step in your build 
process. I include a portion of the pom where exec-maven-plugin is used to 
invoke "npm install" and "ng build".
To expose the angular app we are using HTTP whiteboard. The bundle activator 
exports a  ResourceMapping service configured with the path of the ngapp 
directory. We are doing it in the bundle activator but it could be done in 
@Activate of a DS component. In our case, the communication between the angular 
side and the server side (a DS component) is done using web sockets, but I 
think it would be easy to make a DS component expose a REST service..


DefaultResourceMapping rootResourceMapping = new DefaultResourceMapping();
rootResourceMapping.setAlias("/myApp");
rootResourceMapping.setPath("/ng");
rootResourceMappingRegistration = 
bundleContext.registerService(ResourceMapping.class, rootResourceMapping, null);

// Redirect 404 errors to the default page
DefaultErrorPageMapping errorpageMapping = new DefaultErrorPageMapping();
errorpageMapping.setError("404");
errorpageMapping.setLocation("/myApp/index.html");
errorpage404Registration = 
bundleContext.registerService(ErrorPageMapping.class, errorpageMapping, null);

// Registers a filter to rewrite the URL "myApp/" to
// index.html
RedirectMatchFilter filter = new RedirectMatchFilter("/myApp/", 
"/myApp/index.html");
props = new Hashtable<>();
props.put(ExtenderConstants.PROPERTY_URL_PATTERNS, "/myApp/*");
filtrerRegistration = bundleContext.registerService(Filter.class, filter, 
props);




<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.5.0</version>
    <executions>
<execution>
   <id>exec-npm-install</id>
   <phase>generate-sources</phase>
   <configuration>
<skip>${maven.exec.skip}</skip>
<workingDirectory>${project.basedir}/src/main/ngapp</workingDirectory>
<executable>${npm.executable}</executable>
<arguments>
   <argument>install</argument>
</arguments>
   </configuration>
   <goals>
<goal>exec</goal>
   </goals>
</execution>
<execution>
   <id>exec-npm-ng-build</id>
   <phase>generate-sources</phase>
   <configuration>
<skip>${maven.exec.skip}</skip>
<workingDirectory>${project.basedir}/src/main/ngapp</workingDirectory>
<executable>${ng.executable}</executable>
<arguments>
   <argument>build</argument>
   <argument>--target=${build.target}</argument>
   <argument>--base-href=/myApp/</argument>
   <argument>--no-progress</argument>
   <argument>--output-hashing=all</argument>
</arguments>
   </configuration>
   <goals>
<goal>exec</goal>
   </goals>
</execution>
    </executions>
</plugin>



João Assunção

Email: joao.assun...@exploitsys.com<mailto:joao.assun...@exploitsys.com>
Mobile: +351 916968984
Phone: +351 211933149
Web: 
www.exploitsys.com<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.exploitsys.com&d=DwMFaQ&c=ewHkv9vLloTwhsKn5d4bTdoqsmBfyfooQX5O7EQLv5TtBZ1CwcvjU063xndfqI8U&r=wKHHp1xupEN1UoR2CPDlg9US2Vs3om5ld5YqSsWMQX8&m=fQet__nyoR_6Y5VXE7qnrBRIx637Y7xQ11pF8wBTskQ&s=Sg5iZYx-jtTTX9uaRJ8BBjbVhN9VqxrnOPQmOmTIwZ0&e=>



On Fri, Aug 3, 2018 at 11:42 PM, David Leangen via osgi-dev 
<osgi-dev@mail.osgi.org<mailto:osgi-dev@mail.osgi.org>> wrote:

Hi,

Angular 2+ works very differently from AngularJS. In enRoute (or at least in 
v2, I am not yet familiar with the current enRoute), it used AngularJS. You 
used to be able to just include the JS file, and that was it. Angular 2+ 
requires you to build/compile your application first, so you cannot just ship 
the source code (unless you include some kind of interpreter, but I’ve never 
attempted that).

What we do is build the files at some point during the build process, and ship 
the entire dist directory.

It works for us as a deployment mechanism. Never tried it as a DS component, 
though. Because of the way an Angular 2+ app works, I don’t immediately see how 
you could do that. If you figure it out, I’d be interested in hearing your 
solution.


Cheers,
=David



On Aug 4, 2018, at 4:55, Matthews, Kevin via osgi-dev 
<osgi-dev@mail.osgi.org<mailto:osgi-dev@mail.osgi.org>> wrote:

Hello,

Has anyone integrated the new angular 2+/6 into the enroute project as a 
separate UI module/DS component? I have added the contents of my angular src 
folder into the static folder  of the enroute sample but doesn’t seem to render 
the static pages. Should I add the entire angular folder to static folder or 
just the src folder of my angular generate project?

Kevin Matthews
Senior Application Analyst
First Data, 3975 NW 120 Ave, Coral Springs, FL 33065
Office: 954-845-4222 | Mobile: 561-465-6694

kevin.matth...@firstdata.com<mailto:kevin.matth...@firstdata.com> | 
firstdata.com<http://firstdata.com/>

The information in this message may be proprietary and/or confidential, and 
protected from disclosure. If the reader of this message is not the intended 
recipient, or an employee or agent responsible for delivering this message to 
the intended recipient, you are hereby notified that any dissemination, 
distribution or copying of this communication is strictly prohibited. If you 
have received this communication in error, please notify First Data immediately 
by replying to this message and deleting it from your computer.
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org<mailto:osgi-dev@mail.osgi.org>
https://mail.osgi.org/mailman/listinfo/osgi-dev<https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.osgi.org_mailman_listinfo_osgi-2Ddev&d=DwMFaQ&c=ewHkv9vLloTwhsKn5d4bTdoqsmBfyfooQX5O7EQLv5TtBZ1CwcvjU063xndfqI8U&r=wKHHp1xupEN1UoR2CPDlg9US2Vs3om5ld5YqSsWMQX8&m=fQet__nyoR_6Y5VXE7qnrBRIx637Y7xQ11pF8wBTskQ&s=MduFVUYZWGGC5Y1m5rR721w26i1vuUr3H1-NrwAjBUI&e=>


_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org<mailto:osgi-dev@mail.osgi.org>
https://mail.osgi.org/mailman/listinfo/osgi-dev<https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.osgi.org_mailman_listinfo_osgi-2Ddev&d=DwMFaQ&c=ewHkv9vLloTwhsKn5d4bTdoqsmBfyfooQX5O7EQLv5TtBZ1CwcvjU063xndfqI8U&r=wKHHp1xupEN1UoR2CPDlg9US2Vs3om5ld5YqSsWMQX8&m=fQet__nyoR_6Y5VXE7qnrBRIx637Y7xQ11pF8wBTskQ&s=MduFVUYZWGGC5Y1m5rR721w26i1vuUr3H1-NrwAjBUI&e=>

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to