Skip to content

Commit

Permalink
Poc deployer with some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alagane committed Jan 10, 2019
1 parent 68603e0 commit 86f002e
Show file tree
Hide file tree
Showing 53 changed files with 3,240 additions and 1,230 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ local.properties

### Maven ###
target/
report/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
Expand Down
17 changes: 17 additions & 0 deletions COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

Copyright (c) 2018-2019 Linagora

This program/library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 of the License, or (at your
option) any later version.

This program/library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program/library; If not, see http://www.gnu.org/licenses/
for the GNU Lesser General Public License version 2.1.

657 changes: 497 additions & 160 deletions LICENSE

Large diffs are not rendered by default.

132 changes: 117 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,122 @@
<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>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2018-2019 Linagora
This program/library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 of the License, or (at your
option) any later version.
This program/library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program/library; If not, see http://www.gnu.org/licenses/
for the GNU Lesser General Public License version 2.1.
-->
<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>

<groupId>org.ow2.petals</groupId>
<artifactId>petals-esb-deployer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.ow2.petals</groupId>
<artifactId>petals-client-tools-parent</artifactId>
<version>1.1.1-SNAPSHOT</version>
</parent>

<name>petals-esb-deployer</name>
<url>https://doc.petalslink.com/display/petalscomponents/Petals+ESB+Deployer+1.0.0</url>
<groupId>org.ow2.petals</groupId>
<artifactId>petals-esb-deployer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<name>petals-esb-deployer</name>
<url>https://doc.petalslink.com/display/petalscomponents/Petals+ESB+Deployer+1.0.0</url>

<dependencies>
</dependencies>
<dependencies>
<dependency>
<groupId>org.ow2.petals</groupId>
<artifactId>petals-admin-api</artifactId>
<version>2.1.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.ow2.petals</groupId>
<artifactId>petals-admin-mock</artifactId>
<version>2.1.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.ow2.petals</groupId>
<artifactId>petals-jbi-descriptor</artifactId>
<version>2.4.0</version>
</dependency>

<!-- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency> -->

<!-- <dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency> -->

<!-- <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.7</version>
</dependency> -->

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>

<!-- <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.0</version>
</dependency> -->

<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>0.11.1</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<configuration>
<schemaDirectory>${basedir}/src/main/resources/</schemaDirectory>
<schemaIncludes>
<include>topology-model.xsd</include>
<include>component-repository.xsd</include>
<include>service-unit-model.xsd</include>
<include>bus-model.xsd</include>
<include>model.xsd</include>
</schemaIncludes>
<bindingIncludes>
<include>binding.xjb</include>
</bindingIncludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) 2018-2019 Linagora
*
* This program/library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*
* This program/library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/

package org.ow2.petals.deployer.runtimemodel;

import java.net.URL;

public class RuntimeComponent {
private final String id;

private URL url;

public RuntimeComponent(final String id) {
this.id = id;
}

public RuntimeComponent(final String id, final URL url) {
this(id);
this.url = url;
}

public String getId() {
return id;
}

public URL getUrl() {
return url;
}

public void setUrl(final URL url) {
this.url = url;
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof RuntimeComponent)) {
return false;
}

return id.equals(((RuntimeComponent) obj).id);
}

@Override
public int hashCode() {
return id.hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/**
* Copyright (c) 2018-2019 Linagora
*
* This program/library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*
* This program/library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/

package org.ow2.petals.deployer.runtimemodel;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.ow2.petals.deployer.runtimemodel.RuntimeModel.RuntimeModelException;

public class RuntimeContainer {

private final String id;

private int port;

private String user;

private String password;

private String hostname;

private Map<String, RuntimeServiceUnit> serviceUnits = new HashMap<String, RuntimeServiceUnit>();

private Map<String, RuntimeComponent> components = new HashMap<String, RuntimeComponent>();

public RuntimeContainer(final String id, final int port, final String user, final String password,
final String hostname) {
this.id = id;
this.port = port;
this.user = user;
this.password = password;
this.hostname = hostname;
}

public String getId() {
return id;
}

public int getPort() {
return port;
}

public String getUser() {
return user;
}

public String getPassword() {
return password;
}

public String getHostname() {
return hostname;
}

public void setHostname(final String hostname) {
this.hostname = hostname;
}

public RuntimeServiceUnit getServiceUnit(final String id) {
return serviceUnits.get(id);
}

public void addServiceUnit(final RuntimeServiceUnit serviceUnit) throws RuntimeModelException {
if (serviceUnits.put(serviceUnit.getId(), serviceUnit) != null) {
throw new RuntimeModelException("Service unit " + serviceUnit.getId() + " is already in the list");
}
}

public Collection<RuntimeServiceUnit> getServiceUnits() {
return serviceUnits.values();
}

public void addComponent(final RuntimeComponent component) throws RuntimeModelException {
if (components.put(component.getId(), component) != null) {
throw new RuntimeModelException("Component " + component.getId() + " is already in the list");
}
}

public RuntimeComponent getComponent(final String id) {
return components.get(id);
}

public Collection<RuntimeComponent> getComponents() {
return components.values();
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof RuntimeContainer)) {
return false;
}

return id.equals(((RuntimeContainer) obj).id);
}

@Override
public int hashCode() {
return id.hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2018-2019 Linagora
*
* This program/library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 2.1 of the License, or (at your
* option) any later version.
*
* This program/library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program/library; If not, see http://www.gnu.org/licenses/
* for the GNU Lesser General Public License version 2.1.
*/

package org.ow2.petals.deployer.runtimemodel;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class RuntimeModel {

private Map<String, RuntimeContainer> containers = new HashMap<String, RuntimeContainer>();

public void addContainer(final RuntimeContainer container) throws RuntimeModelException {
if (containers.put(container.getId(), container) != null) {
throw new RuntimeModelException("Container " + container.getId() + " is already in the list");
}
}

public RuntimeContainer getContainer(final String id) {
return containers.get(id);
}

public Collection<RuntimeContainer> getContainers() {
return containers.values();
}

public static class RuntimeModelException extends Exception {
private static final long serialVersionUID = -4775138643228668670L;

public RuntimeModelException(String message) {
super(message);
}
}
}
Loading

0 comments on commit 86f002e

Please sign in to comment.