001: /**
002: * EasyBeans
003: * Copyright (C) 2006-2007 Bull S.A.S.
004: * Contact: easybeans@ow2.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: ServerConfig.java 2137 2007-12-10 18:26:53Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.server;
025:
026: import java.io.File;
027: import java.util.ArrayList;
028: import java.util.List;
029:
030: /**
031: * Defines a configuration class that can be used to start the embedded EJB3 server.
032: * @author Florent Benoit
033: */
034: public class ServerConfig {
035:
036: /**
037: * List of path to lookup for deploying modules.
038: */
039: private List<File> deployDirectories = null;
040:
041: /**
042: * Wait at the end of the start.
043: */
044: private boolean shouldWait = true;
045:
046: /**
047: * Init JACC at startup ?
048: */
049: private boolean initJACC = true;
050:
051: /**
052: * Old deployer.
053: */
054: private static final String OLD_DEPLOYER = "org.ow2.easybeans.olddeployer";
055:
056: /**
057: * Use of MBeans.
058: */
059: private boolean useMBeans = true;
060:
061: /**
062: * Start the JMX connector ?
063: */
064: private boolean startJMXConnector = true;
065:
066: /**
067: * use EasyBeans naming mechanism or one of the embedded server.
068: */
069: private boolean useNaming = true;
070:
071: /**
072: * List of configuration extensions instances.
073: */
074: private List<EasyBeansConfigurationExtension> extensionFactories = null;
075:
076: /**
077: * Is the Directory scanning activated.
078: */
079: private boolean directoryScanningEnabled = true;
080:
081: /**
082: * Add the ejb container components at startup ? (true by default)
083: */
084: private boolean addEmbeddedComponents = true;
085:
086: /**
087: * Register the EasyBeans deployer MBean ?
088: */
089: private boolean registerDeployerMBean = true;
090:
091: /**
092: * Register the J2EEServer MBean ? (it shouldn't be bound if it is linked to another server)
093: */
094: private boolean registerJ2EEServerMBean = true;
095:
096: /**
097: * Auto configure components (by intializing them and starting them).
098: * Should be disable if components are started independently.
099: */
100: private boolean autoConfigureComponents = true;
101:
102: /**
103: * Constructor.
104: */
105: public ServerConfig() {
106: this .deployDirectories = new ArrayList<File>();
107: this .extensionFactories = new ArrayList<EasyBeansConfigurationExtension>();
108: }
109:
110: /**
111: * @return the list of path for loading/looking Java EE modules.
112: */
113: public List<File> getDeployDirectories() {
114: return deployDirectories;
115: }
116:
117: /**
118: * Sets the list of path for loading/looking Java EE modules.
119: * @param deployDirectories the list of path for loading/looking Java EE modules.
120: */
121: public void setDeployDirectories(final List<File> deployDirectories) {
122: this .deployDirectories = deployDirectories;
123: }
124:
125: /**
126: * Add a directory to the list of path for loading/looking Java EE modules.
127: * @param deployDirectory a path for loading/looking Java EE modules.
128: */
129: public void addDeployDirectory(final File deployDirectory) {
130: deployDirectories.add(deployDirectory);
131: }
132:
133: /**
134: * @return true if the server should wait when starting embedded server.
135: */
136: public boolean shouldWait() {
137: return shouldWait;
138: }
139:
140: /**
141: * Sets if the server will loop at the end of it's startup.
142: * @param shouldWait true/false
143: */
144: public void setShouldWait(final boolean shouldWait) {
145: this .shouldWait = shouldWait;
146: }
147:
148: /**
149: * Use or not the MBeans.
150: * @return true if this is the case.
151: */
152: public boolean isUsingMBeans() {
153: return useMBeans;
154: }
155:
156: /**
157: * Sets the value for using MBeans.
158: * @param useMBeans the boolean value.
159: */
160: public void setUseMBeans(final boolean useMBeans) {
161: this .useMBeans = useMBeans;
162: }
163:
164: /**
165: * Use or not the EasyBeans naming system.
166: * @return true if this is the case.
167: */
168: public boolean isUsingNaming() {
169: return useNaming;
170: }
171:
172: /**
173: * Sets the value for using the EasyBeans naming system.
174: * @param useNaming the boolean value.
175: */
176: public void setUseNaming(final boolean useNaming) {
177: this .useNaming = useNaming;
178: }
179:
180: /**
181: * Adds an {@link EasyBeansConfigurationExtension} in the Facory list.
182: * @param extension the factory FQN.
183: */
184: public void addExtensionFactory(
185: final EasyBeansConfigurationExtension extension) {
186: this .extensionFactories.add(extension);
187: }
188:
189: /**
190: * @return Returns the list of {@link EasyBeansConfigurationExtension}.
191: */
192: public List<EasyBeansConfigurationExtension> getExtensionFactories() {
193: return this .extensionFactories;
194: }
195:
196: /**
197: * @return the directoryScanningEnabled
198: */
199: public boolean isDirectoryScanningEnabled() {
200: return directoryScanningEnabled;
201: }
202:
203: /**
204: * @param directoryScanningEnabled the directoryScanningEnabled to set
205: */
206: public void setDirectoryScanningEnabled(
207: final boolean directoryScanningEnabled) {
208: this .directoryScanningEnabled = directoryScanningEnabled;
209: }
210:
211: /**
212: * Init or not JACC at startup.
213: * @param initJACC initialization of JACC provider.
214: */
215: public void setInitJACC(final boolean initJACC) {
216: this .initJACC = initJACC;
217: }
218:
219: /**
220: * @return true if JACC provider needs to be initialized at startup.
221: */
222: public boolean initJACC() {
223: return initJACC;
224: }
225:
226: /**
227: * Sets the flag for adding before the startup the core components.
228: * @param addEmbeddedComponents the boolean value
229: */
230: public void setAddEmbeddedComponents(
231: final boolean addEmbeddedComponents) {
232: this .addEmbeddedComponents = addEmbeddedComponents;
233: }
234:
235: /**
236: * @return true if the core components need to be added before the startup of Embedded.
237: */
238: public boolean addEmbeddedComponents() {
239: return addEmbeddedComponents;
240: }
241:
242: /**
243: * @return true if the system property is set for using old deployer.
244: */
245: public boolean isUsingOldDeployer() {
246: String oldDeployer = System.getProperty(OLD_DEPLOYER, "false");
247: return Boolean.parseBoolean(oldDeployer);
248: }
249:
250: /**
251: * @return true if EasyBeans will start the JMX connector.
252: */
253: public boolean isStartJMXConnector() {
254: return startJMXConnector;
255: }
256:
257: /**
258: * Enable or disable the JMX connector.
259: * @param startJMXConnector true/false.
260: */
261: public void setStartJMXConnector(final boolean startJMXConnector) {
262: this .startJMXConnector = startJMXConnector;
263: }
264:
265: /**
266: * @return true if Deployer needs to be registered.
267: */
268: public boolean isRegisterDeployerMBean() {
269: return registerDeployerMBean;
270: }
271:
272: /**
273: * Enable or disable the Deployer MBean.
274: * @param registerDeployerMBean true/false.
275: */
276: public void setRegisterDeployerMBean(
277: final boolean registerDeployerMBean) {
278: this .registerDeployerMBean = registerDeployerMBean;
279: }
280:
281: /**
282: * @return true if Deployer needs to be registered.
283: */
284: public boolean isRegisterJ2EEServerMBean() {
285: return registerJ2EEServerMBean;
286: }
287:
288: /**
289: * Enable or disable the J2EEServer MBean.
290: * @param registerJ2EEServerMBean true/false.
291: */
292: public void setRegisterJ2EEServerMBean(
293: final boolean registerJ2EEServerMBean) {
294: this .registerJ2EEServerMBean = registerJ2EEServerMBean;
295: }
296:
297: /**
298: * @return true if components are managed by EasyBeans and not externally.
299: */
300: public boolean isAutoConfigureComponents() {
301: return autoConfigureComponents;
302: }
303:
304: /**
305: * Sets the flag for managing components in EasyBeans.
306: * @param autoConfigureComponents if true, managed by EasyBeans
307: */
308: public void setAutoConfigureComponents(
309: final boolean autoConfigureComponents) {
310: this.autoConfigureComponents = autoConfigureComponents;
311: }
312: }
|