public RemoteServer(final int tries, final boolean verbose) { this.tries = (tries < 1 ? 1 : (tries > 3600 ? 3600 : tries)); //Wait at least 1 second to start or stop, but not more than an hour. this.verbose = verbose; home = getHome(); tomcat = (home != null) && (new File(new File(home, "bin"), "catalina.sh").exists()); portShutdown = options.get(SERVER_SHUTDOWN_PORT, tomcat ? 8005 : 4200); portStartup = portShutdown; command = options.get(SERVER_SHUTDOWN_COMMAND, "SHUTDOWN"); host = options.get(SERVER_SHUTDOWN_HOST, "localhost"); connectTimeout = options.get(SOCKET_TIMEOUT, 1000); }
public RemoteServer(final int tries, final boolean verbose) { this.tries = (tries < 1 ? 1 : (tries > 3600 ? 3600 : tries)); //Wait at least 1 second to start or stop, but not more than an hour. this.verbose = verbose; home = getHome(); tomcat = (home != null) && (new File(new File(home, "bin"), "catalina.sh").exists()); portShutdown = options.get(SERVER_SHUTDOWN_PORT, tomcat ? 8005 : 4200); portStartup = portShutdown; command = options.get(SERVER_SHUTDOWN_COMMAND, "SHUTDOWN"); host = options.get(SERVER_SHUTDOWN_HOST, "localhost"); }
public int get(final String property, final int defaultValue) { final String value = properties.getProperty(property); if (value == null || value.equals("")) { return parent.get(property, defaultValue); } try { return log(property, Integer.parseInt(value)); } catch (final NumberFormatException e) { warn(property, value, e); return parent.get(property, defaultValue); } }
public boolean get(final String property, final boolean defaultValue) { final String value = properties.getProperty(property); if (value == null || value.equals("")) { return parent.get(property, defaultValue); } try { return log(property, Boolean.parseBoolean(value)); } catch (final NumberFormatException e) { warn(property, value, e); return parent.get(property, defaultValue); } }
public static PermissionCollection getPermissionCollection() { try { return (PermissionCollection) DelegatePermissionCollection.class.getClassLoader() .loadClass( SystemInstance.get().getOptions().get(PERMISSION_COLLECTION_CLASS, FastPermissionCollection.class.getName())) .newInstance(); } catch (final Exception cnfe) { // return new Permissions(); // the jdk implementation, it seems slow at least for startup up return new FastPermissionCollection(); } }
private void doShutdownExecutor(final boolean waitJobs) { final ThreadPoolExecutor tpe = (ThreadPoolExecutor) executor; tpe.shutdown(); if (waitJobs) { final int timeout = SystemInstance.get().getOptions().get(OPENEJB_EJB_TIMER_POOL_AWAIT_SECONDS, 5); try { tpe.awaitTermination(timeout, TimeUnit.SECONDS); } catch (final InterruptedException e) { logger.error(e.getMessage(), e); } } }
public Log4jLogStreamFactory() { try { final boolean externalLogging = SystemInstance.get().getOptions().get("openejb.logger.external", false); if (!externalLogging) { configureInternal(); } } catch (final Exception e) { // The fall back here is that if log4j.configuration system property is set, then that configuration file will be used. e.printStackTrace(); } System.setProperty("openwebbeans.logging.factory", "org.apache.openejb.cdi.logging.Log4jLoggerFactory"); }
@SuppressWarnings("UseOfObsoleteCollectionType") public LocalInitialContext(final Hashtable env, final LocalInitialContextFactory factory) throws NamingException { super(getContainerSystemEjbContext()); properties = new Properties(); properties.putAll(env); options = new Options(properties); onClose = options.get(ON_CLOSE, Close.LOGOUT); this.factory = factory; login(); startNetworkServices(); }
@SuppressWarnings("UseOfObsoleteCollectionType") public LocalInitialContext(final Hashtable env, final LocalInitialContextFactory factory) throws NamingException { super(getContainerSystemEjbContext()); properties = new Properties(); properties.putAll(env); options = new Options(properties); onClose = options.get(ON_CLOSE, Close.LOGOUT); this.factory = factory; login(); startNetworkServices(); }
public AutoDeployer(final ConfigurationFactory factory, final List<Deployments> deployments) { final Options options = SystemInstance.get().getOptions(); final Duration interval = options.get("openejb.autodeploy.interval", new Duration(2, TimeUnit.SECONDS)); if (interval.getUnit() == null) { interval.setUnit(TimeUnit.SECONDS); } this.factory = factory; this.deployments.addAll(deployments); this.pollIntervalMillis = interval.getUnit().toMillis(interval.getTime()); this.timer = new Timer(this.getClass().getSimpleName(), true); }
public EjbTimerServiceImpl(final BeanContext deployment, final TransactionManager transactionManager, final TimerStore timerStore, final int retryAttempts) { this.deployment = deployment; this.transactionManager = transactionManager; this.timerStore = timerStore; final TransactionType transactionType = deployment.getTransactionType(deployment.getEjbTimeout()); this.transacted = transactionType == TransactionType.Required || transactionType == TransactionType.RequiresNew; this.retryAttempts = retryAttempts; if (retryAttempts < 0) { this.retryAttempts = deployment.getOptions().get(EJB_TIMER_RETRY_ATTEMPTS, 1); } }
public EjbTimerServiceImpl(final BeanContext deployment, final TransactionManager transactionManager, final TimerStore timerStore, final int retryAttempts) { this.deployment = deployment; this.transactionManager = transactionManager; this.timerStore = timerStore; final TransactionType transactionType = deployment.getTransactionType(deployment.getEjbTimeout()); this.transacted = transactionType == TransactionType.Required || transactionType == TransactionType.RequiresNew; this.retryAttempts = retryAttempts; if (retryAttempts < 0) { this.retryAttempts = deployment.getOptions().get(EJB_TIMER_RETRY_ATTEMPTS, 1); } }
private void startNetworkServices() { if (!options.get(OPENEJB_EMBEDDED_REMOTABLE, false)) { return; } try { serviceManager = new ServiceManagerProxy(); serviceManager.start(); } catch (ServiceManagerProxy.AlreadyStartedException e) { logger.debug("Network services already started. Ignoring option " + OPENEJB_EMBEDDED_REMOTABLE); } }
public boolean start() { if (!connect()) { forkServerProcess(); final int port = SystemInstance.get().getOptions().get("ejbd.port", 4201); return Connect.connect(10, "localhost", port); } else { System.out.println(":: server already started ::"); return true; } }
private Duration getDuration(final Options options, final String property, final Duration defaultValue, final TimeUnit defaultUnit) { final String s = options.get(property, defaultValue.toString()); final Duration duration = new Duration(s); if (duration.getUnit() == null) { duration.setUnit(defaultUnit); } return duration; }
private static String getAltDD() { final String property = "openejb.altdd.prefix"; if (SystemInstance.isInitialized()) { return SystemInstance.get().getOptions().get(property, (String) null); } return JavaSecurityManagers.getSystemProperty(property); }
private String getProperty(final String key, final String defaultValue) { String value = SystemInstance.get().getOptions().get(key, defaultValue); final DeploymentModule module = getModule(); if (module instanceof EjbModule) { final EjbModule ejbModule = (EjbModule) module; final OpenejbJar openejbJar = ejbModule.getOpenejbJar(); if (openejbJar != null && openejbJar.getProperties() != null) { value = openejbJar.getProperties().getProperty(key, value); } } return value; }
public AppModule deploy(final AppModule appModule) throws OpenEJBException { final AppValidator validator; if (!SystemInstance.get().getOptions().get(OPENEJB_CHECK_CLASSLOADER, false)) { validator = new AppValidator(); } else { validator = new AppValidator(new CheckClassLoading()); } return validator.validate(appModule); }
public AnnotationDeployer() { discoverAnnotatedBeans = new DiscoverAnnotatedBeans(); processAnnotatedBeans = new ProcessAnnotatedBeans(SystemInstance.get().getOptions().get("openejb.jaxws.add-remote", false)); builtInEnvironmentEntries = new BuiltInEnvironmentEntries(); envEntriesPropertiesDeployer = new EnvEntriesPropertiesDeployer(); mBeanDeployer = new MBeanDeployer(); mergeWebappJndiContext = new MergeWebappJndiContext(); }