--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.dlux</groupId>
+ <artifactId>dlux-parent</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../../</relativePath>
+ </parent>
+ <artifactId>loader</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <dependencies>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package></Import-Package>
+ <Export-Package>org.opendaylight.dlux.loader</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/dlux.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/dlux.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_dlux:Main</url>
+ </scm>
+</project>
--- /dev/null
+package org.opendaylight.dlux.loader;
+
+public interface IDluxLoaderRegistration {
+ public void addModule(String bundleName, String url, String requiredJs, String angularJs);
+}
--- /dev/null
+
+The loader uses the following files from build:
+
+cp ../../dlux-web/build/index.html ./src/main/resources/index/
+cp ../../dlux-web/build/src/main.js ./src/main/resources/dlux/src/main.js
+cp ../../dlux-web/build/src/app/app.controller.js ./src/main/resources/dlux/src/app/app.controller.js
+cp ../../dlux-web/build/src/app/app.module.js ./src/main/resources/dlux/src/app/app.module.js
+cp ../../dlux-web/build/src/app/routingConfig.js ./src/main/resources/dlux/src/app/routingConfig.js
+cp -r ../../dlux-web/build/vendor/* ./src/main/resources/dlux/vendor/
+cp -r ../../dlux-web/build/assets/* ./src/main/resources/dlux/assets/
+rm -rf ./src/main/resources/dlux/assets/yang2xml
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.dlux</groupId>
+ <artifactId>dlux-parent</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <relativePath>../../</relativePath>
+ </parent>
+ <artifactId>loader.implementation</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.dlux</groupId>
+ <artifactId>loader</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.dlux</groupId>
+ <artifactId>dlux.loader.resources</artifactId>
+ <version>${loader.resources.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <resources>
+ <resource>
+ <directory>target/generated-resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <!--Clean extracted resources-->
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>2.5</version>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${project.basedir}/src/main/resources/</directory>
+ <includes>
+ <include>dlux/</include>
+ <include>index/</include>
+ </includes>
+ <excludes></excludes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ <!--Copy resources from the dlux-web/build dir-->
+ <!--<plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-src-resources</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.basedir}/src/main/resources/dlux</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${project.basedir}/../../dlux-web/build/</directory>
+ <includes>
+ <include>src/main.js</include>
+ <include>src/app/app.controller.js</include>
+ <include>src/app/app.module.js</include>
+ <include>src/app/app.routingConfig.js</include>
+ <include>vendor/**</include>
+ <include>assets/**</include>
+ </includes>
+ <excludes>
+ <exclude>assets/yang2xml/</exclude>
+ </excludes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-index</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.basedir}/src/main/resources/index</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${project.basedir}/../../dlux-web/build/</directory>
+ <includes>
+ <include>index.html</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>-->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <!--loader Resources-->
+ <execution>
+ <id>unpack-loader-resources</id>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}/generated-resources</outputDirectory>
+ <groupId>org.opendaylight.dlux</groupId>
+ <includeArtifactIds>dlux.loader.resources</includeArtifactIds>
+ <excludes>META-INF\/**</excludes>
+ <excludeTransitive>true</excludeTransitive>
+ <ignorePermissions>false</ignorePermissions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <!-- Exclusion doesn't seem to work for the yang.xml files within the resources folders -->
+ <excludes>**/*</excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>org.osgi.framework,
+ org.opendaylight.dlux.loader,
+ org.opendaylight.dlux.loader.implementation,
+ org.osgi.service.http,
+ javax.servlet,
+ javax.servlet.http,*
+ </Import-Package>
+ <Export-Package>org.opendaylight.dlux.loader.implementation</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/dlux.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/dlux.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_dlux:Main</url>
+ </scm>
+</project>
--- /dev/null
+package org.opendaylight.dlux.loader.implementation;
+/**
+* Copyright (c) 2014 Inocybe Technologies, and others. All rights reserved.
+*
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0 which accompanies this distribution,
+* and is available at http://www.eclipse.org/legal/epl-v10.html
+*/
+
+import javax.servlet.ServletException;
+
+import org.osgi.service.http.HttpService;
+import org.osgi.service.http.NamespaceException;
+import org.opendaylight.dlux.loader.IDluxLoaderRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DluxLoader implements IDluxLoaderRegistration {
+
+ private DluxLoaderServlet modules;
+ private DluxLoaderIndexServlet index;
+ private static Logger logger = LoggerFactory.getLogger(DluxLoader.class);
+
+ @Override
+ public void addModule(String bundleName, String url, String requiredJs, String angularJs){
+ modules.addModule(bundleName, url, requiredJs, angularJs);
+ }
+ public void onUnbindService(HttpService srv) {
+ modules = null;
+ index = null;
+ }
+
+ public void onBindService(HttpService srv) throws ServletException, NamespaceException {
+ if (srv == null) {
+ logger.error("Unable to inject HttpService into DluxBootstrapper.");
+ } else {
+ modules = new DluxLoaderServlet();
+ index = new DluxLoaderIndexServlet();
+ srv.registerServlet("/src/app/modules.js", modules, null, null);
+ srv.registerServlet("/index.html", index, null, null);
+ srv.registerResources("/", "/dlux", null);
+ }
+ }
+}
--- /dev/null
+package org.opendaylight.dlux.loader.implementation;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DluxLoaderIndexServlet extends HttpServlet{
+
+ private static final long serialVersionUID = 1L;
+ private static Logger logger = LoggerFactory.getLogger(DluxLoaderIndexServlet.class);
+
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ response.setContentType("text/html");
+ InputStream input = null;
+
+ try {
+ input = DluxLoader.class.getClassLoader().getResourceAsStream("/index/index.html");
+ StringBuilder inputStringBuilder = new StringBuilder();
+ if (input == null){
+ PrintWriter out = response.getWriter();
+ out.println("There was an error generating the page.");
+ }
+ else {
+ BufferedReader bufferedReader = new BufferedReader(
+ new InputStreamReader(input, "UTF-8"));
+
+ String line = bufferedReader.readLine();
+ while (line != null) {
+ inputStringBuilder.append(line);
+ inputStringBuilder.append('\n');
+ line = bufferedReader.readLine();
+ }
+
+ String t1 = inputStringBuilder.toString();
+
+ String t2 = t1.replace("!--$", "");
+ String index = t2.replace("$--", "");
+ PrintWriter out = response.getWriter();
+ out.print(index);
+ }
+ } catch (IOException e) {
+ PrintWriter out = response.getWriter();
+ out.println("There was an error generating the page.");
+ logger.error("There was an error reading index.html :",e);
+ }
+ }
+}
--- /dev/null
+package org.opendaylight.dlux.loader.implementation;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DluxLoaderServlet extends HttpServlet{
+ private static final long serialVersionUID = 6095022610364619812L;
+ private ArrayList<Module> modules = new ArrayList<Module>();
+ private static Logger logger = LoggerFactory.getLogger(DluxLoaderServlet.class);
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ String module = "var module = ["+
+ "\'angularAMD\',"+
+ "\'ocLazyLoad\',"+
+ "\'angular-ui-router\',"+
+ "\'angular-translate\',"+
+ "\'angular-translate-loader-static-files\',"+
+ "\'angular-css-injector\',"; // requiredJs
+ String e = "var e = ["+
+ "\'oc.lazyLoad\',"+
+ "\'ui.router\',"+
+ "\'pascalprecht.translate\',"+
+ "\'angular.css.injector\',"; // angularJs
+ String end = "];";
+ StringBuilder sbm = new StringBuilder();
+ StringBuilder sbe = new StringBuilder();
+ sbm.append(module);
+ sbe.append(e);
+ for (Module m: modules){
+ sbm.append("\n\'");
+ sbe.append("\n\'");
+ sbm.append(m.getRequiredJs());
+ sbe.append(m.getAngularJs());
+ sbm.append("\',");
+ sbe.append("\',");
+ }
+ sbm.append(end);
+ sbe.append(end);
+ response.setContentType("text/javascript");
+
+ PrintWriter out = response.getWriter();
+ out.println(sbm.toString() + sbe.toString());
+ }
+ public void addModule(String bundleName, String url, String requiredJs, String angularJs){
+ modules.add(new Module(bundleName, url, requiredJs, angularJs));
+ }
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.dlux.loader.implementation;
+
+public class Module {
+ private String bundleName;
+ private String url;
+ private String requiredJs;
+ private String angularJs;
+ public Module(String bundleName, String url, String requiredJs,
+ String angularJs) {
+ super();
+ this.bundleName = bundleName;
+ this.url = url;
+ this.requiredJs = requiredJs;
+ this.angularJs = angularJs;
+ }
+ public String getBundleName() {
+ return bundleName;
+ }
+ public void setBundleName(String bundleName) {
+ this.bundleName = bundleName;
+ }
+ public String getUrl() {
+ return url;
+ }
+ public void setUrl(String url) {
+ this.url = url;
+ }
+ public String getRequiredJs() {
+ return requiredJs;
+ }
+ public void setRequiredJs(String requiredJs) {
+ this.requiredJs = requiredJs;
+ }
+ public String getAngularJs() {
+ return angularJs;
+ }
+ public void setAngularJs(String angularJs) {
+ this.angularJs = angularJs;
+ }
+}
--- /dev/null
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+ <!--bean id="bundle-onbind" class="org.opendaylight.dlux.bootstrapper.implementation.DluxBootstrapper"/-->
+ <bean id="bootstrapperImpl" class="org.opendaylight.dlux.bootstrapper.implementation.DluxBootstrapper"/>
+
+ <reference id="onBindService" availability="mandatory" activation="eager" interface="org.osgi.service.http.HttpService">
+ <reference-listener ref="bootstrapperImpl" bind-method="onBindService" unbind-method="onUnbindService"/>
+ </reference>
+
+ <service id="serviceRegistration" interface="org.opendaylight.dlux.bootstrapper.IDluxBootstrapperRegistration" ref="bootstrapperImpl"/>
+
+</blueprint>
\ No newline at end of file
<modules>\r
<module>modules</module>\r
<module>dlux-web</module>\r
+ <module>loader/api</module>\r
+ <module>loader/impl</module>\r
<module>features</module> \r
</modules>\r
<dependencyManagement>\r