1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.aludratest.service.cmdline.impl;
17
18 import org.aludratest.config.ConfigProperties;
19 import org.aludratest.config.Preferences;
20 import org.aludratest.exception.AutomationException;
21 import org.aludratest.service.AbstractConfigurableAludraService;
22 import org.aludratest.service.Implementation;
23 import org.aludratest.service.cmdline.CommandLineCondition;
24 import org.aludratest.service.cmdline.CommandLineInteraction;
25 import org.aludratest.service.cmdline.CommandLineService;
26 import org.aludratest.service.cmdline.CommandLineVerification;
27 import org.apache.commons.vfs2.FileSystemException;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31
32
33 @Implementation({ CommandLineService.class })
34 @ConfigProperties({})
35 public class CommandLineServiceImpl extends AbstractConfigurableAludraService implements CommandLineService {
36
37
38 private static final Logger LOGGER = LoggerFactory.getLogger(CommandLineServiceImpl.class);
39
40 private CommandLineActionImpl action;
41
42 private CommandLineServiceConfiguration configuration;
43
44
45
46 @Override
47 public String getDescription() {
48 return getClass().getSimpleName();
49 }
50
51
52
53 @Override
54 public String getPropertiesBaseName() {
55 return "commandLineService";
56 }
57
58 @Override
59 public void configure(Preferences preferences) throws AutomationException {
60 try {
61 configuration = new CommandLineServiceConfiguration(preferences);
62 }
63 catch (FileSystemException e) {
64 LOGGER.error("Error configuring FileService", e);
65 throw new AutomationException("Error initializing " + this, e);
66 }
67 }
68
69
70
71 @Override
72 public void initService() {
73 this.action = new CommandLineActionImpl(configuration);
74 }
75
76
77 @Override
78 public void close() {
79 this.configuration.close();
80 }
81
82
83
84 @Override
85 public CommandLineInteraction perform() {
86 return action;
87 }
88
89 @Override
90 public CommandLineVerification verify() {
91 return action;
92 }
93
94 @Override
95 public CommandLineCondition check() {
96 return action;
97 }
98
99 @Override
100 public String getBaseDirectory() {
101 return configuration.getBaseDirectory();
102 }
103
104 }