public static void addExtensions(final ClassLoader loader, final Collection<String> classes) { for (final String clazz : classes) { try { final Object object = loader.loadClass(clazz).getConstructor().newInstance(); SystemInstance.get().addObserver(object); } catch (final Throwable t) { LOGGER.error("Extension construction failed" + clazz, t); } } }
public static void addExtensions(final Collection<Class<?>> classes) { for (final Class<?> clazz : classes) { try { final Object object = clazz.getConstructor().newInstance(); SystemInstance.get().addObserver(object); } catch (final Throwable t) { LOGGER.error("Extension construction failed" + clazz.getName(), t); } } }
public static void addExtensions(final ClassLoader loader, final Collection<String> classes) { for (final String clazz : classes) { try { final Object object = loader.loadClass(clazz).newInstance(); SystemInstance.get().addObserver(object); } catch (final Throwable t) { LOGGER.error("Extension construction failed" + clazz, t); } } }
public static void addExtensions(final Collection<Class<?>> classes) { for (final Class<?> clazz : classes) { try { final Object object = clazz.newInstance(); SystemInstance.get().addObserver(object); } catch (final Throwable t) { LOGGER.error("Extension construction failed" + clazz.getName(), t); } } }
public void addDeploymentListener(final DeploymentListener deploymentListener) { final ReentrantLock l = lock; l.lock(); try { logger.warning("DeploymentListener API is replaced by @Observes event"); SystemInstance.get().addObserver(new DeploymentListenerObserver(deploymentListener)); } finally { l.unlock(); } }
public void addDeploymentListener(final DeploymentListener deploymentListener) { final ReentrantLock l = lock; l.lock(); try { logger.warning("DeploymentListener API is replaced by @Observes event"); SystemInstance.get().addObserver(new DeploymentListenerObserver(deploymentListener)); } finally { l.unlock(); } }
protected void init() throws NamingException { final SystemInstance systemInstance = SystemInstance.get(); configuration = Tribestream.class.cast( systemInstance.getComponent(ContainerSystem.class).getJNDIContext().lookup( Assembler.OPENEJB_RESOURCE_JNDI_PREFIX + systemInstance.getComponent(OpenEjbConfiguration.class).facilities.resources.stream() .filter(t -> Tribestream.class.getName().equals(t.className)) .findFirst() .orElseThrow(() -> new IllegalStateException( "No tribestream configuration, configure in tomee.xml a resource like:\n" + "<Resource id=\"tribestream\" class-name=\"" + Tribestream.class.getName() + "\">\n" + " cassandraAuthorities=cassandra1.company.com:9160,cassandra2.company.com:9160\n" + "</Resource>")) .id)); if (!configuration.isSkip()) { systemInstance.addObserver(this); } }
public void createService(final ServiceInfo serviceInfo) throws OpenEJBException { final ObjectRecipe serviceRecipe = createRecipe(Collections.<ServiceInfo>emptyList(), serviceInfo); serviceRecipe.setProperty("properties", new UnsetPropertiesRecipe()); final Object service = serviceRecipe.create(); SystemInstance.get().addObserver(service); logUnusedProperties(serviceRecipe, serviceInfo); final Class<?> serviceClass = service.getClass(); getContext().put(serviceClass.getName(), service); props.put(serviceClass.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); config.facilities.services.add(serviceInfo); logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
public void createService(final ServiceInfo serviceInfo) throws OpenEJBException { final ObjectRecipe serviceRecipe = createRecipe(serviceInfo); serviceRecipe.setProperty("properties", new UnsetPropertiesRecipe()); final Object service = serviceRecipe.create(); SystemInstance.get().addObserver(service); logUnusedProperties(serviceRecipe, serviceInfo); final Class<?> serviceClass = service.getClass(); getContext().put(serviceClass.getName(), service); props.put(serviceClass.getName(), service); props.put(serviceInfo.service, service); props.put(serviceInfo.id, service); config.facilities.services.add(serviceInfo); logger.getChildLogger("service").debug("createService.success", serviceInfo.service, serviceInfo.id, serviceInfo.className); }
public boolean add(final WebDeploymentListener webDeploymentListener) { // compatibility LOGGER.warning("WebDeploymentListener API is replaced by 'void afterApplicationCreated(@Observes final AfterApplicationCreated event)' API"); SystemInstance.get().addObserver(new WebDeploymentListenerObserver(webDeploymentListener)); return true; }
@Override public void init(final Properties props) throws Exception { final SystemInstance system = SystemInstance.get(); TomcatRsRegistry tomcatRestHandler = (TomcatRsRegistry) system.getComponent(RsRegistry.class); if (tomcatRestHandler == null) { tomcatRestHandler = new TomcatRsRegistry(); system.setComponent(RsRegistry.class, tomcatRestHandler); } system.addObserver(this); }
@Override public void init(final Properties props) throws Exception { final SystemInstance system = SystemInstance.get(); TomcatRsRegistry tomcatRestHandler = (TomcatRsRegistry) system.getComponent(RsRegistry.class); if (tomcatRestHandler == null) { tomcatRestHandler = new TomcatRsRegistry(); system.setComponent(RsRegistry.class, tomcatRestHandler); } system.addObserver(this); }
public static Object build(final Collection<ServiceInfo> services, final ServiceInfo info, final ObjectRecipe serviceRecipe) { if ("org.apache.openejb.config.sys.MapFactory".equals(info.className)) { return info.properties; } if (!info.properties.containsKey("properties")) { info.properties.put("properties", new UnsetPropertiesRecipe()); } // we can't ask for having a setter for existing code serviceRecipe.allow(Option.FIELD_INJECTION); serviceRecipe.allow(Option.PRIVATE_PROPERTIES); setProperties(services, info, serviceRecipe); final Object service = serviceRecipe.create(); SystemInstance.get().addObserver(service); // TODO: remove it? in all case the observer should remove itself when done Assembler.logUnusedProperties(serviceRecipe, info); return service; }
public LifecycleEventToTelemetryConverter() { HTTPProcessor.init(); SystemInstance.get().setComponent(LifecycleEventToTelemetryConverter.class, this); if (SystemInstance.get().getProperty("openejb.loader", "-").startsWith("tom")) { SystemInstance.get().addObserver(new Internal()); } }
@PostConstruct public void postConstruct() { HTTPProcessor.init(); if (store == null) { try { final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); Object o = containerSystem.getJNDIContext().lookup("openejb:Resource/" + dataStore); if (EventDataStore.class.isAssignableFrom(o.getClass())) { store = EventDataStore.class.cast(o); } } catch (NamingException e) { e.printStackTrace();// TODO: just fail no? } } if (fullHostname == null) { this.fullHostname = fullHostname(); } if (shortHostname == null) { this.shortHostname = shortHostname(); } if (ipAddress == null) { this.ipAddress = ipAddress(); } SystemInstance.get().setComponent(MetricsService.class, this); SystemInstance.get().addObserver(this); }
public void deployCore(final @Observes ContainerSystemPostCreate init) throws Exception { if (!activated) { return; } final SystemInstance systemInstance = SystemInstance.get(); // deploy our notification-core module final ConfigurationFactory configurationFactory = systemInstance.getComponent(ConfigurationFactory.class); final Assembler assembler = systemInstance.getComponent(Assembler.class); final AppInfo appInfo = configurationFactory.configureApplication(createTribestreamNotificationCoreModule()); final AppContext appContext = assembler.createApplication(appInfo); // create our observer and inject EJBs inside final AlterPersisterObserver observer = new AlterPersisterObserver( acceptedTypes == null ? Collections.<String>emptyList() : asList(acceptedTypes.split(" *, *")), pause, retries); final BeanManagerImpl bm = appContext.getWebBeansContext().getBeanManagerImpl(); final CreationalContext<?> cc = bm.createCreationalContext(null); try { // keep our life easy ;) OWBInjector.inject(bm, observer, cc); } finally { cc.release(); // cause that's just EJB so we are fine } systemInstance.addObserver(observer); activated = false; // deployed, don't redo if called again // just make it easier to get when we have a single persistence of alerts systemInstance.setComponent( AlertService.class, AlertService.class.cast( SystemInstance.get().getComponent(ContainerSystem.class).getJNDIContext().lookup("global/" + moduleName + "/AlertService"))); }
public void setupTribestreamProvider(@Observes final AssemblerCreated init) { final SystemInstance si = SystemInstance.get(); final String value = si.getProperty("openejb.provider.default", "com.tomitribe.tomee"); si.setProperty("openejb.provider.default", value); final CheckService checkService = new CheckService(); checkService.start(); SystemInstance.get().addObserver(checkService); SystemInstance.get().setComponent(CheckService.class, checkService); registerDataSourceCreators(); setDefaultCreator(); }
@Override public void start() throws ServiceException { SystemInstance.get().setComponent(RESTService.class, this); beforeStart(); containerSystem = (CoreContainerSystem) SystemInstance.get().getComponent(ContainerSystem.class); assembler = SystemInstance.get().getComponent(Assembler.class); if (assembler != null) { SystemInstance.get().addObserver(this); for (final AppInfo appInfo : assembler.getDeployedApplications()) { final AppContext appContext = containerSystem.getAppContext(appInfo.appId); afterApplicationCreated(new AssemblerAfterApplicationCreated(appInfo, appContext, null)); } } }
@Override public void start() throws ServiceException { wsRegistry = SystemInstance.get().getComponent(WsRegistry.class); if (wsRegistry == null && SystemInstance.get().getComponent(HttpListenerRegistry.class) != null) { wsRegistry = new OpenEJBHttpWsRegistry(); } if (portAddressRegistry == null) { portAddressRegistry = new PortAddressRegistryImpl(); SystemInstance.get().setComponent(PortAddressRegistry.class, portAddressRegistry); } containerSystem = (CoreContainerSystem) SystemInstance.get().getComponent(ContainerSystem.class); portAddressRegistry = SystemInstance.get().getComponent(PortAddressRegistry.class); assembler = SystemInstance.get().getComponent(Assembler.class); SystemInstance.get().setComponent(WsService.class, this); if (assembler != null) { SystemInstance.get().addObserver(this); for (final AppInfo appInfo : assembler.getDeployedApplications()) { final AppContext appContext = containerSystem.getAppContext(appInfo.appId); deploy(new AssemblerAfterApplicationCreated(appInfo, appContext, null)); } } }
@Override public void start() throws ServiceException { wsRegistry = SystemInstance.get().getComponent(WsRegistry.class); if (wsRegistry == null && SystemInstance.get().getComponent(HttpListenerRegistry.class) != null) { wsRegistry = new OpenEJBHttpWsRegistry(); } if (portAddressRegistry == null) { portAddressRegistry = new PortAddressRegistryImpl(); SystemInstance.get().setComponent(PortAddressRegistry.class, portAddressRegistry); } containerSystem = (CoreContainerSystem) SystemInstance.get().getComponent(ContainerSystem.class); portAddressRegistry = SystemInstance.get().getComponent(PortAddressRegistry.class); assembler = SystemInstance.get().getComponent(Assembler.class); SystemInstance.get().setComponent(WsService.class, this); if (assembler != null) { SystemInstance.get().addObserver(this); for (final AppInfo appInfo : assembler.getDeployedApplications()) { final AppContext appContext = containerSystem.getAppContext(appInfo.appId); deploy(new AssemblerAfterApplicationCreated(appInfo, appContext, null)); } } }