creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1462896 - in /creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles: Main.java NexusClient.java Platform.java Templates.java
Date Sun, 31 Mar 2013 08:16:48 GMT
Author: rdonkin
Date: Sun Mar 31 08:16:47 2013
New Revision: 1462896

URL: http://svn.apache.org/r1462896
Log:
Introduce parameter object to simplify constructors

Added:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Platform.java   (with
props)
Modified:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NexusClient.java
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java?rev=1462896&r1=1462895&r2=1462896&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java Sun Mar 31
08:16:47 2013
@@ -70,22 +70,22 @@ public class Main {
     private final Templates templates;
 
     public Main(final String... args) throws Exception {
-        this(new Configuration(args), new FileSystem(), new IOSystem());
+        this(new Configuration(args), Platform.aPlatform());
     }
 
-    public Main(final Configuration configuration, final FileSystem fileSystem,
-            final IOSystem ioSystem) throws Exception {
-        this(configuration, fileSystem, new NexusClient(fileSystem, ioSystem),
-                ioSystem, new Templates(ioSystem, new TentaclesResources()));
+    public Main(final Configuration configuration, final Platform platform)
+            throws Exception {
+        this(configuration, platform, new NexusClient(platform), new Templates(
+                platform));
     }
 
-    public Main(final Configuration configuration, final FileSystem fileSystem,
-            final NexusClient client, final IOSystem ioSystem,
-            final Templates templates) throws Exception {
+    public Main(final Configuration configuration, final Platform platform,
+            final NexusClient client, final Templates templates)
+            throws Exception {
         this.client = client;
         this.configuration = configuration;
-        this.fileSystem = fileSystem;
-        this.ioSystem = ioSystem;
+        this.fileSystem = platform.getFileSystem();
+        this.ioSystem = platform.getIoSystem();
         this.templates = templates;
 
         this.local =
@@ -107,7 +107,8 @@ public class Main {
 
         final URL style =
                 this.getClass().getClassLoader().getResource("legal/style.css");
-        ioSystem.copy(style.openStream(), new File(this.local, "style.css"));
+        this.ioSystem.copy(style.openStream(),
+                new File(this.local, "style.css"));
 
         licenses("asl-2.0");
         licenses("cpl-1.0");

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NexusClient.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NexusClient.java?rev=1462896&r1=1462895&r2=1462896&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NexusClient.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/NexusClient.java Sun
Mar 31 08:16:47 2013
@@ -39,10 +39,10 @@ public class NexusClient {
     private final FileSystem fileSystem;
     private final IOSystem ioSystem;
 
-    public NexusClient(final FileSystem fileSystem, final IOSystem ioSystem) {
+    public NexusClient(final Platform platform) {
         this.client = new DefaultHttpClient();
-        this.fileSystem = fileSystem;
-        this.ioSystem = ioSystem;
+        this.fileSystem = platform.getFileSystem();
+        this.ioSystem = platform.getIoSystem();
     }
 
     public File download(final URI uri, final File file) throws IOException {

Added: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Platform.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Platform.java?rev=1462896&view=auto
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Platform.java (added)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Platform.java Sun Mar
31 08:16:47 2013
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ *  to you 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 org.apache.creadur.tentacles;
+
+public class Platform {
+
+    public static Platform aPlatform() {
+        final FileSystem fileSystem = new FileSystem();
+        final IOSystem ioSystem = new IOSystem();
+        final TentaclesResources tentaclesResources = new TentaclesResources();
+        return new Platform(tentaclesResources, fileSystem, ioSystem);
+    }
+
+    private final TentaclesResources tentaclesResources;
+    private final FileSystem fileSystem;
+    private final IOSystem ioSystem;
+
+    public Platform(final TentaclesResources tentaclesResources,
+            final FileSystem fileSystem, final IOSystem ioSystem) {
+        super();
+        this.tentaclesResources = tentaclesResources;
+        this.fileSystem = fileSystem;
+        this.ioSystem = ioSystem;
+    }
+
+    public TentaclesResources getTentaclesResources() {
+        return this.tentaclesResources;
+    }
+
+    public FileSystem getFileSystem() {
+        return this.fileSystem;
+    }
+
+    public IOSystem getIoSystem() {
+        return this.ioSystem;
+    }
+
+}

Propchange: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Platform.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java?rev=1462896&r1=1462895&r2=1462896&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java Sun
Mar 31 08:16:47 2013
@@ -27,10 +27,9 @@ public final class Templates {
     private final VelocityEngine engine;
     private final TentaclesResources tentaclesResources;
 
-    public Templates(final IOSystem ioSystem,
-            final TentaclesResources tentaclesResources) {
-        this.ioSystem = ioSystem;
-        this.tentaclesResources = tentaclesResources;
+    public Templates(final Platform platform) {
+        this.ioSystem = platform.getIoSystem();
+        this.tentaclesResources = platform.getTentaclesResources();
         final Properties properties = new Properties();
         properties.setProperty("file.resource.loader.cache", "true");
         properties.setProperty("resource.loader", "file, class");



Mime
View raw message