public FileUtils getBase() { if (!isInitialized()) { return new FileUtils("openejb.base", "openejb.home", System.getProperties()); } return base; }
public FileUtils getHome() { if (!isInitialized()) { return new FileUtils("openejb.home", "user.dir", System.getProperties()); } return home; }
public FileUtils getHome() { if (!isInitialized()) { return new FileUtils("openejb.home", "user.dir", System.getProperties()); } return home; }
public FileUtils getBase() { if (!isInitialized()) { return new FileUtils("openejb.base", "openejb.home", System.getProperties()); } return base; }
protected static String autoJaccProvider() { return SystemInstance.isInitialized() ? SystemInstance.get().getProperty(JaccProvider.class.getName(), BasicJaccProvider.class.getName()) : BasicJaccProvider.class.getName(); }
@Override public void init(final FilterConfig filterConfig) throws ServletException { final SystemInstance si = SystemInstance.isInitialized() ? SystemInstance.get() : null; final Properties config = si != null ? si.getProperties() : System.getProperties(); securityService = si != null ? si.getComponent(SecurityService.class) : null; active = Boolean.parseBoolean(config.getProperty("tomee.http.request.wrap", "true")); }
private static Properties properties() { if (SystemInstance.isInitialized()) { return SystemInstance.get().getProperties(); } else { // try to read manually the conf/system.properties final String catalinaBase = System.getProperty("catalina.base"); if (catalinaBase != null) { final File sysProp = new File(catalinaBase, "conf/system.properties"); if (sysProp.exists() && sysProp.isFile()) { final Properties properties; try { properties = IO.readProperties(sysProp); } catch (final IOException e) { throw new IllegalStateException(e); } properties.putAll(System.getProperties()); // make sure System properties always override return properties; } } return System.getProperties(); } }
private static String getAltDD() { final String property = "openejb.altdd.prefix"; if (SystemInstance.isInitialized()) { return SystemInstance.get().getOptions().get(property, (String) null); } return System.getProperty(property); }
public static ClassLoader get() { final ParentClassLoaderFinder parentFinder = SystemInstance.isInitialized() ? SystemInstance.get().getComponent(ParentClassLoaderFinder.class) : null; if (parentFinder != null) { return parentFinder.getParentClassLoader(FALLBACK); } return FALLBACK; } }
public static ClassLoader get() { final ParentClassLoaderFinder parentFinder = SystemInstance.isInitialized() ? SystemInstance.get().getComponent(ParentClassLoaderFinder.class) : null; if (parentFinder != null) { return parentFinder.getParentClassLoader(FALLBACK); } return FALLBACK; } }
public ProvisioningResolver() { resolvers.put("mvn", new MavenResolver()); resolvers.put("http", new HttpResolver()); resolvers.put("https", new HttpResolver()); if (SystemInstance.isInitialized()) { final String userOnes = SystemInstance.get().getProperty("openejb.provisinig.archive-resolvers"); if (userOnes != null) { for (final String u : userOnes.split(" *, *")) { final String c = u.trim(); if (!c.isEmpty()) { continue; } try { final ArchiveResolver instance = ArchiveResolver.class.cast(ProvisioningResolver.class.getClassLoader().loadClass(c)); addResolver(instance); } catch (final ClassNotFoundException e) { throw new IllegalArgumentException(e); } } } SystemInstance.get().fireEvent(new ProvisiningResolverCreated(this)); } for (final ArchiveResolver ar : resolvers.values()) { if (ProvisioningResolverAware.class.isInstance(ar)) { ProvisioningResolverAware.class.cast(ar).setResolver(this); } } }
private static UserDatabase readFromFile() { final MemoryUserDatabase database = new MemoryUserDatabase("UserMemoryDatabase"); database.setReadonly(false); final String property = SystemInstance.isInitialized() ? SystemInstance.get().getProperty("tribe.security.UserMemoryDatabase.pathname", System.getProperty("tomitribe.UserMemoryDatabase.pathname")) : System.getProperty("tomitribe.UserMemoryDatabase.pathname"); if (property != null) { database.setPathname(property); } // else keep default try { database.open(); } catch (final Exception e) { throw new IllegalStateException(e); } return database; }
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); }
@Override public String getProperty(final String name) { final String parentValue = super.getProperty(name); if (SystemInstance.isInitialized()) { if (SystemInstance.get().getProperties().containsKey(name)) { return SystemInstance.get().getProperty(name); } final String propertyKeyValue = "logging" + reverseProperty(name); if (SystemInstance.get().getProperties().containsKey(propertyKeyValue)) { return SystemInstance.get().getProperty(propertyKeyValue); } } // if it is one of ours loggers and no value is defined let set our nice logging style if (OpenEJBLogManager.class.getName().equals(System.getProperty("java.util.logging.manager")) // custom logging && isOverridableLogger(name) // managed loggers && parentValue == null) { // not already defined if (name.endsWith(".handlers")) { return consoleHandlerClazz; } else if (name.endsWith(".useParentHandlers")) { return "false"; } } return parentValue; } }
public static synchronized void configure() { configure(SystemInstance.isInitialized() ? SystemInstance.get().getProperties() : JavaSecurityManagers.getSystemProperties()); }
@Override public String getProperty(final String name) { final String parentValue = super.getProperty(name); if (SystemInstance.isInitialized()) { if (SystemInstance.get().getProperties().containsKey(name)) { return SystemInstance.get().getProperty(name); } final String propertyKeyValue = "logging" + reverseProperty(name); if (SystemInstance.get().getProperties().containsKey(propertyKeyValue)) { return SystemInstance.get().getProperty(propertyKeyValue); } } // if it is one of ours loggers and no value is defined let set our nice logging style if (OpenEJBLogManager.class.getName().equals(JavaSecurityManagers.getSystemProperty("java.util.logging.manager")) // custom logging && isOverridableLogger(name) // managed loggers && parentValue == null) { // not already defined if (name.endsWith(".handlers")) { return consoleHandlerClazz; } else if (name.endsWith(".useParentHandlers")) { return "false"; } } return parentValue; } }
public static Set<String> realLocation(final String location) { final boolean initialized = SystemInstance.isInitialized(); if (!initialized) { if (DEFAULT_PROVISIONING_RESOLVER == null) { synchronized (ProvisioningUtil.class) { if (DEFAULT_PROVISIONING_RESOLVER == null) { DEFAULT_PROVISIONING_RESOLVER = new ProvisioningResolver(); } } } return DEFAULT_PROVISIONING_RESOLVER.realLocation(location); } return SystemInstance.get().getComponent(ProvisioningResolver.class).realLocation(location); } }
public void release(@Observes final EventContext<BeforeUnDeploy> event) { if (!SystemInstance.isInitialized()) { event.proceed(); return; } try { event.proceed(); } finally { final BeanContext bc = beanContext(); if (bc != null) { // can be null if deployment exception final CreationalContext<?> cc = bc.get(CreationalContext.class); if (cc != null) { cc.release(); } } } }
public void observes(@Observes final EventContext<TestEvent> event) { if (!SystemInstance.isInitialized()) { event.proceed(); return; } final BeanContext context = beanContext(); ThreadContext oldCtx = null; ClassLoader oldCl = null; if (context != null) { oldCtx = ThreadContext.enter(new ThreadContext(context, null)); } else { oldCl = Thread.currentThread().getContextClassLoader(); if (classLoader.get() != null) { setTCCL(classLoader.get()); } } try { event.proceed(); } finally { if (context != null) { ThreadContext.exit(oldCtx); } else { setTCCL(oldCl); } } }
@Override public void enrich(final Object testInstance) { if (!SystemInstance.isInitialized()) { return; } new MockitoEnricher().enrich(testInstance); final AppContext context = appContext.get(); if (context != null) { OpenEJBEnricher.enrich(testInstance, context); } else { // try to enrich with all for deployment at startup feature - only once context can be used in a class final List<AppContext> appContexts = SystemInstance.get().getComponent(ContainerSystem.class).getAppContexts(); final Class<?> clazz = testInstance.getClass(); for (final AppContext appContext : appContexts) { try { final BeanManager bm = appContext.getWebBeansContext().getBeanManagerImpl(); final AnnotatedType<?> at = bm.createAnnotatedType(clazz); bm.createInjectionTarget(at); final CreationalContext<Object> cc = bm.createCreationalContext(null); OWBInjector.inject(bm, testInstance, cc); cc.release(); } catch (final Exception e) { // no-op } } } }