Skip to content

Commit

Permalink
configure by properties
Browse files Browse the repository at this point in the history
  • Loading branch information
saig0 committed Aug 18, 2017
1 parent 668de2d commit 8b0c58a
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 3 deletions.
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,30 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>io.zeebe.dmn.StandaloneDmnApplication</mainClass>
</manifest>
</archive>
<finalName>zeebe-dmn</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/io/zeebe/dmn/DmnApplication.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright © 2017 camunda services GmbH ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.zeebe.dmn;

import java.util.Properties;
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/io/zeebe/dmn/DmnRepository.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright © 2017 camunda services GmbH ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.zeebe.dmn;

import java.io.IOException;
Expand All @@ -15,7 +30,7 @@

public class DmnRepository
{
private final static Logger LOG = LoggerFactory.getLogger(DmnRepository.class);
private static final Logger LOG = LoggerFactory.getLogger(DmnRepository.class);

private final String directory;
private final DmnEngine dmnEngine;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/io/zeebe/dmn/DmnTaskWorker.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright © 2017 camunda services GmbH ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.zeebe.dmn;

import java.io.IOException;
Expand Down
57 changes: 55 additions & 2 deletions src/main/java/io/zeebe/dmn/StandaloneDmnApplication.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,78 @@
/*
* Copyright © 2017 camunda services GmbH ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.zeebe.dmn;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.Scanner;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class StandaloneDmnApplication
{
private static final Logger LOG = LoggerFactory.getLogger(StandaloneDmnApplication.class);

public static final String PROP_FILE = "application.properties";

public static final String REPO_DIR_PROP = "zeebe.dmn.repo";
public static final String TOPIC_PROP = "zeebe.dmn.topic";

private static final String DEFAULT_REPO_DIR = "repo";
private static final String DEFAULT_TOPIC = "default-topic";

public static void main(String[] args)
{
// TODO map args to client properties
final Properties properties = loadProperties();

final String repoDir = properties.getProperty(REPO_DIR_PROP, DEFAULT_REPO_DIR);
final String topic = properties.getProperty(TOPIC_PROP, DEFAULT_TOPIC);

final DmnApplication application = new DmnApplication(DEFAULT_REPO_DIR, DEFAULT_TOPIC);
final DmnApplication application = new DmnApplication(repoDir, topic);
application.start();

waitUntilClose();

application.close();
}

private static Properties loadProperties()
{
final Properties properties = new Properties();

try
{
final InputStream propertyStream = StandaloneDmnApplication.class.getResourceAsStream(PROP_FILE);
if (propertyStream != null)
{
properties.load(propertyStream);
}
else
{
LOG.debug("No configuration found '{}'. Use default values.", PROP_FILE);
}
}
catch (IOException e)
{
LOG.warn("Failed to read properties '{}'.", PROP_FILE, e);
}
return properties;
}

private static void waitUntilClose()
{
try (Scanner scanner = new Scanner(System.in))
Expand Down

0 comments on commit 8b0c58a

Please sign in to comment.