Skip to content

Commit

Permalink
Switch to bnd.osgi and Angular UI
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneider committed Oct 12, 2015
1 parent f2aa24b commit eef7dda
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 54 deletions.
1 change: 1 addition & 0 deletions tasklist-blueprint-cdi/angular-ui/.gitignore
@@ -0,0 +1 @@
/target/
1 change: 1 addition & 0 deletions tasklist-blueprint-cdi/angular-ui/osgi.bnd
@@ -0,0 +1 @@
Web-ContextPath: /tasklist
18 changes: 18 additions & 0 deletions tasklist-blueprint-cdi/angular-ui/pom.xml
@@ -0,0 +1,18 @@
<?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>
<artifactId>tasklist-blueprint-cdi</artifactId>
<groupId>net.lr.tasklist.cdi</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>tasklist-angular-ui</artifactId>
<packaging>bundle</packaging>

<name>tasklist-angular-ui</name>
<description>angular-ui web bundle</description>

</project>
37 changes: 37 additions & 0 deletions tasklist-blueprint-cdi/angular-ui/src/main/resources/app.js
@@ -0,0 +1,37 @@
(function() {
var app = angular.module('myApp', []);
app.factory("Post", function($resource) {
return $resource("/cxf/tasklistRest");
});

app.controller('TaskController', function($scope, $http) {
$scope.task = {};
$scope.reload = function() {
$http.get("/cxf/tasklistRest")
.success(function (response) {$scope.tasks = response.task;});
};

$scope.put = function() {
var toSend = {task: $scope.task};
$http.put("/cxf/tasklistRest/" + $scope.task.id, toSend)
.success(function (response) {$scope.reload();});

this.task = {};
};

$scope.delete = function(id) {
$http.delete("/cxf/tasklistRest/"+ id)
.success(function (response) {$scope.reload();});
$scope.task = {};
}

$scope.select = function(id) {
$scope.task = $scope.tasks[id];
}

$scope.newTask = function(id) {
$scope.task = {};
}
$scope.reload();
});
})();
88 changes: 88 additions & 0 deletions tasklist-blueprint-cdi/angular-ui/src/main/resources/index.html
@@ -0,0 +1,88 @@
<!DOCTYPE html>
<html>
<style>
table, th , td {
border: 1px solid grey;
border-collapse: collapse;
padding: 5px;
}
table tr:nth-child(odd) {
background-color: #f1f1f1;
}
table tr:nth-child(even) {
background-color: #ffffff;
}
table tbody tr:hover {
border-color: red;
cursor: pointer;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
<script src= "app.js"></script>
<body>

<h1>Tasks</h1>

<div ng-app="myApp" ng-controller="TaskController as taskCtrl">
<div>
<button class="btn btn-success" ng-click="reload()"><span class="glyphicon glyphicon-refresh"></span> Reload</button>
<button class="btn btn-success" ng-click="newTask()"><span class="glyphicon glyphicon-plus"></span> New Task</button>
</div>
<hr>
<table class="table table-striped">
<thead>
<tr>
<th>Del</th>
<th>Id</th>
<th>Title</th>
<th>Description</th>
</tr>
</thead>
<tobdy>
<tr ng-repeat="t in tasks">
<td><span class="glyphicon glyphicon-remove" ng-click="delete(t.id)"></span> <span class="glyphicon glyphicon-pencil" ng-click="select($index)"></span></td>
<td>{{t.id}}</td>
<td>{{t.title}}</td>
<td>{{t.description}}</td>
</tr>
</tbody>
</table>

<hr>

<h2>Task</h2>

<form class="form-horizontal" novalidate>
<div class="form-group">
<label class="col-sm-1 control-label">Id:</label>
<div class="col-sm-10">
<input type="text" ng-model="task.id">
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">Title:</label>
<div class="col-sm-10">
<input type="text" ng-model="task.title">
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label">Description:</label>
<div class="col-sm-10">
<input type="text" ng-model="task.description">
</div>
</div>
<div class="form-group">
<label class="col-sm-1 control-label"></label>
<div class="col-sm-10">
<button class="btn btn-success" ng-click="put()"><span class="glyphicon glyphicon-save"></span> Save</button>
</div>
</div>
</form>

</div>

</body>
</html>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="tasklist-cdi-${pom.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0">
<repository>mvn:org.apache.cxf.karaf/apache-cxf/3.1.1/xml/features</repository>
<repository>mvn:org.apache.cxf.karaf/apache-cxf/3.1.3/xml/features</repository>
<repository>mvn:org.ops4j.pax.jdbc/pax-jdbc-features/0.7.0/xml/features</repository>

<feature name="example-tasklist-cdi" version="${pom.version}">
Expand All @@ -21,12 +21,17 @@
</feature>

<feature name="example-tasklist-cdi-service" version="${pom.version}">
<feature>cxf-features-logging</feature>
<feature>cxf-jaxrs</feature>
<bundle>mvn:net.lr.tasklist.cdi/tasklist-service/${pom.version}</bundle>
</feature>


<feature name="example-tasklist-cdi-ui" version="${pom.version}">
<feature>war</feature>
<bundle>mvn:net.lr.tasklist.cdi/tasklist-angular-ui/${pom.version}</bundle>
</feature>

<feature name="example-tasklist-cdi-ui-old" version="${pom.version}">
<feature>http</feature>
<feature>http-whiteboard</feature>
<bundle>mvn:net.lr.tasklist.cdi/tasklist-model/${pom.version}</bundle>
Expand Down
6 changes: 6 additions & 0 deletions tasklist-blueprint-cdi/model/osgi.bnd
@@ -0,0 +1,6 @@
Meta-Persistence: \
META-INF/persistence.xml
Import-Package: \
org.hibernate.proxy, \
javassist.util.proxy, \
*
35 changes: 10 additions & 25 deletions tasklist-blueprint-cdi/model/pom.xml
@@ -1,31 +1,16 @@
<?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">
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>net.lr.tasklist.cdi</groupId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>tasklist-blueprint-cdi</artifactId>
<relativePath>..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.lr.tasklist.cdi</groupId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>tasklist-blueprint-cdi</artifactId>
<relativePath>..</relativePath>
</parent>

<packaging>bundle</packaging>
<artifactId>tasklist-model</artifactId>
<packaging>bundle</packaging>
<artifactId>tasklist-model</artifactId>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
<!-- Needed for runtime enhancement -->
<Import-Package>*, org.hibernate.proxy, javassist.util.proxy</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions tasklist-blueprint-cdi/persistence/osgi.bnd
@@ -0,0 +1 @@
-dsannotations: *
10 changes: 0 additions & 10 deletions tasklist-blueprint-cdi/persistence/pom.xml
Expand Up @@ -50,16 +50,6 @@
</scanPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.3</version>
<extensions>true</extensions>
<configuration>
<instructions>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
16 changes: 9 additions & 7 deletions tasklist-blueprint-cdi/pom.xml
@@ -1,8 +1,5 @@
<?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">
<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>

Expand All @@ -22,7 +19,8 @@
<module>ui</module>
<module>features</module>
<module>tasklist-service</module>
</modules>
<module>angular-ui</module>
</modules>

<dependencies>
<dependency>
Expand Down Expand Up @@ -116,9 +114,13 @@
<artifactId>maven-bundle-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<_include>osgi.bnd</_include>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

</project>

</project>
1 change: 1 addition & 0 deletions tasklist-blueprint-cdi/tasklist-service/osgi.bnd
@@ -0,0 +1 @@
-dsannotations: *
10 changes: 0 additions & 10 deletions tasklist-blueprint-cdi/tasklist-service/pom.xml
Expand Up @@ -55,16 +55,6 @@
</scanPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.3</version>
<extensions>true</extensions>
<configuration>
<instructions>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -1,12 +1,15 @@
package net.lr.tasklist.service.impl;

import static java.util.Collections.singletonList;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;

import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.ext.logging.LoggingFeature;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;

@Singleton
Expand All @@ -25,6 +28,7 @@ public void create() {
factory.setAddress("/tasklistRest");
factory.setServiceBean(taskServiceRest);
factory.setBus(bus);
factory.setFeatures(singletonList(new LoggingFeature()));
server = factory.create();
server.start();
}
Expand Down
Empty file.

0 comments on commit eef7dda

Please sign in to comment.