001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.process;
016    
017    import java.io.Serializable;
018    
019    import java.util.Collections;
020    import java.util.List;
021    
022    /**
023     * @author Shuyang Zhou
024     */
025    public class ProcessConfig implements Serializable {
026    
027            public List<String> getArguments() {
028                    return _arguments;
029            }
030    
031            public String getBootstrapClassPath() {
032                    return _bootstrapClassPath;
033            }
034    
035            public String getJavaExecutable() {
036                    return _javaExecutable;
037            }
038    
039            public ClassLoader getReactClassLoader() {
040                    return _reactClassLoader;
041            }
042    
043            public String getRuntimeClassPath() {
044                    return _runtimeClassPath;
045            }
046    
047            public static class Builder {
048    
049                    public ProcessConfig build() {
050                            return new ProcessConfig(this);
051                    }
052    
053                    public Builder setArguments(List<String> arguments) {
054                            _arguments = arguments;
055    
056                            return this;
057                    }
058    
059                    public Builder setBootstrapClassPath(String bootstrapClassPath) {
060                            _bootstrapClassPath = bootstrapClassPath;
061    
062                            return this;
063                    }
064    
065                    public Builder setJavaExecutable(String javaExecutable) {
066                            _javaExecutable = javaExecutable;
067    
068                            return this;
069                    }
070    
071                    public Builder setReactClassLoader(ClassLoader reactClassLoader) {
072                            _reactClassLoader = reactClassLoader;
073    
074                            return this;
075                    }
076    
077                    public Builder setRuntimeClassPath(String runtimeClassPath) {
078                            _runtimeClassPath = runtimeClassPath;
079    
080                            return this;
081                    }
082    
083                    private List<String> _arguments = Collections.emptyList();
084                    private String _bootstrapClassPath = System.getProperty(
085                            "java.class.path");
086                    private String _javaExecutable = "java";
087                    private ClassLoader _reactClassLoader =
088                            ProcessConfig.class.getClassLoader();
089                    private String _runtimeClassPath = _bootstrapClassPath;
090    
091            }
092    
093            private ProcessConfig(Builder builder) {
094                    _arguments = builder._arguments;
095                    _bootstrapClassPath = builder._bootstrapClassPath;
096                    _javaExecutable = builder._javaExecutable;
097                    _reactClassLoader = builder._reactClassLoader;
098                    _runtimeClassPath = builder._runtimeClassPath;
099            }
100    
101            private static final long serialVersionUID = 1L;
102    
103            private final List<String> _arguments;
104            private final String _bootstrapClassPath;
105            private final String _javaExecutable;
106            private final transient ClassLoader _reactClassLoader;
107            private final String _runtimeClassPath;
108    
109    }